[cocos2dx] Ported to 3.6, no two color batching yet

This commit is contained in:
badlogic 2017-01-30 16:55:04 +01:00
parent fe8eae4b8e
commit 25fb5b1bff
2 changed files with 33 additions and 21 deletions

View File

@ -154,6 +154,10 @@
76F5BD551D2BD7D3005917E5 /* TankExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76F5BD531D2BD7D3005917E5 /* TankExample.cpp */; };
76F5BD561D2BD7EF005917E5 /* TankExample.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76F5BD531D2BD7D3005917E5 /* TankExample.cpp */; };
76F5BD571D2BD7EF005917E5 /* TankExample.h in Sources */ = {isa = PBXBuildFile; fileRef = 76F5BD541D2BD7D3005917E5 /* TankExample.h */; };
76FAC18C1E3F97D2001CCC8C /* Color.c in Sources */ = {isa = PBXBuildFile; fileRef = 76FAC18A1E3F97D2001CCC8C /* Color.c */; };
76FAC18D1E3F97D2001CCC8C /* PointAttachment.c in Sources */ = {isa = PBXBuildFile; fileRef = 76FAC18B1E3F97D2001CCC8C /* PointAttachment.c */; };
76FAC18F1E3F98A0001CCC8C /* Color.c in Sources */ = {isa = PBXBuildFile; fileRef = 76FAC18A1E3F97D2001CCC8C /* Color.c */; };
76FAC1901E3F98A0001CCC8C /* PointAttachment.c in Sources */ = {isa = PBXBuildFile; fileRef = 76FAC18B1E3F97D2001CCC8C /* PointAttachment.c */; };
8262943E1AAF051F00CB7CF7 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8262943D1AAF051F00CB7CF7 /* Security.framework */; };
BF171245129291EC00B8313A /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF170DB012928DE900B8313A /* OpenGLES.framework */; };
BF1712471292920000B8313A /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF170DB412928DE900B8313A /* libz.dylib */; };
@ -309,6 +313,8 @@
76F28CB01DEC7EBB00CDE54D /* VertexAttachment.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = VertexAttachment.c; path = "../../../spine-c/spine-c/src/spine/VertexAttachment.c"; sourceTree = "<group>"; };
76F5BD531D2BD7D3005917E5 /* TankExample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TankExample.cpp; sourceTree = "<group>"; };
76F5BD541D2BD7D3005917E5 /* TankExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TankExample.h; sourceTree = "<group>"; };
76FAC18A1E3F97D2001CCC8C /* Color.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = Color.c; path = "../../../spine-c/spine-c/src/spine/Color.c"; sourceTree = "<group>"; };
76FAC18B1E3F97D2001CCC8C /* PointAttachment.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = PointAttachment.c; path = "../../../spine-c/spine-c/src/spine/PointAttachment.c"; sourceTree = "<group>"; };
8262943D1AAF051F00CB7CF7 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
BF170DB012928DE900B8313A /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
BF170DB412928DE900B8313A /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
@ -524,6 +530,8 @@
76AAA3B21D180F7300C54FCB /* spine */ = {
isa = PBXGroup;
children = (
76FAC18A1E3F97D2001CCC8C /* Color.c */,
76FAC18B1E3F97D2001CCC8C /* PointAttachment.c */,
76F28C8F1DEC7EBA00CDE54D /* Animation.c */,
76F28C901DEC7EBA00CDE54D /* AnimationState.c */,
76F28C911DEC7EBA00CDE54D /* AnimationStateData.c */,
@ -742,6 +750,7 @@
76AAA3C31D180F7C00C54FCB /* RaptorExample.cpp in Sources */,
76F28CB51DEC7EBB00CDE54D /* AtlasAttachmentLoader.c in Sources */,
76AAA3C01D180F7C00C54FCB /* AppDelegate.cpp in Sources */,
76FAC18D1E3F97D2001CCC8C /* PointAttachment.c in Sources */,
76F28CC31DEC7EBB00CDE54D /* PathConstraint.c in Sources */,
76AAA3C41D180F7C00C54FCB /* SimpleCommand.cpp in Sources */,
503AE10017EB989F00D1A890 /* AppController.mm in Sources */,
@ -769,6 +778,7 @@
76F28CBF1DEC7EBB00CDE54D /* IkConstraintData.c in Sources */,
76F28CC61DEC7EBB00CDE54D /* Skeleton.c in Sources */,
76AAA4101D18106000C54FCB /* SkeletonRenderer.cpp in Sources */,
76FAC18C1E3F97D2001CCC8C /* Color.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -776,6 +786,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
76FAC18F1E3F98A0001CCC8C /* Color.c in Sources */,
76FAC1901E3F98A0001CCC8C /* PointAttachment.c in Sources */,
76F28CD11DEC7FFA00CDE54D /* Animation.c in Sources */,
76F28CD21DEC7FFA00CDE54D /* AnimationState.c in Sources */,
76F28CD31DEC7FFA00CDE54D /* AnimationStateData.c in Sources */,

View File

@ -179,10 +179,10 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
SkeletonBatch* batch = SkeletonBatch::getInstance();
Color3B nodeColor = getColor();
_skeleton->r = nodeColor.r / (float)255;
_skeleton->g = nodeColor.g / (float)255;
_skeleton->b = nodeColor.b / (float)255;
_skeleton->a = getDisplayedOpacity() / (float)255;
_skeleton->color.r = nodeColor.r / (float)255;
_skeleton->color.g = nodeColor.g / (float)255;
_skeleton->color.b = nodeColor.b / (float)255;
_skeleton->color.a = getDisplayedOpacity() / (float)255;
Color4F color;
AttachmentVertices* attachmentVertices = nullptr;
@ -193,33 +193,33 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
switch (slot->attachment->type) {
case SP_ATTACHMENT_REGION: {
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices);
spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices, 0, 2);
attachmentVertices = getAttachmentVertices(attachment);
color.r = attachment->r;
color.g = attachment->g;
color.b = attachment->b;
color.a = attachment->a;
color.r = attachment->color.r;
color.g = attachment->color.g;
color.b = attachment->color.b;
color.a = attachment->color.a;
break;
}
case SP_ATTACHMENT_MESH: {
spMeshAttachment* attachment = (spMeshAttachment*)slot->attachment;
spMeshAttachment_computeWorldVertices(attachment, slot, _worldVertices);
spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, attachment->super.worldVerticesLength, _worldVertices, 0, 2);
attachmentVertices = getAttachmentVertices(attachment);
color.r = attachment->r;
color.g = attachment->g;
color.b = attachment->b;
color.a = attachment->a;
color.r = attachment->color.r;
color.g = attachment->color.g;
color.b = attachment->color.b;
color.a = attachment->color.a;
break;
}
default:
continue;
}
color.a *= _skeleton->a * slot->a * 255;
color.a *= _skeleton->color.a * slot->color.a * 255;
float multiplier = _premultipliedAlpha ? color.a : 255;
color.r *= _skeleton->r * slot->r * multiplier;
color.g *= _skeleton->g * slot->g * multiplier;
color.b *= _skeleton->b * slot->b * multiplier;
color.r *= _skeleton->color.r * slot->color.r * multiplier;
color.g *= _skeleton->color.g * slot->color.g * multiplier;
color.b *= _skeleton->color.b * slot->color.b * multiplier;
@ -279,7 +279,7 @@ void SkeletonRenderer::drawDebug (Renderer* renderer, const Mat4 &transform, uin
spSlot* slot = _skeleton->drawOrder[i];
if (!slot->attachment || slot->attachment->type != SP_ATTACHMENT_REGION) continue;
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices);
spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices, 0, 2);
points[0] = Vec2(_worldVertices[0], _worldVertices[1]);
points[1] = Vec2(_worldVertices[2], _worldVertices[3]);
points[2] = Vec2(_worldVertices[4], _worldVertices[5]);
@ -326,11 +326,11 @@ Rect SkeletonRenderer::getBoundingBox () const {
int verticesCount;
if (slot->attachment->type == SP_ATTACHMENT_REGION) {
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices);
spRegionAttachment_computeWorldVertices(attachment, slot->bone, _worldVertices, 0, 2);
verticesCount = 8;
} else if (slot->attachment->type == SP_ATTACHMENT_MESH) {
spMeshAttachment* mesh = (spMeshAttachment*)slot->attachment;
spMeshAttachment_computeWorldVertices(mesh, slot, _worldVertices);
spVertexAttachment_computeWorldVertices(SUPER(mesh), slot, 0, mesh->super.worldVerticesLength, _worldVertices, 0, 2);
verticesCount = mesh->super.worldVerticesLength;
} else
continue;