Added Bone_isYDown.

Fixes bad commit.
This commit is contained in:
NathanSweet 2015-01-30 22:31:34 +01:00
parent 028769f54f
commit d11b90c4e8
3 changed files with 7 additions and 1 deletions

View File

@ -57,6 +57,7 @@ struct spBone {
}; };
void spBone_setYDown (int/*bool*/yDown); void spBone_setYDown (int/*bool*/yDown);
int/*bool*/spBone_isYDown ();
/* @param parent May be 0. */ /* @param parent May be 0. */
spBone* spBone_create (spBoneData* data, struct spSkeleton* skeleton, spBone* parent); spBone* spBone_create (spBoneData* data, struct spSkeleton* skeleton, spBone* parent);
@ -72,6 +73,7 @@ void spBone_localToWorld (spBone* self, float localX, float localY, float* world
#ifdef SPINE_SHORT_NAMES #ifdef SPINE_SHORT_NAMES
typedef spBone Bone; typedef spBone Bone;
#define Bone_setYDown(...) spBone_setYDown(__VA_ARGS__) #define Bone_setYDown(...) spBone_setYDown(__VA_ARGS__)
#define Bone_isYDown() spBone_isYDown()
#define Bone_create(...) spBone_create(__VA_ARGS__) #define Bone_create(...) spBone_create(__VA_ARGS__)
#define Bone_dispose(...) spBone_dispose(__VA_ARGS__) #define Bone_dispose(...) spBone_dispose(__VA_ARGS__)
#define Bone_setToSetupPose(...) spBone_setToSetupPose(__VA_ARGS__) #define Bone_setToSetupPose(...) spBone_setToSetupPose(__VA_ARGS__)

View File

@ -37,6 +37,10 @@ void spBone_setYDown (int value) {
yDown = value; yDown = value;
} }
int spBone_isYDown () {
return yDown;
}
spBone* spBone_create (spBoneData* data, spSkeleton* skeleton, spBone* parent) { spBone* spBone_create (spBoneData* data, spSkeleton* skeleton, spBone* parent) {
spBone* self = NEW(spBone); spBone* self = NEW(spBone);
CONST_CAST(spBoneData*, self->data) = data; CONST_CAST(spBoneData*, self->data) = data;

View File

@ -70,7 +70,7 @@ void spIkConstraint_apply1 (spBone* bone, float targetX, float targetY, float al
float parentRotation = (!bone->data->inheritRotation || !bone->parent) ? 0 : bone->parent->worldRotation; float parentRotation = (!bone->data->inheritRotation || !bone->parent) ? 0 : bone->parent->worldRotation;
float rotation = bone->rotation; float rotation = bone->rotation;
float rotationIK = ATAN2(targetY - bone->worldY, targetX - bone->worldX) * RAD_DEG; float rotationIK = ATAN2(targetY - bone->worldY, targetX - bone->worldX) * RAD_DEG;
if (bone->worldFlipX != (bone->worldFlipY != yDown)) rotationIK = -rotationIK; if (bone->worldFlipX != (bone->worldFlipY != Bone_isYDown())) rotationIK = -rotationIK;
rotationIK -= parentRotation; rotationIK -= parentRotation;
bone->rotationIK = rotation + (rotationIK - rotation) * alpha; bone->rotationIK = rotation + (rotationIK - rotation) * alpha;
} }