Bläddra i källkod

[cocos2dx] Removed VertexEffect, see #2076

Mario Zechner 3 år sedan
förälder
incheckning
ee1c698197

+ 0 - 12
spine-cocos2dx/example/Classes/RaptorExample.cpp

@@ -36,7 +36,6 @@ using namespace spine;
 
 PowInterpolation pow2(2);
 PowOutInterpolation powOut2(2);
-SwirlVertexEffect effect(400, powOut2);
 
 Scene *RaptorExample::scene() {
 	Scene *scene = Scene::create();
@@ -52,10 +51,6 @@ bool RaptorExample::init() {
 	skeletonNode->addAnimation(1, "gun-grab", false, 2);
 	skeletonNode->setTwoColorTint(true);
 
-	effect.setCenterY(200);
-	swirlTime = 0;
-
-	skeletonNode->setVertexEffect(&effect);
 
 	skeletonNode->setPosition(Vec2(_contentSize.width / 2, 20));
 	addChild(skeletonNode);
@@ -77,10 +72,3 @@ bool RaptorExample::init() {
 
 	return true;
 }
-
-void RaptorExample::update(float fDelta) {
-	swirlTime += fDelta;
-	float percent = spine::MathUtil::fmod(swirlTime, 2);
-	if (percent > 1) percent = 1 - (percent - 1);
-	effect.setAngle(pow2.interpolate(-60.0f, 60.0f, percent));
-}

+ 1 - 3
spine-cocos2dx/example/Classes/RaptorExample.h

@@ -39,9 +39,7 @@ public:
 
 	CREATE_FUNC(RaptorExample);
 
-	virtual bool init();
-
-	virtual void update(float fDelta);
+	virtual bool init();	
 
 private:
 	spine::SkeletonAnimation *skeletonNode;

+ 31 - 92
spine-cocos2dx/spine-cocos2dx/src/spine/SkeletonRenderer.cpp

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

+ 1 - 5
spine-cocos2dx/spine-cocos2dx/src/spine/SkeletonRenderer.h

@@ -102,9 +102,6 @@ namespace spine {
 		/* Whether two color tinting is enabled */
 		bool isTwoColorTint();
 
-		/* Sets the vertex effect to be used, set to 0 to disable vertex effects */
-		void setVertexEffect(VertexEffect *effect);
-
 		/* Sets the range of slots that should be rendered. Use -1, -1 to clear the range */
 		void setSlotsRange(int startSlotIndex, int endSlotIndex);
 
@@ -150,8 +147,7 @@ namespace spine {
 		bool _debugBones;
 		bool _debugMeshes;
 		bool _debugBoundingRect;
-		SkeletonClipping *_clipper;
-		VertexEffect *_effect;
+		SkeletonClipping *_clipper;		
 		cocos2d::Rect _boundingRect;
 
 		int _startSlotIndex;