Replace 'tiles.bufferCount' with function
This commit is contained in:
parent
41e1187063
commit
4f08382c69
|
@ -275,9 +275,6 @@ struct TilemapPrivate
|
||||||
VBO::ID vbo;
|
VBO::ID vbo;
|
||||||
bool animated;
|
bool animated;
|
||||||
|
|
||||||
/* Buffer count is either 1 or 4 */
|
|
||||||
uint8_t bufferCount;
|
|
||||||
|
|
||||||
/* Size of an IBO buffer frame, in bytes */
|
/* Size of an IBO buffer frame, in bytes */
|
||||||
GLintptr bufferFrameSize;
|
GLintptr bufferFrameSize;
|
||||||
|
|
||||||
|
@ -356,7 +353,6 @@ struct TilemapPrivate
|
||||||
|
|
||||||
atlas.animatedATs.reserve(autotileCount);
|
atlas.animatedATs.reserve(autotileCount);
|
||||||
tiles.animated = false;
|
tiles.animated = false;
|
||||||
tiles.bufferCount = 1;
|
|
||||||
tiles.frameIdx = 0;
|
tiles.frameIdx = 0;
|
||||||
tiles.aniIdx = 0;
|
tiles.aniIdx = 0;
|
||||||
|
|
||||||
|
@ -430,6 +426,11 @@ struct TilemapPrivate
|
||||||
prepareCon.disconnect();
|
prepareCon.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t bufferCount() const
|
||||||
|
{
|
||||||
|
return tiles.animated ? 4 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
void updateAtlasInfo()
|
void updateAtlasInfo()
|
||||||
{
|
{
|
||||||
if (!tileset || tileset->isDisposed())
|
if (!tileset || tileset->isDisposed())
|
||||||
|
@ -470,7 +471,6 @@ struct TilemapPrivate
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles.animated = !animatedATs.empty();
|
tiles.animated = !animatedATs.empty();
|
||||||
tiles.bufferCount = animatedATs.empty() ? 1 : 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateMapDataInfo()
|
void updateMapDataInfo()
|
||||||
|
@ -705,7 +705,7 @@ struct TilemapPrivate
|
||||||
/* Adjust to atlas coordinates */
|
/* Adjust to atlas coordinates */
|
||||||
texRect.y += atInd * autotileH;
|
texRect.y += atInd * autotileH;
|
||||||
|
|
||||||
for (int k = 0; k < tiles.bufferCount; ++k)
|
for (int k = 0; k < bufferCount(); ++k)
|
||||||
{
|
{
|
||||||
FloatRect _texRect = texRect;
|
FloatRect _texRect = texRect;
|
||||||
|
|
||||||
|
@ -767,7 +767,7 @@ struct TilemapPrivate
|
||||||
SVertex v[4];
|
SVertex v[4];
|
||||||
Quad::setTexPosRect(v, texRect, posRect);
|
Quad::setTexPosRect(v, texRect, posRect);
|
||||||
|
|
||||||
for (int k = 0; k < tiles.bufferCount; ++k)
|
for (int k = 0; k < bufferCount(); ++k)
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
targetArray->v[k].append(v[i]);
|
targetArray->v[k].append(v[i]);
|
||||||
}
|
}
|
||||||
|
@ -824,12 +824,12 @@ struct TilemapPrivate
|
||||||
int bufferFrameQuadCount = quadCount;
|
int bufferFrameQuadCount = quadCount;
|
||||||
tiles.bufferFrameSize = quadCount * 6 * sizeof(uint32_t);
|
tiles.bufferFrameSize = quadCount * 6 * sizeof(uint32_t);
|
||||||
|
|
||||||
quadCount *= tiles.bufferCount;
|
quadCount *= bufferCount();
|
||||||
|
|
||||||
VBO::bind(tiles.vbo);
|
VBO::bind(tiles.vbo);
|
||||||
VBO::allocEmpty(quadDataSize(quadCount));
|
VBO::allocEmpty(quadDataSize(quadCount));
|
||||||
|
|
||||||
for (int k = 0; k < tiles.bufferCount; ++k)
|
for (int k = 0; k < bufferCount(); ++k)
|
||||||
{
|
{
|
||||||
VBO::uploadSubData(k*quadDataSize(bufferFrameQuadCount),
|
VBO::uploadSubData(k*quadDataSize(bufferFrameQuadCount),
|
||||||
quadDataSize(groundQuadCount), groundVert.v[k].constData());
|
quadDataSize(groundQuadCount), groundVert.v[k].constData());
|
||||||
|
@ -848,7 +848,7 @@ struct TilemapPrivate
|
||||||
VBO::unbind();
|
VBO::unbind();
|
||||||
|
|
||||||
/* Ensure global IBO size */
|
/* Ensure global IBO size */
|
||||||
gState->ensureQuadIBO(quadCount*tiles.bufferCount);
|
gState->ensureQuadIBO(quadCount*bufferCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
void bindAtlas(SimpleShader &shader)
|
void bindAtlas(SimpleShader &shader)
|
||||||
|
|
Loading…
Reference in New Issue