Exemplo n.º 1
0
void PhysicsWorld::debugDraw()
{
    if (_debugDraw && _bodys != nullptr)
    {
        _drawNode= DrawNode::create();
        
        Object* child = nullptr;
        CCARRAY_FOREACH(_bodys, child)
        {
            PhysicsBody* body = dynamic_cast<PhysicsBody*>(child);
            
            std::vector<PhysicsShape*> shapes = body->getShapes();
            
            for (auto it = shapes.begin(); it != shapes.end(); ++it)
            {
                drawWithShape(_drawNode, *it);
            }
        }
Exemplo n.º 2
0
void PhysicsWorld::debugDraw()
{
    if (_debugDraw == nullptr)
    {
        _debugDraw = new (std::nothrow) PhysicsDebugDraw(*this);
    }
    
    if (_debugDraw && !_bodies.empty())
    {
        if (_debugDraw->begin())
        {
            if (_debugDrawMask & DEBUGDRAW_SHAPE)
            {
                for (Ref* obj : _bodies)
                {
                    PhysicsBody* body = dynamic_cast<PhysicsBody*>(obj);
                    
                    if (!body->isEnabled())
                    {
                        continue;
                    }
                    
                    for (auto& shape : body->getShapes())
                    {
                        _debugDraw->drawShape(*dynamic_cast<PhysicsShape*>(shape));
                    }
                }
            }
            
            if (_debugDrawMask & DEBUGDRAW_JOINT)
            {
                for (auto joint : _joints)
                {
                    _debugDraw->drawJoint(*joint);
                }
            }
            
            _debugDraw->end();
        }
    }
}
void PhysicsWorld::debugDraw()
{
    if (_debugDraw == nullptr)
    {
        _debugDraw = new PhysicsDebugDraw(*this);
    }
    
    if (_debugDraw && _bodies != nullptr)
    {
        if (_debugDraw->begin())
        {
            if (_debugDrawMask & DEBUGDRAW_SHAPE)
            {
                for (Object* obj : *_bodies)
                {
                    PhysicsBody* body = dynamic_cast<PhysicsBody*>(obj);
                    
                    for (auto shape : *body->getShapes())
                    {
                        _debugDraw->drawShape(*dynamic_cast<PhysicsShape*>(shape));
                    }
                }
            }
            
            if (_debugDrawMask & DEBUGDRAW_JOINT)
            {
                for (auto joint : _joints)
                {
                    _debugDraw->drawJoint(*joint);
                }
            }
            
            _debugDraw->end();
        }
    }
}