Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
badlogic committed Apr 16, 2024
1 parent 0211519 commit de6b411
Show file tree
Hide file tree
Showing 24 changed files with 1,400 additions and 1,388 deletions.
664 changes: 332 additions & 332 deletions spine-c/spine-c/src/spine/Animation.c

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions spine-c/spine-c/src/spine/AnimationState.c
Expand Up @@ -399,10 +399,10 @@ int spAnimationState_apply(spAnimationState *self, spSkeleton *skeleton) {
/* Apply mixing from entries first. */
alpha = current->alpha;
if (current->mixingFrom)
alpha *= _spAnimationState_applyMixingFrom(self, current, skeleton, blend);
alpha *= _spAnimationState_applyMixingFrom(self, current, skeleton, blend);
else if (current->trackTime >= current->trackEnd && current->next == 0)
alpha = 0;
int/*bool*/ attachments = alpha >= current->alphaAttachmentThreshold;
alpha = 0;
int /*bool*/ attachments = alpha >= current->alphaAttachmentThreshold;

/* Apply current entry. */
animationLast = current->animationLast;
Expand All @@ -422,7 +422,7 @@ int spAnimationState_apply(spAnimationState *self, spSkeleton *skeleton) {
_spAnimationState_applyAttachmentTimeline(self, timeline, skeleton, applyTime, blend, attachments);
} else {
spTimeline_apply(timelines[ii], skeleton, animationLast, applyTime, applyEvents,
&internal->eventsCount, alpha, blend, SP_MIX_DIRECTION_IN);
&internal->eventsCount, alpha, blend, SP_MIX_DIRECTION_IN);
}
}
} else {
Expand All @@ -438,12 +438,12 @@ int spAnimationState_apply(spAnimationState *self, spSkeleton *skeleton) {
timelineBlend = timelineMode->items[ii] == SUBSEQUENT ? blend : SP_MIX_BLEND_SETUP;
if (!shortestRotation && timeline->type == SP_TIMELINE_ROTATE)
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, applyTime, alpha, timelineBlend,
timelinesRotation, ii << 1, firstFrame);
timelinesRotation, ii << 1, firstFrame);
else if (timeline->type == SP_TIMELINE_ATTACHMENT)
_spAnimationState_applyAttachmentTimeline(self, timeline, skeleton, applyTime, timelineBlend, attachments);
else
spTimeline_apply(timeline, skeleton, animationLast, applyTime, applyEvents, &internal->eventsCount,
alpha, timelineBlend, SP_MIX_DIRECTION_IN);
alpha, timelineBlend, SP_MIX_DIRECTION_IN);
}
}
_spAnimationState_queueEvents(self, current, animationTime);
Expand Down Expand Up @@ -665,8 +665,8 @@ void _spAnimationState_applyRotateTimeline(spAnimationState *self, spTimeline *t

/* Mix between rotations using the direction of the shortest route on the first frame while detecting crosses. */
diff = r2 - r1;
diff -= CEIL(diff / 360 - 0.5) * 360;
if (diff == 0) {
diff -= CEIL(diff / 360 - 0.5) * 360;
if (diff == 0) {
total = timelinesRotation[i];
} else {
float lastTotal, lastDiff, loops;
Expand Down Expand Up @@ -716,15 +716,15 @@ void _spAnimationState_queueEvents(spAnimationState *self, spTrackEntry *entry,

/* Queue complete if completed a loop iteration or the animation. */
if (entry->loop) {
if (duration == 0)
complete = -1;
else {
int cycles = (int) (entry->trackTime / duration);
complete = cycles > 0 && cycles > (int) (entry->trackLast / duration);
}
} else {
complete = (animationTime >= animationEnd && entry->animationLast < animationEnd);
}
if (duration == 0)
complete = -1;
else {
int cycles = (int) (entry->trackTime / duration);
complete = cycles > 0 && cycles > (int) (entry->trackLast / duration);
}
} else {
complete = (animationTime >= animationEnd && entry->animationLast < animationEnd);
}
if (complete) _spEventQueue_complete(internal->queue, entry);

/* Queue events after complete. */
Expand Down Expand Up @@ -918,7 +918,7 @@ _spAnimationState_trackEntry(spAnimationState *self, int trackIndex, spAnimation

entry->eventThreshold = 0;
entry->mixAttachmentThreshold = 0;
entry->alphaAttachmentThreshold = 0;
entry->alphaAttachmentThreshold = 0;
entry->mixDrawOrderThreshold = 0;

entry->animationStart = 0;
Expand Down Expand Up @@ -1060,13 +1060,13 @@ float spTrackEntry_getTrackComplete(spTrackEntry *entry) {
}

void spTrackEntry_setMixDuration(spTrackEntry *entry, float mixDuration, float delay) {
entry->mixDuration = mixDuration;
if (entry->previous && delay <= 0) delay += spTrackEntry_getTrackComplete(entry) - mixDuration;
entry->delay = delay;
entry->mixDuration = mixDuration;
if (entry->previous && delay <= 0) delay += spTrackEntry_getTrackComplete(entry) - mixDuration;
entry->delay = delay;
}

int spTrackEntry_wasApplied(spTrackEntry *entry) {
return entry->nextTrackLast != -1;
return entry->nextTrackLast != -1;
}

void _spTrackEntry_computeHold(spTrackEntry *entry, spAnimationState *state) {
Expand Down
151 changes: 75 additions & 76 deletions spine-c/spine-c/src/spine/Bone.c
Expand Up @@ -48,8 +48,8 @@ spBone *spBone_create(spBoneData *data, spSkeleton *skeleton, spBone *parent) {
self->parent = parent;
self->a = 1.0f;
self->d = 1.0f;
self->active = -1;
self->inherit = SP_INHERIT_NORMAL;
self->active = -1;
self->inherit = SP_INHERIT_NORMAL;
spBone_setToSetupPose(self);
return self;
}
Expand All @@ -70,10 +70,10 @@ 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 pa, pb, pc, pd;
float sx = self->skeleton->scaleX;
float sy = self->skeleton->scaleY * (spBone_isYDown() ? -1 : 1);
spBone *parent = self->parent;
float pa, pb, pc, pd;
float sx = self->skeleton->scaleX;
float sy = self->skeleton->scaleY * (spBone_isYDown() ? -1 : 1);
spBone *parent = self->parent;

self->ax = x;
self->ay = y;
Expand All @@ -84,14 +84,14 @@ void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotat
self->ashearY = shearY;

if (!parent) { /* Root bone. */
float rx = (rotation + shearX) * DEG_RAD;
float ry = (rotation + 90 + shearY) * DEG_RAD;
self->a = COS(rx) * scaleX * sx;
self->b = COS(ry) * scaleY * sx;
self->c = SIN(rx) * scaleX * sy;
self->d = SIN(ry) * scaleY * sy;
self->worldX = x * sx + self->skeleton->x;
self->worldY = y * sy + self->skeleton->y;
float rx = (rotation + shearX) * DEG_RAD;
float ry = (rotation + 90 + shearY) * DEG_RAD;
self->a = COS(rx) * scaleX * sx;
self->b = COS(ry) * scaleY * sx;
self->c = SIN(rx) * scaleX * sy;
self->d = SIN(ry) * scaleY * sy;
self->worldX = x * sx + self->skeleton->x;
self->worldY = y * sy + self->skeleton->y;
return;
}

Expand All @@ -105,25 +105,25 @@ void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotat

switch (self->inherit) {
case SP_INHERIT_NORMAL: {
float rx = (rotation + shearX) * DEG_RAD;
float ry = (rotation + 90 + shearY) * DEG_RAD;
float la = COS(rx) * scaleX;
float lb = COS(ry) * scaleY;
float lc = SIN(rx) * scaleX;
float ld = SIN(ry) * scaleY;
float rx = (rotation + shearX) * DEG_RAD;
float ry = (rotation + 90 + shearY) * DEG_RAD;
float la = COS(rx) * scaleX;
float lb = COS(ry) * scaleY;
float lc = SIN(rx) * scaleX;
float ld = SIN(ry) * scaleY;
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_INHERIT_ONLYTRANSLATION: {
float rx = (rotation + shearX) * DEG_RAD;
float ry = (rotation + 90 + shearY) * DEG_RAD;
self->a = COS(rx) * scaleX;
self->b = COS(ry) * scaleY;
self->c = SIN(rx) * scaleX;
self->d = SIN(ry) * scaleY;
float rx = (rotation + shearX) * DEG_RAD;
float ry = (rotation + 90 + shearY) * DEG_RAD;
self->a = COS(rx) * scaleX;
self->b = COS(ry) * scaleY;
self->c = SIN(rx) * scaleX;
self->d = SIN(ry) * scaleY;
break;
}
case SP_INHERIT_NOROTATIONORREFLECTION: {
Expand All @@ -141,12 +141,12 @@ void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotat
pc = 0;
prx = 90 - ATAN2DEG(pd, pb);
}
float rx = (rotation + shearX - prx) *DEG_RAD;
float ry = (rotation + shearY - prx + 90) *DEG_RAD;
float la = COS(rx) * scaleX;
float lb = COS(ry) * scaleY;
float lc = SIN(rx) * scaleX;
float ld = SIN(ry) * scaleY;
float rx = (rotation + shearX - prx) * DEG_RAD;
float ry = (rotation + shearY - prx + 90) * DEG_RAD;
float la = COS(rx) * scaleX;
float lb = COS(ry) * scaleY;
float lc = SIN(rx) * scaleX;
float ld = SIN(ry) * scaleY;
self->a = pa * la - pb * lc;
self->b = pa * lb - pb * ld;
self->c = pc * la + pd * lc;
Expand All @@ -155,23 +155,23 @@ void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotat
}
case SP_INHERIT_NOSCALE:
case SP_INHERIT_NOSCALEORREFLECTION: {
rotation *= DEG_RAD;
float cosine = COS(rotation);
float sine = SIN(rotation);
float za = (pa * cosine + pb * sine) / sx;
float zc = (pc * cosine + pd * sine) / sy;
float s = SQRT(za * za + zc * zc);
rotation *= DEG_RAD;
float cosine = COS(rotation);
float sine = SIN(rotation);
float za = (pa * cosine + pb * sine) / sx;
float zc = (pc * cosine + pd * sine) / sy;
float s = SQRT(za * za + zc * zc);
if (self->data->inherit == SP_INHERIT_NOSCALE && (pa * pd - pb * pc < 0) != (sx < 0 != sy < 0))
s = -s;
rotation = PI / 2 + ATAN2(zc, za);
float zb = COS(rotation) * s;
float zd = SIN(rotation) * s;
shearX *= DEG_RAD;
shearY = (90 + shearY) * DEG_RAD;
float la = COS(shearX) * scaleX;
float lb = COS(shearY) * scaleY;
float lc = SIN(shearX) * scaleX;
float ld = SIN(shearY) * scaleY;
rotation = PI / 2 + ATAN2(zc, za);
float zb = COS(rotation) * s;
float zd = SIN(rotation) * s;
shearX *= DEG_RAD;
shearY = (90 + shearY) * DEG_RAD;
float la = COS(shearX) * scaleX;
float lb = COS(shearY) * scaleY;
float lc = SIN(shearX) * scaleX;
float ld = SIN(shearY) * scaleY;
self->a = za * la + zb * lc;
self->b = za * lb + zb * ld;
self->c = zc * la + zd * lc;
Expand All @@ -193,7 +193,7 @@ void spBone_setToSetupPose(spBone *self) {
self->scaleY = self->data->scaleY;
self->shearX = self->data->shearX;
self->shearY = self->data->shearY;
self->inherit = self->data->inherit;
self->inherit = self->data->inherit;
}

float spBone_getWorldRotationX(spBone *self) {
Expand Down Expand Up @@ -225,7 +225,7 @@ void spBone_updateAppliedTransform(spBone *self) {
float s, sa, sc;
float cosine, sine;

float yDownScale = spBone_isYDown() ? -1 : 1;
float yDownScale = spBone_isYDown() ? -1 : 1;

spBone *parent = self->parent;
if (!parent) {
Expand Down Expand Up @@ -266,7 +266,7 @@ void spBone_updateAppliedTransform(spBone *self) {
}
case SP_INHERIT_NOSCALE:
case SP_INHERIT_NOSCALEORREFLECTION: {
float r = self->rotation * DEG_RAD;
float r = self->rotation * DEG_RAD;
cosine = COS(r), sine = SIN(r);
pa = (pa * cosine + pb * sine) / self->skeleton->scaleX;
pc = (pc * cosine + pd * sine) / self->skeleton->scaleY * yDownScale;
Expand Down Expand Up @@ -321,12 +321,12 @@ void spBone_worldToLocal(spBone *self, float worldX, float worldY, float *localX
}

void spBone_worldToParent(spBone *self, float worldX, float worldY, float *localX, float *localY) {
if (self->parent == NULL) {
*localX = worldX;
*localY = worldY;
} else {
spBone_worldToLocal(self->parent, worldX, worldY, localX, localY);
}
if (self->parent == NULL) {
*localX = worldX;
*localY = worldY;
} else {
spBone_worldToLocal(self->parent, worldX, worldY, localX, localY);
}
}

void spBone_localToWorld(spBone *self, float localX, float localY, float *worldX, float *worldY) {
Expand All @@ -336,33 +336,32 @@ void spBone_localToWorld(spBone *self, float localX, float localY, float *worldX
}

void spBone_parentToWorld(spBone *self, float localX, float localY, float *worldX, float *worldY) {
if (self->parent != NULL) {
*worldX = localX;
*worldY = localY;
} else {
spBone_localToWorld(self->parent, localX, localY, worldX, worldY);
}
if (self->parent != NULL) {
*worldX = localX;
*worldY = localY;
} else {
spBone_localToWorld(self->parent, localX, localY, worldX, worldY);
}
}

float spBone_worldToLocalRotation(spBone *self, float worldRotation) {
worldRotation *= DEG_RAD;
float sine = SIN(worldRotation), cosine = COS(worldRotation);
return ATAN2DEG(self->a * sine - self->c * cosine, self->d * cosine - self->b * sine) + self->rotation - self->shearX;
worldRotation *= DEG_RAD;
float sine = SIN(worldRotation), cosine = COS(worldRotation);
return ATAN2DEG(self->a * sine - self->c * cosine, self->d * cosine - self->b * sine) + self->rotation - self->shearX;
}

float spBone_localToWorldRotation(spBone *self, float localRotation) {
localRotation = (localRotation - self->rotation - self->shearX) * DEG_RAD;
float sine = SIN(localRotation), cosine = COS(localRotation);
return ATAN2DEG(cosine * self->c + sine * self->d, cosine * self->a + sine * self->b);

localRotation = (localRotation - self->rotation - self->shearX) * DEG_RAD;
float sine = SIN(localRotation), cosine = COS(localRotation);
return ATAN2DEG(cosine * self->c + sine * self->d, cosine * self->a + sine * self->b);
}

void spBone_rotateWorld(spBone *self, float degrees) {
degrees *= DEG_RAD;
float sine = SIN(degrees), cosine = COS(degrees);
float ra = self->a, rb = self->b;
self->a = cosine * ra - sine * self->c;
self->b = cosine * rb - sine * self->d;
self->c = sine * ra + cosine * self->c;
self->d = sine * rb + cosine * self->d;
degrees *= DEG_RAD;
float sine = SIN(degrees), cosine = COS(degrees);
float ra = self->a, rb = self->b;
self->a = cosine * ra - sine * self->c;
self->b = cosine * rb - sine * self->d;
self->c = sine * ra + cosine * self->c;
self->d = sine * rb + cosine * self->d;
}
8 changes: 4 additions & 4 deletions spine-c/spine-c/src/spine/BoneData.c
Expand Up @@ -38,13 +38,13 @@ spBoneData *spBoneData_create(int index, const char *name, spBoneData *parent) {
self->scaleX = 1;
self->scaleY = 1;
self->inherit = SP_INHERIT_NORMAL;
self->icon = NULL;
self->visible = -1;
return self;
self->icon = NULL;
self->visible = -1;
return self;
}

void spBoneData_dispose(spBoneData *self) {
FREE(self->name);
FREE(self->icon);
FREE(self->icon);
FREE(self);
}
14 changes: 7 additions & 7 deletions spine-c/spine-c/src/spine/Debug.c
Expand Up @@ -209,13 +209,13 @@ void spDebug_printTimeline(spTimeline *timeline) {
spSequenceTimeline *t = (spSequenceTimeline *) timeline;
_spDebug_printTimelineBase(&t->super);
}
case SP_TIMELINE_INHERIT: {
spInheritTimeline *t = (spInheritTimeline *) timeline;
_spDebug_printTimelineBase(&t->super);
}
default: {
_spDebug_printTimelineBase(timeline);
}
case SP_TIMELINE_INHERIT: {
spInheritTimeline *t = (spInheritTimeline *) timeline;
_spDebug_printTimelineBase(&t->super);
}
default: {
_spDebug_printTimelineBase(timeline);
}
}
}

Expand Down

0 comments on commit de6b411

Please sign in to comment.