Browse Source

Formatting

Mario Zechner 1 year ago
parent
commit
aaa9b81628

+ 1 - 1
spine-cpp/spine-cpp-lite/spine-cpp-lite.cpp

@@ -1525,7 +1525,7 @@ spine_bounds spine_skeleton_get_bounds(spine_skeleton skeleton) {
 	if (skeleton == nullptr) return (spine_bounds) bounds;
 	if (skeleton == nullptr) return (spine_bounds) bounds;
 	Skeleton *_skeleton = (Skeleton *) skeleton;
 	Skeleton *_skeleton = (Skeleton *) skeleton;
 	Vector<float> vertices;
 	Vector<float> vertices;
-    SkeletonClipping clipper;
+	SkeletonClipping clipper;
 
 
 	_skeleton->getBounds(bounds->x, bounds->y, bounds->width, bounds->height, vertices, &clipper);
 	_skeleton->getBounds(bounds->x, bounds->y, bounds->width, bounds->height, vertices, &clipper);
 	return (spine_bounds) bounds;
 	return (spine_bounds) bounds;

+ 32 - 32
spine-cpp/spine-cpp/src/spine/Skeleton.cpp

@@ -458,8 +458,8 @@ Skeleton::findPhysicsConstraint(const String &constraintName) {
 }
 }
 
 
 void Skeleton::getBounds(float &outX, float &outY, float &outWidth,
 void Skeleton::getBounds(float &outX, float &outY, float &outWidth,
-                         float &outHeight, Vector<float> &outVertexBuffer) {
-    getBounds(outX, outY, outWidth, outHeight, outVertexBuffer, NULL);
+						 float &outHeight, Vector<float> &outVertexBuffer) {
+	getBounds(outX, outY, outWidth, outHeight, outVertexBuffer, NULL);
 }
 }
 
 
 static unsigned short quadIndices[] = {0, 1, 2, 2, 3, 0};
 static unsigned short quadIndices[] = {0, 1, 2, 2, 3, 0};
@@ -477,8 +477,8 @@ void Skeleton::getBounds(float &outX, float &outY, float &outWidth,
 			continue;
 			continue;
 		size_t verticesLength = 0;
 		size_t verticesLength = 0;
 		Attachment *attachment = slot->getAttachment();
 		Attachment *attachment = slot->getAttachment();
-        unsigned short *triangles = NULL;
-        size_t trianglesLength = 0;
+		unsigned short *triangles = NULL;
+		size_t trianglesLength = 0;
 
 
 		if (attachment != NULL &&
 		if (attachment != NULL &&
 			attachment->getRTTI().instanceOf(RegionAttachment::rtti)) {
 			attachment->getRTTI().instanceOf(RegionAttachment::rtti)) {
@@ -490,8 +490,8 @@ void Skeleton::getBounds(float &outX, float &outY, float &outWidth,
 				outVertexBuffer.setSize(8, 0);
 				outVertexBuffer.setSize(8, 0);
 			}
 			}
 			regionAttachment->computeWorldVertices(*slot, outVertexBuffer, 0);
 			regionAttachment->computeWorldVertices(*slot, outVertexBuffer, 0);
-            triangles = quadIndices;
-            trianglesLength = 6;
+			triangles = quadIndices;
+			trianglesLength = 6;
 		} else if (attachment != NULL &&
 		} else if (attachment != NULL &&
 				   attachment->getRTTI().instanceOf(MeshAttachment::rtti)) {
 				   attachment->getRTTI().instanceOf(MeshAttachment::rtti)) {
 			MeshAttachment *mesh = static_cast<MeshAttachment *>(attachment);
 			MeshAttachment *mesh = static_cast<MeshAttachment *>(attachment);
@@ -503,33 +503,33 @@ void Skeleton::getBounds(float &outX, float &outY, float &outWidth,
 
 
 			mesh->computeWorldVertices(*slot, 0, verticesLength,
 			mesh->computeWorldVertices(*slot, 0, verticesLength,
 									   outVertexBuffer.buffer(), 0);
 									   outVertexBuffer.buffer(), 0);
-            triangles = mesh->getTriangles().buffer();
-            trianglesLength = mesh->getTriangles().size();
+			triangles = mesh->getTriangles().buffer();
+			trianglesLength = mesh->getTriangles().size();
 		} else if (attachment != NULL &&
 		} else if (attachment != NULL &&
-            attachment->getRTTI().instanceOf(ClippingAttachment::rtti) && clipper != NULL) {
-            clipper->clipStart(*slot, static_cast<ClippingAttachment *>(attachment));
-        }
-
-        if (verticesLength > 0) {
-            float *vertices = outVertexBuffer.buffer();
-            if (clipper != NULL && clipper->isClipping()) {
-                clipper->clipTriangles(outVertexBuffer.buffer(), triangles, trianglesLength);
-                vertices = clipper->getClippedVertices().buffer();
-                verticesLength = clipper->getClippedVertices().size();
-            }
-            for (size_t ii = 0; ii < verticesLength; ii += 2) {
-                float vx = vertices[ii];
-                float vy = vertices[ii + 1];
-
-                minX = MathUtil::min(minX, vx);
-                minY = MathUtil::min(minY, vy);
-                maxX = MathUtil::max(maxX, vx);
-                maxY = MathUtil::max(maxY, vy);
-            }
-        }
-        if (clipper != NULL) clipper->clipEnd(*slot);
-	}
-    if (clipper != NULL) clipper->clipEnd();
+				   attachment->getRTTI().instanceOf(ClippingAttachment::rtti) && clipper != NULL) {
+			clipper->clipStart(*slot, static_cast<ClippingAttachment *>(attachment));
+		}
+
+		if (verticesLength > 0) {
+			float *vertices = outVertexBuffer.buffer();
+			if (clipper != NULL && clipper->isClipping()) {
+				clipper->clipTriangles(outVertexBuffer.buffer(), triangles, trianglesLength);
+				vertices = clipper->getClippedVertices().buffer();
+				verticesLength = clipper->getClippedVertices().size();
+			}
+			for (size_t ii = 0; ii < verticesLength; ii += 2) {
+				float vx = vertices[ii];
+				float vy = vertices[ii + 1];
+
+				minX = MathUtil::min(minX, vx);
+				minY = MathUtil::min(minY, vy);
+				maxX = MathUtil::max(maxX, vx);
+				maxY = MathUtil::max(maxY, vy);
+			}
+		}
+		if (clipper != NULL) clipper->clipEnd(*slot);
+	}
+	if (clipper != NULL) clipper->clipEnd();
 
 
 	outX = minX;
 	outX = minX;
 	outY = minY;
 	outY = minY;

+ 70 - 70
spine-cpp/spine-cpp/src/spine/SkeletonClipping.cpp

@@ -83,76 +83,76 @@ void SkeletonClipping::clipEnd() {
 }
 }
 
 
 void SkeletonClipping::clipTriangles(float *vertices, unsigned short *triangles,
 void SkeletonClipping::clipTriangles(float *vertices, unsigned short *triangles,
-                                     size_t trianglesLength) {
-    Vector<float> &clipOutput = _clipOutput;
-    Vector<float> &clippedVertices = _clippedVertices;
-    Vector<unsigned short> &clippedTriangles = _clippedTriangles;
-    Vector<Vector<float> *> &polygons = *_clippingPolygons;
-    size_t polygonsCount = (*_clippingPolygons).size();
-
-    size_t index = 0;
-    clippedVertices.clear();
-    _clippedUVs.clear();
-    clippedTriangles.clear();
-
-    int stride = 2;
-    size_t i = 0;
-    continue_outer:
-    for (; i < trianglesLength; i += 3) {
-        int vertexOffset = triangles[i] * stride;
-        float x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
-
-        vertexOffset = triangles[i + 1] * stride;
-        float x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1];
-
-        vertexOffset = triangles[i + 2] * stride;
-        float x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
-
-        for (size_t p = 0; p < polygonsCount; p++) {
-            size_t s = clippedVertices.size();
-            if (clip(x1, y1, x2, y2, x3, y3, &(*polygons[p]), &clipOutput)) {
-                size_t clipOutputLength = clipOutput.size();
-                if (clipOutputLength == 0) continue;
-
-                size_t clipOutputCount = clipOutputLength >> 1;
-                clippedVertices.setSize(s + clipOutputCount * 2, 0);
-                for (size_t ii = 0; ii < clipOutputLength; ii += 2) {
-                    float x = clipOutput[ii], y = clipOutput[ii + 1];
-                    clippedVertices[s] = x;
-                    clippedVertices[s + 1] = y;
-                    s += 2;
-                }
-
-                s = clippedTriangles.size();
-                clippedTriangles.setSize(s + 3 * (clipOutputCount - 2), 0);
-                clipOutputCount--;
-                for (size_t ii = 1; ii < clipOutputCount; ii++) {
-                    clippedTriangles[s] = (unsigned short) (index);
-                    clippedTriangles[s + 1] = (unsigned short) (index + ii);
-                    clippedTriangles[s + 2] = (unsigned short) (index + ii + 1);
-                    s += 3;
-                }
-                index += clipOutputCount + 1;
-            } else {
-                clippedVertices.setSize(s + 3 * 2, 0);
-                clippedVertices[s] = x1;
-                clippedVertices[s + 1] = y1;
-                clippedVertices[s + 2] = x2;
-                clippedVertices[s + 3] = y2;
-                clippedVertices[s + 4] = x3;
-                clippedVertices[s + 5] = y3;
-
-                s = clippedTriangles.size();
-                clippedTriangles.setSize(s + 3, 0);
-                clippedTriangles[s] = (unsigned short) index;
-                clippedTriangles[s + 1] = (unsigned short) (index + 1);
-                clippedTriangles[s + 2] = (unsigned short) (index + 2);
-                index += 3;
-                i += 3;
-                goto continue_outer;
-            }
-        }
-    }
+									 size_t trianglesLength) {
+	Vector<float> &clipOutput = _clipOutput;
+	Vector<float> &clippedVertices = _clippedVertices;
+	Vector<unsigned short> &clippedTriangles = _clippedTriangles;
+	Vector<Vector<float> *> &polygons = *_clippingPolygons;
+	size_t polygonsCount = (*_clippingPolygons).size();
+
+	size_t index = 0;
+	clippedVertices.clear();
+	_clippedUVs.clear();
+	clippedTriangles.clear();
+
+	int stride = 2;
+	size_t i = 0;
+continue_outer:
+	for (; i < trianglesLength; i += 3) {
+		int vertexOffset = triangles[i] * stride;
+		float x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
+
+		vertexOffset = triangles[i + 1] * stride;
+		float x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1];
+
+		vertexOffset = triangles[i + 2] * stride;
+		float x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
+
+		for (size_t p = 0; p < polygonsCount; p++) {
+			size_t s = clippedVertices.size();
+			if (clip(x1, y1, x2, y2, x3, y3, &(*polygons[p]), &clipOutput)) {
+				size_t clipOutputLength = clipOutput.size();
+				if (clipOutputLength == 0) continue;
+
+				size_t clipOutputCount = clipOutputLength >> 1;
+				clippedVertices.setSize(s + clipOutputCount * 2, 0);
+				for (size_t ii = 0; ii < clipOutputLength; ii += 2) {
+					float x = clipOutput[ii], y = clipOutput[ii + 1];
+					clippedVertices[s] = x;
+					clippedVertices[s + 1] = y;
+					s += 2;
+				}
+
+				s = clippedTriangles.size();
+				clippedTriangles.setSize(s + 3 * (clipOutputCount - 2), 0);
+				clipOutputCount--;
+				for (size_t ii = 1; ii < clipOutputCount; ii++) {
+					clippedTriangles[s] = (unsigned short) (index);
+					clippedTriangles[s + 1] = (unsigned short) (index + ii);
+					clippedTriangles[s + 2] = (unsigned short) (index + ii + 1);
+					s += 3;
+				}
+				index += clipOutputCount + 1;
+			} else {
+				clippedVertices.setSize(s + 3 * 2, 0);
+				clippedVertices[s] = x1;
+				clippedVertices[s + 1] = y1;
+				clippedVertices[s + 2] = x2;
+				clippedVertices[s + 3] = y2;
+				clippedVertices[s + 4] = x3;
+				clippedVertices[s + 5] = y3;
+
+				s = clippedTriangles.size();
+				clippedTriangles.setSize(s + 3, 0);
+				clippedTriangles[s] = (unsigned short) index;
+				clippedTriangles[s + 1] = (unsigned short) (index + 1);
+				clippedTriangles[s + 2] = (unsigned short) (index + 2);
+				index += 3;
+				i += 3;
+				goto continue_outer;
+			}
+		}
+	}
 }
 }
 
 
 void SkeletonClipping::clipTriangles(Vector<float> &vertices, Vector<unsigned short> &triangles, Vector<float> &uvs,
 void SkeletonClipping::clipTriangles(Vector<float> &vertices, Vector<unsigned short> &triangles, Vector<float> &uvs,

+ 5 - 1
spine-godot/.vscode/launch.json

@@ -9,7 +9,11 @@
       "request": "launch",
       "request": "launch",
       "name": "debug scene v4",
       "name": "debug scene v4",
       "program": "godot/bin/godot.windows.editor.dev.x86_64.exe",
       "program": "godot/bin/godot.windows.editor.dev.x86_64.exe",
-      "args": ["--path", "example-v4", "examples/07-slot-node/slot-node.tscn"],
+      "args": [
+        "--path",
+        "example-v4",
+        "examples/03-mix-and-match/mix-and-match.tscn"
+      ],
       "cwd": "${workspaceFolder}",
       "cwd": "${workspaceFolder}",
       "preLaunchTask": "build-v4",
       "preLaunchTask": "build-v4",
       "linux": {
       "linux": {

+ 1 - 1
spine-sdl/example/main.c

@@ -54,7 +54,7 @@ int main() {
 	spAnimationStateData *animationStateData = spAnimationStateData_create(skeletonData);
 	spAnimationStateData *animationStateData = spAnimationStateData_create(skeletonData);
 	animationStateData->defaultMix = 0.2f;
 	animationStateData->defaultMix = 0.2f;
 	spSkeletonDrawable *drawable = spSkeletonDrawable_create(skeletonData, animationStateData);
 	spSkeletonDrawable *drawable = spSkeletonDrawable_create(skeletonData, animationStateData);
-    drawable->usePremultipliedAlpha = -1;
+	drawable->usePremultipliedAlpha = -1;
 	drawable->skeleton->x = 400;
 	drawable->skeleton->x = 400;
 	drawable->skeleton->y = 500;
 	drawable->skeleton->y = 500;
 	spSkeleton_setToSetupPose(drawable->skeleton);
 	spSkeleton_setToSetupPose(drawable->skeleton);

+ 2 - 2
spine-sdl/example/main.cpp

@@ -54,13 +54,13 @@ int main(int argc, char **argv) {
 	json.setScale(0.5f);
 	json.setScale(0.5f);
 	spine::SkeletonData *skeletonData = json.readSkeletonDataFile("data/spineboy-pro.json");
 	spine::SkeletonData *skeletonData = json.readSkeletonDataFile("data/spineboy-pro.json");
 	spine::SkeletonDrawable drawable(skeletonData);
 	spine::SkeletonDrawable drawable(skeletonData);
-    drawable.usePremultipliedAlpha = true;
+	drawable.usePremultipliedAlpha = true;
 	drawable.animationState->getData()->setDefaultMix(0.2f);
 	drawable.animationState->getData()->setDefaultMix(0.2f);
 	drawable.skeleton->setPosition(400, 500);
 	drawable.skeleton->setPosition(400, 500);
 	drawable.skeleton->setToSetupPose();
 	drawable.skeleton->setToSetupPose();
 	drawable.animationState->setAnimation(0, "portal", true);
 	drawable.animationState->setAnimation(0, "portal", true);
 	drawable.animationState->addAnimation(0, "run", true, 0);
 	drawable.animationState->addAnimation(0, "run", true, 0);
-    drawable.update(0, spine::Physics_Update);
+	drawable.update(0, spine::Physics_Update);
 
 
 	bool quit = false;
 	bool quit = false;
 	uint64_t lastFrameTime = SDL_GetPerformanceCounter();
 	uint64_t lastFrameTime = SDL_GetPerformanceCounter();

+ 36 - 36
spine-sdl/src/spine-sdl-c.c

@@ -42,7 +42,7 @@ spSkeletonDrawable *spSkeletonDrawable_create(spSkeletonData *skeletonData, spAn
 	spSkeletonDrawable *self = NEW(spSkeletonDrawable);
 	spSkeletonDrawable *self = NEW(spSkeletonDrawable);
 	self->skeleton = spSkeleton_create(skeletonData);
 	self->skeleton = spSkeleton_create(skeletonData);
 	self->animationState = spAnimationState_create(animationStateData);
 	self->animationState = spAnimationState_create(animationStateData);
-    self->usePremultipliedAlpha = 0;
+	self->usePremultipliedAlpha = 0;
 	self->sdlIndices = spIntArray_create(12);
 	self->sdlIndices = spIntArray_create(12);
 	self->sdlVertices = spSdlVertexArray_create(12);
 	self->sdlVertices = spSdlVertexArray_create(12);
 	self->worldVertices = spFloatArray_create(12);
 	self->worldVertices = spFloatArray_create(12);
@@ -164,41 +164,41 @@ void spSkeletonDrawable_draw(spSkeletonDrawable *self, struct SDL_Renderer *rend
 		for (int ii = 0; ii < (int) indicesCount; ii++)
 		for (int ii = 0; ii < (int) indicesCount; ii++)
 			spIntArray_add(self->sdlIndices, indices[ii]);
 			spIntArray_add(self->sdlIndices, indices[ii]);
 
 
-        if (!self->usePremultipliedAlpha) {
-            switch (slot->data->blendMode) {
-                case SP_BLEND_MODE_NORMAL:
-                    SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
-                    break;
-                case SP_BLEND_MODE_MULTIPLY:
-                    SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_MOD);
-                    break;
-                case SP_BLEND_MODE_ADDITIVE:
-                    SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_ADD);
-                    break;
-                case SP_BLEND_MODE_SCREEN:
-                    SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
-                    break;
-            }
-        } else {
-            SDL_BlendMode target;
-            switch (slot->data->blendMode) {
-                case SP_BLEND_MODE_NORMAL:
-                    target = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD);
-                    SDL_SetTextureBlendMode(texture, target);
-                    break;
-                case SP_BLEND_MODE_MULTIPLY:
-                    SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_MOD);
-                    break;
-                case SP_BLEND_MODE_ADDITIVE:
-                    target = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD);
-                    SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_ADD);
-                    break;
-                case SP_BLEND_MODE_SCREEN:
-                    target = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD);
-                    SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
-                    break;
-            }
-        }
+		if (!self->usePremultipliedAlpha) {
+			switch (slot->data->blendMode) {
+				case SP_BLEND_MODE_NORMAL:
+					SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
+					break;
+				case SP_BLEND_MODE_MULTIPLY:
+					SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_MOD);
+					break;
+				case SP_BLEND_MODE_ADDITIVE:
+					SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_ADD);
+					break;
+				case SP_BLEND_MODE_SCREEN:
+					SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
+					break;
+			}
+		} else {
+			SDL_BlendMode target;
+			switch (slot->data->blendMode) {
+				case SP_BLEND_MODE_NORMAL:
+					target = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD);
+					SDL_SetTextureBlendMode(texture, target);
+					break;
+				case SP_BLEND_MODE_MULTIPLY:
+					SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_MOD);
+					break;
+				case SP_BLEND_MODE_ADDITIVE:
+					target = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD);
+					SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_ADD);
+					break;
+				case SP_BLEND_MODE_SCREEN:
+					target = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD);
+					SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
+					break;
+			}
+		}
 
 
 		SDL_RenderGeometry(renderer, texture, self->sdlVertices->items, self->sdlVertices->size, self->sdlIndices->items,
 		SDL_RenderGeometry(renderer, texture, self->sdlVertices->items, self->sdlVertices->size, self->sdlIndices->items,
 						   indicesCount);
 						   indicesCount);

+ 1 - 1
spine-sdl/src/spine-sdl-c.h

@@ -43,7 +43,7 @@ _SP_ARRAY_DECLARE_TYPE(spSdlVertexArray, struct SDL_Vertex)
 typedef struct spSkeletonDrawable {
 typedef struct spSkeletonDrawable {
 	spSkeleton *skeleton;
 	spSkeleton *skeleton;
 	spAnimationState *animationState;
 	spAnimationState *animationState;
-    int usePremultipliedAlpha;
+	int usePremultipliedAlpha;
 
 
 	spSkeletonClipping *clipper;
 	spSkeletonClipping *clipper;
 	spFloatArray *worldVertices;
 	spFloatArray *worldVertices;

+ 1 - 1
spine-sdl/src/spine-sdl-cpp.h

@@ -46,7 +46,7 @@ namespace spine {
 
 
 		Skeleton *skeleton;
 		Skeleton *skeleton;
 		AnimationState *animationState;
 		AnimationState *animationState;
-        bool usePremultipliedAlpha;
+		bool usePremultipliedAlpha;
 
 
 	private:
 	private:
 		bool ownsAnimationStateData;
 		bool ownsAnimationStateData;