Added support for larger tilemaps in CCFastTMXTiledMap (#17006)

* Added option to use 32 bit indices for large maps

* Added option to use 32 bit indices for large maps
This commit is contained in:
Ruud Arentsen 2016-12-15 03:01:37 +01:00 committed by minggo
parent effb6f077a
commit a66215916e
2 changed files with 8 additions and 0 deletions

View File

@ -313,7 +313,11 @@ void TMXLayer::updateIndexBuffer()
{ {
if(nullptr == _indexBuffer) if(nullptr == _indexBuffer)
{ {
#ifdef CC_FAST_TILEMAP_32_BIT_INDICES
_indexBuffer = IndexBuffer::create(IndexBuffer::IndexType::INDEX_TYPE_UINT_32, (int)_indices.size());
#else
_indexBuffer = IndexBuffer::create(IndexBuffer::IndexType::INDEX_TYPE_SHORT_16, (int)_indices.size()); _indexBuffer = IndexBuffer::create(IndexBuffer::IndexType::INDEX_TYPE_SHORT_16, (int)_indices.size());
#endif
CC_SAFE_RETAIN(_indexBuffer); CC_SAFE_RETAIN(_indexBuffer);
} }
_indexBuffer->updateIndices(&_indices[0], (int)_indices.size(), 0); _indexBuffer->updateIndices(&_indices[0], (int)_indices.size(), 0);

View File

@ -334,7 +334,11 @@ protected:
bool _quadsDirty; bool _quadsDirty;
std::vector<int> _tileToQuadIndex; std::vector<int> _tileToQuadIndex;
std::vector<V3F_C4B_T2F_Quad> _totalQuads; std::vector<V3F_C4B_T2F_Quad> _totalQuads;
#ifdef CC_FAST_TILEMAP_32_BIT_INDICES
std::vector<GLuint> _indices;
#else
std::vector<GLushort> _indices; std::vector<GLushort> _indices;
#endif
std::map<int/*vertexZ*/, int/*offset to _indices by quads*/> _indicesVertexZOffsets; std::map<int/*vertexZ*/, int/*offset to _indices by quads*/> _indicesVertexZOffsets;
std::unordered_map<int/*vertexZ*/, int/*number to quads*/> _indicesVertexZNumber; std::unordered_map<int/*vertexZ*/, int/*number to quads*/> _indicesVertexZNumber;
std::vector<PrimitiveCommand> _renderCommands; std::vector<PrimitiveCommand> _renderCommands;