optimise tile map rendering

This commit is contained in:
Huabing.Xu 2014-07-02 17:16:03 +08:00
parent efa452e0c4
commit 0214131bb2
2 changed files with 4 additions and 4 deletions

View File

@ -264,9 +264,8 @@ void FastTMXLayer::updateTiles(const Rect& culledRect)
int offset = iter->second;
iter->second++;
//CC_ASSERT(_tileToQuadIndex.find(tileIndex) != _tileToQuadIndex.end() && _tileToQuadIndex[tileIndex] <= _totalQuads.size()-1);
int quadIndex = (int)_tileToQuadIndex[tileIndex];
int quadIndex = _tileToQuadIndex[tileIndex];
CC_ASSERT(-1 != quadIndex);
_indices[6 * offset + 0] = quadIndex * 4 + 0;
_indices[6 * offset + 1] = quadIndex * 4 + 1;
_indices[6 * offset + 2] = quadIndex * 4 + 2;
@ -414,6 +413,7 @@ void FastTMXLayer::updateTotalQuads()
_tileToQuadIndex.clear();
_totalQuads.resize(int(_layerSize.width * _layerSize.height));
_indices.resize(6 * int(_layerSize.width * _layerSize.height));
_tileToQuadIndex.resize(int(_layerSize.width * _layerSize.height),-1);
_indicesVertexZOffsets.clear();
int quadIndex = 0;

View File

@ -239,7 +239,7 @@ protected:
Mat4 _tileToNodeTransform;
/** data for rendering */
bool _quadsDirty;
std::unordered_map<ssize_t, ssize_t> _tileToQuadIndex;
std::vector<int> _tileToQuadIndex;
std::vector<V3F_C4B_T2F_Quad> _totalQuads;
std::vector<int> _indices;
std::map<int/*vertexZ*/, int/*offset to _indices by quads*/> _indicesVertexZOffsets;