[cocos2dx] More fixes to two color batching.

This commit is contained in:
badlogic 2018-06-05 13:30:00 +02:00
parent ec718b73ee
commit 7e68a48189
5 changed files with 10 additions and 9 deletions

View File

@ -107,7 +107,7 @@ bool AppDelegate::applicationDidFinishLaunching () {
// create a scene. it's an autorelease object
//auto scene = RaptorExample::scene();
auto scene = SkeletonRendererSeparatorExample::scene();
auto scene = CoinExample::scene();
// run
director->runWithScene(scene);

View File

@ -44,8 +44,9 @@ bool CoinExample::init () {
if (!LayerColor::initWithColor(Color4B(128, 128, 128, 255))) return false;
skeletonNode = SkeletonAnimation::createWithBinaryFile("coin-pro.skel", "coin.atlas", 1);
skeletonNode->setAnimation(0, "rotate", true);
skeletonNode->setAnimation(0, "rotate", true);
skeletonNode->setTwoColorTint(true);
skeletonNode->setPosition(Vec2(_contentSize.width / 2, 100));
addChild(skeletonNode);

View File

@ -44,7 +44,7 @@ bool TankExample::init () {
if (!LayerColor::initWithColor(Color4B(128, 128, 128, 255))) return false;
skeletonNode = SkeletonAnimation::createWithBinaryFile("tank-pro.skel", "tank.atlas", 0.5f);
skeletonNode->setAnimation(0, "drive", true);
skeletonNode->setAnimation(0, "shoot", true);
skeletonNode->setPosition(Vec2(_contentSize.width / 2 + 400, 20));
addChild(skeletonNode);

View File

@ -409,7 +409,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
if (!isTwoColorTint) {
if (_clipper->isClipping()) {
_clipper->clipTriangles((float*)&triangles.verts[0].vertices, triangles.indices, triangles.indexCount, (float*)&triangles.verts[0].texCoords, triangles.vertCount * sizeof(cocos2d::V3F_C4B_T2F) / 4);
_clipper->clipTriangles((float*)&triangles.verts[0].vertices, triangles.indices, triangles.indexCount, (float*)&triangles.verts[0].texCoords, sizeof(cocos2d::V3F_C4B_T2F) / 4);
batch->deallocateVertices(triangles.vertCount);
if (_clipper->getClippedTriangles().size() == 0){
@ -495,7 +495,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
}
} else {
if (_clipper->isClipping()) {
_clipper->clipTriangles((float*)&trianglesTwoColor.verts[0].position, trianglesTwoColor.indices, trianglesTwoColor.indexCount, (float*)&trianglesTwoColor.verts[0].texCoords, trianglesTwoColor.vertCount * sizeof(V3F_C4B_C4B_T2F) / 4);
_clipper->clipTriangles((float*)&trianglesTwoColor.verts[0].position, trianglesTwoColor.indices, trianglesTwoColor.indexCount, (float*)&trianglesTwoColor.verts[0].texCoords, sizeof(V3F_C4B_C4B_T2F) / 4);
twoColorBatch->deallocateVertices(trianglesTwoColor.vertCount);
if (_clipper->getClippedTriangles().size() == 0){

View File

@ -105,15 +105,15 @@ void SkeletonClipping::clipTriangles(float *vertices, unsigned short *triangles,
size_t i = 0;
continue_outer:
for (; i < trianglesLength; i += 3) {
int vertexOffset = triangles[i] << 1;
int vertexOffset = triangles[i] * stride;
float x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
float u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1];
vertexOffset = triangles[i + 1] << 1;
vertexOffset = triangles[i + 1] * stride;
float x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1];
float u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1];
vertexOffset = triangles[i + 2] << 1;
vertexOffset = triangles[i + 2] * stride;
float x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
float u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];