|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
The Spine module's exported ABI — everything that does not depend on which Spine release is vendored. More...
#include "./SpineBindings.hpp"#include "./SpineRuntime.hpp"#include <algorithm>#include <cstdio>#include <cstring>#include <iterator>#include <string>#include <unordered_map>#include <vector>
Go to the source code of this file.
Macros | |
| #define | EMSCRIPTEN_KEEPALIVE |
Functions | |
| int | spine_loadSkeleton (uintptr_t skelDataPtr, int skelDataLen, uintptr_t atlasPtr, int atlasLen, int isBinary) |
| const char * | spine_getLastError () |
| void | spine_unloadSkeleton (int handle) |
| int | spine_getAtlasPageCount (int handle) |
| const char * | spine_getAtlasPageTextureName (int handle, int pageIndex) |
| void | spine_setAtlasPageTexture (int handle, int pageIndex, uint32_t textureId, int width, int height) |
| int | spine_createInstance (int skeletonHandle) |
| void | spine_destroyInstance (int instanceId) |
| void | spine_setToSetupPose (int instanceId) |
| int | spine_playAnimation (int instanceId, const char *name, int loop, int track) |
| int | spine_addAnimation (int instanceId, const char *name, int loop, float delay, int track) |
| void | spine_setSkin (int instanceId, const char *name) |
| void | spine_update (int instanceId, float dt) |
| void | spine_advanceAndApply (int instanceId, float dt) |
| void | spine_materializeWorldPose (int instanceId, float dt) |
| float | spine_getAnimationDuration (int skeletonHandle, const char *animation) |
| int | spine_requiresContinuousWorldPose (int skeletonHandle) |
| const char * | spine_getAnimations (int instanceId) |
| const char * | spine_getSkins (int instanceId) |
| int | spine_getBonePosition (int instanceId, const char *bone, uintptr_t outXPtr, uintptr_t outYPtr) |
| const char * | spine_getBones (int instanceId) |
| int | spine_getBonePoses (int instanceId, uintptr_t outPtr, int capacity) |
| float | spine_getBoneRotation (int instanceId, const char *bone) |
| void | spine_getBounds (int instanceId, uintptr_t outXPtr, uintptr_t outYPtr, uintptr_t outWPtr, uintptr_t outHPtr) |
| int | spine_getSkeletonBounds (int skeletonHandle, uintptr_t outXPtr, uintptr_t outYPtr, uintptr_t outWPtr, uintptr_t outHPtr) |
| int | spine_probe_extract (int instanceId, int stage, int useCollector) |
| void | spine_probe_counts (std::uint32_t *out) |
| int | spine_probe_clip_start (int instanceId, int stage) |
| void | spine_probe_clip_start_counts (std::uint32_t *out) |
| int | spine_clipBudget (int instanceId, std::uint32_t *out) |
| void | spine_probe_clip_storage (std::uint32_t *out) |
| int | spine_probe_pose (int instanceId, float dt, int stage) |
| void | spine_probe_pose_counts (std::uint32_t *out) |
| void | spine_probe_storage (std::uint32_t *out) |
| int | spine_getMeshBatchColorPremultiplied (int instanceId, int batchIndex) |
| int | spine_getMeshBatchCount (int instanceId) |
| int | spine_getMeshBatchVertexCount (int instanceId, int batchIndex) |
| int | spine_getMeshBatchIndexCount (int instanceId, int batchIndex) |
| void | spine_getMeshBatchData (int instanceId, int batchIndex, uintptr_t outVerticesPtr, uintptr_t outIndicesPtr, uintptr_t outTextureIdPtr, uintptr_t outBlendModePtr) |
| void | spine_setClippingEnabled (int enabled) |
| void | spine_setDefaultMix (int skeletonHandle, float duration) |
| void | spine_setMixDuration (int skeletonHandle, const char *fromAnim, const char *toAnim, float duration) |
| void | spine_setTrackAlpha (int instanceId, int track, float alpha) |
| void | spine_enableEvents (int instanceId) |
| int | spine_getEventCount (int instanceId) |
| uintptr_t | spine_getEventBuffer () |
| void | spine_clearEvents () |
| const char * | spine_getEventAnimationName (int index) |
| const char * | spine_getEventName (int index) |
| const char * | spine_getEventStringValue (int index) |
| int | spine_setAttachment (int instanceId, const char *slotName, const char *attachmentName) |
| int | spine_setIKTarget (int instanceId, const char *constraintName, float targetX, float targetY, float mix) |
| const char * | spine_listConstraints (int instanceId) |
| const char * | spine_getTransformConstraintMix (int instanceId, const char *name) |
| int | spine_setTransformConstraintMix (int instanceId, const char *name, float rotate, float x, float y, float scaleX, float scaleY, float shearY) |
| const char * | spine_getPathConstraintMix (int instanceId, const char *name) |
| int | spine_setPathConstraintMix (int instanceId, const char *name, float position, float spacing, float rotate, float x, float y) |
| int | spine_setSlotColor (int instanceId, const char *slotName, float r, float g, float b, float a) |
| int | spine_setSkeletonColor (int instanceId, float r, float g, float b, float a) |
| int | spine_runtimeVersion () |
| size_t | spine_eventBufferBytes () |
Variables | |
| static es::spine::ClipStartCounts | g_clipStartCounts {} |
The Spine module's exported ABI — everything that does not depend on which Spine release is vendored.
Pure computation: skeleton loading, animation update, mesh extraction. No GL, no filesystem. The engine core submits the batches this hands back.
Handle tables, batch packing and the readback buffers live here and are written once. The runtime itself sits behind SpineRuntime.hpp, implemented per vendored release, so adding a Spine version costs a backend rather than another branch through this file.
The same TU compiles into the native host binary, where there is no side module story: the entry points are declared in SpineBindings.hpp and reached through the QuickJS wrappers EHT generates from them.
Definition in file SpineModuleEntry.cpp.
| #define EMSCRIPTEN_KEEPALIVE |
Definition at line 32 of file SpineModuleEntry.cpp.
| int spine_addAnimation | ( | int | instanceId, |
| const char * | name, | ||
| int | loop, | ||
| float | delay, | ||
| int | track ) |
Definition at line 242 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_advanceAndApply | ( | int | instanceId, |
| float | dt ) |
Advance the animation clock and apply it to the bones' LOCAL transforms — everything an animation means, and nothing about where it is in the world. The events this produced are queued here, so a caller drains them whether or not it goes on to materialize a world pose.
Definition at line 267 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_clearEvents | ( | ) |
Definition at line 665 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_clipBudget | ( | int | instanceId, |
| std::uint32_t * | out ) |
What one instance's clipping costs THIS pose, in work not time, into eleven u32 slots: the polygon as authored, what it decomposed into, the triangles that reached the region and what became of each, and what the cut handed back. Poses and extracts, because a diagnostic pays for its own answer.
Definition at line 488 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_createInstance | ( | int | skeletonHandle | ) |
Definition at line 207 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_destroyInstance | ( | int | instanceId | ) |
Definition at line 220 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_enableEvents | ( | int | instanceId | ) |
Definition at line 644 of file SpineModuleEntry.cpp.
References g_ctx.
| size_t spine_eventBufferBytes | ( | ) |
Definition at line 814 of file SpineModuleEntry.cpp.
References g_ctx.
| float spine_getAnimationDuration | ( | int | skeletonHandle, |
| const char * | animation ) |
How long one animation runs; negative where there is no such animation.
Definition at line 285 of file SpineModuleEntry.cpp.
References g_ctx.
| const char * spine_getAnimations | ( | int | instanceId | ) |
Definition at line 300 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_getAtlasPageCount | ( | int | handle | ) |
Definition at line 187 of file SpineModuleEntry.cpp.
References g_ctx.
| const char * spine_getAtlasPageTextureName | ( | int | handle, |
| int | pageIndex ) |
Definition at line 192 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_getBonePoses | ( | int | instanceId, |
| uintptr_t | outPtr, | ||
| int | capacity ) |
Every bone's parent index and pose in one call: 5 floats a bone — parent (-1 for a root), x, y, degrees, length — into outPtr, at most capacity bones. Returns how many it wrote. One crossing for the whole tree, because an overlay asks every frame.
Definition at line 340 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_getBonePosition | ( | int | instanceId, |
| const char * | bone, | ||
| uintptr_t | outXPtr, | ||
| uintptr_t | outYPtr ) |
Definition at line 316 of file SpineModuleEntry.cpp.
References g_ctx.
| float spine_getBoneRotation | ( | int | instanceId, |
| const char * | bone ) |
Definition at line 361 of file SpineModuleEntry.cpp.
References g_ctx.
| const char * spine_getBones | ( | int | instanceId | ) |
The bone names, in the skeleton's own order — a parent before each of its children.
Definition at line 327 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_getBounds | ( | int | instanceId, |
| uintptr_t | outXPtr, | ||
| uintptr_t | outYPtr, | ||
| uintptr_t | outWPtr, | ||
| uintptr_t | outHPtr ) |
Definition at line 368 of file SpineModuleEntry.cpp.
References g_ctx.
| const char * spine_getEventAnimationName | ( | int | index | ) |
Definition at line 670 of file SpineModuleEntry.cpp.
References g_ctx.
| uintptr_t spine_getEventBuffer | ( | ) |
Definition at line 659 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_getEventCount | ( | int | instanceId | ) |
Definition at line 652 of file SpineModuleEntry.cpp.
References g_ctx.
| const char * spine_getEventName | ( | int | index | ) |
Definition at line 679 of file SpineModuleEntry.cpp.
References g_ctx.
| const char * spine_getEventStringValue | ( | int | index | ) |
Definition at line 688 of file SpineModuleEntry.cpp.
References g_ctx.
| const char * spine_getLastError | ( | ) |
Definition at line 169 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_getMeshBatchColorPremultiplied | ( | int | instanceId, |
| int | batchIndex ) |
Definition at line 572 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_getMeshBatchCount | ( | int | instanceId | ) |
Definition at line 579 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_getMeshBatchData | ( | int | instanceId, |
| int | batchIndex, | ||
| uintptr_t | outVerticesPtr, | ||
| uintptr_t | outIndicesPtr, | ||
| uintptr_t | outTextureIdPtr, | ||
| uintptr_t | outBlendModePtr ) |
Definition at line 599 of file SpineModuleEntry.cpp.
References es::skeletal::MeshBatch::blendMode, es::skeletal::Buffer< T >::data(), g_ctx, es::skeletal::MeshBatch::indices, es::skeletal::Buffer< T >::size(), es::skeletal::MeshBatch::texture, and es::skeletal::MeshBatch::vertices.
| int spine_getMeshBatchIndexCount | ( | int | instanceId, |
| int | batchIndex ) |
Definition at line 592 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_getMeshBatchVertexCount | ( | int | instanceId, |
| int | batchIndex ) |
Definition at line 585 of file SpineModuleEntry.cpp.
References g_ctx, and es::skeletal::VERTEX_FLOATS.
| const char * spine_getPathConstraintMix | ( | int | instanceId, |
| const char * | name ) |
Definition at line 770 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_getSkeletonBounds | ( | int | skeletonHandle, |
| uintptr_t | outXPtr, | ||
| uintptr_t | outYPtr, | ||
| uintptr_t | outWPtr, | ||
| uintptr_t | outHPtr ) |
The skeleton's AUTHORED extent, into four floats. Answerable from the data alone — no instance, no pose — which is what makes it usable for deciding whether a pose is worth computing. Zero and false where the runtime cannot report it.
Definition at line 382 of file SpineModuleEntry.cpp.
References g_ctx.
| const char * spine_getSkins | ( | int | instanceId | ) |
Definition at line 308 of file SpineModuleEntry.cpp.
References g_ctx.
| const char * spine_getTransformConstraintMix | ( | int | instanceId, |
| const char * | name ) |
Definition at line 750 of file SpineModuleEntry.cpp.
References g_ctx.
| const char * spine_listConstraints | ( | int | instanceId | ) |
Definition at line 715 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_loadSkeleton | ( | uintptr_t | skelDataPtr, |
| int | skelDataLen, | ||
| uintptr_t | atlasPtr, | ||
| int | atlasLen, | ||
| int | isBinary ) |
Definition at line 155 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_materializeWorldPose | ( | int | instanceId, |
| float | dt ) |
Resolve the world transforms the local pose implies. Deferring it past an advance is only equivalent where the skeleton says so — see spine_requiresContinuousWorldPose.
Definition at line 279 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_playAnimation | ( | int | instanceId, |
| const char * | name, | ||
| int | loop, | ||
| int | track ) |
Definition at line 237 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_probe_clip_start | ( | int | instanceId, |
| int | stage ) |
BENCHMARK ONLY — open the instance's first clip region to stage (es::ES_SPINE_NS::ClipStartStage), so what a 39-vertex polygon costs before a single triangle is cut can be priced without a clock inside the preparation.
Definition at line 458 of file SpineModuleEntry.cpp.
References g_clipStartCounts, and g_ctx.
| void spine_probe_clip_start_counts | ( | std::uint32_t * | out | ) |
Nine slots: five counts, then the region's bounds as four floats.
Definition at line 468 of file SpineModuleEntry.cpp.
References g_clipStartCounts.
| void spine_probe_clip_storage | ( | std::uint32_t * | out | ) |
BENCHMARK ONLY — the clipper's own scratch, into six u32 slots. Zero where a backend keeps no clipper of its own.
Definition at line 515 of file SpineModuleEntry.cpp.
| void spine_probe_counts | ( | std::uint32_t * | out | ) |
The counts of the last spine_probe_extract, into twenty-four u32 slots.
Definition at line 421 of file SpineModuleEntry.cpp.
| int spine_probe_extract | ( | int | instanceId, |
| int | stage, | ||
| int | useCollector ) |
BENCHMARK ONLY — the extraction run to stage.
useCollector 0 counts the emitted triangles and drops them, 1 stores them as a frame does; the difference at the last stage is what the collector's vectors cost. Not on any frame path: the staged walk is its own instantiation.
Definition at line 404 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_probe_pose | ( | int | instanceId, |
| float | dt, | ||
| int | stage ) |
BENCHMARK ONLY — the pose run to stage (es::ES_SPINE_NS::PoseStage). Advancing a pose is not a query: this MOVES the instance forward, so a caller measuring with it owns the instance's clock.
Definition at line 533 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_probe_pose_counts | ( | std::uint32_t * | out | ) |
The counts of the last spine_probe_pose, into nine u32 slots.
Definition at line 542 of file SpineModuleEntry.cpp.
| void spine_probe_storage | ( | std::uint32_t * | out | ) |
BENCHMARK ONLY — what the batch pool holds, into four u32 slots: slots ever opened, slots this extraction used, and the vertex floats and indices it can take without allocating again. Capacity that stops growing is what says a steady scene stopped reallocating; a wall clock can only suggest it.
Definition at line 562 of file SpineModuleEntry.cpp.
References g_ctx, es::skeletal::BatchList::Capacity::indices, es::skeletal::BatchList::Capacity::slots, and es::skeletal::BatchList::Capacity::vertexFloats.
| int spine_requiresContinuousWorldPose | ( | int | skeletonHandle | ) |
1 where this skeleton's world pose carries state and may not be deferred.
Definition at line 291 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_runtimeVersion | ( | ) |
Definition at line 806 of file SpineModuleEntry.cpp.
| void spine_setAtlasPageTexture | ( | int | handle, |
| int | pageIndex, | ||
| uint32_t | textureId, | ||
| int | width, | ||
| int | height ) |
Definition at line 197 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_setAttachment | ( | int | instanceId, |
| const char * | slotName, | ||
| const char * | attachmentName ) |
Definition at line 701 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_setClippingEnabled | ( | int | enabled | ) |
Definition at line 615 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_setDefaultMix | ( | int | skeletonHandle, |
| float | duration ) |
Definition at line 624 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_setIKTarget | ( | int | instanceId, |
| const char * | constraintName, | ||
| float | targetX, | ||
| float | targetY, | ||
| float | mix ) |
Definition at line 706 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_setMixDuration | ( | int | skeletonHandle, |
| const char * | fromAnim, | ||
| const char * | toAnim, | ||
| float | duration ) |
Definition at line 629 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_setPathConstraintMix | ( | int | instanceId, |
| const char * | name, | ||
| float | position, | ||
| float | spacing, | ||
| float | rotate, | ||
| float | x, | ||
| float | y ) |
Definition at line 783 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_setSkeletonColor | ( | int | instanceId, |
| float | r, | ||
| float | g, | ||
| float | b, | ||
| float | a ) |
Definition at line 798 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_setSkin | ( | int | instanceId, |
| const char * | name ) |
Definition at line 247 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_setSlotColor | ( | int | instanceId, |
| const char * | slotName, | ||
| float | r, | ||
| float | g, | ||
| float | b, | ||
| float | a ) |
Definition at line 790 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_setToSetupPose | ( | int | instanceId | ) |
Back to where the data says the skeleton starts — the one state a replay can be reproduced from. See es::ES_SPINE_NS::setToSetupPose.
Definition at line 232 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_setTrackAlpha | ( | int | instanceId, |
| int | track, | ||
| float | alpha ) |
Definition at line 635 of file SpineModuleEntry.cpp.
References g_ctx.
| int spine_setTransformConstraintMix | ( | int | instanceId, |
| const char * | name, | ||
| float | rotate, | ||
| float | x, | ||
| float | y, | ||
| float | scaleX, | ||
| float | scaleY, | ||
| float | shearY ) |
Definition at line 763 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_unloadSkeleton | ( | int | handle | ) |
Definition at line 174 of file SpineModuleEntry.cpp.
References g_ctx.
| void spine_update | ( | int | instanceId, |
| float | dt ) |
Definition at line 252 of file SpineModuleEntry.cpp.
References g_ctx.
|
static |
The last staged open's counts. Benchmark only; a frame never writes it.
Definition at line 450 of file SpineModuleEntry.cpp.
Referenced by spine_probe_clip_start(), and spine_probe_clip_start_counts().