Skip to content

Commit de6b411

Browse files
committed
Formatting
1 parent 0211519 commit de6b411

24 files changed

+1400
-1388
lines changed

spine-c/spine-c/src/spine/Animation.c

+332-332
Large diffs are not rendered by default.

spine-c/spine-c/src/spine/AnimationState.c

+22-22
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,10 @@ int spAnimationState_apply(spAnimationState *self, spSkeleton *skeleton) {
399399
/* Apply mixing from entries first. */
400400
alpha = current->alpha;
401401
if (current->mixingFrom)
402-
alpha *= _spAnimationState_applyMixingFrom(self, current, skeleton, blend);
402+
alpha *= _spAnimationState_applyMixingFrom(self, current, skeleton, blend);
403403
else if (current->trackTime >= current->trackEnd && current->next == 0)
404-
alpha = 0;
405-
int/*bool*/ attachments = alpha >= current->alphaAttachmentThreshold;
404+
alpha = 0;
405+
int /*bool*/ attachments = alpha >= current->alphaAttachmentThreshold;
406406

407407
/* Apply current entry. */
408408
animationLast = current->animationLast;
@@ -422,7 +422,7 @@ int spAnimationState_apply(spAnimationState *self, spSkeleton *skeleton) {
422422
_spAnimationState_applyAttachmentTimeline(self, timeline, skeleton, applyTime, blend, attachments);
423423
} else {
424424
spTimeline_apply(timelines[ii], skeleton, animationLast, applyTime, applyEvents,
425-
&internal->eventsCount, alpha, blend, SP_MIX_DIRECTION_IN);
425+
&internal->eventsCount, alpha, blend, SP_MIX_DIRECTION_IN);
426426
}
427427
}
428428
} else {
@@ -438,12 +438,12 @@ int spAnimationState_apply(spAnimationState *self, spSkeleton *skeleton) {
438438
timelineBlend = timelineMode->items[ii] == SUBSEQUENT ? blend : SP_MIX_BLEND_SETUP;
439439
if (!shortestRotation && timeline->type == SP_TIMELINE_ROTATE)
440440
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, applyTime, alpha, timelineBlend,
441-
timelinesRotation, ii << 1, firstFrame);
441+
timelinesRotation, ii << 1, firstFrame);
442442
else if (timeline->type == SP_TIMELINE_ATTACHMENT)
443443
_spAnimationState_applyAttachmentTimeline(self, timeline, skeleton, applyTime, timelineBlend, attachments);
444444
else
445445
spTimeline_apply(timeline, skeleton, animationLast, applyTime, applyEvents, &internal->eventsCount,
446-
alpha, timelineBlend, SP_MIX_DIRECTION_IN);
446+
alpha, timelineBlend, SP_MIX_DIRECTION_IN);
447447
}
448448
}
449449
_spAnimationState_queueEvents(self, current, animationTime);
@@ -665,8 +665,8 @@ void _spAnimationState_applyRotateTimeline(spAnimationState *self, spTimeline *t
665665

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

717717
/* Queue complete if completed a loop iteration or the animation. */
718718
if (entry->loop) {
719-
if (duration == 0)
720-
complete = -1;
721-
else {
722-
int cycles = (int) (entry->trackTime / duration);
723-
complete = cycles > 0 && cycles > (int) (entry->trackLast / duration);
724-
}
725-
} else {
726-
complete = (animationTime >= animationEnd && entry->animationLast < animationEnd);
727-
}
719+
if (duration == 0)
720+
complete = -1;
721+
else {
722+
int cycles = (int) (entry->trackTime / duration);
723+
complete = cycles > 0 && cycles > (int) (entry->trackLast / duration);
724+
}
725+
} else {
726+
complete = (animationTime >= animationEnd && entry->animationLast < animationEnd);
727+
}
728728
if (complete) _spEventQueue_complete(internal->queue, entry);
729729

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

919919
entry->eventThreshold = 0;
920920
entry->mixAttachmentThreshold = 0;
921-
entry->alphaAttachmentThreshold = 0;
921+
entry->alphaAttachmentThreshold = 0;
922922
entry->mixDrawOrderThreshold = 0;
923923

924924
entry->animationStart = 0;
@@ -1060,13 +1060,13 @@ float spTrackEntry_getTrackComplete(spTrackEntry *entry) {
10601060
}
10611061

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

10681068
int spTrackEntry_wasApplied(spTrackEntry *entry) {
1069-
return entry->nextTrackLast != -1;
1069+
return entry->nextTrackLast != -1;
10701070
}
10711071

10721072
void _spTrackEntry_computeHold(spTrackEntry *entry, spAnimationState *state) {

spine-c/spine-c/src/spine/Bone.c

+75-76
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ spBone *spBone_create(spBoneData *data, spSkeleton *skeleton, spBone *parent) {
4848
self->parent = parent;
4949
self->a = 1.0f;
5050
self->d = 1.0f;
51-
self->active = -1;
52-
self->inherit = SP_INHERIT_NORMAL;
51+
self->active = -1;
52+
self->inherit = SP_INHERIT_NORMAL;
5353
spBone_setToSetupPose(self);
5454
return self;
5555
}
@@ -70,10 +70,10 @@ void spBone_updateWorldTransform(spBone *self) {
7070

7171
void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotation, float scaleX, float scaleY,
7272
float shearX, float shearY) {
73-
float pa, pb, pc, pd;
74-
float sx = self->skeleton->scaleX;
75-
float sy = self->skeleton->scaleY * (spBone_isYDown() ? -1 : 1);
76-
spBone *parent = self->parent;
73+
float pa, pb, pc, pd;
74+
float sx = self->skeleton->scaleX;
75+
float sy = self->skeleton->scaleY * (spBone_isYDown() ? -1 : 1);
76+
spBone *parent = self->parent;
7777

7878
self->ax = x;
7979
self->ay = y;
@@ -84,14 +84,14 @@ void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotat
8484
self->ashearY = shearY;
8585

8686
if (!parent) { /* Root bone. */
87-
float rx = (rotation + shearX) * DEG_RAD;
88-
float ry = (rotation + 90 + shearY) * DEG_RAD;
89-
self->a = COS(rx) * scaleX * sx;
90-
self->b = COS(ry) * scaleY * sx;
91-
self->c = SIN(rx) * scaleX * sy;
92-
self->d = SIN(ry) * scaleY * sy;
93-
self->worldX = x * sx + self->skeleton->x;
94-
self->worldY = y * sy + self->skeleton->y;
87+
float rx = (rotation + shearX) * DEG_RAD;
88+
float ry = (rotation + 90 + shearY) * DEG_RAD;
89+
self->a = COS(rx) * scaleX * sx;
90+
self->b = COS(ry) * scaleY * sx;
91+
self->c = SIN(rx) * scaleX * sy;
92+
self->d = SIN(ry) * scaleY * sy;
93+
self->worldX = x * sx + self->skeleton->x;
94+
self->worldY = y * sy + self->skeleton->y;
9595
return;
9696
}
9797

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

106106
switch (self->inherit) {
107107
case SP_INHERIT_NORMAL: {
108-
float rx = (rotation + shearX) * DEG_RAD;
109-
float ry = (rotation + 90 + shearY) * DEG_RAD;
110-
float la = COS(rx) * scaleX;
111-
float lb = COS(ry) * scaleY;
112-
float lc = SIN(rx) * scaleX;
113-
float ld = SIN(ry) * scaleY;
108+
float rx = (rotation + shearX) * DEG_RAD;
109+
float ry = (rotation + 90 + shearY) * DEG_RAD;
110+
float la = COS(rx) * scaleX;
111+
float lb = COS(ry) * scaleY;
112+
float lc = SIN(rx) * scaleX;
113+
float ld = SIN(ry) * scaleY;
114114
self->a = pa * la + pb * lc;
115115
self->b = pa * lb + pb * ld;
116116
self->c = pc * la + pd * lc;
117117
self->d = pc * lb + pd * ld;
118118
return;
119119
}
120120
case SP_INHERIT_ONLYTRANSLATION: {
121-
float rx = (rotation + shearX) * DEG_RAD;
122-
float ry = (rotation + 90 + shearY) * DEG_RAD;
123-
self->a = COS(rx) * scaleX;
124-
self->b = COS(ry) * scaleY;
125-
self->c = SIN(rx) * scaleX;
126-
self->d = SIN(ry) * scaleY;
121+
float rx = (rotation + shearX) * DEG_RAD;
122+
float ry = (rotation + 90 + shearY) * DEG_RAD;
123+
self->a = COS(rx) * scaleX;
124+
self->b = COS(ry) * scaleY;
125+
self->c = SIN(rx) * scaleX;
126+
self->d = SIN(ry) * scaleY;
127127
break;
128128
}
129129
case SP_INHERIT_NOROTATIONORREFLECTION: {
@@ -141,12 +141,12 @@ void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotat
141141
pc = 0;
142142
prx = 90 - ATAN2DEG(pd, pb);
143143
}
144-
float rx = (rotation + shearX - prx) *DEG_RAD;
145-
float ry = (rotation + shearY - prx + 90) *DEG_RAD;
146-
float la = COS(rx) * scaleX;
147-
float lb = COS(ry) * scaleY;
148-
float lc = SIN(rx) * scaleX;
149-
float ld = SIN(ry) * scaleY;
144+
float rx = (rotation + shearX - prx) * DEG_RAD;
145+
float ry = (rotation + shearY - prx + 90) * DEG_RAD;
146+
float la = COS(rx) * scaleX;
147+
float lb = COS(ry) * scaleY;
148+
float lc = SIN(rx) * scaleX;
149+
float ld = SIN(ry) * scaleY;
150150
self->a = pa * la - pb * lc;
151151
self->b = pa * lb - pb * ld;
152152
self->c = pc * la + pd * lc;
@@ -155,23 +155,23 @@ void spBone_updateWorldTransformWith(spBone *self, float x, float y, float rotat
155155
}
156156
case SP_INHERIT_NOSCALE:
157157
case SP_INHERIT_NOSCALEORREFLECTION: {
158-
rotation *= DEG_RAD;
159-
float cosine = COS(rotation);
160-
float sine = SIN(rotation);
161-
float za = (pa * cosine + pb * sine) / sx;
162-
float zc = (pc * cosine + pd * sine) / sy;
163-
float s = SQRT(za * za + zc * zc);
158+
rotation *= DEG_RAD;
159+
float cosine = COS(rotation);
160+
float sine = SIN(rotation);
161+
float za = (pa * cosine + pb * sine) / sx;
162+
float zc = (pc * cosine + pd * sine) / sy;
163+
float s = SQRT(za * za + zc * zc);
164164
if (self->data->inherit == SP_INHERIT_NOSCALE && (pa * pd - pb * pc < 0) != (sx < 0 != sy < 0))
165165
s = -s;
166-
rotation = PI / 2 + ATAN2(zc, za);
167-
float zb = COS(rotation) * s;
168-
float zd = SIN(rotation) * s;
169-
shearX *= DEG_RAD;
170-
shearY = (90 + shearY) * DEG_RAD;
171-
float la = COS(shearX) * scaleX;
172-
float lb = COS(shearY) * scaleY;
173-
float lc = SIN(shearX) * scaleX;
174-
float ld = SIN(shearY) * scaleY;
166+
rotation = PI / 2 + ATAN2(zc, za);
167+
float zb = COS(rotation) * s;
168+
float zd = SIN(rotation) * s;
169+
shearX *= DEG_RAD;
170+
shearY = (90 + shearY) * DEG_RAD;
171+
float la = COS(shearX) * scaleX;
172+
float lb = COS(shearY) * scaleY;
173+
float lc = SIN(shearX) * scaleX;
174+
float ld = SIN(shearY) * scaleY;
175175
self->a = za * la + zb * lc;
176176
self->b = za * lb + zb * ld;
177177
self->c = zc * la + zd * lc;
@@ -193,7 +193,7 @@ void spBone_setToSetupPose(spBone *self) {
193193
self->scaleY = self->data->scaleY;
194194
self->shearX = self->data->shearX;
195195
self->shearY = self->data->shearY;
196-
self->inherit = self->data->inherit;
196+
self->inherit = self->data->inherit;
197197
}
198198

199199
float spBone_getWorldRotationX(spBone *self) {
@@ -225,7 +225,7 @@ void spBone_updateAppliedTransform(spBone *self) {
225225
float s, sa, sc;
226226
float cosine, sine;
227227

228-
float yDownScale = spBone_isYDown() ? -1 : 1;
228+
float yDownScale = spBone_isYDown() ? -1 : 1;
229229

230230
spBone *parent = self->parent;
231231
if (!parent) {
@@ -266,7 +266,7 @@ void spBone_updateAppliedTransform(spBone *self) {
266266
}
267267
case SP_INHERIT_NOSCALE:
268268
case SP_INHERIT_NOSCALEORREFLECTION: {
269-
float r = self->rotation * DEG_RAD;
269+
float r = self->rotation * DEG_RAD;
270270
cosine = COS(r), sine = SIN(r);
271271
pa = (pa * cosine + pb * sine) / self->skeleton->scaleX;
272272
pc = (pc * cosine + pd * sine) / self->skeleton->scaleY * yDownScale;
@@ -321,12 +321,12 @@ void spBone_worldToLocal(spBone *self, float worldX, float worldY, float *localX
321321
}
322322

323323
void spBone_worldToParent(spBone *self, float worldX, float worldY, float *localX, float *localY) {
324-
if (self->parent == NULL) {
325-
*localX = worldX;
326-
*localY = worldY;
327-
} else {
328-
spBone_worldToLocal(self->parent, worldX, worldY, localX, localY);
329-
}
324+
if (self->parent == NULL) {
325+
*localX = worldX;
326+
*localY = worldY;
327+
} else {
328+
spBone_worldToLocal(self->parent, worldX, worldY, localX, localY);
329+
}
330330
}
331331

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

338338
void spBone_parentToWorld(spBone *self, float localX, float localY, float *worldX, float *worldY) {
339-
if (self->parent != NULL) {
340-
*worldX = localX;
341-
*worldY = localY;
342-
} else {
343-
spBone_localToWorld(self->parent, localX, localY, worldX, worldY);
344-
}
339+
if (self->parent != NULL) {
340+
*worldX = localX;
341+
*worldY = localY;
342+
} else {
343+
spBone_localToWorld(self->parent, localX, localY, worldX, worldY);
344+
}
345345
}
346346

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

353353
float spBone_localToWorldRotation(spBone *self, float localRotation) {
354-
localRotation = (localRotation - self->rotation - self->shearX) * DEG_RAD;
355-
float sine = SIN(localRotation), cosine = COS(localRotation);
356-
return ATAN2DEG(cosine * self->c + sine * self->d, cosine * self->a + sine * self->b);
357-
354+
localRotation = (localRotation - self->rotation - self->shearX) * DEG_RAD;
355+
float sine = SIN(localRotation), cosine = COS(localRotation);
356+
return ATAN2DEG(cosine * self->c + sine * self->d, cosine * self->a + sine * self->b);
358357
}
359358

360359
void spBone_rotateWorld(spBone *self, float degrees) {
361-
degrees *= DEG_RAD;
362-
float sine = SIN(degrees), cosine = COS(degrees);
363-
float ra = self->a, rb = self->b;
364-
self->a = cosine * ra - sine * self->c;
365-
self->b = cosine * rb - sine * self->d;
366-
self->c = sine * ra + cosine * self->c;
367-
self->d = sine * rb + cosine * self->d;
360+
degrees *= DEG_RAD;
361+
float sine = SIN(degrees), cosine = COS(degrees);
362+
float ra = self->a, rb = self->b;
363+
self->a = cosine * ra - sine * self->c;
364+
self->b = cosine * rb - sine * self->d;
365+
self->c = sine * ra + cosine * self->c;
366+
self->d = sine * rb + cosine * self->d;
368367
}

spine-c/spine-c/src/spine/BoneData.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ spBoneData *spBoneData_create(int index, const char *name, spBoneData *parent) {
3838
self->scaleX = 1;
3939
self->scaleY = 1;
4040
self->inherit = SP_INHERIT_NORMAL;
41-
self->icon = NULL;
42-
self->visible = -1;
43-
return self;
41+
self->icon = NULL;
42+
self->visible = -1;
43+
return self;
4444
}
4545

4646
void spBoneData_dispose(spBoneData *self) {
4747
FREE(self->name);
48-
FREE(self->icon);
48+
FREE(self->icon);
4949
FREE(self);
5050
}

spine-c/spine-c/src/spine/Debug.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ void spDebug_printTimeline(spTimeline *timeline) {
209209
spSequenceTimeline *t = (spSequenceTimeline *) timeline;
210210
_spDebug_printTimelineBase(&t->super);
211211
}
212-
case SP_TIMELINE_INHERIT: {
213-
spInheritTimeline *t = (spInheritTimeline *) timeline;
214-
_spDebug_printTimelineBase(&t->super);
215-
}
216-
default: {
217-
_spDebug_printTimelineBase(timeline);
218-
}
212+
case SP_TIMELINE_INHERIT: {
213+
spInheritTimeline *t = (spInheritTimeline *) timeline;
214+
_spDebug_printTimelineBase(&t->super);
215+
}
216+
default: {
217+
_spDebug_printTimelineBase(timeline);
218+
}
219219
}
220220
}
221221

0 commit comments

Comments
 (0)