Ejemplo n.º 1
0
    void PhysicsBodyObject::SetActive( bool active )
    {
        if( active == Active() )
            return;

        rsk::ActiveObject::SetActive( active );
    //
    //  Encapsulate RSKMAP_ITERATE; duplicate them so only what's needed is run
        PhysicsWorld* world = gGame->GetWorld();
        if( active )
        {
            RSKMAP_ITERATE_VALUE_NAMED( m_Detectors, slot )
            {
                if( slot->active )
                {
                    world->AddBody( slot->area.Self() );
                    CommitDetectorActive( *slot, active );
                }
            }
            return;
        }

        if( world )
        {
            RSKMAP_ITERATE_VALUE_NAMED( m_Detectors, slot )
            {
                CommitDetectorActive( *slot, active );
                world->RemoveBody( slot->area->GetID() );
            }
            return;
        }
Ejemplo n.º 2
0
 PhysicsBodyObject::~PhysicsBodyObject()
 {
     if( gGame.Exists() )
     {
         PhysicsWorld* world = gGame->GetWorld();
         if( world )
         {
             RSKMAP_ITERATE( m_Detectors )
                 world->RemoveBody( iter->second.area->GetID() );
         }
     }
 }