mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[cocos2dx] More fixes to two color batching.
This commit is contained in:
parent
ec718b73ee
commit
7e68a48189
@ -107,7 +107,7 @@ bool AppDelegate::applicationDidFinishLaunching () {
|
|||||||
|
|
||||||
// create a scene. it's an autorelease object
|
// create a scene. it's an autorelease object
|
||||||
//auto scene = RaptorExample::scene();
|
//auto scene = RaptorExample::scene();
|
||||||
auto scene = SkeletonRendererSeparatorExample::scene();
|
auto scene = CoinExample::scene();
|
||||||
|
|
||||||
// run
|
// run
|
||||||
director->runWithScene(scene);
|
director->runWithScene(scene);
|
||||||
|
|||||||
@ -45,6 +45,7 @@ bool CoinExample::init () {
|
|||||||
|
|
||||||
skeletonNode = SkeletonAnimation::createWithBinaryFile("coin-pro.skel", "coin.atlas", 1);
|
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));
|
skeletonNode->setPosition(Vec2(_contentSize.width / 2, 100));
|
||||||
addChild(skeletonNode);
|
addChild(skeletonNode);
|
||||||
|
|||||||
@ -44,7 +44,7 @@ bool TankExample::init () {
|
|||||||
if (!LayerColor::initWithColor(Color4B(128, 128, 128, 255))) return false;
|
if (!LayerColor::initWithColor(Color4B(128, 128, 128, 255))) return false;
|
||||||
|
|
||||||
skeletonNode = SkeletonAnimation::createWithBinaryFile("tank-pro.skel", "tank.atlas", 0.5f);
|
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));
|
skeletonNode->setPosition(Vec2(_contentSize.width / 2 + 400, 20));
|
||||||
addChild(skeletonNode);
|
addChild(skeletonNode);
|
||||||
|
|||||||
@ -409,7 +409,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
|||||||
|
|
||||||
if (!isTwoColorTint) {
|
if (!isTwoColorTint) {
|
||||||
if (_clipper->isClipping()) {
|
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);
|
batch->deallocateVertices(triangles.vertCount);
|
||||||
|
|
||||||
if (_clipper->getClippedTriangles().size() == 0){
|
if (_clipper->getClippedTriangles().size() == 0){
|
||||||
@ -495,7 +495,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_clipper->isClipping()) {
|
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);
|
twoColorBatch->deallocateVertices(trianglesTwoColor.vertCount);
|
||||||
|
|
||||||
if (_clipper->getClippedTriangles().size() == 0){
|
if (_clipper->getClippedTriangles().size() == 0){
|
||||||
|
|||||||
@ -105,15 +105,15 @@ void SkeletonClipping::clipTriangles(float *vertices, unsigned short *triangles,
|
|||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
continue_outer:
|
continue_outer:
|
||||||
for (; i < trianglesLength; i += 3) {
|
for (; i < trianglesLength; i += 3) {
|
||||||
int vertexOffset = triangles[i] << 1;
|
int vertexOffset = triangles[i] * stride;
|
||||||
float x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
|
float x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
|
||||||
float u1 = uvs[vertexOffset], v1 = uvs[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 x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1];
|
||||||
float u2 = uvs[vertexOffset], v2 = uvs[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 x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
|
||||||
float u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];
|
float u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user