|
@@ -137,26 +137,26 @@ namespace spine {
|
|
|
}
|
|
|
|
|
|
SkeletonRenderer::SkeletonRenderer()
|
|
|
- : _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
|
|
+ : _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
|
|
}
|
|
|
|
|
|
SkeletonRenderer::SkeletonRenderer(Skeleton *skeleton, bool ownsSkeleton, bool ownsSkeletonData, bool ownsAtlas)
|
|
|
- : _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
|
|
+ : _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
|
|
initWithSkeleton(skeleton, ownsSkeleton, ownsSkeletonData, ownsAtlas);
|
|
|
}
|
|
|
|
|
|
SkeletonRenderer::SkeletonRenderer(SkeletonData *skeletonData, bool ownsSkeletonData)
|
|
|
- : _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
|
|
+ : _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
|
|
initWithData(skeletonData, ownsSkeletonData);
|
|
|
}
|
|
|
|
|
|
SkeletonRenderer::SkeletonRenderer(const std::string &skeletonDataFile, Atlas *atlas, float scale)
|
|
|
- : _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
|
|
+ : _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
|
|
initWithJsonFile(skeletonDataFile, atlas, scale);
|
|
|
}
|
|
|
|
|
|
SkeletonRenderer::SkeletonRenderer(const std::string &skeletonDataFile, const std::string &atlasFile, float scale)
|
|
|
- : _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _effect(nullptr), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
|
|
+ : _atlas(nullptr), _attachmentLoader(nullptr), _timeScale(1), _debugSlots(false), _debugBones(false), _debugMeshes(false), _debugBoundingRect(false), _startSlotIndex(0), _endSlotIndex(std::numeric_limits<int>::max()) {
|
|
|
initWithJsonFile(skeletonDataFile, atlasFile, scale);
|
|
|
}
|
|
|
|
|
@@ -280,10 +280,6 @@ namespace spine {
|
|
|
SkeletonTwoColorBatch *twoColorBatch = SkeletonTwoColorBatch::getInstance();
|
|
|
const bool hasSingleTint = (isTwoColorTint() == false);
|
|
|
|
|
|
- if (_effect) {
|
|
|
- _effect->begin(*_skeleton);
|
|
|
- }
|
|
|
-
|
|
|
const Color3B displayedColor = getDisplayedColor();
|
|
|
Color nodeColor;
|
|
|
nodeColor.r = displayedColor.r / 255.f;
|
|
@@ -437,28 +433,14 @@ namespace spine {
|
|
|
|
|
|
const float *verts = _clipper->getClippedVertices().buffer();
|
|
|
const float *uvs = _clipper->getClippedUVs().buffer();
|
|
|
- if (_effect) {
|
|
|
- V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
|
- Color darkTmp;
|
|
|
- for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
|
|
- Color lightCopy = color;
|
|
|
- vertex->vertices.x = verts[vv];
|
|
|
- vertex->vertices.y = verts[vv + 1];
|
|
|
- vertex->texCoords.u = uvs[vv];
|
|
|
- vertex->texCoords.v = uvs[vv + 1];
|
|
|
- _effect->transform(vertex->vertices.x, vertex->vertices.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkTmp);
|
|
|
- vertex->colors = ColorToColor4B(lightCopy);
|
|
|
- }
|
|
|
- } else {
|
|
|
- V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
|
- for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
|
|
- vertex->vertices.x = verts[vv];
|
|
|
- vertex->vertices.y = verts[vv + 1];
|
|
|
- vertex->texCoords.u = uvs[vv];
|
|
|
- vertex->texCoords.v = uvs[vv + 1];
|
|
|
- vertex->colors = color4B;
|
|
|
- }
|
|
|
- }
|
|
|
+ V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
|
+ for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
|
|
+ vertex->vertices.x = verts[vv];
|
|
|
+ vertex->vertices.y = verts[vv + 1];
|
|
|
+ vertex->texCoords.u = uvs[vv];
|
|
|
+ vertex->texCoords.v = uvs[vv + 1];
|
|
|
+ vertex->colors = color4B;
|
|
|
+ }
|
|
|
} else {
|
|
|
// Not clipping.
|
|
|
#if COCOS2D_VERSION < 0x00040000
|
|
@@ -466,21 +448,10 @@ namespace spine {
|
|
|
#else
|
|
|
cocos2d::TrianglesCommand *batchedTriangles = batch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, triangles, transform, transformFlags);
|
|
|
#endif
|
|
|
-
|
|
|
- if (_effect) {
|
|
|
- V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
|
- Color darkTmp;
|
|
|
- for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
|
|
- Color lightCopy = color;
|
|
|
- _effect->transform(vertex->vertices.x, vertex->vertices.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkTmp);
|
|
|
- vertex->colors = ColorToColor4B(lightCopy);
|
|
|
- }
|
|
|
- } else {
|
|
|
- V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
|
- for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
|
|
- vertex->colors = color4B;
|
|
|
- }
|
|
|
- }
|
|
|
+ V3F_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
|
+ for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
|
|
+ vertex->colors = color4B;
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
// Two color tinting.
|
|
@@ -509,30 +480,15 @@ namespace spine {
|
|
|
const float *verts = _clipper->getClippedVertices().buffer();
|
|
|
const float *uvs = _clipper->getClippedUVs().buffer();
|
|
|
|
|
|
- if (_effect) {
|
|
|
- V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
|
- for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
|
|
- Color lightCopy = color;
|
|
|
- Color darkCopy = darkColor;
|
|
|
- vertex->position.x = verts[vv];
|
|
|
- vertex->position.y = verts[vv + 1];
|
|
|
- vertex->texCoords.u = uvs[vv];
|
|
|
- vertex->texCoords.v = uvs[vv + 1];
|
|
|
- _effect->transform(vertex->position.x, vertex->position.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkCopy);
|
|
|
- vertex->color = ColorToColor4B(lightCopy);
|
|
|
- vertex->color2 = ColorToColor4B(darkCopy);
|
|
|
- }
|
|
|
- } else {
|
|
|
- V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
|
- for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
|
|
- vertex->position.x = verts[vv];
|
|
|
- vertex->position.y = verts[vv + 1];
|
|
|
- vertex->texCoords.u = uvs[vv];
|
|
|
- vertex->texCoords.v = uvs[vv + 1];
|
|
|
- vertex->color = color4B;
|
|
|
- vertex->color2 = darkColor4B;
|
|
|
- }
|
|
|
- }
|
|
|
+ V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
|
+ for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2, ++vertex) {
|
|
|
+ vertex->position.x = verts[vv];
|
|
|
+ vertex->position.y = verts[vv + 1];
|
|
|
+ vertex->texCoords.u = uvs[vv];
|
|
|
+ vertex->texCoords.v = uvs[vv + 1];
|
|
|
+ vertex->color = color4B;
|
|
|
+ vertex->color2 = darkColor4B;
|
|
|
+ }
|
|
|
} else {
|
|
|
|
|
|
#if COCOS2D_VERSION < 0x00040000
|
|
@@ -541,22 +497,11 @@ namespace spine {
|
|
|
TwoColorTrianglesCommand *batchedTriangles = lastTwoColorTrianglesCommand = twoColorBatch->addCommand(renderer, _globalZOrder, attachmentVertices->_texture, _programState, blendFunc, trianglesTwoColor, transform, transformFlags);
|
|
|
#endif
|
|
|
|
|
|
- if (_effect) {
|
|
|
- V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
|
- for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
|
|
- Color lightCopy = color;
|
|
|
- Color darkCopy = darkColor;
|
|
|
- _effect->transform(vertex->position.x, vertex->position.y, vertex->texCoords.u, vertex->texCoords.v, lightCopy, darkCopy);
|
|
|
- vertex->color = ColorToColor4B(lightCopy);
|
|
|
- vertex->color2 = ColorToColor4B(darkCopy);
|
|
|
- }
|
|
|
- } else {
|
|
|
- V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
|
- for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
|
|
- vertex->color = color4B;
|
|
|
- vertex->color2 = darkColor4B;
|
|
|
- }
|
|
|
- }
|
|
|
+ V3F_C4B_C4B_T2F *vertex = batchedTriangles->getTriangles().verts;
|
|
|
+ for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v, ++vertex) {
|
|
|
+ vertex->color = color4B;
|
|
|
+ vertex->color2 = darkColor4B;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
_clipper->clipEnd(*slot);
|
|
@@ -597,8 +542,6 @@ namespace spine {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (_effect) _effect->end();
|
|
|
-
|
|
|
if (_debugBoundingRect || _debugSlots || _debugBones || _debugMeshes) {
|
|
|
drawDebug(renderer, transform, transformFlags);
|
|
|
}
|
|
@@ -797,10 +740,6 @@ namespace spine {
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
- void SkeletonRenderer::setVertexEffect(VertexEffect *effect) {
|
|
|
- this->_effect = effect;
|
|
|
- }
|
|
|
-
|
|
|
void SkeletonRenderer::setSlotsRange(int startSlotIndex, int endSlotIndex) {
|
|
|
_startSlotIndex = startSlotIndex == -1 ? 0 : startSlotIndex;
|
|
|
_endSlotIndex = endSlotIndex == -1 ? std::numeric_limits<int>::max() : endSlotIndex;
|