diff --git a/spine-c/src/spine/Skeleton.c b/spine-c/src/spine/Skeleton.c index 9e3d6fca3..d8835db72 100644 --- a/spine-c/src/spine/Skeleton.c +++ b/spine-c/src/spine/Skeleton.c @@ -117,6 +117,10 @@ void spSkeleton_dispose (spSkeleton* self) { spSlot_dispose(self->slots[i]); FREE(self->slots); + for (i = 0; i < self->ikConstraintsCount; ++i) + spIkConstraint_dispose(self->ikConstraints[i]); + FREE(self->ikConstraints); + FREE(self->drawOrder); FREE(self); } diff --git a/spine-cocos2d-iphone/2/src/spine/SkeletonRenderer.m b/spine-cocos2d-iphone/2/src/spine/SkeletonRenderer.m index 32a4f3d61..ef0d5d0d8 100644 --- a/spine-cocos2d-iphone/2/src/spine/SkeletonRenderer.m +++ b/spine-cocos2d-iphone/2/src/spine/SkeletonRenderer.m @@ -149,14 +149,14 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; const int* triangles = 0; int trianglesCount = 0; float r = 0, g = 0, b = 0, a = 0; - for (int i = 0, n = _skeleton->slotCount; i < n; i++) { + for (int i = 0, n = _skeleton->slotsCount; i < n; i++) { spSlot* slot = _skeleton->drawOrder[i]; if (!slot->attachment) continue; CCTexture2D *texture = 0; switch (slot->attachment->type) { case SP_ATTACHMENT_REGION: { spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; - spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, worldVertices); + spRegionAttachment_computeWorldVertices(attachment, slot->bone, worldVertices); texture = [self getTextureForRegion:attachment]; uvs = attachment->uvs; verticesCount = 8; @@ -170,7 +170,7 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; } case SP_ATTACHMENT_MESH: { spMeshAttachment* attachment = (spMeshAttachment*)slot->attachment; - spMeshAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot, worldVertices); + spMeshAttachment_computeWorldVertices(attachment, slot, worldVertices); texture = [self getTextureForMesh:attachment]; uvs = attachment->uvs; verticesCount = attachment->verticesCount; @@ -184,7 +184,7 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; } case SP_ATTACHMENT_SKINNED_MESH: { spSkinnedMeshAttachment* attachment = (spSkinnedMeshAttachment*)slot->attachment; - spSkinnedMeshAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot, worldVertices); + spSkinnedMeshAttachment_computeWorldVertices(attachment, slot, worldVertices); texture = [self getTextureForSkinnedMesh:attachment]; uvs = attachment->uvs; verticesCount = attachment->uvsCount; @@ -220,11 +220,11 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; ccDrawColor4B(0, 0, 255, 255); glLineWidth(1); CGPoint points[4]; - for (int i = 0, n = _skeleton->slotCount; i < n; i++) { + for (int i = 0, n = _skeleton->slotsCount; i < n; i++) { spSlot* slot = _skeleton->drawOrder[i]; if (!slot->attachment || slot->attachment->type != SP_ATTACHMENT_REGION) continue; spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; - spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, worldVertices); + spRegionAttachment_computeWorldVertices(attachment, slot->bone, worldVertices); points[0] = ccp(worldVertices[0], worldVertices[1]); points[1] = ccp(worldVertices[2], worldVertices[3]); points[2] = ccp(worldVertices[4], worldVertices[5]); @@ -236,7 +236,7 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; // Bone lengths. glLineWidth(2); ccDrawColor4B(255, 0, 0, 255); - for (int i = 0, n = _skeleton->boneCount; i < n; i++) { + 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; @@ -245,7 +245,7 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; // Bone origins. ccPointSize(4); ccDrawColor4B(0, 0, 255, 255); // Root bone is blue. - for (int i = 0, n = _skeleton->boneCount; i < n; i++) { + for (int i = 0, n = _skeleton->bonesCount; i < n; i++) { spBone *bone = _skeleton->bones[i]; ccDrawPoint(ccp(bone->worldX, bone->worldY)); if (i == 0) ccDrawColor4B(0, 255, 0, 255); @@ -268,21 +268,21 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; - (CGRect) boundingBox { float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN; float scaleX = self.scaleX, scaleY = self.scaleY; - for (int i = 0; i < _skeleton->slotCount; ++i) { + for (int i = 0; i < _skeleton->slotsCount; ++i) { spSlot* slot = _skeleton->slots[i]; if (!slot->attachment) continue; int verticesCount; if (slot->attachment->type == SP_ATTACHMENT_REGION) { spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; - spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, worldVertices); + spRegionAttachment_computeWorldVertices(attachment, slot->bone, worldVertices); verticesCount = 8; } else if (slot->attachment->type == SP_ATTACHMENT_MESH) { spMeshAttachment* mesh = (spMeshAttachment*)slot->attachment; - spMeshAttachment_computeWorldVertices(mesh, slot->skeleton->x, slot->skeleton->y, slot, worldVertices); + 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->skeleton->x, slot->skeleton->y, slot, worldVertices); + spSkinnedMeshAttachment_computeWorldVertices(mesh, slot, worldVertices); verticesCount = mesh->uvsCount; } else continue; diff --git a/spine-cocos2d-iphone/3.0/src/spine/SkeletonRenderer.m b/spine-cocos2d-iphone/3.0/src/spine/SkeletonRenderer.m index e70a7371e..b4ab82425 100755 --- a/spine-cocos2d-iphone/3.0/src/spine/SkeletonRenderer.m +++ b/spine-cocos2d-iphone/3.0/src/spine/SkeletonRenderer.m @@ -147,7 +147,7 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; const int* triangles = 0; int trianglesCount = 0; float r = 0, g = 0, b = 0, a = 0; - for (int i = 0, n = _skeleton->slotCount; i < n; i++) { + for (int i = 0, n = _skeleton->slotsCount; i < n; i++) { spSlot* slot = _skeleton->drawOrder[i]; if (!slot->attachment) continue; @@ -155,7 +155,7 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; switch (slot->attachment->type) { case SP_ATTACHMENT_REGION: { spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; - spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, worldVertices); + spRegionAttachment_computeWorldVertices(attachment, slot->bone, worldVertices); texture = [self getTextureForRegion:attachment]; uvs = attachment->uvs; verticesCount = 8; @@ -170,7 +170,7 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; case SP_ATTACHMENT_MESH: { spMeshAttachment* attachment = (spMeshAttachment*)slot->attachment; - spMeshAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot, worldVertices); + spMeshAttachment_computeWorldVertices(attachment, slot, worldVertices); texture = [self getTextureForMesh:attachment]; uvs = attachment->uvs; verticesCount = attachment->verticesCount; @@ -185,7 +185,7 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; case SP_ATTACHMENT_SKINNED_MESH: { spSkinnedMeshAttachment* attachment = (spSkinnedMeshAttachment*)slot->attachment; - spSkinnedMeshAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot, worldVertices); + spSkinnedMeshAttachment_computeWorldVertices(attachment, slot, worldVertices); texture = [self getTextureForSkinnedMesh:attachment]; uvs = attachment->uvs; verticesCount = attachment->uvsCount; @@ -233,11 +233,11 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; if (_debugSlots) { // Slots. CGPoint points[4]; - for (int i = 0, n = _skeleton->slotCount; i < n; i++) { + for (int i = 0, n = _skeleton->slotsCount; i < n; i++) { spSlot* slot = _skeleton->drawOrder[i]; if (!slot->attachment || slot->attachment->type != SP_ATTACHMENT_REGION) continue; spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; - spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, worldVertices); + spRegionAttachment_computeWorldVertices(attachment, slot->bone, worldVertices); points[0] = ccp(worldVertices[0], worldVertices[1]); points[1] = ccp(worldVertices[2], worldVertices[3]); points[2] = ccp(worldVertices[4], worldVertices[5]); @@ -248,7 +248,7 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; } if (_debugBones) { // Bone lengths. - for (int i = 0, n = _skeleton->boneCount; i < n; i++) { + 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; @@ -256,7 +256,7 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; } // Bone origins. - for (int i = 0, n = _skeleton->boneCount; i < n; i++) { + for (int i = 0, n = _skeleton->bonesCount; i < n; i++) { spBone *bone = _skeleton->bones[i]; [_drawNode drawDot:ccp(bone->worldX, bone->worldY) radius:4 color:[CCColor greenColor]]; if (i == 0) [_drawNode drawDot:ccp(bone->worldX, bone->worldY) radius:4 color:[CCColor blueColor]]; @@ -279,21 +279,21 @@ static const int quadTriangles[6] = {0, 1, 2, 2, 3, 0}; - (CGRect) boundingBox { float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN; float scaleX = self.scaleX, scaleY = self.scaleY; - for (int i = 0; i < _skeleton->slotCount; ++i) { + for (int i = 0; i < _skeleton->slotsCount; ++i) { spSlot* slot = _skeleton->slots[i]; if (!slot->attachment) continue; int verticesCount; if (slot->attachment->type == SP_ATTACHMENT_REGION) { spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; - spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, worldVertices); + spRegionAttachment_computeWorldVertices(attachment, slot->bone, worldVertices); verticesCount = 8; } else if (slot->attachment->type == SP_ATTACHMENT_MESH) { spMeshAttachment* mesh = (spMeshAttachment*)slot->attachment; - spMeshAttachment_computeWorldVertices(mesh, slot->skeleton->x, slot->skeleton->y, slot, worldVertices); + 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->skeleton->x, slot->skeleton->y, slot, worldVertices); + spSkinnedMeshAttachment_computeWorldVertices(mesh, slot, worldVertices); verticesCount = mesh->uvsCount; } else continue; diff --git a/spine-cocos2dx/2/src/spine/SkeletonRenderer.cpp b/spine-cocos2dx/2/src/spine/SkeletonRenderer.cpp index 8ff54fbd8..0a2fec9e9 100644 --- a/spine-cocos2dx/2/src/spine/SkeletonRenderer.cpp +++ b/spine-cocos2dx/2/src/spine/SkeletonRenderer.cpp @@ -151,14 +151,14 @@ void SkeletonRenderer::draw () { const int* triangles = nullptr; int trianglesCount = 0; float r = 0, g = 0, b = 0, a = 0; - for (int i = 0, n = skeleton->slotCount; i < n; i++) { + for (int i = 0, n = skeleton->slotsCount; i < n; i++) { spSlot* slot = skeleton->drawOrder[i]; if (!slot->attachment) continue; CCTexture2D *texture = nullptr; switch (slot->attachment->type) { case SP_ATTACHMENT_REGION: { spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; - spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, worldVertices); + spRegionAttachment_computeWorldVertices(attachment, slot->bone, worldVertices); texture = getTexture(attachment); uvs = attachment->uvs; verticesCount = 8; @@ -172,7 +172,7 @@ void SkeletonRenderer::draw () { } case SP_ATTACHMENT_MESH: { spMeshAttachment* attachment = (spMeshAttachment*)slot->attachment; - spMeshAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot, worldVertices); + spMeshAttachment_computeWorldVertices(attachment, slot, worldVertices); texture = getTexture(attachment); uvs = attachment->uvs; verticesCount = attachment->verticesCount; @@ -186,7 +186,7 @@ void SkeletonRenderer::draw () { } case SP_ATTACHMENT_SKINNED_MESH: { spSkinnedMeshAttachment* attachment = (spSkinnedMeshAttachment*)slot->attachment; - spSkinnedMeshAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot, worldVertices); + spSkinnedMeshAttachment_computeWorldVertices(attachment, slot, worldVertices); texture = getTexture(attachment); uvs = attachment->uvs; verticesCount = attachment->uvsCount; @@ -220,11 +220,11 @@ void SkeletonRenderer::draw () { ccDrawColor4B(0, 0, 255, 255); glLineWidth(1); CCPoint points[4]; - for (int i = 0, n = skeleton->slotCount; i < n; i++) { + for (int i = 0, n = skeleton->slotsCount; i < n; i++) { spSlot* slot = skeleton->drawOrder[i]; if (!slot->attachment || slot->attachment->type != SP_ATTACHMENT_REGION) continue; spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; - spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, worldVertices); + spRegionAttachment_computeWorldVertices(attachment, slot->bone, worldVertices); points[0] = ccp(worldVertices[0], worldVertices[1]); points[1] = ccp(worldVertices[2], worldVertices[3]); points[2] = ccp(worldVertices[4], worldVertices[5]); @@ -236,7 +236,7 @@ void SkeletonRenderer::draw () { // Bone lengths. glLineWidth(2); ccDrawColor4B(255, 0, 0, 255); - for (int i = 0, n = skeleton->boneCount; i < n; i++) { + 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; @@ -245,7 +245,7 @@ void SkeletonRenderer::draw () { // Bone origins. ccPointSize(4); ccDrawColor4B(0, 0, 255, 255); // Root bone is blue. - for (int i = 0, n = skeleton->boneCount; i < n; i++) { + for (int i = 0, n = skeleton->bonesCount; i < n; i++) { spBone *bone = skeleton->bones[i]; ccDrawPoint(ccp(bone->worldX, bone->worldY)); if (i == 0) ccDrawColor4B(0, 255, 0, 255); @@ -268,21 +268,21 @@ CCTexture2D* SkeletonRenderer::getTexture (spSkinnedMeshAttachment* attachment) CCRect SkeletonRenderer::boundingBox () { float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN; float scaleX = getScaleX(), scaleY = getScaleY(); - for (int i = 0; i < skeleton->slotCount; ++i) { + for (int i = 0; i < skeleton->slotsCount; ++i) { spSlot* slot = skeleton->slots[i]; if (!slot->attachment) continue; int verticesCount; if (slot->attachment->type == SP_ATTACHMENT_REGION) { spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment; - spRegionAttachment_computeWorldVertices(attachment, slot->skeleton->x, slot->skeleton->y, slot->bone, worldVertices); + spRegionAttachment_computeWorldVertices(attachment, slot->bone, worldVertices); verticesCount = 8; } else if (slot->attachment->type == SP_ATTACHMENT_MESH) { spMeshAttachment* mesh = (spMeshAttachment*)slot->attachment; - spMeshAttachment_computeWorldVertices(mesh, slot->skeleton->x, slot->skeleton->y, slot, worldVertices); + 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->skeleton->x, slot->skeleton->y, slot, worldVertices); + spSkinnedMeshAttachment_computeWorldVertices(mesh, slot, worldVertices); verticesCount = mesh->uvsCount; } else continue;