mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-22 02:06:03 +08:00
[cocos2d-x] Fixed broken mesh indices when RegionAttachment alpha == 0. Closes #1708.
This commit is contained in:
parent
06bd6a90bd
commit
254baf4d75
@ -48,6 +48,7 @@ namespace spine {
|
|||||||
bool cullRectangle(Renderer* renderer, const Mat4& transform, const cocos2d::Rect& rect);
|
bool cullRectangle(Renderer* renderer, const Mat4& transform, const cocos2d::Rect& rect);
|
||||||
Color4B ColorToColor4B(const Color& color);
|
Color4B ColorToColor4B(const Color& color);
|
||||||
bool slotIsOutRange(Slot& slot, int startSlotIndex, int endSlotIndex);
|
bool slotIsOutRange(Slot& slot, int startSlotIndex, int endSlotIndex);
|
||||||
|
bool nothingToDraw(Slot& slot, int startSlotIndex, int endSlotIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// C Variable length array
|
// C Variable length array
|
||||||
@ -301,18 +302,7 @@ namespace spine {
|
|||||||
for (int i = 0, n = _skeleton->getSlots().size(); i < n; ++i) {
|
for (int i = 0, n = _skeleton->getSlots().size(); i < n; ++i) {
|
||||||
Slot* slot = _skeleton->getDrawOrder()[i];;
|
Slot* slot = _skeleton->getDrawOrder()[i];;
|
||||||
|
|
||||||
if (slotIsOutRange(*slot, _startSlotIndex, _endSlotIndex)) {
|
if (nothingToDraw(*slot, _startSlotIndex, _endSlotIndex)) {
|
||||||
_clipper->clipEnd(*slot);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!slot->getAttachment()) {
|
|
||||||
_clipper->clipEnd(*slot);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Early exit if slot is invisible
|
|
||||||
if (slot->getColor().a == 0 || !slot->getBone().isActive()) {
|
|
||||||
_clipper->clipEnd(*slot);
|
_clipper->clipEnd(*slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -324,12 +314,6 @@ namespace spine {
|
|||||||
RegionAttachment* attachment = static_cast<RegionAttachment*>(slot->getAttachment());
|
RegionAttachment* attachment = static_cast<RegionAttachment*>(slot->getAttachment());
|
||||||
attachmentVertices = static_cast<AttachmentVertices*>(attachment->getRendererObject());
|
attachmentVertices = static_cast<AttachmentVertices*>(attachment->getRendererObject());
|
||||||
|
|
||||||
// Early exit if attachment is invisible
|
|
||||||
if (attachment->getColor().a == 0) {
|
|
||||||
_clipper->clipEnd(*slot);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
float* dstTriangleVertices = nullptr;
|
float* dstTriangleVertices = nullptr;
|
||||||
int dstStride = 0; // in floats
|
int dstStride = 0; // in floats
|
||||||
if (hasSingleTint) {
|
if (hasSingleTint) {
|
||||||
@ -935,21 +919,28 @@ namespace spine {
|
|||||||
return startSlotIndex > index || endSlotIndex < index;
|
return startSlotIndex > index || endSlotIndex < index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool nothingToDraw(Slot& slot, int startSlotIndex, int endSlotIndex) {
|
||||||
|
Attachment *attachment = slot.getAttachment();
|
||||||
|
if (!attachment ||
|
||||||
|
slotIsOutRange(slot, startSlotIndex, endSlotIndex) ||
|
||||||
|
!slot.getBone().isActive() ||
|
||||||
|
slot.getColor().a == 0)
|
||||||
|
return true;
|
||||||
|
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
|
||||||
|
if (static_cast<RegionAttachment*>(attachment)->getColor().a == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int computeTotalCoordCount(Skeleton& skeleton, int startSlotIndex, int endSlotIndex) {
|
int computeTotalCoordCount(Skeleton& skeleton, int startSlotIndex, int endSlotIndex) {
|
||||||
int coordCount = 0;
|
int coordCount = 0;
|
||||||
for (size_t i = 0; i < skeleton.getSlots().size(); ++i) {
|
for (size_t i = 0; i < skeleton.getSlots().size(); ++i) {
|
||||||
Slot& slot = *skeleton.getSlots()[i];
|
Slot& slot = *skeleton.getSlots()[i];
|
||||||
|
if (nothingToDraw(slot, startSlotIndex, endSlotIndex)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Attachment* const attachment = slot.getAttachment();
|
Attachment* const attachment = slot.getAttachment();
|
||||||
if (!attachment) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (slotIsOutRange(slot, startSlotIndex, endSlotIndex)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Early exit if slot is invisible
|
|
||||||
if (slot.getColor().a == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
|
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
|
||||||
coordCount += 8;
|
coordCount += 8;
|
||||||
}
|
}
|
||||||
@ -969,16 +960,10 @@ namespace spine {
|
|||||||
#endif
|
#endif
|
||||||
for (size_t i = 0; i < skeleton.getSlots().size(); ++i) {
|
for (size_t i = 0; i < skeleton.getSlots().size(); ++i) {
|
||||||
/*const*/ Slot& slot = *skeleton.getDrawOrder()[i]; // match the draw order of SkeletonRenderer::Draw
|
/*const*/ Slot& slot = *skeleton.getDrawOrder()[i]; // match the draw order of SkeletonRenderer::Draw
|
||||||
|
if (nothingToDraw(slot, startSlotIndex, endSlotIndex)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Attachment* const attachment = slot.getAttachment();
|
Attachment* const attachment = slot.getAttachment();
|
||||||
if (!attachment) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (slotIsOutRange(slot, startSlotIndex, endSlotIndex)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (slot.getColor().a == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
|
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
|
||||||
RegionAttachment* const regionAttachment = static_cast<RegionAttachment*>(attachment);
|
RegionAttachment* const regionAttachment = static_cast<RegionAttachment*>(attachment);
|
||||||
assert(dstPtr + 8 <= dstEnd);
|
assert(dstPtr + 8 <= dstEnd);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user