bool PxVehicleTireLoadFilterData::isValid() const { PX_CHECK_AND_RETURN_VAL(mMaxNormalisedLoad>=mMinNormalisedLoad, "PxVehicleTireLoadFilterData.mMaxNormalisedLoad must be greater than or equal to PxVehicleTireLoadFilterData.mMinNormalisedLoad", false); PX_CHECK_AND_RETURN_VAL(mMaxFilteredNormalisedLoad>0, "PxVehicleTireLoadFilterData.mMaxFilteredNormalisedLoad must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(PxAbs((1.0f/(mMaxNormalisedLoad - mMinNormalisedLoad)) - mDenominator) < 0.001f, "PxVehicleTireLoadFilterData.mMaxFilteredNormalisedLoad, PxVehicleTireLoadFilterData.mMinNormalisedLoad, and PxVehicleTireLoadFilterData.mDenominator don't match", false); return true; }
PxReal PxVehicleDrivableSurfaceToTireFrictionPairs::getTypePairFriction(const PxU32 surfaceType, const PxU32 tireType) const { PX_CHECK_AND_RETURN_VAL(tireType<mNumTireTypes, "Invalid tireType", 0.0f); PX_CHECK_AND_RETURN_VAL(surfaceType<mNumSurfaceTypes, "Invalid surfaceType", 0.0f); return *(mPairs + mNumTireTypes*surfaceType + tireType); }
bool PxVehicleAckermannGeometryData::isValid() const { PX_CHECK_AND_RETURN_VAL(mAccuracy>=0.0f && mAccuracy<=1.0f, "PxVehicleAckermannGeometryData.mAccuracy must be in range (0,1)", false); PX_CHECK_AND_RETURN_VAL(mFrontWidth>0.0f, "PxVehicleAckermannGeometryData.mFrontWidth must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mRearWidth>0.0f, "PxVehicleAckermannGeometryData.mRearWidth must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mAxleSeparation>0.0f, "PxVehicleAckermannGeometryData.mAxleSeparation must be greater than zero", false); return true; }
bool PxVehicleDriveSimData::isValid() const { PX_CHECK_AND_RETURN_VAL(mEngine.isValid(), "Invalid PxVehicleCoreSimulationData.mEngine", false); PX_CHECK_AND_RETURN_VAL(mGears.isValid(), "Invalid PxVehicleCoreSimulationData.mGears", false); PX_CHECK_AND_RETURN_VAL(mClutch.isValid(), "Invalid PxVehicleCoreSimulationData.mClutch", false); PX_CHECK_AND_RETURN_VAL(mAutoBox.isValid(), "Invalid PxVehicleCoreSimulationData.mAutoBox", false); return true; }
bool PxVehicleTireData::isValid() const { PX_CHECK_AND_RETURN_VAL(mFrictionVsSlipGraph[0][0]>=0.0f && mFrictionVsSlipGraph[0][1]>=0.0f, "Illegal values for mFrictionVsSlipGraph[0]", false); PX_CHECK_AND_RETURN_VAL(mFrictionVsSlipGraph[1][0]>=0.0f && mFrictionVsSlipGraph[1][1]>=0.0f, "Illegal values for mFrictionVsSlipGraph[1]", false); PX_CHECK_AND_RETURN_VAL(mFrictionVsSlipGraph[2][0]>=0.0f && mFrictionVsSlipGraph[2][1]>=0.0f, "Illegal values for mFrictionVsSlipGraph[2]", false); PX_CHECK_AND_RETURN_VAL(PxAbs((1.0f/(mFrictionVsSlipGraph[1][0]-mFrictionVsSlipGraph[0][0])) - mFrictionVsSlipGraphRecipx1Minusx0) < 0.001f, "PxVehicleTireData.mFrictionVsSlipGraphRecipx1Minusx0 not set up", false); PX_CHECK_AND_RETURN_VAL(PxAbs((1.0f/(mFrictionVsSlipGraph[2][0]-mFrictionVsSlipGraph[1][0])) - mFrictionVsSlipGraphRecipx2Minusx1) < 0.001f, "PxVehicleTireData.mFrictionVsSlipGraphRecipx2Minusx1 not set up", false); return true; }
bool PxVehicleSuspensionData::isValid() const { PX_CHECK_AND_RETURN_VAL(mSpringStrength>=0.0f, "PxVehicleSuspensionData.mSpringStrength must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(mSpringDamperRate>=0.0f, "PxVehicleSuspensionData.mSpringDamperRate must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(mMaxCompression>=0.0f, "PxVehicleSuspensionData.mMaxCompression must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(mMaxDroop>=0.0f, "PxVehicleSuspensionData.mMaxDroop must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(mSprungMass>=0.0f, "PxVehicleSuspensionData.mSprungMass must be greater than or equal to zero", false); return true; }
bool PxVehicleAutoBoxData::isValid() const { for(PxU32 i=0;i<PxVehicleGearsData::eMAX_NUM_GEAR_RATIOS;i++) { PX_CHECK_AND_RETURN_VAL(mUpRatios[i]>=0.0f, "PxVehicleAutoBoxData.mUpRatios must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(mDownRatios[i]>=0.0f, "PxVehicleAutoBoxData.mDownRatios must be greater than or equal to zero", false); } return true; }
bool PxVehicleWheelData::isValid() const { PX_CHECK_AND_RETURN_VAL(mRadius>0.0f, "PxVehicleWheelData.mRadius must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mWidth>0.0f, "PxVehicleWheelData.mWidth must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mMass>0.0f, "PxVehicleWheelData.mMass must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mMOI>0.0f, "PxVehicleWheelData.mMOI must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mDampingRate>0.0f, "PxVehicleWheelData.mDampingRate must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mMaxBrakeTorque>=0.0f, "PxVehicleWheelData.mMaxBrakeTorque must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(mMaxHandBrakeTorque>=0.0f, "PxVehicleWheelData.mMaxHandBrakeTorque must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(mToeAngle<=PxPi, "PxVehicleWheelData.mToeAngle must be less than Pi", false); PX_CHECK_AND_RETURN_VAL(PxAbs((1.0f/mRadius) - mRecipRadius) < 0.001f, "PxVehicleWheelData.mRadius and PxVehicleWheelData.mRecipRadius don't match", false); PX_CHECK_AND_RETURN_VAL(PxAbs((1.0f/mMOI) - mRecipMOI) < 0.001f, "PxVehicleWheelData.mMOI and PxVehicleWheelData.mRecipMOI don't match", false); return true; }
bool NpArticulation::isSleeping() const { NP_READ_CHECK(getOwnerScene()); PX_CHECK_AND_RETURN_VAL(getAPIScene(), "Articulation::isSleeping: articulation must be in a scene.", true); return getArticulation().isSleeping(); }
bool PxVehicleWheelsDynData::isValid() const { for(PxU32 i=0;i<mNumWheels4;i++) { PX_CHECK_AND_RETURN_VAL(mWheels4DynData[i].isValid(), "Invalid PxVehicleSuspWheelTireNDynData.mSuspWheelTire4DynData[i]", false); } return true; }
bool PxVehicleWheels4SimData::isValid(const PxU32 id) const { PX_ASSERT(id<4); PX_CHECK_AND_RETURN_VAL(mSuspensions[id].isValid(), "Invalid PxVehicleSuspWheelTire4SimulationData.mSuspensions", false); PX_CHECK_AND_RETURN_VAL(mWheels[id].isValid(), "Invalid PxVehicleSuspWheelTire4SimulationData.mWheels", false); PX_CHECK_AND_RETURN_VAL(mTires[id].isValid(), "Invalid PxVehicleSuspWheelTire4SimulationData.mTires", false); PX_CHECK_AND_RETURN_VAL(mSuspDownwardTravelDirections[id].magnitude()>=0.999f && mSuspDownwardTravelDirections[id].magnitude()<=1.001f, "Invalid PxVehicleSuspWheelTire4SimulationData.mSuspDownwardTravelDirections", false); PX_CHECK_AND_RETURN_VAL(mSuspForceAppPointOffsets[id].magnitude()!=0.0f, "Invalid PxVehicleSuspWheelTire4SimulationData.mSuspForceAppPointOffsets.mSuspForceAppPointOffsets", false); PX_CHECK_AND_RETURN_VAL(mTireForceAppPointOffsets[id].magnitude()!=0.0f, "Invalid PxVehicleSuspWheelTire4SimulationData.mTireForceAppPointOffsets.mTireForceAppPointOffsets", false); PX_CHECK_AND_RETURN_VAL(mWheelCentreOffsets[id].magnitude()!=0.0f, "Invalid PxVehicleSuspWheelTire4SimulationData.mWheelCentreOffsets.mWheelCentreOffsets", false); PX_CHECK_AND_RETURN_VAL(mTireRestLoads[id]>0.0f, "Invalid PxVehicleSuspWheelTire4SimulationData.mTireRestLoads", false); PX_CHECK_AND_RETURN_VAL(PxAbs((1.0f/mTireRestLoads[id]) - mRecipTireRestLoads[id]) <= 0.001f, "Invalid PxVehicleSuspWheelTire4SimulationData.mRecipTireRestLoads", false); PX_UNUSED(id); return true; }
PxSpatialIndexItemId NpSpatialIndex::insert(PxSpatialIndexItem& item, const PxBounds3& bounds) { PX_SIMD_GUARD; PX_CHECK_AND_RETURN_VAL(bounds.isValid(), "PxSpatialIndex::insert: bounds are not valid.", PX_SPATIAL_INDEX_INVALID_ITEM_ID); Sq::PrunerHandle output; Sq::PrunerPayload payload; payload.data[0] = reinterpret_cast<size_t>(&item); mPruner->addObjects(&output, &bounds, &payload); mPendingUpdates = true; return output; }
bool PxVehicleEngineData::isValid() const { PX_CHECK_AND_RETURN_VAL(mPeakTorque>0.0f, "PxVehicleEngineData.mPeakTorque must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mMaxOmega>0.0f, "PxVehicleEngineData.mMaxOmega must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mDampingRateFullThrottle>0.0f, "PxVehicleEngineData.mDampingRateFullThrottle must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mDampingRateZeroThrottleClutchEngaged>0.0f, "PxVehicleEngineData.mDampingRateZeroThrottleClutchEngaged must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mDampingRateZeroThrottleClutchDisengaged>0.0f, "PxVehicleEngineData.mDampingRateZeroThrottleClutchDisengaged must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mRecipMaxOmega>0.0f, "PxVehicleEngineData.mRecipMaxOmega must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(PxAbs((1.0f/mMaxOmega)-mRecipMaxOmega) <= 0.001f, "PxVehicleEngineData.mMaxOmega and PxVehicleEngineData.mRecipMaxOmega don't match", false); return true; }
bool PxVehicleDifferential4WData::isValid() const { PX_CHECK_AND_RETURN_VAL(mFrontRearSplit<=1.0f && mFrontRearSplit>=0.0f, "PxVehicleDifferential4WData.mFrontRearSplit must be in range (0,1)", false); PX_CHECK_AND_RETURN_VAL(mFrontLeftRightSplit<=1.0f && mFrontLeftRightSplit>=0.0f, "PxVehicleDifferential4WData.mFrontLeftRightSplit must be in range (0,1)", false); PX_CHECK_AND_RETURN_VAL(mRearLeftRightSplit<=1.0f || mRearLeftRightSplit>=0.0f, "PxVehicleDifferential4WData.mRearLeftRightSplit must be in range (0,1)", false); PX_CHECK_AND_RETURN_VAL(mCentreBias>=1.0f, "PxVehicleDifferential4WData.mCentreBias must be greater than or equal to 1.0f", false); PX_CHECK_AND_RETURN_VAL(mFrontBias>=1.0f, "PxVehicleDifferential4WData.mFrontBias must be greater than or equal to 1.0f", false); PX_CHECK_AND_RETURN_VAL(mRearBias>=1.0f, "PxVehicleDifferential4WData.mRearBias must be greater than or equal to 1.0f", false); PX_CHECK_AND_RETURN_VAL(mType<eMAX_NUM_DIFF_TYPES, "PxVehicleDifferential4WData.mType has illegal value", false); return true; }
bool PxVehicleWheelsSimData::isValid() const { for(PxU32 i=0;i<mNumWheels4-1;i++) { mWheels4SimData[i].isValid(0); mWheels4SimData[i].isValid(1); mWheels4SimData[i].isValid(2); mWheels4SimData[i].isValid(3); } const PxU32 numInLastBlock = 4 - (4*mNumWheels4 - mNumActiveWheels); for(PxU32 i=0;i<numInLastBlock;i++) { mWheels4SimData[mNumWheels4-1].isValid(i); } PX_CHECK_AND_RETURN_VAL(mNormalisedLoadFilter.isValid(), "Invalid PxVehicleWheelsSimData.mNormalisedLoadFilter", false); return true; }
bool PxVehicleGearsData::isValid() const { PX_CHECK_AND_RETURN_VAL(mFinalRatio>0, "PxVehicleGearsData.mFinalRatio must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mNumRatios>=1, "PxVehicleGearsData.mNumRatios must be greater than zero", false); PX_CHECK_AND_RETURN_VAL(mSwitchTime>=0.0f, "PxVehicleGearsData.mSwitchTime must be greater than or equal to zero", false); PX_CHECK_AND_RETURN_VAL(mRatios[PxVehicleGearsData::eREVERSE]<0.0f, "PxVehicleGearsData.mRatios[PxVehicleGearsData::eREVERSE] must be less than zero", false); PX_CHECK_AND_RETURN_VAL(mRatios[PxVehicleGearsData::eNEUTRAL]==0.0f, "PxVehicleGearsData.mRatios[PxVehicleGearsData::eNEUTRAL] must be zero", false); for(PxU32 i=PxVehicleGearsData::eFIRST;i<mNumRatios;i++) { PX_CHECK_AND_RETURN_VAL(mRatios[i]>0.0f, "Forward gear ratios must be greater than zero", false); } for(PxU32 i=PxVehicleGearsData::eSECOND;i<mNumRatios;i++) { PX_CHECK_AND_RETURN_VAL(mRatios[i]<mRatios[i-1], "Forward gear ratios must be a descending sequence of gear ratios", false); } return true; }
PxVehicleDrivableSurfaceToTireFrictionPairs* PxVehicleDrivableSurfaceToTireFrictionPairs::create (const PxU32 maxNumTireTypes, const PxU32 maxNumSurfaceTypes, const PxMaterial** drivableSurfaceMaterials, const PxVehicleDrivableSurfaceType* drivableSurfaceTypes) { PX_CHECK_AND_RETURN_VAL(maxNumSurfaceTypes < eMAX_NUM_SURFACE_TYPES, "maxNumSurfaceTypes must be less than eMAX_NUM_SURFACE_TYPES", NULL); PxU32 byteSize = ((sizeof(PxU32)*(maxNumTireTypes*maxNumSurfaceTypes) + 15) & ~15); byteSize += ((sizeof(PxMaterial*)*maxNumSurfaceTypes + 15) & ~15); byteSize += ((sizeof(PxVehicleDrivableSurfaceType)*maxNumSurfaceTypes + 15) & ~15); byteSize += ((sizeof(PxVehicleDrivableSurfaceToTireFrictionPairs) + 15) & ~ 15); PxU8* ptr = (PxU8*)PX_ALLOC(byteSize, PX_DEBUG_EXP("PxVehicleDrivableSurfaceToTireFrictionPairs")); PxVehicleDrivableSurfaceToTireFrictionPairs* pairs = (PxVehicleDrivableSurfaceToTireFrictionPairs*)ptr; ptr += ((sizeof(PxVehicleDrivableSurfaceToTireFrictionPairs) + 15) & ~ 15); pairs->mPairs = (PxReal*)ptr; ptr += ((sizeof(PxU32)*(maxNumTireTypes*maxNumSurfaceTypes) + 15) & ~15); pairs->mDrivableSurfaceMaterials = (const PxMaterial**)ptr; ptr += ((sizeof(PxMaterial*)*maxNumSurfaceTypes + 15) & ~15); pairs->mDrivableSurfaceTypes = (PxVehicleDrivableSurfaceType*)ptr; ptr += ((sizeof(PxVehicleDrivableSurfaceType)*maxNumSurfaceTypes +15) & ~15); for(PxU32 i=0;i<maxNumSurfaceTypes;i++) { pairs->mDrivableSurfaceTypes[i] = drivableSurfaceTypes[i]; pairs->mDrivableSurfaceMaterials[i] = drivableSurfaceMaterials[i]; } for(PxU32 i=0;i<maxNumTireTypes*maxNumSurfaceTypes;i++) { pairs->mPairs[i]=1.0f; } pairs->mNumTireTypes=maxNumTireTypes; pairs->mNumSurfaceTypes=maxNumSurfaceTypes; return pairs; }
bool PxVehicleChassisData::isValid() const { PX_CHECK_AND_RETURN_VAL(mMOI.x>0.0f && mMOI.y>0.0f && mMOI.z>0.0f, "Illegal PxVehicleChassisData.mMOI - each element of the chassis moi needs to non-zero", false); PX_CHECK_AND_RETURN_VAL(mMass>0.0f, "Ilegal PxVehicleChassisData.mMass - chassis mass needs to be non-zero", false); return true; }
bool PxVehicleWheelsSimData::getIsWheelDisabled(const PxU32 wheel) const { PX_CHECK_AND_RETURN_VAL(wheel < 4*mNumWheels4, "PxVehicleWheelsSimData::getIsWheelDisabled - Illegal wheel", false); const PxVehicleSuspensionData& suspData=getSuspensionData(wheel); return (PX_DISABLED_SUSPENSION_SPRUNGMASS==suspData.mSprungMass && PX_DISABLED_SUSPENSION_SPRINTSTRENGTH==suspData.mSpringStrength); }
bool PxVehicleWheels::isValid() const { PX_CHECK_AND_RETURN_VAL(mWheelsSimData.isValid(), "invalid mWheelsSimData", false); PX_CHECK_AND_RETURN_VAL(mWheelsDynData.isValid(), "invalid mWheelsDynData", false); return true; }
PxVec3 PxVehicleWheelsDynData::getSuspLineDir(const PxU32 tireIdx) const { PX_CHECK_AND_RETURN_VAL(tireIdx < mNumActiveWheels, "PxVehicleWheelsDynData::getSuspLineDirs - Illegal wheel", PxVec3(0,0,0)); const PxVehicleWheels4DynData& suspWheelTire4=mWheels4DynData[(tireIdx>>2)]; return suspWheelTire4.mSuspLineDirs[tireIdx & 3]; }
PxReal PxVehicleWheelsDynData::getTireFriction(const PxU32 tireIdx) const { PX_CHECK_AND_RETURN_VAL(tireIdx < mNumActiveWheels, "PxVehicleWheelsDynData::getTireFriction - Illegal wheel", 0.0f); const PxVehicleWheels4DynData& suspWheelTire4=mWheels4DynData[(tireIdx>>2)]; return suspWheelTire4.mTireFrictions[tireIdx & 3]; }
const PxMaterial* PxVehicleWheelsDynData::getTireDrivableSurfaceMaterial(const PxU32 tireIdx) const { PX_CHECK_AND_RETURN_VAL(tireIdx < mNumActiveWheels, "PxVehicleWheelsDynData::getTireDrivableSurfaceType - Illegal wheel", 0); const PxVehicleWheels4DynData& suspWheelTire4=mWheels4DynData[(tireIdx>>2)]; return suspWheelTire4.mTireSurfaceMaterials[tireIdx & 3]; }
PxReal PxVehicleWheelsDynData::getSteer(const PxU32 wheelIdx) const { PX_CHECK_AND_RETURN_VAL(wheelIdx < mNumActiveWheels, "PxVehicleWheelsDynData::getSteer - Illegal wheel", 0.0f); const PxVehicleWheels4DynData& suspWheelTire4=mWheels4DynData[(wheelIdx>>2)]; return suspWheelTire4.mSteerAngles[wheelIdx & 3]; }
PxReal PxVehicleWheelsDynData::getSuspJounce(const PxU32 suspIdx) const { PX_CHECK_AND_RETURN_VAL(suspIdx < mNumActiveWheels, "PxVehicleWheelsDynData::getSuspJounce - Illegal wheel", 0.0f); const PxVehicleWheels4DynData& suspWheelTire4=mWheels4DynData[(suspIdx>>2)]; return suspWheelTire4.mSuspJounces[suspIdx & 3]; }
PxReal PxVehicleWheelsDynData::getWheelRotationSpeed(const PxU32 wheelIdx) const { PX_CHECK_AND_RETURN_VAL(wheelIdx < mNumActiveWheels, "PxVehicleWheelsDynData::getWheelRotationSpeed - Illegal wheel", 0.0f); const PxVehicleWheels4DynData& suspWheelTire4=mWheels4DynData[(wheelIdx>>2)]; return suspWheelTire4.mWheelSpeeds[wheelIdx & 3]; }
PxReal PxVehicleDriveDynData::getAnalogInput(const PxU32 type) const { PX_CHECK_AND_RETURN_VAL(type<eMAX_NB_ANALOG_INPUTS, "PxVehicleDriveDynData::getAnalogInput - illegal type", 0.0f); return mControlAnalogVals[type]; }
bool PxVehicleDrive::isValid() const { PX_CHECK_AND_RETURN_VAL(PxVehicleWheels::isValid(), "invalid PxVehicleWheels", false); PX_CHECK_AND_RETURN_VAL(mDriveDynData.isValid(), "Invalid PxVehicleDrive.mCoreSimData", false); return true; }
PxReal PxVehicleNoDrive::getBrakeTorque(const PxU32 id) const { PX_CHECK_AND_RETURN_VAL(id < mWheelsSimData.getNbWheels(), "PxVehicleNoDrive::getBrakeTorque - Illegal wheel", 0); return mBrakeTorques[id]; }
PxReal PxVehicleNoDrive::getSteerAngle(const PxU32 id) const { PX_CHECK_AND_RETURN_VAL(id < mWheelsSimData.getNbWheels(), "PxVehicleNoDrive::getSteerAngle - Illegal wheel",0); return mSteerAngles[id]; }