//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- CBaseEntity *CTriggerPortalCleanser::CreateSimplePhysicsObject( CBaseEntity *pEntity ) { CBaseEntity *pPhysEntity = NULL; int modelindex = pEntity->GetModelIndex(); const model_t *model = modelinfo->GetModel( modelindex ); if ( model && modelinfo->GetModelType(model) == mod_brush ) { pPhysEntity = CreateEntityByName( "simple_physics_brush" ); } else { pPhysEntity = CreateEntityByName( "simple_physics_prop" ); } pPhysEntity->KeyValue( "model", STRING(pEntity->GetModelName()) ); pPhysEntity->SetAbsOrigin( pEntity->GetAbsOrigin() ); pPhysEntity->SetAbsAngles( pEntity->GetAbsAngles() ); pPhysEntity->Spawn(); if ( !TransferPhysicsObject( pEntity, pPhysEntity, true ) ) { pPhysEntity->VPhysicsInitNormal( SOLID_VPHYSICS, 0, false ); } pEntity->Remove(); return pPhysEntity; }
// UNDONE: Move/rename this function static CBaseEntity *CreateSimplePhysicsObject( CBaseEntity *pEntity, bool createAsleep ) { CBaseEntity *pPhysEntity = NULL; int modelindex = pEntity->GetModelIndex(); const model_t *model = modelinfo->GetModel( modelindex ); if ( model && modelinfo->GetModelType(model) == mod_brush ) { pPhysEntity = CreateEntityByName( "simple_physics_brush" ); } else { pPhysEntity = CreateEntityByName( "simple_physics_prop" ); } pPhysEntity->KeyValue( "model", STRING(pEntity->GetModelName()) ); pPhysEntity->SetAbsOrigin( pEntity->GetAbsOrigin() ); pPhysEntity->SetAbsAngles( pEntity->GetAbsAngles() ); pPhysEntity->Spawn(); if ( !TransferPhysicsObject( pEntity, pPhysEntity ) ) { pPhysEntity->VPhysicsInitNormal( SOLID_VPHYSICS, 0, false ); } if ( !createAsleep ) { pPhysEntity->VPhysicsGetObject()->Wake(); } return pPhysEntity; }