示例#1
0
/* ....................................................................... */
bool
Collidable::removeFromWorldInternal(World* world)
{
    PS_DBG2("oo::Collidable::removeFromWorldInternal(%p, world=%p)", this, world) ;




    bool    rb = RigidBody::removeFromWorldInternal(world) ;

    /*!
     * @todo    need to check the RigidBody::removeFromWorldInternal return value
     */

    (void) rb ;



    Space*  space = world->asSpace() ;


    if( space ) {
        if( dGeomGetSpace(m_ODE_geom) == space->getODESpace() ) {
            dSpaceRemove(space->getODESpace(), m_ODE_geom) ;
        }

    } else {
        PS_WARN("oo::Collidable::removeFromWorldInternal(%p, ...): %p not a Space", this, world) ;
    }


    return rb ;
}
示例#2
0
/* ....................................................................... */
bool
Collidable::addToWorldInternal(World* world)
{
    PS_DBG2("oo::Collidable::addToWorldInternal(%p, world=%p)", this, world) ;



    /*
     * During the RigidBody::addToWorldInternal we recreate the dBodyID, so we
     * must call it before everything else in order to correctly use the
     * dGeomSetBody function
     */
    bool    rb = RigidBody::addToWorldInternal(world) ;

    /*!
     * @todo    check the RigidBody::addToWorldInternal return value
     */

    (void) rb ;


    dGeomSetBody(m_ODE_geom, m_ODE_body) ;

    // Recreate the geometry offset - indispensable
    setCollidableOffset(m_matrix_offset) ;



    Space*  space = world->asSpace() ;

    if( space ) {

        if( dGeomGetSpace(m_ODE_geom) != space->getODESpace() ) {
            dSpaceAdd(space->getODESpace(), m_ODE_geom) ;
        }

    } else {
        PS_WARN("oo::Collidable::addToWorldInternal(%p, ...): %p not a Space", this, world) ;
    }


    return rb ;
}