void UpdateSleepObjects( void ) { int i; CUtlVector<CPhysicsObject *> sleepObjects; for ( i = 0; i < m_activeObjects.Count(); i++ ) { CPhysicsObject *pObject = m_activeObjects[i]; if ( pObject->GetSleepState() != OBJ_AWAKE ) { sleepObjects.AddToTail( pObject ); } } for ( i = sleepObjects.Count()-1; i >= 0; --i ) { // put fully to sleep sleepObjects[i]->NotifySleep(); // remove from the active list DeleteObject( sleepObjects[i] ); } }
void event_object_revived( IVP_Event_Object *pEvent ) { CPhysicsObject *pObject = static_cast<CPhysicsObject *>(pEvent->real_object->client_data); if ( !pObject ) return; int sleepState = pObject->GetSleepState(); pObject->NotifyWake(); // asleep, but already in active list if ( sleepState == OBJ_STARTSLEEP ) return; // don't track static objects (like the world). That way we only track objects that will move if ( pObject->GetObject()->get_movement_state() != IVP_MT_STATIC ) { Assert(pObject->GetActiveIndex()==0xFFFF); if ( pObject->GetActiveIndex()!=0xFFFF) return; int index = m_activeObjects.AddToTail( pObject ); pObject->SetActiveIndex( index ); } if ( m_pCallback ) { m_pCallback->ObjectWake( pObject ); } }