fix BoneNode::visit for visit other node that is not a BoneNode or SkinNode

This commit is contained in:
geron-cn 2015-08-07 11:44:06 +08:00
parent 3ae3020d61
commit c569e70aea
1 changed files with 14 additions and 7 deletions

View File

@ -330,15 +330,17 @@ void BoneNode::visit(cocos2d::Renderer *renderer, const cocos2d::Mat4& parentTra
int i = 0; int i = 0;
if (!_childBones.empty()) if (!_children.empty())
{ {
sortAllChildren(); sortAllChildren();
// draw children zOrder < 0 // draw children zOrder < 0
for (; i < _childBones.size(); i++) for (; i < _children.size(); i++)
{ {
auto bone = _childBones.at(i); auto node = _children.at(i);
if (bone && bone->getZOrder() < 0) if (_rootSkeleton != nullptr && _boneSkins.contains(node)) // skip skin when bone is in a skeleton
bone->visit(renderer, _modelViewTransform, flags); continue;
if (node && node->getLocalZOrder() < 0)
node->visit(renderer, _modelViewTransform, flags);
else else
break; break;
} }
@ -346,8 +348,13 @@ void BoneNode::visit(cocos2d::Renderer *renderer, const cocos2d::Mat4& parentTra
if (visibleByCamera) if (visibleByCamera)
this->draw(renderer, _modelViewTransform, flags); this->draw(renderer, _modelViewTransform, flags);
for (auto it = _childBones.cbegin() + i; it != _childBones.cend(); ++it) for (auto it = _children.cbegin() + i; it != _children.cend(); ++it)
(*it)->visit(renderer, _modelViewTransform, flags); {
auto node = (*it);
if (_rootSkeleton != nullptr && _boneSkins.contains(node)) // skip skin when bone is in a skeleton
continue;
node->visit(renderer, _modelViewTransform, flags);
}
} }
else if (visibleByCamera) else if (visibleByCamera)
{ {