diff --git a/spine-c/spine-c/include/spine/Animation.h b/spine-c/spine-c/include/spine/Animation.h index c00b98ede..a45932766 100644 --- a/spine-c/spine-c/include/spine/Animation.h +++ b/spine-c/spine-c/include/spine/Animation.h @@ -51,7 +51,7 @@ _SP_ARRAY_DECLARE_TYPE(spPropertyIdArray, spPropertyId) _SP_ARRAY_DECLARE_TYPE(spTimelineArray, spTimeline*) typedef struct spAnimation { - const char *const name; + const char *name; float duration; spTimelineArray *timelines; @@ -375,7 +375,7 @@ spRGB2Timeline_setFrame(spRGB2Timeline *self, int frameIndex, float time, float typedef struct spAttachmentTimeline { spTimeline super; int slotIndex; - const char **const attachmentNames; + const char **attachmentNames; } spAttachmentTimeline; SP_API spAttachmentTimeline *spAttachmentTimeline_create(int framesCount, int SlotIndex); @@ -388,8 +388,8 @@ spAttachmentTimeline_setFrame(spAttachmentTimeline *self, int frameIndex, float typedef struct spDeformTimeline { spCurveTimeline super; - int const frameVerticesCount; - const float **const frameVertices; + int frameVerticesCount; + const float **frameVertices; int slotIndex; spAttachment *attachment; } spDeformTimeline; @@ -418,7 +418,7 @@ SP_API void spSequenceTimeline_setFrame(spSequenceTimeline *self, int frameIndex typedef struct spEventTimeline { spTimeline super; - spEvent **const events; + spEvent **events; } spEventTimeline; SP_API spEventTimeline *spEventTimeline_create(int framesCount); @@ -429,8 +429,8 @@ SP_API void spEventTimeline_setFrame(spEventTimeline *self, int frameIndex, spEv typedef struct spDrawOrderTimeline { spTimeline super; - const int **const drawOrders; - int const slotsCount; + const int **drawOrders; + int slotsCount; } spDrawOrderTimeline; SP_API spDrawOrderTimeline *spDrawOrderTimeline_create(int framesCount, int slotsCount); diff --git a/spine-c/spine-c/include/spine/AnimationState.h b/spine-c/spine-c/include/spine/AnimationState.h index f9ab158f0..20a9fad43 100644 --- a/spine-c/spine-c/include/spine/AnimationState.h +++ b/spine-c/spine-c/include/spine/AnimationState.h @@ -83,7 +83,7 @@ struct spTrackEntry { }; struct spAnimationState { - spAnimationStateData *const data; + spAnimationStateData *data; int tracksCount; spTrackEntry **tracks; diff --git a/spine-c/spine-c/include/spine/AnimationStateData.h b/spine-c/spine-c/include/spine/AnimationStateData.h index 2a9eed76a..3ae7696a9 100644 --- a/spine-c/spine-c/include/spine/AnimationStateData.h +++ b/spine-c/spine-c/include/spine/AnimationStateData.h @@ -39,9 +39,9 @@ extern "C" { #endif typedef struct spAnimationStateData { - spSkeletonData *const skeletonData; + spSkeletonData *skeletonData; float defaultMix; - const void *const entries; + const void *entries; } spAnimationStateData; SP_API spAnimationStateData *spAnimationStateData_create(spSkeletonData *skeletonData); diff --git a/spine-c/spine-c/include/spine/Attachment.h b/spine-c/spine-c/include/spine/Attachment.h index a071d0f03..1a6de4563 100644 --- a/spine-c/spine-c/include/spine/Attachment.h +++ b/spine-c/spine-c/include/spine/Attachment.h @@ -49,9 +49,9 @@ typedef enum { } spAttachmentType; typedef struct spAttachment { - const char *const name; - const spAttachmentType type; - const void *const vtable; + const char *name; + spAttachmentType type; + const void *vtable; int refCount; struct spAttachmentLoader *attachmentLoader; } spAttachment; diff --git a/spine-c/spine-c/include/spine/AttachmentLoader.h b/spine-c/spine-c/include/spine/AttachmentLoader.h index 7c4874f21..12bacbf3a 100644 --- a/spine-c/spine-c/include/spine/AttachmentLoader.h +++ b/spine-c/spine-c/include/spine/AttachmentLoader.h @@ -43,7 +43,7 @@ typedef struct spAttachmentLoader { const char *error1; const char *error2; - const void *const vtable; + const void *vtable; } spAttachmentLoader; SP_API void spAttachmentLoader_dispose(spAttachmentLoader *self); diff --git a/spine-c/spine-c/include/spine/Bone.h b/spine-c/spine-c/include/spine/Bone.h index 6bf2818cd..bd1bc0653 100644 --- a/spine-c/spine-c/include/spine/Bone.h +++ b/spine-c/spine-c/include/spine/Bone.h @@ -32,6 +32,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -41,19 +42,21 @@ struct spSkeleton; typedef struct spBone spBone; struct spBone { - spBoneData *const data; - struct spSkeleton *const skeleton; - spBone *const parent; + spBoneData *data; + struct spSkeleton *skeleton; + spBone *parent; int childrenCount; - spBone **const children; + spBone **children; float x, y, rotation, scaleX, scaleY, shearX, shearY; float ax, ay, arotation, ascaleX, ascaleY, ashearX, ashearY; - float const a, b, worldX; - float const c, d, worldY; + float a, b, worldX; + float c, d, worldY; int/*bool*/ sorted; int/*bool*/ active; + + spInherit inherit; }; SP_API void spBone_setYDown(int/*bool*/yDown); @@ -86,8 +89,12 @@ SP_API void spBone_updateAppliedTransform(spBone *self); SP_API void spBone_worldToLocal(spBone *self, float worldX, float worldY, float *localX, float *localY); +SP_API void spBone_worldToParent(spBone *self, float worldX, float worldY, float *parentX, float *parentY); + SP_API void spBone_localToWorld(spBone *self, float localX, float localY, float *worldX, float *worldY); +SP_API void spBone_localToParent(spBone *self, float localX, float localY, float *parentX, float *parentY); + SP_API float spBone_worldToLocalRotation(spBone *self, float worldRotation); SP_API float spBone_localToWorldRotation(spBone *self, float localRotation); diff --git a/spine-c/spine-c/include/spine/BoneData.h b/spine-c/spine-c/include/spine/BoneData.h index 39152c29d..7f0289b1c 100644 --- a/spine-c/spine-c/include/spine/BoneData.h +++ b/spine-c/spine-c/include/spine/BoneData.h @@ -38,23 +38,25 @@ extern "C" { #endif typedef enum { - SP_TRANSFORMMODE_NORMAL, - SP_TRANSFORMMODE_ONLYTRANSLATION, - SP_TRANSFORMMODE_NOROTATIONORREFLECTION, - SP_TRANSFORMMODE_NOSCALE, - SP_TRANSFORMMODE_NOSCALEORREFLECTION -} spTransformMode; + SP_INHERIT_NORMAL, + SP_INHERIT_ONLYTRANSLATION, + SP_INHERIT_NOROTATIONORREFLECTION, + SP_INHERIT_NOSCALE, + SP_INHERIT_NOSCALEORREFLECTION +} spInherit; typedef struct spBoneData spBoneData; struct spBoneData { - const int index; - const char *const name; - spBoneData *const parent; + int index; + const char *name; + spBoneData *parent; float length; float x, y, rotation, scaleX, scaleY, shearX, shearY; - spTransformMode transformMode; + spInherit inherit; int/*bool*/ skinRequired; spColor color; + const char *icon; + int/*bool*/ visible; }; SP_API spBoneData *spBoneData_create(int index, const char *name, spBoneData *parent); diff --git a/spine-c/spine-c/include/spine/Event.h b/spine-c/spine-c/include/spine/Event.h index 97456b7d4..ecb8cbda8 100644 --- a/spine-c/spine-c/include/spine/Event.h +++ b/spine-c/spine-c/include/spine/Event.h @@ -38,8 +38,8 @@ extern "C" { #endif typedef struct spEvent { - spEventData *const data; - float const time; + spEventData *data; + float time; int intValue; float floatValue; const char *stringValue; diff --git a/spine-c/spine-c/include/spine/EventData.h b/spine-c/spine-c/include/spine/EventData.h index 178a2abe1..0dd7d4c2b 100644 --- a/spine-c/spine-c/include/spine/EventData.h +++ b/spine-c/spine-c/include/spine/EventData.h @@ -37,7 +37,7 @@ extern "C" { #endif typedef struct spEventData { - const char *const name; + const char *name; int intValue; float floatValue; const char *stringValue; diff --git a/spine-c/spine-c/include/spine/IkConstraint.h b/spine-c/spine-c/include/spine/IkConstraint.h index 78f3694dc..0f6b9a898 100644 --- a/spine-c/spine-c/include/spine/IkConstraint.h +++ b/spine-c/spine-c/include/spine/IkConstraint.h @@ -41,7 +41,7 @@ extern "C" { struct spSkeleton; typedef struct spIkConstraint { - spIkConstraintData *const data; + spIkConstraintData *data; int bonesCount; spBone **bones; diff --git a/spine-c/spine-c/include/spine/IkConstraintData.h b/spine-c/spine-c/include/spine/IkConstraintData.h index 13f86bec1..e769647be 100644 --- a/spine-c/spine-c/include/spine/IkConstraintData.h +++ b/spine-c/spine-c/include/spine/IkConstraintData.h @@ -38,7 +38,7 @@ extern "C" { #endif typedef struct spIkConstraintData { - const char *const name; + const char *name; int order; int /*boolean*/ skinRequired; int bonesCount; diff --git a/spine-c/spine-c/include/spine/MeshAttachment.h b/spine-c/spine-c/include/spine/MeshAttachment.h index 21d8f25c8..eb950f883 100644 --- a/spine-c/spine-c/include/spine/MeshAttachment.h +++ b/spine-c/spine-c/include/spine/MeshAttachment.h @@ -61,7 +61,7 @@ struct spMeshAttachment { int hullLength; - spMeshAttachment *const parentMesh; + spMeshAttachment *parentMesh; /* Nonessential. */ int edgesCount; diff --git a/spine-c/spine-c/include/spine/PathConstraint.h b/spine-c/spine-c/include/spine/PathConstraint.h index a5c9ba721..2b190bfda 100644 --- a/spine-c/spine-c/include/spine/PathConstraint.h +++ b/spine-c/spine-c/include/spine/PathConstraint.h @@ -43,9 +43,9 @@ extern "C" { struct spSkeleton; typedef struct spPathConstraint { - spPathConstraintData *const data; + spPathConstraintData *data; int bonesCount; - spBone **const bones; + spBone **bones; spSlot *target; float position, spacing; float mixRotate, mixX, mixY; diff --git a/spine-c/spine-c/include/spine/PathConstraintData.h b/spine-c/spine-c/include/spine/PathConstraintData.h index 5177b7a7e..6b7d76f22 100644 --- a/spine-c/spine-c/include/spine/PathConstraintData.h +++ b/spine-c/spine-c/include/spine/PathConstraintData.h @@ -51,11 +51,11 @@ typedef enum { } spRotateMode; typedef struct spPathConstraintData { - const char *const name; + const char *name; int order; int/*bool*/ skinRequired; int bonesCount; - spBoneData **const bones; + spBoneData **bones; spSlotData *target; spPositionMode positionMode; spSpacingMode spacingMode; diff --git a/spine-c/spine-c/include/spine/Physics.h b/spine-c/spine-c/include/spine/Physics.h new file mode 100644 index 000000000..bd088543d --- /dev/null +++ b/spine-c/spine-c/include/spine/Physics.h @@ -0,0 +1,48 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#ifndef SPINE_PHYSICS_H_ +#define SPINE_PHYSICS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + SP_PHYSICS_NONE, + SP_PHYSICS_RESET, + SP_PHYSICS_UPDATE, + SP_PHYSICS_POSE +} spPhysics; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/spine-c/spine-c/include/spine/Skeleton.h b/spine-c/spine-c/include/spine/Skeleton.h index c20db56d7..36adfb76b 100644 --- a/spine-c/spine-c/include/spine/Skeleton.h +++ b/spine-c/spine-c/include/spine/Skeleton.h @@ -43,11 +43,11 @@ extern "C" { #endif typedef struct spSkeleton { - spSkeletonData *const data; + spSkeletonData *data; int bonesCount; spBone **bones; - spBone *const root; + spBone *root; int slotsCount; spSlot **slots; @@ -62,10 +62,12 @@ typedef struct spSkeleton { int pathConstraintsCount; spPathConstraint **pathConstraints; - spSkin *const skin; + spSkin *skin; spColor color; float scaleX, scaleY; float x, y; + + float time; } spSkeleton; SP_API spSkeleton *spSkeleton_create(spSkeletonData *data); @@ -76,7 +78,9 @@ SP_API void spSkeleton_dispose(spSkeleton *self); * are added or removed. */ SP_API void spSkeleton_updateCache(spSkeleton *self); -SP_API void spSkeleton_updateWorldTransform(const spSkeleton *self); +SP_API void spSkeleton_updateWorldTransform(const spSkeleton *self, spPhysics physics); + +SP_API void spSkeleton_update(spSkeleton *self, float delta); /* Sets the bones, constraints, and slots to their setup pose values. */ SP_API void spSkeleton_setToSetupPose(const spSkeleton *self); diff --git a/spine-c/spine-c/include/spine/SkeletonBinary.h b/spine-c/spine-c/include/spine/SkeletonBinary.h index 89669c212..8379fe829 100644 --- a/spine-c/spine-c/include/spine/SkeletonBinary.h +++ b/spine-c/spine-c/include/spine/SkeletonBinary.h @@ -45,7 +45,7 @@ struct spAtlasAttachmentLoader; typedef struct spSkeletonBinary { float scale; spAttachmentLoader *attachmentLoader; - const char *const error; + const char *error; } spSkeletonBinary; SP_API spSkeletonBinary *spSkeletonBinary_createWithLoader(spAttachmentLoader *attachmentLoader); diff --git a/spine-c/spine-c/include/spine/SkeletonBounds.h b/spine-c/spine-c/include/spine/SkeletonBounds.h index facac8f52..f9db02ea9 100644 --- a/spine-c/spine-c/include/spine/SkeletonBounds.h +++ b/spine-c/spine-c/include/spine/SkeletonBounds.h @@ -39,7 +39,7 @@ extern "C" { #endif typedef struct spPolygon { - float *const vertices; + float *vertices; int count; int capacity; } spPolygon; diff --git a/spine-c/spine-c/include/spine/SkeletonJson.h b/spine-c/spine-c/include/spine/SkeletonJson.h index ac2caf9ed..7ad75e518 100644 --- a/spine-c/spine-c/include/spine/SkeletonJson.h +++ b/spine-c/spine-c/include/spine/SkeletonJson.h @@ -46,7 +46,7 @@ struct spAtlasAttachmentLoader; typedef struct spSkeletonJson { float scale; spAttachmentLoader *attachmentLoader; - const char *const error; + const char *error; } spSkeletonJson; SP_API spSkeletonJson *spSkeletonJson_createWithLoader(spAttachmentLoader *attachmentLoader); diff --git a/spine-c/spine-c/include/spine/Skin.h b/spine-c/spine-c/include/spine/Skin.h index d1dfe903e..7659d76a6 100644 --- a/spine-c/spine-c/include/spine/Skin.h +++ b/spine-c/spine-c/include/spine/Skin.h @@ -55,7 +55,7 @@ _SP_ARRAY_DECLARE_TYPE(spTransformConstraintDataArray, spTransformConstraintData _SP_ARRAY_DECLARE_TYPE(spPathConstraintDataArray, spPathConstraintData*) typedef struct spSkin { - const char *const name; + const char *name; spBoneDataArray *bones; spIkConstraintDataArray *ikConstraints; diff --git a/spine-c/spine-c/include/spine/Slot.h b/spine-c/spine-c/include/spine/Slot.h index ce4161057..e29664b67 100644 --- a/spine-c/spine-c/include/spine/Slot.h +++ b/spine-c/spine-c/include/spine/Slot.h @@ -40,8 +40,8 @@ extern "C" { #endif typedef struct spSlot { - spSlotData *const data; - spBone *const bone; + spSlotData *data; + spBone *bone; spColor color; spColor *darkColor; spAttachment *attachment; diff --git a/spine-c/spine-c/include/spine/SlotData.h b/spine-c/spine-c/include/spine/SlotData.h index 603097c1e..b04cd35b4 100644 --- a/spine-c/spine-c/include/spine/SlotData.h +++ b/spine-c/spine-c/include/spine/SlotData.h @@ -43,9 +43,9 @@ typedef enum { } spBlendMode; typedef struct spSlotData { - const int index; - const char *const name; - const spBoneData *const boneData; + int index; + const char *name; + const spBoneData *boneData; const char *attachmentName; spColor color; spColor *darkColor; diff --git a/spine-c/spine-c/include/spine/TransformConstraint.h b/spine-c/spine-c/include/spine/TransformConstraint.h index 364ec86d9..db8e8d340 100644 --- a/spine-c/spine-c/include/spine/TransformConstraint.h +++ b/spine-c/spine-c/include/spine/TransformConstraint.h @@ -41,9 +41,9 @@ extern "C" { struct spSkeleton; typedef struct spTransformConstraint { - spTransformConstraintData *const data; + spTransformConstraintData *data; int bonesCount; - spBone **const bones; + spBone **bones; spBone *target; float mixRotate, mixX, mixY, mixScaleX, mixScaleY, mixShearY; int /*boolean*/ active; diff --git a/spine-c/spine-c/include/spine/TransformConstraintData.h b/spine-c/spine-c/include/spine/TransformConstraintData.h index 65e6899d9..7e2321432 100644 --- a/spine-c/spine-c/include/spine/TransformConstraintData.h +++ b/spine-c/spine-c/include/spine/TransformConstraintData.h @@ -38,11 +38,11 @@ extern "C" { #endif typedef struct spTransformConstraintData { - const char *const name; + const char *name; int order; int/*bool*/ skinRequired; int bonesCount; - spBoneData **const bones; + spBoneData **bones; spBoneData *target; float mixRotate, mixX, mixY, mixScaleX, mixScaleY, mixShearY; float offsetRotation, offsetX, offsetY, offsetScaleX, offsetScaleY, offsetShearY; diff --git a/spine-c/spine-c/include/spine/extension.h b/spine-c/spine-c/include/spine/extension.h index f5d723bec..11aa28677 100644 --- a/spine-c/spine-c/include/spine/extension.h +++ b/spine-c/spine-c/include/spine/extension.h @@ -81,9 +81,6 @@ /* Cast to a sub class. Not type safe, use with care. */ #define SUB_CAST(TYPE, VALUE) ((TYPE*)VALUE) -/* Casts away const. Can be used as an lvalue. Not type safe, use with care. */ -#define CONST_CAST(TYPE, VALUE) (*(TYPE*)&VALUE) - /* Gets the vtable for the specified type. Not type safe, use with care. */ #define VTABLE(TYPE, VALUE) ((_##TYPE##Vtable*)((TYPE*)VALUE)->vtable) @@ -91,7 +88,7 @@ #define FREE(VALUE) _spFree((void*)VALUE) /* Allocates a new char[], assigns it to TO, and copies FROM to it. Can be used on const types. */ -#define MALLOC_STR(TO, FROM) strcpy(CONST_CAST(char*, TO) = (char*)MALLOC(char, strlen(FROM) + 1), FROM) +#define MALLOC_STR(TO, FROM) strcpy(TO = (char*)MALLOC(char, strlen(FROM) + 1), FROM) #define PI 3.1415926535897932385f #define PI2 (PI * 2) diff --git a/spine-c/spine-c/include/spine/spine.h b/spine-c/spine-c/include/spine/spine.h index 9a17b95cd..2ab8b94ee 100644 --- a/spine-c/spine-c/include/spine/spine.h +++ b/spine-c/spine-c/include/spine/spine.h @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include diff --git a/spine-c/spine-c/src/spine/Animation.c b/spine-c/spine-c/src/spine/Animation.c index ea670cff5..ef90f6536 100644 --- a/spine-c/spine-c/src/spine/Animation.c +++ b/spine-c/spine-c/src/spine/Animation.c @@ -1679,7 +1679,7 @@ spAttachmentTimeline *spAttachmentTimeline_create(int framesCount, int slotIndex ids[0] = ((spPropertyId) SP_PROPERTY_ATTACHMENT << 32) | slotIndex; _spTimeline_init(SUPER(self), framesCount, 1, ids, 1, SP_TIMELINE_ATTACHMENT, _spAttachmentTimeline_dispose, _spAttachmentTimeline_apply, 0); - CONST_CAST(char **, self->attachmentNames) = CALLOC(char *, framesCount); + self->attachmentNames = CALLOC(char *, framesCount); self->slotIndex = slotIndex; return self; } @@ -1983,8 +1983,8 @@ spDeformTimeline *spDeformTimeline_create(int framesCount, int frameVerticesCoun ids[0] = ((spPropertyId) SP_PROPERTY_DEFORM << 32) | ((slotIndex << 16 | attachment->id) & 0xffffffff); _spCurveTimeline_init(SUPER(self), framesCount, 1, bezierCount, ids, 1, SP_TIMELINE_DEFORM, _spDeformTimeline_dispose, _spDeformTimeline_apply, _spDeformTimeline_setBezier); - CONST_CAST(float **, self->frameVertices) = CALLOC(float *, framesCount); - CONST_CAST(int, self->frameVerticesCount) = frameVerticesCount; + self->frameVertices = CALLOC(float *, framesCount); + self->frameVerticesCount = frameVerticesCount; self->slotIndex = slotIndex; self->attachment = SUPER(attachment); return self; @@ -1998,7 +1998,7 @@ void spDeformTimeline_setFrame(spDeformTimeline *self, int frame, float time, fl self->frameVertices[frame] = 0; else { self->frameVertices[frame] = MALLOC(float, self->frameVerticesCount); - memcpy(CONST_CAST(float *, self->frameVertices[frame]), vertices, self->frameVerticesCount * sizeof(float)); + memcpy(self->frameVertices[frame], vertices, self->frameVerticesCount * sizeof(float)); } } @@ -2171,7 +2171,7 @@ spEventTimeline *spEventTimeline_create(int framesCount) { ids[0] = (spPropertyId) SP_PROPERTY_EVENT << 32; _spTimeline_init(SUPER(self), framesCount, 1, ids, 1, SP_TIMELINE_EVENT, _spEventTimeline_dispose, _spEventTimeline_apply, 0); - CONST_CAST(spEvent **, self->events) = CALLOC(spEvent *, framesCount); + self->events = CALLOC(spEvent *, framesCount); return self; } @@ -2234,8 +2234,8 @@ spDrawOrderTimeline *spDrawOrderTimeline_create(int framesCount, int slotsCount) _spTimeline_init(SUPER(self), framesCount, 1, ids, 1, SP_TIMELINE_DRAWORDER, _spDrawOrderTimeline_dispose, _spDrawOrderTimeline_apply, 0); - CONST_CAST(int **, self->drawOrders) = CALLOC(int *, framesCount); - CONST_CAST(int, self->slotsCount) = slotsCount; + self->drawOrders = CALLOC(int *, framesCount); + self->slotsCount = slotsCount; return self; } @@ -2248,7 +2248,7 @@ void spDrawOrderTimeline_setFrame(spDrawOrderTimeline *self, int frame, float ti self->drawOrders[frame] = 0; else { self->drawOrders[frame] = MALLOC(int, self->slotsCount); - memcpy(CONST_CAST(int *, self->drawOrders[frame]), drawOrder, self->slotsCount * sizeof(int)); + memcpy( self->drawOrders[frame], drawOrder, self->slotsCount * sizeof(int)); } } diff --git a/spine-c/spine-c/src/spine/AnimationState.c b/spine-c/spine-c/src/spine/AnimationState.c index 216323456..47a0b08b5 100644 --- a/spine-c/spine-c/src/spine/AnimationState.c +++ b/spine-c/spine-c/src/spine/AnimationState.c @@ -251,7 +251,7 @@ spAnimationState *spAnimationState_create(spAnimationStateData *data) { internal = NEW(_spAnimationState); self = SUPER(internal); - CONST_CAST(spAnimationStateData *, self->data) = data; + self->data = data; self->timeScale = 1; internal->queue = _spEventQueue_create(internal); diff --git a/spine-c/spine-c/src/spine/AnimationStateData.c b/spine-c/spine-c/src/spine/AnimationStateData.c index 92ed455a2..45d931884 100644 --- a/spine-c/spine-c/src/spine/AnimationStateData.c +++ b/spine-c/spine-c/src/spine/AnimationStateData.c @@ -71,7 +71,7 @@ void _FromEntry_dispose(_FromEntry *self) { spAnimationStateData *spAnimationStateData_create(spSkeletonData *skeletonData) { spAnimationStateData *self = NEW(spAnimationStateData); - CONST_CAST(spSkeletonData *, self->skeletonData) = skeletonData; + self->skeletonData = skeletonData; return self; } @@ -128,7 +128,7 @@ void spAnimationStateData_setMix(spAnimationStateData *self, spAnimation *from, if (!fromEntry) { fromEntry = _FromEntry_create(from); fromEntry->next = (_FromEntry *) self->entries; - CONST_CAST(_FromEntry *, self->entries) = fromEntry; + self->entries = fromEntry; } toEntry = _ToEntry_create(to, duration); toEntry->next = fromEntry->toEntries; diff --git a/spine-c/spine-c/src/spine/Atlas.c b/spine-c/spine-c/src/spine/Atlas.c index 717a09de6..e579299d0 100644 --- a/spine-c/spine-c/src/spine/Atlas.c +++ b/spine-c/spine-c/src/spine/Atlas.c @@ -97,7 +97,7 @@ spKeyValue spKeyValueArray_peek(spKeyValueArray *self) { return self->items[self spAtlasPage *spAtlasPage_create(spAtlas *atlas, const char *name) { spAtlasPage *self = NEW(spAtlasPage); - CONST_CAST(spAtlas *, self->atlas) = atlas; + self->atlas = atlas; MALLOC_STR(self->name, name); self->minFilter = SP_ATLAS_NEAREST; self->magFilter = SP_ATLAS_NEAREST; diff --git a/spine-c/spine-c/src/spine/Attachment.c b/spine-c/spine-c/src/spine/Attachment.c index 43a7806d3..2a560299b 100644 --- a/spine-c/spine-c/src/spine/Attachment.c +++ b/spine-c/spine-c/src/spine/Attachment.c @@ -40,12 +40,12 @@ typedef struct _spAttachmentVtable { void _spAttachment_init(spAttachment *self, const char *name, spAttachmentType type, /**/ void (*dispose)(spAttachment *self), spAttachment *(*copy)(spAttachment *self)) { - CONST_CAST(_spAttachmentVtable *, self->vtable) = NEW(_spAttachmentVtable); + self->vtable = NEW(_spAttachmentVtable); VTABLE(spAttachment, self)->dispose = dispose; VTABLE(spAttachment, self)->copy = copy; MALLOC_STR(self->name, name); - CONST_CAST(spAttachmentType, self->type) = type; + self->type = type; } void _spAttachment_deinit(spAttachment *self) { diff --git a/spine-c/spine-c/src/spine/AttachmentLoader.c b/spine-c/spine-c/src/spine/AttachmentLoader.c index 85f4cfb73..9bb1001eb 100644 --- a/spine-c/spine-c/src/spine/AttachmentLoader.c +++ b/spine-c/spine-c/src/spine/AttachmentLoader.c @@ -49,7 +49,7 @@ void _spAttachmentLoader_init(spAttachmentLoader *self, const char *path, spSequence *sequence), void (*configureAttachment)(spAttachmentLoader *self, spAttachment *), void (*disposeAttachment)(spAttachmentLoader *self, spAttachment *)) { - CONST_CAST(_spAttachmentLoaderVtable *, self->vtable) = NEW(_spAttachmentLoaderVtable); + self->vtable = NEW(_spAttachmentLoaderVtable); VTABLE(spAttachmentLoader, self)->dispose = dispose; VTABLE(spAttachmentLoader, self)->createAttachment = createAttachment; VTABLE(spAttachmentLoader, self)->configureAttachment = configureAttachment; diff --git a/spine-c/spine-c/src/spine/Bone.c b/spine-c/spine-c/src/spine/Bone.c index 09272cc3f..3737dae4d 100644 --- a/spine-c/spine-c/src/spine/Bone.c +++ b/spine-c/spine-c/src/spine/Bone.c @@ -43,11 +43,13 @@ int spBone_isYDown(void) { spBone *spBone_create(spBoneData *data, spSkeleton *skeleton, spBone *parent) { spBone *self = NEW(spBone); - CONST_CAST(spBoneData *, self->data) = data; - CONST_CAST(spSkeleton *, self->skeleton) = skeleton; - CONST_CAST(spBone *, self->parent) = parent; - CONST_CAST(float, self->a) = 1.0f; - CONST_CAST(float, self->d) = 1.0f; + self->data = data; + self->skeleton = skeleton; + self->parent = parent; + self->a = 1.0f; + self->d = 1.0f; + self->active = -1; + self->inherit = SP_INHERIT_NORMAL; spBone_setToSetupPose(self); return self; } @@ -68,8 +70,8 @@ void spBone_updateWorldTransform(spBone *self) { void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY) { - float cosine, sine; - float pa, pb, pc, pd; + float cosine, sine; + float pa, pb, pc, pd; spBone *parent = self->parent; float sx = self->skeleton->scaleX; float sy = self->skeleton->scaleY * (spBone_isYDown() ? -1 : 1); @@ -84,12 +86,12 @@ void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotat if (!parent) { /* Root bone. */ float rotationY = rotation + 90 + shearY; - CONST_CAST(float, self->a) = COS_DEG(rotation + shearX) * scaleX * sx; - CONST_CAST(float, self->b) = COS_DEG(rotationY) * scaleY * sx; - CONST_CAST(float, self->c) = SIN_DEG(rotation + shearX) * scaleX * sy; - CONST_CAST(float, self->d) = SIN_DEG(rotationY) * scaleY * sy; - CONST_CAST(float, self->worldX) = x * sx + self->skeleton->x; - CONST_CAST(float, self->worldY) = y * sy + self->skeleton->y; + self->a = COS_DEG(rotation + shearX) * scaleX * sx; + self->b = COS_DEG(rotationY) * scaleY * sx; + self->c = SIN_DEG(rotation + shearX) * scaleX * sy; + self->d = SIN_DEG(rotationY) * scaleY * sy; + self->worldX = x * sx + self->skeleton->x; + self->worldY = y * sy + self->skeleton->y; return; } @@ -98,31 +100,31 @@ void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotat pc = parent->c; pd = parent->d; - CONST_CAST(float, self->worldX) = pa * x + pb * y + parent->worldX; - CONST_CAST(float, self->worldY) = pc * x + pd * y + parent->worldY; + self->worldX = pa * x + pb * y + parent->worldX; + self->worldY = pc * x + pd * y + parent->worldY; - switch (self->data->transformMode) { - case SP_TRANSFORMMODE_NORMAL: { + switch (self->data->inherit) { + case SP_INHERIT_NORMAL: { float rotationY = rotation + 90 + shearY; float la = COS_DEG(rotation + shearX) * scaleX; float lb = COS_DEG(rotationY) * scaleY; float lc = SIN_DEG(rotation + shearX) * scaleX; float ld = SIN_DEG(rotationY) * scaleY; - CONST_CAST(float, self->a) = pa * la + pb * lc; - CONST_CAST(float, self->b) = pa * lb + pb * ld; - CONST_CAST(float, self->c) = pc * la + pd * lc; - CONST_CAST(float, self->d) = pc * lb + pd * ld; + self->a = pa * la + pb * lc; + self->b = pa * lb + pb * ld; + self->c = pc * la + pd * lc; + self->d = pc * lb + pd * ld; return; } - case SP_TRANSFORMMODE_ONLYTRANSLATION: { + case SP_INHERIT_ONLYTRANSLATION: { float rotationY = rotation + 90 + shearY; - CONST_CAST(float, self->a) = COS_DEG(rotation + shearX) * scaleX; - CONST_CAST(float, self->b) = COS_DEG(rotationY) * scaleY; - CONST_CAST(float, self->c) = SIN_DEG(rotation + shearX) * scaleX; - CONST_CAST(float, self->d) = SIN_DEG(rotationY) * scaleY; + self->a = COS_DEG(rotation + shearX) * scaleX; + self->b = COS_DEG(rotationY) * scaleY; + self->c = SIN_DEG(rotation + shearX) * scaleX; + self->d = SIN_DEG(rotationY) * scaleY; break; } - case SP_TRANSFORMMODE_NOROTATIONORREFLECTION: { + case SP_INHERIT_NOROTATIONORREFLECTION: { float s = pa * pa + pc * pc; float prx, rx, ry, la, lb, lc, ld; if (s > 0.0001f) { @@ -143,14 +145,14 @@ void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotat lb = COS_DEG(ry) * scaleY; lc = SIN_DEG(rx) * scaleX; ld = SIN_DEG(ry) * scaleY; - CONST_CAST(float, self->a) = pa * la - pb * lc; - CONST_CAST(float, self->b) = pa * lb - pb * ld; - CONST_CAST(float, self->c) = pc * la + pd * lc; - CONST_CAST(float, self->d) = pc * lb + pd * ld; + self->a = pa * la - pb * lc; + self->b = pa * lb - pb * ld; + self->c = pc * la + pd * lc; + self->d = pc * lb + pd * ld; break; } - case SP_TRANSFORMMODE_NOSCALE: - case SP_TRANSFORMMODE_NOSCALEORREFLECTION: { + case SP_INHERIT_NOSCALE: + case SP_INHERIT_NOSCALEORREFLECTION: { float za, zc, s; float r, zb, zd, la, lb, lc, ld; cosine = COS_DEG(rotation); @@ -162,7 +164,7 @@ void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotat za *= s; zc *= s; s = SQRT(za * za + zc * zc); - if (self->data->transformMode == SP_TRANSFORMMODE_NOSCALE && (pa * pd - pb * pc < 0) != (sx < 0 != sy < 0)) + if (self->data->inherit == SP_INHERIT_NOSCALE && (pa * pd - pb * pc < 0) != (sx < 0 != sy < 0)) s = -s; r = PI / 2 + ATAN2(zc, za); zb = COS(r) * s; @@ -171,17 +173,17 @@ void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotat lb = COS_DEG(90 + shearY) * scaleY; lc = SIN_DEG(shearX) * scaleX; ld = SIN_DEG(90 + shearY) * scaleY; - CONST_CAST(float, self->a) = za * la + zb * lc; - CONST_CAST(float, self->b) = za * lb + zb * ld; - CONST_CAST(float, self->c) = zc * la + zd * lc; - CONST_CAST(float, self->d) = zc * lb + zd * ld; + self->a = za * la + zb * lc; + self->b = za * lb + zb * ld; + self->c = zc * la + zd * lc; + self->d = zc * lb + zd * ld; } } - CONST_CAST(float, self->a) *= sx; - CONST_CAST(float, self->b) *= sx; - CONST_CAST(float, self->c) *= sy; - CONST_CAST(float, self->d) *= sy; + self->a *= sx; + self->b *= sx; + self->c *= sy; + self->d *= sy; } void spBone_setToSetupPose(spBone *self) { @@ -242,14 +244,14 @@ void spBone_updateAppliedTransform(spBone *self) { self->ax = (dx * ia - dy * ib); self->ay = (dy * id - dx * ic); - if (self->data->transformMode == SP_TRANSFORMMODE_ONLYTRANSLATION) { + if (self->data->inherit == SP_INHERIT_ONLYTRANSLATION) { ra = self->a; rb = self->b; rc = self->c; rd = self->d; } else { - switch (self->data->transformMode) { - case SP_TRANSFORMMODE_NOROTATIONORREFLECTION: { + switch (self->data->inherit) { + case SP_INHERIT_NOROTATIONORREFLECTION: { s = ABS(pa * pd - pb * pc) / (pa * pa + pc * pc); sa = pa / self->skeleton->scaleX; sc = pc / self->skeleton->scaleY; @@ -260,8 +262,8 @@ void spBone_updateAppliedTransform(spBone *self) { ib = pb * pid; break; } - case SP_TRANSFORMMODE_NOSCALE: - case SP_TRANSFORMMODE_NOSCALEORREFLECTION: { + case SP_INHERIT_NOSCALE: + case SP_INHERIT_NOSCALEORREFLECTION: { cosine = COS_DEG(self->rotation), sine = SIN_DEG(self->rotation); pa = (pa * cosine + pb * sine) / self->skeleton->scaleX; pc = (pc * cosine + pd * sine) / self->skeleton->scaleY; @@ -270,7 +272,7 @@ void spBone_updateAppliedTransform(spBone *self) { pa *= s; pc *= s; s = SQRT(pa * pa + pc * pc); - if (self->data->transformMode == SP_TRANSFORMMODE_NOSCALE && + if (self->data->inherit == SP_INHERIT_NOSCALE && pid < 0 != (self->skeleton->scaleX < 0 != self->skeleton->scaleY < 0)) s = -s; r = PI / 2 + ATAN2(pc, pa); @@ -283,8 +285,8 @@ void spBone_updateAppliedTransform(spBone *self) { id = pa * pid; break; } - case SP_TRANSFORMMODE_ONLYTRANSLATION: - case SP_TRANSFORMMODE_NORMAL: + case SP_INHERIT_ONLYTRANSLATION: + case SP_INHERIT_NORMAL: break; } ra = ia * self->a - ib * self->c; @@ -340,8 +342,8 @@ float spBone_localToWorldRotation(spBone *self, float localRotation) { void spBone_rotateWorld(spBone *self, float degrees) { float a = self->a, b = self->b, c = self->c, d = self->d; float cosine = COS_DEG(degrees), sine = SIN_DEG(degrees); - CONST_CAST(float, self->a) = cosine * a - sine * c; - CONST_CAST(float, self->b) = cosine * b - sine * d; - CONST_CAST(float, self->c) = sine * a + cosine * c; - CONST_CAST(float, self->d) = sine * b + cosine * d; + self->a = cosine * a - sine * c; + self->b = cosine * b - sine * d; + self->c = sine * a + cosine * c; + self->d = sine * b + cosine * d; } diff --git a/spine-c/spine-c/src/spine/BoneData.c b/spine-c/spine-c/src/spine/BoneData.c index c256d6f02..0c11ede05 100644 --- a/spine-c/spine-c/src/spine/BoneData.c +++ b/spine-c/spine-c/src/spine/BoneData.c @@ -32,16 +32,19 @@ spBoneData *spBoneData_create(int index, const char *name, spBoneData *parent) { spBoneData *self = NEW(spBoneData); - CONST_CAST(int, self->index) = index; + self->index = index; MALLOC_STR(self->name, name); - CONST_CAST(spBoneData *, self->parent) = parent; + self->parent = parent; self->scaleX = 1; self->scaleY = 1; - self->transformMode = SP_TRANSFORMMODE_NORMAL; - return self; + self->inherit = SP_INHERIT_NORMAL; + self->icon = NULL; + self->visible = -1; + return self; } void spBoneData_dispose(spBoneData *self) { FREE(self->name); + FREE(self->icon); FREE(self); } diff --git a/spine-c/spine-c/src/spine/Event.c b/spine-c/spine-c/src/spine/Event.c index f37cf5d7e..34782bf2e 100644 --- a/spine-c/spine-c/src/spine/Event.c +++ b/spine-c/spine-c/src/spine/Event.c @@ -32,8 +32,8 @@ spEvent *spEvent_create(float time, spEventData *data) { spEvent *self = NEW(spEvent); - CONST_CAST(spEventData *, self->data) = data; - CONST_CAST(float, self->time) = time; + self->data = data; + self->time = time; return self; } diff --git a/spine-c/spine-c/src/spine/IkConstraint.c b/spine-c/spine-c/src/spine/IkConstraint.c index bdd58af5c..7ef900aea 100644 --- a/spine-c/spine-c/src/spine/IkConstraint.c +++ b/spine-c/spine-c/src/spine/IkConstraint.c @@ -36,7 +36,7 @@ spIkConstraint *spIkConstraint_create(spIkConstraintData *data, const spSkeleton int i; spIkConstraint *self = NEW(spIkConstraint); - CONST_CAST(spIkConstraintData *, self->data) = data; + self->data = data; self->bendDirection = data->bendDirection; self->compress = data->compress; self->stretch = data->stretch; @@ -78,12 +78,12 @@ void spIkConstraint_apply1(spBone *bone, float targetX, float targetY, int /*boo float rotationIK = -bone->ashearX - bone->arotation; float tx = 0, ty = 0, sx = 0, sy = 0, s = 0, sa = 0, sc = 0; - switch (bone->data->transformMode) { - case SP_TRANSFORMMODE_ONLYTRANSLATION: + switch (bone->data->inherit) { + case SP_INHERIT_ONLYTRANSLATION: tx = (targetX - bone->worldX) * SIGNUM(bone->skeleton->scaleX); ty = (targetY - bone->worldY) * SIGNUM(bone->skeleton->scaleY); break; - case SP_TRANSFORMMODE_NOROTATIONORREFLECTION: { + case SP_INHERIT_NOROTATIONORREFLECTION: { s = ABS(pa * pd - pb * pc) / MAX(0.0001f, pa * pa + pc * pc); sa = pa / bone->skeleton->scaleX; sc = pc / bone->skeleton->scaleY; @@ -113,9 +113,9 @@ void spIkConstraint_apply1(spBone *bone, float targetX, float targetY, int /*boo sy = bone->ascaleY; if (compress || stretch) { float b, dd; - switch (bone->data->transformMode) { - case SP_TRANSFORMMODE_NOSCALE: - case SP_TRANSFORMMODE_NOSCALEORREFLECTION: + switch (bone->data->inherit) { + case SP_INHERIT_NOSCALE: + case SP_INHERIT_NOSCALEORREFLECTION: tx = targetX - bone->worldX; ty = targetY - bone->worldY; default:; diff --git a/spine-c/spine-c/src/spine/MeshAttachment.c b/spine-c/spine-c/src/spine/MeshAttachment.c index e62c074c2..25cb6071f 100644 --- a/spine-c/spine-c/src/spine/MeshAttachment.c +++ b/spine-c/spine-c/src/spine/MeshAttachment.c @@ -166,7 +166,7 @@ void spMeshAttachment_updateRegion(spMeshAttachment *self) { } void spMeshAttachment_setParentMesh(spMeshAttachment *self, spMeshAttachment *parentMesh) { - CONST_CAST(spMeshAttachment *, self->parentMesh) = parentMesh; + self->parentMesh = parentMesh; if (parentMesh) { self->super.bones = parentMesh->super.bones; self->super.bonesCount = parentMesh->super.bonesCount; diff --git a/spine-c/spine-c/src/spine/PathConstraint.c b/spine-c/spine-c/src/spine/PathConstraint.c index a9514c5d4..61b0842bc 100644 --- a/spine-c/spine-c/src/spine/PathConstraint.c +++ b/spine-c/spine-c/src/spine/PathConstraint.c @@ -39,9 +39,9 @@ spPathConstraint *spPathConstraint_create(spPathConstraintData *data, const spSkeleton *skeleton) { int i; spPathConstraint *self = NEW(spPathConstraint); - CONST_CAST(spPathConstraintData *, self->data) = data; + self->data = data; self->bonesCount = data->bonesCount; - CONST_CAST(spBone **, self->bones) = MALLOC(spBone *, self->bonesCount); + self->bones = MALLOC(spBone *, self->bonesCount); for (i = 0; i < self->bonesCount; ++i) self->bones[i] = spSkeleton_findBone(skeleton, self->data->bones[i]->name); self->target = spSkeleton_findSlot(skeleton, self->data->target->name); @@ -179,15 +179,15 @@ void spPathConstraint_update(spPathConstraint *self) { } for (i = 0, p = 3; i < boneCount; i++, p += 3) { spBone *bone = bones[i]; - CONST_CAST(float, bone->worldX) += (boneX - bone->worldX) * mixX; - CONST_CAST(float, bone->worldY) += (boneY - bone->worldY) * mixY; + bone->worldX += (boneX - bone->worldX) * mixX; + bone->worldY += (boneY - bone->worldY) * mixY; x = positions[p], y = positions[p + 1], dx = x - boneX, dy = y - boneY; if (scale) { length = lengths[i]; if (length != 0) { s = (SQRT(dx * dx + dy * dy) / length - 1) * mixRotate + 1; - CONST_CAST(float, bone->a) *= s; - CONST_CAST(float, bone->c) *= s; + bone->a *= s; + bone->c *= s; } } boneX = x; @@ -216,10 +216,10 @@ void spPathConstraint_update(spPathConstraint *self) { r *= mixRotate; cosine = COS(r); sine = SIN(r); - CONST_CAST(float, bone->a) = cosine * a - sine * c; - CONST_CAST(float, bone->b) = cosine * b - sine * d; - CONST_CAST(float, bone->c) = sine * a + cosine * c; - CONST_CAST(float, bone->d) = sine * b + cosine * d; + bone->a = cosine * a - sine * c; + bone->b = cosine * b - sine * d; + bone->c = sine * a + cosine * c; + bone->d = sine * b + cosine * d; } spBone_updateAppliedTransform(bone); } diff --git a/spine-c/spine-c/src/spine/Skeleton.c b/spine-c/spine-c/src/spine/Skeleton.c index 0aa2a8507..a1d428b43 100644 --- a/spine-c/spine-c/src/spine/Skeleton.c +++ b/spine-c/spine-c/src/spine/Skeleton.c @@ -58,7 +58,7 @@ spSkeleton *spSkeleton_create(spSkeletonData *data) { _spSkeleton *internal = NEW(_spSkeleton); spSkeleton *self = SUPER(internal); - CONST_CAST(spSkeletonData *, self->data) = data; + self->data = data; self->bonesCount = self->data->bonesCount; self->bones = MALLOC(spBone *, self->bonesCount); @@ -79,7 +79,7 @@ spSkeleton *spSkeleton_create(spSkeletonData *data) { for (i = 0; i < self->bonesCount; ++i) { spBoneData *boneData = self->data->bones[i]; spBone *bone = self->bones[i]; - CONST_CAST(spBone **, bone->children) = MALLOC(spBone *, childrenCounts[boneData->index]); + bone->children = MALLOC(spBone *, childrenCounts[boneData->index]); } for (i = 0; i < self->bonesCount; ++i) { spBone *bone = self->bones[i]; @@ -87,7 +87,7 @@ spSkeleton *spSkeleton_create(spSkeletonData *data) { if (parent) parent->children[parent->childrenCount++] = bone; } - CONST_CAST(spBone *, self->root) = (self->bonesCount > 0 ? self->bones[0] : NULL); + self->root = (self->bonesCount > 0 ? self->bones[0] : NULL); self->slotsCount = data->slotsCount; self->slots = MALLOC(spSlot *, self->slotsCount); @@ -120,6 +120,8 @@ spSkeleton *spSkeleton_create(spSkeletonData *data) { self->scaleX = 1; self->scaleY = 1; + self->time = 0; + spSkeleton_updateCache(self); FREE(childrenCounts); @@ -399,7 +401,7 @@ continue_outer: _sortBone(internal, self->bones[i]); } -void spSkeleton_updateWorldTransform(const spSkeleton *self) { +void spSkeleton_updateWorldTransform(const spSkeleton *self, spPhysics physics) { int i, n; _spSkeleton *internal = SUB_CAST(_spSkeleton, self); @@ -433,6 +435,10 @@ void spSkeleton_updateWorldTransform(const spSkeleton *self) { } } +void spSkeleton_update(spSkeleton *self, float delta) { + self->time += delta; +} + void spSkeleton_updateWorldTransformWith(const spSkeleton *self, const spBone *parent) { /* Apply the parent bone transform to the root bone. The root bone always inherits scale, rotation and reflection. */ int i; @@ -440,18 +446,18 @@ void spSkeleton_updateWorldTransformWith(const spSkeleton *self, const spBone *p _spSkeleton *internal = SUB_CAST(_spSkeleton, self); spBone *rootBone = self->root; float pa = parent->a, pb = parent->b, pc = parent->c, pd = parent->d; - CONST_CAST(float, rootBone->worldX) = pa * self->x + pb * self->y + parent->worldX; - CONST_CAST(float, rootBone->worldY) = pc * self->x + pd * self->y + parent->worldY; + rootBone->worldX = pa * self->x + pb * self->y + parent->worldX; + rootBone->worldY = pc * self->x + pd * self->y + parent->worldY; rotationY = rootBone->rotation + 90 + rootBone->shearY; la = COS_DEG(rootBone->rotation + rootBone->shearX) * rootBone->scaleX; lb = COS_DEG(rotationY) * rootBone->scaleY; lc = SIN_DEG(rootBone->rotation + rootBone->shearX) * rootBone->scaleX; ld = SIN_DEG(rotationY) * rootBone->scaleY; - CONST_CAST(float, rootBone->a) = (pa * la + pb * lc) * self->scaleX; - CONST_CAST(float, rootBone->b) = (pa * lb + pb * ld) * self->scaleX; - CONST_CAST(float, rootBone->c) = (pc * la + pd * lc) * self->scaleY; - CONST_CAST(float, rootBone->d) = (pc * lb + pd * ld) * self->scaleY; + rootBone->a = (pa * la + pb * lc) * self->scaleX; + rootBone->b = (pa * lb + pb * ld) * self->scaleX; + rootBone->c = (pc * la + pd * lc) * self->scaleY; + rootBone->d = (pc * lb + pd * ld) * self->scaleY; /* Update everything except root bone. */ for (i = 0; i < internal->updateCacheCount; ++i) { @@ -564,7 +570,7 @@ void spSkeleton_setSkin(spSkeleton *self, spSkin *newSkin) { } } } - CONST_CAST(spSkin *, self->skin) = newSkin; + self->skin = newSkin; spSkeleton_updateCache(self); } diff --git a/spine-c/spine-c/src/spine/SkeletonBinary.c b/spine-c/spine-c/src/spine/SkeletonBinary.c index eb89e1c9c..2ca5653f4 100644 --- a/spine-c/spine-c/src/spine/SkeletonBinary.c +++ b/spine-c/spine-c/src/spine/SkeletonBinary.c @@ -1319,7 +1319,7 @@ spSkeletonData *spSkeletonBinary_readSkeletonData(spSkeletonBinary *self, const input->end = binary + length; FREE(self->error); - CONST_CAST(char *, self->error) = 0; + self->error = 0; internal->linkedMeshCount = 0; skeletonData = spSkeletonData_create(); @@ -1391,19 +1391,19 @@ spSkeletonData *spSkeletonBinary_readSkeletonData(spSkeletonBinary *self, const mode = readVarint(input, 1); switch (mode) { case 0: - data->transformMode = SP_TRANSFORMMODE_NORMAL; + data->inherit = SP_INHERIT_NORMAL; break; case 1: - data->transformMode = SP_TRANSFORMMODE_ONLYTRANSLATION; + data->inherit = SP_INHERIT_ONLYTRANSLATION; break; case 2: - data->transformMode = SP_TRANSFORMMODE_NOROTATIONORREFLECTION; + data->inherit = SP_INHERIT_NOROTATIONORREFLECTION; break; case 3: - data->transformMode = SP_TRANSFORMMODE_NOSCALE; + data->inherit = SP_INHERIT_NOSCALE; break; case 4: - data->transformMode = SP_TRANSFORMMODE_NOSCALEORREFLECTION; + data->inherit = SP_INHERIT_NOSCALEORREFLECTION; break; } data->skinRequired = readBoolean(input); @@ -1477,7 +1477,7 @@ spSkeletonData *spSkeletonBinary_readSkeletonData(spSkeletonBinary *self, const data->skinRequired = readBoolean(input); FREE(name); data->bonesCount = readVarint(input, 1); - CONST_CAST(spBoneData **, data->bones) = MALLOC(spBoneData *, data->bonesCount); + data->bones = MALLOC(spBoneData *, data->bonesCount); for (ii = 0; ii < data->bonesCount; ++ii) data->bones[ii] = skeletonData->bones[readVarint(input, 1)]; data->target = skeletonData->bones[readVarint(input, 1)]; @@ -1509,7 +1509,7 @@ spSkeletonData *spSkeletonBinary_readSkeletonData(spSkeletonBinary *self, const data->skinRequired = readBoolean(input); FREE(name); data->bonesCount = readVarint(input, 1); - CONST_CAST(spBoneData **, data->bones) = MALLOC(spBoneData *, data->bonesCount); + data->bones = MALLOC(spBoneData *, data->bonesCount); for (ii = 0; ii < data->bonesCount; ++ii) data->bones[ii] = skeletonData->bones[readVarint(input, 1)]; data->target = skeletonData->slots[readVarint(input, 1)]; diff --git a/spine-c/spine-c/src/spine/SkeletonBounds.c b/spine-c/spine-c/src/spine/SkeletonBounds.c index e6517651e..61b7bed7b 100644 --- a/spine-c/spine-c/src/spine/SkeletonBounds.c +++ b/spine-c/spine-c/src/spine/SkeletonBounds.c @@ -34,7 +34,7 @@ spPolygon *spPolygon_create(int capacity) { spPolygon *self = NEW(spPolygon); self->capacity = capacity; - CONST_CAST(float *, self->vertices) = MALLOC(float, capacity); + self->vertices = MALLOC(float, capacity); return self; } diff --git a/spine-c/spine-c/src/spine/SkeletonJson.c b/spine-c/spine-c/src/spine/SkeletonJson.c index 434a758fb..529f5256c 100644 --- a/spine-c/spine-c/src/spine/SkeletonJson.c +++ b/spine-c/spine-c/src/spine/SkeletonJson.c @@ -971,7 +971,7 @@ spSkeletonData *spSkeletonJson_readSkeletonData(spSkeletonJson *self, const char _spSkeletonJson *internal = SUB_CAST(_spSkeletonJson, self); FREE(self->error); - CONST_CAST(char *, self->error) = 0; + self->error = 0; internal->linkedMeshCount = 0; root = Json_create(json); @@ -1040,16 +1040,16 @@ spSkeletonData *spSkeletonJson_readSkeletonData(spSkeletonJson *self, const char data->shearX = Json_getFloat(boneMap, "shearX", 0); data->shearY = Json_getFloat(boneMap, "shearY", 0); transformMode = Json_getString(boneMap, "transform", "normal"); - data->transformMode = SP_TRANSFORMMODE_NORMAL; - if (strcmp(transformMode, "normal") == 0) data->transformMode = SP_TRANSFORMMODE_NORMAL; + data->inherit = SP_INHERIT_NORMAL; + if (strcmp(transformMode, "normal") == 0) data->inherit = SP_INHERIT_NORMAL; else if (strcmp(transformMode, "onlyTranslation") == 0) - data->transformMode = SP_TRANSFORMMODE_ONLYTRANSLATION; + data->inherit = SP_INHERIT_ONLYTRANSLATION; else if (strcmp(transformMode, "noRotationOrReflection") == 0) - data->transformMode = SP_TRANSFORMMODE_NOROTATIONORREFLECTION; + data->inherit = SP_INHERIT_NOROTATIONORREFLECTION; else if (strcmp(transformMode, "noScale") == 0) - data->transformMode = SP_TRANSFORMMODE_NOSCALE; + data->inherit = SP_INHERIT_NOSCALE; else if (strcmp(transformMode, "noScaleOrReflection") == 0) - data->transformMode = SP_TRANSFORMMODE_NOSCALEORREFLECTION; + data->inherit = SP_INHERIT_NOSCALEORREFLECTION; data->skinRequired = Json_getInt(boneMap, "skin", 0) ? 1 : 0; color = Json_getString(boneMap, "color", 0); @@ -1177,7 +1177,7 @@ spSkeletonData *spSkeletonJson_readSkeletonData(spSkeletonJson *self, const char boneMap = Json_getItem(constraintMap, "bones"); data->bonesCount = boneMap->size; - CONST_CAST(spBoneData **, data->bones) = MALLOC(spBoneData *, boneMap->size); + data->bones = MALLOC(spBoneData *, boneMap->size); for (boneMap = boneMap->child, ii = 0; boneMap; boneMap = boneMap->next, ++ii) { data->bones[ii] = spSkeletonData_findBone(skeletonData, boneMap->valueString); if (!data->bones[ii]) { @@ -1231,7 +1231,7 @@ spSkeletonData *spSkeletonJson_readSkeletonData(spSkeletonJson *self, const char boneMap = Json_getItem(constraintMap, "bones"); data->bonesCount = boneMap->size; - CONST_CAST(spBoneData **, data->bones) = MALLOC(spBoneData *, boneMap->size); + data->bones = MALLOC(spBoneData *, boneMap->size); for (boneMap = boneMap->child, ii = 0; boneMap; boneMap = boneMap->next, ++ii) { data->bones[ii] = spSkeletonData_findBone(skeletonData, boneMap->valueString); if (!data->bones[ii]) { diff --git a/spine-c/spine-c/src/spine/Slot.c b/spine-c/spine-c/src/spine/Slot.c index 75ea24524..140ab9dc9 100644 --- a/spine-c/spine-c/src/spine/Slot.c +++ b/spine-c/spine-c/src/spine/Slot.c @@ -32,8 +32,8 @@ spSlot *spSlot_create(spSlotData *data, spBone *bone) { spSlot *self = NEW(spSlot); - CONST_CAST(spSlotData *, self->data) = data; - CONST_CAST(spBone *, self->bone) = bone; + self->data = data; + self->bone = bone; spColor_setFromFloats(&self->color, 1, 1, 1, 1); self->darkColor = data->darkColor == 0 ? 0 : spColor_create(); spSlot_setToSetupPose(self); @@ -67,7 +67,7 @@ void spSlot_setAttachment(spSlot *self, spAttachment *attachment) { self->deformCount = 0; } - CONST_CAST(spAttachment *, self->attachment) = attachment; + self->attachment = attachment; self->sequenceIndex = -1; } @@ -80,7 +80,7 @@ void spSlot_setToSetupPose(spSlot *self) { else { spAttachment *attachment = spSkeleton_getAttachmentForSlotIndex( self->bone->skeleton, self->data->index, self->data->attachmentName); - CONST_CAST(spAttachment *, self->attachment) = 0; + self->attachment = 0; spSlot_setAttachment(self, attachment); } } diff --git a/spine-c/spine-c/src/spine/SlotData.c b/spine-c/spine-c/src/spine/SlotData.c index 84edd4397..b4ae58588 100644 --- a/spine-c/spine-c/src/spine/SlotData.c +++ b/spine-c/spine-c/src/spine/SlotData.c @@ -32,9 +32,9 @@ spSlotData *spSlotData_create(const int index, const char *name, spBoneData *boneData) { spSlotData *self = NEW(spSlotData); - CONST_CAST(int, self->index) = index; + self->index = index; MALLOC_STR(self->name, name); - CONST_CAST(spBoneData *, self->boneData) = boneData; + self->boneData = boneData; spColor_setFromFloats(&self->color, 1, 1, 1, 1); return self; } @@ -51,5 +51,5 @@ void spSlotData_setAttachmentName(spSlotData *self, const char *attachmentName) if (attachmentName) MALLOC_STR(self->attachmentName, attachmentName); else - CONST_CAST(char *, self->attachmentName) = 0; + self->attachmentName = 0; } diff --git a/spine-c/spine-c/src/spine/TransformConstraint.c b/spine-c/spine-c/src/spine/TransformConstraint.c index ff426c331..059347e73 100644 --- a/spine-c/spine-c/src/spine/TransformConstraint.c +++ b/spine-c/spine-c/src/spine/TransformConstraint.c @@ -34,7 +34,7 @@ spTransformConstraint *spTransformConstraint_create(spTransformConstraintData *data, const spSkeleton *skeleton) { int i; spTransformConstraint *self = NEW(spTransformConstraint); - CONST_CAST(spTransformConstraintData *, self->data) = data; + self->data = data; self->mixRotate = data->mixRotate; self->mixX = data->mixX; self->mixY = data->mixY; @@ -42,7 +42,7 @@ spTransformConstraint *spTransformConstraint_create(spTransformConstraintData *d self->mixScaleY = data->mixScaleY; self->mixShearY = data->mixShearY; self->bonesCount = data->bonesCount; - CONST_CAST(spBone **, self->bones) = MALLOC(spBone *, self->bonesCount); + self->bones = MALLOC(spBone *, self->bonesCount); for (i = 0; i < self->bonesCount; ++i) self->bones[i] = spSkeleton_findBone(skeleton, self->data->bones[i]->name); self->target = spSkeleton_findBone(skeleton, self->data->target->name); @@ -77,29 +77,29 @@ void _spTransformConstraint_applyAbsoluteWorld(spTransformConstraint *self) { r *= mixRotate; cosine = COS(r); sine = SIN(r); - CONST_CAST(float, bone->a) = cosine * a - sine * c; - CONST_CAST(float, bone->b) = cosine * b - sine * d; - CONST_CAST(float, bone->c) = sine * a + cosine * c; - CONST_CAST(float, bone->d) = sine * b + cosine * d; + bone->a = cosine * a - sine * c; + bone->b = cosine * b - sine * d; + bone->c = sine * a + cosine * c; + bone->d = sine * b + cosine * d; } if (translate) { spBone_localToWorld(target, self->data->offsetX, self->data->offsetY, &x, &y); - CONST_CAST(float, bone->worldX) += (x - bone->worldX) * mixX; - CONST_CAST(float, bone->worldY) += (y - bone->worldY) * mixY; + bone->worldX += (x - bone->worldX) * mixX; + bone->worldY += (y - bone->worldY) * mixY; } if (mixScaleX > 0) { s = SQRT(bone->a * bone->a + bone->c * bone->c); if (s != 0) s = (s + (SQRT(ta * ta + tc * tc) - s + self->data->offsetScaleX) * mixScaleX) / s; - CONST_CAST(float, bone->a) *= s; - CONST_CAST(float, bone->c) *= s; + bone->a *= s; + bone->c *= s; } if (mixScaleY != 0) { s = SQRT(bone->b * bone->b + bone->d * bone->d); if (s != 0) s = (s + (SQRT(tb * tb + td * td) - s + self->data->offsetScaleY) * mixScaleY) / s; - CONST_CAST(float, bone->b) *= s; - CONST_CAST(float, bone->d) *= s; + bone->b *= s; + bone->d *= s; } if (mixShearY > 0) { @@ -111,8 +111,8 @@ void _spTransformConstraint_applyAbsoluteWorld(spTransformConstraint *self) { else if (r < -PI) r += PI2; r = by + (r + offsetShearY) * mixShearY; - CONST_CAST(float, bone->b) = COS(r) * s; - CONST_CAST(float, bone->d) = SIN(r) * s; + bone->b = COS(r) * s; + bone->d = SIN(r) * s; } spBone_updateAppliedTransform(bone); } @@ -141,27 +141,27 @@ void _spTransformConstraint_applyRelativeWorld(spTransformConstraint *self) { r *= mixRotate; cosine = COS(r); sine = SIN(r); - CONST_CAST(float, bone->a) = cosine * a - sine * c; - CONST_CAST(float, bone->b) = cosine * b - sine * d; - CONST_CAST(float, bone->c) = sine * a + cosine * c; - CONST_CAST(float, bone->d) = sine * b + cosine * d; + bone->a = cosine * a - sine * c; + bone->b = cosine * b - sine * d; + bone->c = sine * a + cosine * c; + bone->d = sine * b + cosine * d; } if (translate != 0) { spBone_localToWorld(target, self->data->offsetX, self->data->offsetY, &x, &y); - CONST_CAST(float, bone->worldX) += (x * mixX); - CONST_CAST(float, bone->worldY) += (y * mixY); + bone->worldX += (x * mixX); + bone->worldY += (y * mixY); } if (mixScaleX != 0) { s = (SQRT(ta * ta + tc * tc) - 1 + self->data->offsetScaleX) * mixScaleX + 1; - CONST_CAST(float, bone->a) *= s; - CONST_CAST(float, bone->c) *= s; + bone->a *= s; + bone->c *= s; } if (mixScaleY > 0) { s = (SQRT(tb * tb + td * td) - 1 + self->data->offsetScaleY) * mixScaleY + 1; - CONST_CAST(float, bone->b) *= s; - CONST_CAST(float, bone->d) *= s; + bone->b *= s; + bone->d *= s; } if (mixShearY > 0) { @@ -172,8 +172,8 @@ void _spTransformConstraint_applyRelativeWorld(spTransformConstraint *self) { b = bone->b, d = bone->d; r = ATAN2(d, b) + (r - PI / 2 + offsetShearY) * mixShearY; s = SQRT(b * b + d * d); - CONST_CAST(float, bone->b) = COS(r) * s; - CONST_CAST(float, bone->d) = SIN(r) * s; + bone->b = COS(r) * s; + bone->d = SIN(r) * s; } spBone_updateAppliedTransform(bone); diff --git a/spine-sfml/c/example/main.cpp b/spine-sfml/c/example/main.cpp index 9419ad044..3004c6a4d 100644 --- a/spine-sfml/c/example/main.cpp +++ b/spine-sfml/c/example/main.cpp @@ -126,7 +126,7 @@ void spineboy(spSkeletonData *skeletonData, spAtlas *atlas) { skeleton->x = 320; skeleton->y = 590; - spSkeleton_updateWorldTransform(skeleton); + spSkeleton_updateWorldTransform(skeleton, SP_PHYSICS_UPDATE); spSlot *headSlot = spSkeleton_findSlot(skeleton, "head"); @@ -156,7 +156,7 @@ void spineboy(spSkeletonData *skeletonData, spAtlas *atlas) { headSlot->color.b = 1; } - drawable->update(delta); + drawable->update(delta, SP_PHYSICS_UPDATE); window.clear(); window.draw(*drawable); @@ -208,7 +208,7 @@ void ikDemo(spSkeletonData *skeletonData, spAtlas *atlas) { // then calculate the world transforms of every bone. // This is needed so we can call Bone#worldToLocal() // later. - drawable->update(delta); + drawable->update(delta, SP_PHYSICS_UPDATE); // Position the "crosshair" bone at the mouse // location. We do this before calling @@ -231,7 +231,7 @@ void ikDemo(spSkeletonData *skeletonData, spAtlas *atlas) { // Calculate final world transform with the // crosshair bone set to the mouse cursor // position. - spSkeleton_updateWorldTransform(drawable->skeleton); + spSkeleton_updateWorldTransform(drawable->skeleton, SP_PHYSICS_UPDATE); window.clear(); window.draw(*drawable); @@ -250,7 +250,7 @@ void goblins(spSkeletonData *skeletonData, spAtlas *atlas) { spSkeleton_setSlotsToSetupPose(skeleton); skeleton->x = 320; skeleton->y = 590; - spSkeleton_updateWorldTransform(skeleton); + spSkeleton_updateWorldTransform(skeleton, SP_PHYSICS_UPDATE); spAnimationState_setAnimationByName(drawable->state, 0, "walk", true); @@ -265,7 +265,7 @@ void goblins(spSkeletonData *skeletonData, spAtlas *atlas) { float delta = deltaClock.getElapsedTime().asSeconds(); deltaClock.restart(); - drawable->update(delta); + drawable->update(delta, SP_PHYSICS_UPDATE); window.clear(); window.draw(*drawable); @@ -282,7 +282,7 @@ void raptor(spSkeletonData *skeletonData, spAtlas *atlas) { spSkeleton *skeleton = drawable->skeleton; skeleton->x = 320; skeleton->y = 590; - spSkeleton_updateWorldTransform(skeleton); + spSkeleton_updateWorldTransform(skeleton, SP_PHYSICS_UPDATE); spAnimationState_setAnimationByName(drawable->state, 0, "walk", true); spAnimationState_addAnimationByName(drawable->state, 1, "gun-grab", false, 2); @@ -298,7 +298,7 @@ void raptor(spSkeletonData *skeletonData, spAtlas *atlas) { float delta = deltaClock.getElapsedTime().asSeconds(); deltaClock.restart(); - drawable->update(delta); + drawable->update(delta, SP_PHYSICS_UPDATE); window.clear(); window.draw(*drawable); @@ -315,7 +315,7 @@ void tank(spSkeletonData *skeletonData, spAtlas *atlas) { spSkeleton *skeleton = drawable->skeleton; skeleton->x = 500; skeleton->y = 590; - spSkeleton_updateWorldTransform(skeleton); + spSkeleton_updateWorldTransform(skeleton, SP_PHYSICS_UPDATE); spAnimationState_setAnimationByName(drawable->state, 0, "drive", true); @@ -330,7 +330,7 @@ void tank(spSkeletonData *skeletonData, spAtlas *atlas) { float delta = deltaClock.getElapsedTime().asSeconds(); deltaClock.restart(); - drawable->update(delta); + drawable->update(delta, SP_PHYSICS_UPDATE); window.clear(); window.draw(*drawable); window.display(); @@ -346,7 +346,7 @@ void vine(spSkeletonData *skeletonData, spAtlas *atlas) { spSkeleton *skeleton = drawable->skeleton; skeleton->x = 320; skeleton->y = 590; - spSkeleton_updateWorldTransform(skeleton); + spSkeleton_updateWorldTransform(skeleton, SP_PHYSICS_UPDATE); spAnimationState_setAnimationByName(drawable->state, 0, "grow", true); @@ -361,7 +361,7 @@ void vine(spSkeletonData *skeletonData, spAtlas *atlas) { float delta = deltaClock.getElapsedTime().asSeconds(); deltaClock.restart(); - drawable->update(delta); + drawable->update(delta, SP_PHYSICS_UPDATE); window.clear(); window.draw(*drawable); @@ -378,7 +378,7 @@ void stretchyman(spSkeletonData *skeletonData, spAtlas *atlas) { spSkeleton *skeleton = drawable->skeleton; skeleton->x = 100; skeleton->y = 590; - spSkeleton_updateWorldTransform(skeleton); + spSkeleton_updateWorldTransform(skeleton, SP_PHYSICS_UPDATE); spAnimationState_setAnimationByName(drawable->state, 0, "sneak", true); @@ -393,7 +393,7 @@ void stretchyman(spSkeletonData *skeletonData, spAtlas *atlas) { float delta = deltaClock.getElapsedTime().asSeconds(); deltaClock.restart(); - drawable->update(delta); + drawable->update(delta, SP_PHYSICS_UPDATE); window.clear(); window.draw(*drawable); @@ -412,7 +412,7 @@ void coin(spSkeletonData *skeletonData, spAtlas *atlas) { spSkeleton *skeleton = drawable->skeleton; skeleton->x = 320; skeleton->y = 320; - spSkeleton_updateWorldTransform(skeleton); + spSkeleton_updateWorldTransform(skeleton, SP_PHYSICS_UPDATE); spAnimationState_setAnimationByName(drawable->state, 0, "animation", true); sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - vine"); @@ -427,7 +427,7 @@ void coin(spSkeletonData *skeletonData, spAtlas *atlas) { float delta = deltaClock.getElapsedTime().asSeconds(); deltaClock.restart(); - drawable->update(delta); + drawable->update(delta, SP_PHYSICS_UPDATE); window.clear(); window.draw(*drawable); @@ -446,7 +446,7 @@ void dragon(spSkeletonData *skeletonData, spAtlas *atlas) { spSkeleton *skeleton = drawable->skeleton; skeleton->x = 320; skeleton->y = 320; - spSkeleton_updateWorldTransform(skeleton); + spSkeleton_updateWorldTransform(skeleton, SP_PHYSICS_UPDATE); spAnimationState_setAnimationByName(drawable->state, 0, "flying", true); sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - dragon"); @@ -461,7 +461,7 @@ void dragon(spSkeletonData *skeletonData, spAtlas *atlas) { float delta = deltaClock.getElapsedTime().asSeconds(); deltaClock.restart(); - drawable->update(delta); + drawable->update(delta, SP_PHYSICS_UPDATE); window.clear(); window.draw(*drawable); @@ -478,7 +478,7 @@ void owl(spSkeletonData *skeletonData, spAtlas *atlas) { spSkeleton *skeleton = drawable->skeleton; skeleton->x = 320; skeleton->y = 400; - spSkeleton_updateWorldTransform(skeleton); + spSkeleton_updateWorldTransform(skeleton, SP_PHYSICS_UPDATE); spAnimationState_setAnimationByName(drawable->state, 0, "idle", true); spAnimationState_setAnimationByName(drawable->state, 1, "blink", true); @@ -518,7 +518,7 @@ void owl(spSkeletonData *skeletonData, spAtlas *atlas) { deltaClock.restart(); spSkeleton_setToSetupPose(drawable->skeleton); - drawable->update(delta); + drawable->update(delta, SP_PHYSICS_UPDATE); window.clear(); window.draw(*drawable); @@ -541,7 +541,7 @@ void test(spSkeletonData *skeletonData, spAtlas *atlas) { for (int i = 0; i < 1; i++) { spAnimationState_update(animState, d); spAnimationState_apply(animState, skeleton); - spSkeleton_updateWorldTransform(skeleton); + spSkeleton_updateWorldTransform(skeleton, SP_PHYSICS_UPDATE); for (int ii = 0; ii < skeleton->bonesCount; ii++) { spBone *bone = skeleton->bones[ii]; printf("%s %f %f %f %f %f %f\n", bone->data->name, bone->a, bone->b, bone->c, bone->d, bone->worldX, bone->worldY); @@ -569,7 +569,7 @@ void testSkinsApi(spSkeletonData *skeletonData, spAtlas *atlas) { skeleton->x = 320; skeleton->y = 590; - spSkeleton_updateWorldTransform(skeleton); + spSkeleton_updateWorldTransform(skeleton, SP_PHYSICS_UPDATE); spAnimationState_setAnimationByName(drawable->state, 0, "walk", true); @@ -584,7 +584,7 @@ void testSkinsApi(spSkeletonData *skeletonData, spAtlas *atlas) { float delta = deltaClock.getElapsedTime().asSeconds(); deltaClock.restart(); - drawable->update(delta); + drawable->update(delta, SP_PHYSICS_UPDATE); window.clear(); window.draw(*drawable); @@ -622,7 +622,7 @@ void testMixAndMatch(spSkeletonData *skeletonData, spAtlas *atlas) { skeleton->x = 320; skeleton->y = 590; - spSkeleton_updateWorldTransform(skeleton); + spSkeleton_updateWorldTransform(skeleton, SP_PHYSICS_UPDATE); spAnimationState_setAnimationByName(drawable->state, 0, "dance", true); @@ -637,7 +637,7 @@ void testMixAndMatch(spSkeletonData *skeletonData, spAtlas *atlas) { float delta = deltaClock.getElapsedTime().asSeconds(); deltaClock.restart(); - drawable->update(delta); + drawable->update(delta, SP_PHYSICS_UPDATE); window.clear(); window.draw(*drawable); diff --git a/spine-sfml/c/src/spine/spine-sfml.cpp b/spine-sfml/c/src/spine/spine-sfml.cpp index 250738229..4108fa615 100644 --- a/spine-sfml/c/src/spine/spine-sfml.cpp +++ b/spine-sfml/c/src/spine/spine-sfml.cpp @@ -149,10 +149,11 @@ namespace spine { spColorArray_dispose(tempColors); } - void SkeletonDrawable::update(float deltaTime) { + void SkeletonDrawable::update(float deltaTime, spPhysics physics) { spAnimationState_update(state, deltaTime * timeScale); spAnimationState_apply(state, skeleton); - spSkeleton_updateWorldTransform(skeleton); + spSkeleton_update(skeleton, deltaTime * timeScale); + spSkeleton_updateWorldTransform(skeleton, physics); } void SkeletonDrawable::draw(RenderTarget &target, RenderStates states) const { diff --git a/spine-sfml/c/src/spine/spine-sfml.h b/spine-sfml/c/src/spine/spine-sfml.h index 181fa3750..4456e5dff 100644 --- a/spine-sfml/c/src/spine/spine-sfml.h +++ b/spine-sfml/c/src/spine/spine-sfml.h @@ -52,7 +52,7 @@ namespace spine { SkeletonDrawable(spSkeletonData *skeleton, spAnimationStateData *stateData = 0); ~SkeletonDrawable(); - void update(float deltaTime); + void update(float deltaTime, spPhysics physics); virtual void draw(sf::RenderTarget &target, sf::RenderStates states) const;