浏览代码

Updated spine-cocos2dx 2 and 3 to Spine v3.

NathanSweet 9 年之前
父节点
当前提交
b25992464b

+ 8 - 1
spine-c/spine-c.vcxproj

@@ -20,12 +20,14 @@
     <ConfigurationType>StaticLibrary</ConfigurationType>
     <UseDebugLibraries>true</UseDebugLibraries>
     <CharacterSet>Unicode</CharacterSet>
+    <PlatformToolset>v110</PlatformToolset>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>StaticLibrary</ConfigurationType>
     <UseDebugLibraries>false</UseDebugLibraries>
     <WholeProgramOptimization>true</WholeProgramOptimization>
     <CharacterSet>Unicode</CharacterSet>
+    <PlatformToolset>v110</PlatformToolset>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
   <ImportGroup Label="ExtensionSettings">
@@ -97,6 +99,9 @@
     <ClInclude Include="include\spine\Slot.h" />
     <ClInclude Include="include\spine\SlotData.h" />
     <ClInclude Include="include\spine\spine.h" />
+    <ClInclude Include="include\spine\TransformConstraint.h" />
+    <ClInclude Include="include\spine\TransformConstraintData.h" />
+    <ClInclude Include="include\spine\WeightedMeshAttachment.h" />
     <ClInclude Include="src\spine\Json.h" />
   </ItemGroup>
   <ItemGroup>
@@ -123,9 +128,11 @@
     <ClCompile Include="src\spine\SkeletonData.c" />
     <ClCompile Include="src\spine\SkeletonJson.c" />
     <ClCompile Include="src\spine\Skin.c" />
-    <ClCompile Include="src\spine\SkinnedMeshAttachment.c" />
     <ClCompile Include="src\spine\Slot.c" />
     <ClCompile Include="src\spine\SlotData.c" />
+    <ClCompile Include="src\spine\TransformConstraint.c" />
+    <ClCompile Include="src\spine\TransformConstraintData.c" />
+    <ClCompile Include="src\spine\WeightedMeshAttachment.c" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 18 - 3
spine-c/spine-c.vcxproj.filters

@@ -96,6 +96,15 @@
     <ClInclude Include="include\spine\IkConstraintData.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="include\spine\TransformConstraint.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="include\spine\TransformConstraintData.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="include\spine\WeightedMeshAttachment.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="src\spine\Atlas.c">
@@ -167,14 +176,20 @@
     <ClCompile Include="src\spine\MeshAttachment.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="src\spine\SkinnedMeshAttachment.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="src\spine\IkConstraint.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="src\spine\IkConstraintData.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\spine\TransformConstraint.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="src\spine\TransformConstraintData.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="src\spine\WeightedMeshAttachment.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 2 - 2
spine-c/src/spine/Bone.c

@@ -88,8 +88,8 @@ void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rota
 		CONST_CAST(float, self->d) = ld;
 		CONST_CAST(float, self->worldX) = x;
 		CONST_CAST(float, self->worldY) = y;
-		CONST_CAST(float, self->worldSignX) = scaleX > 0 ? 1 : -1;
-		CONST_CAST(float, self->worldSignY) = scaleY > 0 ? 1 : -1;
+		CONST_CAST(float, self->worldSignX) = scaleX > 0 ? 1.0f : -1.0f;
+		CONST_CAST(float, self->worldSignY) = scaleY > 0 ? 1.0f : -1.0f;
 		return;
 	}
 

+ 1 - 1
spine-c/src/spine/IkConstraint.c

@@ -133,7 +133,7 @@ void spIkConstraint_apply2 (spBone* parent, spBone* child, float targetX, float
 		float aa = a * a, bb = b * b, ll = l1 * l1, dd = tx * tx + ty * ty;
 		float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa;
 		float d = c1 * c1 - 4 * c2 * c0;
-		float minAngle = 0, minDist = 999999999, minX = 0, minY = 0;
+		float minAngle = 0, minDist = 999999999.0f, minX = 0, minY = 0;
 		float maxAngle = 0, maxDist = 0, maxX = 0, maxY = 0;
 		float x = l1 + a, dist = x * x, angle, y;
 		cy = 0;

+ 9 - 9
spine-cocos2dx/2/src/spine/SkeletonRenderer.cpp

@@ -184,9 +184,9 @@ void SkeletonRenderer::draw () {
 			a = attachment->a;
 			break;
 		}
-		case SP_ATTACHMENT_SKINNED_MESH: {
-			spSkinnedMeshAttachment* attachment = (spSkinnedMeshAttachment*)slot->attachment;
-			spSkinnedMeshAttachment_computeWorldVertices(attachment, slot, worldVertices);
+		case SP_ATTACHMENT_WEIGHTED_MESH: {
+			spWeightedMeshAttachment* attachment = (spWeightedMeshAttachment*)slot->attachment;
+			spWeightedMeshAttachment_computeWorldVertices(attachment, slot, worldVertices);
 			texture = getTexture(attachment);
 			uvs = attachment->uvs;
 			verticesCount = attachment->uvsCount;
@@ -250,8 +250,8 @@ void SkeletonRenderer::draw () {
 		ccDrawColor4B(255, 0, 0, 255);
 		for (int i = 0, n = skeleton->bonesCount; i < n; i++) {
 			spBone *bone = skeleton->bones[i];
-			float x = bone->data->length * bone->m00 + bone->worldX;
-			float y = bone->data->length * bone->m10 + bone->worldY;
+			float x = bone->data->length * bone->a + bone->worldX;
+			float y = bone->data->length * bone->c + bone->worldY;
 			ccDrawLine(ccp(bone->worldX, bone->worldY), ccp(x, y));
 		}
 		// Bone origins.
@@ -273,7 +273,7 @@ CCTexture2D* SkeletonRenderer::getTexture (spMeshAttachment* attachment) const {
 	return (CCTexture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
 }
 
-CCTexture2D* SkeletonRenderer::getTexture (spSkinnedMeshAttachment* attachment) const {
+CCTexture2D* SkeletonRenderer::getTexture (spWeightedMeshAttachment* attachment) const {
 	return (CCTexture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
 }
 
@@ -292,9 +292,9 @@ CCRect SkeletonRenderer::boundingBox () {
 			spMeshAttachment* mesh = (spMeshAttachment*)slot->attachment;
 			spMeshAttachment_computeWorldVertices(mesh, slot, worldVertices);
 			verticesCount = mesh->verticesCount;
-		} else if (slot->attachment->type == SP_ATTACHMENT_SKINNED_MESH) {
-			spSkinnedMeshAttachment* mesh = (spSkinnedMeshAttachment*)slot->attachment;
-			spSkinnedMeshAttachment_computeWorldVertices(mesh, slot, worldVertices);
+		} else if (slot->attachment->type == SP_ATTACHMENT_WEIGHTED_MESH) {
+			spWeightedMeshAttachment* mesh = (spWeightedMeshAttachment*)slot->attachment;
+			spWeightedMeshAttachment_computeWorldVertices(mesh, slot, worldVertices);
 			verticesCount = mesh->uvsCount;
 		} else
 			continue;

+ 1 - 1
spine-cocos2dx/2/src/spine/SkeletonRenderer.h

@@ -97,7 +97,7 @@ protected:
 
 	virtual cocos2d::CCTexture2D* getTexture (spRegionAttachment* attachment) const;
 	virtual cocos2d::CCTexture2D* getTexture (spMeshAttachment* attachment) const;
-	virtual cocos2d::CCTexture2D* getTexture (spSkinnedMeshAttachment* attachment) const;
+	virtual cocos2d::CCTexture2D* getTexture (spWeightedMeshAttachment* attachment) const;
 
 private:
 	bool ownsSkeletonData;

+ 9 - 9
spine-cocos2dx/3/src/spine/SkeletonRenderer.cpp

@@ -198,9 +198,9 @@ void SkeletonRenderer::drawSkeleton (const Mat4 &transform, uint32_t transformFl
 			a = attachment->a;
 			break;
 		}
-		case SP_ATTACHMENT_SKINNED_MESH: {
-			spSkinnedMeshAttachment* attachment = (spSkinnedMeshAttachment*)slot->attachment;
-			spSkinnedMeshAttachment_computeWorldVertices(attachment, slot, _worldVertices);
+		case SP_ATTACHMENT_WEIGHTED_MESH: {
+			spWeightedMeshAttachment* attachment = (spWeightedMeshAttachment*)slot->attachment;
+			spWeightedMeshAttachment_computeWorldVertices(attachment, slot, _worldVertices);
 			texture = getTexture(attachment);
 			uvs = attachment->uvs;
 			verticesCount = attachment->uvsCount;
@@ -271,8 +271,8 @@ void SkeletonRenderer::drawSkeleton (const Mat4 &transform, uint32_t transformFl
 			DrawPrimitives::setDrawColor4B(255, 0, 0, 255);
 			for (int i = 0, n = _skeleton->bonesCount; i < n; i++) {
 				spBone *bone = _skeleton->bones[i];
-				float x = bone->data->length * bone->m00 + bone->worldX;
-				float y = bone->data->length * bone->m10 + bone->worldY;
+				float x = bone->data->length * bone->a + bone->worldX;
+				float y = bone->data->length * bone->c + bone->worldY;
 				DrawPrimitives::drawLine(Vec2(bone->worldX, bone->worldY), Vec2(x, y));
 			}
 			// Bone origins.
@@ -296,7 +296,7 @@ Texture2D* SkeletonRenderer::getTexture (spMeshAttachment* attachment) const {
 	return (Texture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
 }
 
-Texture2D* SkeletonRenderer::getTexture (spSkinnedMeshAttachment* attachment) const {
+Texture2D* SkeletonRenderer::getTexture (spWeightedMeshAttachment* attachment) const {
 	return (Texture2D*)((spAtlasRegion*)attachment->rendererObject)->page->rendererObject;
 }
 
@@ -315,9 +315,9 @@ Rect SkeletonRenderer::getBoundingBox () const {
 			spMeshAttachment* mesh = (spMeshAttachment*)slot->attachment;
 			spMeshAttachment_computeWorldVertices(mesh, slot, _worldVertices);
 			verticesCount = mesh->verticesCount;
-		} else if (slot->attachment->type == SP_ATTACHMENT_SKINNED_MESH) {
-			spSkinnedMeshAttachment* mesh = (spSkinnedMeshAttachment*)slot->attachment;
-			spSkinnedMeshAttachment_computeWorldVertices(mesh, slot, _worldVertices);
+		} else if (slot->attachment->type == SP_ATTACHMENT_WEIGHTED_MESH) {
+			spWeightedMeshAttachment* mesh = (spWeightedMeshAttachment*)slot->attachment;
+			spWeightedMeshAttachment_computeWorldVertices(mesh, slot, _worldVertices);
 			verticesCount = mesh->uvsCount;
 		} else
 			continue;

+ 1 - 1
spine-cocos2dx/3/src/spine/SkeletonRenderer.h

@@ -115,7 +115,7 @@ protected:
 	void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
 	virtual cocos2d::Texture2D* getTexture (spRegionAttachment* attachment) const;
 	virtual cocos2d::Texture2D* getTexture (spMeshAttachment* attachment) const;
-	virtual cocos2d::Texture2D* getTexture (spSkinnedMeshAttachment* attachment) const;
+	virtual cocos2d::Texture2D* getTexture (spWeightedMeshAttachment* attachment) const;
 
 	bool _ownsSkeletonData;
 	spAtlas* _atlas;