Formatting

This commit is contained in:
Mario Zechner 2024-04-16 17:21:36 +02:00
parent 0211519a66
commit de6b411007
24 changed files with 1380 additions and 1368 deletions

View File

@ -357,7 +357,7 @@ float spCurveTimeline1_getAbsoluteValue2(spCurveTimeline1 *self, float time, flo
return current + (value - current) * alpha;
}
float spCurveTimeline1_getScaleValue (spCurveTimeline1 *self, float time, float alpha, spMixBlend blend, spMixDirection direction, float current, float setup) {
float spCurveTimeline1_getScaleValue(spCurveTimeline1 *self, float time, float alpha, spMixBlend blend, spMixDirection direction, float current, float setup) {
float *frames = self->super.frames->items;
if (time < frames[0]) {
switch (blend) {
@ -2150,7 +2150,7 @@ void spDrawOrderTimeline_setFrame(spDrawOrderTimeline *self, int frame, float ti
self->drawOrders[frame] = 0;
else {
self->drawOrders[frame] = MALLOC(int, self->slotsCount);
memcpy( self->drawOrders[frame], drawOrder, self->slotsCount * sizeof(int));
memcpy(self->drawOrders[frame], drawOrder, self->slotsCount * sizeof(int));
}
}
@ -2158,7 +2158,7 @@ void spDrawOrderTimeline_setFrame(spDrawOrderTimeline *self, int frame, float ti
void _spInheritTimeline_apply(spTimeline *timeline, spSkeleton *skeleton, float lastTime, float time,
spEvent **firedEvents, int *eventsCount, float alpha, spMixBlend blend,
spMixDirection direction) {
spInheritTimeline *self = (spInheritTimeline *)timeline;
spInheritTimeline *self = (spInheritTimeline *) timeline;
spBone *bone = skeleton->bones[self->boneIndex];
float *frames = self->super.frames->items;
if (!bone->active) return;
@ -2640,8 +2640,8 @@ void spPathConstraintMixTimeline_setFrame(spPathConstraintMixTimeline *self, int
/**/
int/*bool*/ _spPhysicsConstraintTimeline_global(spPhysicsConstraintData *data, spTimelineType type) {
switch(type) {
int /*bool*/ _spPhysicsConstraintTimeline_global(spPhysicsConstraintData *data, spTimelineType type) {
switch (type) {
case SP_TIMELINE_PHYSICSCONSTRAINT_INERTIA:
return data->inertiaGlobal;
case SP_TIMELINE_PHYSICSCONSTRAINT_STRENGTH:
@ -2663,7 +2663,7 @@ int/*bool*/ _spPhysicsConstraintTimeline_global(spPhysicsConstraintData *data, s
}
void _spPhysicsConstraintTimeline_set(spPhysicsConstraint *constraint, spTimelineType type, float value) {
switch(type) {
switch (type) {
case SP_TIMELINE_PHYSICSCONSTRAINT_INERTIA:
constraint->inertia = value;
break;
@ -2692,7 +2692,7 @@ void _spPhysicsConstraintTimeline_set(spPhysicsConstraint *constraint, spTimelin
}
float _spPhysicsConstraintTimeline_get(spPhysicsConstraint *constraint, spTimelineType type) {
switch(type) {
switch (type) {
case SP_TIMELINE_PHYSICSCONSTRAINT_INERTIA:
return constraint->inertia;
case SP_TIMELINE_PHYSICSCONSTRAINT_STRENGTH:
@ -2714,7 +2714,7 @@ float _spPhysicsConstraintTimeline_get(spPhysicsConstraint *constraint, spTimeli
}
float _spPhysicsConstraintTimeline_setup(spPhysicsConstraint *constraint, spTimelineType type) {
switch(type) {
switch (type) {
case SP_TIMELINE_PHYSICSCONSTRAINT_INERTIA:
return constraint->data->inertia;
case SP_TIMELINE_PHYSICSCONSTRAINT_STRENGTH:
@ -2748,7 +2748,7 @@ void _spPhysicsConstraintTimeline_apply(spTimeline *timeline, spSkeleton *skelet
for (int i = 0; i < skeleton->physicsConstraintsCount; i++) {
spPhysicsConstraint *constraint = physicsConstraints[i];
if (constraint->active && _spPhysicsConstraintTimeline_global(constraint->data, type))
_spPhysicsConstraintTimeline_set(constraint, type,spCurveTimeline1_getAbsoluteValue2(SUPER(self), time, alpha, blend, _spPhysicsConstraintTimeline_get(constraint, type), _spPhysicsConstraintTimeline_setup(constraint, type), value));
_spPhysicsConstraintTimeline_set(constraint, type, spCurveTimeline1_getAbsoluteValue2(SUPER(self), time, alpha, blend, _spPhysicsConstraintTimeline_get(constraint, type), _spPhysicsConstraintTimeline_setup(constraint, type), value));
}
} else {
spPhysicsConstraint *constraint = skeleton->physicsConstraints[self->physicsConstraintIndex];
@ -2765,7 +2765,7 @@ spPhysicsConstraintTimeline_create(int frameCount, int bezierCount, int physicsC
spPhysicsConstraintTimeline *timeline = NEW(spPhysicsConstraintTimeline);
spPropertyId ids[1];
spPropertyId id;
switch(type) {
switch (type) {
case SP_TIMELINE_PHYSICSCONSTRAINT_INERTIA:
id = SP_PROPERTY_PHYSICSCONSTRAINT_INERTIA;
break;
@ -2806,7 +2806,7 @@ void spPhysicsConstraintTimeline_setFrame(spPhysicsConstraintTimeline *self, int
void _spPhysicsConstraintResetTimeline_apply(spTimeline *timeline, spSkeleton *skeleton, float lastTime, float time,
spEvent **firedEvents, int *eventsCount, float alpha, spMixBlend blend,
spMixDirection direction) {
spPhysicsConstraintResetTimeline *self = (spPhysicsConstraintResetTimeline *)timeline;
spPhysicsConstraintResetTimeline *self = (spPhysicsConstraintResetTimeline *) timeline;
spPhysicsConstraint *constraint = NULL;
if (self->physicsConstraintIndex != -1) {
constraint = skeleton->physicsConstraints[self->physicsConstraintIndex];

View File

@ -402,7 +402,7 @@ int spAnimationState_apply(spAnimationState *self, spSkeleton *skeleton) {
alpha *= _spAnimationState_applyMixingFrom(self, current, skeleton, blend);
else if (current->trackTime >= current->trackEnd && current->next == 0)
alpha = 0;
int/*bool*/ attachments = alpha >= current->alphaAttachmentThreshold;
int /*bool*/ attachments = alpha >= current->alphaAttachmentThreshold;
/* Apply current entry. */
animationLast = current->animationLast;

View File

@ -141,8 +141,8 @@ 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 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;
@ -354,7 +354,6 @@ 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);
}
void spBone_rotateWorld(spBone *self, float degrees) {

View File

@ -627,7 +627,7 @@ static spAnimation *_spSkeletonBinary_readAnimation(spSkeletonBinary *self, cons
1);
break;
case BONE_TRANSLATE:
readTimeline2(input,timelines,
readTimeline2(input, timelines,
SUPER(spTranslateTimeline_create(frameCount, bezierCount, boneIndex)),
scale);
break;
@ -1046,7 +1046,7 @@ static unsigned short *_readShortArray(_dataInput *input, int n) {
return array;
}
static int _readVertices(_dataInput *input, float **vertices, int *verticesLength, int **bones, int *bonesCount, int/*bool*/ weighted, float scale) {
static int _readVertices(_dataInput *input, float **vertices, int *verticesLength, int **bones, int *bonesCount, int /*bool*/ weighted, float scale) {
int vertexCount = readVarint(input, 1);
*verticesLength = vertexCount << 1;
if (!weighted) {
@ -1086,7 +1086,7 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
switch (type) {
case SP_ATTACHMENT_REGION: {
char *path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : (char*)name;
char *path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : (char *) name;
path = string_copy(path);
spColor color;
spColor_setFromFloats(&color, 1, 1, 1, 1);
@ -1142,7 +1142,7 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
unsigned short *edges = NULL;
int edgesCount = 0;
char* path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : (char*)name;
char *path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : (char *) name;
path = string_copy(path);
spColor color;
spColor_setFromFloats(&color, 1, 1, 1, 1);
@ -1187,13 +1187,13 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
return attachment;
}
case SP_ATTACHMENT_LINKED_MESH: {
char *path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : (char*)name;
char *path = (flags & 16) != 0 ? readStringRef(input, skeletonData) : (char *) name;
path = string_copy(path);
spColor color;
spColor_setFromFloats(&color, 1, 1, 1, 1);
if ((flags & 32) != 0) readColor(input, &color.r, &color.g, &color.b, &color.a);
spSequence *sequence = (flags & 64) != 0 ? readSequence(input) : NULL;
int/*bool*/ inheritTimelines = (flags & 128) != 0;
int /*bool*/ inheritTimelines = (flags & 128) != 0;
int skinIndex = readVarint(input, 1);
char *parent = readStringRef(input, skeletonData);
float width = 0, height = 0;
@ -1206,7 +1206,7 @@ spAttachment *spSkeletonBinary_readAttachment(spSkeletonBinary *self, _dataInput
if (!attachment)
return NULL;
mesh = SUB_CAST(spMeshAttachment, attachment);
mesh->path = (char*)path;
mesh->path = (char *) path;
if (mesh->path) {
char *tmp = NULL;
MALLOC_STR(tmp, mesh->path);

View File

@ -1194,7 +1194,7 @@ spSkeletonData *spSkeletonJson_readSkeletonData(spSkeletonJson *self, const char
}
char *pathName = NULL;
char *slotName = (char*)Json_getString(slotMap, "name", NULL);
char *slotName = (char *) Json_getString(slotMap, "name", NULL);
int slash = string_lastIndexOf(slotName, '/');
if (slash != -1) {
pathName = string_substring(slotName, 0, slash);
@ -1661,7 +1661,7 @@ spSkeletonData *spSkeletonJson_readSkeletonData(spSkeletonJson *self, const char
mesh->edgesCount = entry->size;
mesh->edges = MALLOC(unsigned short, entry->size);
for (entry = entry->child, ii = 0; entry; entry = entry->next, ++ii)
mesh->edges[ii] = (unsigned short)entry->valueInt;
mesh->edges[ii] = (unsigned short) entry->valueInt;
}
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);

View File

@ -44,7 +44,7 @@ _SP_ARRAY_IMPLEMENT_TYPE(spPhysicsConstraintDataArray, spPhysicsConstraintData *
_Entry *_Entry_create(int slotIndex, const char *name, spAttachment *attachment) {
_Entry *self = NEW(_Entry);
self->slotIndex = slotIndex;
MALLOC_STR(self->name, (char *)name);
MALLOC_STR(self->name, (char *) name);
self->attachment = attachment;
return self;
}
@ -69,7 +69,7 @@ static void _SkinHashTableEntry_dispose(_SkinHashTableEntry *self) {
spSkin *spSkin_create(const char *name) {
spSkin *self = SUPER(NEW(_spSkin));
MALLOC_STR(self->name, (char*)name);
MALLOC_STR(self->name, (char *) name);
self->bones = spBoneDataArray_create(4);
self->ikConstraints = spIkConstraintDataArray_create(4);
self->transformConstraints = spTransformConstraintDataArray_create(4);

View File

@ -32,7 +32,7 @@
#include "SpineSprite.h"
void SpineSkeleton::_bind_methods() {
ClassDB::bind_method(D_METHOD("update_world_transform"), &SpineSkeleton::update_world_transform);
ClassDB::bind_method(D_METHOD("update_world_transform", "physics"), &SpineSkeleton::update_world_transform);
ClassDB::bind_method(D_METHOD("set_to_setup_pose"), &SpineSkeleton::set_to_setup_pose);
ClassDB::bind_method(D_METHOD("set_bones_to_setup_pose"), &SpineSkeleton::set_bones_to_setup_pose);
ClassDB::bind_method(D_METHOD("set_slots_to_setup_pose"), &SpineSkeleton::set_slots_to_setup_pose);

View File

@ -8,11 +8,15 @@ up into multiple modules:
1. `spine-canvas/`, a self-contained Canvas backend, built on the core classes.
1. `spine-threejs/`, a self-contained THREE.JS backend, built on the core classes.
1. `spine-player/`, a self-contained player to easily display Spine animations on your website, built on the core classes and WebGL backend.
1. `spine-phaser/`, a Phaser backend, built on the core classes.
1. `spine-pixi/`, a Pixi backend, built on the core classes.
In most cases, the `spine-player` module is best suited for your needs. Please refer to the [Spine Web Player documentation](https://esotericsoftware.com/spine-player) for more information.
For documentation of the core API in `spine-core`, please refer to our [Spine Runtimes Guide](http://esotericsoftware.com/spine-runtimes-guide).
For documentation of spine-phaser, please refer to our [spine-phaser Guide](https://esotericsoftware.com/spine-phaser).
For module specific APIs in `spine-canvas`, `spine-webgl`, and `spine-threejs`, please refer to the [Examples](#examples) in the respecitve `spine-<modulename>/example` folder. For `spine-webgl` specifically, we have provided additional [demos](spine-webgl/demos), which you can also [view online](http://esotericsoftware.com/spine-demos).
## Licensing
@ -45,20 +49,26 @@ You can include a module in your project via a `<script>` tag from the [unpkg](h
```
// spine-ts Core
<script src="https://unpkg.com/@esotericsoftware/spine-core@4.0.*/dist/iife/spine-core.js"></script>
<script src="https://unpkg.com/@esotericsoftware/spine-core@4.2.*/dist/iife/spine-core.js"></script>
// spine-ts Canvas
<script src="https://unpkg.com/@esotericsoftware/spine-canvas@4.0.*/dist/iife/spine-canvas.js"></script>
<script src="https://unpkg.com/@esotericsoftware/spine-canvas@4.2.*/dist/iife/spine-canvas.js"></script>
// spine-ts WebGL
<script src="https://unpkg.com/@esotericsoftware/spine-webgl@4.0.*/dist/iife/spine-webgl.js"></script>
<script src="https://unpkg.com/@esotericsoftware/spine-webgl@4.2.*/dist/iife/spine-webgl.js"></script>
// spine-ts Player, which requires a spine-player.css as well
<script src="https://unpkg.com/@esotericsoftware/spine-player@4.0.*/dist/iife/spine-player.js"></script>
<script src="https://unpkg.com/@esotericsoftware/spine-player@4.2.*/dist/iife/spine-player.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@esotericsoftware/spine-player@4.0.*/dist/spine-player.css">
// spine-ts ThreeJS
<script src="https://unpkg.com/@esotericsoftware/spine-threejs@4.0.*/dist/iife/spine-threejs.js"></script>
<script src="https://unpkg.com/@esotericsoftware/spine-threejs@4.2.*/dist/iife/spine-threejs.js"></script>
// spine-phaser
<script src="https://unpkg.com/@esotericsoftware/spine-phaser@4.2.*/dist/iife/spine-phaser.js"></script>
// spine-pixi
<script src="https://unpkg.com/@esotericsoftware/spine-pixi@4.2.*/dist/iife/spine-pixi.js"></script>
```
We also provide `js.map` source maps. They will be automatically fetched from unpkg when debugging code of a spine-module in Chrome, Firefox, or Safari, mapping the JavaScript code back to its original TypeScript sources.
@ -75,6 +85,8 @@ npm install @esotericsoftware/spine-canvas
npm install @esotericsoftware/spine-webgl
npm install @esotericsoftware/spine-player
npm install @esotericsoftware/spine-threejs
npm install @esotericsoftware/spine-phaser
npm install @esotericsoftware/spine-pixi
```
spine-ts modules are provided in the [ECMAScript format](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules), which can be consumed natively by all modern browsers, or bundled by tools like [webpack](https://webpack.js.org/), [Babel](https://babeljs.io/), [Parcel](https://parceljs.org/), or [esbuild](https://esbuild.github.io/). You can import functions and classes from a spine-ts module in your JavaScript or TypeScript code using the `import` syntax to get access to all exported constants, functions, and classes of a module:

View File

@ -138,6 +138,7 @@ export class SkeletonMesh extends THREE.Object3D {
state.update(deltaTime);
state.apply(skeleton);
skeleton.update(deltaTime);
skeleton.updateWorldTransform(Physics.update);
this.updateGeometry();