[cocos2dx] Fix for tint black in 3.7 branch.

This commit is contained in:
badlogic 2018-08-13 16:47:36 +02:00
parent bd778ba417
commit a6dcbc61e3

View File

@ -183,29 +183,6 @@ namespace spine {
initialize();
}
<<<<<<< HEAD
// Early exit if the skeleton is invisible
if (getDisplayedOpacity() == 0 || _skeleton->color.a == 0){
return;
}
if (_effect) _effect->begin(_effect, _skeleton);
Color4F nodeColor;
nodeColor.r = getDisplayedColor().r / (float)255;
nodeColor.g = getDisplayedColor().g / (float)255;
nodeColor.b = getDisplayedColor().b / (float)255;
nodeColor.a = getDisplayedOpacity() / (float)255;
Color4F color;
Color4F darkColor;
float darkPremultipliedAlpha = _premultipliedAlpha ? 255 : 0;
AttachmentVertices* attachmentVertices = nullptr;
TwoColorTrianglesCommand* lastTwoColorTrianglesCommand = nullptr;
bool inRange = _startSlotIndex != -1 || _endSlotIndex != -1 ? false : true;
for (int i = 0, n = _skeleton->slotsCount; i < n; ++i) {
spSlot* slot = _skeleton->drawOrder[i];
=======
void SkeletonRenderer::initWithData (spSkeletonData* skeletonData, bool ownsSkeletonData) {
_ownsSkeleton = true;
setSkeletonData(skeletonData, ownsSkeletonData);
@ -215,7 +192,6 @@ namespace spine {
void SkeletonRenderer::initWithJsonFile (const std::string& skeletonDataFile, spAtlas* atlas, float scale) {
_atlas = atlas;
_attachmentLoader = SUPER(Cocos2dAttachmentLoader_create(_atlas));
>>>>>>> 3.6
spSkeletonJson* json = spSkeletonJson_createWithLoader(_attachmentLoader);
json->scale = scale;
@ -295,18 +271,7 @@ namespace spine {
return;
}
<<<<<<< HEAD
// Early exit if slot is invisible
if (slot->color.a == 0) {
spSkeletonClipping_clipEnd(_clipper, slot);
continue;
}
cocos2d::TrianglesCommand::Triangles triangles;
TwoColorTriangles trianglesTwoColor;
=======
if (_effect) _effect->begin(_effect, _skeleton);
>>>>>>> 3.6
Color4F nodeColor;
nodeColor.r = getDisplayedColor().r / (float)255;
@ -316,39 +281,15 @@ namespace spine {
Color4F color;
Color4F darkColor;
float darkPremultipliedAlpha = _premultipliedAlpha ? 255 : 0;
AttachmentVertices* attachmentVertices = nullptr;
TwoColorTrianglesCommand* lastTwoColorTrianglesCommand = nullptr;
bool inRange = _startSlotIndex != -1 || _endSlotIndex != -1 ? false : true;
for (int i = 0, n = _skeleton->slotsCount; i < n; ++i) {
spSlot* slot = _skeleton->drawOrder[i];
<<<<<<< HEAD
// Early exit if attachment is invisible
if (attachment->color.a == 0) {
spSkeletonClipping_clipEnd(_clipper, slot);
continue;
}
if (!isTwoColorTint) {
triangles.indices = attachmentVertices->_triangles->indices;
triangles.indexCount = attachmentVertices->_triangles->indexCount;
triangles.verts = batch->allocateVertices(attachmentVertices->_triangles->vertCount);
triangles.vertCount = attachmentVertices->_triangles->vertCount;
memcpy(triangles.verts, attachmentVertices->_triangles->verts, sizeof(cocos2d::V3F_C4B_T2F) * attachmentVertices->_triangles->vertCount);
spRegionAttachment_computeWorldVertices(attachment, slot->bone, (float*)triangles.verts, 0, 6);
} else {
trianglesTwoColor.indices = attachmentVertices->_triangles->indices;
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachmentVertices->_triangles->vertCount);
trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
for (int i = 0; i < trianglesTwoColor.vertCount; i++) {
trianglesTwoColor.verts[i].texCoords = attachmentVertices->_triangles->verts[i].texCoords;
}
spRegionAttachment_computeWorldVertices(attachment, slot->bone, (float*)trianglesTwoColor.verts, 0, 7);
=======
if (_startSlotIndex >= 0 && _startSlotIndex == slot->data->index) {
inRange = true;
>>>>>>> 3.6
}
if (!inRange) {
@ -360,36 +301,9 @@ namespace spine {
inRange = false;
}
<<<<<<< HEAD
// Early exit if attachment is invisible
if (attachment->color.a == 0) {
spSkeletonClipping_clipEnd(_clipper, slot);
continue;
}
if (!isTwoColorTint) {
triangles.indices = attachmentVertices->_triangles->indices;
triangles.indexCount = attachmentVertices->_triangles->indexCount;
triangles.verts = batch->allocateVertices(attachmentVertices->_triangles->vertCount);
triangles.vertCount = attachmentVertices->_triangles->vertCount;
memcpy(triangles.verts, attachmentVertices->_triangles->verts, sizeof(cocos2d::V3F_C4B_T2F) * attachmentVertices->_triangles->vertCount);
int vertexSizeInFloats = sizeof(cocos2d::V3F_C4B_T2F) / sizeof(float);
spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, attachment->super.worldVerticesLength, (float*)triangles.verts, 0, vertexSizeInFloats);
} else {
trianglesTwoColor.indices = attachmentVertices->_triangles->indices;
trianglesTwoColor.indexCount = attachmentVertices->_triangles->indexCount;
trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachmentVertices->_triangles->vertCount);
trianglesTwoColor.vertCount = attachmentVertices->_triangles->vertCount;
for (int i = 0; i < trianglesTwoColor.vertCount; i++) {
trianglesTwoColor.verts[i].texCoords = attachmentVertices->_triangles->verts[i].texCoords;
}
int vertexSizeInFloats = sizeof(V3F_C4B_C4B_T2F) / sizeof(float);
spVertexAttachment_computeWorldVertices(SUPER(attachment), slot, 0, attachment->super.worldVerticesLength, (float*)trianglesTwoColor.verts, 0, vertexSizeInFloats);
=======
if (!slot->attachment) {
spSkeletonClipping_clipEnd(_clipper, slot);
continue;
>>>>>>> 3.6
}
// Early exit if slot is invisible
@ -510,7 +424,7 @@ namespace spine {
darkColor.g = 0;
darkColor.b = 0;
}
darkColor.a = _premultipliedAlpha ? 255 : 0;
darkColor.a = darkPremultipliedAlpha;
BlendFunc blendFunc;
switch (slot->data->blendMode) {
@ -648,7 +562,7 @@ namespace spine {
dark.r = darkColor.r / 255.0f;
dark.g = darkColor.g / 255.0f;
dark.b = darkColor.b / 255.0f;
// dark.a = darkColor.a / 255.0f;
dark.a = darkColor.a / 255.0f;
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2) {
V3F_C4B_C4B_T2F* vertex = batchedTriangles->getTriangles().verts + v;
spColor lightCopy = light;
@ -711,7 +625,7 @@ namespace spine {
vertex->color2.r = (GLubyte)(darkCopy.r * 255);
vertex->color2.g = (GLubyte)(darkCopy.g * 255);
vertex->color2.b = (GLubyte)(darkCopy.b * 255);
// vertex->color2.a = (GLubyte)darkColor.a;
vertex->color2.a = (GLubyte)darkColor.a;
}
} else {
for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v) {
@ -1009,4 +923,3 @@ namespace spine {
}
}