Skip to content

Commit c9c53bd

Browse files
committed
Still use V3F_T2F_C4B for sprite render
1 parent 5b519b4 commit c9c53bd

Some content is hidden

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

47 files changed

+303
-272
lines changed

core/2d/AnchoredSprite.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ AnchoredSprite* AnchoredSprite::create()
147147
return nullptr;
148148
}
149149

150-
void AnchoredSprite::setVertexCoords(const Rect& rect, V3F_T2F_C4F_Quad* outQuad)
150+
void AnchoredSprite::setVertexCoords(const Rect& rect, V3F_T2F_C4B_Quad* outQuad)
151151
{
152152
float relativeOffsetX = _unflippedOffsetPositionFromCenter.x - getContentSize().x * _spriteVertexAnchor.x;
153153
float relativeOffsetY = _unflippedOffsetPositionFromCenter.y - getContentSize().y * _spriteVertexAnchor.y;

core/2d/AnchoredSprite.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class AX_DLL AnchoredSprite : public Sprite
143143
virtual Rect getTouchRect();
144144

145145
protected:
146-
virtual void setVertexCoords(const Rect& rect, V3F_T2F_C4F_Quad* outQuad) override;
146+
virtual void setVertexCoords(const Rect& rect, V3F_T2F_C4B_Quad* outQuad) override;
147147
Vec2 _spriteVertexAnchor = Vec2::ANCHOR_MIDDLE;
148148
};
149149

core/2d/AutoPolygon.cpp

Lines changed: 9 additions & 9 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_T2F_C4F[other.triangles.vertCount];
66+
triangles.verts = new V3F_T2F_C4B[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_T2F_C4F[other.triangles.vertCount];
83+
triangles.verts = new V3F_T2F_C4B[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;
@@ -97,17 +97,17 @@ PolygonInfo::~PolygonInfo()
9797
releaseVertsAndIndices();
9898
}
9999

100-
void PolygonInfo::setQuad(V3F_T2F_C4F_Quad* quad)
100+
void PolygonInfo::setQuad(V3F_T2F_C4B_Quad* quad)
101101
{
102102
releaseVertsAndIndices();
103103
_isVertsOwner = false;
104104
triangles.indices = quadIndices9;
105105
triangles.vertCount = 4;
106106
triangles.indexCount = 6;
107-
triangles.verts = (V3F_T2F_C4F*)quad;
107+
triangles.verts = (V3F_T2F_C4B*)quad;
108108
}
109109

110-
void PolygonInfo::setQuads(V3F_T2F_C4F_Quad* quad, int numberOfQuads)
110+
void PolygonInfo::setQuads(V3F_T2F_C4B_Quad* quad, int numberOfQuads)
111111
{
112112
AXASSERT(numberOfQuads >= 1 && numberOfQuads <= 9, "Invalid number of Quads");
113113

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

122122
void PolygonInfo::setTriangles(const TrianglesCommand::Triangles& other)
@@ -159,7 +159,7 @@ unsigned int PolygonInfo::getTrianglesCount() const
159159
float PolygonInfo::getArea() const
160160
{
161161
float area = 0;
162-
V3F_T2F_C4F* verts = triangles.verts;
162+
V3F_T2F_C4B* verts = triangles.verts;
163163
unsigned short* indices = triangles.indices;
164164
for (unsigned int i = 0; i < triangles.indexCount; i += 3)
165165
{
@@ -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_T2F_C4F> verts;
613+
axstd::pod_vector<V3F_T2F_C4B> 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;
@@ -654,7 +654,7 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector<Vec2>& po
654654
return triangles;
655655
}
656656

657-
void AutoPolygon::calculateUV(const Rect& rect, V3F_T2F_C4F* verts, ssize_t count)
657+
void AutoPolygon::calculateUV(const Rect& rect, V3F_T2F_C4B* verts, ssize_t count)
658658
{
659659
/*
660660
whole texture UV coordination

core/2d/AutoPolygon.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,17 @@ class AX_DLL PolygonInfo
8080
* set the data to be a pointer to a quad
8181
* the member verts will not be released when this PolygonInfo destructs
8282
* as the verts memory are managed by other objects
83-
* @param quad a pointer to the V3F_T2F_C4F_Quad object
83+
* @param quad a pointer to the V3F_T2F_C4B_Quad object
8484
*/
85-
void setQuad(V3F_T2F_C4F_Quad* quad);
85+
void setQuad(V3F_T2F_C4B_Quad* quad);
8686

8787
/**
8888
* set the data to be a pointer to a number of Quads
8989
* the member verts will not be released when this PolygonInfo destructs
9090
* as the verts memory are managed by other objects
91-
* @param quad a pointer to the V3F_T2F_C4F_Quad quads
91+
* @param quad a pointer to the V3F_T2F_C4B_Quad quads
9292
*/
93-
void setQuads(V3F_T2F_C4F_Quad* quads, int numberOfQuads);
93+
void setQuads(V3F_T2F_C4B_Quad* quads, int numberOfQuads);
9494

9595
/**
9696
* set the data to be a pointer to a triangles
@@ -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_T2F_C4F* verts, ssize_t count);
228+
void calculateUV(const Rect& rect, V3F_T2F_C4B* verts, ssize_t count);
229229

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

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_T2F_C4F> _vertices;
182+
std::vector<V3F_T2F_C4B> _vertices;
183183
struct
184184
{
185185
uint32_t stencilWriteMask = 0;

core/2d/FastTMXLayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ void FastTMXLayer::updateTiles(const Rect& culledRect)
275275

276276
void FastTMXLayer::updateVertexBuffer()
277277
{
278-
unsigned int vertexBufferSize = (unsigned int)(sizeof(V3F_T2F_C4F) * _totalQuads.size() * 4);
278+
unsigned int vertexBufferSize = (unsigned int)(sizeof(V3F_T2F_C4B) * _totalQuads.size() * 4);
279279
if (!_vertexBuffer)
280280
{
281281
_vertexBuffer = backend::DriverBase::getInstance()->newBuffer(vertexBufferSize, backend::BufferType::VERTEX, backend::BufferUsage::STATIC);
@@ -503,7 +503,7 @@ void FastTMXLayer::updateTotalQuads()
503503
_tileToQuadIndex.resize(int(_layerSize.width * _layerSize.height), -1);
504504
_indicesVertexZOffsets.clear();
505505

506-
auto color = Color::WHITE;
506+
auto color = Color4B::WHITE;
507507
color.a = getDisplayedOpacity();
508508

509509
if (_texture->hasPremultipliedAlpha())

core/2d/FastTMXLayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ class AX_DLL FastTMXLayer : public Node
371371
float _cameraZoomDirty;
372372

373373
std::vector<int> _tileToQuadIndex;
374-
std::vector<V3F_T2F_C4F_Quad> _totalQuads;
374+
std::vector<V3F_T2F_C4B_Quad> _totalQuads;
375375
#ifdef AX_FAST_TILEMAP_32_BIT_INDICES
376376
std::vector<unsigned int> _indices;
377377
#else

core/2d/Label.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,15 +1775,15 @@ void Label::updateBuffer(TextureAtlas* textureAtlas, CustomCommand& customComman
17751775
{
17761776
if (textureAtlas->getTotalQuads() > customCommand.getVertexCapacity())
17771777
{
1778-
customCommand.createVertexBuffer((unsigned int)sizeof(V3F_T2F_C4F_Quad),
1778+
customCommand.createVertexBuffer((unsigned int)sizeof(V3F_T2F_C4B_Quad),
17791779
(unsigned int)textureAtlas->getTotalQuads(),
17801780
CustomCommand::BufferUsage::DYNAMIC);
17811781
customCommand.createIndexBuffer(CustomCommand::IndexFormat::U_SHORT,
17821782
(unsigned int)textureAtlas->getTotalQuads() * 6,
17831783
CustomCommand::BufferUsage::DYNAMIC);
17841784
}
17851785
customCommand.updateVertexBuffer(textureAtlas->getQuads(),
1786-
(unsigned int)(textureAtlas->getTotalQuads() * sizeof(V3F_T2F_C4F_Quad)));
1786+
(unsigned int)(textureAtlas->getTotalQuads() * sizeof(V3F_T2F_C4B_Quad)));
17871787
customCommand.updateIndexBuffer(textureAtlas->getIndices(),
17881788
(unsigned int)(textureAtlas->getTotalQuads() * 6 * sizeof(unsigned short)));
17891789
customCommand.setIndexDrawInfo(0, (unsigned int)(textureAtlas->getTotalQuads() * 6));
@@ -1895,7 +1895,7 @@ void Label::updateEffectUniforms(BatchCommand& batch,
18951895
_displayedOpacity = _shadowColor.a * (oldOPacity / 255.0f) * 255;
18961896
setColor(Color3B(_shadowColor));
18971897
batch.shadowCommand.updateVertexBuffer(
1898-
textureAtlas->getQuads(), (unsigned int)(textureAtlas->getTotalQuads() * sizeof(V3F_T2F_C4F_Quad)));
1898+
textureAtlas->getQuads(), (unsigned int)(textureAtlas->getTotalQuads() * sizeof(V3F_T2F_C4B_Quad)));
18991899
batch.shadowCommand.init(_globalZOrder);
19001900
renderer->addCommand(&batch.shadowCommand);
19011901

core/2d/LabelAtlas.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void LabelAtlas::updateAtlasValues()
161161
}
162162

163163
AXASSERT(n <= _textureAtlas->getCapacity(), "updateAtlasValues: Invalid String length");
164-
V3F_T2F_C4F_Quad* quads = _textureAtlas->getQuads();
164+
auto quads = _textureAtlas->getQuads();
165165
for (ssize_t i = 0; i < n; i++)
166166
{
167167

@@ -203,7 +203,7 @@ void LabelAtlas::updateAtlasValues()
203203
quads[i].tr.position.x = (float)(i * _itemWidth + _itemWidth);
204204
quads[i].tr.position.y = (float)(_itemHeight);
205205
quads[i].tr.position.z = 0.0f;
206-
Color c(_displayedColor, _displayedOpacity / 255.0f);
206+
Color4B c(_displayedColor, _displayedOpacity);
207207
quads[i].tl.color = c;
208208
quads[i].tr.color = c;
209209
quads[i].bl.color = c;

core/2d/ParticleBatchNode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ void ParticleBatchNode::increaseAtlasCapacityTo(ssize_t quantity)
474474
// sets a 0'd quad into the quads array
475475
void ParticleBatchNode::disableParticle(int particleIndex)
476476
{
477-
V3F_T2F_C4F_Quad* quad = &((_textureAtlas->getQuads())[particleIndex]);
477+
auto quad = &((_textureAtlas->getQuads())[particleIndex]);
478478
quad->br.position.x = quad->br.position.y = quad->tr.position.x = quad->tr.position.y = quad->tl.position.x =
479479
quad->tl.position.y = quad->bl.position.x = quad->bl.position.y = 0.0f;
480480
}

0 commit comments

Comments
 (0)