void BMaxObject::LoadPhysics() { if (m_dwPhysicsMethod > 0 && IsPhysicsEnabled() && (GetStaticActorCount() == 0)) { if (m_pAnimatedMesh && m_pAnimatedMesh->IsLoaded()) { CParaXModel* ppMesh = m_pAnimatedMesh->GetModel(); if (ppMesh == 0 || ppMesh->GetHeader().maxExtent.x <= 0.f) { EnablePhysics(false); // disable physics forever, if failed loading physics data return; } // get world transform matrix Matrix4 mxWorld; GetWorldTransform(mxWorld); IParaPhysicsActor* pActor = CGlobals::GetPhysicsWorld()->CreateStaticMesh(m_pAnimatedMesh.get(), mxWorld, m_nPhysicsGroup, &m_staticActors, this); if (m_staticActors.empty()) { // disable physics forever, if no physics actors are loaded. EnablePhysics(false); } } } }
//------------------------------------------------------------------------ void CParachute::Open() { // not used any more return; IEntity* pCanvas = m_pEntitySystem->GetEntity(m_canvasId); // enable canvas physics EnablePhysics(pCanvas, true); if (!pCanvas->GetPhysics()) { CryLog("[Parachute] Canvas physics enabling failed!"); return; } // set canvas to players pos IEntity* pOwner = GetOwner(); pCanvas->SetWorldTM(pOwner->GetWorldTM()); pCanvas->AttachChild(pOwner); m_actorId = pOwner->GetId(); // attach player to canvas GetOwnerActor()->LinkToVehicle(m_canvasId); m_isOpened = true; EnableUpdate(true, eIUS_General); pe_action_awake awake; awake.bAwake = true; pCanvas->GetPhysics()->Action(&awake); if (pOwner->GetPhysics()) { pe_status_dynamics dyn; if (pOwner->GetPhysics()->GetStatus(&dyn)) { // set parachute to player's speed pe_action_set_velocity vel; vel.v = 0.75f*dyn.v; pCanvas->GetPhysics()->Action(&vel); } } }