Skip to content

Commit 2594ab6

Browse files
committed
refine
1 parent efcb868 commit 2594ab6

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

native/cocos/editor-support/spine-creator-support/SkeletonRenderer.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@
4545
#include "spine-creator-support/spine-cocos2dx.h"
4646

4747

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-
5648
USING_NS_MW; // NOLINT(google-build-using-namespace)
5749
using namespace spine; // NOLINT(google-build-using-namespace)
5850
using namespace cc; // NOLINT(google-build-using-namespace)
@@ -73,6 +65,14 @@ enum DebugType {
7365
BONES
7466
};
7567

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+
7676
extern "C" AttachmentVertices *generateAttachmentVertices(Attachment *attachment);
7777
namespace cc {
7878
SkeletonRenderer *SkeletonRenderer::create() {
@@ -494,7 +494,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
494494
#if CC_USE_SPINE_3_8
495495
attachment->computeWorldVertices(slot->getBone(), reinterpret_cast<float *>(triangles.verts), 0, vs1);
496496
#else
497-
LOOP_UV_COORDS(triangles.verts, attachment->getUVs(), triangles.vertCount);
497+
loopUVCoords(triangles.verts, attachment->getUVs(), triangles.vertCount);
498498
attachment->computeWorldVertices(*slot, reinterpret_cast<float *>(triangles.verts), 0, vs1);
499499
#endif
500500

@@ -514,7 +514,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
514514
}
515515
attachment->computeWorldVertices(slot->getBone(), reinterpret_cast<float *>(trianglesTwoColor.verts), 0, vs2);
516516
#else
517-
LOOP_UV_COORDS(trianglesTwoColor.verts, attachment->getUVs(), trianglesTwoColor.vertCount);
517+
loopUVCoords(trianglesTwoColor.verts, attachment->getUVs(), trianglesTwoColor.vertCount);
518518
attachment->computeWorldVertices(*slot, reinterpret_cast<float *>(trianglesTwoColor.verts), 0, vs2);
519519
#endif
520520

@@ -569,7 +569,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
569569
triangles.verts = reinterpret_cast<V3F_T2F_C4B *>(vb.getCurBuffer());
570570
memcpy(static_cast<void *>(triangles.verts), static_cast<void *>(attachmentVertices->_triangles->verts), vbSize);
571571
#ifdef CC_USE_SPINE_4_2
572-
LOOP_UV_COORDS(triangles.verts, attachment->getUVs(), triangles.vertCount);
572+
loopUVCoords(triangles.verts, attachment->getUVs(), triangles.vertCount);
573573
#endif
574574
attachment->computeWorldVertices(*slot, 0, attachment->getWorldVerticesLength(), reinterpret_cast<float *>(triangles.verts), 0, vs1);
575575

@@ -588,7 +588,7 @@ void SkeletonRenderer::render(float /*deltaTime*/) {
588588
trianglesTwoColor.verts[ii].texCoord = attachmentVertices->_triangles->verts[ii].texCoord;
589589
}
590590
#else
591-
LOOP_UV_COORDS(trianglesTwoColor.verts, attachment->getUVs(), trianglesTwoColor.vertCount);
591+
loopUVCoords(trianglesTwoColor.verts, attachment->getUVs(), trianglesTwoColor.vertCount);
592592
#endif
593593
attachment->computeWorldVertices(*slot, 0, attachment->getWorldVerticesLength(), reinterpret_cast<float *>(trianglesTwoColor.verts), 0, vs2);
594594

native/cocos/editor-support/spine-wasm/spine-skeleton-instance.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ extern HashMap<SkeletonData *, HashMap<Attachment *, AttachmentVertices *>*> spi
1717
extern HashMap<SkeletonData *, HashMap<spine::String, spine::String>*> spineTexturesMap;
1818

1919

20-
//------------------------- UV坐标处理 -------------------------
2120
template<typename VertexType, typename UVArrayType>
2221
void loopUVCoords(VertexType* tmp, const UVArrayType& uvs, int count) {
2322
for (int i = 0, ii = 0; i < count; ++i, ii += 2) {
@@ -30,12 +29,11 @@ void loopUVCoords(VertexType* tmp, const UVArrayType& uvs, int count) {
3029
template<typename MeshT,
3130
typename AttachmentT,
3231
typename VerticesT,
33-
typename TexMapT> // 默认使用全局版本控制
32+
typename TexMapT>
3433
void setSpineTextureID(MeshT& currMesh,
3534
AttachmentT* attachment,
3635
VerticesT* vertices,
3736
TexMapT* texMap) {
38-
// Spine 4.2 实现
3937
if (auto* region = static_cast<AtlasRegion*>(attachment->getRegion())) {
4038
if (region->page && region->page->name != vertices->_textureName) {
4139
currMesh.textureID = (*texMap)[region->page->name];

0 commit comments

Comments
 (0)