45
45
#include " spine-creator-support/spine-cocos2dx.h"
46
46
47
47
48
- #define LOOP_UV_COORDS (tmp_var, uvs_var, loop_count ) \
49
- for (int _i = 0 , _ii = 0 ; _i < (loop_count); ++_i, _ii += 2 ) { \
50
- (tmp_var)[_i].texCoord .u = (uvs_var)[_ii]; \
51
- (tmp_var)[_i].texCoord .v = (uvs_var)[_ii + 1 ]; \
52
- }
53
-
54
-
55
-
56
48
USING_NS_MW; // NOLINT(google-build-using-namespace)
57
49
using namespace spine ; // NOLINT(google-build-using-namespace)
58
50
using namespace cc ; // NOLINT(google-build-using-namespace)
@@ -73,6 +65,14 @@ enum DebugType {
73
65
BONES
74
66
};
75
67
68
+ template <typename VertexType, typename UVArrayType>
69
+ void loopUVCoords (VertexType* tmp, const UVArrayType& uvs, int count) {
70
+ for (int i = 0 , ii = 0 ; i < count; ++i, ii += 2 ) {
71
+ tmp[i].texCoord .u = uvs[ii];
72
+ tmp[i].texCoord .v = uvs[ii + 1 ];
73
+ }
74
+ }
75
+
76
76
extern " C" AttachmentVertices *generateAttachmentVertices (Attachment *attachment);
77
77
namespace cc {
78
78
SkeletonRenderer *SkeletonRenderer::create () {
@@ -494,7 +494,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
494
494
#if CC_USE_SPINE_3_8
495
495
attachment->computeWorldVertices (slot->getBone (), reinterpret_cast <float *>(triangles.verts ), 0 , vs1);
496
496
#else
497
- LOOP_UV_COORDS (triangles.verts , attachment->getUVs (), triangles.vertCount );
497
+ loopUVCoords (triangles.verts , attachment->getUVs (), triangles.vertCount );
498
498
attachment->computeWorldVertices (*slot, reinterpret_cast <float *>(triangles.verts ), 0 , vs1);
499
499
#endif
500
500
@@ -514,7 +514,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
514
514
}
515
515
attachment->computeWorldVertices (slot->getBone (), reinterpret_cast <float *>(trianglesTwoColor.verts ), 0 , vs2);
516
516
#else
517
- LOOP_UV_COORDS (trianglesTwoColor.verts , attachment->getUVs (), trianglesTwoColor.vertCount );
517
+ loopUVCoords (trianglesTwoColor.verts , attachment->getUVs (), trianglesTwoColor.vertCount );
518
518
attachment->computeWorldVertices (*slot, reinterpret_cast <float *>(trianglesTwoColor.verts ), 0 , vs2);
519
519
#endif
520
520
@@ -569,7 +569,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
569
569
triangles.verts = reinterpret_cast <V3F_T2F_C4B *>(vb.getCurBuffer ());
570
570
memcpy (static_cast <void *>(triangles.verts ), static_cast <void *>(attachmentVertices->_triangles ->verts ), vbSize);
571
571
#ifdef CC_USE_SPINE_4_2
572
- LOOP_UV_COORDS (triangles.verts , attachment->getUVs (), triangles.vertCount );
572
+ loopUVCoords (triangles.verts , attachment->getUVs (), triangles.vertCount );
573
573
#endif
574
574
attachment->computeWorldVertices (*slot, 0 , attachment->getWorldVerticesLength (), reinterpret_cast <float *>(triangles.verts ), 0 , vs1);
575
575
@@ -588,7 +588,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
588
588
trianglesTwoColor.verts [ii].texCoord = attachmentVertices->_triangles ->verts [ii].texCoord ;
589
589
}
590
590
#else
591
- LOOP_UV_COORDS (trianglesTwoColor.verts , attachment->getUVs (), trianglesTwoColor.vertCount );
591
+ loopUVCoords (trianglesTwoColor.verts , attachment->getUVs (), trianglesTwoColor.vertCount );
592
592
#endif
593
593
attachment->computeWorldVertices (*slot, 0 , attachment->getWorldVerticesLength (), reinterpret_cast <float *>(trianglesTwoColor.verts ), 0 , vs2);
594
594
0 commit comments