bool CPhysicsManager::AddPhysicActor (CPhysicActor* actor, float mass) { assert(actor != NULL); assert( m_pScene != NULL ); bool isOk = false; NxActor* nxActor; NxActorDesc* actorDesc = actor->GetActorDesc(); assert(actorDesc!=NULL); nxActor = m_pScene->createActor( *actorDesc ); if (nxActor!=NULL) { nxActor->userData = actor->GetUserData(); if (mass > 0.0f) nxActor->setMass(mass); actor->CreateActor(nxActor); isOk = true; } return isOk; }
//----------------------------------------------------------------------------- // SetDensity //----------------------------------------------------------------------------- void CPhysicObj::SetDensity (int nPartIdx, float fDensity) { assert( nPartIdx < GetNumParts() ); NxActor* pActor = GetActor(nPartIdx); pActor->setMass( m_InitInfo.pPhysicModel->CalcVolume() * fDensity ); }
//----------------------------------------------------------------------------- // SetMass //----------------------------------------------------------------------------- void CPhysicObj::SetMass (int nPartIdx, float fMass) { assert( nPartIdx < GetNumParts() ); NxActor* pActor = GetActor(nPartIdx); pActor->setMass( fMass ); }