载入中...
搜索中...
未找到
PrimitivePath.cpp
浏览该文件的文档.
40void flattenQuad(glm::vec2 a, glm::vec2 control, glm::vec2 b, float tolerance, std::uint32_t depth,
53void flattenCubic(glm::vec2 a, glm::vec2 c1, glm::vec2 c2, glm::vec2 b, float tolerance, std::uint32_t depth,
170bool finite(glm::vec3 value) { return std::isfinite(value.x) && std::isfinite(value.y) && std::isfinite(value.z); }
190 return volume * volume > minimumRelativeVolumeSquared * glm::dot(a, a) * glm::dot(b, b) * glm::dot(c, c);
207 eve::DiagnosticCode::InvalidArgument, "invalid primitive dash pattern", "primitive", {}, "graphics"));
217 eve::DiagnosticCode::InvalidArgument, "primitive dash period overflow", "primitive", {}, "graphics"));
223 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, error.what(), "primitive", {}, "graphics"));
242 return finite(geometry.center) && nonZero(geometry.halfAxes[0]) && nonZero(geometry.halfAxes[1]) &&
251 return finite(geometry.center) && nonZero(geometry.normal) && nonZero(geometry.zeroDirection) &&
304 eve::DiagnosticCode::Failed, "primitive scene slot capacity exceeded", "primitive", {}, "graphics"));
310 return eve::Result<PrimitiveHandle>::success(PrimitiveHandle(owner_, index, slots_[index].generation));
344eve::Result<std::size_t> PrimitiveScene::updateMany(std::span<const PrimitiveBatchUpdate> updates) {
448 eve::DiagnosticCode::Failed, "primitive scene command budget exceeded", "primitive", {}, "graphics"));
470 if (!handle.isValid() || handle.owner() != owner_ || handle.index() >= slots_.size()) return false;
495 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "primitive proxy must not be null",
500 eve::Diagnostic::error(eve::DiagnosticCode::StaleHandle, "primitive scene owner no longer exists",
505 eve::Diagnostic::error(eve::DiagnosticCode::StaleHandle, "primitive handle is stale", "primitive", {},
511eve::Result<PrimitiveUpdateStatus> mutatePrimitive(ScriptPrimitive3D* value, Mutator&& mutator) {
519 eve::Diagnostic::error(eve::DiagnosticCode::StaleHandle, "primitive scene owner no longer exists",
536 auto projected = eve::script::projectStatusResult(vm, eve::Status::success(eve::StatusCode::Applied));
554eve::Result<std::vector<glm::vec3>> scriptPoints(ssq::Array values, std::size_t minimum, std::size_t maximum) {
557 eve::DiagnosticCode::InvalidArgument, "expected a flat xyz array with the required point count", "points",
566 eve::DiagnosticCode::InvalidArgument, error.what(), "points", {}, "graphics.primitive.binding"));
574 cls.addFunc("newPrimitiveGrid3D", [vm](Graphics* self, ssq::Array xyz, int cellsU, int cellsV, float r, float g,
587 descriptor.geometry = PrimitiveGrid3D{points[0], points[1], points[2], static_cast<std::uint32_t>(cellsU),
592 cls.addFunc("newPrimitiveArc3D", [vm](Graphics* self, ssq::Array xyz, float radius, float start, float sweep,
599 descriptor.geometry = PrimitiveArc3D{points[0], points[1], points[2], radius, start, sweep, 32};
604 [vm](Graphics* self, ssq::Array xyz, bool closed, float r, float g, float b, float a, float width) {
637 cls.addFunc("newPrimitiveDisk3D", [vm](Graphics* self, float x, float y, float z, float nx, float ny, float nz,
646 [vm](Graphics* self, float ax, float ay, float az, float bx, float by, float bz, float radius, float r,
654 cls.addFunc("newPrimitiveCapsule3D", [vm](Graphics* self, float ax, float ay, float az, float bx, float by,
672 [vm](Graphics* self, float ax, float ay, float az, float bx, float by, float bz, float headLength,
684 "setPrimitiveTransforms3D", [vm, primitiveTag](Graphics* self, ssq::Array proxies, ssq::Array matrices) {
687 vm, eve::Result<std::size_t>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument,
761 for (int row = 0; row < 4; ++row) transform[column][row] = elements.get<float>(column * 4 + row);
770 mutatePrimitive(value, [&](PrimitiveDescriptor3D& descriptor) { descriptor.transform = transform; });
787 value, [mode = *parsed](PrimitiveDescriptor3D& descriptor) { descriptor.paint.stroke.widthSpace = mode; });
823 value, [mode = *parsed](PrimitiveDescriptor3D& descriptor) { descriptor.paint.stroke.cap = mode; });
841 value, [mode = *parsed](PrimitiveDescriptor3D& descriptor) { descriptor.paint.stroke.join = mode; });
894 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "primitive proxy must not be null",
902 eve::Diagnostic::error(eve::DiagnosticCode::StaleHandle, "primitive scene owner no longer exists",
914 mutatePrimitive(value, [visible](PrimitiveDescriptor3D& descriptor) { descriptor.visible = visible; });
920 primitive.addFunc("setColor", [vm](ScriptPrimitive3D* value, float r, float g, float b, float a) {
936 primitive.addFunc("setDash", [vm](ScriptPrimitive3D* value, float drawLength, float gapLength, float phase,
942 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "dash space must be screen or world",
959 mutatePrimitive(value, [](PrimitiveDescriptor3D& descriptor) { descriptor.paint.stroke.dash.reset(); });
1003 cls.addFunc("newPrimitiveLine3D", [vm](Graphics* self, float ax, float ay, float az, float bx, float by, float bz,
1011 cls.addFunc("newPrimitiveSphere3D", [vm](Graphics* self, float x, float y, float z, float radius, float r, float g,
1033std::uint32_t resolveRadialSegments(const RadialTessellation& tessellation, float projectedRadiusPixels) {
1034 const bool validError = std::isfinite(tessellation.maxScreenErrorPixels) && tessellation.maxScreenErrorPixels > 0.f;
1037 const bool validCustom = tessellation.customSegments >= 3 && tessellation.customSegments <= 4096;
1048 EV_PARAM_CHECK(validRadius, "adaptive radial projected radius must be finite and non-negative");
1050 const float cosine = glm::clamp(1.f - tessellation.maxScreenErrorPixels / projectedRadiusPixels, -1.f, 1.f);
1087 EV_PARAM_CHECK(validFarPlane, "scene primitive far plane must be finite and greater than near plane");
EVEngine assertion entry point, backed by zeroerr.
#define EV_PARAM_CHECK(cond,...)
Validate a function parameter / public API precondition.
Definition Assert.h:30
The single Squirrel projection for common Result, Status and Value.
Explicit Value/Owned/Borrowed semantics at the Squirrel boundary.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
const Status & status() const noexcept
Inspect the structured operation status.
Definition Result.h:300
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
Definition Graphics.h:134
std::shared_ptr< PrimitiveScene > getPrimitiveScene() const noexcept
Returns the authoritative persistent spatial-primitive scene.
Definition Graphics.h:508
Path2D & quadTo(glm::vec2 control, glm::vec2 point)
Adds a quadratic Bezier segment.
Definition PrimitivePath.cpp:88
Path2D & cubicTo(glm::vec2 control1, glm::vec2 control2, glm::vec2 point)
Adds a cubic Bezier segment.
Definition PrimitivePath.cpp:98
std::vector< FlattenedContour2D > flatten(float tolerance=0.25f, std::uint32_t maxDepth=12) const
Flattens curves into owning line contours.
Definition PrimitivePath.cpp:123
void clear() noexcept
Removes all verbs and points while retaining capacity.
Definition PrimitivePath.cpp:117
Instance-qualified persistent primitive handle.
Definition PrimitiveScene.h:21
LocalHandle::index_type index_type
Definition PrimitiveScene.h:24
static constexpr index_type invalidIndex
Definition PrimitiveScene.h:27
static constexpr std::optional< generation_type > nextGeneration(generation_type current) noexcept
Next generation.
Definition PrimitiveScene.h:44
Frame-local scene recorder for 3D line primitives.
Definition PrimitiveDrawList.h:114
void drawArrow(glm::vec3 from, glm::vec3 to, float headLength, float headRadius, const ScenePrimitivePaint &paint)
Records a shaft and four-sided arrow head.
Definition PrimitiveDrawList.cpp:800
void drawSphere(glm::vec3 center, float radius, const ScenePrimitivePaint &paint, std::uint32_t segments=32)
Records three orthogonal great circles.
Definition PrimitiveDrawList.cpp:691
void drawCapsule(glm::vec3 a, glm::vec3 b, float radius, const ScenePrimitivePaint &paint, std::uint32_t segments=32)
Draws capsule.
Definition PrimitiveDrawList.cpp:743
void drawFrustum(const std::array< glm::vec3, 8 > &corners, const ScenePrimitivePaint &paint)
Draws frustum.
Definition PrimitiveDrawList.cpp:815
void drawObb(glm::vec3 center, const std::array< glm::vec3, 3 > &halfAxes, const ScenePrimitivePaint &paint)
Draws obb.
Definition PrimitiveDrawList.cpp:663
void drawGrid(glm::vec3 origin, glm::vec3 axisU, glm::vec3 axisV, std::uint32_t cellsU, std::uint32_t cellsV, const ScenePrimitivePaint &paint)
Records a planar grid spanned by two caller-provided axes.
Definition PrimitiveDrawList.cpp:673
void drawAabb(glm::vec3 minimum, glm::vec3 maximum, const ScenePrimitivePaint &paint)
Records the twelve edges of an axis-aligned box.
Definition PrimitiveDrawList.cpp:635
void drawPolyline(std::span< const glm::vec3 > points, bool closed, const ScenePrimitivePaint &paint)
Draws polyline.
Definition PrimitiveDrawList.cpp:541
void drawArc(glm::vec3 center, glm::vec3 normal, glm::vec3 zeroDirection, float radius, float startRadians, float sweepRadians, const ScenePrimitivePaint &paint, std::uint32_t segments=32)
Draws arc.
Definition PrimitiveDrawList.cpp:612
void drawCylinder(glm::vec3 a, glm::vec3 b, float radius, const ScenePrimitivePaint &paint, std::uint32_t segments=32)
Records endpoint circles and four side lines of a cylinder.
Definition PrimitiveDrawList.cpp:752
void drawDisk(glm::vec3 center, glm::vec3 normal, float radius, const ScenePrimitivePaint &paint, std::uint32_t segments=32)
Draws disk.
Definition PrimitiveDrawList.cpp:600
void drawCone(glm::vec3 apex, glm::vec3 axis, float height, float radius, const ScenePrimitivePaint &paint, std::uint32_t segments=32)
Records the base circle and four side lines of a cone.
Definition PrimitiveDrawList.cpp:776
void clear()
Invalidates all live handles while retaining slot capacity.
Definition PrimitivePath.cpp:371
void render(PrimitiveSceneCanvas3D &canvas) const
Compatibility-only wrapper over tryRender; throws on budget failure.
Definition PrimitivePath.cpp:389
eve::Result< PrimitiveRemoveStatus > remove(PrimitiveHandle handle)
Removes .
Definition PrimitivePath.cpp:325
eve::Result< PrimitiveHandle > add(PrimitiveDescriptor3D descriptor)
Adds .
Definition PrimitivePath.cpp:293
eve::Result< std::size_t > updateMany(std::span< const PrimitiveBatchUpdate > updates)
Atomically replaces several live descriptors after validating every handle.
Definition PrimitivePath.cpp:344
eve::Result< PrimitiveUpdateStatus > update(PrimitiveHandle handle, PrimitiveDescriptor3D descriptor)
Updates .
Definition PrimitivePath.cpp:313
eve::Result< void > tryRender(PrimitiveSceneCanvas3D &canvas) const
Projects visible descriptors in stable slot order using per-slot CPU caches. Successful updates inval...
Definition PrimitivePath.cpp:394
const PrimitiveDescriptor3D * tryGet(PrimitiveHandle handle) const noexcept
Resolves a live primitive handle.
Definition PrimitivePath.cpp:364
bool isStale(PrimitiveHandle handle) const noexcept
Returns true when a handle is invalid, removed, foreign, or generation-stale.
Definition PrimitivePath.cpp:369
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
@ Square
void exposePrimitiveScriptBindings(ssq::Table &table, ssq::Class &cls)
Registers owning primitive proxies on the VM owner thread; retains no table references.
Definition PrimitivePath.cpp:572
@ FillAndStroke
@ Stroke
eve::Color Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
@ ScreenPixels
@ WorldUnits
@ ScreenPixels
@ WorldUnits
std::uint32_t resolveRadialSegments(const RadialTessellation &tessellation, float projectedRadiusPixels)
Resolves a radial tessellation policy to a validated segment count.
Definition PrimitivePath.cpp:1033
@ TestAndWrite
ssq::Table projectStatusResult(HSQUIRRELVM vm, const Status &status)
Project a checked native status that carries no payload.
Definition SquirrelBinding.cpp:524
WidgetDesc row(std::vector< WidgetDesc > children, std::string id)
Horizontal elastic layout row.
Definition Widget.cpp:870
@ InvalidArgument
@ Failed
@ StaleHandle
@ Applied
@ Premultiplied
@ Additive
@ Alpha
@ Multiply
@ Opaque
Definition Container.h:602
Owning alternating draw/gap pattern for stroked primitives.
Definition PrimitiveTypes.h:48
void validate() const
Validates finite positive intervals and an even interval count.
Definition PrimitivePath.cpp:1056
One persistent scene primitive owned by PrimitiveScene.
Definition PrimitiveScene.h:141
PrimitiveGeometry3D geometry
Definition PrimitiveScene.h:142
std::size_t segmentCount
Definition PrimitiveTypes.h:113
std::size_t commandCount
Definition PrimitiveTypes.h:112
std::size_t triangleCount
Definition PrimitiveTypes.h:114
std::size_t droppedCommands
Definition PrimitiveTypes.h:118
std::size_t cacheHits
Definition PrimitiveTypes.h:117
Owning persistent polyline descriptor.
Definition PrimitiveScene.h:57
Quality and screen-error policy used by circles and curved spatial primitives.
Definition PrimitiveTypes.h:37
std::uint32_t customSegments
Definition PrimitiveTypes.h:40
float maxScreenErrorPixels
Definition PrimitiveTypes.h:39