MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / updateDrive4W

Method updateDrive4W

physx/source/physxvehicle/src/PxVehicleUpdate.cpp:4782–5369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4780};
4781
4782void PxVehicleUpdate::updateDrive4W(
4783const PxF32 timestep,
4784const PxVec3& gravity, const PxF32 gravityMagnitude, const PxF32 recipGravityMagnitude,
4785const PxVehicleDrivableSurfaceToTireFrictionPairs& drivableSurfaceToTireFrictionPairs,
4786PxVehicleDrive4W* vehDrive4W, PxVehicleWheelQueryResult* vehWheelQueryResults, PxVehicleConcurrentUpdateData* vehConcurrentUpdates)
4787{
4788 PX_SIMD_GUARD; // denorm exception in transformInertiaTensor() on osx
4789
4790 START_TIMER(TIMER_ADMIN);
4791
4792 PX_CHECK_AND_RETURN(
4793 vehDrive4W->mDriveDynData.mControlAnalogVals[PxVehicleDrive4WControl::eANALOG_INPUT_ACCEL]>-0.01f &&
4794 vehDrive4W->mDriveDynData.mControlAnalogVals[PxVehicleDrive4WControl::eANALOG_INPUT_ACCEL]<1.01f,
4795 "Illegal vehicle control value - accel must be in range (0,1)");
4796 PX_CHECK_AND_RETURN(
4797 vehDrive4W->mDriveDynData.mControlAnalogVals[PxVehicleDrive4WControl::eANALOG_INPUT_BRAKE]>-0.01f &&
4798 vehDrive4W->mDriveDynData.mControlAnalogVals[PxVehicleDrive4WControl::eANALOG_INPUT_BRAKE]<1.01f,
4799 "Illegal vehicle control value - brake must be in range (0,1)");
4800 PX_CHECK_AND_RETURN(
4801 vehDrive4W->mDriveDynData.mControlAnalogVals[PxVehicleDrive4WControl::eANALOG_INPUT_HANDBRAKE]>-0.01f &&
4802 vehDrive4W->mDriveDynData.mControlAnalogVals[PxVehicleDrive4WControl::eANALOG_INPUT_HANDBRAKE]<1.01f,
4803 "Illegal vehicle control value - handbrake must be in range (0,1)");
4804 PX_CHECK_AND_RETURN(
4805 vehDrive4W->mDriveDynData.mControlAnalogVals[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_LEFT]>-1.01f &&
4806 vehDrive4W->mDriveDynData.mControlAnalogVals[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_LEFT]<1.01f,
4807 "Illegal vehicle control value - left steer must be in range (-1,1)");
4808 PX_CHECK_AND_RETURN(
4809 vehDrive4W->mDriveDynData.mControlAnalogVals[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_RIGHT]>-1.01f &&
4810 vehDrive4W->mDriveDynData.mControlAnalogVals[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_RIGHT]<1.01f,
4811 "Illegal vehicle control value - right steer must be in range (-1,1)");
4812 PX_CHECK_AND_RETURN(
4813 PxAbs(vehDrive4W->mDriveDynData.mControlAnalogVals[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_RIGHT]-
4814 vehDrive4W->mDriveDynData.mControlAnalogVals[PxVehicleDrive4WControl::eANALOG_INPUT_STEER_LEFT])<1.01f,
4815 "Illegal vehicle control value - right steer value minus left steer value must be in range (-1,1)");
4816 PX_CHECK_AND_RETURN(
4817 !(vehDrive4W->getRigidDynamicActor()->getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC),
4818 "Attempting to update a drive4W with a kinematic actor - this isn't allowed");
4819 PX_CHECK_AND_RETURN(
4820 NULL==vehWheelQueryResults || vehWheelQueryResults->nbWheelQueryResults >= vehDrive4W->mWheelsSimData.getNbWheels(),
4821 "nbWheelQueryResults must always be greater than or equal to number of wheels in corresponding vehicle");
4822 PX_CHECK_AND_RETURN(
4823 NULL==vehConcurrentUpdates || vehConcurrentUpdates->nbConcurrentWheelUpdates >= vehDrive4W->mWheelsSimData.getNbWheels(),
4824 "vehConcurrentUpdates->nbConcurrentWheelUpdates must always be greater than or equal to number of wheels in corresponding vehicle");
4825
4826#if PX_CHECKED
4827 {
4828 //Check that the sense of left/right and forward/rear is true.
4829 const PxVec3 fl=vehDrive4W->mWheelsSimData.mWheels4SimData[0].getWheelCentreOffset(PxVehicleDrive4WWheelOrder::eFRONT_LEFT);
4830 const PxVec3 fr=vehDrive4W->mWheelsSimData.mWheels4SimData[0].getWheelCentreOffset(PxVehicleDrive4WWheelOrder::eFRONT_RIGHT);
4831 const PxVec3 rl=vehDrive4W->mWheelsSimData.mWheels4SimData[0].getWheelCentreOffset(PxVehicleDrive4WWheelOrder::eREAR_LEFT);
4832 const PxVec3 rr=vehDrive4W->mWheelsSimData.mWheels4SimData[0].getWheelCentreOffset(PxVehicleDrive4WWheelOrder::eREAR_RIGHT);
4833 const PxVec3 right=gRight;
4834 const PxF32 s0=computeSign((fr-fl).dot(right));
4835 const PxF32 s1=computeSign((rr-rl).dot(right));
4836 PX_CHECK_AND_RETURN(0==s0 || 0==s1 || s0==s1, "PxVehicle4W does not obey the rule that the eFRONT_RIGHT/eREAR_RIGHT wheels are to the right of the eFRONT_LEFT/eREAR_LEFT wheels");
4837 }
4838#endif
4839

Callers

nothing calls this directly

Calls 15

START_TIMERFunction · 0.85
PxAbsFunction · 0.85
computeSignFunction · 0.85
END_TIMERFunction · 0.85
PxMinFunction · 0.85
processAutoBoxFunction · 0.85
processGearsFunction · 0.85
computeClutchStrengthFunction · 0.85
computeGearRatioFunction · 0.85
updateGraphDataGearRatioFunction · 0.85

Tested by

no test coverage detected