mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +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 "GoblinsExample.h"
|
||||
#include "SkeletonRendererSeparatorExample.h"
|
||||
|
||||
USING_NS_CC;
|
||||
using namespace spine;
|
||||
@ -89,7 +89,7 @@ bool SpineboyExample::init () {
|
||||
else if (skeletonNode->getTimeScale() == 1)
|
||||
skeletonNode->setTimeScale(0.3f);
|
||||
else
|
||||
Director::getInstance()->replaceScene(GoblinsExample::scene());
|
||||
Director::getInstance()->replaceScene(SkeletonRendererSeparatorExample::scene());
|
||||
return true;
|
||||
};
|
||||
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||
|
||||
@ -266,11 +266,11 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
||||
bool isTwoColorTint = this->isTwoColorTint();
|
||||
|
||||
// Early exit if the skeleton is invisible
|
||||
if (getDisplayedOpacity() == 0 || _skeleton->color.a == 0){
|
||||
if (getDisplayedOpacity() == 0 || _skeleton->getColor().a == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
if (_effect) _effect->begin(_effect, _skeleton);
|
||||
if (_effect) _effect->begin(*_skeleton);
|
||||
|
||||
Color4F nodeColor;
|
||||
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
|
||||
if (slot->color.a == 0) {
|
||||
spSkeletonClipping_clipEnd(_clipper, slot);
|
||||
if (slot->getColor().a == 0) {
|
||||
_clipper->clipEnd(*slot);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -319,8 +319,8 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
||||
attachmentVertices = (AttachmentVertices*)attachment->getRendererObject();
|
||||
|
||||
// Early exit if attachment is invisible
|
||||
if (attachment->color.a == 0) {
|
||||
spSkeletonClipping_clipEnd(_clipper, slot);
|
||||
if (attachment->getColor().a == 0) {
|
||||
_clipper->clipEnd(*slot);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -352,8 +352,8 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
|
||||
attachmentVertices = (AttachmentVertices*)attachment->getRendererObject();
|
||||
|
||||
// Early exit if attachment is invisible
|
||||
if (attachment->color.a == 0) {
|
||||
spSkeletonClipping_clipEnd(_clipper, slot);
|
||||
if (attachment->getColor().a == 0) {
|
||||
_clipper->clipEnd(*slot);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ void SkeletonDrawable::draw(RenderTarget &target, RenderStates states) const {
|
||||
vertexArray->clear();
|
||||
states.texture = NULL;
|
||||
|
||||
// Early out if the skeleton alpha is 0
|
||||
// Early out if skeleton is invisible
|
||||
if (skeleton->getColor().a == 0) return;
|
||||
|
||||
if (vertexEffect != NULL) vertexEffect->begin(*skeleton);
|
||||
@ -120,7 +120,7 @@ void SkeletonDrawable::draw(RenderTarget &target, RenderStates states) const {
|
||||
RegionAttachment *regionAttachment = (RegionAttachment *) attachment;
|
||||
attachmentColor = ®ionAttachment->getColor();
|
||||
|
||||
// Early out if the attachment color is 0
|
||||
// Early out if the slot color is 0
|
||||
if (attachmentColor->a == 0) {
|
||||
clipper.clipEnd(slot);
|
||||
continue;
|
||||
@ -132,13 +132,13 @@ void SkeletonDrawable::draw(RenderTarget &target, RenderStates states) const {
|
||||
uvs = ®ionAttachment->getUVs();
|
||||
indices = &quadIndices;
|
||||
indicesCount = 6;
|
||||
texture = (Texture *) ((AtlasRegion *) regionAttachment->getRendererObject())->page->rendererObject;
|
||||
texture = (Texture *) ((AtlasRegion *) regionAttachment->getRendererObject())->page->getRendererObject();
|
||||
|
||||
} else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
|
||||
MeshAttachment *mesh = (MeshAttachment *) attachment;
|
||||
attachmentColor = &mesh->getColor();
|
||||
|
||||
// Early out if the attachment color is 0
|
||||
// Early out if the slot color is 0
|
||||
if (attachmentColor->a == 0) {
|
||||
clipper.clipEnd(slot);
|
||||
continue;
|
||||
@ -151,6 +151,7 @@ void SkeletonDrawable::draw(RenderTarget &target, RenderStates states) const {
|
||||
uvs = &mesh->getUVs();
|
||||
indices = &mesh->getTriangles();
|
||||
indicesCount = mesh->getTriangles().size();
|
||||
|
||||
} else if (attachment->getRTTI().isExactly(ClippingAttachment::rtti)) {
|
||||
ClippingAttachment *clip = (ClippingAttachment *) slot.getAttachment();
|
||||
clipper.clipStart(slot, clip);
|
||||
@ -304,4 +305,4 @@ void SFMLTextureLoader::unload(void *texture) {
|
||||
SpineExtension *getDefaultExtension() {
|
||||
return new DefaultSpineExtension();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user