IVVehicle * CIVVehicle::GetVehicle() { #ifdef EXT_LOG //CLogFile::Printf(__FUNCSIG__); #endif return (IVVehicle *)GetPhysical(); }
IVPed * CIVPed::GetPed() { #ifdef EXT_LOG CLogFile::Printf(__FUNCSIG__); #endif return (IVPed *)GetPhysical(); }
// check to make sure that the avatar and the exclude region are in the same subworld bool plExcludeRegionModifier::ICheckSubworlds(plKey avatar) { plSceneObject* avObj = plSceneObject::ConvertNoRef(avatar->GetObjectPtr()); if (avObj) { // get the avatar modifier const plArmatureMod *avMod = (plArmatureMod*)avObj->GetModifierByType(plArmatureMod::Index()); if (avMod) { // get the avatar controller plPhysicalControllerCore* avController = avMod->GetController(); if (avController) { // get physical of the detector region plPhysical* phys = GetPhysical(GetTarget()); if (phys) { // are they in the same subworld? if ( phys->GetWorldKey() == avController->GetSubworld() ) return true; else return false; } } } } return false; }
void plExcludeRegionSDLModifier::IPutCurrentStateIn(plStateDataRecord* dstState) { plSimpleStateVariable* var = dstState->FindVar(kXRegionSDLCleared); if (var) { plPhysical* phys = GetPhysical(GetTarget()); if (phys) { //bool cleared = phys->GetGroup() == plSimDefs::kGroupStatic; bool cleared = phys->GetGroup() == plSimDefs::kGroupExcludeRegion; var->Set(cleared); } } }
void Player::SetActive(bool on) { if (false==on) { GetEquipped()->SetShooting(false); IPhysical *object = GetPhysical(); //object->SetVelocityVector(Ogre::Vector3::ZERO); //object->SetLinVelocity(Ogre::Vector3::ZERO); //object->SetThrottle(Ogre::Vector3::ZERO); //object->SetLinVelocityAccel(Ogre::Vector3::ZERO); object->Stop(); object->SetRotVelocity(Ogre::Vector3::ZERO); } }
void plExcludeRegionModifier::ISetPhysicalState(bool cleared) { plPhysical* phys = GetPhysical(GetTarget()); if (phys) { phys->ExcludeRegionHack(cleared); if (cleared) { phys->AddLOSDB(plSimDefs::kLOSDBUIBlockers); if (HasFlag(kBlockCameras)) phys->AddLOSDB(plSimDefs::kLOSDBCameraBlockers); } else { phys->RemoveLOSDB(plSimDefs::kLOSDBUIBlockers); if (HasFlag(kBlockCameras)) phys->RemoveLOSDB(plSimDefs::kLOSDBCameraBlockers); } } }
// [G] public: virtual CgOutput* GetArgReg(uint nNth) override { auto const pArgRegs = s_oGprGroup.m_pArgs; if (nNth < static_cast<uint>(pArgRegs->m_c)) { return GetPhysical(pArgRegs->m_prgpReg[nNth]); } if (nNth >= lengthof(m_rgpArgReg)) { COMPILER_INTERNAL_ERROR(); return new ThreadSlot(RegClass_Gpr, 0, sizeof(void*)); } CgOutput* pMx = m_rgpArgReg[nNth]; if (!pMx) { pMx = new ThreadSlot( RegClass_Gpr, offsetof(Thread, mv_value[nNth]), sizeof(void*)); m_rgpArgReg[nNth] = pMx; } return pMx; }
void Player::Step(unsigned timeMs) { //Ogre::Quaternion InvInitialOrientation = InitialRotation.Inverse(); if (!AutoPilotActive) GetPhysical()->SetForwardDirection(GetOrientation()*Vector3::UNIT_Z); //if (GetRoomable()->GetRooms()->IsEmpty()) //{ // HUDCentre::GetInstance()->ShowGuiltyConscienceOverlay(true); //} else //{ // HUDCentre::GetInstance()->ShowGuiltyConscienceOverlay(false); //} //int diff = timeMs - BackupPosTime; /*BackupPosTime+=timeMs; if (BackupPosTime>BACKUP_POSITION_TIMEOUT && !GetRoomable()->GetRooms()->IsEmpty()) { BackupPosTime = 0; if (CommonDeclarations::GetRoomManager()->IsValidPosition(GetPhysical()->GetPosition())) BackupPosition = GetPhysical()->GetPosition(); }*/ //static unsigned RollSpeed = 10; SceneObject::Step(timeMs); if (BonusesModule.get()) BonusesModule->Step(timeMs); Ogre::Vector3 AccelerationOn = GetPhysical()->GetAccelerationOn(); Ogre::Vector3 rot_velocity = CommonDeclarations::GetCamera()->GetRotVelocity(); float angle = abs(LookRelativeOrientation.getRoll().valueRadians()); float actual_fps = LookFps; if (angle>0 && angle<LookBufferAngle) { float coeff = 2 + 2*angle/LookBufferAngle; actual_fps*=coeff; } if (angle>MaxLookRollAngle-LookBufferAngle) { float coeff = 2 + 2*(MaxLookRollAngle-LookBufferAngle)/angle; actual_fps*=coeff; } if (rot_velocity.x>1) { if (angle<MaxLookRollAngle) { Quaternion q; q.FromAngleAxis(Ogre::Degree(LookRollSpeed),Vector3::UNIT_Z); LookRelativeRotationUnit.StartRotation(LookRelativeOrientation, LookRelativeOrientation*q, actual_fps); } } else if (rot_velocity.x<-1) { if (angle<MaxLookRollAngle) { Quaternion q; q.FromAngleAxis(-Ogre::Degree(LookRollSpeed),Vector3::UNIT_Z); LookRelativeRotationUnit.StartRotation(LookRelativeOrientation, LookRelativeOrientation*q, actual_fps); } } else { if (LookRelativeOrientation!=Quaternion::IDENTITY) { Quaternion q = Quaternion::IDENTITY; LookRelativeRotationUnit.StartRotation(LookRelativeOrientation, q, actual_fps); } } angle = abs(StrafeRelativeOrientation.getRoll().valueRadians()); actual_fps = StrafeFps; if (angle>0 && angle<StrafeBufferAngle) { float coeff = 2 + 2*angle/StrafeBufferAngle; actual_fps*=coeff; } if (angle>MaxStrafeRollAngle-StrafeBufferAngle) { float coeff = 2 + 2*(MaxStrafeRollAngle-StrafeBufferAngle)/angle; actual_fps*=coeff; } if (1==AccelerationOn.x) { if (angle<MaxStrafeRollAngle) { Quaternion q; q.FromAngleAxis(-Ogre::Degree(StrafeRollSpeed),Vector3::UNIT_Z); StrafeRelativeRotationUnit.StartRotation(StrafeRelativeOrientation, StrafeRelativeOrientation*q, actual_fps); } } else if(-1==AccelerationOn.x) { if (angle<MaxStrafeRollAngle) { Quaternion q; q.FromAngleAxis(Ogre::Degree(StrafeRollSpeed),Vector3::UNIT_Z); StrafeRelativeRotationUnit.StartRotation(StrafeRelativeOrientation, StrafeRelativeOrientation*q, actual_fps); } } else { if (StrafeRelativeOrientation!=Quaternion::IDENTITY) { Quaternion q = Quaternion::IDENTITY; StrafeRelativeRotationUnit.StartRotation(StrafeRelativeOrientation, q, actual_fps); } } { if(StrafeRelativeRotationUnit.mRotating) { StrafeRelativeRotationUnit.Step(); if(StrafeRelativeRotationUnit.mRotating) // Process timed rotation { StrafeRelativeOrientation = StrafeRelativeRotationUnit.Slerp(); } } if(LookRelativeRotationUnit.mRotating) { LookRelativeRotationUnit.Step(); if(LookRelativeRotationUnit.mRotating) // Process timed rotation { LookRelativeOrientation = LookRelativeRotationUnit.Slerp(); } } } RelativeOrientation = StrafeRelativeOrientation*LookRelativeOrientation; }
IVVehicle * CIVVehicle::GetVehicle() { return (IVVehicle *)GetPhysical(); }
IVPed * CIVPed::GetPed() { return (IVPed *)GetPhysical(); }
IPed * CPed::GetPed() { return (IPed *)GetPhysical(); }
// Move avatars out of volume void plExcludeRegionModifier::IMoveAvatars() { //some reason this is not always finding all avatars might have something to do with //Physx trigger flutter. Adding in brute force method /* for (int i = 0; i < fContainedAvatars.Count(); i++) { if ( ICheckSubworlds(fContainedAvatars[i]) ) { int closestIdx = IFindClosestSafePoint(fContainedAvatars[i]); if (closestIdx != -1) { plAvSeekMsg* msg = new plAvSeekMsg; msg->SetBCastFlag(plMessage::kPropagateToModifiers); msg->AddReceiver(fContainedAvatars[i]); msg->fSmartSeek = fSeek; msg->fDuration = fSeekTime; msg->fSeekPoint = fSafePoints[closestIdx]; msg->fFlags |= plAvSeekMsg::kSeekFlagUnForce3rdPersonOnFinish; msg->Send(); } } } */ plPXPhysical* phys =(plPXPhysical*) GetPhysical(GetTarget()); if (phys) { plKey DetectorWorldKey = phys->GetWorldKey(); int numControllers = plPXPhysicalControllerCore::GetNumberOfControllersInThisSubWorld(phys->GetWorldKey()); if (numControllers > 0) { plPXPhysicalControllerCore** controllers = new plPXPhysicalControllerCore*[numControllers]; int actualCount = plPXPhysicalControllerCore::GetControllersInThisSubWorld(phys->GetWorldKey(), numControllers, controllers); for (int i=0;i<actualCount;i++) { NxCapsule cap; controllers[i]->GetWorldSpaceCapsule(cap); if(phys->OverlapWithCapsule(cap)) { plSceneObject* so = plSceneObject::ConvertNoRef(controllers[i]->GetOwner()->ObjectIsLoaded()); const plArmatureMod* constAvMod = (plArmatureMod*)so->GetModifierByType(plArmatureMod::Index()); if(constAvMod) { plAvBrainGeneric *curGenBrain = (plAvBrainGeneric *)constAvMod->FindBrainByClass(plAvBrainGeneric::Index()); // *** warning; if there's more than one generic brain active, this will only look at the first if (curGenBrain && curGenBrain->GetType() == plAvBrainGeneric::kLadder) { plAvBrainGenericMsg* pMsg = new plAvBrainGenericMsg( nil, constAvMod->GetKey(), plAvBrainGenericMsg::kGotoStage, -1, false, 0.0, false, false, 0.0 ); pMsg->Send(); } else { int closestIdx = IFindClosestSafePoint(controllers[i]->GetOwner()); if (closestIdx != -1) { plAvSeekMsg* msg = new plAvSeekMsg; msg->SetBCastFlag(plMessage::kPropagateToModifiers); msg->AddReceiver(controllers[i]->GetOwner()); msg->fSmartSeek = fSeek; msg->fDuration = fSeekTime; msg->fSeekPoint = fSafePoints[closestIdx]; msg->fFlags |= plAvSeekMsg::kSeekFlagUnForce3rdPersonOnFinish; msg->Send(); } } } } } delete[] controllers; } } }