Browse Source

Merge branch '4.1' into 4.2-beta

# Conflicts:
#	spine-cocos2dx/spine-cocos2dx/src/spine/SkeletonRenderer.cpp
Mario Zechner 2 years ago
parent
commit
329f5b404f

+ 4 - 0
.gitignore

@@ -188,3 +188,7 @@ spine-godot/.clang-format
 spine-ts/spine-phaser/dist
 spine-ts/spine-phaser/dist
 spine-godot/.cache
 spine-godot/.cache
 spine-godot/build/compile_commands.json
 spine-godot/build/compile_commands.json
+
+spine-flutter/ios/Classes/spine-cpp
+spine-flutter/macos/Classes/spine-cpp
+spine-flutter/src/spine-cpp

+ 2 - 1
CHANGELOG.md

@@ -89,6 +89,7 @@
   * Added CMake parameter `SPINE_SANITIZE` which will enable sanitizers on macOS and Linux.
   * Added CMake parameter `SPINE_SANITIZE` which will enable sanitizers on macOS and Linux.
     * Added `SPINE_MAJOR_VERSION`, `SPINE_MINOR_VERSION`, and `SPINE_VERSION_STRING`. Parsing skeleton .JSON and .skel files will report an error if the skeleton version does not match the runtime version.
     * Added `SPINE_MAJOR_VERSION`, `SPINE_MINOR_VERSION`, and `SPINE_VERSION_STRING`. Parsing skeleton .JSON and .skel files will report an error if the skeleton version does not match the runtime version.
 * **Breaking changes**
 * **Breaking changes**
+  * `RegionAttachment` and `MeshAttachment` no longer implement `HasRendererObject`.
   * `RegionAttachment` and `MeshAttachment` now contain a `TextureRegion*` instead of encoding region fields directly.
   * `RegionAttachment` and `MeshAttachment` now contain a `TextureRegion*` instead of encoding region fields directly.
   * `AttachmentLoader::newRegionAttachment()` and `AttachmentLoader::newMeshAttachment()` now take an additional `Sequence*` parameter.
   * `AttachmentLoader::newRegionAttachment()` and `AttachmentLoader::newMeshAttachment()` now take an additional `Sequence*` parameter.
   * `MeshAttachment::updateUVs()` was renamed to `MeshAttachment::updateRegion()`.
   * `MeshAttachment::updateUVs()` was renamed to `MeshAttachment::updateRegion()`.
@@ -97,7 +98,7 @@
   * `VertexAttachment::getDeformAttachment()` was renamed to `VertexAttachment::getTimelineAttachment()`.
   * `VertexAttachment::getDeformAttachment()` was renamed to `VertexAttachment::getTimelineAttachment()`.
   * `Skeleton::update()` has been removed.
   * `Skeleton::update()` has been removed.
   * `Skeleton::getTime()` has been removed.
   * `Skeleton::getTime()` has been removed.
-  * `VertexEffect` has been removed.
+  * `VertexEffect` has been removed.  
   
   
 ### Cocos2d-x
 ### Cocos2d-x
 
 

+ 15 - 15
spine-cocos2dx/spine-cocos2dx/src/spine/SkeletonRenderer.cpp

@@ -269,7 +269,7 @@ namespace spine {
 		Color darkColor;
 		Color darkColor;
 		const float darkPremultipliedAlpha = _premultipliedAlpha ? 1.f : 0;
 		const float darkPremultipliedAlpha = _premultipliedAlpha ? 1.f : 0;
 		TwoColorTrianglesCommand *lastTwoColorTrianglesCommand = nullptr;
 		TwoColorTrianglesCommand *lastTwoColorTrianglesCommand = nullptr;
-		for (int i = 0, n = _skeleton->getSlots().size(); i < n; ++i) {
+		for (int i = 0, n = (int)_skeleton->getSlots().size(); i < n; ++i) {
 			Slot *slot = _skeleton->getDrawOrder()[i];
 			Slot *slot = _skeleton->getDrawOrder()[i];
 
 
 			if (nothingToDraw(*slot, _startSlotIndex, _endSlotIndex)) {
 			if (nothingToDraw(*slot, _startSlotIndex, _endSlotIndex)) {
@@ -284,7 +284,7 @@ namespace spine {
 
 
 			if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
 			if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
 				RegionAttachment *attachment = static_cast<RegionAttachment *>(slot->getAttachment());
 				RegionAttachment *attachment = static_cast<RegionAttachment *>(slot->getAttachment());
-                texture = (Texture2D*)((AtlasRegion*)attachment->getRegion())->page->texture;
+				texture = (Texture2D*)((AtlasRegion*)attachment->getRegion())->page->texture;
 
 
 				float *dstTriangleVertices = nullptr;
 				float *dstTriangleVertices = nullptr;
 				int dstStride = 0;// in floats
 				int dstStride = 0;// in floats
@@ -322,7 +322,7 @@ namespace spine {
 				color = attachment->getColor();
 				color = attachment->getColor();
 			} else if (slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) {
 			} else if (slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) {
 				MeshAttachment *attachment = (MeshAttachment *) slot->getAttachment();
 				MeshAttachment *attachment = (MeshAttachment *) slot->getAttachment();
-                texture = (Texture2D*)((AtlasRegion*)attachment->getRegion())->page->texture;
+				texture = (Texture2D*)((AtlasRegion*)attachment->getRegion())->page->texture;
 
 
 				float *dstTriangleVertices = nullptr;
 				float *dstTriangleVertices = nullptr;
 				int dstStride = 0;// in floats
 				int dstStride = 0;// in floats
@@ -330,8 +330,8 @@ namespace spine {
 				if (hasSingleTint) {
 				if (hasSingleTint) {
 					triangles.indices = attachment->getTriangles().buffer();
 					triangles.indices = attachment->getTriangles().buffer();
 					triangles.indexCount = (unsigned short)attachment->getTriangles().size();
 					triangles.indexCount = (unsigned short)attachment->getTriangles().size();
-					triangles.verts = batch->allocateVertices(attachment->getWorldVerticesLength() / 2);
-					triangles.vertCount = attachment->getWorldVerticesLength() / 2;
+					triangles.verts = batch->allocateVertices((int)attachment->getWorldVerticesLength() / 2);
+					triangles.vertCount = (int)attachment->getWorldVerticesLength() / 2;
                     for (int v = 0, i = 0; v < triangles.vertCount; v++, i += 2) {
                     for (int v = 0, i = 0; v < triangles.vertCount; v++, i += 2) {
                         auto &texCoords = triangles.verts[v].texCoords;
                         auto &texCoords = triangles.verts[v].texCoords;
                         texCoords.u = attachment->getUVs()[i];
                         texCoords.u = attachment->getUVs()[i];
@@ -343,8 +343,8 @@ namespace spine {
 				} else {
 				} else {
 					trianglesTwoColor.indices = attachment->getTriangles().buffer();
 					trianglesTwoColor.indices = attachment->getTriangles().buffer();
 					trianglesTwoColor.indexCount = (unsigned short)attachment->getTriangles().size();
 					trianglesTwoColor.indexCount = (unsigned short)attachment->getTriangles().size();
-					trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachment->getWorldVerticesLength() / 2);
-					trianglesTwoColor.vertCount = attachment->getWorldVerticesLength() / 2;
+					trianglesTwoColor.verts = twoColorBatch->allocateVertices((int)attachment->getWorldVerticesLength() / 2);
+					trianglesTwoColor.vertCount = (int)attachment->getWorldVerticesLength() / 2;
                     for (int v = 0, i = 0; v < trianglesTwoColor.vertCount; v++, i += 2) {
                     for (int v = 0, i = 0; v < trianglesTwoColor.vertCount; v++, i += 2) {
                         auto &texCoords = trianglesTwoColor.verts[v].texCoords;
                         auto &texCoords = trianglesTwoColor.verts[v].texCoords;
                         texCoords.u = attachment->getUVs()[i];
                         texCoords.u = attachment->getUVs()[i];
@@ -408,9 +408,9 @@ namespace spine {
 						continue;
 						continue;
 					}
 					}
 
 
-					triangles.vertCount = _clipper->getClippedVertices().size() / 2;
+					triangles.vertCount = (int)_clipper->getClippedVertices().size() / 2;
 					triangles.verts = batch->allocateVertices(triangles.vertCount);
 					triangles.verts = batch->allocateVertices(triangles.vertCount);
-					triangles.indexCount = _clipper->getClippedTriangles().size();
+					triangles.indexCount = (int)_clipper->getClippedTriangles().size();
 					triangles.indices = batch->allocateIndices(triangles.indexCount);
 					triangles.indices = batch->allocateIndices(triangles.indexCount);
 					memcpy(triangles.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
 					memcpy(triangles.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
 
 
@@ -454,9 +454,9 @@ namespace spine {
 						continue;
 						continue;
 					}
 					}
 
 
-					trianglesTwoColor.vertCount = _clipper->getClippedVertices().size() / 2;
+					trianglesTwoColor.vertCount = (int)_clipper->getClippedVertices().size() / 2;
 					trianglesTwoColor.verts = twoColorBatch->allocateVertices(trianglesTwoColor.vertCount);
 					trianglesTwoColor.verts = twoColorBatch->allocateVertices(trianglesTwoColor.vertCount);
-					trianglesTwoColor.indexCount = _clipper->getClippedTriangles().size();
+					trianglesTwoColor.indexCount = (int)_clipper->getClippedTriangles().size();
 					trianglesTwoColor.indices = twoColorBatch->allocateIndices(trianglesTwoColor.indexCount);
 					trianglesTwoColor.indices = twoColorBatch->allocateIndices(trianglesTwoColor.indexCount);
 					memcpy(trianglesTwoColor.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
 					memcpy(trianglesTwoColor.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
 
 
@@ -576,7 +576,7 @@ namespace spine {
 			drawNode->setLineWidth(2.0f);
 			drawNode->setLineWidth(2.0f);
 #endif
 #endif
 			V3F_C4B_T2F_Quad quad;
 			V3F_C4B_T2F_Quad quad;
-			for (int i = 0, n = _skeleton->getSlots().size(); i < n; i++) {
+			for (int i = 0, n = (int)_skeleton->getSlots().size(); i < n; i++) {
 				Slot *slot = _skeleton->getDrawOrder()[i];
 				Slot *slot = _skeleton->getDrawOrder()[i];
 
 
 				if (!slot->getBone().isActive()) continue;
 				if (!slot->getBone().isActive()) continue;
@@ -606,7 +606,7 @@ namespace spine {
 #else
 #else
 			drawNode->setLineWidth(2.0f);
 			drawNode->setLineWidth(2.0f);
 #endif
 #endif
-			for (int i = 0, n = _skeleton->getBones().size(); i < n; i++) {
+			for (int i = 0, n = (int)_skeleton->getBones().size(); i < n; i++) {
 				Bone *bone = _skeleton->getBones()[i];
 				Bone *bone = _skeleton->getBones()[i];
 				if (!bone->isActive()) continue;
 				if (!bone->isActive()) continue;
 				float x = bone->getData().getLength() * bone->getA() + bone->getWorldX();
 				float x = bone->getData().getLength() * bone->getA() + bone->getWorldX();
@@ -615,7 +615,7 @@ namespace spine {
 			}
 			}
 			// Bone origins.
 			// Bone origins.
 			auto color = Color4F::BLUE;// Root bone is blue.
 			auto color = Color4F::BLUE;// Root bone is blue.
-			for (int i = 0, n = _skeleton->getBones().size(); i < n; i++) {
+			for (int i = 0, n = (int)_skeleton->getBones().size(); i < n; i++) {
 				Bone *bone = _skeleton->getBones()[i];
 				Bone *bone = _skeleton->getBones()[i];
 				if (!bone->isActive()) continue;
 				if (!bone->isActive()) continue;
 				drawNode->drawPoint(Vec2(bone->getWorldX(), bone->getWorldY()), 4, color);
 				drawNode->drawPoint(Vec2(bone->getWorldX(), bone->getWorldY()), 4, color);
@@ -630,7 +630,7 @@ namespace spine {
 #else
 #else
 			drawNode->setLineWidth(2.0f);
 			drawNode->setLineWidth(2.0f);
 #endif
 #endif
-			for (int i = 0, n = _skeleton->getSlots().size(); i < n; ++i) {
+			for (int i = 0, n = (int)_skeleton->getSlots().size(); i < n; ++i) {
 				Slot *slot = _skeleton->getDrawOrder()[i];
 				Slot *slot = _skeleton->getDrawOrder()[i];
 				if (!slot->getBone().isActive()) continue;
 				if (!slot->getBone().isActive()) continue;
 				if (!slot->getAttachment() || !slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) continue;
 				if (!slot->getAttachment() || !slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) continue;

+ 3 - 3
spine-cocos2dx/spine-cocos2dx/src/spine/v4/SkeletonBatch.cpp

@@ -132,7 +132,7 @@ namespace spine {
 	unsigned short *SkeletonBatch::allocateIndices(uint32_t numIndices) {
 	unsigned short *SkeletonBatch::allocateIndices(uint32_t numIndices) {
 		if (_indices.getCapacity() - _indices.size() < numIndices) {
 		if (_indices.getCapacity() - _indices.size() < numIndices) {
 			unsigned short *oldData = _indices.buffer();
 			unsigned short *oldData = _indices.buffer();
-			int oldSize = _indices.size();
+			int oldSize = (int)_indices.size();
 			_indices.ensureCapacity(_indices.size() + numIndices);
 			_indices.ensureCapacity(_indices.size() + numIndices);
 			unsigned short *newData = _indices.buffer();
 			unsigned short *newData = _indices.buffer();
 			for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
 			for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
@@ -187,8 +187,8 @@ namespace spine {
 
 
 	cocos2d::TrianglesCommand *SkeletonBatch::nextFreeCommand() {
 	cocos2d::TrianglesCommand *SkeletonBatch::nextFreeCommand() {
 		if (_commandsPool.size() <= _nextFreeCommand) {
 		if (_commandsPool.size() <= _nextFreeCommand) {
-			unsigned int newSize = _commandsPool.size() * 2 + 1;
-			for (int i = _commandsPool.size(); i < newSize; i++) {
+			unsigned int newSize = (int)_commandsPool.size() * 2 + 1;
+			for (int i = (int)_commandsPool.size(); i < newSize; i++) {
 				_commandsPool.push_back(createNewTrianglesCommand());
 				_commandsPool.push_back(createNewTrianglesCommand());
 			}
 			}
 		}
 		}

+ 3 - 3
spine-cocos2dx/spine-cocos2dx/src/spine/v4/SkeletonTwoColorBatch.cpp

@@ -321,7 +321,7 @@ namespace spine {
 	unsigned short *SkeletonTwoColorBatch::allocateIndices(uint32_t numIndices) {
 	unsigned short *SkeletonTwoColorBatch::allocateIndices(uint32_t numIndices) {
 		if (_indices.getCapacity() - _indices.size() < numIndices) {
 		if (_indices.getCapacity() - _indices.size() < numIndices) {
 			unsigned short *oldData = _indices.buffer();
 			unsigned short *oldData = _indices.buffer();
-			int oldSize = _indices.size();
+			int oldSize = (int)_indices.size();
 			_indices.ensureCapacity(_indices.size() + numIndices);
 			_indices.ensureCapacity(_indices.size() + numIndices);
 			unsigned short *newData = _indices.buffer();
 			unsigned short *newData = _indices.buffer();
 			for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
 			for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
@@ -406,8 +406,8 @@ namespace spine {
 
 
 	TwoColorTrianglesCommand *SkeletonTwoColorBatch::nextFreeCommand() {
 	TwoColorTrianglesCommand *SkeletonTwoColorBatch::nextFreeCommand() {
 		if (_commandsPool.size() <= _nextFreeCommand) {
 		if (_commandsPool.size() <= _nextFreeCommand) {
-			unsigned int newSize = _commandsPool.size() * 2 + 1;
-			for (int i = _commandsPool.size(); i < newSize; i++) {
+			unsigned int newSize = (int)_commandsPool.size() * 2 + 1;
+			for (int i = (int)_commandsPool.size(); i < newSize; i++) {
 				_commandsPool.push_back(new TwoColorTrianglesCommand());
 				_commandsPool.push_back(new TwoColorTrianglesCommand());
 			}
 			}
 		}
 		}

+ 1 - 1
spine-cpp/spine-cpp/include/spine/MeshAttachment.h

@@ -39,7 +39,7 @@
 
 
 namespace spine {
 namespace spine {
 	/// Attachment that displays a texture region using a mesh.
 	/// Attachment that displays a texture region using a mesh.
-	class SP_API MeshAttachment : public VertexAttachment, public HasRendererObject {
+	class SP_API MeshAttachment : public VertexAttachment {
 		friend class SkeletonBinary;
 		friend class SkeletonBinary;
 
 
 		friend class SkeletonJson;
 		friend class SkeletonJson;

+ 1 - 1
spine-cpp/spine-cpp/include/spine/RegionAttachment.h

@@ -44,7 +44,7 @@ namespace spine {
 	class Bone;
 	class Bone;
 
 
 	/// Attachment that displays a texture region.
 	/// Attachment that displays a texture region.
-	class SP_API RegionAttachment : public Attachment, public HasRendererObject {
+	class SP_API RegionAttachment : public Attachment {
 		friend class SkeletonBinary;
 		friend class SkeletonBinary;
 
 
 		friend class SkeletonJson;
 		friend class SkeletonJson;

+ 1 - 1
spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp

@@ -34,7 +34,7 @@ using namespace spine;
 
 
 RTTI_IMPL(MeshAttachment, VertexAttachment)
 RTTI_IMPL(MeshAttachment, VertexAttachment)
 
 
-MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name), HasRendererObject(),
+MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name),
 													 _parentMesh(NULL),
 													 _parentMesh(NULL),
 													 _path(),
 													 _path(),
 													 _color(1, 1, 1, 1),
 													 _color(1, 1, 1, 1),

+ 1 - 1
spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp

@@ -47,7 +47,7 @@ const int RegionAttachment::URY = 5;
 const int RegionAttachment::BRX = 6;
 const int RegionAttachment::BRX = 6;
 const int RegionAttachment::BRY = 7;
 const int RegionAttachment::BRY = 7;
 
 
-RegionAttachment::RegionAttachment(const String &name) : Attachment(name), HasRendererObject(),
+RegionAttachment::RegionAttachment(const String &name) : Attachment(name),
 														 _x(0),
 														 _x(0),
 														 _y(0),
 														 _y(0),
 														 _rotation(0),
 														 _rotation(0),