소스 검색

[cpp][sfml][cocos2dx] skip rendering of skeletons/slots/attachment with alpha equal 0.

badlogic 7 년 전
부모
커밋
218d3b4737
3개의 변경된 파일16개의 추가작업 그리고 15개의 파일을 삭제
  1. 2 2
      spine-cocos2dx/example/Classes/SpineboyExample.cpp
  2. 8 8
      spine-cocos2dx/src/spine/SkeletonRenderer.cpp
  3. 6 5
      spine-sfml/cpp/src/spine/spine-sfml.cpp

+ 2 - 2
spine-cocos2dx/example/Classes/SpineboyExample.cpp

@@ -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);

+ 8 - 8
spine-cocos2dx/src/spine/SkeletonRenderer.cpp

@@ -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;
 			}
 

+ 6 - 5
spine-sfml/cpp/src/spine/spine-sfml.cpp

@@ -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 = &regionAttachment->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 = &regionAttachment->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();
 }
-}
+}