clean up Fast TMX code

This commit is contained in:
Huabing.Xu 2014-06-25 10:04:20 +08:00
parent 740372ceb3
commit 67f83f43b0
2 changed files with 3 additions and 37 deletions

View File

@ -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();

View File

@ -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<V3F_C4B_T2F_Quad> _quads;
std::vector<QuadCommand> _renderCommands;
std::map<int/*zorder*/, ssize_t/*number*/> _quadsNumber;
std::unordered_map<int/*zorder*/, NopreMultiplyMVQuadCommand> _renderCommands2;
/** indices */
std::vector<GLushort> _indices;
bool _dirty;
};