Sprite: removed _hasChildren

_hasChildren has been replaced with !_children.empty()
This commit is contained in:
Ricardo Quesada 2014-01-15 18:37:07 -08:00
parent e8bd5cb4a3
commit 9b490a9124
3 changed files with 16 additions and 24 deletions

View File

@ -9,7 +9,8 @@ cocos2d-x-3.0final ?.? ?
[FIX] ControlButton doesn't support to set scale ratio of touchdown state.
[FIX] Particles: Crash was triggered if there is not `textureFileName`section in particle plist file.
[FIX] Renderer: QuadCommand::init() does not copy the Quads, it only store a reference making the code faster
[FIX] Renderer: Performance improved in Sprite and SpriteBatchNode (and subclasses) sprites in about 20%
[FIX] Renderer: Performance improved in Sprite and SpriteBatchNode (and subclasses) sprites in about 20%
[FIX] Sprite: removed _hasChildren optimization. It uses !_children.empty() now which is super fast as well
[FIX] Tests: TestCpp works with CMake on Windows.
[FIX] Tests: Sprites Performance Test has 3 new tests
[FIX] TextureCache: getTextureForKey and removeTextureForKey work as expected

View File

@ -242,9 +242,7 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
// zwoptex default values
_offsetPosition = Point::ZERO;
_hasChildren = false;
// clean the Quad
memset(&_quad, 0, sizeof(_quad));
@ -767,7 +765,6 @@ void Sprite::addChild(Node *child, int zOrder, int tag)
}
//CCNode already sets isReorderChildDirty_ so this needs to be after batchNode check
Node::addChild(child, zOrder, tag);
_hasChildren = true;
}
void Sprite::reorderChild(Node *child, int zOrder)
@ -813,8 +810,6 @@ void Sprite::removeAllChildrenWithCleanup(bool cleanup)
}
Node::removeAllChildrenWithCleanup(cleanup);
_hasChildren = false;
}
void Sprite::sortAllChildren()
@ -882,27 +877,24 @@ void Sprite::setDirtyRecursively(bool bValue)
{
_recursiveDirty = bValue;
setDirty(bValue);
// recursively set dirty
if (_hasChildren)
{
for(const auto &child: _children) {
Sprite* sp = dynamic_cast<Sprite*>(child);
if (sp)
{
sp->setDirtyRecursively(true);
}
for(const auto &child: _children) {
Sprite* sp = dynamic_cast<Sprite*>(child);
if (sp)
{
sp->setDirtyRecursively(true);
}
}
}
// XXX HACK: optimization
#define SET_DIRTY_RECURSIVELY() { \
if (! _recursiveDirty) { \
_recursiveDirty = true; \
setDirty(true); \
if ( _hasChildren) \
setDirtyRecursively(true); \
} \
#define SET_DIRTY_RECURSIVELY() { \
if (! _recursiveDirty) { \
_recursiveDirty = true; \
setDirty(true); \
if (!_children.empty()) \
setDirtyRecursively(true); \
} \
}
void Sprite::setPosition(const Point& pos)

View File

@ -538,7 +538,6 @@ protected:
bool _dirty; /// Whether the sprite needs to be updated
bool _recursiveDirty; /// Whether all of the sprite's children needs to be updated
bool _hasChildren; /// Whether the sprite contains children
bool _shouldBeHidden; /// should not be drawn because one of the ancestors is not visible
kmMat4 _transformToBatch;