Skip to content

Commit 06ba9c5

Browse files
committed
Tidy vertex format
1 parent 16bc58a commit 06ba9c5

File tree

102 files changed

+1205
-1365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1205
-1365
lines changed

3rdparty/box2d/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(target_name ${lib_name})
44

55
project(${lib_name})
66

7-
FILE(GLOB_RECURSE box2d_sources *.h;*.c)
7+
file(GLOB_RECURSE box2d_sources *.h;*.c)
88

99
add_library(${target_name} ${box2d_sources})
1010

core/2d/AnchoredSprite.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ void AnchoredSprite::setVertexCoords(const Rect& rect, V3F_C4F_T2F_Quad* outQuad
186186
const float y2 = y1 + rect.size.height;
187187

188188
// Don't update Z.
189-
outQuad->bl.vertices.set(x1, y1, 0.0f);
190-
outQuad->br.vertices.set(x2, y1, 0.0f);
191-
outQuad->tl.vertices.set(x1, y2, 0.0f);
192-
outQuad->tr.vertices.set(x2, y2, 0.0f);
189+
outQuad->bl.position.set(x1, y1, 0.0f);
190+
outQuad->br.position.set(x2, y1, 0.0f);
191+
outQuad->tl.position.set(x1, y2, 0.0f);
192+
outQuad->tr.position.set(x2, y2, 0.0f);
193193
}
194194
}
195195

core/2d/AutoPolygon.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ PolygonInfo::PolygonInfo(const PolygonInfo& other) : triangles(), _isVertsOwner(
6363
_filename = other._filename;
6464
_isVertsOwner = true;
6565
_rect = other._rect;
66-
triangles.verts = new V3F_C4F_T2F[other.triangles.vertCount];
66+
triangles.verts = new V3F_T2F_C4F[other.triangles.vertCount];
6767
triangles.indices = new unsigned short[other.triangles.indexCount];
6868
AXASSERT(triangles.verts && triangles.indices, "not enough memory");
6969
triangles.vertCount = other.triangles.vertCount;
@@ -80,7 +80,7 @@ PolygonInfo& PolygonInfo::operator=(const PolygonInfo& other)
8080
_filename = other._filename;
8181
_isVertsOwner = true;
8282
_rect = other._rect;
83-
triangles.verts = new V3F_C4F_T2F[other.triangles.vertCount];
83+
triangles.verts = new V3F_T2F_C4F[other.triangles.vertCount];
8484
triangles.indices = new unsigned short[other.triangles.indexCount];
8585
AXASSERT(triangles.verts && triangles.indices, "not enough memory");
8686
triangles.vertCount = other.triangles.vertCount;
@@ -104,7 +104,7 @@ void PolygonInfo::setQuad(V3F_C4F_T2F_Quad* quad)
104104
triangles.indices = quadIndices9;
105105
triangles.vertCount = 4;
106106
triangles.indexCount = 6;
107-
triangles.verts = (V3F_C4F_T2F*)quad;
107+
triangles.verts = (V3F_T2F_C4F*)quad;
108108
}
109109

110110
void PolygonInfo::setQuads(V3F_C4F_T2F_Quad* quad, int numberOfQuads)
@@ -116,7 +116,7 @@ void PolygonInfo::setQuads(V3F_C4F_T2F_Quad* quad, int numberOfQuads)
116116
triangles.indices = quadIndices9;
117117
triangles.vertCount = 4 * numberOfQuads;
118118
triangles.indexCount = 6 * numberOfQuads;
119-
triangles.verts = (V3F_C4F_T2F*)quad;
119+
triangles.verts = (V3F_T2F_C4F*)quad;
120120
}
121121

122122
void PolygonInfo::setTriangles(const TrianglesCommand::Triangles& other)
@@ -159,13 +159,13 @@ unsigned int PolygonInfo::getTrianglesCount() const
159159
float PolygonInfo::getArea() const
160160
{
161161
float area = 0;
162-
V3F_C4F_T2F* verts = triangles.verts;
162+
V3F_T2F_C4F* verts = triangles.verts;
163163
unsigned short* indices = triangles.indices;
164164
for (unsigned int i = 0; i < triangles.indexCount; i += 3)
165165
{
166-
auto A = verts[indices[i]].vertices;
167-
auto B = verts[indices[i + 1]].vertices;
168-
auto C = verts[indices[i + 2]].vertices;
166+
auto A = verts[indices[i]].position;
167+
auto B = verts[indices[i + 1]].position;
168+
auto C = verts[indices[i + 2]].position;
169169
area += (A.x * (B.y - C.y) + B.x * (C.y - A.y) + C.x * (A.y - B.y)) / 2;
170170
}
171171
return area;
@@ -610,7 +610,7 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector<Vec2>& po
610610
std::vector<p2t::Triangle*> tris = cdt.GetTriangles();
611611

612612
axstd::pod_vector<unsigned short> indices(tris.size() * 3);
613-
axstd::pod_vector<V3F_C4F_T2F> verts;
613+
axstd::pod_vector<V3F_T2F_C4F> verts;
614614
verts.reserve(indices.size() / 2); // we won't know the size of verts until we process all of the triangles!
615615

616616
unsigned short idx = 0;
@@ -627,7 +627,7 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector<Vec2>& po
627627
auto length = vdx;
628628
for (j = 0; j < length; j++)
629629
{
630-
if (verts[j].vertices == v3)
630+
if (verts[j].position == v3)
631631
{
632632
found = true;
633633
break;
@@ -640,10 +640,8 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector<Vec2>& po
640640
}
641641
else
642642
{
643-
// vert does not exist yet, so we need to create a new one,
644-
auto c = Color::WHITE;
645-
auto t2f = Tex2F(0, 0); // don't worry about tex coords now, we calculate that later
646-
verts.push_back(V3F_C4F_T2F{v3, c, t2f});
643+
// vert does not exist yet, so we need to create a new one
644+
verts.emplace_back(v3, Vec2::ZERO, Color::WHITE);
647645
indices[idx++] = vdx++;;
648646
}
649647
}
@@ -656,7 +654,7 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector<Vec2>& po
656654
return triangles;
657655
}
658656

659-
void AutoPolygon::calculateUV(const Rect& rect, V3F_C4F_T2F* verts, ssize_t count)
657+
void AutoPolygon::calculateUV(const Rect& rect, V3F_T2F_C4F* verts, ssize_t count)
660658
{
661659
/*
662660
whole texture UV coordination
@@ -683,10 +681,10 @@ void AutoPolygon::calculateUV(const Rect& rect, V3F_C4F_T2F* verts, ssize_t coun
683681
for (auto i = verts; i != end; ++i)
684682
{
685683
// for every point, offset with the center point
686-
float u = (i->vertices.x * _scaleFactor + rect.origin.x) / texWidth;
687-
float v = (rect.origin.y + rect.size.height - i->vertices.y * _scaleFactor) / texHeight;
688-
i->texCoords.u = u;
689-
i->texCoords.v = v;
684+
float u = (i->position.x * _scaleFactor + rect.origin.x) / texWidth;
685+
float v = (rect.origin.y + rect.size.height - i->position.y * _scaleFactor) / texHeight;
686+
i->texCoord.u = u;
687+
i->texCoord.v = v;
690688
}
691689
}
692690

core/2d/AutoPolygon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class AX_DLL AutoPolygon
225225
* ap.calculateUV(rect, myPolygons.verts, 20);
226226
* @endcode
227227
*/
228-
void calculateUV(const Rect& rect, V3F_C4F_T2F* verts, ssize_t count);
228+
void calculateUV(const Rect& rect, V3F_T2F_C4F* verts, ssize_t count);
229229

230230
/**
231231
* a helper function, packing trace, reduce, expand, triangulate and calculate uv in one function

core/2d/CameraBackgroundBrush.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,17 @@ bool CameraBackgroundDepthBrush::init()
133133
pipelineDescriptor.programState = _programState;
134134

135135
_vertices.resize(4);
136-
_vertices[0].vertices = Vec3(-1, -1, 0);
137-
_vertices[1].vertices = Vec3(1, -1, 0);
138-
_vertices[2].vertices = Vec3(1, 1, 0);
139-
_vertices[3].vertices = Vec3(-1, 1, 0);
136+
_vertices[0].position = Vec3(-1, -1, 0);
137+
_vertices[1].position = Vec3(1, -1, 0);
138+
_vertices[2].position = Vec3(1, 1, 0);
139+
_vertices[3].position = Vec3(-1, 1, 0);
140140

141-
_vertices[0].colors = _vertices[1].colors = _vertices[2].colors = _vertices[3].colors = Color(0, 0, 0, 1);
141+
_vertices[0].color = _vertices[1].color = _vertices[2].color = _vertices[3].color = Color(0, 0, 0, 1);
142142

143-
_vertices[0].texCoords = Tex2F(0, 0);
144-
_vertices[1].texCoords = Tex2F(1, 0);
145-
_vertices[2].texCoords = Tex2F(1, 1);
146-
_vertices[3].texCoords = Tex2F(0, 1);
143+
_vertices[0].texCoord = Tex2F(0, 0);
144+
_vertices[1].texCoord = Tex2F(1, 0);
145+
_vertices[2].texCoord = Tex2F(1, 1);
146+
_vertices[3].texCoord = Tex2F(0, 1);
147147

148148
_customCommand.setBeforeCallback(AX_CALLBACK_0(CameraBackgroundDepthBrush::onBeforeDraw, this));
149149
_customCommand.setAfterCallback(AX_CALLBACK_0(CameraBackgroundDepthBrush::onAfterDraw, this));
@@ -235,7 +235,7 @@ void CameraBackgroundColorBrush::setColor(const Color& color)
235235
{
236236
for (auto&& vert : _vertices)
237237
{
238-
vert.colors = color;
238+
vert.color = color;
239239
}
240240
_customCommand.updateVertexBuffer(_vertices.data(), sizeof(_vertices[0]) * _vertices.size());
241241
}

core/2d/CameraBackgroundBrush.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class AX_DLL CameraBackgroundDepthBrush : public CameraBackgroundBrush
179179
CustomCommand _customCommand;
180180

181181
bool _clearColor;
182-
std::vector<V3F_C4F_T2F> _vertices;
182+
std::vector<V3F_T2F_C4F> _vertices;
183183
struct
184184
{
185185
uint32_t stencilWriteMask = 0;

0 commit comments

Comments
 (0)