From 67f83f43b042fcf4b4cb3f42a52ab06d4ff0c3f8 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 25 Jun 2014 10:04:20 +0800 Subject: [PATCH] clean up Fast TMX code --- cocos/2d/CCFastTMXLayer.cpp | 30 ++---------------------------- cocos/2d/CCFastTMXLayer.h | 10 +--------- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/cocos/2d/CCFastTMXLayer.cpp b/cocos/2d/CCFastTMXLayer.cpp index 169df9c211..aef37b38b3 100644 --- a/cocos/2d/CCFastTMXLayer.cpp +++ b/cocos/2d/CCFastTMXLayer.cpp @@ -144,7 +144,7 @@ void FastTMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flag inv.inverse(); rect = RectApplyTransform(rect, inv); - _verticesToDraw = updateTiles(rect, renderer); + _verticesToDraw = updateTiles(rect); std::sort(_quads.begin(), _quads.end(), sortQuadCommand); // don't draw more than 65535 vertices since we are using GL_UNSIGNED_SHORT for indices _verticesToDraw = std::min(_verticesToDraw, 65535); @@ -163,23 +163,9 @@ void FastTMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flag index += quadNumberIter.second; renderer->addCommand(&quadCommand); } -// for( int index = 0; index < _verticesToDraw/6; ++index) -// { -// float z = _quads[index].bl.vertices.z; -// _renderCommands[index].init(z, _texture->getName(), glprogramState, BlendFunc::ALPHA_PREMULTIPLIED, &_quads[index], 1, transform); -// renderer->addCommand(&_renderCommands[index]); -// } - -// _customCommand.init(_globalZOrder); -// _customCommand.func = CC_CALLBACK_0(FastTMXLayer::onDraw, this, transform, flags); -// renderer->addCommand(&_customCommand); } -void FastTMXLayer::onDraw(const Mat4 &transform, bool transformUpdated) -{ -} - -int FastTMXLayer::updateTiles(const Rect& culledRect, Renderer* renderer) +int FastTMXLayer::updateTiles(const Rect& culledRect) { int tilesUsed = 0; @@ -228,8 +214,6 @@ int FastTMXLayer::updateTiles(const Rect& culledRect, Renderer* renderer) if (_quads.size() < quadsNeed) { _quads.resize(quadsNeed); - _renderCommands.resize(quadsNeed); - _indices.resize(quadsNeed * 6); } //clear quadsNumber @@ -345,14 +329,6 @@ int FastTMXLayer::updateTiles(const Rect& culledRect, Renderer* renderer) quad->tl.colors = Color4B::WHITE; quad->tr.colors = Color4B::WHITE; - int vertexbase = tilesUsed * 4; - _indices[tilesUsed * 6 + 0] = vertexbase; - _indices[tilesUsed * 6 + 1] = vertexbase + 1; - _indices[tilesUsed * 6 + 2] = vertexbase + 2; - _indices[tilesUsed * 6 + 3] = vertexbase + 3; - _indices[tilesUsed * 6 + 4] = vertexbase + 2; - _indices[tilesUsed * 6 + 5]= vertexbase + 1; - tilesUsed++; } @@ -609,8 +585,6 @@ void FastTMXLayer::setTileForGID(int index, int gid) _dirty = true; } - - void FastTMXLayer::removeChild(Node* node, bool cleanup) { int tag = node->getTag(); diff --git a/cocos/2d/CCFastTMXLayer.h b/cocos/2d/CCFastTMXLayer.h index 7291921f4c..e1eb458d63 100644 --- a/cocos/2d/CCFastTMXLayer.h +++ b/cocos/2d/CCFastTMXLayer.h @@ -189,7 +189,7 @@ public: protected: bool initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo); - int updateTiles(const Rect& culledRect, Renderer* renderer); + int updateTiles(const Rect& culledRect); void setupVBO(); Vec2 calculateLayerOffset(const Vec2& offset); @@ -198,8 +198,6 @@ protected: Mat4 tileToNodeTransform(); Rect tileBoundsForClipTransform(const Mat4 &tileToClip); - - void onDraw(const Mat4 &transform, bool transformUpdated); int getVertexZForPos(const Vec2& pos); @@ -207,7 +205,6 @@ protected: void setTileForGID(int index, int gid); protected: - CustomCommand _customCommand; //! name of the layer std::string _layerName; @@ -240,17 +237,12 @@ protected: int _vertexZvalue; bool _useAutomaticVertexZ; - /** tile coordinate to node coordinate transform */ Mat4 _tileToNodeTransform; /** quads to be rendered */ std::vector _quads; - std::vector _renderCommands; - std::map _quadsNumber; std::unordered_map _renderCommands2; - /** indices */ - std::vector _indices; bool _dirty; };