mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[cpp][sfml][cocos2dx] skip rendering of skeletons/slots/attachment with alpha equal 0.
This commit is contained in:
parent
22c1e32164
commit
218d3b4737
@ -29,7 +29,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "SpineboyExample.h"
|
#include "SpineboyExample.h"
|
||||||
#include "GoblinsExample.h"
|
#include "SkeletonRendererSeparatorExample.h"
|
||||||
|
|
||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
@ -89,7 +89,7 @@ bool SpineboyExample::init () {
|
|||||||
else if (skeletonNode->getTimeScale() == 1)
|
else if (skeletonNode->getTimeScale() == 1)
|
||||||
skeletonNode->setTimeScale(0.3f);
|
skeletonNode->setTimeScale(0.3f);
|
||||||
else
|
else
|
||||||
Director::getInstance()->replaceScene(GoblinsExample::scene());
|
Director::getInstance()->replaceScene(SkeletonRendererSeparatorExample::scene());
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||||
|
|||||||
@ -266,11 +266,11 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
|||||||
bool isTwoColorTint = this->isTwoColorTint();
|
bool isTwoColorTint = this->isTwoColorTint();
|
||||||
|
|
||||||
// Early exit if the skeleton is invisible
|
// Early exit if the skeleton is invisible
|
||||||
if (getDisplayedOpacity() == 0 || _skeleton->color.a == 0){
|
if (getDisplayedOpacity() == 0 || _skeleton->getColor().a == 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_effect) _effect->begin(_effect, _skeleton);
|
if (_effect) _effect->begin(*_skeleton);
|
||||||
|
|
||||||
Color4F nodeColor;
|
Color4F nodeColor;
|
||||||
nodeColor.r = getDisplayedColor().r / (float)255;
|
nodeColor.r = getDisplayedColor().r / (float)255;
|
||||||
@ -306,8 +306,8 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Early exit if slot is invisible
|
// Early exit if slot is invisible
|
||||||
if (slot->color.a == 0) {
|
if (slot->getColor().a == 0) {
|
||||||
spSkeletonClipping_clipEnd(_clipper, slot);
|
_clipper->clipEnd(*slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,8 +319,8 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
|||||||
attachmentVertices = (AttachmentVertices*)attachment->getRendererObject();
|
attachmentVertices = (AttachmentVertices*)attachment->getRendererObject();
|
||||||
|
|
||||||
// Early exit if attachment is invisible
|
// Early exit if attachment is invisible
|
||||||
if (attachment->color.a == 0) {
|
if (attachment->getColor().a == 0) {
|
||||||
spSkeletonClipping_clipEnd(_clipper, slot);
|
_clipper->clipEnd(*slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,8 +352,8 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
|||||||
attachmentVertices = (AttachmentVertices*)attachment->getRendererObject();
|
attachmentVertices = (AttachmentVertices*)attachment->getRendererObject();
|
||||||
|
|
||||||
// Early exit if attachment is invisible
|
// Early exit if attachment is invisible
|
||||||
if (attachment->color.a == 0) {
|
if (attachment->getColor().a == 0) {
|
||||||
spSkeletonClipping_clipEnd(_clipper, slot);
|
_clipper->clipEnd(*slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -91,7 +91,7 @@ void SkeletonDrawable::draw(RenderTarget &target, RenderStates states) const {
|
|||||||
vertexArray->clear();
|
vertexArray->clear();
|
||||||
states.texture = NULL;
|
states.texture = NULL;
|
||||||
|
|
||||||
// Early out if the skeleton alpha is 0
|
// Early out if skeleton is invisible
|
||||||
if (skeleton->getColor().a == 0) return;
|
if (skeleton->getColor().a == 0) return;
|
||||||
|
|
||||||
if (vertexEffect != NULL) vertexEffect->begin(*skeleton);
|
if (vertexEffect != NULL) vertexEffect->begin(*skeleton);
|
||||||
@ -120,7 +120,7 @@ void SkeletonDrawable::draw(RenderTarget &target, RenderStates states) const {
|
|||||||
RegionAttachment *regionAttachment = (RegionAttachment *) attachment;
|
RegionAttachment *regionAttachment = (RegionAttachment *) attachment;
|
||||||
attachmentColor = ®ionAttachment->getColor();
|
attachmentColor = ®ionAttachment->getColor();
|
||||||
|
|
||||||
// Early out if the attachment color is 0
|
// Early out if the slot color is 0
|
||||||
if (attachmentColor->a == 0) {
|
if (attachmentColor->a == 0) {
|
||||||
clipper.clipEnd(slot);
|
clipper.clipEnd(slot);
|
||||||
continue;
|
continue;
|
||||||
@ -132,13 +132,13 @@ void SkeletonDrawable::draw(RenderTarget &target, RenderStates states) const {
|
|||||||
uvs = ®ionAttachment->getUVs();
|
uvs = ®ionAttachment->getUVs();
|
||||||
indices = &quadIndices;
|
indices = &quadIndices;
|
||||||
indicesCount = 6;
|
indicesCount = 6;
|
||||||
texture = (Texture *) ((AtlasRegion *) regionAttachment->getRendererObject())->page->rendererObject;
|
texture = (Texture *) ((AtlasRegion *) regionAttachment->getRendererObject())->page->getRendererObject();
|
||||||
|
|
||||||
} else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
|
} else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
|
||||||
MeshAttachment *mesh = (MeshAttachment *) attachment;
|
MeshAttachment *mesh = (MeshAttachment *) attachment;
|
||||||
attachmentColor = &mesh->getColor();
|
attachmentColor = &mesh->getColor();
|
||||||
|
|
||||||
// Early out if the attachment color is 0
|
// Early out if the slot color is 0
|
||||||
if (attachmentColor->a == 0) {
|
if (attachmentColor->a == 0) {
|
||||||
clipper.clipEnd(slot);
|
clipper.clipEnd(slot);
|
||||||
continue;
|
continue;
|
||||||
@ -151,6 +151,7 @@ void SkeletonDrawable::draw(RenderTarget &target, RenderStates states) const {
|
|||||||
uvs = &mesh->getUVs();
|
uvs = &mesh->getUVs();
|
||||||
indices = &mesh->getTriangles();
|
indices = &mesh->getTriangles();
|
||||||
indicesCount = mesh->getTriangles().size();
|
indicesCount = mesh->getTriangles().size();
|
||||||
|
|
||||||
} else if (attachment->getRTTI().isExactly(ClippingAttachment::rtti)) {
|
} else if (attachment->getRTTI().isExactly(ClippingAttachment::rtti)) {
|
||||||
ClippingAttachment *clip = (ClippingAttachment *) slot.getAttachment();
|
ClippingAttachment *clip = (ClippingAttachment *) slot.getAttachment();
|
||||||
clipper.clipStart(slot, clip);
|
clipper.clipStart(slot, clip);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user