feat(physics): wire physx sdk into build
This commit is contained in:
143
engine/third_party/physx/include/vehicle2/PxVehicleAPI.h
vendored
Normal file
143
engine/third_party/physx/include/vehicle2/PxVehicleAPI.h
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "vehicle2/PxVehicleLimits.h"
|
||||
#include "vehicle2/PxVehicleComponent.h"
|
||||
#include "vehicle2/PxVehicleComponentSequence.h"
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "vehicle2/PxVehicleFunctions.h"
|
||||
#include "vehicle2/PxVehicleMaths.h"
|
||||
|
||||
#include "vehicle2/braking/PxVehicleBrakingParams.h"
|
||||
#include "vehicle2/braking/PxVehicleBrakingFunctions.h"
|
||||
|
||||
#include "vehicle2/commands/PxVehicleCommandParams.h"
|
||||
#include "vehicle2/commands/PxVehicleCommandStates.h"
|
||||
#include "vehicle2/commands/PxVehicleCommandHelpers.h"
|
||||
|
||||
#include "vehicle2/drivetrain/PxVehicleDrivetrainParams.h"
|
||||
#include "vehicle2/drivetrain/PxVehicleDrivetrainStates.h"
|
||||
#include "vehicle2/drivetrain/PxVehicleDrivetrainHelpers.h"
|
||||
#include "vehicle2/drivetrain/PxVehicleDrivetrainFunctions.h"
|
||||
#include "vehicle2/drivetrain/PxVehicleDrivetrainComponents.h"
|
||||
|
||||
#include "vehicle2/physxActor/PxVehiclePhysXActorStates.h"
|
||||
#include "vehicle2/physxActor/PxVehiclePhysXActorHelpers.h"
|
||||
#include "vehicle2/physxActor/PxVehiclePhysXActorFunctions.h"
|
||||
#include "vehicle2/physxActor/PxVehiclePhysXActorComponents.h"
|
||||
|
||||
#include "vehicle2/physxConstraints/PxVehiclePhysXConstraintParams.h"
|
||||
#include "vehicle2/physxConstraints/PxVehiclePhysXConstraintStates.h"
|
||||
#include "vehicle2/physxConstraints/PxVehiclePhysXConstraintHelpers.h"
|
||||
#include "vehicle2/physxConstraints/PxVehiclePhysXConstraintFunctions.h"
|
||||
#include "vehicle2/physxConstraints/PxVehiclePhysXConstraintComponents.h"
|
||||
|
||||
#include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryState.h"
|
||||
#include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryParams.h"
|
||||
#include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryHelpers.h"
|
||||
#include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryFunctions.h"
|
||||
#include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryComponents.h"
|
||||
|
||||
#include "vehicle2/pvd/PxVehiclePvdHelpers.h"
|
||||
#include "vehicle2/pvd/PxVehiclePvdFunctions.h"
|
||||
#include "vehicle2/pvd/PxVehiclePvdComponents.h"
|
||||
|
||||
#include "vehicle2/rigidBody/PxVehicleRigidBodyParams.h"
|
||||
#include "vehicle2/rigidBody/PxVehicleRigidBodyStates.h"
|
||||
#include "vehicle2/rigidBody/PxVehicleRigidBodyFunctions.h"
|
||||
#include "vehicle2/rigidBody/PxVehicleRigidBodyComponents.h"
|
||||
|
||||
#include "vehicle2/roadGeometry/PxVehicleRoadGeometryState.h"
|
||||
|
||||
#include "vehicle2/steering/PxVehicleSteeringParams.h"
|
||||
#include "vehicle2/steering/PxVehicleSteeringFunctions.h"
|
||||
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionParams.h"
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionStates.h"
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionHelpers.h"
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionFunctions.h"
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionComponents.h"
|
||||
|
||||
#include "vehicle2/tire/PxVehicleTireParams.h"
|
||||
#include "vehicle2/tire/PxVehicleTireStates.h"
|
||||
#include "vehicle2/tire/PxVehicleTireHelpers.h"
|
||||
#include "vehicle2/tire/PxVehicleTireFunctions.h"
|
||||
#include "vehicle2/tire/PxVehicleTireComponents.h"
|
||||
|
||||
#include "vehicle2/wheel/PxVehicleWheelParams.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelStates.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelHelpers.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelFunctions.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelComponents.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/** \brief Initialize the PhysX Vehicle library.
|
||||
|
||||
This should be called before calling any functions or methods in extensions which may require allocation.
|
||||
\note This function does not need to be called before creating a PxDefaultAllocator object.
|
||||
|
||||
\param foundation a PxFoundation object
|
||||
|
||||
\see PxCloseVehicleExtension PxFoundation
|
||||
*/
|
||||
PX_FORCE_INLINE bool PxInitVehicleExtension(physx::PxFoundation& foundation)
|
||||
{
|
||||
PX_UNUSED(foundation);
|
||||
PX_CHECK_AND_RETURN_VAL(&PxGetFoundation() == &foundation, "Supplied foundation must match the one that will be used to perform allocations", false);
|
||||
PxIncFoundationRefCount();
|
||||
return true;
|
||||
}
|
||||
|
||||
/** \brief Shut down the PhysX Vehicle library.
|
||||
|
||||
This function should be called to cleanly shut down the PhysX Vehicle library before application exit.
|
||||
|
||||
\note This function is required to be called to release foundation usage.
|
||||
|
||||
\see PxInitVehicleExtension
|
||||
*/
|
||||
PX_FORCE_INLINE void PxCloseVehicleExtension()
|
||||
{
|
||||
PxDecFoundationRefCount();
|
||||
}
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
66
engine/third_party/physx/include/vehicle2/PxVehicleComponent.h
vendored
Normal file
66
engine/third_party/physx/include/vehicle2/PxVehicleComponent.h
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
struct PxVehicleSimulationContext;
|
||||
|
||||
class PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~PxVehicleComponent() {}
|
||||
|
||||
/**
|
||||
\brief Update function for a vehicle component.
|
||||
|
||||
\param[in] dt The timestep size to use for the update step.
|
||||
\param[in] context Vehicle simulation context holding global data or data that usually applies to a
|
||||
large group of vehicles.
|
||||
\return True if subsequent components in a sequence should get updated, false if the sequence should
|
||||
be aborted.
|
||||
|
||||
\see PxVehicleComponentSequence
|
||||
*/
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context) = 0;
|
||||
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
322
engine/third_party/physx/include/vehicle2/PxVehicleComponentSequence.h
vendored
Normal file
322
engine/third_party/physx/include/vehicle2/PxVehicleComponentSequence.h
vendored
Normal file
@@ -0,0 +1,322 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
#include "foundation/PxAssert.h"
|
||||
#include "foundation/PxErrors.h"
|
||||
#include "foundation/PxFoundation.h"
|
||||
#include "PxVehicleComponent.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
struct PxVehicleComponentSequenceLimits
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eMAX_NB_SUBGROUPS = 16,
|
||||
eMAX_NB_COMPONENTS = 64,
|
||||
eMAX_NB_SUBGROUPELEMENTS = eMAX_NB_SUBGROUPS + eMAX_NB_COMPONENTS
|
||||
};
|
||||
};
|
||||
|
||||
struct PxVehicleComponentSequence
|
||||
{
|
||||
enum
|
||||
{
|
||||
eINVALID_SUBSTEP_GROUP = 0xff
|
||||
};
|
||||
|
||||
PxVehicleComponentSequence()
|
||||
: mNbComponents(0), mNbSubgroups(1), mNbSubGroupElements(0), mActiveSubgroup(0)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Add a component to the sequence.
|
||||
|
||||
\param[in] component The component to add to the sequence.
|
||||
\return True on success, else false (for example due to component count limit being reached).
|
||||
*/
|
||||
PX_FORCE_INLINE bool add(PxVehicleComponent* component);
|
||||
|
||||
/**
|
||||
\brief Start a substepping group.
|
||||
\note All components added using #add() will be added to the new substepping group until either the group
|
||||
is marked as complete with a call to #endSubstepGroup() or a subsequent substepping group is started with
|
||||
a call to #beginSubstepGroup().
|
||||
\note Groups can be nested with stacked calls to #beginSubstepGroup().
|
||||
\note Each group opened by #beginSubstepGroup() must be closed with a complementary #endSubstepGroup() prior to calling #update().
|
||||
\param[in] nbSubSteps is the number of substeps for the group's sequence. This can be changed with a call to #setSubsteps().
|
||||
\return Handle for the substepping group on success, else eINVALID_SUBSTEP_GROUP
|
||||
\see setSubsteps()
|
||||
\see endSubstepGroup()
|
||||
*/
|
||||
PX_FORCE_INLINE PxU8 beginSubstepGroup(const PxU8 nbSubSteps = 1);
|
||||
|
||||
/**
|
||||
\brief End a substepping group
|
||||
\note The group most recently opened with #beginSubstepGroup() will be closed by this call.
|
||||
\see setSubsteps()
|
||||
\see beginSubstepGroup()
|
||||
*/
|
||||
PX_FORCE_INLINE void endSubstepGroup()
|
||||
{
|
||||
mActiveSubgroup = mSubGroups[mActiveSubgroup].parentGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Set the number of substeps to perform for a specific substepping group.
|
||||
\param[in] subGroupHandle specifies the substepping group
|
||||
\param[in] nbSteps is the number of times to invoke the sequence of components and groups in the specified substepping group.
|
||||
\see beginSubstepGroup()
|
||||
\see endSubstepGroup()
|
||||
*/
|
||||
void setSubsteps(const PxU8 subGroupHandle, const PxU8 nbSteps)
|
||||
{
|
||||
PX_ASSERT(subGroupHandle < mNbSubgroups);
|
||||
mSubGroups[subGroupHandle].nbSteps = nbSteps;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Update each component in the sequence.
|
||||
|
||||
\note If the update method of a component in the sequence returns false, the update process gets aborted.
|
||||
|
||||
\param[in] dt is the timestep of the update. The provided value has to be positive.
|
||||
\param[in] context specifies global quantities of the simulation such as gravitational acceleration.
|
||||
*/
|
||||
void update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_ASSERT(0 == mActiveSubgroup);
|
||||
|
||||
if (dt > 0.0f)
|
||||
{
|
||||
updateSubGroup(dt, context, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL,
|
||||
"PxVehicleComponentSequence::update: The timestep must be positive!");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
eINVALID_COMPONENT = 0xff,
|
||||
eINVALID_SUB_GROUP_ELEMENT = 0xff
|
||||
};
|
||||
|
||||
//Elements have the form of a linked list to allow traversal over a list of elements.
|
||||
//Each element is either a single component or a subgroup.
|
||||
struct SubGroupElement
|
||||
{
|
||||
SubGroupElement()
|
||||
: childGroup(eINVALID_SUBSTEP_GROUP),
|
||||
component(eINVALID_COMPONENT),
|
||||
nextElement(eINVALID_SUB_GROUP_ELEMENT)
|
||||
{
|
||||
}
|
||||
|
||||
PxU8 childGroup;
|
||||
PxU8 component;
|
||||
PxU8 nextElement;
|
||||
};
|
||||
|
||||
//A group is a linked list of elements to be processed in sequence.
|
||||
//Each group stores the first element in the sequence.
|
||||
//Each element in the sequence stores the next element in the sequence
|
||||
//to allow traversal over the list of elements in the group.
|
||||
struct Group
|
||||
{
|
||||
Group()
|
||||
: parentGroup(eINVALID_SUBSTEP_GROUP),
|
||||
firstElement(eINVALID_SUB_GROUP_ELEMENT),
|
||||
nbSteps(1)
|
||||
{
|
||||
}
|
||||
PxU8 parentGroup;
|
||||
PxU8 firstElement;
|
||||
PxU8 nbSteps;
|
||||
};
|
||||
|
||||
PxVehicleComponent* mComponents[PxVehicleComponentSequenceLimits::eMAX_NB_COMPONENTS];
|
||||
PxU8 mNbComponents;
|
||||
|
||||
Group mSubGroups[PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPS];
|
||||
PxU8 mNbSubgroups;
|
||||
|
||||
SubGroupElement mSubGroupElements[PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPELEMENTS];
|
||||
PxU8 mNbSubGroupElements;
|
||||
|
||||
PxU8 mActiveSubgroup;
|
||||
|
||||
bool updateSubGroup(const PxReal dt, const PxVehicleSimulationContext& context, const PxU8 groupId, const PxU8 parentSepMultiplier)
|
||||
{
|
||||
const PxU8 nbSteps = mSubGroups[groupId].nbSteps;
|
||||
const PxU8 stepMultiplier = parentSepMultiplier * nbSteps;
|
||||
const PxReal timestepForGroup = dt / PxReal(stepMultiplier);
|
||||
for (PxU8 k = 0; k < nbSteps; k++)
|
||||
{
|
||||
PxU8 nextElement = mSubGroups[groupId].firstElement;
|
||||
while (eINVALID_SUB_GROUP_ELEMENT != nextElement)
|
||||
{
|
||||
const SubGroupElement& e = mSubGroupElements[nextElement];
|
||||
PX_ASSERT(e.component != eINVALID_COMPONENT || e.childGroup != eINVALID_SUBSTEP_GROUP);
|
||||
if (eINVALID_COMPONENT != e.component)
|
||||
{
|
||||
PxVehicleComponent* c = mComponents[e.component];
|
||||
if (!c->update(timestepForGroup, context))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
PX_ASSERT(eINVALID_SUBSTEP_GROUP != e.childGroup);
|
||||
if (!updateSubGroup(dt, context, e.childGroup, stepMultiplier))
|
||||
return false;
|
||||
}
|
||||
nextElement = e.nextElement;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PxU8 getLastKnownElementInGroup(const PxU8 groupId) const
|
||||
{
|
||||
PxU8 currElement = mSubGroups[groupId].firstElement;
|
||||
PxU8 nextElement = mSubGroups[groupId].firstElement;
|
||||
while (nextElement != eINVALID_SUB_GROUP_ELEMENT)
|
||||
{
|
||||
currElement = nextElement;
|
||||
nextElement = mSubGroupElements[nextElement].nextElement;
|
||||
}
|
||||
return currElement;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
bool PxVehicleComponentSequence::add(PxVehicleComponent* c)
|
||||
{
|
||||
if (PxVehicleComponentSequenceLimits::eMAX_NB_COMPONENTS == mNbComponents)
|
||||
return false;
|
||||
if (PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPELEMENTS == mNbSubGroupElements)
|
||||
return false;
|
||||
|
||||
//Create a new element and point it at the component.
|
||||
SubGroupElement& nextElementInGroup = mSubGroupElements[mNbSubGroupElements];
|
||||
nextElementInGroup.childGroup = eINVALID_SUBSTEP_GROUP;
|
||||
nextElementInGroup.component = mNbComponents;
|
||||
nextElementInGroup.nextElement = eINVALID_SUB_GROUP_ELEMENT;
|
||||
|
||||
if (eINVALID_SUB_GROUP_ELEMENT == mSubGroups[mActiveSubgroup].firstElement)
|
||||
{
|
||||
//The group is empty so add the first element to it.
|
||||
//Point the group at the new element because this will
|
||||
//be the first element in the group.
|
||||
mSubGroups[mActiveSubgroup].firstElement = mNbSubGroupElements;
|
||||
}
|
||||
else
|
||||
{
|
||||
//We are extending the sequence of element of the group.
|
||||
//Add the new element to the end of the group's sequence.
|
||||
mSubGroupElements[getLastKnownElementInGroup(mActiveSubgroup)].nextElement = mNbSubGroupElements;
|
||||
}
|
||||
|
||||
//Increment the number of elements.
|
||||
mNbSubGroupElements++;
|
||||
|
||||
//Record the component and increment the number of components.
|
||||
mComponents[mNbComponents] = c;
|
||||
mNbComponents++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PxU8 PxVehicleComponentSequence::beginSubstepGroup(const PxU8 nbSubSteps)
|
||||
{
|
||||
if (mNbSubgroups == PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPS)
|
||||
return eINVALID_SUBSTEP_GROUP;
|
||||
if (mNbSubGroupElements == PxVehicleComponentSequenceLimits::eMAX_NB_SUBGROUPELEMENTS)
|
||||
return eINVALID_SUBSTEP_GROUP;
|
||||
|
||||
//We have a parent and child group relationship.
|
||||
const PxU8 parentGroup = mActiveSubgroup;
|
||||
const PxU8 childGroup = mNbSubgroups;
|
||||
|
||||
//Set up the child group.
|
||||
mSubGroups[childGroup].parentGroup = parentGroup;
|
||||
mSubGroups[childGroup].firstElement = eINVALID_SUB_GROUP_ELEMENT;
|
||||
mSubGroups[childGroup].nbSteps = nbSubSteps;
|
||||
|
||||
//Create a new element to add to the parent group and point it at the child group.
|
||||
SubGroupElement& nextElementIInGroup = mSubGroupElements[mNbSubGroupElements];
|
||||
nextElementIInGroup.childGroup = childGroup;
|
||||
nextElementIInGroup.nextElement = eINVALID_SUB_GROUP_ELEMENT;
|
||||
nextElementIInGroup.component = eINVALID_COMPONENT;
|
||||
|
||||
//Add the new element to the parent group.
|
||||
if (eINVALID_SUB_GROUP_ELEMENT == mSubGroups[parentGroup].firstElement)
|
||||
{
|
||||
//The parent group is empty so add the first element to it.
|
||||
//Point the parent group at the new element because this will
|
||||
//be the first element in the group.
|
||||
mSubGroups[parentGroup].firstElement = mNbSubGroupElements;
|
||||
}
|
||||
else
|
||||
{
|
||||
//We are extending the sequence of elements of the parent group.
|
||||
//Add the new element to the end of the group's sequence.
|
||||
mSubGroupElements[getLastKnownElementInGroup(parentGroup)].nextElement = mNbSubGroupElements;
|
||||
}
|
||||
|
||||
//Push the active group.
|
||||
//All subsequent operations will now address the child group and we push or pop the group.
|
||||
mActiveSubgroup = childGroup;
|
||||
|
||||
//Increment the number of elements.
|
||||
mNbSubGroupElements++;
|
||||
|
||||
//Increment the number of groups.
|
||||
mNbSubgroups++;
|
||||
|
||||
//Return the group id.
|
||||
return mActiveSubgroup;
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
195
engine/third_party/physx/include/vehicle2/PxVehicleFunctions.h
vendored
Normal file
195
engine/third_party/physx/include/vehicle2/PxVehicleFunctions.h
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxMat33.h"
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "PxRigidBody.h"
|
||||
#include "PxVehicleParams.h"
|
||||
#include "roadGeometry/PxVehicleRoadGeometryState.h"
|
||||
#include "rigidBody/PxVehicleRigidBodyStates.h"
|
||||
#include "physxRoadGeometry/PxVehiclePhysXRoadGeometryState.h"
|
||||
#include "physxActor/PxVehiclePhysXActorStates.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
PX_FORCE_INLINE PxVec3 PxVehicleTransformFrameToFrame
|
||||
(const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVec3& v)
|
||||
{
|
||||
PxVec3 result = v;
|
||||
if ((srcFrame.lngAxis != trgFrame.lngAxis) || (srcFrame.latAxis != trgFrame.latAxis) || (srcFrame.vrtAxis != trgFrame.vrtAxis))
|
||||
{
|
||||
const PxMat33 a = srcFrame.getFrame();
|
||||
const PxMat33 r = trgFrame.getFrame();
|
||||
result = (r * a.getTranspose() * v);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVec3 PxVehicleTransformFrameToFrame
|
||||
(const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame,
|
||||
const PxVehicleScale& srcScale, const PxVehicleScale& trgScale,
|
||||
const PxVec3& v)
|
||||
{
|
||||
PxVec3 result = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, v);
|
||||
if((srcScale.scale != trgScale.scale))
|
||||
result *= (trgScale.scale / srcScale.scale);
|
||||
return result;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxTransform PxVehicleTransformFrameToFrame
|
||||
(const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame,
|
||||
const PxVehicleScale& srcScale, const PxVehicleScale& trgScale,
|
||||
const PxTransform& v)
|
||||
{
|
||||
PxTransform result(PxVehicleTransformFrameToFrame(srcFrame, trgFrame, srcScale, trgScale, v.p), v.q);
|
||||
if ((srcFrame.lngAxis != trgFrame.lngAxis) || (srcFrame.latAxis != trgFrame.latAxis) || (srcFrame.vrtAxis != trgFrame.vrtAxis))
|
||||
{
|
||||
PxF32 angle;
|
||||
PxVec3 axis;
|
||||
v.q.toRadiansAndUnitAxis(angle, axis);
|
||||
result.q = PxQuat(angle, PxVehicleTransformFrameToFrame(srcFrame, trgFrame, axis));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVec3 PxVehicleComputeTranslation(const PxVehicleFrame& frame, const PxReal lng, const PxReal lat, const PxReal vrt)
|
||||
{
|
||||
const PxVec3 v = frame.getFrame()*PxVec3(lng, lat, vrt);
|
||||
return v;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxQuat PxVehicleComputeRotation(const PxVehicleFrame& frame, const PxReal roll, const PxReal pitch, const PxReal yaw)
|
||||
{
|
||||
const PxMat33 m = frame.getFrame();
|
||||
const PxVec3& lngAxis = m.column0;
|
||||
const PxVec3& latAxis = m.column1;
|
||||
const PxVec3& vrtAxis = m.column2;
|
||||
const PxQuat quatPitch(pitch, latAxis);
|
||||
const PxQuat quatRoll(roll, lngAxis);
|
||||
const PxQuat quatYaw(yaw, vrtAxis);
|
||||
const PxQuat result = quatYaw * quatRoll * quatPitch;
|
||||
return result;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxF32 PxVehicleComputeSign(const PxReal f)
|
||||
{
|
||||
return physx::intrinsics::fsel(f, physx::intrinsics::fsel(-f, 0.0f, 1.0f), -1.0f);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Shift the origin of a vehicle by the specified vector.
|
||||
|
||||
Call this method to adjust the internal data structures of vehicles to reflect the shifted origin location
|
||||
(the shift vector will get subtracted from all world space spatial data).
|
||||
|
||||
\param[in] axleDesc is a description of the wheels on the vehicle.
|
||||
\param[in] shift is the translation vector used to shift the origin.
|
||||
\param[in] rigidBodyState stores the current position of the vehicle
|
||||
\param[in] roadGeometryStates stores the hit plane under each wheel.
|
||||
\param[in] physxActor stores the PxRigidActor that is the vehicle's PhysX representation.
|
||||
\param[in] physxQueryStates stores the hit point of the most recent execution of PxVehiclePhysXRoadGeometryQueryUpdate() for each wheel.
|
||||
\note It is the user's responsibility to keep track of the summed total origin shift and adjust all input/output to/from the vehicle accordingly.
|
||||
\note This call will not automatically shift the PhysX scene and its objects. PxScene::shiftOrigin() must be called separately to keep the systems in sync.
|
||||
\note If there is no associated PxRigidActor then set physxActor to NULL.
|
||||
\note If there is an associated PxRigidActor and it is already in a PxScene then the complementary call to PxScene::shiftOrigin() will take care of
|
||||
shifting the associated PxRigidActor. This being the case, set physxActor to NULL. physxActor should be a non-NULL pointer only when there is an
|
||||
associated PxRigidActor and it is not part of a PxScene. This can occur if the associated PxRigidActor is updated using PhysX immediate mode.
|
||||
\note If scene queries are independent of PhysX geometry then set queryStates to NULL.
|
||||
*/
|
||||
PX_FORCE_INLINE void PxVehicleShiftOrigin
|
||||
(const PxVehicleAxleDescription& axleDesc, const PxVec3& shift,
|
||||
PxVehicleRigidBodyState& rigidBodyState, PxVehicleRoadGeometryState* roadGeometryStates,
|
||||
PxVehiclePhysXActor* physxActor = NULL, PxVehiclePhysXRoadGeometryQueryState* physxQueryStates = NULL)
|
||||
{
|
||||
//Adjust the vehicle's internal pose.
|
||||
rigidBodyState.pose.p -= shift;
|
||||
|
||||
//Optionally adjust the PxRigidActor pose.
|
||||
if (physxActor && !physxActor->rigidBody->getScene())
|
||||
{
|
||||
const PxTransform oldPose = physxActor->rigidBody->getGlobalPose();
|
||||
const PxTransform newPose(oldPose.p - shift, oldPose.q);
|
||||
physxActor->rigidBody->setGlobalPose(newPose);
|
||||
}
|
||||
|
||||
for (PxU32 i = 0; i < axleDesc.nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDesc.wheelIdsInAxleOrder[i];
|
||||
|
||||
//Optionally adjust the hit position.
|
||||
if (physxQueryStates && physxQueryStates[wheelId].actor)
|
||||
physxQueryStates[wheelId].hitPosition -= shift;
|
||||
|
||||
//Adjust the hit plane.
|
||||
if (roadGeometryStates[wheelId].hitState)
|
||||
{
|
||||
const PxPlane plane = roadGeometryStates[wheelId].plane;
|
||||
PxU32 largestNormalComponentAxis = 0;
|
||||
PxReal largestNormalComponent = 0.0f;
|
||||
const PxF32 normalComponents[3] = { plane.n.x, plane.n.y, plane.n.z };
|
||||
for (PxU32 k = 0; k < 3; k++)
|
||||
{
|
||||
if (PxAbs(normalComponents[k]) > largestNormalComponent)
|
||||
{
|
||||
largestNormalComponent = PxAbs(normalComponents[k]);
|
||||
largestNormalComponentAxis = k;
|
||||
}
|
||||
}
|
||||
PxVec3 pointInPlane(PxZero);
|
||||
switch (largestNormalComponentAxis)
|
||||
{
|
||||
case 0:
|
||||
pointInPlane.x = -plane.d / plane.n.x;
|
||||
break;
|
||||
case 1:
|
||||
pointInPlane.y = -plane.d / plane.n.y;
|
||||
break;
|
||||
case 2:
|
||||
pointInPlane.z = -plane.d / plane.n.z;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
roadGeometryStates[wheelId].plane.d = -plane.n.dot(pointInPlane - shift);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
53
engine/third_party/physx/include/vehicle2/PxVehicleLimits.h
vendored
Normal file
53
engine/third_party/physx/include/vehicle2/PxVehicleLimits.h
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
struct PxVehicleLimits
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eMAX_NB_WHEELS = 20,
|
||||
eMAX_NB_AXLES = eMAX_NB_WHEELS
|
||||
};
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
|
||||
233
engine/third_party/physx/include/vehicle2/PxVehicleMaths.h
vendored
Normal file
233
engine/third_party/physx/include/vehicle2/PxVehicleMaths.h
vendored
Normal file
@@ -0,0 +1,233 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
|
||||
#include "PxVehicleLimits.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxVehicleVectorN
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
eMAX_SIZE = PxVehicleLimits::eMAX_NB_WHEELS + 3
|
||||
};
|
||||
|
||||
PxVehicleVectorN(const PxU32 size)
|
||||
: mSize(size)
|
||||
{
|
||||
PX_ASSERT(mSize <= PxVehicleVectorN::eMAX_SIZE);
|
||||
PxMemZero(mValues, sizeof(PxReal)*PxVehicleVectorN::eMAX_SIZE);
|
||||
}
|
||||
|
||||
~PxVehicleVectorN()
|
||||
{
|
||||
}
|
||||
|
||||
PxVehicleVectorN(const PxVehicleVectorN& src)
|
||||
{
|
||||
for (PxU32 i = 0; i < src.mSize; i++)
|
||||
{
|
||||
mValues[i] = src.mValues[i];
|
||||
}
|
||||
mSize = src.mSize;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVehicleVectorN& operator=(const PxVehicleVectorN& src)
|
||||
{
|
||||
for (PxU32 i = 0; i < src.mSize; i++)
|
||||
{
|
||||
mValues[i] = src.mValues[i];
|
||||
}
|
||||
mSize = src.mSize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxReal& operator[] (const PxU32 i)
|
||||
{
|
||||
PX_ASSERT(i < mSize);
|
||||
return (mValues[i]);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE const PxReal& operator[] (const PxU32 i) const
|
||||
{
|
||||
//PX_ASSERT(i < mSize);
|
||||
return (mValues[i]);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxU32 getSize() const { return mSize; }
|
||||
|
||||
private:
|
||||
|
||||
PxReal mValues[PxVehicleVectorN::eMAX_SIZE];
|
||||
PxU32 mSize;
|
||||
};
|
||||
|
||||
class PxVehicleMatrixNN
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleMatrixNN()
|
||||
: mSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
PxVehicleMatrixNN(const PxU32 size)
|
||||
: mSize(size)
|
||||
{
|
||||
PX_ASSERT(mSize <= PxVehicleVectorN::eMAX_SIZE);
|
||||
PxMemZero(mValues, sizeof(PxReal)*PxVehicleVectorN::eMAX_SIZE*PxVehicleVectorN::eMAX_SIZE);
|
||||
}
|
||||
|
||||
PxVehicleMatrixNN(const PxVehicleMatrixNN& src)
|
||||
{
|
||||
for (PxU32 i = 0; i < src.mSize; i++)
|
||||
{
|
||||
for (PxU32 j = 0; j < src.mSize; j++)
|
||||
{
|
||||
mValues[i][j] = src.mValues[i][j];
|
||||
}
|
||||
}
|
||||
mSize = src.mSize;
|
||||
}
|
||||
|
||||
~PxVehicleMatrixNN()
|
||||
{
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVehicleMatrixNN& operator=(const PxVehicleMatrixNN& src)
|
||||
{
|
||||
for (PxU32 i = 0; i < src.mSize; i++)
|
||||
{
|
||||
for (PxU32 j = 0; j < src.mSize; j++)
|
||||
{
|
||||
mValues[i][j] = src.mValues[i][j];
|
||||
}
|
||||
}
|
||||
mSize = src.mSize;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxReal get(const PxU32 i, const PxU32 j) const
|
||||
{
|
||||
PX_ASSERT(i < mSize);
|
||||
PX_ASSERT(j < mSize);
|
||||
return mValues[i][j];
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE void set(const PxU32 i, const PxU32 j, const PxReal val)
|
||||
{
|
||||
PX_ASSERT(i < mSize);
|
||||
PX_ASSERT(j < mSize);
|
||||
mValues[i][j] = val;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxU32 getSize() const { return mSize; }
|
||||
|
||||
PX_FORCE_INLINE void setSize(const PxU32 size)
|
||||
{
|
||||
PX_ASSERT(size <= PxVehicleVectorN::eMAX_SIZE);
|
||||
mSize = size;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
PxReal mValues[PxVehicleVectorN::eMAX_SIZE][PxVehicleVectorN::eMAX_SIZE];
|
||||
PxU32 mSize;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
LUPQ decomposition
|
||||
|
||||
Based upon "Outer Product LU with Complete Pivoting," from Matrix Computations (4th Edition), Golub and Van Loan
|
||||
|
||||
Solve A*x = b using:
|
||||
|
||||
MatrixNNLUSolver solver;
|
||||
solver.decomposeLU(A);
|
||||
solver.solve(b, x);
|
||||
*/
|
||||
class PxVehicleMatrixNNLUSolver
|
||||
{
|
||||
private:
|
||||
|
||||
PxVehicleMatrixNN mLU;
|
||||
PxU32 mP[PxVehicleVectorN::eMAX_SIZE - 1]; // Row permutation
|
||||
PxU32 mQ[PxVehicleVectorN::eMAX_SIZE - 1]; // Column permutation
|
||||
PxReal mDetM;
|
||||
|
||||
public:
|
||||
|
||||
PxVehicleMatrixNNLUSolver() {}
|
||||
~PxVehicleMatrixNNLUSolver() {}
|
||||
|
||||
PxReal getDet() const { return mDetM; }
|
||||
|
||||
void decomposeLU(const PxVehicleMatrixNN& A);
|
||||
|
||||
//Given a matrix A and a vector b find x that satisfies Ax = b, where the matrix A is the matrix that was passed to #decomposeLU.
|
||||
//Returns true if the lu decomposition indicates that the matrix has an inverse and x was successfully computed.
|
||||
//Returns false if the lu decomposition resulted in zero determinant ie the matrix has no inverse and no solution exists for x.
|
||||
//Returns false if the size of either b or x doesn't match the size of the matrix passed to #decomposeLU.
|
||||
//If false is returned then each relevant element of x is set to zero.
|
||||
bool solve(const PxVehicleVectorN& b, PxVehicleVectorN& x) const;
|
||||
};
|
||||
|
||||
|
||||
class PxVehicleMatrixNGaussSeidelSolver
|
||||
{
|
||||
public:
|
||||
|
||||
void solve(const PxU32 maxIterations, const PxReal tolerance, const PxVehicleMatrixNN& A, const PxVehicleVectorN& b, PxVehicleVectorN& result) const;
|
||||
};
|
||||
|
||||
class PxVehicleMatrix33Solver
|
||||
{
|
||||
public:
|
||||
|
||||
bool solve(const PxVehicleMatrixNN& A_, const PxVehicleVectorN& b_, PxVehicleVectorN& result) const;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} //namespace vehicle2
|
||||
} //namespace physx
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
910
engine/third_party/physx/include/vehicle2/PxVehicleParams.h
vendored
Normal file
910
engine/third_party/physx/include/vehicle2/PxVehicleParams.h
vendored
Normal file
@@ -0,0 +1,910 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
#include "foundation/PxFoundation.h"
|
||||
#include "foundation/PxAssert.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxMat33.h"
|
||||
|
||||
#include "PxVehicleLimits.h"
|
||||
|
||||
class OmniPvdWriter;
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
class PxConvexMesh;
|
||||
class PxScene;
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleAxleDescription
|
||||
{
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleAxleDescription));
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Add an axle to the vehicle by specifying the number of wheels on the axle and an array of wheel ids specifying each wheel on the axle.
|
||||
\param[in] nbWheelsOnAxle is the number of wheels on the axle to be added.
|
||||
\param[in] wheelIdsOnAxle is an array of wheel ids specifying all the wheels on the axle to be added.
|
||||
*/
|
||||
void addAxle(const PxU32 nbWheelsOnAxle, const PxU32* const wheelIdsOnAxle)
|
||||
{
|
||||
PX_ASSERT((nbWheels + nbWheelsOnAxle) < PxVehicleLimits::eMAX_NB_WHEELS);
|
||||
PX_ASSERT(nbAxles < PxVehicleLimits::eMAX_NB_AXLES);
|
||||
nbWheelsPerAxle[nbAxles] = nbWheelsOnAxle;
|
||||
axleToWheelIds[nbAxles] = nbWheels;
|
||||
for (PxU32 i = 0; i < nbWheelsOnAxle; i++)
|
||||
{
|
||||
wheelIdsInAxleOrder[nbWheels + i] = wheelIdsOnAxle[i];
|
||||
}
|
||||
nbWheels += nbWheelsOnAxle;
|
||||
nbAxles++;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the number of axles on the vehicle.
|
||||
\return The number of axles.
|
||||
\see getNbWheelsOnAxle()
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getNbAxles() const
|
||||
{
|
||||
return nbAxles;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the number of wheels on the ith axle.
|
||||
\param[in] i specifies the axle to be queried for its wheel count.
|
||||
\return The number of wheels on the specified axle.
|
||||
\see getWheelOnAxle()
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getNbWheelsOnAxle(const PxU32 i) const
|
||||
{
|
||||
return nbWheelsPerAxle[i];
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the wheel id of the jth wheel on the ith axle.
|
||||
\param[in] j specifies that the wheel id to be returned is the jth wheel in the list of wheels on the specified axle.
|
||||
\param[in] i specifies the axle to be queried.
|
||||
\return The wheel id of the jth wheel on the ith axle.
|
||||
\see getNbWheelsOnAxle()
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getWheelOnAxle(const PxU32 j, const PxU32 i) const
|
||||
{
|
||||
return wheelIdsInAxleOrder[axleToWheelIds[i] + j];
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the number of wheels on the vehicle.
|
||||
\return The number of wheels.
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getNbWheels() const
|
||||
{
|
||||
return nbWheels;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the axle of a specified wheel.
|
||||
\param[in] wheelId is the wheel whose axle is to be queried.
|
||||
\return The axle of the specified wheel.
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getAxle(const PxU32 wheelId) const
|
||||
{
|
||||
for (PxU32 i = 0; i < getNbAxles(); i++)
|
||||
{
|
||||
for (PxU32 j = 0; j < getNbWheelsOnAxle(i); j++)
|
||||
{
|
||||
if (getWheelOnAxle(j, i) == wheelId)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(nbAxles > 0, "PxVehicleAxleDescription.nbAxles must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(nbWheels > 0, "PxVehicleAxleDescription.nbWheels must be greater than zero", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
PxU32 nbAxles; //!< The number of axles on the vehicle
|
||||
PxU32 nbWheelsPerAxle[PxVehicleLimits::eMAX_NB_AXLES]; //!< The number of wheels on each axle.
|
||||
PxU32 axleToWheelIds[PxVehicleLimits::eMAX_NB_AXLES]; //!< The list of wheel ids for the ith axle begins at wheelIdsInAxleOrder[axleToWheelIds[i]]
|
||||
|
||||
PxU32 wheelIdsInAxleOrder[PxVehicleLimits::eMAX_NB_WHEELS]; //!< The list of all wheel ids on the vehicle.
|
||||
PxU32 nbWheels; //!< The number of wheels on the vehicle.
|
||||
|
||||
|
||||
PX_COMPILE_TIME_ASSERT(PxVehicleLimits::eMAX_NB_AXLES == PxVehicleLimits::eMAX_NB_WHEELS);
|
||||
// It should be possible to support cases where each wheel is controlled individually and thus
|
||||
// having a wheel per axle for up to the max wheel count.
|
||||
};
|
||||
|
||||
|
||||
struct PxVehicleAxes
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
ePosX = 0, //!< The +x axis
|
||||
eNegX, //!< The -x axis
|
||||
ePosY, //!< The +y axis
|
||||
eNegY, //!< The -y axis
|
||||
ePosZ, //!< The +z axis
|
||||
eNegZ, //!< The -z axis
|
||||
eMAX_NB_AXES
|
||||
};
|
||||
};
|
||||
|
||||
struct PxVehicleFrame
|
||||
{
|
||||
PxVehicleAxes::Enum lngAxis; //!< The axis defining the longitudinal (forward) direction of the vehicle.
|
||||
PxVehicleAxes::Enum latAxis; //!< The axis defining the lateral (side) direction of the vehicle.
|
||||
PxVehicleAxes::Enum vrtAxis; //!< The axis defining the vertical (up) direction of the vehicle.
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
lngAxis = PxVehicleAxes::ePosX;
|
||||
latAxis = PxVehicleAxes::ePosY;
|
||||
vrtAxis = PxVehicleAxes::ePosZ;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxMat33 getFrame() const
|
||||
{
|
||||
const PxVec3 basisDirs[6] = { PxVec3(1,0,0), PxVec3(-1,0,0), PxVec3(0,1,0), PxVec3(0,-1,0), PxVec3(0,0,1), PxVec3(0,0,-1) };
|
||||
const PxMat33 mat33(basisDirs[lngAxis], basisDirs[latAxis], basisDirs[vrtAxis]);
|
||||
return mat33;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVec3 getLngAxis() const
|
||||
{
|
||||
const PxVec3 basisDirs[6] = { PxVec3(1,0,0), PxVec3(-1,0,0), PxVec3(0,1,0), PxVec3(0,-1,0), PxVec3(0,0,1), PxVec3(0,0,-1) };
|
||||
return basisDirs[lngAxis];
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVec3 getLatAxis() const
|
||||
{
|
||||
const PxVec3 basisDirs[6] = { PxVec3(1,0,0), PxVec3(-1,0,0), PxVec3(0,1,0), PxVec3(0,-1,0), PxVec3(0,0,1), PxVec3(0,0,-1) };
|
||||
return basisDirs[latAxis];
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVec3 getVrtAxis() const
|
||||
{
|
||||
const PxVec3 basisDirs[6] = { PxVec3(1,0,0), PxVec3(-1,0,0), PxVec3(0,1,0), PxVec3(0,-1,0), PxVec3(0,0,1), PxVec3(0,0,-1) };
|
||||
return basisDirs[vrtAxis];
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(lngAxis < PxVehicleAxes::eMAX_NB_AXES, "PxVehicleFrame.lngAxis is invalid", false);
|
||||
PX_CHECK_AND_RETURN_VAL(latAxis < PxVehicleAxes::eMAX_NB_AXES, "PxVehicleFrame.latAxis is invalid", false);
|
||||
PX_CHECK_AND_RETURN_VAL(vrtAxis < PxVehicleAxes::eMAX_NB_AXES, "PxVehicleFrame.vrtAxis is invalid", false);
|
||||
const PxMat33 frame = getFrame();
|
||||
const PxQuat quat(frame);
|
||||
PX_CHECK_AND_RETURN_VAL(quat.isFinite() && quat.isUnit() && quat.isSane(), "PxVehicleFrame is not a legal frame", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct PxVehicleScale
|
||||
{
|
||||
PxReal scale; //!< The length scale used for the vehicle. For example, if 1.0 is considered meters, then 100.0 would be for centimeters.
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
scale = 1.0f;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(scale > 0.0f, "PxVehicleScale.scale must be greater than zero", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Helper struct to pass array type data to vehice components and functions.
|
||||
|
||||
The Vehicle SDK tries to give the user a certain freedom in how the parameters and
|
||||
states are stored. This helper struct presents a way to either use array of structs
|
||||
or array of pointers to structs to pass data into the provided vehicle components
|
||||
and functions.
|
||||
*/
|
||||
template<typename T>
|
||||
struct PxVehicleArrayData
|
||||
{
|
||||
enum DataFormat
|
||||
{
|
||||
eARRAY_OF_STRUCTS = 0, //!< The data is provided as an array of structs and stored in #arrayOfStructs.
|
||||
eARRAY_OF_POINTERS //!< The data is provided as an array of pointers and stored in #arrayOfPointers.
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Set the data as an array of structs.
|
||||
|
||||
\param[in] data The data as an array of structs.
|
||||
*/
|
||||
PX_FORCE_INLINE void setData(T* data)
|
||||
{
|
||||
arrayOfStructs = data;
|
||||
dataFormat = eARRAY_OF_STRUCTS;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Set the data as an array of pointers.
|
||||
|
||||
\param[in] data The data as an array of pointers.
|
||||
*/
|
||||
PX_FORCE_INLINE void setData(T*const* data)
|
||||
{
|
||||
arrayOfPointers = data;
|
||||
dataFormat = eARRAY_OF_POINTERS;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVehicleArrayData()
|
||||
{
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE explicit PxVehicleArrayData(T* data)
|
||||
{
|
||||
setData(data);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE explicit PxVehicleArrayData(T*const* data)
|
||||
{
|
||||
setData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Get the data entry at a given index.
|
||||
|
||||
\param[in] index The index to retrieve the data entry for.
|
||||
\return Reference to the requested data entry.
|
||||
*/
|
||||
PX_FORCE_INLINE T& getData(PxU32 index)
|
||||
{
|
||||
if (dataFormat == eARRAY_OF_STRUCTS)
|
||||
return arrayOfStructs[index];
|
||||
else
|
||||
return *arrayOfPointers[index];
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE T& operator[](PxU32 index)
|
||||
{
|
||||
return getData(index);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Get the data entry at a given index.
|
||||
|
||||
\param[in] index The index to retrieve the data entry for.
|
||||
\return Reference to the requested data entry.
|
||||
*/
|
||||
PX_FORCE_INLINE const T& getData(PxU32 index) const
|
||||
{
|
||||
if (dataFormat == eARRAY_OF_STRUCTS)
|
||||
return arrayOfStructs[index];
|
||||
else
|
||||
return *arrayOfPointers[index];
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE const T& operator[](PxU32 index) const
|
||||
{
|
||||
return getData(index);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Set as empty.
|
||||
*/
|
||||
PX_FORCE_INLINE void setEmpty()
|
||||
{
|
||||
arrayOfStructs = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Check if declared as empty.
|
||||
|
||||
\return True if empty, else false.
|
||||
*/
|
||||
PX_FORCE_INLINE bool isEmpty() const
|
||||
{
|
||||
return (arrayOfStructs == NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Get a reference to the array but read only.
|
||||
|
||||
\return Read only version of the data.
|
||||
*/
|
||||
PX_FORCE_INLINE const PxVehicleArrayData<const T>& getConst() const
|
||||
{
|
||||
return reinterpret_cast<const PxVehicleArrayData<const T>&>(*this);
|
||||
}
|
||||
|
||||
|
||||
union
|
||||
{
|
||||
T* arrayOfStructs; //!< The data stored as an array of structs.
|
||||
T*const* arrayOfPointers; //!< The data stored as an array of pointers.
|
||||
};
|
||||
PxU8 dataFormat;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct PxVehicleSizedArrayData : public PxVehicleArrayData<T>
|
||||
{
|
||||
/**
|
||||
\brief Set the data as an array of structs and set the number of data entries.
|
||||
|
||||
\param[in] data The data as an array of structs.
|
||||
\param[in] count The number of entries in the data array.
|
||||
*/
|
||||
PX_FORCE_INLINE void setDataAndCount(T* data, const PxU32 count)
|
||||
{
|
||||
PxVehicleArrayData<T>::setData(data);
|
||||
size = count;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Set the data as an array of pointers and set the number of data entries.
|
||||
|
||||
\param[in] data The data as an array of pointers.
|
||||
\param[in] count The number of entries in the data array.
|
||||
*/
|
||||
PX_FORCE_INLINE void setDataAndCount(T*const* data, const PxU32 count)
|
||||
{
|
||||
PxVehicleArrayData<T>::setData(data);
|
||||
size = count;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Set as empty.
|
||||
*/
|
||||
PX_FORCE_INLINE void setEmpty()
|
||||
{
|
||||
PxVehicleArrayData<T>::setEmpty();
|
||||
size = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Check if declared as empty.
|
||||
|
||||
\return True if empty, else false.
|
||||
*/
|
||||
PX_FORCE_INLINE bool isEmpty() const
|
||||
{
|
||||
return ((size == 0) || PxVehicleArrayData<T>::isEmpty());
|
||||
}
|
||||
|
||||
PxU32 size;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Determine whether the PhysX actor associated with a vehicle is to be updated with a velocity change or an acceleration change.
|
||||
A velocity change will be immediately reflected in linear and angular velocity queries against the vehicle. An acceleration change, on the other hand,
|
||||
will leave the linear and angular velocities unchanged until the next PhysX scene update has applied the acceleration update to the actor's linear and
|
||||
angular velocities.
|
||||
\see PxVehiclePhysXActorEndComponent
|
||||
\see PxVehicleWriteRigidBodyStateToPhysXActor
|
||||
*/
|
||||
struct PxVehiclePhysXActorUpdateMode
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eAPPLY_VELOCITY = 0,
|
||||
eAPPLY_ACCELERATION
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Tire slip values are computed using ratios with potential for divide-by-zero errors. PxVehicleTireSlipParams
|
||||
introduces a minimum value for the denominator of each of these ratios.
|
||||
*/
|
||||
struct PxVehicleTireSlipParams
|
||||
{
|
||||
/**
|
||||
\brief The lateral slip angle is typically computed as a function of the ratio of lateral and longitudinal speeds
|
||||
of the rigid body in the tire's frame. This leads to a divide-by-zero in the event that the longitudinal speed
|
||||
approaches zero. The parameter minLatSlipDenominator sets a minimum denominator for the ratio of speeds used to
|
||||
compute the lateral slip angle.
|
||||
\note Larger timesteps typically require larger values of minLatSlipDenominator.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> velocity = length / time
|
||||
*/
|
||||
PxReal minLatSlipDenominator;
|
||||
|
||||
/**
|
||||
\brief The longitudinal slip represents the difference between the longitudinal speed of the rigid body in the tire's
|
||||
frame and the linear speed arising from the rotation of the wheel. This is typically normalized using the reciprocal
|
||||
of the longitudinal speed of the rigid body in the tire's frame. This leads to a divide-by-zero in the event that the
|
||||
longitudinal speed approaches zero. The parameter minPassiveLongSlipDenominator sets a minimum denominator for the normalized
|
||||
longitudinal slip when the wheel experiences zero drive torque and zero brake torque and zero handbrake torque. The aim is
|
||||
to bring the vehicle to rest without experiencing wheel rotational speeds that oscillate around zero.
|
||||
\note The vehicle will come to rest more smoothly with larger values of minPassiveLongSlipDenominator, particularly
|
||||
with large timesteps that often lead to oscillation in wheel rotation speeds when the wheel rotation speed approaches
|
||||
zero.
|
||||
\note It is recommended that minActiveLongSlipDenominator < minPassiveLongSlipDenominator.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> velocity = length / time
|
||||
*/
|
||||
PxReal minPassiveLongSlipDenominator;
|
||||
|
||||
/**
|
||||
\brief The longitudinal slip represents the difference between the longitudinal speed of the rigid body in the tire's
|
||||
frame and the linear speed arising from the rotation of the wheel. This is typically normalized using the reciprocal
|
||||
of the longitudinal speed of the rigid body in the tire's frame. This leads to a divide-by-zero in the event that the
|
||||
longitudinal speed approaches zero. The parameter minActiveLongSlipDenominator sets a minimum denominator for the normalized
|
||||
longitudinal slip when the wheel experiences either a non-zero drive torque or a non-zero brake torque or a non-zero handbrake
|
||||
torque.
|
||||
\note Larger timesteps typically require larger values of minActiveLongSlipDenominator to avoid instabilities occurring when
|
||||
the vehicle is aggressively throttled from rest.
|
||||
\note It is recommended that minActiveLongSlipDenominator < minPassiveLongSlipDenominator.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> velocity = length / time
|
||||
*/
|
||||
PxReal minActiveLongSlipDenominator;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
minLatSlipDenominator = 1.0f;
|
||||
minActiveLongSlipDenominator = 0.1f;
|
||||
minPassiveLongSlipDenominator = 4.0f;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVehicleTireSlipParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PxVehicleTireSlipParams p = *this;
|
||||
const PxReal scaleRatio = trgScale.scale / srcScale.scale;
|
||||
p.minLatSlipDenominator *= scaleRatio;
|
||||
p.minPassiveLongSlipDenominator *= scaleRatio;
|
||||
p.minActiveLongSlipDenominator *= scaleRatio;
|
||||
return p;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(minLatSlipDenominator > 0.0f, "PxVehicleTireSlipParams.minLatSlipDenominator must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(minPassiveLongSlipDenominator > 0.0f, "PxVehicleTireSlipParams.minPassiveLongSlipDenominator must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(minActiveLongSlipDenominator > 0.0f, "PxVehicleTireSlipParams.minActiveLongSlipDenominator must be greater than zero", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Tires have two important directions for the purposes of tire force computation: longitudinal and lateral.
|
||||
*/
|
||||
struct PxVehicleTireDirectionModes
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eLONGITUDINAL = 0,
|
||||
eLATERAL,
|
||||
eMAX_NB_PLANAR_DIRECTIONS
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief The low speed regime often presents numerical difficulties for the tire model due to the potential for divide-by-zero errors.
|
||||
This particularly affects scenarios where the vehicle is slowing down due to damping and drag. In scenarios where there is no
|
||||
significant brake or drive torque, numerical error begins to dominate and it can be difficult to bring the vehicle to rest. A solution
|
||||
to this problem is to recognise that the vehicle is close to rest and to replace the tire forces with velocity constraints that will
|
||||
bring the vehicle to rest. This regime is known as the "sticky tire" regime. PxVehicleTireAxisStickyParams describes velocity and time
|
||||
thresholds that categorise the "sticky tire" regime. It also describes the rate at which the velocity constraints approach zero speed.
|
||||
*/
|
||||
struct PxVehicleTireAxisStickyParams
|
||||
{
|
||||
/**
|
||||
\brief A tire enters the "sticky tire" regime when it has been below a speed specified by #thresholdSpeed for a continuous time
|
||||
specified by #thresholdTime.
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> velocity = length / time
|
||||
*/
|
||||
PxReal thresholdSpeed;
|
||||
|
||||
/**
|
||||
\brief A tire enters the "sticky tire" regime when it has been below a speed specified by #thresholdSpeed for a continuous time
|
||||
specified by #thresholdTime.
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> time
|
||||
*/
|
||||
PxReal thresholdTime;
|
||||
|
||||
/**
|
||||
\brief The rate at which the velocity constraint approaches zero is controlled by the damping parameter.
|
||||
\note Larger values of damping lead to faster approaches to zero. Since the damping behaves like a
|
||||
stiffness with respect to the velocity, too large a value can lead to instabilities.
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> 1 / time (acceleration instead of force based damping, thus not mass/time)
|
||||
*/
|
||||
PxReal damping;
|
||||
|
||||
|
||||
PX_FORCE_INLINE PxVehicleTireAxisStickyParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PxVehicleTireAxisStickyParams p = *this;
|
||||
const PxReal scaleRatio = trgScale.scale / srcScale.scale;
|
||||
p.thresholdSpeed *= scaleRatio;
|
||||
return p;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(thresholdSpeed >= 0.0f, "PxVehicleTireAxisStickyParams.thresholdSpeed must be greater than or equal to zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(thresholdTime >= 0.0f, "PxVehicleTireAxisStickyParams.thresholdTime must be greater than or equal to zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(damping >= 0.0f, "PxVehicleTireAxisStickyParams.damping must be greater than or equal to zero", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief For each tire, the forces of the tire model may be replaced by velocity constraints when the tire enters the "sticky tire"
|
||||
regime. The "sticky tire" regime of the lateral and longitudinal directions of the tire are managed separately.
|
||||
*/
|
||||
struct PxVehicleTireStickyParams
|
||||
{
|
||||
/**
|
||||
The "sticky tire" regime of the lateral and longitudinal directions of the tire are managed separately and are individually
|
||||
parameterized.
|
||||
*/
|
||||
PxVehicleTireAxisStickyParams stickyParams[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS];
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].thresholdSpeed = 0.2f;
|
||||
stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].thresholdTime = 1.0f;
|
||||
stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].damping = 1.0f;
|
||||
stickyParams[PxVehicleTireDirectionModes::eLATERAL].thresholdSpeed = 0.2f;
|
||||
stickyParams[PxVehicleTireDirectionModes::eLATERAL].thresholdTime = 1.0f;
|
||||
stickyParams[PxVehicleTireDirectionModes::eLATERAL].damping = 0.1f;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVehicleTireStickyParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PxVehicleTireStickyParams p = *this;
|
||||
p.stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL] =
|
||||
stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
|
||||
p.stickyParams[PxVehicleTireDirectionModes::eLATERAL] =
|
||||
stickyParams[PxVehicleTireDirectionModes::eLATERAL].transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
|
||||
return p;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
if (!stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].isValid())
|
||||
return false;
|
||||
if (!stickyParams[PxVehicleTireDirectionModes::eLATERAL].isValid())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct PxVehicleSimulationContextType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eDEFAULT, //!< The simulation context inherits from PxVehicleSimulationContext
|
||||
ePHYSX //!< The simulation context inherits from PxVehiclePhysXSimulationContext
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Structure to support Omni PVD, the PhysX Visual Debugger.
|
||||
*/
|
||||
struct PxVehiclePvdContext
|
||||
{
|
||||
public:
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
attributeHandles = NULL;
|
||||
writer = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief The attribute handles used to reflect vehicle parameter and state data in omnipvd.
|
||||
\note A null value will result in no values being reflected in omnipvd.
|
||||
\note #attributeHandles and #writer both need to be non-NULL to reflect vehicle values in omnipvd.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdAttributesRelease
|
||||
\see PxVehiclePVDComponent
|
||||
*/
|
||||
const struct PxVehiclePvdAttributeHandles* attributeHandles;
|
||||
|
||||
/**
|
||||
\brief An instance of OmniPvdWriter used to write vehicle prameter and state data to omnipvd.
|
||||
\note A null value will result in no values being reflected in omnipvd.
|
||||
\note #attributeHandles and #writer both need to be non-NULL to reflect vehicle values in omnipvd.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdAttributesRelease
|
||||
\see PxVehiclePVDComponent
|
||||
*/
|
||||
OmniPvdWriter* writer;
|
||||
};
|
||||
|
||||
struct PxVehicleSimulationContext
|
||||
{
|
||||
PxVehicleSimulationContext()
|
||||
: type(PxVehicleSimulationContextType::eDEFAULT)
|
||||
{}
|
||||
|
||||
PxVec3 gravity;
|
||||
|
||||
PxVehicleFrame frame;
|
||||
PxVehicleScale scale;
|
||||
|
||||
//Tire
|
||||
PxVehicleTireSlipParams tireSlipParams;
|
||||
PxVehicleTireStickyParams tireStickyParams;
|
||||
|
||||
/**
|
||||
\brief Forward wheel speed below which the wheel rotation speed gets blended with the rolling speed.
|
||||
|
||||
The blended rotation speed is used to integrate the wheel rotation angle. At low forward wheel speed,
|
||||
the wheel rotation speed can get unstable (depending on the tire model used) and, for example, oscillate.
|
||||
|
||||
\note If brake or throttle is applied, there will be no blending.
|
||||
|
||||
<b>Unit:</b> velocity = length / time
|
||||
*/
|
||||
PxReal thresholdForwardSpeedForWheelAngleIntegration;
|
||||
|
||||
/**
|
||||
\brief Structure to support Omni PVD, the PhysX Visual Debugger.
|
||||
*/
|
||||
PxVehiclePvdContext pvdContext;
|
||||
|
||||
protected:
|
||||
PxVehicleSimulationContextType::Enum type;
|
||||
|
||||
|
||||
public:
|
||||
PX_FORCE_INLINE PxVehicleSimulationContextType::Enum getType() const { return type; }
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
frame.setToDefault();
|
||||
scale.setToDefault();
|
||||
|
||||
gravity = frame.getVrtAxis() * (-9.81f * scale.scale);
|
||||
|
||||
tireSlipParams.setToDefault();
|
||||
tireStickyParams.setToDefault();
|
||||
|
||||
thresholdForwardSpeedForWheelAngleIntegration = 5.0f * scale.scale;
|
||||
|
||||
pvdContext.setToDefault();
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVehicleSimulationContext transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PxVehicleSimulationContext c = *this;
|
||||
const PxReal scaleRatio = trgScale.scale / srcScale.scale;
|
||||
c.gravity = trgFrame.getFrame()*srcFrame.getFrame().getTranspose()*c.gravity;
|
||||
c.gravity *= scaleRatio;
|
||||
c.tireSlipParams = tireSlipParams.transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
|
||||
c.tireStickyParams = tireStickyParams.transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
|
||||
c.thresholdForwardSpeedForWheelAngleIntegration *= scaleRatio;
|
||||
c.frame = trgFrame;
|
||||
c.scale = trgScale;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
struct PxVehiclePhysXSimulationContext : public PxVehicleSimulationContext
|
||||
{
|
||||
PxVehiclePhysXSimulationContext()
|
||||
: PxVehicleSimulationContext()
|
||||
{
|
||||
type = PxVehicleSimulationContextType::ePHYSX;
|
||||
}
|
||||
|
||||
//Road geometry queries to find the plane under the wheel.
|
||||
const PxConvexMesh* physxUnitCylinderSweepMesh;
|
||||
const PxScene* physxScene;
|
||||
|
||||
//PhysX actor update
|
||||
PxVehiclePhysXActorUpdateMode::Enum physxActorUpdateMode;
|
||||
|
||||
/**
|
||||
\brief Wake counter value to set on the physx actor if a reset is required.
|
||||
|
||||
Certain vehicle states should keep a physx actor of a vehicle awake. This
|
||||
will be achieved by resetting the wake counter value if needed. The wake
|
||||
counter value is the minimum simulation time that a physx actor will stay
|
||||
awake.
|
||||
|
||||
<b>Unit:</b> time
|
||||
|
||||
\see physxActorWakeCounterThreshold PxVehiclePhysxActorKeepAwakeCheck
|
||||
*/
|
||||
PxReal physxActorWakeCounterResetValue;
|
||||
|
||||
/**
|
||||
\brief Threshold below which to check whether the physx actor wake counter
|
||||
should get reset.
|
||||
|
||||
<b>Unit:</b> time
|
||||
|
||||
\see physxActorWakeCounterResetValue PxVehiclePhysxActorKeepAwakeCheck
|
||||
*/
|
||||
PxReal physxActorWakeCounterThreshold;
|
||||
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxVehicleSimulationContext::setToDefault();
|
||||
|
||||
physxUnitCylinderSweepMesh = NULL;
|
||||
physxScene = NULL;
|
||||
|
||||
physxActorUpdateMode = PxVehiclePhysXActorUpdateMode::eAPPLY_VELOCITY;
|
||||
|
||||
physxActorWakeCounterResetValue = 20.0f * 0.02f; // 20 timesteps of size 0.02
|
||||
physxActorWakeCounterThreshold = 0.5f * physxActorWakeCounterResetValue;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVehiclePhysXSimulationContext transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PxVehiclePhysXSimulationContext r = *this;
|
||||
static_cast<PxVehicleSimulationContext&>(r) = PxVehicleSimulationContext::transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Express a function as a sequence of points {(x, y)} that form a piecewise polynomial.
|
||||
*/
|
||||
template <class T, unsigned int NB_ELEMENTS>
|
||||
class PxVehicleFixedSizeLookupTable
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleFixedSizeLookupTable()
|
||||
: nbDataPairs(0)
|
||||
{
|
||||
}
|
||||
|
||||
PxVehicleFixedSizeLookupTable(const PxVehicleFixedSizeLookupTable& src)
|
||||
{
|
||||
PxMemCopy(xVals, src.xVals, sizeof(PxReal)* src.nbDataPairs);
|
||||
PxMemCopy(yVals, src.yVals, sizeof(T)*src.nbDataPairs);
|
||||
nbDataPairs = src.nbDataPairs;
|
||||
}
|
||||
|
||||
~PxVehicleFixedSizeLookupTable()
|
||||
{
|
||||
}
|
||||
|
||||
PxVehicleFixedSizeLookupTable& operator=(const PxVehicleFixedSizeLookupTable& src)
|
||||
{
|
||||
PxMemCopy(xVals, src.xVals, sizeof(PxReal)*src.nbDataPairs);
|
||||
PxMemCopy(yVals, src.yVals, sizeof(T)*src.nbDataPairs);
|
||||
nbDataPairs = src.nbDataPairs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Add one more point to create one more polynomial segment of a piecewise polynomial.
|
||||
*/
|
||||
PX_FORCE_INLINE bool addPair(const PxReal x, const T y)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(nbDataPairs < NB_ELEMENTS, "PxVehicleFixedSizeLookupTable::addPair() exceeded fixed size capacity", false);
|
||||
xVals[nbDataPairs] = x;
|
||||
yVals[nbDataPairs] = y;
|
||||
nbDataPairs++;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Identify the segment of the piecewise polynomial that includes x and compute the corresponding y value by linearly interpolating the gradient of the segment.
|
||||
\param[in] x is the value on the x-axis of the piecewise polynomial.
|
||||
\return Returns the y value that corresponds to the input x.
|
||||
*/
|
||||
PX_FORCE_INLINE T interpolate(const PxReal x) const
|
||||
{
|
||||
if (0 == nbDataPairs)
|
||||
{
|
||||
return T(0);
|
||||
}
|
||||
|
||||
if (1 == nbDataPairs || x < xVals[0])
|
||||
{
|
||||
return yVals[0];
|
||||
}
|
||||
|
||||
PxReal x0 = xVals[0];
|
||||
T y0 = yVals[0];
|
||||
|
||||
for (PxU32 i = 1; i < nbDataPairs; i++)
|
||||
{
|
||||
const PxReal x1 = xVals[i];
|
||||
const T y1 = yVals[i];
|
||||
|
||||
if ((x >= x0) && (x < x1))
|
||||
{
|
||||
return (y0 + (y1 - y0) * (x - x0) / (x1 - x0));
|
||||
}
|
||||
|
||||
x0 = x1;
|
||||
y0 = y1;
|
||||
}
|
||||
|
||||
PX_ASSERT(x >= xVals[nbDataPairs - 1]);
|
||||
return yVals[nbDataPairs - 1];
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
PxMemSet(xVals, 0, NB_ELEMENTS * sizeof(PxReal));
|
||||
PxMemSet(yVals, 0, NB_ELEMENTS * sizeof(T));
|
||||
nbDataPairs = 0;
|
||||
}
|
||||
|
||||
PxReal xVals[NB_ELEMENTS];
|
||||
T yVals[NB_ELEMENTS];
|
||||
PxU32 nbDataPairs;
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
for (PxU32 i = 1; i < nbDataPairs; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(xVals[i] > xVals[i - 1], "PxVehicleFixedSizeLookupTable:: xVals[i+1] must be greater than xVals[i]", false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
75
engine/third_party/physx/include/vehicle2/braking/PxVehicleBrakingFunctions.h
vendored
Normal file
75
engine/third_party/physx/include/vehicle2/braking/PxVehicleBrakingFunctions.h
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
#include "foundation/PxMath.h"
|
||||
#include "PxVehicleBrakingParams.h"
|
||||
#include "../commands/PxVehicleCommandStates.h"
|
||||
#include "../commands/PxVehicleCommandHelpers.h"
|
||||
#include "../drivetrain/PxVehicleDrivetrainParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Compute the brake torque response to an array of brake commands.
|
||||
\param[in] brakeCommands is the array of input brake commands to be applied to the vehicle.
|
||||
\param[in] nbBrakeCommands is the number of input brake commands to be applied to the vehicle.
|
||||
\param[in] longitudinalSpeed is the longitudinal speed of the vehicle.
|
||||
\param[in] wheelId specifies the wheel that is to have its brake response computed.
|
||||
\param[in] brakeResponseParams specifies the per wheel brake torque response to each brake command as a nonlinear function of brake command and longitudinal speed.
|
||||
\param[out] brakeResponseState is the brake torque response to the input brake command.
|
||||
\note commands.brakes[i] and brakeResponseParams[i] are treated as pairs of brake command and brake command response.
|
||||
*/
|
||||
PX_FORCE_INLINE void PxVehicleBrakeCommandResponseUpdate
|
||||
(const PxReal* brakeCommands, const PxU32 nbBrakeCommands, const PxReal longitudinalSpeed,
|
||||
const PxU32 wheelId, const PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams>& brakeResponseParams,
|
||||
PxReal& brakeResponseState)
|
||||
{
|
||||
PX_CHECK_AND_RETURN(nbBrakeCommands <= brakeResponseParams.size, "PxVehicleBrakeCommandLinearUpdate: nbBrakes must be less than or equal to brakeResponseParams.size");
|
||||
PxReal sum = 0.0f;
|
||||
for (PxU32 i = 0; i < nbBrakeCommands; i++)
|
||||
{
|
||||
sum += PxVehicleNonLinearResponseCompute(brakeCommands[i], longitudinalSpeed, wheelId, brakeResponseParams[i]);
|
||||
}
|
||||
brakeResponseState = sum;
|
||||
}
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
82
engine/third_party/physx/include/vehicle2/braking/PxVehicleBrakingParams.h
vendored
Normal file
82
engine/third_party/physx/include/vehicle2/braking/PxVehicleBrakingParams.h
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxFoundation.h"
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
|
||||
#include "vehicle2/commands/PxVehicleCommandParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Distribute a brake response to the wheels of a vehicle.
|
||||
\note The brake torque of each wheel on the ith wheel is brakeCommand * maxResponse * wheelResponseMultipliers[i].
|
||||
\note A typical use case is to set maxResponse to be the vehicle's maximum achievable brake torque
|
||||
that occurs when the brake command is equal to 1.0. The array wheelResponseMultipliers[i] would then be used
|
||||
to specify the maximum achievable brake torque per wheel as a fractional multiplier of the vehicle's maximum achievable brake torque.
|
||||
*/
|
||||
struct PxVehicleBrakeCommandResponseParams : public PxVehicleCommandResponseParams
|
||||
{
|
||||
PX_FORCE_INLINE PxVehicleBrakeCommandResponseParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PxVehicleBrakeCommandResponseParams r = *this;
|
||||
const PxReal scale = trgScale.scale/srcScale.scale;
|
||||
r.maxResponse *= (scale*scale); //maxResponse is a torque!
|
||||
return r;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
|
||||
{
|
||||
if (!axleDesc.isValid())
|
||||
return false;
|
||||
PX_CHECK_AND_RETURN_VAL(maxResponse >= 0.0f, "PxVehicleBrakeCommandResponseParams.maxResponse must be greater than or equal to zero", false);
|
||||
for (PxU32 i = 0; i < axleDesc.nbWheels; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(wheelResponseMultipliers[axleDesc.wheelIdsInAxleOrder[i]] >= 0.0f, "PxVehicleBrakeCommandResponseParams.wheelResponseMultipliers[i] must be greater than or equal to zero.", false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
72
engine/third_party/physx/include/vehicle2/commands/PxVehicleCommandHelpers.h
vendored
Normal file
72
engine/third_party/physx/include/vehicle2/commands/PxVehicleCommandHelpers.h
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "PxVehicleCommandParams.h"
|
||||
#include "PxVehicleCommandStates.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Compute the linear response to a command.
|
||||
\param[in] command is a normalised command value.
|
||||
\param[in] wheelId specifies the wheel that is to respond to the command.
|
||||
\param[in] responseParams specifies the wheel responses for all wheels on a vehicle.
|
||||
\return The linear response of the specified wheel to the command.
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal PxVehicleLinearResponseCompute
|
||||
(const PxReal command, const PxU32 wheelId, const PxVehicleCommandResponseParams& responseParams)
|
||||
{
|
||||
return command*responseParams.maxResponse*responseParams.wheelResponseMultipliers[wheelId];
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the non-linear response to a command.
|
||||
\param[in] command is a normalised command value.
|
||||
\param[in] longitudinalSpeed is the longitudional speed of the vehicle.
|
||||
\param[in] wheelId specifies the wheel that is to respond to the command.
|
||||
\param[in] responseParams specifies the wheel responses for all wheels on a vehicle.
|
||||
\note responseParams is used to compute an interpolated normalized response to the combination of command and longitudinalSpeed.
|
||||
The interpolated normalized response is then used in place of the command as input to PxVehicleComputeLinearResponse().
|
||||
*/
|
||||
PxReal PxVehicleNonLinearResponseCompute
|
||||
(const PxReal command, const PxReal longitudinalSpeed, const PxU32 wheelId, const PxVehicleCommandResponseParams& responseParams);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
198
engine/third_party/physx/include/vehicle2/commands/PxVehicleCommandParams.h
vendored
Normal file
198
engine/third_party/physx/include/vehicle2/commands/PxVehicleCommandParams.h
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxFoundation.h"
|
||||
#include "vehicle2/PxVehicleLimits.h"
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief Each command value may be associated with a table specifying a normalized response as a function of longitudinal speed.
|
||||
Multiple instances of PxVehicleCommandValueResponseTable allow a normalized response to be authored as a multi-variate
|
||||
piecewise polynomial with normalized command response expressed as a nonlinear function of command value and speed.
|
||||
*/
|
||||
struct PxVehicleCommandValueResponseTable
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eMAX_NB_SPEED_RESPONSES = 64
|
||||
};
|
||||
|
||||
/**
|
||||
\brief The command value associated with the table of speed responses.
|
||||
*/
|
||||
PxReal commandValue;
|
||||
|
||||
/**
|
||||
\brief A lookup table specifying the normalised response to the specified command value as a function of longitudinal speed.
|
||||
\note Each entry in the speedResponses table must be of the form (speed, normalizedResponse).
|
||||
\note The longitudinal speeds in the table must form a strictly increasing series.
|
||||
\note The normalized responses must be in range [0, 1].
|
||||
*/
|
||||
PxVehicleFixedSizeLookupTable<PxReal, eMAX_NB_SPEED_RESPONSES> speedResponses;
|
||||
};
|
||||
|
||||
/**
|
||||
\note Brake, drive and steer response typically reduce at increased longitudinal speed. Moreover, response to a brake, throttle or steer command is typically
|
||||
nonlinear and may be subject to dead zones where response is constant with either zero or non-zero response. PxVehicleCommandNonLinearResponseParams allows
|
||||
command responses to be authored as multi-variate piecewise polynomials with normalized command response a function of command value and longitudinal speed.
|
||||
*/
|
||||
class PxVehicleCommandNonLinearResponseParams
|
||||
{
|
||||
public:
|
||||
|
||||
enum Enum
|
||||
{
|
||||
eMAX_NB_COMMAND_VALUES = 8
|
||||
};
|
||||
|
||||
PxVehicleCommandNonLinearResponseParams()
|
||||
: nbSpeedResponses(0),
|
||||
nbCommandValues(0)
|
||||
{
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
nbCommandValues = 0;
|
||||
nbSpeedResponses = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Add a table of normalised response vs speed and associated it with a specified command value.
|
||||
\note commandValueSpeedResponses must be authored as a series of strictly increasing speeds with form {speed, normalizedResponse}
|
||||
\note The responses added must form a series of strictly increasing command values.
|
||||
*/
|
||||
bool addResponse(const PxVehicleCommandValueResponseTable& commandValueSpeedResponses)
|
||||
{
|
||||
const PxReal commandValue = commandValueSpeedResponses.commandValue;
|
||||
const PxReal* speeds = commandValueSpeedResponses.speedResponses.xVals;
|
||||
const PxReal* responses = commandValueSpeedResponses.speedResponses.yVals;
|
||||
const PxU16 nb = PxU16(commandValueSpeedResponses.speedResponses.nbDataPairs);
|
||||
|
||||
PX_CHECK_AND_RETURN_VAL(commandValue >= 0.0f && commandValue <= 1.0f, "PxVehicleCommandAndResponseTable::commandValue must be in range [0, 1]", false);
|
||||
|
||||
PX_CHECK_AND_RETURN_VAL(nbCommandValues < eMAX_NB_COMMAND_VALUES, "PxVehicleNonLinearCommandResponse::addResponse - exceeded maximum number of command responses", false);
|
||||
|
||||
PX_CHECK_AND_RETURN_VAL(((nbSpeedResponses + nb) <= PxVehicleCommandValueResponseTable::eMAX_NB_SPEED_RESPONSES), "PxVehicleNonLinearCommandResponse::addResponse - exceeded maximum number of command responses", false);
|
||||
|
||||
PX_CHECK_AND_RETURN_VAL((0 == nbCommandValues) || (commandValue > commandValues[nbCommandValues - 1]), "PxVehicleNonLinearCommandResponse::addResponse - command must be part of a strictly increasing series", false);
|
||||
|
||||
PX_CHECK_AND_RETURN_VAL(nb > 0, "PxVehicleNonLinearCommandResponse::addResponse - each command response must have at least 1 point", false);
|
||||
|
||||
#if PX_CHECKED
|
||||
for (PxU32 i = 1; i < nb; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(speeds[i] > speeds[i - 1], "PxVehicleNonLinearCommandResponse::addResponse - speeds array must be a strictly increasing series", false);
|
||||
PX_CHECK_AND_RETURN_VAL(responses[i] >= 0.0f && responses[i] <= 1.0f , "PxVehicleNonLinearCommandResponse::addResponse - response must be in range [0, 1]", false);
|
||||
}
|
||||
#endif
|
||||
|
||||
commandValues[nbCommandValues] = commandValue;
|
||||
nbSpeedResponsesPerCommandValue[nbCommandValues] = nb;
|
||||
speedResponsesPerCommandValue[nbCommandValues] = nbSpeedResponses;
|
||||
PxMemCopy(speedResponses + 2 * nbSpeedResponses, speeds, sizeof(PxReal)*nb);
|
||||
PxMemCopy(speedResponses + 2 * nbSpeedResponses + nb, responses, sizeof(PxReal)*nb);
|
||||
nbCommandValues++;
|
||||
nbSpeedResponses += nb;
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief A ragged array of speeds and normalized responses.
|
||||
*/
|
||||
PxReal speedResponses[PxVehicleCommandValueResponseTable::eMAX_NB_SPEED_RESPONSES * 2];
|
||||
|
||||
/**
|
||||
\brief The number of speeds and normalized responses.
|
||||
*/
|
||||
PxU16 nbSpeedResponses;
|
||||
|
||||
/**
|
||||
\brief The table of speed responses for the ith command value begins at speedResponses[2*speedResponsesPerCommandValue[i]]
|
||||
*/
|
||||
PxU16 speedResponsesPerCommandValue[eMAX_NB_COMMAND_VALUES];
|
||||
|
||||
/**
|
||||
\brief The ith command value has N speed responses with N = nbSpeedRenponsesPerCommandValue[i].
|
||||
*/
|
||||
PxU16 nbSpeedResponsesPerCommandValue[eMAX_NB_COMMAND_VALUES];
|
||||
|
||||
/**
|
||||
\brief The command values.
|
||||
*/
|
||||
PxReal commandValues[eMAX_NB_COMMAND_VALUES];
|
||||
|
||||
/**
|
||||
\brief The number of command values.
|
||||
*/
|
||||
PxU16 nbCommandValues;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A description of the per wheel response to an input command.
|
||||
*/
|
||||
struct PxVehicleCommandResponseParams
|
||||
{
|
||||
/**
|
||||
\brief A nonlinear response to command value expressed as a lookup table of normalized response as a function of command value and longitudinal speed.
|
||||
\note The effect of the default state of nonlinearResponse is a linear response to command value that is independent of longitudinal speed.
|
||||
*/
|
||||
PxVehicleCommandNonLinearResponseParams nonlinearResponse;
|
||||
|
||||
/**
|
||||
\brief A description of the per wheel response multiplier to an input command.
|
||||
*/
|
||||
PxReal wheelResponseMultipliers[PxVehicleLimits::eMAX_NB_WHEELS];
|
||||
|
||||
/**
|
||||
\brief The maximum response that occurs when the wheel response multiplier has value 1.0 and nonlinearResponse is in the default state of linear response.
|
||||
*/
|
||||
PxF32 maxResponse;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
136
engine/third_party/physx/include/vehicle2/commands/PxVehicleCommandStates.h
vendored
Normal file
136
engine/third_party/physx/include/vehicle2/commands/PxVehicleCommandStates.h
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
#include "vehicle2/PxVehicleLimits.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief A description of the state of commands that are applied to the vehicle
|
||||
\note brakes[0] and brakes[1] may be used to distinguish brake and handbrake controls.
|
||||
*/
|
||||
struct PxVehicleCommandState
|
||||
{
|
||||
PxReal brakes[2]; //!< The instantaneous state of the brake controllers in range [0,1] with 1 denoting fully pressed and 0 fully depressed.
|
||||
PxU32 nbBrakes; //|< The number of brake commands.
|
||||
PxReal throttle; //!< The instantaneous state of the throttle controller in range [0,1] with 1 denoting fully pressed and 0 fully depressed.
|
||||
PxReal steer; //!< The instantaneous state of the steer controller in range [-1,1].
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleCommandState));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A description of the state of transmission-related commands that are applied to a vehicle with direct drive.
|
||||
*/
|
||||
struct PxVehicleDirectDriveTransmissionCommandState
|
||||
{
|
||||
/**
|
||||
\brief Direct drive vehicles only have reverse, neutral or forward gear.
|
||||
*/
|
||||
enum Enum
|
||||
{
|
||||
eREVERSE = 0,
|
||||
eNEUTRAL,
|
||||
eFORWARD
|
||||
};
|
||||
|
||||
Enum gear; //!< The desired gear of the input gear controller.
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleDirectDriveTransmissionCommandState));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A description of the state of transmission-related commands that are applied to a vehicle with engine drive.
|
||||
*/
|
||||
struct PxVehicleEngineDriveTransmissionCommandState
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
/**
|
||||
\brief Special gear value to denote the automatic shift mode (often referred to as DRIVE).
|
||||
|
||||
When using automatic transmission, setting this value as target gear will enable automatic
|
||||
gear shifts between first and highest gear. If the current gear is a reverse gear or
|
||||
the neutral gear, then this value will trigger a shift to first gear. If this value is
|
||||
used even though there is no automatic transmission available, the gear state will remain
|
||||
unchanged.
|
||||
*/
|
||||
eAUTOMATIC_GEAR = 0xff
|
||||
};
|
||||
|
||||
PxReal clutch; //!< The instantaneous state of the clutch controller in range [0,1] with 1 denoting fully pressed and 0 fully depressed.
|
||||
PxU32 targetGear; //!< The desired gear of the input gear controller.
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleEngineDriveTransmissionCommandState));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A description of the state of transmission-related commands that are applied to a vehicle with tank drive.
|
||||
*/
|
||||
struct PxVehicleTankDriveTransmissionCommandState : public PxVehicleEngineDriveTransmissionCommandState
|
||||
{
|
||||
/**
|
||||
\brief The wheels of each tank track are either all connected to thrusts[0] or all connected to thrusts[1].
|
||||
\note The thrust commands are used to divert torque from the engine to the wheels of the tank tracks controlled by each thrust.
|
||||
\note thrusts[0] and thrusts[1] are in range [-1,1] with the sign dictating whether the thrust will be applied positively or negatively with respect to the gearing ratio.
|
||||
*/
|
||||
PxReal thrusts[2];
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleTankDriveTransmissionCommandState));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
798
engine/third_party/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainComponents.h
vendored
Normal file
798
engine/third_party/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainComponents.h
vendored
Normal file
@@ -0,0 +1,798 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "vehicle2/PxVehicleFunctions.h"
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "vehicle2/PxVehicleComponent.h"
|
||||
|
||||
#include "vehicle2/braking/PxVehicleBrakingFunctions.h"
|
||||
#include "vehicle2/commands/PxVehicleCommandHelpers.h"
|
||||
#include "vehicle2/rigidBody/PxVehicleRigidBodyStates.h"
|
||||
#include "vehicle2/steering/PxVehicleSteeringFunctions.h"
|
||||
#include "vehicle2/steering/PxVehicleSteeringParams.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelStates.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelParams.h"
|
||||
#include "vehicle2/tire/PxVehicleTireStates.h"
|
||||
|
||||
#include "PxVehicleDrivetrainStates.h"
|
||||
#include "PxVehicleDrivetrainFunctions.h"
|
||||
|
||||
#include "common/PxProfileZone.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleBrakeCommandResponseParams;
|
||||
struct PxVehicleDirectDriveThrottleCommandResponseParams;
|
||||
|
||||
/**
|
||||
\brief Forward the applicable set of control values for a direct drive vehicle to a command response state for each
|
||||
applicable control value.
|
||||
\note The applicable control values are brake, handbrake, throttle and steer.
|
||||
\see PxVehicleDirectDriveActuationStateComponent
|
||||
\see PxVehicleDirectDrivetrainComponent
|
||||
\see PxVehicleBrakeCommandLinearUpdate
|
||||
\see PxVehicleDirectDriveThrottleLinearCommandUpdate
|
||||
\see PxVehicleSteerCommandLinearUpdate
|
||||
\see PxVehicleAckermannSteerUpdate
|
||||
*/
|
||||
class PxVehicleDirectDriveCommandResponseComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleDirectDriveCommandResponseComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleDirectDriveCommandResponseComponent() {}
|
||||
|
||||
/**
|
||||
\brief Provide vehicle data items for this component.
|
||||
|
||||
\param[out] axleDescription identifies the wheels on each axle.
|
||||
\param[out] brakeResponseParams An array of brake response parameters with a brake response for each brake command.
|
||||
\param[out] throttleResponseParams The throttle response parameters.
|
||||
\param[out] steerResponseParams The steer response parameters.
|
||||
\param[out] ackermannParams The parameters defining Ackermann steering. NULL if no Ackermann steering is desired.
|
||||
\param[out] commands The throttle, brake, steer etc. command states.
|
||||
\param[out] transmissionCommands The transmission command state describing the current gear.
|
||||
\param[out] rigidBodyState The state of the vehicle's rigid body.
|
||||
\param[out] brakeResponseStates The resulting brake response states given the command input and brake response parameters.
|
||||
\param[out] throttleResponseStates The resulting throttle response states given the command input and throttle response parameters.
|
||||
\param[out] steerResponseStates The resulting steer response states given the command input, steer response and (optionally) Ackermann parameters.
|
||||
*/
|
||||
virtual void getDataForDirectDriveCommandResponseComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams>& brakeResponseParams,
|
||||
const PxVehicleDirectDriveThrottleCommandResponseParams*& throttleResponseParams,
|
||||
const PxVehicleSteerCommandResponseParams*& steerResponseParams,
|
||||
PxVehicleSizedArrayData<const PxVehicleAckermannParams>& ackermannParams,
|
||||
const PxVehicleCommandState*& commands, const PxVehicleDirectDriveTransmissionCommandState*& transmissionCommands,
|
||||
const PxVehicleRigidBodyState*& rigidBodyState,
|
||||
PxVehicleArrayData<PxReal>& brakeResponseStates,
|
||||
PxVehicleArrayData<PxReal>& throttleResponseStates,
|
||||
PxVehicleArrayData<PxReal>& steerResponseStates) = 0;
|
||||
|
||||
/**
|
||||
\brief Compute a per wheel response to the input brake/handbrake/throttle/steer commands
|
||||
and determine if there is an intention to accelerate the vehicle.
|
||||
*/
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(dt);
|
||||
PX_UNUSED(context);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehicleDirectDriveCommandResponseComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams> brakeResponseParams;
|
||||
const PxVehicleDirectDriveThrottleCommandResponseParams* throttleResponseParams;
|
||||
const PxVehicleSteerCommandResponseParams* steerResponseParams;
|
||||
PxVehicleSizedArrayData<const PxVehicleAckermannParams> ackermannParams;
|
||||
const PxVehicleCommandState* commands;
|
||||
const PxVehicleDirectDriveTransmissionCommandState* transmissionCommands;
|
||||
const PxVehicleRigidBodyState* rigidBodyState;
|
||||
PxVehicleArrayData<PxReal> brakeResponseStates;
|
||||
PxVehicleArrayData<PxReal> throttleResponseStates;
|
||||
PxVehicleArrayData<PxReal> steerResponseStates;
|
||||
|
||||
getDataForDirectDriveCommandResponseComponent(axleDescription,
|
||||
brakeResponseParams, throttleResponseParams, steerResponseParams, ackermannParams,
|
||||
commands, transmissionCommands,
|
||||
rigidBodyState,
|
||||
brakeResponseStates, throttleResponseStates, steerResponseStates);
|
||||
|
||||
const PxReal longitudinalSpeed = rigidBodyState->getLongitudinalSpeed(context.frame);
|
||||
|
||||
for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
|
||||
PxVehicleBrakeCommandResponseUpdate(
|
||||
commands->brakes, commands->nbBrakes, longitudinalSpeed,
|
||||
wheelId, brakeResponseParams,
|
||||
brakeResponseStates[wheelId]);
|
||||
|
||||
PxVehicleDirectDriveThrottleCommandResponseUpdate(
|
||||
commands->throttle, *transmissionCommands, longitudinalSpeed,
|
||||
wheelId, *throttleResponseParams,
|
||||
throttleResponseStates[wheelId]);
|
||||
|
||||
PxVehicleSteerCommandResponseUpdate(
|
||||
commands->steer, longitudinalSpeed,
|
||||
wheelId, *steerResponseParams,
|
||||
steerResponseStates[wheelId]);
|
||||
}
|
||||
if (ackermannParams.size > 0)
|
||||
PxVehicleAckermannSteerUpdate(
|
||||
commands->steer,
|
||||
*steerResponseParams, ackermannParams,
|
||||
steerResponseStates);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief Determine the actuation state for each wheel of a direct drive vehicle.
|
||||
\note The actuation state for each wheel contains a binary record of whether brake and drive torque are to be applied to the wheel.
|
||||
\see PxVehicleDirectDriveCommandResponseComponent
|
||||
\see PxVehicleDirectDrivetrainComponent
|
||||
\see PxVehicleDirectDriveActuationStateUpdate
|
||||
*/
|
||||
class PxVehicleDirectDriveActuationStateComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleDirectDriveActuationStateComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleDirectDriveActuationStateComponent() {}
|
||||
|
||||
|
||||
/**
|
||||
\brief Provide vehicle data items for this component.
|
||||
|
||||
\param[out] axleDescription identifies the wheels on each axle.
|
||||
\param[out] brakeResponseStates The brake response states.
|
||||
\param[out] throttleResponseStates The throttle response states.
|
||||
\param[out] actuationStates The actuation states.
|
||||
*/
|
||||
virtual void getDataForDirectDriveActuationStateComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
PxVehicleArrayData<const PxReal>& brakeResponseStates,
|
||||
PxVehicleArrayData<const PxReal>& throttleResponseStates,
|
||||
PxVehicleArrayData<PxVehicleWheelActuationState>& actuationStates) = 0;
|
||||
|
||||
/**
|
||||
\brief Compute the actuation state for each wheel given the brake, handbrake and throttle states.
|
||||
\*/
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(dt);
|
||||
PX_UNUSED(context);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehicleDirectDriveActuationStateComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
PxVehicleArrayData<const PxReal> brakeResponseStates;
|
||||
PxVehicleArrayData<const PxReal> throttleResponseStates;
|
||||
PxVehicleArrayData<PxVehicleWheelActuationState> actuationStates;
|
||||
|
||||
getDataForDirectDriveActuationStateComponent(
|
||||
axleDescription,
|
||||
brakeResponseStates, throttleResponseStates,
|
||||
actuationStates);
|
||||
|
||||
for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
PxVehicleDirectDriveActuationStateUpdate(
|
||||
brakeResponseStates[wheelId], throttleResponseStates[wheelId],
|
||||
actuationStates[wheelId]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Forward integrate the angular speed of each wheel on a vehicle by integrating the
|
||||
brake and drive torque applied to each wheel and the torque that develops on the tire as a response
|
||||
to the longitudinal tire force.
|
||||
\see PxVehicleDirectDriveUpdate
|
||||
*/
|
||||
class PxVehicleDirectDrivetrainComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleDirectDrivetrainComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleDirectDrivetrainComponent() {}
|
||||
|
||||
virtual void getDataForDirectDrivetrainComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
PxVehicleArrayData<const PxReal>& brakeResponseStates,
|
||||
PxVehicleArrayData<const PxReal>& throttleResponseStates,
|
||||
PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates,
|
||||
PxVehicleArrayData<const PxVehicleTireForce>& tireForces,
|
||||
PxVehicleArrayData<PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(context);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehicleDirectDrivetrainComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
PxVehicleArrayData<const PxReal> brakeResponseStates;
|
||||
PxVehicleArrayData<const PxReal> throttleResponseStates;
|
||||
PxVehicleArrayData<const PxVehicleWheelParams> wheelParams;
|
||||
PxVehicleArrayData<const PxVehicleWheelActuationState> actuationStates;
|
||||
PxVehicleArrayData<const PxVehicleTireForce> tireForces;
|
||||
PxVehicleArrayData<PxVehicleWheelRigidBody1dState> wheelRigidBody1dStates;
|
||||
|
||||
getDataForDirectDrivetrainComponent(axleDescription,
|
||||
brakeResponseStates, throttleResponseStates,
|
||||
wheelParams, actuationStates, tireForces,
|
||||
wheelRigidBody1dStates);
|
||||
|
||||
for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
|
||||
PxVehicleDirectDriveUpdate(
|
||||
wheelParams[wheelId], actuationStates[wheelId],
|
||||
brakeResponseStates[wheelId], throttleResponseStates[wheelId],
|
||||
tireForces[wheelId],
|
||||
dt,
|
||||
wheelRigidBody1dStates[wheelId]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Forward the applicable set of control values for a vehicle driven by an engine to a command response state for each
|
||||
applicable control value.
|
||||
|
||||
If parameters for an autobox are provided, the autobox will determine if a gear change should begin in order to
|
||||
maintain a desired engine revs.
|
||||
|
||||
\see PxVehicleBrakeCommandLinearUpdate
|
||||
\see PxVehicleClutchCommandResponseLinearUpdate
|
||||
\see PxVehicleEngineDriveThrottleCommandResponseUpdate
|
||||
\see PxVehicleSteerCommandLinearUpdate
|
||||
\see PxVehicleAckermannSteerUpdate
|
||||
\see PxVehicleAutoBoxUpdate
|
||||
\see PxVehicleGearCommandResponseUpdate
|
||||
*/
|
||||
class PxVehicleEngineDriveCommandResponseComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleEngineDriveCommandResponseComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleEngineDriveCommandResponseComponent() {}
|
||||
|
||||
/**
|
||||
\brief Provide vehicle data items for this component.
|
||||
\param[out] axleDescription identifies the wheels on each axle.
|
||||
\param[out] brakeResponseParams An array of brake response parameters with a brake response for each brake command.
|
||||
\param[out] steerResponseParams The steer response parameters.
|
||||
\param[out] ackermannParams The parameters defining Ackermann steering. NULL if no Ackermann steering is desired.
|
||||
\param[out] gearboxParams The gearbox parameters.
|
||||
\param[out] clutchResponseParams The clutch response parameters.
|
||||
\param[out] engineParams The engine parameters. Only needed if an autobox is provided (see autoboxParams), else it can be set to NULL.
|
||||
\param[out] engineState The engine state. Only needed if an autobox is provided (see autoboxParams), else it can be set to NULL.
|
||||
\param[out] autoboxParams The autobox parameters. If not NULL, the autobox will determine the target gear. Requires the parameters
|
||||
engineParams, engineState and autoboxState to be available. If no autobox is desired, NULL can be used in which case
|
||||
the aforementioned additional parameters can be set to NULL too.
|
||||
\param[out] rigidBodyState The state of the vehicle's rigid body.
|
||||
\param[out] commands The throttle, brake, steer etc. command states.
|
||||
\param[out] transmissionCommands The clutch, target gear etc. command states. If an autobox is provided (see autoboxParams)
|
||||
and the target gear is set to PxVehicleEngineDriveTransmissionCommandState::eAUTOMATIC_GEAR, then the autobox will trigger
|
||||
gear shifts.
|
||||
\param[out] brakeResponseStates The resulting brake response states given the command input and brake response parameters.
|
||||
\param[out] throttleResponseState The resulting throttle response to the input throttle command.
|
||||
\param[out] steerResponseStates The resulting steer response states given the command input, steer response and (optionally) Ackermann parameters.
|
||||
\param[out] gearboxResponseState The resulting gearbox response state given the command input and gearbox parameters.
|
||||
\param[out] clutchResponseState The resulting clutch state given the command input and clutch response parameters.
|
||||
\param[out] autoboxState The resulting autobox state given the autobox/engine/gear params and engine state. Only needed if an autobox is
|
||||
provided (see autoboxParams), else it can be set to NULL.
|
||||
*/
|
||||
virtual void getDataForEngineDriveCommandResponseComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams>& brakeResponseParams,
|
||||
const PxVehicleSteerCommandResponseParams*& steerResponseParams,
|
||||
PxVehicleSizedArrayData<const PxVehicleAckermannParams>& ackermannParams,
|
||||
const PxVehicleGearboxParams*& gearboxParams,
|
||||
const PxVehicleClutchCommandResponseParams*& clutchResponseParams,
|
||||
const PxVehicleEngineParams*& engineParams,
|
||||
const PxVehicleRigidBodyState*& rigidBodyState,
|
||||
const PxVehicleEngineState*& engineState,
|
||||
const PxVehicleAutoboxParams*& autoboxParams,
|
||||
const PxVehicleCommandState*& commands,
|
||||
const PxVehicleEngineDriveTransmissionCommandState*& transmissionCommands,
|
||||
PxVehicleArrayData<PxReal>& brakeResponseStates,
|
||||
PxVehicleEngineDriveThrottleCommandResponseState*& throttleResponseState,
|
||||
PxVehicleArrayData<PxReal>& steerResponseStates,
|
||||
PxVehicleGearboxState*& gearboxResponseState,
|
||||
PxVehicleClutchCommandResponseState*& clutchResponseState,
|
||||
PxVehicleAutoboxState*& autoboxState) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(dt);
|
||||
PX_UNUSED(context);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehicleEngineDriveCommandResponseComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams> brakeResponseParams;
|
||||
const PxVehicleSteerCommandResponseParams* steerResponseParams;
|
||||
PxVehicleSizedArrayData<const PxVehicleAckermannParams> ackermannParams;
|
||||
const PxVehicleGearboxParams* gearboxParams;
|
||||
const PxVehicleClutchCommandResponseParams* clutchResponseParams;
|
||||
const PxVehicleEngineParams* engineParams;
|
||||
const PxVehicleRigidBodyState* rigidBodyState;
|
||||
const PxVehicleEngineState* engineState;
|
||||
const PxVehicleAutoboxParams* autoboxParams;
|
||||
const PxVehicleCommandState* commands;
|
||||
const PxVehicleEngineDriveTransmissionCommandState* transmissionCommands;
|
||||
PxVehicleArrayData<PxReal> brakeResponseStates;
|
||||
PxVehicleEngineDriveThrottleCommandResponseState* throttleResponseState;
|
||||
PxVehicleArrayData<PxReal> steerResponseStates;
|
||||
PxVehicleGearboxState* gearboxResponseState;
|
||||
PxVehicleClutchCommandResponseState* clutchResponseState;
|
||||
PxVehicleAutoboxState* autoboxState;
|
||||
|
||||
getDataForEngineDriveCommandResponseComponent(axleDescription,
|
||||
brakeResponseParams, steerResponseParams, ackermannParams,
|
||||
gearboxParams, clutchResponseParams, engineParams, rigidBodyState,
|
||||
engineState, autoboxParams,
|
||||
commands, transmissionCommands,
|
||||
brakeResponseStates, throttleResponseState,
|
||||
steerResponseStates,
|
||||
gearboxResponseState, clutchResponseState, autoboxState);
|
||||
|
||||
//The autobox can modify commands like throttle and target gear. Since the user defined
|
||||
//values should not be overwritten, a copy is used to compute the response.
|
||||
PxVehicleCommandState commandsTmp = *commands;
|
||||
PxVehicleEngineDriveTransmissionCommandState transmissionCommandsTmp = *transmissionCommands;
|
||||
|
||||
const PxReal longitudinalSpeed = rigidBodyState->getLongitudinalSpeed(context.frame);
|
||||
|
||||
//Let the autobox set the target gear, unless the user defined target gear requests
|
||||
//a shift already
|
||||
if (autoboxParams)
|
||||
{
|
||||
PX_ASSERT(engineParams);
|
||||
PX_ASSERT(engineState);
|
||||
PX_ASSERT(autoboxState);
|
||||
|
||||
PxVehicleAutoBoxUpdate(
|
||||
*engineParams, *gearboxParams, *autoboxParams,
|
||||
*engineState, *gearboxResponseState, dt,
|
||||
transmissionCommandsTmp.targetGear, *autoboxState, commandsTmp.throttle);
|
||||
}
|
||||
else if (transmissionCommandsTmp.targetGear == PxVehicleEngineDriveTransmissionCommandState::eAUTOMATIC_GEAR)
|
||||
{
|
||||
//If there is no autobox but eAUTOMATIC_GEAR was specified, use the current target gear
|
||||
transmissionCommandsTmp.targetGear = gearboxResponseState->targetGear;
|
||||
}
|
||||
|
||||
//Distribute brake torque to the wheels across each axle.
|
||||
for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
PxVehicleBrakeCommandResponseUpdate(
|
||||
commandsTmp.brakes, commandsTmp.nbBrakes, longitudinalSpeed,
|
||||
wheelId, brakeResponseParams,
|
||||
brakeResponseStates[i]);
|
||||
}
|
||||
|
||||
//Update target gear as required.
|
||||
PxVehicleGearCommandResponseUpdate(
|
||||
transmissionCommandsTmp.targetGear,
|
||||
*gearboxParams,
|
||||
*gearboxResponseState);
|
||||
|
||||
//Compute the response to the clutch command.
|
||||
PxVehicleClutchCommandResponseLinearUpdate(
|
||||
transmissionCommandsTmp.clutch,
|
||||
*clutchResponseParams,
|
||||
*clutchResponseState);
|
||||
|
||||
//Compute the response to the throttle command.
|
||||
PxVehicleEngineDriveThrottleCommandResponseLinearUpdate(
|
||||
commandsTmp,
|
||||
*throttleResponseState);
|
||||
|
||||
//Update the steer angles and Ackermann correction.
|
||||
for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
PxVehicleSteerCommandResponseUpdate(commandsTmp.steer, longitudinalSpeed, wheelId, *steerResponseParams, steerResponseStates[i]);
|
||||
}
|
||||
if (ackermannParams.size > 0)
|
||||
PxVehicleAckermannSteerUpdate(commandsTmp.steer, *steerResponseParams, ackermannParams, steerResponseStates);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Compute the per wheel drive torque split of a multi-wheel drive differential.
|
||||
\see PxVehicleDifferentialStateUpdate
|
||||
*/
|
||||
class PxVehicleMultiWheelDriveDifferentialStateComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleMultiWheelDriveDifferentialStateComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleMultiWheelDriveDifferentialStateComponent() {}
|
||||
|
||||
virtual void getDataForMultiWheelDriveDifferentialStateComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
const PxVehicleMultiWheelDriveDifferentialParams*& differentialParams,
|
||||
PxVehicleDifferentialState*& differentialState) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(dt);
|
||||
PX_UNUSED(context);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehicleMultiWheelDriveDifferentialStateComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
const PxVehicleMultiWheelDriveDifferentialParams* differentialParams;
|
||||
PxVehicleDifferentialState* differentialState;
|
||||
|
||||
getDataForMultiWheelDriveDifferentialStateComponent(axleDescription,
|
||||
differentialParams, differentialState);
|
||||
|
||||
PxVehicleDifferentialStateUpdate(
|
||||
*axleDescription,
|
||||
*differentialParams,
|
||||
*differentialState);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Compute the per wheel drive torque split of a differential delivering torque to multiple wheels
|
||||
with limited slip applied to specified wheel pairs.
|
||||
\see PxVehicleDifferentialStateUpdate
|
||||
*/
|
||||
class PxVehicleFourWheelDriveDifferentialStateComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleFourWheelDriveDifferentialStateComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleFourWheelDriveDifferentialStateComponent() {}
|
||||
|
||||
virtual void getDataForFourWheelDriveDifferentialStateComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
const PxVehicleFourWheelDriveDifferentialParams*& differentialParams,
|
||||
PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidbody1dStates,
|
||||
PxVehicleDifferentialState*& differentialState,
|
||||
PxVehicleWheelConstraintGroupState*& wheelConstraintGroupState) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(dt);
|
||||
PX_UNUSED(context);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehicleFourWheelDriveDifferentialStateComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
const PxVehicleFourWheelDriveDifferentialParams* differentialParams;
|
||||
PxVehicleArrayData<const PxVehicleWheelRigidBody1dState> wheelRigidbody1dStates;
|
||||
PxVehicleDifferentialState* differentialState;
|
||||
PxVehicleWheelConstraintGroupState* wheelConstraintGroupState;
|
||||
|
||||
getDataForFourWheelDriveDifferentialStateComponent(axleDescription, differentialParams,
|
||||
wheelRigidbody1dStates,
|
||||
differentialState, wheelConstraintGroupState);
|
||||
|
||||
PxVehicleDifferentialStateUpdate(
|
||||
*axleDescription, *differentialParams,
|
||||
wheelRigidbody1dStates, dt,
|
||||
*differentialState, *wheelConstraintGroupState);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Compute the per wheel drive torque split of a tank drive differential.
|
||||
\see PxVehicleDifferentialStateUpdate
|
||||
*/
|
||||
class PxVehicleTankDriveDifferentialStateComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleTankDriveDifferentialStateComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleTankDriveDifferentialStateComponent() {}
|
||||
|
||||
/**
|
||||
\brief Provide vehicle data items for this component.
|
||||
|
||||
\param[out] axleDescription identifies the wheels on each axle.
|
||||
\param[out] transmissionCommands specifies the values of the thrust controllers that divert torque to the tank tracks.
|
||||
\param[out] wheelParams is an array describing the radius of each wheel.
|
||||
\param[out] differentialParams describes the operation of the tank differential by
|
||||
specifying the default torque split between all wheels connected to the differential and by
|
||||
specifying the wheels coupled to each tank track.
|
||||
\param[out] differentialState stores the instantaneous torque split between all wheels arising from the difference between the thrust controllers.
|
||||
\param[out] constraintGroupState stores the groups of wheels that are connected by sharing a tank track.
|
||||
*/
|
||||
virtual void getDataForTankDriveDifferentialStateComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
const PxVehicleTankDriveTransmissionCommandState*& transmissionCommands,
|
||||
PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
const PxVehicleTankDriveDifferentialParams*& differentialParams,
|
||||
PxVehicleDifferentialState*& differentialState,
|
||||
PxVehicleWheelConstraintGroupState*& constraintGroupState) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(dt);
|
||||
PX_UNUSED(context);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehicleTankDriveDifferentialStateComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
const PxVehicleTankDriveTransmissionCommandState* transmissionCommands;
|
||||
PxVehicleArrayData<const PxVehicleWheelParams> wheelParams;
|
||||
const PxVehicleTankDriveDifferentialParams* differentialParams;
|
||||
PxVehicleDifferentialState* differentialState;
|
||||
PxVehicleWheelConstraintGroupState* constraintGroupState;
|
||||
|
||||
getDataForTankDriveDifferentialStateComponent(
|
||||
axleDescription,
|
||||
transmissionCommands,
|
||||
wheelParams,
|
||||
differentialParams,
|
||||
differentialState, constraintGroupState);
|
||||
|
||||
PxVehicleDifferentialStateUpdate(
|
||||
*axleDescription,
|
||||
wheelParams, *differentialParams,
|
||||
transmissionCommands->thrusts[0], transmissionCommands->thrusts[1],
|
||||
*differentialState, *constraintGroupState);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\deprecated This API was introduced with the new Vehicle API for transition purposes but will be removed in a future version.
|
||||
|
||||
\brief Compute the per wheel drive torque split of a four wheel drive differential.
|
||||
\see PxVehicleDifferentialStateUpdate
|
||||
*/
|
||||
class PX_DEPRECATED PxVehicleLegacyFourWheelDriveDifferentialStateComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleLegacyFourWheelDriveDifferentialStateComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleLegacyFourWheelDriveDifferentialStateComponent() {}
|
||||
|
||||
virtual void getDataForLegacyFourWheelDriveDifferentialStateComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
const PxVehicleFourWheelDriveDifferentialLegacyParams*& differentialParams,
|
||||
PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidbody1dStates,
|
||||
PxVehicleDifferentialState*& differentialState) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(dt);
|
||||
PX_UNUSED(context);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehicleLegacyFourWheelDriveDifferentialStateComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
const PxVehicleFourWheelDriveDifferentialLegacyParams* differentialParams;
|
||||
PxVehicleArrayData<const PxVehicleWheelRigidBody1dState> wheelRigidbody1dStates;
|
||||
PxVehicleDifferentialState* differentialState;
|
||||
|
||||
getDataForLegacyFourWheelDriveDifferentialStateComponent(axleDescription, differentialParams,
|
||||
wheelRigidbody1dStates,
|
||||
differentialState);
|
||||
|
||||
PxVehicleDifferentialStateUpdate(
|
||||
*differentialParams, wheelRigidbody1dStates,
|
||||
*differentialState);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Determine the actuation state for each wheel for a vehicle propelled by engine torque.
|
||||
\note The actuation state for each wheel contains a binary record of whether brake and drive torque are to be applied to the wheel.
|
||||
\see PxVehicleEngineDriveActuationStateUpdate
|
||||
*/
|
||||
class PxVehicleEngineDriveActuationStateComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleEngineDriveActuationStateComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleEngineDriveActuationStateComponent() {}
|
||||
|
||||
virtual void getDataForEngineDriveActuationStateComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
const PxVehicleGearboxParams*& gearboxParams,
|
||||
PxVehicleArrayData<const PxReal>& brakeResponseStates,
|
||||
const PxVehicleEngineDriveThrottleCommandResponseState*& throttleResponseState,
|
||||
const PxVehicleGearboxState*& gearboxState,
|
||||
const PxVehicleDifferentialState*& differentialState,
|
||||
const PxVehicleClutchCommandResponseState*& clutchResponseState,
|
||||
PxVehicleArrayData<PxVehicleWheelActuationState>& actuationStates) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(dt);
|
||||
PX_UNUSED(context);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehicleEngineDriveActuationStateComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
const PxVehicleGearboxParams* gearboxParams;
|
||||
PxVehicleArrayData<const PxReal> brakeResponseStates;
|
||||
const PxVehicleEngineDriveThrottleCommandResponseState* throttleResponseState;
|
||||
const PxVehicleGearboxState* gearboxState;
|
||||
const PxVehicleDifferentialState* differentialState;
|
||||
const PxVehicleClutchCommandResponseState* clutchResponseState;
|
||||
PxVehicleArrayData<PxVehicleWheelActuationState> actuationStates;
|
||||
|
||||
getDataForEngineDriveActuationStateComponent(axleDescription, gearboxParams,
|
||||
brakeResponseStates, throttleResponseState,
|
||||
gearboxState, differentialState, clutchResponseState,
|
||||
actuationStates);
|
||||
|
||||
PxVehicleEngineDriveActuationStateUpdate(
|
||||
*axleDescription,
|
||||
*gearboxParams,
|
||||
brakeResponseStates,
|
||||
*throttleResponseState,
|
||||
*gearboxState, *differentialState, *clutchResponseState,
|
||||
actuationStates);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Forward integrate the angular speed of each wheel and of the engine, accounting for the
|
||||
state of the clutch, gearbox and differential.
|
||||
\see PxVehicleGearboxUpdate
|
||||
\see PxVehicleEngineDrivetrainUpdate
|
||||
*/
|
||||
class PxVehicleEngineDrivetrainComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleEngineDrivetrainComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleEngineDrivetrainComponent() {}
|
||||
|
||||
/**
|
||||
\brief Provide vehicle data items for this component.
|
||||
|
||||
\param[out] axleDescription identifies the wheels on each axle.
|
||||
\param[out] wheelParams specifies the radius of each wheel.
|
||||
\param[out] engineParams specifies the engine's torque curve, idle revs and max revs.
|
||||
\param[out] clutchParams specifies the maximum strength of the clutch.
|
||||
\param[out] gearboxParams specifies the gear ratio of each gear.
|
||||
\param[out] brakeResponseStates stores the instantaneous brake brake torque to apply to each wheel.
|
||||
\param[out] actuationStates stores whether a brake and/or drive torque are to be applied to each wheel.
|
||||
\param[out] tireForces stores the lateral and longitudinal tire force that has developed on each tire.
|
||||
\param[out] throttleResponseState stores the response of the throttle to the input throttle command.
|
||||
\param[out] clutchResponseState stores the instantaneous clutch strength that arises from the input clutch command.
|
||||
\param[out] differentialState stores the instantaneous torque split between the wheels.
|
||||
\param[out] constraintGroupState stores the groups of wheels that are subject to constraints that require them to have the same angular or linear velocity.
|
||||
\param[out] wheelRigidBody1dStates stores the per wheel angular speed to be computed by the component.
|
||||
\param[out] engineState stores the engine rotation speed to be computed by the component.
|
||||
\param[out] gearboxState stores the state of the gearbox to be computed by the component.
|
||||
\param[out] clutchState stores the clutch slip to be computed by the component.
|
||||
\note If constraintGroupState is set to NULL it is assumed that there are no requirements for any wheels to have the same angular or linear velocity.
|
||||
*/
|
||||
virtual void getDataForEngineDrivetrainComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
const PxVehicleEngineParams*& engineParams,
|
||||
const PxVehicleClutchParams*& clutchParams,
|
||||
const PxVehicleGearboxParams*& gearboxParams,
|
||||
PxVehicleArrayData<const PxReal>& brakeResponseStates,
|
||||
PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates,
|
||||
PxVehicleArrayData<const PxVehicleTireForce>& tireForces,
|
||||
const PxVehicleEngineDriveThrottleCommandResponseState*& throttleResponseState,
|
||||
const PxVehicleClutchCommandResponseState*& clutchResponseState,
|
||||
const PxVehicleDifferentialState*& differentialState,
|
||||
const PxVehicleWheelConstraintGroupState*& constraintGroupState,
|
||||
PxVehicleArrayData<PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates,
|
||||
PxVehicleEngineState*& engineState,
|
||||
PxVehicleGearboxState*& gearboxState,
|
||||
PxVehicleClutchSlipState*& clutchState) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(context);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehicleEngineDrivetrainComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
PxVehicleArrayData<const PxVehicleWheelParams> wheelParams;
|
||||
const PxVehicleEngineParams* engineParams;
|
||||
const PxVehicleClutchParams* clutchParams;
|
||||
const PxVehicleGearboxParams* gearboxParams;
|
||||
PxVehicleArrayData<const PxReal> brakeResponseStates;
|
||||
PxVehicleArrayData<const PxVehicleWheelActuationState> actuationStates;
|
||||
PxVehicleArrayData<const PxVehicleTireForce> tireForces;
|
||||
const PxVehicleEngineDriveThrottleCommandResponseState* throttleResponseState;
|
||||
const PxVehicleClutchCommandResponseState* clutchResponseState;
|
||||
const PxVehicleDifferentialState* differentialState;
|
||||
const PxVehicleWheelConstraintGroupState* constraintGroupState;
|
||||
PxVehicleArrayData<PxVehicleWheelRigidBody1dState> wheelRigidBody1dStates;
|
||||
PxVehicleEngineState* engineState;
|
||||
PxVehicleGearboxState* gearboxState;
|
||||
PxVehicleClutchSlipState* clutchState;
|
||||
|
||||
getDataForEngineDrivetrainComponent(axleDescription, wheelParams,
|
||||
engineParams, clutchParams, gearboxParams,
|
||||
brakeResponseStates, actuationStates, tireForces,
|
||||
throttleResponseState, clutchResponseState, differentialState, constraintGroupState,
|
||||
wheelRigidBody1dStates, engineState, gearboxState, clutchState);
|
||||
|
||||
PxVehicleGearboxUpdate(*gearboxParams, dt, *gearboxState);
|
||||
|
||||
PxVehicleEngineDrivetrainUpdate(
|
||||
*axleDescription,
|
||||
wheelParams,
|
||||
*engineParams, *clutchParams, *gearboxParams,
|
||||
brakeResponseStates, actuationStates,
|
||||
tireForces,
|
||||
*gearboxState, *throttleResponseState, *clutchResponseState, *differentialState, constraintGroupState,
|
||||
dt,
|
||||
wheelRigidBody1dStates, *engineState, *clutchState);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
314
engine/third_party/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainFunctions.h
vendored
Normal file
314
engine/third_party/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainFunctions.h
vendored
Normal file
@@ -0,0 +1,314 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleCommandState;
|
||||
struct PxVehicleDirectDriveTransmissionCommandState;
|
||||
struct PxVehicleEngineDriveTransmissionCommandState;
|
||||
struct PxVehicleDirectDriveThrottleCommandResponseParams;
|
||||
struct PxVehicleWheelActuationState;
|
||||
struct PxVehicleWheelParams;
|
||||
struct PxVehicleTireForce;
|
||||
struct PxVehicleWheelRigidBody1dState;
|
||||
struct PxVehicleEngineParams;
|
||||
struct PxVehicleGearboxParams;
|
||||
struct PxVehicleAutoboxParams;
|
||||
struct PxVehicleEngineState;
|
||||
struct PxVehicleGearboxState;
|
||||
struct PxVehicleAutoboxState;
|
||||
struct PxVehicleClutchCommandResponseParams;
|
||||
struct PxVehicleClutchCommandResponseState;
|
||||
struct PxVehicleEngineDriveThrottleCommandResponseState;
|
||||
struct PxVehicleDifferentialState;
|
||||
struct PxVehicleMultiWheelDriveDifferentialParams;
|
||||
struct PxVehicleFourWheelDriveDifferentialParams;
|
||||
struct PxVehicleTankDriveDifferentialParams;
|
||||
struct PxVehicleFourWheelDriveDifferentialLegacyParams;
|
||||
struct PxVehicleClutchParams;
|
||||
struct PxVehicleWheelConstraintGroupState;
|
||||
struct PxVehicleClutchSlipState;
|
||||
|
||||
/**
|
||||
\brief Compute the drive torque response to a throttle command.
|
||||
\param[in] throttle is the throttle command.
|
||||
\param[in] transmissionCommands is the gearing command to apply to the direct drive tranmission.
|
||||
\param[in] longitudinalSpeed is the longitudinal speed of the vehicle's rigid body.
|
||||
\param[in] wheelId specifies the wheel that is to have its throttle response computed.
|
||||
\param[in] throttleResponseParams specifies the per wheel drive torque response to the throttle command as a nonlinear function of throttle command and longitudinal speed.
|
||||
\param[out] throttleResponseState is the drive torque response to the input throttle command.
|
||||
*/
|
||||
void PxVehicleDirectDriveThrottleCommandResponseUpdate
|
||||
(const PxReal throttle, const PxVehicleDirectDriveTransmissionCommandState& transmissionCommands, const PxReal longitudinalSpeed,
|
||||
const PxU32 wheelId, const PxVehicleDirectDriveThrottleCommandResponseParams& throttleResponseParams,
|
||||
PxReal& throttleResponseState);
|
||||
|
||||
/**
|
||||
\brief Determine the actuation state of a wheel given the brake torque, handbrake torque and drive torque applied to it.
|
||||
\param[in] brakeTorque is the brake torque to be applied to the wheel.
|
||||
\param[in] driveTorque is the drive torque to be applied to the wheel.
|
||||
\param[out] actuationState contains a binary record of whether brake or drive torque is applied to the wheel.
|
||||
*/
|
||||
void PxVehicleDirectDriveActuationStateUpdate
|
||||
(const PxReal brakeTorque, const PxReal driveTorque,
|
||||
PxVehicleWheelActuationState& actuationState);
|
||||
|
||||
/**
|
||||
\brief Forward integrate the angular speed of a wheel given the brake and drive torque applied to it
|
||||
\param[in] wheelParams specifies the moment of inertia of the wheel.
|
||||
\param[in] actuationState is a binary record of whether brake and drive torque are to be applied to the wheel.
|
||||
\param[in] brakeTorque is the brake torque to be applied to the wheel.
|
||||
\param[in] driveTorque is the drive torque to be applied to the wheel.
|
||||
\param[in] tireForce specifies the torque to apply to the wheel as a response to the longitudinal tire force.
|
||||
\param[in] dt is the timestep of the forward integration.
|
||||
\param[out] wheelRigidBody1dState describes the angular speed of the wheel.
|
||||
*/
|
||||
void PxVehicleDirectDriveUpdate
|
||||
(const PxVehicleWheelParams& wheelParams,
|
||||
const PxVehicleWheelActuationState& actuationState,
|
||||
const PxReal brakeTorque, const PxReal driveTorque, const PxVehicleTireForce& tireForce,
|
||||
const PxF32 dt,
|
||||
PxVehicleWheelRigidBody1dState& wheelRigidBody1dState);
|
||||
|
||||
/**
|
||||
\param[in] engineParams specifies the engine configuration.
|
||||
\param[in] gearboxParams specifies the gear ratios and the time required to complete a gear change.
|
||||
\param[in] autoboxParams specifies the conditions for switching gear.
|
||||
\param[in] engineState contains the current angular speed of the engine.
|
||||
\param[in] gearboxState describes the current and target gear.
|
||||
\param[in] dt is the time that has lapsed since the last call to PxVehicleAutoBoxUpdate.
|
||||
\param[in,out] targetGearCommand specifies the desired target gear for the gearbox. If set to
|
||||
PxVehicleEngineDriveTransmissionCommandState::eAUTOMATIC_GEAR, the value will get overwritten
|
||||
with a target gear chosen by the autobox.
|
||||
\param[out] autoboxState specifies the time that has lapsed since the last automated gear change and contains a record of
|
||||
any ongoing automated gear change.
|
||||
\param[out] throttle A throttle command value in [0, 1] that will be set to 0 if a gear change is initiated or is ongoing.
|
||||
|
||||
\note The autobox will not begin a gear change if a gear change is already ongoing.
|
||||
\note The autobox will not begin a gear change until a threshold time has lapsed since the last automated gear change.
|
||||
\note A gear change is considered as ongoing for as long as PxVehicleGearboxState::currentGear is different from
|
||||
PxVehicleGearboxState::targetGear.
|
||||
\note The autobox will not shift down from 1st gear or up from reverse gear.
|
||||
\note The autobox shifts in single gear increments or decrements.
|
||||
\note The autobox instantiates a gear change by setting PxVehicleCommandState::targetGear to be different from
|
||||
from PxVehicleGearboxState::currentGear
|
||||
*/
|
||||
void PxVehicleAutoBoxUpdate
|
||||
(const PxVehicleEngineParams& engineParams, const PxVehicleGearboxParams& gearboxParams, const PxVehicleAutoboxParams& autoboxParams,
|
||||
const PxVehicleEngineState& engineState, const PxVehicleGearboxState& gearboxState,
|
||||
const PxReal dt,
|
||||
PxU32& targetGearCommand, PxVehicleAutoboxState& autoboxState,
|
||||
PxReal& throttle);
|
||||
|
||||
/**
|
||||
\brief Propagate input gear commands to the gearbox state.
|
||||
\param[in] targetGearCommand specifies the target gear for the gearbox.
|
||||
\param[in] gearboxParams specifies the number of gears and the index of neutral gear.
|
||||
\param[out] gearboxState contains a record of the current and target gear.
|
||||
\note Any ongoing gear change must complete before starting another.
|
||||
\note A gear change is considered as ongoing for as long as PxVehicleGearboxState::currentGear is different from
|
||||
PxVehicleGearboxState::targetGear.
|
||||
\note The gearbox remains in neutral for the duration of the gear change.
|
||||
\note A gear change begins if PxVehicleCommandState::targetGear is different from PxVehicleGearboxState::currentGear.
|
||||
*/
|
||||
void PxVehicleGearCommandResponseUpdate
|
||||
(const PxU32 targetGearCommand,
|
||||
const PxVehicleGearboxParams& gearboxParams,
|
||||
PxVehicleGearboxState& gearboxState);
|
||||
|
||||
/**
|
||||
\brief Propagate the input clutch command to the clutch response state.
|
||||
\param[in] clutchCommand specifies the state of the clutch pedal.
|
||||
\param[in] clutchResponseParams specifies how the clutch responds to the input clutch command.
|
||||
\param[out] clutchResponse specifies the response of the clutch to the input clutch command.
|
||||
*/
|
||||
void PxVehicleClutchCommandResponseLinearUpdate
|
||||
(const PxReal clutchCommand,
|
||||
const PxVehicleClutchCommandResponseParams& clutchResponseParams,
|
||||
PxVehicleClutchCommandResponseState& clutchResponse);
|
||||
|
||||
/**
|
||||
\brief Propagate the input throttle command to the throttle response state.
|
||||
\param[in] commands specifies the state of the throttle pedal.
|
||||
\param[out] throttleResponse specifies how the clutch responds to the input throttle command.
|
||||
*/
|
||||
void PxVehicleEngineDriveThrottleCommandResponseLinearUpdate
|
||||
(const PxVehicleCommandState& commands,
|
||||
PxVehicleEngineDriveThrottleCommandResponseState& throttleResponse);
|
||||
|
||||
/**
|
||||
\brief Determine the actuation state of all wheels on a vehicle.
|
||||
\param[in] axleDescription is a decription of the axles of the vehicle and the wheels on each axle.
|
||||
\param[in] gearboxParams specifies the index of the neutral gear of the gearbox.
|
||||
\param[in] brakeResponseStates specifies the response of each wheel to the input brake command.
|
||||
\param[in] throttleResponseState specifies the response of the engine to the input throttle command.
|
||||
\param[in] gearboxState specifies the current gear.
|
||||
\param[in] diffState specifies the fraction of available drive torque to be delivered to each wheel.
|
||||
\param[in] clutchResponseState specifies the response of the clutch to the input throttle command.
|
||||
\param[out] actuationStates is an array of binary records determining whether brake and drive torque are to be applied to each wheel.
|
||||
\note Drive torque is not applied to a wheel if
|
||||
a) the gearbox is in neutral
|
||||
b) the differential delivers no torque to the wheel
|
||||
c) no throttle is applied to the engine
|
||||
c) the clutch is fully disengaged.
|
||||
*/
|
||||
void PxVehicleEngineDriveActuationStateUpdate
|
||||
(const PxVehicleAxleDescription& axleDescription,
|
||||
const PxVehicleGearboxParams& gearboxParams,
|
||||
const PxVehicleArrayData<const PxReal>& brakeResponseStates,
|
||||
const PxVehicleEngineDriveThrottleCommandResponseState& throttleResponseState,
|
||||
const PxVehicleGearboxState& gearboxState, const PxVehicleDifferentialState& diffState, const PxVehicleClutchCommandResponseState& clutchResponseState,
|
||||
PxVehicleArrayData<PxVehicleWheelActuationState>& actuationStates);
|
||||
|
||||
/**
|
||||
\deprecated This API was introduced with the new Vehicle API for transition purposes but will be removed in a future version.
|
||||
|
||||
\brief Compute the fraction of available torque to be delivered to each wheel and gather a list of all
|
||||
wheels connected to the differential.
|
||||
\param[in] diffParams specifies the operation of a differential that can be connected to up to four wheels.
|
||||
\param[in] wheelStates describes the angular speed of each wheel
|
||||
\param[out] diffState contains the fraction of available drive torque to be delivered to each wheel.
|
||||
\note If the handbrake is on then torque is only delivered to the wheels specified as the front wheels of the differential.
|
||||
*/
|
||||
void PX_DEPRECATED PxVehicleDifferentialStateUpdate
|
||||
(const PxVehicleFourWheelDriveDifferentialLegacyParams& diffParams,
|
||||
const PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelStates,
|
||||
PxVehicleDifferentialState& diffState);
|
||||
|
||||
/**
|
||||
\brief Compute the fraction of available torque to be delivered to each wheel and gather a list of all
|
||||
wheels connected to the differential. Additionally, add wheel constraints for wheel pairs whose
|
||||
rotational speed ratio exceeds the corresponding differential bias.
|
||||
\param[in] axleDescription is a decription of the axles of the vehicle and the wheels on each axle.
|
||||
\param[in] diffParams describe the division of available drive torque and the biases of the limited
|
||||
slip differential.
|
||||
\param[in] wheelStates describes the rotational speeds of each wheel.
|
||||
\param[in] dt is the simulation time that has passes since the last call to PxVehicleDifferentialStateUpdate()
|
||||
\param[out] diffState contains the fraction of available drive torque to be delivered to each wheel.
|
||||
\param[out] wheelConstraintGroupState describes the groups of wheels that have exceeded their corresponding
|
||||
differential biases.
|
||||
*/
|
||||
void PxVehicleDifferentialStateUpdate
|
||||
(const PxVehicleAxleDescription& axleDescription, const PxVehicleFourWheelDriveDifferentialParams& diffParams,
|
||||
const PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelStates,
|
||||
const PxReal dt,
|
||||
PxVehicleDifferentialState& diffState, PxVehicleWheelConstraintGroupState& wheelConstraintGroupState);
|
||||
|
||||
/**
|
||||
\brief Compute the fraction of available torque to be delivered to each wheel and gather a list of all
|
||||
wheels connected to the differential.
|
||||
\param[in] axleDescription is a decription of the axles of the vehicle and the wheels on each axle.
|
||||
\param[in] diffParams specifies the operation of a differential that can be connected to any combination of wheels.
|
||||
\param[out] diffState contains the fraction of available drive torque to be delivered to each wheel connected to the differential.
|
||||
*/
|
||||
void PxVehicleDifferentialStateUpdate
|
||||
(const PxVehicleAxleDescription& axleDescription, const PxVehicleMultiWheelDriveDifferentialParams& diffParams,
|
||||
PxVehicleDifferentialState& diffState);
|
||||
|
||||
/**
|
||||
\brief Compute the fraction of available torque to be delivered to each wheel and gather a list of all
|
||||
wheels connected to the differential.
|
||||
\param[in] axleDescription is a decription of the axles of the vehicle and the wheels on each axle.
|
||||
\param[in] wheelParams is an array that describes the wheel radius of each wheel.
|
||||
\param[in] diffParams specifies the operation of a tank differential.
|
||||
\param[in] thrustCommand0 is the state of one of the two thrust controllers.
|
||||
\param[in] thrustCommand1 is the state of one of the two thrust controllers.
|
||||
\param[out] diffState contains the fraction of available drive torque to be delivered to each wheel connected to the differential.
|
||||
\param[out] wheelConstraintGroupState describes the groups of wheels connected by sharing a tank track.
|
||||
*/
|
||||
void PxVehicleDifferentialStateUpdate
|
||||
(const PxVehicleAxleDescription& axleDescription,
|
||||
const PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams, const PxVehicleTankDriveDifferentialParams& diffParams,
|
||||
const PxReal thrustCommand0, PxReal thrustCommand1,
|
||||
PxVehicleDifferentialState& diffState, PxVehicleWheelConstraintGroupState& wheelConstraintGroupState);
|
||||
|
||||
|
||||
/**
|
||||
\brief Update the current gear of the gearbox. If a gear change is ongoing then complete the gear change if a threshold
|
||||
time has passed since the beginning of the gear change.
|
||||
\param[in] gearboxParams describes the time required to complete a gear change.
|
||||
\param[in] dt is the time that has lapsed since the last call to PxVehicleGearboxUpdate.
|
||||
\param[out] gearboxState is the gearbox state to be updated.
|
||||
\note A gear change is considered as ongoing for as long as PxVehicleGearboxState::currentGear is different from
|
||||
PxVehicleGearboxState::targetGear.
|
||||
*/
|
||||
void PxVehicleGearboxUpdate
|
||||
(const PxVehicleGearboxParams& gearboxParams,
|
||||
const PxF32 dt,
|
||||
PxVehicleGearboxState& gearboxState);
|
||||
|
||||
/**
|
||||
\brief Forward integrate the angular speed of the vehicle's wheels and engine, given the state of clutch, differential and gearbox.
|
||||
\param[in] axleDescription is a decription of the axles of the vehicle and the wheels on each axle.
|
||||
\param[in] wheelParams specifies the moment of inertia of each wheel.
|
||||
\param[in] engineParams specifies the torque curve of the engine and its moment of inertia.
|
||||
\param[in] clutchParams specifies the maximum clutch strength that happens when the clutch is fully engaged.
|
||||
\param[in] gearboxParams specifies the gearing ratios of the gearbox.
|
||||
\param[in] brakeResponseStates describes the per wheel response to the input brake command.
|
||||
\param[in] actuationStates is a binary record of whether brake or drive torque is applied to each wheel.
|
||||
\param[in] tireForces describes the torque to apply to each wheel as a response to the longitudinal tire force.
|
||||
\param[in] gearboxState describes the current gear.
|
||||
\param[in] throttleResponse describes the engine response to the input throttle pedal.
|
||||
\param[in] clutchResponse describes the clutch response to the input clutch pedal.
|
||||
\param[in] diffState describes the fraction of available drive torque to be delivered to each wheel.
|
||||
\param[in] constraintGroupState describes groups of wheels with rotational speed constrained to the same value.
|
||||
\param[in] dt is the time that has lapsed since the last call to PxVehicleEngineDrivetrainUpdate
|
||||
\param[out] wheelRigidbody1dStates describes the angular speed of each wheel.
|
||||
\param[out] engineState describes the angular speed of the engine.
|
||||
\param[out] clutchState describes the clutch slip.
|
||||
\note If constraintGroupState is NULL then it is assumed that there are no wheels subject to rotational speed constraints.
|
||||
*/
|
||||
void PxVehicleEngineDrivetrainUpdate
|
||||
(const PxVehicleAxleDescription& axleDescription,
|
||||
const PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
const PxVehicleEngineParams& engineParams, const PxVehicleClutchParams& clutchParams, const PxVehicleGearboxParams& gearboxParams,
|
||||
const PxVehicleArrayData<const PxReal>& brakeResponseStates,
|
||||
const PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates,
|
||||
const PxVehicleArrayData<const PxVehicleTireForce>& tireForces,
|
||||
const PxVehicleGearboxState& gearboxState, const PxVehicleEngineDriveThrottleCommandResponseState& throttleResponse, const PxVehicleClutchCommandResponseState& clutchResponse,
|
||||
const PxVehicleDifferentialState& diffState, const PxVehicleWheelConstraintGroupState* constraintGroupState,
|
||||
const PxReal dt,
|
||||
PxVehicleArrayData<PxVehicleWheelRigidBody1dState>& wheelRigidbody1dStates,
|
||||
PxVehicleEngineState& engineState, PxVehicleClutchSlipState& clutchState);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
156
engine/third_party/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainHelpers.h
vendored
Normal file
156
engine/third_party/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainHelpers.h
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "vehicle2/drivetrain/PxVehicleDrivetrainParams.h"
|
||||
#include "vehicle2/drivetrain/PxVehicleDrivetrainStates.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleWheelRigidBody1dState;
|
||||
|
||||
/**
|
||||
\brief Compute the coupling strength of the clutch.
|
||||
\param[in] clutchResponseState describes the response of the clutch to the input clutch command.
|
||||
\param[in] gearboxParams holds the index of neutral gear.
|
||||
\param[in] gearboxState describes the current gear.
|
||||
\note If the gear is in neutral the clutch is fully disengaged and the clutch strength is 0.
|
||||
\note A clutch response state of 0.0 denotes a fully engaged clutch with maximum strength.
|
||||
\note A clutch response state of 1.0 denotes a fully disengaged clutch with a strength of 0.0.
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal PxVehicleClutchStrengthCompute(const PxVehicleClutchCommandResponseState& clutchResponseState, const PxVehicleGearboxParams& gearboxParams, const PxVehicleGearboxState& gearboxState)
|
||||
{
|
||||
return (gearboxParams.neutralGear != gearboxState.currentGear) ? clutchResponseState.commandResponse : 0.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the damping rate of the engine.
|
||||
\param[in] engineParams describes various damping rates of the engine in different operational states.
|
||||
\param[in] gearboxParams holds the index of neutral gear.
|
||||
\param[in] gearboxState describes the current gear.
|
||||
\param[in] clutchResponseState is the response of the clutch to the clutch command.
|
||||
\param[in] throttleResponseState is the response of the throttle to the throttle command.
|
||||
\note Engines typically have different damping rates with clutch engaged and disengaged.
|
||||
\note Engines typically have different damping rates at different throttle pedal values.
|
||||
\see PxVehicleClutchStrengthCompute()
|
||||
\note In neutral gear the clutch is considered to be fully disengaged.
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal PxVehicleEngineDampingRateCompute
|
||||
(const PxVehicleEngineParams& engineParams,
|
||||
const PxVehicleGearboxParams& gearboxParams, const PxVehicleGearboxState& gearboxState,
|
||||
const PxVehicleClutchCommandResponseState& clutchResponseState,
|
||||
const PxVehicleEngineDriveThrottleCommandResponseState& throttleResponseState)
|
||||
{
|
||||
const PxReal K = (gearboxParams.neutralGear != gearboxState.currentGear) ? clutchResponseState.normalisedCommandResponse : 0.0f;
|
||||
const PxReal zeroThrottleDamping = engineParams.dampingRateZeroThrottleClutchEngaged +
|
||||
(1.0f - K)* (engineParams.dampingRateZeroThrottleClutchDisengaged - engineParams.dampingRateZeroThrottleClutchEngaged);
|
||||
const PxReal appliedThrottle = throttleResponseState.commandResponse;
|
||||
const PxReal fullThrottleDamping = engineParams.dampingRateFullThrottle;
|
||||
const PxReal engineDamping = zeroThrottleDamping + (fullThrottleDamping - zeroThrottleDamping)*appliedThrottle;
|
||||
return engineDamping;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the gear ratio delivered by the gearbox in the current gear.
|
||||
\param[in] gearboxParams describes the gear ratio of each gear and the final ratio.
|
||||
\param[in] gearboxState describes the current gear.
|
||||
\note The gear ratio is the product of the gear ratio of the current gear and the final gear ratio of the gearbox.
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal PxVehicleGearRatioCompute
|
||||
(const PxVehicleGearboxParams& gearboxParams, const PxVehicleGearboxState& gearboxState)
|
||||
{
|
||||
const PxReal gearRatio = gearboxParams.ratios[gearboxState.currentGear] * gearboxParams.finalRatio;
|
||||
return gearRatio;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the drive torque to deliver to the engine.
|
||||
\param[in] engineParams describes the profile of maximum available torque across the full range of engine rotational speed.
|
||||
\param[in] engineState describes the engine rotational speed.
|
||||
\param[in] throttleCommandResponseState describes the engine's response to input throttle command.
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal PxVehicleEngineDriveTorqueCompute
|
||||
(const PxVehicleEngineParams& engineParams, const PxVehicleEngineState& engineState, const PxVehicleEngineDriveThrottleCommandResponseState& throttleCommandResponseState)
|
||||
{
|
||||
const PxReal appliedThrottle = throttleCommandResponseState.commandResponse;
|
||||
const PxReal peakTorque = engineParams.peakTorque;
|
||||
const PxVehicleFixedSizeLookupTable<PxReal, PxVehicleEngineParams::eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES>& torqueCurve = engineParams.torqueCurve;
|
||||
const PxReal normalisedRotSpeed = engineState.rotationSpeed/engineParams.maxOmega;
|
||||
const PxReal engineDriveTorque = appliedThrottle*peakTorque*torqueCurve.interpolate(normalisedRotSpeed);
|
||||
return engineDriveTorque;
|
||||
}
|
||||
|
||||
/**
|
||||
\deprecated This API was introduced with the new Vehicle API for transition purposes but will be removed in a future version.
|
||||
|
||||
\brief Compute the contribution that each wheel makes to the averaged wheel speed at the clutch plate connected to the wheels driven by
|
||||
the differential.
|
||||
\param[in] diffParams describes the wheels coupled to the differential and the operation of the torque split at the differential.
|
||||
\param[in] nbWheels The number of wheels. Can be larger than the number of wheels connected to the differential.
|
||||
\param[out] diffAveWheelSpeedContributions describes the contribution that each wheel makes to the averaged wheel speed at the clutch.
|
||||
The buffer needs to be sized to be able to hold at least nbWheels entries.
|
||||
\note Any wheel on an axle connected to the differential could have a non-zero value, depending on the way the differential couples to the wheels.
|
||||
\note Any wheel on an axle not connected to the differential will have a zero contribution to the averaged wheel speed.
|
||||
*/
|
||||
void PX_DEPRECATED PxVehicleLegacyDifferentialWheelSpeedContributionsCompute
|
||||
(const PxVehicleFourWheelDriveDifferentialLegacyParams& diffParams,
|
||||
const PxU32 nbWheels, PxReal* diffAveWheelSpeedContributions);
|
||||
|
||||
/**
|
||||
\deprecated This API was introduced with the new Vehicle API for transition purposes but will be removed in a future version.
|
||||
|
||||
\brief Compute the fraction of available torque that is delivered to each wheel through the differential.
|
||||
\param[in] diffParams describes the wheels coupled to the differential and the operation of the torque split at the differential.
|
||||
\param[in] wheelOmegas describes the rotational speeds of the wheels. Is expected to have nbWheels entries.
|
||||
\param[in] nbWheels The number of wheels. Can be larger than the number of wheels connected to the differential.
|
||||
\param[out] diffTorqueRatios describes the fraction of available torque delivered to each wheel.
|
||||
The buffer needs to be sized to be able to hold at least nbWheels entries.
|
||||
\note Any wheel on an axle connected to the diff could receive a non-zero ratio, depending on the way the differential couples to the wheels.
|
||||
\note Any wheel not on an axle connected to the diff will have a zero value.
|
||||
\note The sum of all the ratios adds to 1.0.
|
||||
\note Slipping wheels driven by the differential will typically receive less torque than non-slipping wheels in the event that the
|
||||
differential has a limited slip configuration.
|
||||
*/
|
||||
void PX_DEPRECATED PxVehicleLegacyDifferentialTorqueRatiosCompute
|
||||
(const PxVehicleFourWheelDriveDifferentialLegacyParams& diffParams,
|
||||
const PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelOmegas,
|
||||
const PxU32 nbWheels, PxReal* diffTorqueRatios);
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
993
engine/third_party/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainParams.h
vendored
Normal file
993
engine/third_party/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainParams.h
vendored
Normal file
@@ -0,0 +1,993 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxFoundation.h"
|
||||
#include "common/PxCoreUtilityTypes.h"
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
|
||||
#include "vehicle2/commands/PxVehicleCommandParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Distribute a throttle response to the wheels of a direct drive vehicle.
|
||||
\note The drive torque applied to each wheel on the ith axle is throttleCommand * maxResponse * wheelResponseMultipliers[i].
|
||||
\note A typical use case is to set maxResponse to be the vehicle's maximum achievable drive torque
|
||||
that occurs when the steer command is equal to 1.0. The array wheelResponseMultipliers[i] would then be used
|
||||
to specify the maximum achievable drive torque per wheel as a fractional multiplier of the vehicle's maximum achievable steer angle.
|
||||
*/
|
||||
struct PxVehicleDirectDriveThrottleCommandResponseParams : public PxVehicleCommandResponseParams
|
||||
{
|
||||
PX_FORCE_INLINE PxVehicleDirectDriveThrottleCommandResponseParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PxVehicleDirectDriveThrottleCommandResponseParams r = *this;
|
||||
const PxReal scale = trgScale.scale/srcScale.scale;
|
||||
r.maxResponse *= (scale*scale); //Max response is a torque!
|
||||
return r;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(PxIsFinite(maxResponse), "PxVehicleDirectDriveThrottleCommandResponseParams.maxResponse must be a finite value", false);
|
||||
for (PxU32 i = 0; i < axleDesc.nbWheels; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(PxIsFinite(wheelResponseMultipliers[axleDesc.wheelIdsInAxleOrder[i]]), "PxVehicleDirectDriveThrottleCommandResponseParams.wheelResponseMultipliers[i] must be a finite value", false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Specifies the maximum clutch strength that occurs when the clutch pedal is fully disengaged and the clutch is fully engaged.
|
||||
*/
|
||||
struct PxVehicleClutchCommandResponseParams
|
||||
{
|
||||
/**
|
||||
\brief Strength of clutch.
|
||||
|
||||
\note The clutch is the mechanism that couples the engine to the wheels.
|
||||
A stronger clutch more strongly couples the engine to the wheels, while a
|
||||
clutch of strength zero completely decouples the engine from the wheels.
|
||||
Stronger clutches more quickly bring the wheels and engine into equilibrium, while weaker
|
||||
clutches take longer, resulting in periods of clutch slip and delays in power transmission
|
||||
from the engine to the wheels.
|
||||
The torque generated by the clutch is proportional to the clutch strength and
|
||||
the velocity difference between the engine's rotational speed and the rotational speed of the
|
||||
driven wheels after accounting for the gear ratio.
|
||||
The torque at the clutch is applied negatively to the engine and positively to the driven wheels.
|
||||
|
||||
<b>Range:</b> [0,inf)<br>
|
||||
<b>Unit:</b> torque * time = mass * (length^2) / time
|
||||
*/
|
||||
PxReal maxResponse;
|
||||
|
||||
PX_FORCE_INLINE PxVehicleClutchCommandResponseParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
const PxReal scale = trgScale.scale/srcScale.scale;
|
||||
PxVehicleClutchCommandResponseParams r = *this;
|
||||
r.maxResponse *= (scale*scale);
|
||||
return r;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(maxResponse >= 0.0f, "PxVehicleClutchCommandResponseParams.maxResponse must be greater than or equal to zero", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Choose between a potentially more expensive but more accurate solution to the clutch model or a potentially cheaper but less accurate solution.
|
||||
\see PxVehicleClutchParams
|
||||
*/
|
||||
struct PxVehicleClutchAccuracyMode
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eESTIMATE = 0,
|
||||
eBEST_POSSIBLE
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief The clutch connects two plates together. One plate rotates with the speed of the engine. The second plate rotates with a weighted average of all
|
||||
wheels connected to the differential after accounting for the gear ratio. The difference in rotation speeds generates a restoring torque applied to engine and wheels
|
||||
that aims to reduce the difference in rotational speed. The restoring torque is proportional to the clutch strength and the clutch pedal position.
|
||||
*/
|
||||
struct PxVehicleClutchParams
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief The engine and wheel rotation speeds that are coupled through the clutch can be updated by choosing
|
||||
one of two modes: eESTIMATE and eBEST_POSSIBLE.
|
||||
|
||||
\note If eESTIMATE is chosen the vehicle sdk will update the wheel and engine rotation speeds
|
||||
with estimated values to the implemented clutch model.
|
||||
|
||||
\note If eBEST_POSSIBLE is chosen the vehicle sdk will compute the best possible
|
||||
solution (within floating point tolerance) to the implemented clutch model.
|
||||
This is the recommended mode.
|
||||
|
||||
\note The clutch model remains the same if either eESTIMATE or eBEST_POSSIBLE is chosen but the accuracy and
|
||||
computational cost of the solution to the model can be tuned as required.
|
||||
*/
|
||||
PxVehicleClutchAccuracyMode::Enum accuracyMode;
|
||||
|
||||
/**
|
||||
\brief Tune the mathematical accuracy and computational cost of the computed estimate to the wheel and
|
||||
engine rotation speeds if eESTIMATE is chosen.
|
||||
|
||||
\note As estimateIterations increases the computational cost of the clutch also increases and the solution
|
||||
approaches the solution that would be computed if eBEST_POSSIBLE was chosen instead.
|
||||
|
||||
\note This has no effect if eBEST_POSSIBLE is chosen as the accuracy mode.
|
||||
|
||||
\note A value of zero is not allowed if eESTIMATE is chosen as the accuracy mode.
|
||||
*/
|
||||
PxU32 estimateIterations;
|
||||
|
||||
PX_FORCE_INLINE PxVehicleClutchParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PX_UNUSED(srcScale);
|
||||
PX_UNUSED(trgScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL((PxVehicleClutchAccuracyMode::eBEST_POSSIBLE == accuracyMode) || ((PxVehicleClutchAccuracyMode::eESTIMATE == accuracyMode) && (estimateIterations > 0)), "PxVehicleClutchParams.estimateIterations must be greater than zero if PxVehicleClutchAccuracyMode::eESTIMATE is selected", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct PxVehicleEngineParams
|
||||
{
|
||||
/**
|
||||
\brief Maximum supported number of points in the #torqueCurve graph.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES = 8
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Graph of normalized torque (torque/#peakTorque) against normalized engine speed ( engineRotationSpeed / #maxOmega ).
|
||||
|
||||
\note The normalized engine speed is the x-axis of the graph, while the normalized torque is the y-axis of the graph.
|
||||
*/
|
||||
PxVehicleFixedSizeLookupTable<PxReal, eMAX_NB_ENGINE_TORQUE_CURVE_ENTRIES> torqueCurve;
|
||||
|
||||
/**
|
||||
\brief Moment of inertia of the engine around the axis of rotation.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> mass * (length^2)
|
||||
*/
|
||||
PxReal moi;
|
||||
|
||||
/**
|
||||
\brief Maximum torque available to apply to the engine when the accelerator pedal is at maximum.
|
||||
|
||||
\note The torque available is the value of the accelerator pedal (in range [0, 1]) multiplied by the normalized torque as computed from #torqueCurve multiplied by #peakTorque.
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> mass * (length^2) / (time^2)
|
||||
*/
|
||||
PxReal peakTorque;
|
||||
|
||||
/**
|
||||
\brief Minimum rotation speed of the engine.
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> radians / time
|
||||
*/
|
||||
PxReal idleOmega;
|
||||
|
||||
/**
|
||||
\brief Maximum rotation speed of the engine.
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> radians / time
|
||||
*/
|
||||
PxReal maxOmega;
|
||||
|
||||
/**
|
||||
\brief Damping rate of engine when full throttle is applied.
|
||||
|
||||
\note If the clutch is engaged (any gear except neutral) then the damping rate applied at run-time is an interpolation
|
||||
between #dampingRateZeroThrottleClutchEngaged and #dampingRateFullThrottle:
|
||||
#dampingRateZeroThrottleClutchEngaged + (#dampingRateFullThrottle-#dampingRateZeroThrottleClutchEngaged)*acceleratorPedal;
|
||||
|
||||
\note If the clutch is disengaged (in neutral gear) the damping rate applied at run-time is an interpolation
|
||||
between #dampingRateZeroThrottleClutchDisengaged and #dampingRateFullThrottle:
|
||||
#dampingRateZeroThrottleClutchDisengaged + (#dampingRateFullThrottle-#dampingRateZeroThrottleClutchDisengaged)*acceleratorPedal;
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> torque * time = mass * (length^2) / time
|
||||
*/
|
||||
PxReal dampingRateFullThrottle;
|
||||
|
||||
/**
|
||||
\brief Damping rate of engine when no throttle is applied and with engaged clutch.
|
||||
|
||||
\note If the clutch is engaged (any gear except neutral) then the damping rate applied at run-time is an interpolation
|
||||
between #dampingRateZeroThrottleClutchEngaged and #dampingRateFullThrottle:
|
||||
#dampingRateZeroThrottleClutchEngaged + (#dampingRateFullThrottle-#dampingRateZeroThrottleClutchEngaged)*acceleratorPedal;
|
||||
|
||||
\note If the clutch is disengaged (in neutral gear) the damping rate applied at run-time is an interpolation
|
||||
between #dampingRateZeroThrottleClutchDisengaged and #dampingRateFullThrottle:
|
||||
#dampingRateZeroThrottleClutchDisengaged + (#dampingRateFullThrottle-#dampingRateZeroThrottleClutchDisengaged)*acceleratorPedal;
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> torque * time = mass * (length^2) / time
|
||||
*/
|
||||
PxReal dampingRateZeroThrottleClutchEngaged;
|
||||
|
||||
/**
|
||||
\brief Damping rate of engine when no throttle is applied and with disengaged clutch.
|
||||
|
||||
\note If the clutch is engaged (any gear except neutral) then the damping rate applied at run-time is an interpolation
|
||||
between #dampingRateZeroThrottleClutchEngaged and #dampingRateFullThrottle:
|
||||
#dampingRateZeroThrottleClutchEngaged + (#dampingRateFullThrottle-#dampingRateZeroThrottleClutchEngaged)*acceleratorPedal;
|
||||
|
||||
\note If the clutch is disengaged (in neutral gear) the damping rate applied at run-time is an interpolation
|
||||
between #dampingRateZeroThrottleClutchDisengaged and #dampingRateFullThrottle:
|
||||
#dampingRateZeroThrottleClutchDisengaged + (#dampingRateFullThrottle-#dampingRateZeroThrottleClutchDisengaged)*acceleratorPedal;
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> torque * time = mass * (length^2) / time
|
||||
*/
|
||||
PxReal dampingRateZeroThrottleClutchDisengaged;
|
||||
|
||||
PX_FORCE_INLINE PxVehicleEngineParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PxVehicleEngineParams r = *this;
|
||||
const PxReal scale = trgScale.scale/srcScale.scale;
|
||||
r.moi *= (scale*scale);
|
||||
r.peakTorque *= (scale*scale);
|
||||
r.dampingRateFullThrottle *= (scale*scale);
|
||||
r.dampingRateZeroThrottleClutchDisengaged *= (scale*scale);
|
||||
r.dampingRateZeroThrottleClutchEngaged *= (scale*scale);
|
||||
return r;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(moi > 0.0f, "PxVehicleEngineParams.moi must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(peakTorque >= 0.0f, "PxVehicleEngineParams.peakTorque must be greater than or equal to zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(torqueCurve.isValid(), "PxVehicleEngineParams.torqueCurve is invalid", false);
|
||||
PX_CHECK_AND_RETURN_VAL(maxOmega >= 0.0f, "PxVehicleEngineParams.maxOmega must be greater than or equal to zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(idleOmega >= 0.0f, "PxVehicleEngineParams.idleOmega must be greater or equal to zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(dampingRateFullThrottle >= 0.0f, "PxVehicleEngineParams.dampingRateFullThrottle must be greater than or equal to zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(dampingRateZeroThrottleClutchEngaged >= 0.0f, "PxVehicleEngineParams.dampingRateZeroThrottleClutchEngaged must be greater than or equal to zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(dampingRateZeroThrottleClutchDisengaged >= 0.0f, "PxVehicleEngineParams.dampingRateZeroThrottleClutchDisengaged must be greater than or equal to zero", false)
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct PxVehicleGearboxParams
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief The gear that denotes neutral gear
|
||||
*/
|
||||
PxU32 neutralGear;
|
||||
|
||||
/**
|
||||
\brief Maximum supported number of gears, including reverse and neutral.
|
||||
*/
|
||||
enum Enum
|
||||
{
|
||||
eMAX_NB_GEARS = 32
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Gear ratios
|
||||
|
||||
The ratio for reverse gears must be negative, the ratio for the neutral gear
|
||||
has to be 0 and the ratio for forward gears must be positive.
|
||||
*/
|
||||
PxReal ratios[eMAX_NB_GEARS];
|
||||
|
||||
/**
|
||||
\brief Gear ratio applied is #ratios[currentGear]*#finalRatio
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
*/
|
||||
PxReal finalRatio;
|
||||
|
||||
/**
|
||||
\brief Number of gears (including reverse and neutral).
|
||||
|
||||
<b>Range:</b> [1, eMAX_NB_GEARS]<br>
|
||||
*/
|
||||
PxU32 nbRatios;
|
||||
|
||||
/**
|
||||
\brief Time it takes to switch gear.
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> time
|
||||
*/
|
||||
PxReal switchTime;
|
||||
|
||||
PX_FORCE_INLINE PxVehicleGearboxParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PX_UNUSED(srcScale);
|
||||
PX_UNUSED(trgScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(finalRatio > 0, "PxVehicleGearboxParams.finalRatio must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(nbRatios >= 1, "PxVehicleGearboxParams.nbRatios must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(nbRatios <= eMAX_NB_GEARS, "PxVehicleGearboxParams.nbRatios must be less than or equal to eMAX_NB_GEARS", false);
|
||||
PX_CHECK_AND_RETURN_VAL(neutralGear < nbRatios, "PxVehicleGearboxParams.neutralGear must be less than PxVehicleGearboxParams.nbRatios", false);
|
||||
PX_CHECK_AND_RETURN_VAL(switchTime >= 0.0f, "PxVehicleGearboxParams.switchTime must be greater than or equal to zero", false);
|
||||
for(PxU32 i = 0; i < neutralGear; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(ratios[i] < 0.0f, "Reverse gear ratios must be less than zero", false);
|
||||
}
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(ratios[neutralGear] == 0.0f, "Neutral gear ratio must be equal to zero", false);
|
||||
}
|
||||
for (PxU32 i = neutralGear + 1; i < nbRatios; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(ratios[i] > 0.0f, "Forward gear ratios must be greater than zero", false);
|
||||
}
|
||||
for (PxU32 i = neutralGear + 2; i < nbRatios; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(ratios[i] < ratios[i - 1], "Forward gear ratios must be a descending sequence of gear ratios", false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct PxVehicleAutoboxParams
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
\brief Value of ( engineRotationSpeed /maxEngineRevs ) that is high enough to increment gear.
|
||||
|
||||
\note When ( engineRotationSpeed / #PxVehicleEngineParams::maxOmega ) > upRatios[currentGear] the autobox will begin
|
||||
a transition to currentGear+1 unless currentGear is the highest possible gear or neutral or reverse.
|
||||
|
||||
<b>Range:</b> [0, 1]<br>
|
||||
*/
|
||||
PxReal upRatios[PxVehicleGearboxParams::eMAX_NB_GEARS];
|
||||
|
||||
/**
|
||||
\brief Value of engineRevs/maxEngineRevs that is low enough to decrement gear.
|
||||
|
||||
\note When ( engineRotationSpeed / #PxVehicleEngineParams::maxOmega) < downRatios[currentGear] the autobox will begin
|
||||
a transition to currentGear-1 unless currentGear is first gear or neutral or reverse.
|
||||
|
||||
<b>Range:</b> [0, 1]<br>
|
||||
*/
|
||||
PxReal downRatios[PxVehicleGearboxParams::eMAX_NB_GEARS];
|
||||
|
||||
/**
|
||||
\brief Set the latency time of the autobox.
|
||||
|
||||
\note Latency time is the minimum time that must pass between each gear change that is initiated by the autobox.
|
||||
The auto-box will only attempt to initiate another gear change up or down if the simulation time that has passed since the most recent
|
||||
automated gear change is greater than the specified latency.
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> time
|
||||
*/
|
||||
PxReal latency;
|
||||
|
||||
PX_FORCE_INLINE PxVehicleAutoboxParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PX_UNUSED(srcScale);
|
||||
PX_UNUSED(trgScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid(const PxVehicleGearboxParams& gearboxParams) const
|
||||
{
|
||||
if (!gearboxParams.isValid())
|
||||
return false;
|
||||
|
||||
for (PxU32 i = gearboxParams.neutralGear + 1; i < gearboxParams.nbRatios-1; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(upRatios[i] >= 0.0f, "PxVehicleAutoboxParams.upRatios must be greater than or equal to zero", false);
|
||||
}
|
||||
for (PxU32 i = gearboxParams.neutralGear + 2; i < gearboxParams.nbRatios; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(downRatios[i] >= 0.0f, "PxVehicleAutoboxParams.downRatios must be greater than or equal to zero", false);
|
||||
}
|
||||
PX_CHECK_AND_RETURN_VAL(latency >= 0.0f, "PxVehicleAutoboxParams.latency must be greater than or equal to zero", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\deprecated This API was introduced with the new Vehicle API for transition purposes but will be removed in a future version.
|
||||
*/
|
||||
struct PX_DEPRECATED PxVehicleFourWheelDriveDifferentialLegacyParams
|
||||
{
|
||||
public:
|
||||
|
||||
enum Enum
|
||||
{
|
||||
eDIFF_TYPE_LS_4WD, //limited slip differential for car with 4 driven wheels
|
||||
eDIFF_TYPE_LS_FRONTWD, //limited slip differential for car with front-wheel drive
|
||||
eDIFF_TYPE_LS_REARWD, //limited slip differential for car with rear-wheel drive
|
||||
eMAX_NB_DIFF_TYPES
|
||||
};
|
||||
|
||||
/**
|
||||
\brief The two front wheels are specified by the array frontWheelIds.
|
||||
\note The states eDIFF_TYPE_LS_4WD, eDIFF_TYPE_LS_FRONTWD require knowledge of the front wheels
|
||||
to allow torque splits between front and rear axles as well as torque splits across the front axle.
|
||||
\note frontWheelIds[0] should specify the wheel on the front axle that is negatively placed on the lateral axis.
|
||||
\note frontWheelIds[1] should specify the wheel on the front axle that is positively placed on the lateral axis.
|
||||
\note If #frontNegPosSplit > 0.5, more torque will be delivered to the wheel specified by frontWheelIds[0] than to the wheel
|
||||
specified by frontWheelIds[1]. The converse is true if #frontNegPosSplit < 0.5.
|
||||
*/
|
||||
PxU32 frontWheelIds[2];
|
||||
|
||||
|
||||
/**
|
||||
\brief The two rear wheels are specified by the array rearWheelIds.
|
||||
\note The states eDIFF_TYPE_LS_4WD, eDIFF_TYPE_LS_REARWD require knowledge of the rear wheels
|
||||
to allow torque splits between front and rear axles as well as torque splits across the rear axle.
|
||||
\note rearWheelIds[0] should specify the wheel on the rear axle that is negatively placed on the lateral axis.
|
||||
\note rearWheelIds[1] should specify the wheel on the rear axle that is positively placed on the lateral axis.
|
||||
\note If #rearNegPosSplit > 0.5, more torque will be delivered to the wheel specified by rearWheelIds[0] than to the wheel
|
||||
specified by rearWheelIds[1]. The converse is true if #rearNegPosSplit < 0.5.
|
||||
*/
|
||||
PxU32 rearWheelIds[2];
|
||||
|
||||
/**
|
||||
\brief Ratio of torque split between front and rear wheels (>0.5 means more front, <0.5 means more to rear).
|
||||
|
||||
\note Only applied to DIFF_TYPE_LS_4WD
|
||||
|
||||
<b>Range:</b> [0, 1]<br>
|
||||
*/
|
||||
PxReal frontRearSplit;
|
||||
|
||||
/**
|
||||
\brief Ratio of torque split between front-negative and front-positive wheels (>0.5 means more to #frontWheelIds[0], <0.5 means more to #frontWheelIds[1]).
|
||||
|
||||
\note Only applied to DIFF_TYPE_LS_4WD and DIFF_TYPE_LS_FRONTWD
|
||||
|
||||
<b>Range:</b> [0, 1]<br>
|
||||
*/
|
||||
PxReal frontNegPosSplit;
|
||||
|
||||
/**
|
||||
\brief Ratio of torque split between rear-negative wheel and rear-positive wheels (>0.5 means more to #rearWheelIds[0], <0.5 means more to #rearWheelIds[1]).
|
||||
|
||||
\note Only applied to DIFF_TYPE_LS_4WD and eDIFF_TYPE_LS_REARWD
|
||||
|
||||
<b>Range:</b> [0, 1]<br>
|
||||
*/
|
||||
PxReal rearNegPosSplit;
|
||||
|
||||
/**
|
||||
\brief Maximum allowed ratio of average front wheel rotation speed and rear wheel rotation speeds.
|
||||
The differential will divert more torque to the slower wheels when the bias is exceeded.
|
||||
|
||||
\note Only applied to DIFF_TYPE_LS_4WD
|
||||
|
||||
<b>Range:</b> [1, inf)<br>
|
||||
*/
|
||||
PxReal centerBias;
|
||||
|
||||
/**
|
||||
\brief Maximum allowed ratio of front-left and front-right wheel rotation speeds.
|
||||
The differential will divert more torque to the slower wheel when the bias is exceeded.
|
||||
|
||||
\note Only applied to DIFF_TYPE_LS_4WD and DIFF_TYPE_LS_FRONTWD
|
||||
|
||||
<b>Range:</b> [1, inf)<br>
|
||||
*/
|
||||
PxReal frontBias;
|
||||
|
||||
/**
|
||||
\brief Maximum allowed ratio of rear-left and rear-right wheel rotation speeds.
|
||||
The differential will divert more torque to the slower wheel when the bias is exceeded.
|
||||
|
||||
\note Only applied to DIFF_TYPE_LS_4WD and DIFF_TYPE_LS_REARWD
|
||||
|
||||
<b>Range:</b> [1, inf)<br>
|
||||
*/
|
||||
PxReal rearBias;
|
||||
|
||||
/**
|
||||
\brief Type of differential.
|
||||
|
||||
<b>Range:</b> [DIFF_TYPE_LS_4WD, eDIFF_TYPE_LS_REARWD]<br>
|
||||
*/
|
||||
Enum type;
|
||||
|
||||
PX_FORCE_INLINE PxVehicleFourWheelDriveDifferentialLegacyParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PX_UNUSED(srcScale);
|
||||
PX_UNUSED(trgScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
|
||||
{
|
||||
PX_UNUSED(axleDesc);
|
||||
PX_CHECK_AND_RETURN_VAL((axleDesc.getAxle(frontWheelIds[0]) != 0xffffffff) && (axleDesc.getAxle(frontWheelIds[0])== axleDesc.getAxle(frontWheelIds[1])), "frontWheelIds[0] and frontWheelIds[1] must reference wheels on the same axle", false);
|
||||
PX_CHECK_AND_RETURN_VAL((axleDesc.getAxle(rearWheelIds[0]) != 0xffffffff) && (axleDesc.getAxle(rearWheelIds[0]) == axleDesc.getAxle(rearWheelIds[1])), "rearWheelIds[0] and rearWheelIds[1] must reference wheels on the same axle", false);
|
||||
PX_CHECK_AND_RETURN_VAL(frontRearSplit <= 1.0f && frontRearSplit >= 0.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.frontRearSplit must be in range [0,1]", false);
|
||||
PX_CHECK_AND_RETURN_VAL(frontNegPosSplit <= 1.0f && frontNegPosSplit >= 0.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.frontNegPosSplit must be in range [0,1]", false);
|
||||
PX_CHECK_AND_RETURN_VAL(rearNegPosSplit <= 1.0f && rearNegPosSplit >= 0.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.rearNegPosSplit must be in range [0,1]", false);
|
||||
PX_CHECK_AND_RETURN_VAL(centerBias >= 1.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.centerBias must be greater than or equal to 1.0f", false);
|
||||
PX_CHECK_AND_RETURN_VAL(frontBias >= 1.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.frontBias must be greater than or equal to 1.0f", false);
|
||||
PX_CHECK_AND_RETURN_VAL(rearBias >= 1.0f, "PxVehicleLegacyFourWheelDriveDifferentialParams.rearBias must be greater than or equal to 1.0f", false);
|
||||
PX_CHECK_AND_RETURN_VAL(type < PxVehicleFourWheelDriveDifferentialLegacyParams::eMAX_NB_DIFF_TYPES, "PxVehicleLegacyFourWheelDriveDifferentialParams.type has illegal value", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief PxVehicleMultiWheelDriveDifferentialParams specifies the wheels that are to receive drive torque from the differential
|
||||
and the division of torque between the wheels that are connected to the differential.
|
||||
*/
|
||||
struct PxVehicleMultiWheelDriveDifferentialParams
|
||||
{
|
||||
/**
|
||||
\brief torqueRatios describes the fraction of torque delivered to each wheel through the differential.
|
||||
\note Wheels not connected to the differential must receive zero torque.
|
||||
\note Wheels connected to the differential may receive a non-zero torque.
|
||||
\note The sum of the absolute of the ratios of all wheels must equal to 1.0.
|
||||
\note A negative torque ratio simulates a wheel with negative gearing applied.
|
||||
|
||||
<b>Range:</b> [1, -1]<br>
|
||||
*/
|
||||
PxReal torqueRatios[PxVehicleLimits::eMAX_NB_WHEELS];
|
||||
|
||||
/**
|
||||
\brief aveWheelSpeedRatios describes the contribution of each wheel to the average wheel speed measured at the clutch.
|
||||
\note Wheels not connected to the differential do not contribute to the average wheel speed measured at the clutch.
|
||||
\note Wheels connected to the differential may delivere a non-zero contribution to the average wheel speed measured at the clutch.
|
||||
\note The sum of all ratios of all wheels must equal to 1.0.
|
||||
|
||||
<b>Range:</b> [0, 1]<br>
|
||||
*/
|
||||
PxReal aveWheelSpeedRatios[PxVehicleLimits::eMAX_NB_WHEELS];
|
||||
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleMultiWheelDriveDifferentialParams));
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVehicleMultiWheelDriveDifferentialParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PX_UNUSED(srcScale);
|
||||
PX_UNUSED(trgScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
|
||||
{
|
||||
if (!axleDesc.isValid())
|
||||
return false;
|
||||
PxReal aveWheelSpeedSum = 0.0f;
|
||||
PxReal torqueRatioSum = 0.0f;
|
||||
for (PxU32 i = 0; i < axleDesc.nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDesc.wheelIdsInAxleOrder[i];
|
||||
PX_CHECK_AND_RETURN_VAL(PxAbs(torqueRatios[wheelId]) <= 1.0f, "PxVehicleMultiWheelDriveDifferentialParams.torqueRatios[i] must be in range [-1, 1] for all wheels connected to the differential", false);
|
||||
PX_CHECK_AND_RETURN_VAL(aveWheelSpeedRatios[wheelId] >= 0.0f && aveWheelSpeedRatios[wheelId] <= 1.0f, "PxVehicleMultiWheelDriveDifferentialParams.aveWheelSpeedRatios[i] must be in range [0, 1] for all wheels connected to the differential", false);
|
||||
aveWheelSpeedSum += aveWheelSpeedRatios[wheelId];
|
||||
torqueRatioSum += PxAbs(torqueRatios[wheelId]);
|
||||
}
|
||||
PX_CHECK_AND_RETURN_VAL(aveWheelSpeedSum >= 0.99f && aveWheelSpeedSum <= 1.01f, "Sum of PxVehicleMultiWheelDriveDifferentialParams.aveWheelSpeedRatios[i] must be 1.0.", false);
|
||||
PX_CHECK_AND_RETURN_VAL(torqueRatioSum >= 0.99f && torqueRatioSum <= 1.01f, "Sum of PxVehicleMultiWheelDriveDifferentialParams.torqueRatios[i] must be 1.0.", false);
|
||||
PX_UNUSED(aveWheelSpeedSum);
|
||||
PX_UNUSED(torqueRatioSum);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A special value that indicates instantaneous resolution of a slip that exceeds a differential bias.
|
||||
*/
|
||||
#define PX_VEHICLE_FOUR_WHEEL_DIFFERENTIAL_MAXIMUM_STRENGTH PX_MAX_F32
|
||||
|
||||
/**
|
||||
\brief PxVehicleFourWheelDriveDifferentialParams specifies the wheels that are to receive drive torque from the differential
|
||||
and the division of torque between the wheels that are connected to the differential. Additionally, it specifies the biases
|
||||
and strength of a limited slip differential that operates on two wheels specified as front wheels and two wheels specified
|
||||
as rear wheels.
|
||||
*/
|
||||
struct PxVehicleFourWheelDriveDifferentialParams : public PxVehicleMultiWheelDriveDifferentialParams
|
||||
{
|
||||
/**
|
||||
\brief The ids of the two wheels considered by the differential to be the front pair.
|
||||
\note When the ratio of the rotational speeds of the front wheels exceeds frontBias, drive torque is diverted so
|
||||
that the ratio approaches the value specified by frontTarget. When the bias is not breached, the drive torque
|
||||
is specified by the corresponding entries in PxVehicleMultiWheelDriveDifferentialParams::torqueRatios.
|
||||
*/
|
||||
PxU32 frontWheelIds[2];
|
||||
|
||||
/**
|
||||
\brief The ids of the two wheels considered by the differential to be the rear pair.
|
||||
\note When the ratio of the rotational speeds of the rear wheels exceeds rearBias, drive torque is diverted so
|
||||
that the ratio approaches the value specified by rearTarget. When the bias is not breached, the drive torque
|
||||
is specified by the corresponding entries in PxVehicleMultiWheelDriveDifferentialParams::torqueRatios.
|
||||
*/
|
||||
PxU32 rearWheelIds[2];
|
||||
|
||||
/**
|
||||
\brief The parameter frontBias specifies the maximum angular speed ratio of the two front wheels specified by frontWheelIds[2].
|
||||
\note If frontBias has value 0.0, the differential will not try to enforce any relationship between the rotational speeds of the two front wheels.
|
||||
\note If frontBias has value 0.0, the torque split between the front wheels is specified by the array torqueRatios.
|
||||
\note frontBias must have value 0.0 (deactivated limited slip) or be greater than 1.0 (activated limited slip) or be equal to 1.0 (locked axle).
|
||||
\note If frontBias has value greater than or equal to 1.0 then the array frontWheelIds must be specified and the corresponding entries of
|
||||
the isConnected[] array must be set true.
|
||||
\note If frontBias has value greater than or equal to 1.0 then frontTarget must also be specified.
|
||||
\note A locked axle may be achieved by setting frontBias and frontTarget to 1.0.
|
||||
\note A limited slip differential may be achieved by setting frontBias > 1.0 and frontBias > frontTarget > 1.0.
|
||||
*/
|
||||
PxReal frontBias;
|
||||
|
||||
/**
|
||||
\brief The parameter frontTarget specifies the target rotational speed ratio of the two front wheels in the event that the ratio exceeds frontBias and frontBias
|
||||
is configured for an activated limited slip or locked axle.
|
||||
\note frontTarget must be less than frontBias and greater than 1.0 to implement a limited slip differential.
|
||||
\note Set frontTarget and frontBias to 1.0 to implement a locked axle.
|
||||
*/
|
||||
PxReal frontTarget;
|
||||
|
||||
/**
|
||||
\brief The parameter rearBias specifies the maximum angular speed ratio of the two rear wheels specified by rearWheelIds[2].
|
||||
\note If rearBias has value 0.0, the differential will not try to enforce any relationship between the rotational speeds of the two rear wheels.
|
||||
\note If rearBias has value 0.0, the torque split between the rear wheels is specified by the array torqueRatios.
|
||||
\note rearBias must have value 0.0 (deactivated limited slip) or be greater than 1.0 (activated limited slip) or be equal to 1.0 (locked axle).
|
||||
\note If rearBias has value greater than or equal to 1.0 then the array rearWheelIds must be specified and the corresponding entries of
|
||||
the isConnected[] array must be set true.
|
||||
\note If rearBias has value greater than or equal to 1.0 then rearTarget must also be specified.
|
||||
\note A locked axle may be achieved by setting rearBias and rearTarget to 1.0.
|
||||
\note A limited slip differential may be achieved by setting rearBias > 1.0 and rearBias > rearTarget > 1.0
|
||||
*/
|
||||
PxReal rearBias;
|
||||
|
||||
/**
|
||||
\brief The parameter rearTarget specifies the target rotational speed ratio of the two rear wheels in the event that the ratio exceeds rearBias and rearBias
|
||||
is configured for an activated limited slip or locked axle.
|
||||
\note rearTarget must be less than rearBias and greater than 1.0 to implement a limited slip differential.
|
||||
\note Set rearTarget and rearBias to 1.0 to implement a locked axle.
|
||||
*/
|
||||
PxReal rearTarget;
|
||||
|
||||
/**
|
||||
\brief The parameter centerBias specifies the maximum angular speed ratio of the sum of the two front wheels and the sum of the two rear wheels,
|
||||
as specified by frontWheelIds[2] and rearWheelIds[2].
|
||||
\note If centerBias has value 0.0, the differential will not try to enforce any relationship between the rotational speeds of the front and rear wheels.
|
||||
\note If centerBias has value 0.0, the torque split between the front and rear rear wheels is specified by the array torqueRatios.
|
||||
\note centerBias must have value 0.0 (deactivated limited slip) or be greater than 1.0 (activated limited slip) or be equal to 1.0 (locked).
|
||||
\note If centerBias has value greater than or equal to 1.0 then the arrays frontWheelIds and rearWheelIds must be specified and the corresponding entries of
|
||||
the isConnected[] array must be set true.
|
||||
\note If centerBias has value greater than or equal to 1.0 then centerTarget must also be specified.
|
||||
\note A locked front/rear differential may be achieved by setting centerBias and centerTarget to 1.0.
|
||||
\note A limited slip differential may be achieved by setting centerBias > 1.0 and centerBias > centerTarget > 1.0
|
||||
*/
|
||||
PxReal centerBias;
|
||||
|
||||
/**
|
||||
\brief The parameter centerTarget specifies the target rotational speed ratio of the sum of the two front wheels and the sum of the two rear wheels
|
||||
in the event that the ratio exceeds centerBias and centerBias is configured for an activated limited slip.
|
||||
\note centerTarget must be less than centerBias and greater than 1.0 to implement a limited slip differential.
|
||||
\note Set centerTarget and centerBias to 1.0 to implement a locked differential.
|
||||
*/
|
||||
PxReal centerTarget;
|
||||
|
||||
/**
|
||||
\brief The parameter rate specifies how quickly the ratio of rotational speeds approaches the target rotational speed ratio.
|
||||
\note strength must be in range [0,PX_VEHICLE_FOUR_WHEEL_DIFF_MAXIMUM_STRENGTH].
|
||||
\note The ratio of rotational speeds is decremented each update by rate*dt until the ratio is equal to the target ratio.
|
||||
\note A value of 0 will result in a deactivated limited slip.
|
||||
\note A value of PX_VEHICLE_FOUR_WHEEL_DIFF_MAXIMUM_STRENGTH will result in instantaneous correction of the rotational speed ratios.
|
||||
*/
|
||||
PxReal rate;
|
||||
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxVehicleMultiWheelDriveDifferentialParams::setToDefault();
|
||||
frontBias = 0.0f;
|
||||
rearBias = 0.0f;
|
||||
centerBias = 0.0f;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
|
||||
{
|
||||
if (!PxVehicleMultiWheelDriveDifferentialParams::isValid(axleDesc))
|
||||
return false;
|
||||
|
||||
PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) ||
|
||||
(centerBias > 1.0f &&
|
||||
frontWheelIds[0] < axleDesc.nbWheels && frontWheelIds[1] < axleDesc.nbWheels &&
|
||||
rearWheelIds[0] < axleDesc.nbWheels && rearWheelIds[1] < axleDesc.nbWheels),
|
||||
"PxVehicleFourWheelDriveDifferentialParams:: centreBias is enabled but the frontWheelIds and rearWheelIds are not configured correctly.", false);
|
||||
PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) ||
|
||||
(centerBias > 1.0f &&
|
||||
frontWheelIds[0] != frontWheelIds[1] && frontWheelIds[0] != rearWheelIds[0] && frontWheelIds[0] != rearWheelIds[1] &&
|
||||
frontWheelIds[1] != rearWheelIds[0] && frontWheelIds[1] != rearWheelIds[1] &&
|
||||
rearWheelIds[0] != rearWheelIds[1]),
|
||||
"PxVehicleFourWheelDriveDifferentialParams:: centreBias is enabled but the frontWheelIds and rearWheelIds are not configured correctly.", false);
|
||||
PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) ||
|
||||
(centerBias > 1.0f &&
|
||||
torqueRatios[frontWheelIds[0]] != 0.0f && torqueRatios[frontWheelIds[1]] != 0.0f && torqueRatios[rearWheelIds[0]] != 0.0f && torqueRatios[rearWheelIds[1]] != 0.0f),
|
||||
"PxVehicleFourWheelDriveDifferentialParams:: centreBias is enabled but the front and rear wheels are not connected.", false);
|
||||
|
||||
PX_CHECK_AND_RETURN_VAL((0.0f == rearBias) ||
|
||||
(rearBias > 1.0f && rearWheelIds[0] < axleDesc.nbWheels && rearWheelIds[1] < axleDesc.nbWheels),
|
||||
"PxVehicleFourWheelDriveDifferentialParams:: rearBias is enabled but the rearWheelIds are not configured correctly.", false);
|
||||
PX_CHECK_AND_RETURN_VAL((0.0f == rearBias) ||
|
||||
(rearBias > 1.0f && rearWheelIds[0] != rearWheelIds[1]),
|
||||
"PxVehicleFourWheelDriveDifferentialParams:: rearBias is enabled but the rearWheelIds are not configured correctly.", false);
|
||||
PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) ||
|
||||
(rearBias > 1.0f && torqueRatios[rearWheelIds[0]] != 0.0f && torqueRatios[rearWheelIds[1]] != 0.0f),
|
||||
"PxVehicleFourWheelDriveDifferentialParams:: rearBias is enabled but the rear wheels are not connected.", false);
|
||||
|
||||
PX_CHECK_AND_RETURN_VAL((0.0f == frontBias) ||
|
||||
(frontBias > 1.0f && frontWheelIds[0] < axleDesc.nbWheels && frontWheelIds[1] < axleDesc.nbWheels),
|
||||
"PxVehicleFourWheelDriveDifferentialParams:: frontBias is enabled but the frontWheelIds are not configured correctly.", false);
|
||||
PX_CHECK_AND_RETURN_VAL((0.0f == frontBias) ||
|
||||
(frontBias > 1.0f && frontWheelIds[0] != frontWheelIds[1]),
|
||||
"PxVehicleFourWheelDriveDifferentialParams:: frontBias is enabled but the frontWheelIds are not configured correctly.", false);
|
||||
PX_CHECK_AND_RETURN_VAL((0.0f == frontBias) ||
|
||||
(frontBias > 1.0f && torqueRatios[frontWheelIds[0]] != 0.0f && frontWheelIds[frontWheelIds[1]]),
|
||||
"PxVehicleFourWheelDriveDifferentialParams:: frontBias is enabled but the front wheels are not connected.", false);
|
||||
|
||||
PX_CHECK_AND_RETURN_VAL(((0.0f == frontBias) && (0.0f == rearBias) && (0.0f == centerBias)) || (rate >= 0.0f),
|
||||
"PxVehicleFourWheelDriveDifferentialParams:: strength must be greater than or equal to zero", false);
|
||||
|
||||
PX_CHECK_AND_RETURN_VAL((0.0f == frontBias) || ((1.0f == frontTarget && 1.0f == rearTarget) || (frontTarget > 1.0f && frontTarget < frontBias)),
|
||||
"PxVehicleFourWheelDriveDifferentialParams: frontBias is enabled but frontTarget not in range (1.0f, frontBias)", false);
|
||||
PX_CHECK_AND_RETURN_VAL((0.0f == rearBias) || ((1.0f == rearTarget && 1.0f == rearBias) || (rearTarget > 1.0f && rearTarget < rearBias)),
|
||||
"PxVehicleFourWheelDriveDifferentialParams: rearBias is enabled but rearTarget not in range (1.0f, rearBias)", false);
|
||||
PX_CHECK_AND_RETURN_VAL((0.0f == centerBias) || ((1.0f == centerTarget && 1.0f == centerBias) || (centerTarget > 1.0f && centerTarget < centerBias)),
|
||||
"PxVehicleFourWheelDriveDifferentialParams: centerBias is enabled but centerTarget not in range (1.0f, centerBias)", false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVehicleFourWheelDriveDifferentialParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PX_UNUSED(srcScale);
|
||||
PX_UNUSED(trgScale);
|
||||
PxVehicleFourWheelDriveDifferentialParams r = *this;
|
||||
static_cast<PxVehicleMultiWheelDriveDifferentialParams&>(r) = PxVehicleMultiWheelDriveDifferentialParams::transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A description of a tank differential.
|
||||
\note The wheels on a tank may be connected to the differential or not connected to the differential.
|
||||
\note The wheels on a tank track may be connected to a tank track or not connected to a tank track.
|
||||
\note Wheels connected to the differential but not to a tank track receive the torque split specified by the
|
||||
corresponding elements of PxVehicleMultiWheelDriveDifferentialParams::torqueRatios[].
|
||||
\note Wheels connected to a tank track but not to the differential receive no torque from the engine.
|
||||
\note Wheels connected to a tank track and to the differential receive the torque split specified by the
|
||||
corresponding elements of PxVehicleMultiWheelDriveDifferentialParams::torqueRatios[] multiplied by the corresponding
|
||||
thrust controller value. If the thrust controller has a negative value, the wheels will receive a torque that is negative
|
||||
with respect to the gearing ratio.
|
||||
\note The wheels in each tank track have a constraint applied to them to enforce the rule that they all have the same longitudinal speed
|
||||
at the contact point between the wheel and the tank track.
|
||||
*/
|
||||
struct PxVehicleTankDriveDifferentialParams : public PxVehicleMultiWheelDriveDifferentialParams
|
||||
{
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxVehicleMultiWheelDriveDifferentialParams::setToDefault();
|
||||
nbTracks = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Add a tank track by specifying the number of wheels along the track and an array of wheel ids specifying each wheel in the tank track.
|
||||
\param[in] nbWheelsInTrackToAdd is the number of wheels in the track to be added.
|
||||
\param[in] wheelIdsInTrackToAdd is an array of wheel ids specifying all the wheels in the track to be added.
|
||||
\param[in] thrustControllerIndex specifies the index of the thrust controller that will be used to control the tank track.
|
||||
*/
|
||||
void addTankTrack(const PxU32 nbWheelsInTrackToAdd, const PxU32* const wheelIdsInTrackToAdd, const PxU32 thrustControllerIndex)
|
||||
{
|
||||
PxU32 trackToWheelIdsOffset = nbTracks ? trackToWheelIds[nbTracks - 1] + nbWheelsPerTrack[nbTracks - 1] : 0;
|
||||
PX_ASSERT((trackToWheelIdsOffset + nbWheelsInTrackToAdd) <= PxVehicleLimits::eMAX_NB_WHEELS);
|
||||
PX_ASSERT(nbTracks < PxVehicleLimits::eMAX_NB_WHEELS);
|
||||
PX_ASSERT(thrustControllerIndex < 2);
|
||||
nbWheelsPerTrack[nbTracks] = nbWheelsInTrackToAdd;
|
||||
thrustIdPerTrack[nbTracks] = thrustControllerIndex;
|
||||
trackToWheelIds[nbTracks] = trackToWheelIdsOffset;
|
||||
for (PxU32 i = 0; i < nbWheelsInTrackToAdd; i++)
|
||||
{
|
||||
wheelIdsInTrackOrder[trackToWheelIdsOffset + i] = wheelIdsInTrackToAdd[i];
|
||||
}
|
||||
nbTracks++;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the number of tracks.
|
||||
\return The number of tracks.
|
||||
\see getNbWheelsInTrack()
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getNbTracks() const
|
||||
{
|
||||
return nbTracks;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the number of wheels in the ith track.
|
||||
\param[in] i specifies the track to be queried for its wheel count.
|
||||
\return The number of wheels in the specified track.
|
||||
\see getWheelInTrack()
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getNbWheelsInTrack(const PxU32 i) const
|
||||
{
|
||||
return nbWheelsPerTrack[i];
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the array of all wheels in the ith track.
|
||||
\param[in] i specifies the track to be queried for its wheels.
|
||||
\return The array of wheels in the specified track.
|
||||
*/
|
||||
PX_FORCE_INLINE const PxU32* getWheelsInTrack(const PxU32 i) const
|
||||
{
|
||||
return (wheelIdsInTrackOrder + trackToWheelIds[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the wheel id of the jth wheel in the ith track.
|
||||
\param[in] j specifies that the wheel id to be returned is the jth wheel in the list of wheels on the specified track.
|
||||
\param[in] i specifies the track to be queried.
|
||||
\return The wheel id of the jth wheel in the ith track.
|
||||
\see getNbWheelsInTrack()
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getWheelInTrack(const PxU32 j, const PxU32 i) const
|
||||
{
|
||||
return wheelIdsInTrackOrder[trackToWheelIds[i] + j];
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the index of the thrust controller that will control a specified track.
|
||||
\param[in] i specifies the track to be queried for its thrust controller index
|
||||
\return The index of the thrust controller that will control the ith track.
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getThrustControllerIndex(const PxU32 i) const
|
||||
{
|
||||
return thrustIdPerTrack[i];
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVehicleTankDriveDifferentialParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PX_UNUSED(srcScale);
|
||||
PX_UNUSED(trgScale);
|
||||
PxVehicleTankDriveDifferentialParams r = *this;
|
||||
static_cast<PxVehicleMultiWheelDriveDifferentialParams&>(r) = PxVehicleMultiWheelDriveDifferentialParams::transformAndScale(srcFrame, trgFrame, srcScale, trgScale);
|
||||
return r;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
|
||||
{
|
||||
if (!PxVehicleMultiWheelDriveDifferentialParams::isValid(axleDesc))
|
||||
return false;
|
||||
|
||||
PX_CHECK_AND_RETURN_VAL(nbTracks <= PxVehicleLimits::eMAX_NB_WHEELS, "PxVehicleTankDriveDifferentialParams.nbTracks must not exceed PxVehicleLimits::eMAX_NB_WHEELS", false);
|
||||
|
||||
const PxU32 nbWheelsInTracksSize = nbTracks ? trackToWheelIds[nbTracks - 1] + nbWheelsPerTrack[nbTracks - 1] : 0;
|
||||
PX_UNUSED(nbWheelsInTracksSize);
|
||||
PX_CHECK_AND_RETURN_VAL(nbWheelsInTracksSize <= PxVehicleLimits::eMAX_NB_WHEELS, "PxVehicleTankDriveDifferentialParams.nbWheelsInTracks must not exceed PxVehicleLimits::eMAX_NB_WHEELS", false);
|
||||
for (PxU32 i = 0; i < nbTracks; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(thrustIdPerTrack[i] < 2, "PxVehicleTankDriveDifferentialParams.thrustId must be less than 2", false);
|
||||
}
|
||||
|
||||
for (PxU32 i = 0; i < axleDesc.nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDesc.wheelIdsInAxleOrder[i];
|
||||
PxU32 count = 0;
|
||||
for (PxU32 j = 0; j < nbTracks; j++)
|
||||
{
|
||||
const PxU32 nbWheels = getNbWheelsInTrack(j);
|
||||
const PxU32* wheelIds = getWheelsInTrack(j);
|
||||
|
||||
for (PxU32 k = 0; k < nbWheels; k++)
|
||||
{
|
||||
if (wheelIds[k] == wheelId)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
PX_CHECK_AND_RETURN_VAL(count <= 1, "PxVehicleTankDriveDifferentialParams - a wheel cannot be in more than one tank track", false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
PxU32 nbTracks; //!< The number of tracks
|
||||
PxU32 thrustIdPerTrack[PxVehicleLimits::eMAX_NB_WHEELS]; //!< The id of the thrust that will control the track. Must have value 0 or 1.
|
||||
PxU32 nbWheelsPerTrack[PxVehicleLimits::eMAX_NB_WHEELS]; //!< The number of wheels in each track
|
||||
PxU32 trackToWheelIds[PxVehicleLimits::eMAX_NB_WHEELS]; //!< The list of wheel ids for the ith tank track begins at wheelIdsInTrackOrder[trackToWheelIds[i]]
|
||||
|
||||
PxU32 wheelIdsInTrackOrder[PxVehicleLimits::eMAX_NB_WHEELS];//!< The list of all wheel ids in all tracks
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
|
||||
284
engine/third_party/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainStates.h
vendored
Normal file
284
engine/third_party/physx/include/vehicle2/drivetrain/PxVehicleDrivetrainStates.h
vendored
Normal file
@@ -0,0 +1,284 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "vehicle2/commands/PxVehicleCommandStates.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
struct PxVehicleClutchCommandResponseState
|
||||
{
|
||||
PxReal normalisedCommandResponse;
|
||||
PxReal commandResponse;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleClutchCommandResponseState));
|
||||
}
|
||||
};
|
||||
|
||||
struct PxVehicleEngineDriveThrottleCommandResponseState
|
||||
{
|
||||
PxReal commandResponse;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleEngineDriveThrottleCommandResponseState));
|
||||
}
|
||||
};
|
||||
|
||||
struct PxVehicleEngineState
|
||||
{
|
||||
/**
|
||||
\brief The rotation speed of the engine (radians per second).
|
||||
|
||||
<b>Unit:</b> radians / time
|
||||
*/
|
||||
PxReal rotationSpeed;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleEngineState));
|
||||
}
|
||||
};
|
||||
|
||||
#define PX_VEHICLE_NO_GEAR_SWITCH_PENDING -1.0f
|
||||
#define PX_VEHICLE_GEAR_SWITCH_INITIATED -2.0f
|
||||
|
||||
struct PxVehicleGearboxState
|
||||
{
|
||||
/**
|
||||
\brief Current gear
|
||||
*/
|
||||
PxU32 currentGear;
|
||||
|
||||
/**
|
||||
\brief Target gear (different from current gear if a gear change is underway)
|
||||
*/
|
||||
PxU32 targetGear;
|
||||
|
||||
/**
|
||||
\brief Reported time that has passed since gear change started.
|
||||
|
||||
The special value PX_VEHICLE_NO_GEAR_SWITCH_PENDING denotes that there is currently
|
||||
no gear change underway.
|
||||
|
||||
If a gear switch was initiated, the special value PX_VEHICLE_GEAR_SWITCH_INITIATED
|
||||
will be used temporarily but get translated to 0 in the gearbox update immediately.
|
||||
This state might only get encountered, if the vehicle component update is split into
|
||||
multiple sequences that do not run in one go.
|
||||
|
||||
<b>Unit:</b> time
|
||||
*/
|
||||
PxReal gearSwitchTime;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
currentGear = 0;
|
||||
targetGear = 0;
|
||||
gearSwitchTime = PX_VEHICLE_NO_GEAR_SWITCH_PENDING;
|
||||
}
|
||||
};
|
||||
|
||||
#define PX_VEHICLE_UNSPECIFIED_TIME_SINCE_LAST_SHIFT PX_MAX_F32
|
||||
|
||||
struct PxVehicleAutoboxState
|
||||
{
|
||||
/**
|
||||
\brief Time that has lapsed since the last autobox gear shift.
|
||||
|
||||
<b>Unit:</b> time
|
||||
*/
|
||||
PxReal timeSinceLastShift;
|
||||
|
||||
/**
|
||||
\brief Describes whether a gear shift triggered by the autobox is still in flight.
|
||||
*/
|
||||
bool activeAutoboxGearShift;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
timeSinceLastShift = PX_VEHICLE_UNSPECIFIED_TIME_SINCE_LAST_SHIFT;
|
||||
activeAutoboxGearShift = false;
|
||||
}
|
||||
};
|
||||
|
||||
struct PxVehicleDifferentialState
|
||||
{
|
||||
/**
|
||||
\brief A list of wheel indices that are connected to the differential.
|
||||
*/
|
||||
PxU32 connectedWheels[PxVehicleLimits::eMAX_NB_WHEELS];
|
||||
|
||||
/**
|
||||
\brief The number of wheels that are connected to the differential.
|
||||
*/
|
||||
PxU32 nbConnectedWheels;
|
||||
|
||||
/**
|
||||
\brief The fraction of available torque that is delivered to each wheel through the differential.
|
||||
\note If a wheel is not connected to the differential then the fraction of available torque delivered to that wheel will be zero.
|
||||
\note A negative torque ratio for a wheel indicates a negative gearing is to be applied to that wheel.
|
||||
\note The sum of the absolute value of each fraction must equal 1.0.
|
||||
*/
|
||||
PxReal torqueRatiosAllWheels[PxVehicleLimits::eMAX_NB_WHEELS];
|
||||
|
||||
/**
|
||||
\brief The contribution of each wheel to the average wheel rotation speed measured at the clutch.
|
||||
\note If a wheel is not connected to the differential then the contribution to the average rotation speed measured at the clutch must be zero.
|
||||
\note The sum of all contributions must equal 1.0.
|
||||
*/
|
||||
PxReal aveWheelSpeedContributionAllWheels[PxVehicleLimits::eMAX_NB_WHEELS];
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleDifferentialState));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Specify groups of wheels that are to be constrained to have pre-determined angular velocity relationship.
|
||||
*/
|
||||
struct PxVehicleWheelConstraintGroupState
|
||||
{
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleWheelConstraintGroupState));
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Add a wheel constraint group by specifying the number of wheels in the group, an array of wheel ids specifying each wheel in the group
|
||||
and a desired rotational speed relationship.
|
||||
\param[in] nbWheelsInGroupToAdd is the number of wheels in the group to be added.
|
||||
\param[in] wheelIdsInGroupToAdd is an array of wheel ids specifying all the wheels in the group to be added.
|
||||
\param[in] constraintMultipliers is an array of constraint multipliers describing the desired relationship of the wheel rotational speeds.
|
||||
\note constraintMultipliers[j] specifies the target rotational speed of the jth wheel in the constraint group as a multiplier of the rotational
|
||||
speed of the zeroth wheel in the group.
|
||||
*/
|
||||
void addConstraintGroup(const PxU32 nbWheelsInGroupToAdd, const PxU32* const wheelIdsInGroupToAdd, const PxF32* constraintMultipliers)
|
||||
{
|
||||
PX_ASSERT((nbWheelsInGroups + nbWheelsInGroupToAdd) < PxVehicleLimits::eMAX_NB_WHEELS);
|
||||
PX_ASSERT(nbGroups < PxVehicleLimits::eMAX_NB_WHEELS);
|
||||
nbWheelsPerGroup[nbGroups] = nbWheelsInGroupToAdd;
|
||||
groupToWheelIds[nbGroups] = nbWheelsInGroups;
|
||||
for (PxU32 i = 0; i < nbWheelsInGroupToAdd; i++)
|
||||
{
|
||||
wheelIdsInGroupOrder[nbWheelsInGroups + i] = wheelIdsInGroupToAdd[i];
|
||||
wheelMultipliersInGroupOrder[nbWheelsInGroups + i] = constraintMultipliers[i];
|
||||
}
|
||||
nbWheelsInGroups += nbWheelsInGroupToAdd;
|
||||
nbGroups++;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the number of wheel constraint groups in the vehicle.
|
||||
\return The number of wheel constraint groups.
|
||||
\see getNbWheelsInConstraintGroup()
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getNbConstraintGroups() const
|
||||
{
|
||||
return nbGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the number of wheels in the ith constraint group.
|
||||
\param[in] i specifies the constraint group to be queried for its wheel count.
|
||||
\return The number of wheels in the specified constraint group.
|
||||
\see getWheelInConstraintGroup()
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getNbWheelsInConstraintGroup(const PxU32 i) const
|
||||
{
|
||||
return nbWheelsPerGroup[i];
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the wheel id of the jth wheel in the ith constraint group.
|
||||
\param[in] j specifies that the wheel id to be returned is the jth wheel in the list of wheels on the specified constraint group.
|
||||
\param[in] i specifies the constraint group to be queried.
|
||||
\return The wheel id of the jth wheel in the ith constraint group.
|
||||
\see getNbWheelsInConstraintGroup()
|
||||
*/
|
||||
PX_FORCE_INLINE PxU32 getWheelInConstraintGroup(const PxU32 j, const PxU32 i) const
|
||||
{
|
||||
return wheelIdsInGroupOrder[groupToWheelIds[i] + j];
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return the constraint multiplier of the jth wheel in the ith constraint group
|
||||
\param[in] j specifies that the wheel id to be returned is the jth wheel in the list of wheels on the specified constraint group.
|
||||
\param[in] i specifies the constraint group to be queried.
|
||||
\return The constraint multiplier of the jth wheel in the ith constraint group.
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal getMultiplierInConstraintGroup(const PxU32 j, const PxU32 i) const
|
||||
{
|
||||
return wheelMultipliersInGroupOrder[groupToWheelIds[i] + j];
|
||||
}
|
||||
|
||||
PxU32 nbGroups; //!< The number of constraint groups in the vehicle
|
||||
PxU32 nbWheelsPerGroup[PxVehicleLimits::eMAX_NB_AXLES]; //!< The number of wheels in each group
|
||||
PxU32 groupToWheelIds[PxVehicleLimits::eMAX_NB_AXLES]; //!< The list of wheel ids for the ith group begins at wheelIdsInGroupOrder[groupToWheelIds[i]]
|
||||
|
||||
PxU32 wheelIdsInGroupOrder[PxVehicleLimits::eMAX_NB_WHEELS]; //!< The list of all wheel ids in constraint groups
|
||||
PxF32 wheelMultipliersInGroupOrder[PxVehicleLimits::eMAX_NB_WHEELS];//!< The constraint multipliers for each constraint group.
|
||||
PxU32 nbWheelsInGroups; //!< The number of wheels in a constraint group.
|
||||
};
|
||||
|
||||
/**
|
||||
\brief The clutch is modelled as two spinning plates with one connected to the wheels through the gearing and the other connected to the engine. The clutch slip is angular speed difference of the two plates.
|
||||
*/
|
||||
struct PxVehicleClutchSlipState
|
||||
{
|
||||
/**
|
||||
\brief The slip at the clutch.
|
||||
|
||||
<b>Unit:</b> radians / time
|
||||
*/
|
||||
PxReal clutchSlip;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleClutchSlipState));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
239
engine/third_party/physx/include/vehicle2/physxActor/PxVehiclePhysXActorComponents.h
vendored
Normal file
239
engine/third_party/physx/include/vehicle2/physxActor/PxVehiclePhysXActorComponents.h
vendored
Normal file
@@ -0,0 +1,239 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "vehicle2/PxVehicleComponent.h"
|
||||
|
||||
#include "vehicle2/wheel/PxVehicleWheelStates.h"
|
||||
|
||||
#include "PxVehiclePhysXActorFunctions.h"
|
||||
#include "PxVehiclePhysXActorStates.h"
|
||||
|
||||
#include "common/PxProfileZone.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Work items at the beginning of an update step for a PhysX actor based vehicle.
|
||||
|
||||
Includes:
|
||||
- Waking the actor up if it is sleeping and a throttle or steer command is issued.
|
||||
- Clearing certain states if the actor is sleeping.
|
||||
- Reading the state from the PhysX actor and copy to the vehicle internal state.
|
||||
|
||||
\see PxVehiclePhysxActorWakeup PxVehiclePhysxActorSleepCheck PxVehicleReadRigidBodyStateFromPhysXActor
|
||||
*/
|
||||
class PxVehiclePhysXActorBeginComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehiclePhysXActorBeginComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehiclePhysXActorBeginComponent() {}
|
||||
|
||||
/**
|
||||
\brief Provide vehicle data items for this component.
|
||||
|
||||
\param[out] axleDescription identifies the wheels on each axle.
|
||||
\param[out] commands are the brake, throttle and steer values that will drive the vehicle.
|
||||
\param[out] transmissionCommands are the target gear and clutch values that will control
|
||||
the transmission. Can be set to NULL if the vehicle does not have a gearbox. If
|
||||
specified, then gearParams and gearState has to be specifed too.
|
||||
\param[out] gearParams The gearbox parameters. Can be set to NULL if the vehicle does
|
||||
not have a gearbox and transmissionCommands is NULL.
|
||||
\param[out] gearState The state of the gearbox. Can be set to NULL if the vehicle does
|
||||
not have a gearbox and transmissionCommands is NULL.
|
||||
\param[out] engineParams The engine parameters. Can be set to NULL if the vehicle does
|
||||
not have an engine. Must be specified, if engineState is specified.
|
||||
\param[out] physxActor is the PxRigidBody instance associated with the vehicle.
|
||||
\param[out] physxSteerState is the previous state of the steer and is used to determine if the
|
||||
steering wheel has changed by comparing with PxVehicleCommandState::steer.
|
||||
\param[out] physxConstraints The state of the suspension limit and low speed tire constraints.
|
||||
If the vehicle actor is sleeping and constraints are active, they will be
|
||||
deactivated and marked as dirty.
|
||||
\param[out] rigidBodyState is the state of the rigid body used by the Vehicle SDK.
|
||||
\param[out] wheelRigidBody1dStates describes the angular speed of each wheel.
|
||||
\param[out] engineState The engine state. Can be set to NULL if the vehicle does
|
||||
not have an engine. If specified, then engineParams has to be specifed too.
|
||||
*/
|
||||
virtual void getDataForPhysXActorBeginComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
const PxVehicleCommandState*& commands,
|
||||
const PxVehicleEngineDriveTransmissionCommandState*& transmissionCommands,
|
||||
const PxVehicleGearboxParams*& gearParams,
|
||||
const PxVehicleGearboxState*& gearState,
|
||||
const PxVehicleEngineParams*& engineParams,
|
||||
PxVehiclePhysXActor*& physxActor,
|
||||
PxVehiclePhysXSteerState*& physxSteerState,
|
||||
PxVehiclePhysXConstraints*& physxConstraints,
|
||||
PxVehicleRigidBodyState*& rigidBodyState,
|
||||
PxVehicleArrayData<PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates,
|
||||
PxVehicleEngineState*& engineState) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(dt);
|
||||
PX_UNUSED(context);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehiclePhysXActorBeginComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
const PxVehicleCommandState* commands;
|
||||
const PxVehicleEngineDriveTransmissionCommandState* transmissionCommands;
|
||||
const PxVehicleGearboxParams* gearParams;
|
||||
const PxVehicleGearboxState* gearState;
|
||||
const PxVehicleEngineParams* engineParams;
|
||||
PxVehiclePhysXActor* physxActor;
|
||||
PxVehiclePhysXSteerState* physxSteerState;
|
||||
PxVehiclePhysXConstraints* physxConstraints;
|
||||
PxVehicleRigidBodyState* rigidBodyState;
|
||||
PxVehicleArrayData<PxVehicleWheelRigidBody1dState> wheelRigidBody1dStates;
|
||||
PxVehicleEngineState* engineState;
|
||||
|
||||
getDataForPhysXActorBeginComponent(axleDescription, commands, transmissionCommands,
|
||||
gearParams, gearState, engineParams,
|
||||
physxActor, physxSteerState, physxConstraints,
|
||||
rigidBodyState, wheelRigidBody1dStates, engineState);
|
||||
|
||||
if (physxActor->rigidBody->getScene()) // Considering case where actor is not in a scene and constraints get solved via immediate mode
|
||||
{
|
||||
PxVehiclePhysxActorWakeup(*commands, transmissionCommands, gearParams, gearState,
|
||||
*physxActor->rigidBody, *physxSteerState);
|
||||
|
||||
if (PxVehiclePhysxActorSleepCheck(*axleDescription, *physxActor->rigidBody, engineParams,
|
||||
*rigidBodyState, *physxConstraints, wheelRigidBody1dStates, engineState))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PxVehicleReadRigidBodyStateFromPhysXActor(*physxActor->rigidBody, *rigidBodyState);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Work items at the end of an update step for a PhysX actor based vehicle.
|
||||
|
||||
Includes:
|
||||
- Writing vehicle internal state to the PhysX actor.
|
||||
- Keeping the vehicle awake if certain criteria are met.
|
||||
*/
|
||||
class PxVehiclePhysXActorEndComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehiclePhysXActorEndComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehiclePhysXActorEndComponent() {}
|
||||
|
||||
/**
|
||||
\brief Provide vehicle data items for this component.
|
||||
|
||||
\param[out] axleDescription identifies the wheels on each axle.
|
||||
\param[out] rigidBodyState is the state of the rigid body used by the Vehicle SDK.
|
||||
\param[out] wheelParams describes the radius, mass etc. of the wheels.
|
||||
\param[out] wheelShapeLocalPoses are the local poses in the wheel's frame to apply to the PxShape instances that represent the wheel
|
||||
\param[out] wheelRigidBody1dStates describes the angular speed of the wheels.
|
||||
\param[out] wheelLocalPoses describes the local poses of the wheels in the rigid body frame.
|
||||
\param[out] gearState The gear state. Can be set to NULL if the vehicle does
|
||||
not have gears.
|
||||
\param[out] throttle The throttle command state (see #PxVehicleCommandState).
|
||||
Can be set to NULL if the vehicle is not controlled through
|
||||
PxVehicleCommandState.
|
||||
\param[out] physxActor is the PxRigidBody instance associated with the vehicle.
|
||||
*/
|
||||
virtual void getDataForPhysXActorEndComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
const PxVehicleRigidBodyState*& rigidBodyState,
|
||||
PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
PxVehicleArrayData<const PxTransform>& wheelShapeLocalPoses,
|
||||
PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates,
|
||||
PxVehicleArrayData<const PxVehicleWheelLocalPose>& wheelLocalPoses,
|
||||
const PxVehicleGearboxState*& gearState,
|
||||
const PxReal*& throttle,
|
||||
PxVehiclePhysXActor*& physxActor) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(dt);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehiclePhysXActorEndComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
const PxVehicleRigidBodyState* rigidBodyState;
|
||||
PxVehicleArrayData<const PxVehicleWheelParams> wheelParams;
|
||||
PxVehicleArrayData<const PxTransform> wheelShapeLocalPoses;
|
||||
PxVehicleArrayData<const PxVehicleWheelRigidBody1dState> wheelRigidBody1dStates;
|
||||
PxVehicleArrayData<const PxVehicleWheelLocalPose> wheelLocalPoses;
|
||||
const PxVehicleGearboxState* gearState;
|
||||
const PxReal* throttle;
|
||||
PxVehiclePhysXActor* physxActor;
|
||||
|
||||
getDataForPhysXActorEndComponent(axleDescription, rigidBodyState,
|
||||
wheelParams, wheelShapeLocalPoses, wheelRigidBody1dStates, wheelLocalPoses, gearState, throttle,
|
||||
physxActor);
|
||||
|
||||
for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
|
||||
PxVehicleWriteWheelLocalPoseToPhysXWheelShape(wheelLocalPoses[wheelId].localPose, wheelShapeLocalPoses[wheelId],
|
||||
physxActor->wheelShapes[wheelId]);
|
||||
}
|
||||
|
||||
if (context.getType() == PxVehicleSimulationContextType::ePHYSX)
|
||||
{
|
||||
const PxVehiclePhysXSimulationContext& physxContext = static_cast<const PxVehiclePhysXSimulationContext&>(context);
|
||||
|
||||
PxVehicleWriteRigidBodyStateToPhysXActor(physxContext.physxActorUpdateMode, *rigidBodyState, dt, *physxActor->rigidBody);
|
||||
|
||||
PxVehiclePhysxActorKeepAwakeCheck(*axleDescription, wheelParams, wheelRigidBody1dStates,
|
||||
physxContext.physxActorWakeCounterThreshold, physxContext.physxActorWakeCounterResetValue, gearState, throttle,
|
||||
*physxActor->rigidBody);
|
||||
}
|
||||
else
|
||||
{
|
||||
PX_ALWAYS_ASSERT();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
196
engine/third_party/physx/include/vehicle2/physxActor/PxVehiclePhysXActorFunctions.h
vendored
Normal file
196
engine/third_party/physx/include/vehicle2/physxActor/PxVehiclePhysXActorFunctions.h
vendored
Normal file
@@ -0,0 +1,196 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
|
||||
class PxRigidBody;
|
||||
class PxShape;
|
||||
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleCommandState;
|
||||
struct PxVehicleEngineDriveTransmissionCommandState;
|
||||
struct PxVehicleEngineParams;
|
||||
struct PxVehicleEngineState;
|
||||
struct PxVehicleGearboxParams;
|
||||
struct PxVehicleGearboxState;
|
||||
struct PxVehicleRigidBodyState;
|
||||
struct PxVehiclePhysXConstraints;
|
||||
struct PxVehicleWheelLocalPose;
|
||||
struct PxVehicleWheelParams;
|
||||
struct PxVehicleWheelRigidBody1dState;
|
||||
struct PxVehiclePhysXSteerState;
|
||||
|
||||
/**
|
||||
\brief Wake up the physx actor if the actor is asleep and the commands signal an intent to
|
||||
change the state of the vehicle.
|
||||
\param[in] commands are the brake, throttle and steer values that will drive the vehicle.
|
||||
\param[in] transmissionCommands are the target gear and clutch values that will control
|
||||
the transmission. If the target gear is different from the current gearbox
|
||||
target gear, then the physx actor will get woken up. Can be set to NULL if the
|
||||
vehicle does not have a gearbox or if this is not a desired behavior. If
|
||||
specified, then gearParams and gearState has to be specifed too.
|
||||
\param[in] gearParams The gearbox parameters. Can be set to NULL if the vehicle does
|
||||
not have a gearbox and transmissionCommands is NULL.
|
||||
\param[in] gearState The state of the gearbox. Can be set to NULL if the vehicle does
|
||||
not have a gearbox and transmissionCommands is NULL.
|
||||
\param[in] physxActor is the PxRigidBody instance associated with the vehicle.
|
||||
\param[in,out] physxSteerState and commands are compared to
|
||||
determine if the steering state has changed since the last call to PxVehiclePhysxActorWakeup().
|
||||
\note If the steering has changed, the actor will be woken up.
|
||||
\note On exit from PxVehiclePhysxActorWakeup, physxSteerState.previousSteerCommand is assigned to the value
|
||||
of commands.steer so that the steer state may be propagated to the subsequent call to PxVehiclePhysxActorWakeup().
|
||||
\note If physxSteerState.previousSteerCommand has value PX_VEHICLE_UNSPECIFIED_STEER_STATE, the steering state
|
||||
is treated as though it has not changed.
|
||||
*/
|
||||
void PxVehiclePhysxActorWakeup(
|
||||
const PxVehicleCommandState& commands,
|
||||
const PxVehicleEngineDriveTransmissionCommandState* transmissionCommands,
|
||||
const PxVehicleGearboxParams* gearParams,
|
||||
const PxVehicleGearboxState* gearState,
|
||||
PxRigidBody& physxActor,
|
||||
PxVehiclePhysXSteerState& physxSteerState);
|
||||
|
||||
/**
|
||||
\brief Check if the physx actor is sleeping and clear certain vehicle states if it is.
|
||||
|
||||
\param[in] axleDescription identifies the wheels on each axle.
|
||||
\param[in] physxActor is the PxRigidBody instance associated with the vehicle.
|
||||
\param[in] engineParams The engine parameters. Can be set to NULL if the vehicle does
|
||||
not have an engine. Must be specified, if engineState is specified.
|
||||
\param[in,out] rigidBodyState is the state of the rigid body used by the Vehicle SDK.
|
||||
\param[in,out] physxConstraints The state of the suspension limit and low speed tire constraints.
|
||||
If the vehicle actor is sleeping and constraints are active, they will be
|
||||
deactivated and marked as dirty.
|
||||
\param[in,out] wheelRigidBody1dStates describes the angular speed of the wheels.
|
||||
\param[out] engineState The engine state. Can be set to NULL if the vehicle does
|
||||
not have an engine. If specified, then engineParams has to be specifed too.
|
||||
The engine rotation speed will get set to the idle rotation speed if
|
||||
the actor is sleeping.
|
||||
\return True if the actor was sleeping, else false.
|
||||
*/
|
||||
bool PxVehiclePhysxActorSleepCheck
|
||||
(const PxVehicleAxleDescription& axleDescription,
|
||||
const PxRigidBody& physxActor,
|
||||
const PxVehicleEngineParams* engineParams,
|
||||
PxVehicleRigidBodyState& rigidBodyState,
|
||||
PxVehiclePhysXConstraints& physxConstraints,
|
||||
PxVehicleArrayData<PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates,
|
||||
PxVehicleEngineState* engineState);
|
||||
|
||||
/**
|
||||
\brief Check if the physx actor has to be kept awake.
|
||||
|
||||
Certain criteria should keep the vehicle physx actor awake, for example, if the
|
||||
(mass normalized) rotational kinetic energy of the wheels is above a certain
|
||||
threshold or if a gear change is pending or if throttle is applied.
|
||||
This method will reset the wake counter of the physx actor to a specified value,
|
||||
if any of the mentioned criteria are met.
|
||||
|
||||
\note The physx actor's sleep threshold will be used as threshold to test against
|
||||
for the energy criteria.
|
||||
|
||||
\param[in] axleDescription identifies the wheels on each axle.
|
||||
\param[in] wheelParams describes the radius, mass etc. of the wheels.
|
||||
\param[in] wheelRigidBody1dStates describes the angular speed of the wheels.
|
||||
\param[in] wakeCounterThreshold Once the wake counter of the physx actor falls
|
||||
below this threshold, the method will start testing if the wake
|
||||
counter needs to be reset.
|
||||
\param[in] wakeCounterResetValue The value to set the physx actor wake counter
|
||||
to, if any of the criteria to do so are met.
|
||||
\param[in] gearState The gear state. Can be set to NULL if the vehicle does
|
||||
not have gears or if the mentioned behavior is not desired.
|
||||
\param[in] throttle The throttle command state (see #PxVehicleCommandState).
|
||||
Can be set to NULL if the vehicle is not controlled through
|
||||
PxVehicleCommandState or if the mentioned behavior is not desired.
|
||||
\param[in] physxActor is the PxRigidBody instance associated with the vehicle.
|
||||
*/
|
||||
void PxVehiclePhysxActorKeepAwakeCheck
|
||||
(const PxVehicleAxleDescription& axleDescription,
|
||||
const PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
const PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates,
|
||||
const PxReal wakeCounterThreshold,
|
||||
const PxReal wakeCounterResetValue,
|
||||
const PxVehicleGearboxState* gearState,
|
||||
const PxReal* throttle,
|
||||
PxRigidBody& physxActor);
|
||||
|
||||
|
||||
/**
|
||||
\brief Read the rigid body state from a PhysX actor.
|
||||
\param[in] physxActor is a reference to a PhysX actor.
|
||||
\param[out] rigidBodyState is the state of the rigid body used by the Vehicle SDK.
|
||||
*/
|
||||
void PxVehicleReadRigidBodyStateFromPhysXActor
|
||||
(const PxRigidBody& physxActor,
|
||||
PxVehicleRigidBodyState& rigidBodyState);
|
||||
|
||||
/**
|
||||
\brief Update the local pose of a PxShape that is associated with a wheel.
|
||||
\param[in] wheelLocalPose describes the local pose of each wheel in the rigid body frame.
|
||||
\param[in] wheelShapeLocalPose describes the local pose to apply to the PxShape instance in the wheel's frame.
|
||||
\param[in] shape is the target PxShape.
|
||||
*/
|
||||
void PxVehicleWriteWheelLocalPoseToPhysXWheelShape
|
||||
(const PxTransform& wheelLocalPose, const PxTransform& wheelShapeLocalPose, PxShape* shape);
|
||||
|
||||
/**
|
||||
\brief Write the rigid body state to a PhysX actor.
|
||||
\param[in] physxActorUpdateMode controls whether the PhysX actor is to be updated with
|
||||
instantaneous velocity changes or with accumulated accelerations to be applied in
|
||||
the next simulation step of the associated PxScene.
|
||||
\param[in] rigidBodyState is the state of the rigid body.
|
||||
\param[in] dt is the simulation time that has elapsed since the last call to
|
||||
PxVehicleWriteRigidBodyStateToPhysXActor().
|
||||
\param[out] physXActor is a reference to the PhysX actor.
|
||||
*/
|
||||
void PxVehicleWriteRigidBodyStateToPhysXActor
|
||||
(const PxVehiclePhysXActorUpdateMode::Enum physxActorUpdateMode,
|
||||
const PxVehicleRigidBodyState& rigidBodyState,
|
||||
const PxReal dt,
|
||||
PxRigidBody& physXActor);
|
||||
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
205
engine/third_party/physx/include/vehicle2/physxActor/PxVehiclePhysXActorHelpers.h
vendored
Normal file
205
engine/third_party/physx/include/vehicle2/physxActor/PxVehiclePhysXActorHelpers.h
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "PxFiltering.h"
|
||||
#include "PxShape.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
|
||||
class PxGeometry;
|
||||
class PxMaterial;
|
||||
struct PxCookingParams;
|
||||
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleRigidBodyParams;
|
||||
struct PxVehicleAxleDescription;
|
||||
struct PxVehicleWheelParams;
|
||||
struct PxVehiclePhysXActor;
|
||||
struct PxVehicleFrame;
|
||||
struct PxVehicleSuspensionParams;
|
||||
|
||||
class PxVehiclePhysXRigidActorParams
|
||||
{
|
||||
PX_NOCOPY(PxVehiclePhysXRigidActorParams)
|
||||
|
||||
public:
|
||||
|
||||
PxVehiclePhysXRigidActorParams(const PxVehicleRigidBodyParams& _physxActorRigidBodyParams, const char* _physxActorName)
|
||||
: rigidBodyParams(_physxActorRigidBodyParams),
|
||||
physxActorName(_physxActorName)
|
||||
{
|
||||
}
|
||||
|
||||
const PxVehicleRigidBodyParams& rigidBodyParams;
|
||||
const char* physxActorName;
|
||||
};
|
||||
|
||||
class PxVehiclePhysXRigidActorShapeParams
|
||||
{
|
||||
PX_NOCOPY(PxVehiclePhysXRigidActorShapeParams)
|
||||
|
||||
public:
|
||||
|
||||
PxVehiclePhysXRigidActorShapeParams
|
||||
(const PxGeometry& _geometry, const PxTransform& _localPose, const PxMaterial& _material,
|
||||
const PxShapeFlags _flags, const PxFilterData& _simulationFilterData, const PxFilterData& _queryFilterData)
|
||||
: geometry(_geometry),
|
||||
localPose(_localPose),
|
||||
material(_material),
|
||||
flags(_flags),
|
||||
simulationFilterData(_simulationFilterData),
|
||||
queryFilterData(_queryFilterData)
|
||||
{
|
||||
}
|
||||
|
||||
const PxGeometry& geometry;
|
||||
const PxTransform& localPose;
|
||||
const PxMaterial& material;
|
||||
PxShapeFlags flags;
|
||||
PxFilterData simulationFilterData;
|
||||
PxFilterData queryFilterData;
|
||||
};
|
||||
|
||||
class PxVehiclePhysXWheelParams
|
||||
{
|
||||
PX_NOCOPY(PxVehiclePhysXWheelParams)
|
||||
|
||||
public:
|
||||
|
||||
PxVehiclePhysXWheelParams(const PxVehicleAxleDescription& _axleDescription, const PxVehicleWheelParams* _wheelParams)
|
||||
: axleDescription(_axleDescription),
|
||||
wheelParams(_wheelParams)
|
||||
{
|
||||
}
|
||||
|
||||
const PxVehicleAxleDescription& axleDescription;
|
||||
const PxVehicleWheelParams* wheelParams;
|
||||
};
|
||||
|
||||
class PxVehiclePhysXWheelShapeParams
|
||||
{
|
||||
PX_NOCOPY(PxVehiclePhysXWheelShapeParams)
|
||||
|
||||
public:
|
||||
|
||||
PxVehiclePhysXWheelShapeParams(const PxMaterial& _material, const PxShapeFlags _flags, const PxFilterData _simulationFilterData, const PxFilterData _queryFilterData)
|
||||
: material(_material),
|
||||
flags(_flags),
|
||||
simulationFilterData(_simulationFilterData),
|
||||
queryFilterData(_queryFilterData)
|
||||
{
|
||||
}
|
||||
|
||||
const PxMaterial& material;
|
||||
PxShapeFlags flags;
|
||||
PxFilterData simulationFilterData;
|
||||
PxFilterData queryFilterData;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Create a PxRigidDynamic instance, instantiate it with desired properties and populate it with PxShape instances.
|
||||
\param[in] vehicleFrame describes the frame of the vehicle.
|
||||
\param[in] rigidActorParams describes the mass and moment of inertia of the rigid body.
|
||||
\param[in] rigidActorCmassLocalPose specifies the mapping between actor and rigid body frame.
|
||||
\param[in] rigidActorShapeParams describes the collision geometry associated with the rigid body.
|
||||
\param[in] wheelParams describes the radius and half-width of the wheels.
|
||||
\param[in] wheelShapeParams describes the PxMaterial and PxShapeFlags to apply to the wheel shapes.
|
||||
\param[in] physics is a PxPhysics instance.
|
||||
\param[in] params is a PxCookingParams instance
|
||||
\param[in] vehiclePhysXActor is a record of the PxRigidDynamic and PxShape instances instantiated.
|
||||
\note This is an alternative to PxVehiclePhysXArticulationLinkCreate.
|
||||
\note PxVehiclePhysXActorCreate primarily serves as an illustration of the instantiation of the PhysX class instances
|
||||
required to simulate a vehicle with a PxRigidDynamic.
|
||||
\see PxVehiclePhysXActorDestroy
|
||||
*/
|
||||
void PxVehiclePhysXActorCreate
|
||||
(const PxVehicleFrame& vehicleFrame,
|
||||
const PxVehiclePhysXRigidActorParams& rigidActorParams, const PxTransform& rigidActorCmassLocalPose,
|
||||
const PxVehiclePhysXRigidActorShapeParams& rigidActorShapeParams,
|
||||
const PxVehiclePhysXWheelParams& wheelParams, const PxVehiclePhysXWheelShapeParams& wheelShapeParams,
|
||||
PxPhysics& physics, const PxCookingParams& params,
|
||||
PxVehiclePhysXActor& vehiclePhysXActor);
|
||||
|
||||
|
||||
/**
|
||||
\brief Configure an actor so that it is ready for vehicle simulation.
|
||||
\param[in] rigidActorParams describes the mass and moment of inertia of the rigid body.
|
||||
\param[in] rigidActorCmassLocalPose specifies the mapping between actor and rigid body frame.
|
||||
\param[out] rigidBody is the body to be prepared for simulation.
|
||||
*/
|
||||
void PxVehiclePhysXActorConfigure
|
||||
(const PxVehiclePhysXRigidActorParams& rigidActorParams, const PxTransform& rigidActorCmassLocalPose,
|
||||
PxRigidBody& rigidBody);
|
||||
|
||||
/**
|
||||
\brief Create a PxArticulationReducedCoordinate and a single PxArticulationLink,
|
||||
instantiate the PxArticulationLink with desired properties and populate it with PxShape instances.
|
||||
\param[in] vehicleFrame describes the frame of the vehicle.
|
||||
\param[in] rigidActorParams describes the mass and moment of inertia of the rigid body.
|
||||
\param[in] rigidActorCmassLocalPose specifies the mapping between actor and rigid body frame.
|
||||
\param[in] rigidActorShapeParams describes the collision geometry associated with the rigid body.
|
||||
\param[in] wheelParams describes the radius and half-width of the wheels.
|
||||
\param[in] wheelShapeParams describes the PxMaterial and PxShapeFlags to apply to the wheel shapes.
|
||||
\param[in] physics is a PxPhysics instance.
|
||||
\param[in] params is a PxCookingParams instance
|
||||
\param[in] vehiclePhysXActor is a record of the PxArticulationReducedCoordinate, PxArticulationLink and PxShape instances instantiated.
|
||||
\note This is an alternative to PxVehiclePhysXActorCreate.
|
||||
\note PxVehiclePhysXArticulationLinkCreate primarily serves as an illustration of the instantiation of the PhysX class instances
|
||||
required to simulate a vehicle as part of an articulated ensemble.
|
||||
\see PxVehiclePhysXActorDestroy
|
||||
*/
|
||||
void PxVehiclePhysXArticulationLinkCreate
|
||||
(const PxVehicleFrame& vehicleFrame,
|
||||
const PxVehiclePhysXRigidActorParams& rigidActorParams, const PxTransform& rigidActorCmassLocalPose,
|
||||
const PxVehiclePhysXRigidActorShapeParams& rigidActorShapeParams,
|
||||
const PxVehiclePhysXWheelParams& wheelParams, const PxVehiclePhysXWheelShapeParams& wheelShapeParams,
|
||||
PxPhysics& physics, const PxCookingParams& params,
|
||||
PxVehiclePhysXActor& vehiclePhysXActor);
|
||||
|
||||
/**
|
||||
\brief Release the PxRigidDynamic, PxArticulationReducedCoordinate, PxArticulationLink and PxShape instances
|
||||
instantiated by PxVehiclePhysXActorCreate or PxVehiclePhysXArticulationLinkCreate.
|
||||
\param[in] vehiclePhysXActor is a description of the PhysX instances to be released.
|
||||
*/
|
||||
void PxVehiclePhysXActorDestroy(PxVehiclePhysXActor& vehiclePhysXActor);
|
||||
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
94
engine/third_party/physx/include/vehicle2/physxActor/PxVehiclePhysXActorStates.h
vendored
Normal file
94
engine/third_party/physx/include/vehicle2/physxActor/PxVehiclePhysXActorStates.h
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
|
||||
#include "PxRigidBody.h"
|
||||
|
||||
#include "vehicle2/PxVehicleLimits.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
|
||||
class PxShape;
|
||||
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief A description of the PhysX actor and shapes that represent the vehicle in an associated PxScene.
|
||||
*/
|
||||
struct PxVehiclePhysXActor
|
||||
{
|
||||
/**
|
||||
\brief The PhysX rigid body that represents the vehcle in the associated PhysX scene.
|
||||
\note PxActorFlag::eDISABLE_GRAVITY must be set true on the PxRigidBody
|
||||
*/
|
||||
PxRigidBody* rigidBody;
|
||||
|
||||
/**
|
||||
\brief An array of shapes with one shape pointer (or NULL) for each wheel.
|
||||
*/
|
||||
PxShape* wheelShapes[PxVehicleLimits::eMAX_NB_WHEELS];
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehiclePhysXActor));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#define PX_VEHICLE_UNSPECIFIED_STEER_STATE PX_MAX_F32
|
||||
|
||||
/**
|
||||
\brief A description of the previous steer command applied to the vehicle.
|
||||
*/
|
||||
struct PxVehiclePhysXSteerState
|
||||
{
|
||||
|
||||
/**
|
||||
\brief The steer command that was most previously applied to the vehicle.
|
||||
*/
|
||||
PxReal previousSteerCommand;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
previousSteerCommand = PX_VEHICLE_UNSPECIFIED_STEER_STATE;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
119
engine/third_party/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintComponents.h
vendored
Normal file
119
engine/third_party/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintComponents.h
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "vehicle2/PxVehicleComponent.h"
|
||||
|
||||
#include "vehicle2/roadGeometry/PxVehicleRoadGeometryState.h"
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionParams.h"
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionStates.h"
|
||||
|
||||
#include "PxVehiclePhysXConstraintFunctions.h"
|
||||
#include "PxVehiclePhysXConstraintHelpers.h"
|
||||
#include "PxVehiclePhysXConstraintStates.h"
|
||||
#include "PxVehiclePhysXConstraintParams.h"
|
||||
|
||||
#include "common/PxProfileZone.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxVehiclePhysXConstraintComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
PxVehiclePhysXConstraintComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehiclePhysXConstraintComponent() {}
|
||||
|
||||
virtual void getDataForPhysXConstraintComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
const PxVehicleRigidBodyState*& rigidBodyState,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams,
|
||||
PxVehicleArrayData<const PxVehiclePhysXSuspensionLimitConstraintParams>& suspensionLimitParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionState>& suspensionStates,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspensionComplianceStates,
|
||||
PxVehicleArrayData<const PxVehicleRoadGeometryState>& wheelRoadGeomStates,
|
||||
PxVehicleArrayData<const PxVehicleTireDirectionState>& tireDirectionStates,
|
||||
PxVehicleArrayData<const PxVehicleTireStickyState>& tireStickyStates,
|
||||
PxVehiclePhysXConstraints*& constraints) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(dt);
|
||||
PX_UNUSED(context);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehiclePhysXConstraintComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
const PxVehicleRigidBodyState* rigidBodyState;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams;
|
||||
PxVehicleArrayData<const PxVehiclePhysXSuspensionLimitConstraintParams> suspensionLimitParams;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionState> suspensionStates;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceState> suspensionComplianceStates;
|
||||
PxVehicleArrayData<const PxVehicleRoadGeometryState> wheelRoadGeomStates;
|
||||
PxVehicleArrayData<const PxVehicleTireDirectionState> tireDirectionStates;
|
||||
PxVehicleArrayData<const PxVehicleTireStickyState> tireStickyStates;
|
||||
PxVehiclePhysXConstraints* constraints;
|
||||
|
||||
getDataForPhysXConstraintComponent(axleDescription, rigidBodyState,
|
||||
suspensionParams, suspensionLimitParams, suspensionStates, suspensionComplianceStates,
|
||||
wheelRoadGeomStates, tireDirectionStates, tireStickyStates,
|
||||
constraints);
|
||||
|
||||
PxVehicleConstraintsDirtyStateUpdate(*constraints);
|
||||
|
||||
for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
|
||||
PxVehiclePhysXConstraintStatesUpdate(
|
||||
suspensionParams[wheelId], suspensionLimitParams[wheelId],
|
||||
suspensionStates[wheelId], suspensionComplianceStates[wheelId],
|
||||
wheelRoadGeomStates[wheelId].plane.n,
|
||||
context.tireStickyParams.stickyParams[PxVehicleTireDirectionModes::eLONGITUDINAL].damping,
|
||||
context.tireStickyParams.stickyParams[PxVehicleTireDirectionModes::eLATERAL].damping,
|
||||
tireDirectionStates[wheelId], tireStickyStates[wheelId],
|
||||
*rigidBodyState,
|
||||
constraints->constraintStates[wheelId]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
88
engine/third_party/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintFunctions.h
vendored
Normal file
88
engine/third_party/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintFunctions.h
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleSuspensionParams;
|
||||
struct PxVehiclePhysXSuspensionLimitConstraintParams;
|
||||
struct PxVehicleSuspensionState;
|
||||
struct PxVehicleSuspensionComplianceState;
|
||||
struct PxVehicleTireDirectionState;
|
||||
struct PxVehicleTireStickyState;
|
||||
struct PxVehicleRigidBodyState;
|
||||
struct PxVehiclePhysXConstraintState;
|
||||
|
||||
/**
|
||||
\brief Read constraint data from the vehicle's internal state for a single wheel and write it to a
|
||||
structure that will be read by the associated PxScene and used to impose the constraints during the next
|
||||
PxScene::simulate() step.
|
||||
\param[in] suspensionParams describes the suspension frame.
|
||||
\param[in] suspensionLimitParams describes the restitution value applied to any constraint triggered by
|
||||
the suspension travel limit.
|
||||
\param[in] suspensionState describes the excess suspension compression beyond the suspension travel limit that will be
|
||||
resolved with a constraint.
|
||||
\param[in] suspensionComplianceState describes the effect of suspension compliance on the effective application point
|
||||
of the suspension force.
|
||||
\param[in] groundPlaneNormal The normal direction of the ground plane the wheel is driving on. A normalized vector is
|
||||
expected.
|
||||
\param[in] tireStickyDampingLong The damping coefficient to use in the constraint to approach a zero target velocity
|
||||
along the longitudinal tire axis.
|
||||
\param[in] tireStickyDampingLat Same concept as tireStickyDampingLong but for the lateral tire axis.
|
||||
\param[in] tireDirectionState describes the longitudinal and lateral directions of the tire in the world frame.
|
||||
\param[in] tireStickyState describes the low speed state of the tire in the longitudinal and lateral directions.
|
||||
\param[in] rigidBodyState describes the pose of the rigid body.
|
||||
\param[out] constraintState is the data structure that will be read by the associated PxScene in the next call to
|
||||
PxScene::simulate().
|
||||
\note Constraints include suspension constraints to account for suspension travel limit and sticky
|
||||
tire constraints that bring the vehicle to rest at low longitudinal and lateral speed.
|
||||
*/
|
||||
void PxVehiclePhysXConstraintStatesUpdate
|
||||
(const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxVehiclePhysXSuspensionLimitConstraintParams& suspensionLimitParams,
|
||||
const PxVehicleSuspensionState& suspensionState, const PxVehicleSuspensionComplianceState& suspensionComplianceState,
|
||||
const PxVec3& groundPlaneNormal,
|
||||
const PxReal tireStickyDampingLong, const PxReal tireStickyDampingLat,
|
||||
const PxVehicleTireDirectionState& tireDirectionState, const PxVehicleTireStickyState& tireStickyState,
|
||||
const PxVehicleRigidBodyState& rigidBodyState,
|
||||
PxVehiclePhysXConstraintState& constraintState);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
88
engine/third_party/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintHelpers.h
vendored
Normal file
88
engine/third_party/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintHelpers.h
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
|
||||
class PxPhysics;
|
||||
class PxRigidBody;
|
||||
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleAxleDescription;
|
||||
struct PxVehiclePhysXConstraints;
|
||||
|
||||
/**
|
||||
\brief Instantiate the PhysX custom constraints.
|
||||
|
||||
Custom constraints will resolve excess suspension compression and velocity constraints that serve as
|
||||
a replacement low speed tire model.
|
||||
|
||||
\param[in] axleDescription describes the axles of the vehicle and the wheels on each axle.
|
||||
\param[in] physics is a PxPhysics instance.
|
||||
\param[in] physxActor is the vehicle's PhysX representation as a PxRigidBody
|
||||
\param[in] vehicleConstraints is a wrapper class that holds pointers to PhysX objects required to implement the custom constraint.
|
||||
*/
|
||||
void PxVehicleConstraintsCreate
|
||||
(const PxVehicleAxleDescription& axleDescription,
|
||||
PxPhysics& physics, PxRigidBody& physxActor,
|
||||
PxVehiclePhysXConstraints& vehicleConstraints);
|
||||
|
||||
/**
|
||||
\brief To ensure the constraints are processed by the PhysX scene they are marked as dirty prior to each simulate step.
|
||||
|
||||
\param[in] vehicleConstraints is a wrapper class that holds pointers to PhysX objects required to implement the custom constraint.
|
||||
|
||||
\see PxVehicleConstraintsCreate
|
||||
*/
|
||||
void PxVehicleConstraintsDirtyStateUpdate
|
||||
(PxVehiclePhysXConstraints& vehicleConstraints);
|
||||
|
||||
/**
|
||||
\brief Destroy the PhysX custom constraints.
|
||||
|
||||
\param[in,out] vehicleConstraints describes the PhysX custom constraints to be released.
|
||||
|
||||
\see PxVehicleConstraintsCreate
|
||||
*/
|
||||
void PxVehicleConstraintsDestroy
|
||||
(PxVehiclePhysXConstraints& vehicleConstraints);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
106
engine/third_party/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintParams.h
vendored
Normal file
106
engine/third_party/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintParams.h
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxFoundation.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleFrame;
|
||||
struct PxVehicleScale;
|
||||
|
||||
/**
|
||||
\brief A description of the PhysX models employed to resolve suspension limit constraints.
|
||||
\see PxVehiclePhysXConstraintState
|
||||
*/
|
||||
struct PxVehiclePhysXSuspensionLimitConstraintParams
|
||||
{
|
||||
/**
|
||||
\brief restitution is used by the restitution model used to generate a target velocity when resolving suspension limit
|
||||
constraints.
|
||||
\note A value of 0.0 means that the restitution model is not employed.
|
||||
\note Restitution has no effect if directionForSuspensionLimitConstraint has value Enum::eNONE.
|
||||
\see Px1DConstraintFlag::eRESTITUTION
|
||||
\see Px1DConstraint::RestitutionModifiers::restitution
|
||||
*/
|
||||
PxReal restitution;
|
||||
|
||||
/**
|
||||
\brief Set the direction to apply a constraint impulse when the suspension cannot place the wheel on the ground
|
||||
and simultaneously respect the limits of suspension travel. The choices are to push along the ground normal to resolve the
|
||||
geometric error or to push along the suspension direction. The former choice can be thought of as mimicing a force applied
|
||||
by the tire's contact with the ground, while the latter can be thought of as mimicing a force arising from a suspension limit spring.
|
||||
When the ground normal and the suspension direction are approximately aligned, both do an equivalent job of maintaining the wheel above
|
||||
the ground. When the vehicle is on its side, eSUSPENSION does a better job of keeping the wheels above
|
||||
the ground but comes at the cost of an unnaturally strong torque that can lead to unwanted self-righting behaviour.
|
||||
eROAD_GEOMETRY_NORMAL is a good choice to avoid self-righting behaviour and still do a reasonable job at maintaining
|
||||
the wheel above the ground in the event that the vehicle is tending towards a roll onto its side.
|
||||
eNONE should be chosen if it is desired that no extra impulse is applied when the suspension alone cannot keep the wheels above
|
||||
the ground plane.
|
||||
*/
|
||||
enum DirectionSpecifier
|
||||
{
|
||||
eSUSPENSION,
|
||||
eROAD_GEOMETRY_NORMAL,
|
||||
eNONE
|
||||
};
|
||||
DirectionSpecifier directionForSuspensionLimitConstraint;
|
||||
|
||||
PX_FORCE_INLINE PxVehiclePhysXSuspensionLimitConstraintParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PX_UNUSED(srcScale);
|
||||
PX_UNUSED(trgScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(
|
||||
PxVehiclePhysXSuspensionLimitConstraintParams::eSUSPENSION == directionForSuspensionLimitConstraint ||
|
||||
PxVehiclePhysXSuspensionLimitConstraintParams::eROAD_GEOMETRY_NORMAL == directionForSuspensionLimitConstraint ||
|
||||
PxVehiclePhysXSuspensionLimitConstraintParams::eNONE == directionForSuspensionLimitConstraint, "PxVehiclePhysXSuspensionLimitConstraintParams.directionForSuspensionLimitConstraint must have legal value", false);
|
||||
PX_CHECK_AND_RETURN_VAL(restitution >= 0.0f && restitution <= 1.0f, "PxVehiclePhysXSuspensionLimitConstraintParams.restitution must be in range [0, 1]", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
353
engine/third_party/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintStates.h
vendored
Normal file
353
engine/third_party/physx/include/vehicle2/physxConstraints/PxVehiclePhysXConstraintStates.h
vendored
Normal file
@@ -0,0 +1,353 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "foundation/PxAssert.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "extensions/PxConstraintExt.h"
|
||||
|
||||
#include "vehicle2/PxVehicleLimits.h"
|
||||
#include "vehicle2/tire/PxVehicleTireStates.h"
|
||||
|
||||
#include "PxConstraint.h"
|
||||
#include "PxConstraintDesc.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
|
||||
class PxConstraint;
|
||||
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief A description of the number of PxConstraintConnector instances per vehicle required to maintain suspension limit
|
||||
and sticky tire instances.
|
||||
*/
|
||||
struct PxVehiclePhysXConstraintLimits
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eNB_DOFS_PER_PXCONSTRAINT = 12,
|
||||
eNB_DOFS_PER_WHEEL = 3,
|
||||
eNB_WHEELS_PER_PXCONSTRAINT = eNB_DOFS_PER_PXCONSTRAINT / eNB_DOFS_PER_WHEEL,
|
||||
eNB_CONSTRAINTS_PER_VEHICLE = (PxVehicleLimits::eMAX_NB_WHEELS + (eNB_WHEELS_PER_PXCONSTRAINT - 1)) / (eNB_WHEELS_PER_PXCONSTRAINT)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief PxVehiclePhysXConstraintState is a data structure used to write
|
||||
constraint data to the internal state of the associated PxScene.
|
||||
\see Px1dConstraint
|
||||
*/
|
||||
struct PxVehiclePhysXConstraintState
|
||||
{
|
||||
/**
|
||||
\brief a boolean describing whether to trigger a low speed constraint along the tire longitudinal and lateral directions.
|
||||
*/
|
||||
bool tireActiveStatus[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS];
|
||||
/**
|
||||
\brief linear component of velocity jacobian in world space for the tire's longitudinal and lateral directions.
|
||||
*/
|
||||
PxVec3 tireLinears[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS];
|
||||
/**
|
||||
\brief angular component of velocity jacobian in world space for the tire's longitudinal and lateral directions.
|
||||
*/
|
||||
PxVec3 tireAngulars[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS];
|
||||
/**
|
||||
\brief damping coefficient applied to the tire's longitudinal and lateral velocities.
|
||||
|
||||
The constraint sets a target velocity of 0 and the damping coefficient will impact the size of the
|
||||
impulse applied to reach the target. Since damping acts as a stiffness with respect to the velocity,
|
||||
too large a value can cause instabilities.
|
||||
*/
|
||||
PxReal tireDamping[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS];
|
||||
|
||||
|
||||
/**
|
||||
\brief a boolean describing whether to trigger a suspension limit constraint.
|
||||
*/
|
||||
bool suspActiveStatus;
|
||||
/**
|
||||
\brief linear component of velocity jacobian in the world frame.
|
||||
*/
|
||||
PxVec3 suspLinear;
|
||||
/**
|
||||
\brief angular component of velocity jacobian in the world frame.
|
||||
*/
|
||||
PxVec3 suspAngular;
|
||||
/**
|
||||
\brief the excess suspension compression to be resolved by the constraint that cannot be resolved due to the travel limit
|
||||
of the suspension spring.
|
||||
|
||||
\note The expected error value is the excess suspension compression projected onto the ground plane normal and should have
|
||||
a negative sign.
|
||||
*/
|
||||
PxReal suspGeometricError;
|
||||
/**
|
||||
\brief restitution value of the restitution model used to generate a target velocity that will resolve the geometric error.
|
||||
\note A value of 0.0 means that the restitution model is not employed.
|
||||
\see Px1DConstraintFlag::eRESTITUTION
|
||||
\see Px1DConstraint::RestitutionModifiers::restitution
|
||||
*/
|
||||
PxReal restitution;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehiclePhysXConstraintState));
|
||||
}
|
||||
};
|
||||
|
||||
//TAG:solverprepshader
|
||||
PX_FORCE_INLINE PxU32 vehicleConstraintSolverPrep
|
||||
(Px1DConstraint* constraints,
|
||||
PxVec3p& body0WorldOffset,
|
||||
PxU32 maxConstraints,
|
||||
PxConstraintInvMassScale&,
|
||||
const void* constantBlock,
|
||||
const PxTransform& bodyAToWorld,
|
||||
const PxTransform& bodyBToWorld,
|
||||
bool,
|
||||
PxVec3p& cA2w, PxVec3p& cB2w)
|
||||
{
|
||||
PX_UNUSED(maxConstraints);
|
||||
PX_UNUSED(body0WorldOffset);
|
||||
PX_UNUSED(bodyBToWorld);
|
||||
PX_ASSERT(bodyAToWorld.isValid()); PX_ASSERT(bodyBToWorld.isValid());
|
||||
|
||||
const PxVehiclePhysXConstraintState* data = static_cast<const PxVehiclePhysXConstraintState*>(constantBlock);
|
||||
PxU32 numActive = 0;
|
||||
|
||||
//KS - the TGS solver will use raXn to try to add to the angular part of the linear constraints.
|
||||
//We overcome this by setting the ra and rb offsets to be 0.
|
||||
cA2w = bodyAToWorld.p;
|
||||
cB2w = bodyBToWorld.p;
|
||||
// note: this is only needed for PxSolverType::eTGS and even then it should not have an effect as
|
||||
// long as a constraint raises Px1DConstraintFlag::eANGULAR_CONSTRAINT
|
||||
|
||||
//Susp limit constraints.
|
||||
for (PxU32 i = 0; i < PxVehiclePhysXConstraintLimits::eNB_WHEELS_PER_PXCONSTRAINT; i++)
|
||||
{
|
||||
if (data[i].suspActiveStatus)
|
||||
{
|
||||
// Going beyond max suspension compression should be treated similar to rigid body contacts.
|
||||
// Thus setting up constraints that try to emulate such contacts.
|
||||
//
|
||||
// linear l = contact normal = n
|
||||
// angular a = suspension force application offset x contact normal = cross(r, n)
|
||||
//
|
||||
// velocity at contact:
|
||||
// vl: part from linear vehicle velocity v
|
||||
// vl = dot(n, v) = dot(l, v)
|
||||
//
|
||||
// va: part from angular vehicle velocity w
|
||||
// va = dot(n, cross(w, r)) = dot(w, cross(r, n)) = dot(w, a)
|
||||
//
|
||||
// ve: part from excess suspension compression
|
||||
// ve = (geomError / dt) (note: geomError is expected to be negative here)
|
||||
//
|
||||
// velocity target vt = vl + va + ve
|
||||
// => should become 0 by applying positive impulse along l. If vt is positive,
|
||||
// nothing will happen as a negative impulse would have to be applied (but
|
||||
// min impulse is set to 0). If vt is negative, a positive impulse will get
|
||||
// applied to push vt towards 0.
|
||||
//
|
||||
|
||||
Px1DConstraint& p = constraints[numActive];
|
||||
p.linear0 = data[i].suspLinear;
|
||||
p.angular0 = data[i].suspAngular;
|
||||
p.geometricError = data[i].suspGeometricError;
|
||||
p.linear1 = PxVec3(0);
|
||||
p.angular1 = PxVec3(0);
|
||||
p.minImpulse = 0;
|
||||
p.maxImpulse = FLT_MAX;
|
||||
p.velocityTarget = 0;
|
||||
p.solveHint = PxConstraintSolveHint::eINEQUALITY;
|
||||
|
||||
// note: this is only needed for PxSolverType::eTGS to not have the angular part
|
||||
// be modified based on the linear part during substeps. Basically, it will
|
||||
// disable the constraint re-projection etc. to emulate PxSolverType::ePGS.
|
||||
p.flags |= Px1DConstraintFlag::eANGULAR_CONSTRAINT;
|
||||
|
||||
if (data[i].restitution > 0.0f)
|
||||
{
|
||||
p.flags |= Px1DConstraintFlag::eRESTITUTION;
|
||||
p.mods.bounce.restitution = data[i].restitution;
|
||||
p.mods.bounce.velocityThreshold = -FLT_MAX;
|
||||
}
|
||||
numActive++;
|
||||
}
|
||||
}
|
||||
|
||||
//Sticky tire friction constraints.
|
||||
for (PxU32 i = 0; i < PxVehiclePhysXConstraintLimits::eNB_WHEELS_PER_PXCONSTRAINT; i++)
|
||||
{
|
||||
if (data[i].tireActiveStatus[PxVehicleTireDirectionModes::eLONGITUDINAL])
|
||||
{
|
||||
Px1DConstraint& p = constraints[numActive];
|
||||
p.linear0 = data[i].tireLinears[PxVehicleTireDirectionModes::eLONGITUDINAL];
|
||||
p.angular0 = data[i].tireAngulars[PxVehicleTireDirectionModes::eLONGITUDINAL];
|
||||
p.geometricError = 0.0f;
|
||||
p.linear1 = PxVec3(0);
|
||||
p.angular1 = PxVec3(0);
|
||||
p.minImpulse = -FLT_MAX;
|
||||
p.maxImpulse = FLT_MAX;
|
||||
p.velocityTarget = 0.0f;
|
||||
p.mods.spring.damping = data[i].tireDamping[PxVehicleTireDirectionModes::eLONGITUDINAL];
|
||||
// note: no stiffness specified as this will have no effect with geometricError=0
|
||||
p.flags = Px1DConstraintFlag::eSPRING | Px1DConstraintFlag::eACCELERATION_SPRING;
|
||||
p.flags |= Px1DConstraintFlag::eANGULAR_CONSTRAINT; // see explanation of same flag usage further above
|
||||
numActive++;
|
||||
}
|
||||
}
|
||||
|
||||
//Sticky tire friction constraints.
|
||||
for (PxU32 i = 0; i < PxVehiclePhysXConstraintLimits::eNB_WHEELS_PER_PXCONSTRAINT; i++)
|
||||
{
|
||||
if (data[i].tireActiveStatus[PxVehicleTireDirectionModes::eLATERAL])
|
||||
{
|
||||
Px1DConstraint& p = constraints[numActive];
|
||||
p.linear0 = data[i].tireLinears[PxVehicleTireDirectionModes::eLATERAL];
|
||||
p.angular0 = data[i].tireAngulars[PxVehicleTireDirectionModes::eLATERAL];
|
||||
p.geometricError = 0.0f;
|
||||
p.linear1 = PxVec3(0);
|
||||
p.angular1 = PxVec3(0);
|
||||
p.minImpulse = -FLT_MAX;
|
||||
p.maxImpulse = FLT_MAX;
|
||||
p.velocityTarget = 0.0f;
|
||||
p.mods.spring.damping = data[i].tireDamping[PxVehicleTireDirectionModes::eLATERAL];
|
||||
// note: no stiffness specified as this will have no effect with geometricError=0
|
||||
p.flags = Px1DConstraintFlag::eSPRING | Px1DConstraintFlag::eACCELERATION_SPRING;
|
||||
p.flags |= Px1DConstraintFlag::eANGULAR_CONSTRAINT; // see explanation of same flag usage further above
|
||||
numActive++;
|
||||
}
|
||||
}
|
||||
|
||||
return numActive;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE void visualiseVehicleConstraint
|
||||
(PxConstraintVisualizer &viz,
|
||||
const void* constantBlock,
|
||||
const PxTransform& body0Transform,
|
||||
const PxTransform& body1Transform,
|
||||
PxU32 flags)
|
||||
{
|
||||
PX_UNUSED(&viz);
|
||||
PX_UNUSED(constantBlock);
|
||||
PX_UNUSED(body0Transform);
|
||||
PX_UNUSED(body1Transform);
|
||||
PX_UNUSED(flags);
|
||||
PX_ASSERT(body0Transform.isValid());
|
||||
PX_ASSERT(body1Transform.isValid());
|
||||
}
|
||||
|
||||
class PxVehicleConstraintConnector : public PxConstraintConnector
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleConstraintConnector() : mVehicleConstraintState(NULL) {}
|
||||
PxVehicleConstraintConnector(PxVehiclePhysXConstraintState* vehicleConstraintState) : mVehicleConstraintState(vehicleConstraintState) {}
|
||||
~PxVehicleConstraintConnector() {}
|
||||
|
||||
void setConstraintState(PxVehiclePhysXConstraintState* constraintState) { mVehicleConstraintState = constraintState; }
|
||||
|
||||
virtual void* prepareData() { return mVehicleConstraintState; }
|
||||
virtual const void* getConstantBlock() const { return mVehicleConstraintState; }
|
||||
virtual PxConstraintSolverPrep getPrep() const { return vehicleConstraintSolverPrep; }
|
||||
|
||||
//Is this necessary if physx no longer supports double-buffering?
|
||||
virtual void onConstraintRelease() { }
|
||||
|
||||
//Can be empty functions.
|
||||
virtual bool updatePvdProperties(physx::pvdsdk::PvdDataStream& pvdConnection, const PxConstraint* c, PxPvdUpdateType::Enum updateType) const
|
||||
{
|
||||
PX_UNUSED(pvdConnection);
|
||||
PX_UNUSED(c);
|
||||
PX_UNUSED(updateType);
|
||||
return true;
|
||||
}
|
||||
virtual void updateOmniPvdProperties() const { }
|
||||
virtual void onComShift(PxU32 actor) { PX_UNUSED(actor); }
|
||||
virtual void onOriginShift(const PxVec3& shift) { PX_UNUSED(shift); }
|
||||
virtual void* getExternalReference(PxU32& typeID) { typeID = PxConstraintExtIDs::eVEHICLE_JOINT; return this; }
|
||||
virtual PxBase* getSerializable() { return NULL; }
|
||||
|
||||
private:
|
||||
|
||||
PxVehiclePhysXConstraintState* mVehicleConstraintState;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A mapping between constraint state data and the associated PxConstraint instances.
|
||||
*/
|
||||
struct PxVehiclePhysXConstraints
|
||||
{
|
||||
/**
|
||||
\brief PxVehiclePhysXConstraintComponent writes to the constraintStates array and a
|
||||
callback invoked by PxScene::simulate() reads a portion from it for a block of wheels
|
||||
and writes that portion to an associated PxConstraint instance.
|
||||
*/
|
||||
PxVehiclePhysXConstraintState constraintStates[PxVehicleLimits::eMAX_NB_WHEELS];
|
||||
|
||||
/**
|
||||
\brief PxVehiclePhysXConstraintComponent writes to the constraintStates array and a
|
||||
callback invoked by PxScene::simulate() reads a portion from it for a block of wheels
|
||||
and writes that portion to an associated PxConstraint instance.
|
||||
*/
|
||||
PxConstraint* constraints[PxVehiclePhysXConstraintLimits::eNB_CONSTRAINTS_PER_VEHICLE];
|
||||
|
||||
/**
|
||||
\brief A constraint connector is necessary to connect each PxConstraint to a portion of the constraintStates array.
|
||||
*/
|
||||
PxVehicleConstraintConnector* constraintConnectors[PxVehiclePhysXConstraintLimits::eNB_CONSTRAINTS_PER_VEHICLE];
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
for (PxU32 i = 0; i < PxVehicleLimits::eMAX_NB_WHEELS; i++)
|
||||
{
|
||||
constraintStates[i].setToDefault();
|
||||
}
|
||||
for(PxU32 i = 0; i < PxVehiclePhysXConstraintLimits::eNB_CONSTRAINTS_PER_VEHICLE; i++)
|
||||
{
|
||||
constraints[i] = NULL;
|
||||
constraintConnectors[i] = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
|
||||
144
engine/third_party/physx/include/vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryComponents.h
vendored
Normal file
144
engine/third_party/physx/include/vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryComponents.h
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "vehicle2/PxVehicleComponent.h"
|
||||
|
||||
#include "vehicle2/commands/PxVehicleCommandHelpers.h"
|
||||
#include "vehicle2/roadGeometry/PxVehicleRoadGeometryState.h"
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionParams.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelParams.h"
|
||||
|
||||
#include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryFunctions.h"
|
||||
#include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryParams.h"
|
||||
#include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryState.h"
|
||||
|
||||
#include "common/PxProfileZone.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxVehiclePhysXRoadGeometrySceneQueryComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
PxVehiclePhysXRoadGeometrySceneQueryComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehiclePhysXRoadGeometrySceneQueryComponent() {}
|
||||
|
||||
/**
|
||||
\brief Provide vehicle data items for this component.
|
||||
|
||||
\param[out] axleDescription identifies the wheels on each axle.
|
||||
\param[out] roadGeomParams The road geometry parameters of the vehicle.
|
||||
\param[out] steerResponseStates The steer response state of the wheels.
|
||||
\param[out] rigidBodyState The pose, velocity etc. of the vehicle rigid body.
|
||||
\param[out] wheelParams The wheel parameters for the wheels.
|
||||
\param[out] suspensionParams The suspension parameters for the wheels.
|
||||
\param[out] materialFrictionParams The tire friction tables for the wheels.
|
||||
\param[out] roadGeometryStates The detected ground surface plane, friction value etc. for the wheels.
|
||||
\param[out] physxRoadGeometryStates Optional buffer to store additional information about the query (like actor/shape that got hit etc.).
|
||||
Set to empty if not desired.
|
||||
*/
|
||||
virtual void getDataForPhysXRoadGeometrySceneQueryComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
const PxVehiclePhysXRoadGeometryQueryParams*& roadGeomParams,
|
||||
PxVehicleArrayData<const PxReal>& steerResponseStates,
|
||||
const PxVehicleRigidBodyState*& rigidBodyState,
|
||||
PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams,
|
||||
PxVehicleArrayData<const PxVehiclePhysXMaterialFrictionParams>& materialFrictionParams,
|
||||
PxVehicleArrayData<PxVehicleRoadGeometryState>& roadGeometryStates,
|
||||
PxVehicleArrayData<PxVehiclePhysXRoadGeometryQueryState>& physxRoadGeometryStates) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(dt);
|
||||
|
||||
PX_PROFILE_ZONE("PxVehiclePhysXRoadGeometrySceneQueryComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
const PxVehiclePhysXRoadGeometryQueryParams* roadGeomParams;
|
||||
PxVehicleArrayData<const PxReal> steerResponseStates;
|
||||
const PxVehicleRigidBodyState* rigidBodyState;
|
||||
PxVehicleArrayData<const PxVehicleWheelParams> wheelParams;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams;
|
||||
PxVehicleArrayData<const PxVehiclePhysXMaterialFrictionParams> materialFrictionParams;
|
||||
PxVehicleArrayData<PxVehicleRoadGeometryState> roadGeometryStates;
|
||||
PxVehicleArrayData<PxVehiclePhysXRoadGeometryQueryState> physxRoadGeometryStates;
|
||||
|
||||
getDataForPhysXRoadGeometrySceneQueryComponent(axleDescription,
|
||||
roadGeomParams, steerResponseStates, rigidBodyState,
|
||||
wheelParams, suspensionParams, materialFrictionParams,
|
||||
roadGeometryStates, physxRoadGeometryStates);
|
||||
|
||||
if (context.getType() == PxVehicleSimulationContextType::ePHYSX)
|
||||
{
|
||||
const PxVehiclePhysXSimulationContext& physxContext = static_cast<const PxVehiclePhysXSimulationContext&>(context);
|
||||
|
||||
for(PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
|
||||
const PxQueryFilterData* fdPtr = roadGeomParams->filterDataEntries ? (roadGeomParams->filterDataEntries + wheelId) : &roadGeomParams->defaultFilterData;
|
||||
|
||||
PxVehiclePhysXRoadGeometryQueryUpdate(
|
||||
wheelParams[wheelId], suspensionParams[wheelId],
|
||||
roadGeomParams->roadGeometryQueryType, roadGeomParams->filterCallback, *fdPtr,
|
||||
materialFrictionParams[wheelId],
|
||||
steerResponseStates[wheelId], *rigidBodyState,
|
||||
*physxContext.physxScene, physxContext.physxUnitCylinderSweepMesh, context.frame,
|
||||
roadGeometryStates[wheelId],
|
||||
!physxRoadGeometryStates.isEmpty() ? &physxRoadGeometryStates[wheelId] : NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PX_ALWAYS_ASSERT();
|
||||
|
||||
for(PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
|
||||
roadGeometryStates[wheelId].setToDefault();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
|
||||
#include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
class PxScene;
|
||||
class PxConvexMesh;
|
||||
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleWheelParams;
|
||||
struct PxVehicleSuspensionParams;
|
||||
struct PxVehiclePhysXRoadGeometryQueryState;
|
||||
struct PxVehicleRigidBodyState;
|
||||
struct PxVehicleFrame;
|
||||
struct PxVehicleRoadGeometryState;
|
||||
|
||||
/**
|
||||
\brief Compute the plane of the road geometry under a wheel and the tire friction of the contact.
|
||||
\param[in] wheelParams describes the radius and halfwidth of the wheel.
|
||||
\param[in] suspParams describes the frame of the suspension and wheel and the maximum suspension travel.
|
||||
\param[in] queryType describes what type of PhysX scene query to use (see #PxVehiclePhysXRoadGeometryQueryType).
|
||||
If PxVehiclePhysXRoadGeometryQueryType::eNONE is used, no work will be done.
|
||||
\param[in] filterCallback describes the filter callback to use for the PhysX scene query. NULL is a valid input.
|
||||
\param[in] filterData describes the filter data to use for the PhysX scene query.
|
||||
\param[in] materialFrictionParams describes a mapping between PxMaterial and friction in order to compute a tire friction value.
|
||||
\param[in] wheelYawAngle is the yaw angle (in radians) of the wheel.
|
||||
\param[in] rigidBodyState describes the pose of the rigid body.
|
||||
\param[in] scene is the PhysX scene that will be queried by the scene query.
|
||||
\param[in] unitCylinderSweepMesh is a convex cylindrical mesh of unit radius and half-width to be used in
|
||||
the event that a sweep query is to be used.
|
||||
\param[in] frame describes the lateral, longitudinal and vertical axes and is used to scale unitCylinderSweepMesh
|
||||
by the wheel's radius and half-width.
|
||||
\param[out] roadGeomState contains the plane and friction of the road geometry under the wheel.
|
||||
\param[out] physxRoadGeometryState Optional buffer to store additional information about the query (like actor/shape that got hit etc.).
|
||||
Set to NULL if not needed.
|
||||
\note PxVehicleRoadGeometryState::hitState will have value false in the event that the there is no reachable road geometry under the wheel and
|
||||
true if there is reachable road geometry under the wheel. Road geometry is considered reachable if the suspension can elongate from its
|
||||
reference pose far enough to place wheel on the ground.
|
||||
*/
|
||||
void PxVehiclePhysXRoadGeometryQueryUpdate
|
||||
(const PxVehicleWheelParams& wheelParams, const PxVehicleSuspensionParams& suspParams,
|
||||
const PxVehiclePhysXRoadGeometryQueryType::Enum queryType,
|
||||
PxQueryFilterCallback* filterCallback, const PxQueryFilterData& filterData,
|
||||
const PxVehiclePhysXMaterialFrictionParams& materialFrictionParams,
|
||||
const PxReal wheelYawAngle, const PxVehicleRigidBodyState& rigidBodyState,
|
||||
const PxScene& scene, const PxConvexMesh* unitCylinderSweepMesh,
|
||||
const PxVehicleFrame& frame,
|
||||
PxVehicleRoadGeometryState& roadGeomState,
|
||||
PxVehiclePhysXRoadGeometryQueryState* physxRoadGeometryState);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
69
engine/third_party/physx/include/vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryHelpers.h
vendored
Normal file
69
engine/third_party/physx/include/vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryHelpers.h
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
|
||||
class PxConvexMesh;
|
||||
class PxPhysics;
|
||||
struct PxCookingParams;
|
||||
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleFrame;
|
||||
|
||||
/**
|
||||
\brief Create a cylindrical mesh with unit radius and half-width.
|
||||
\param[in] vehicleFrame is a description of the lateral and longitudinal axes.
|
||||
\param[in] physics is a PxPhysics instance.
|
||||
\param[in] params is a PxCookingParams instance
|
||||
\return Return a PxConvexMesh instance that represents a convex hull with unit radius and half-width.
|
||||
\see PxVehicleUnitCylinderSweepMeshDestroy
|
||||
*/
|
||||
PxConvexMesh* PxVehicleUnitCylinderSweepMeshCreate(const PxVehicleFrame& vehicleFrame, PxPhysics& physics, const PxCookingParams& params);
|
||||
|
||||
/**
|
||||
\brief Release the mesh created with PxVehicleUnitCylinderSweepMeshCreate.
|
||||
\param[in] mesh is a PxConvexMesh instance.
|
||||
\see PxVehicleUnitCylinderSweepMeshCreate
|
||||
*/
|
||||
void PxVehicleUnitCylinderSweepMeshDestroy(PxConvexMesh* mesh);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
174
engine/third_party/physx/include/vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryParams.h
vendored
Normal file
174
engine/third_party/physx/include/vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryParams.h
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxFoundation.h"
|
||||
|
||||
#include "PxQueryFiltering.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
class PxMaterial;
|
||||
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleFrame;
|
||||
struct PxVehicleScale;
|
||||
|
||||
/**
|
||||
\brief PhysX scene queries may be raycasts or sweeps.
|
||||
\note eNONE will result in no PhysX scene query. This option will not overwrite the associated PxVehicleRoadGeometryState.
|
||||
*/
|
||||
struct PxVehiclePhysXRoadGeometryQueryType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eNONE = 0, //!< Info about the road geometry below the wheel is provided by the user
|
||||
eRAYCAST, //!< The road geometry below the wheel is analyzed using a raycast query
|
||||
eSWEEP, //!< The road geometry below the wheel is analyzed using a sweep query
|
||||
eMAX_NB
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A description of type of PhysX scene query and the filter data to apply to the query.
|
||||
*/
|
||||
struct PxVehiclePhysXRoadGeometryQueryParams
|
||||
{
|
||||
/**
|
||||
\brief The default filter data to use for the physx scene query.
|
||||
|
||||
If per wheel filter data is provided in #filterDataEntries, then this member
|
||||
will be ignored.
|
||||
|
||||
\see PxSceneQuerySystemBase::raycast
|
||||
\see PxSceneQuerySystemBase::sweep
|
||||
*/
|
||||
PxQueryFilterData defaultFilterData;
|
||||
|
||||
/**
|
||||
\brief Array of filter data entries (one per wheel) to use for the physx scene query.
|
||||
|
||||
A null pointer is allowed in which case #defaultFilterData will be used for all wheels.
|
||||
|
||||
\see PxSceneQuerySystemBase::raycast
|
||||
\see PxSceneQuerySystemBase::sweep
|
||||
*/
|
||||
PxQueryFilterData* filterDataEntries;
|
||||
|
||||
/**
|
||||
\brief A filter callback to be used by the physx scene query
|
||||
\note A null pointer is allowed.
|
||||
\see PxSceneQuerySystemBase::raycast
|
||||
\see PxSceneQuerySystemBase::sweep
|
||||
*/
|
||||
PxQueryFilterCallback* filterCallback;
|
||||
|
||||
/**
|
||||
\brief A description of the type of physx scene query to employ.
|
||||
\see PxSceneQuerySystemBase::raycast
|
||||
\see PxSceneQuerySystemBase::sweep
|
||||
*/
|
||||
PxVehiclePhysXRoadGeometryQueryType::Enum roadGeometryQueryType;
|
||||
|
||||
PX_FORCE_INLINE PxVehiclePhysXRoadGeometryQueryParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PX_UNUSED(srcScale);
|
||||
PX_UNUSED(trgScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(roadGeometryQueryType < PxVehiclePhysXRoadGeometryQueryType::eMAX_NB, "PxVehiclePhysXRoadGeometryQueryParams.roadGeometryQueryType has illegal value", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
A mapping between PxMaterial and a friction value to be used by the tire model.
|
||||
\see PxVehiclePhysXMaterialFrictionParams
|
||||
*/
|
||||
struct PxVehiclePhysXMaterialFriction
|
||||
{
|
||||
/**
|
||||
\brief A PxMaterial instance that is to be mapped to a friction value.
|
||||
*/
|
||||
const PxMaterial* material;
|
||||
|
||||
/**
|
||||
\brief A friction value that is to be mapped to a PxMaterial instance.
|
||||
\note friction must have value greater than or equal to zero.
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
|
||||
\see PxVehicleTireGripState::friction
|
||||
*/
|
||||
PxReal friction;
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(friction >= 0.0f, "PxVehiclePhysXMaterialFriction.friction must be greater than or equal to zero", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A mappping between PxMaterial instance and friction for multiple PxMaterial intances.
|
||||
*/
|
||||
struct PxVehiclePhysXMaterialFrictionParams
|
||||
{
|
||||
PxVehiclePhysXMaterialFriction* materialFrictions; //!< An array of mappings between PxMaterial and friction.
|
||||
PxU32 nbMaterialFrictions; //!< The number of mappings between PxMaterial and friction.
|
||||
PxReal defaultFriction; //!< A default friction value to be used in the event that the PxMaterial under the tire is not found in the array #materialFrictions.
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
for (PxU32 i = 0; i < nbMaterialFrictions; i++)
|
||||
{
|
||||
if (!materialFrictions[i].isValid())
|
||||
return false;
|
||||
}
|
||||
PX_CHECK_AND_RETURN_VAL(defaultFriction >= 0.0f, "PxVehiclePhysXMaterialFrictionParams.defaultFriction must be greater than or equal to zero", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
65
engine/third_party/physx/include/vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryState.h
vendored
Normal file
65
engine/third_party/physx/include/vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryState.h
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxMemory.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
|
||||
class PxRigidActor;
|
||||
class PxShape;
|
||||
class PxMaterial;
|
||||
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehiclePhysXRoadGeometryQueryState
|
||||
{
|
||||
PxRigidActor* actor; //!< The actor that got hit by the query.
|
||||
PxShape* shape; //!< The shape that got hit by the query.
|
||||
PxMaterial* material; //!< The material at the hit point.
|
||||
PxVec3 hitPosition; //!< The hit position in world space.
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehiclePhysXRoadGeometryQueryState));
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
|
||||
351
engine/third_party/physx/include/vehicle2/pvd/PxVehiclePvdComponents.h
vendored
Normal file
351
engine/third_party/physx/include/vehicle2/pvd/PxVehiclePvdComponents.h
vendored
Normal file
@@ -0,0 +1,351 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "vehicle2/PxVehicleComponent.h"
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "PxVehiclePvdFunctions.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
#define VEHICLE_FLOAT_ARRAY_DATA(b) PxVehicleArrayData<PxReal> b; b.setEmpty();
|
||||
#define VEHICLE_ARRAY_DATA(a, b) PxVehicleArrayData<const a> b; b.setEmpty();
|
||||
#define VEHICLE_SIZED_ARRAY_DATA(a, b) PxVehicleSizedArrayData<const a> b; b.setEmpty();
|
||||
|
||||
class PxVehiclePVDComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehiclePVDComponent() : PxVehicleComponent() , firstTime(true) {}
|
||||
virtual ~PxVehiclePVDComponent() {}
|
||||
|
||||
virtual void getDataForPVDComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
const PxVehicleRigidBodyParams*& rbodyParams, const PxVehicleRigidBodyState*& rbodyState,
|
||||
const PxVehicleSuspensionStateCalculationParams*& suspStateCalcParams,
|
||||
PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams>& brakeResponseParams,
|
||||
const PxVehicleSteerCommandResponseParams*& steerResponseParams,
|
||||
const PxVehicleAckermannParams*& ackermannParams,
|
||||
PxVehicleArrayData<PxReal>& brakeResponseStates,
|
||||
PxVehicleArrayData<PxReal>& steerResponseStates,
|
||||
PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
PxVehicleArrayData<const PxVehicleWheelActuationState>& wheelActuationStates,
|
||||
PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates,
|
||||
PxVehicleArrayData<const PxVehicleWheelLocalPose>& wheelLocalPoses,
|
||||
PxVehicleArrayData<const PxVehicleRoadGeometryState>& roadGeomStates,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams>& suspParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceParams>& suspCompParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionForceParams>& suspForceParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionState>& suspStates,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspCompStates,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionForce>& suspForces,
|
||||
PxVehicleArrayData<const PxVehicleTireForceParams>& tireForceParams,
|
||||
PxVehicleArrayData<const PxVehicleTireDirectionState>& tireDirectionStates,
|
||||
PxVehicleArrayData<const PxVehicleTireSpeedState>& tireSpeedStates,
|
||||
PxVehicleArrayData<const PxVehicleTireSlipState>& tireSlipStates,
|
||||
PxVehicleArrayData<const PxVehicleTireStickyState>& tireStickyStates,
|
||||
PxVehicleArrayData<const PxVehicleTireGripState>& tireGripStates,
|
||||
PxVehicleArrayData<const PxVehicleTireCamberAngleState>& tireCamberStates,
|
||||
PxVehicleArrayData<const PxVehicleTireForce>& tireForces,
|
||||
PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams>& antiRollForceParams,
|
||||
const PxVehicleAntiRollTorque*& antiRollTorque,
|
||||
const PxVehicleCommandState*& commandState,
|
||||
const PxVehicleDirectDriveThrottleCommandResponseParams*& directDriveThrottleResponseParams,
|
||||
const PxVehicleDirectDriveTransmissionCommandState*& directDriveTransmissionState,
|
||||
PxVehicleArrayData<PxReal>& directDrivethrottleResponseState,
|
||||
const PxVehicleClutchCommandResponseParams*& clutchResponseParams,
|
||||
const PxVehicleClutchParams*& clutchParams,
|
||||
const PxVehicleEngineParams*& engineParams,
|
||||
const PxVehicleGearboxParams*& gearboxParams,
|
||||
const PxVehicleAutoboxParams*& autoboxParams,
|
||||
const PxVehicleMultiWheelDriveDifferentialParams*& multiWheelDiffParams,
|
||||
const PxVehicleFourWheelDriveDifferentialParams*& fourWheelDiffParams,
|
||||
const PxVehicleTankDriveDifferentialParams*& tankDiffParams,
|
||||
const PxVehicleEngineDriveTransmissionCommandState*& engineDriveTransmissionState,
|
||||
const PxVehicleTankDriveTransmissionCommandState*& tankDriveTransmissionState,
|
||||
const PxVehicleClutchCommandResponseState*& clutchResponseState,
|
||||
const PxVehicleEngineDriveThrottleCommandResponseState*& engineDriveThrottleResponseState,
|
||||
const PxVehicleEngineState*& engineState,
|
||||
const PxVehicleGearboxState*& gearboxState,
|
||||
const PxVehicleAutoboxState*& autoboxState,
|
||||
const PxVehicleDifferentialState*& diffState,
|
||||
const PxVehicleClutchSlipState*& clutchSlipState,
|
||||
PxVehicleArrayData<const PxVehiclePhysXSuspensionLimitConstraintParams>& physxConstraintParams,
|
||||
PxVehicleArrayData<const PxVehiclePhysXMaterialFrictionParams>& physxMaterialFrictionParams,
|
||||
const PxVehiclePhysXActor*& physxActor,
|
||||
const PxVehiclePhysXRoadGeometryQueryParams*& physxRoadGeomQryParams,
|
||||
PxVehicleArrayData<const PxVehiclePhysXRoadGeometryQueryState>& physxRoadGeomStates,
|
||||
PxVehicleArrayData<const PxVehiclePhysXConstraintState>& physxConstraintStates,
|
||||
const PxVehiclePhysXSteerState*& physxSteerState,
|
||||
PxVehiclePvdObjectHandles*& objectHandles) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_UNUSED(dt);
|
||||
PX_UNUSED(context);
|
||||
|
||||
OmniPvdWriter* pvdWriter = context.pvdContext.writer;
|
||||
|
||||
if(!context.pvdContext.attributeHandles || !pvdWriter)
|
||||
return true;
|
||||
|
||||
const PxVehicleAxleDescription* axleDesc = NULL;
|
||||
const PxVehicleRigidBodyParams* rbodyParams = NULL;
|
||||
const PxVehicleRigidBodyState* rbodyState = NULL;
|
||||
const PxVehicleSuspensionStateCalculationParams* suspStateCalcParams = NULL;
|
||||
VEHICLE_SIZED_ARRAY_DATA(PxVehicleBrakeCommandResponseParams, brakeResponseParams);
|
||||
const PxVehicleSteerCommandResponseParams* steerResponseParams = NULL;
|
||||
const PxVehicleAckermannParams* ackermannParams = NULL;
|
||||
VEHICLE_FLOAT_ARRAY_DATA(brakeResponseStates);
|
||||
VEHICLE_FLOAT_ARRAY_DATA(steerResponseStates);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleWheelParams, wheelParams);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleWheelActuationState, wheelActuationStates);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleWheelRigidBody1dState, wheelRigidBody1dStates);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleWheelLocalPose, wheelLocalPoses);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleRoadGeometryState, roadGeomStates);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleSuspensionParams, suspParams);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleSuspensionComplianceParams, suspComplianceParams);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleSuspensionForceParams, suspForceParams);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleSuspensionState, suspStates);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleSuspensionComplianceState, suspComplianceStates);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleSuspensionForce, suspForces);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleTireForceParams, tireForceParams);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleTireDirectionState, tireDirectionStates);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleTireSpeedState, tireSpeedStates);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleTireSlipState, tireSlipStates);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleTireStickyState, tireStickyStates);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleTireGripState, tireGripStates);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleTireCamberAngleState, tireCamberStates);
|
||||
VEHICLE_ARRAY_DATA(PxVehicleTireForce, tireForces);
|
||||
VEHICLE_SIZED_ARRAY_DATA(PxVehicleAntiRollForceParams, antiRollParams);
|
||||
const PxVehicleAntiRollTorque* antiRollTorque = NULL;
|
||||
const PxVehicleCommandState* commandState = NULL;
|
||||
const PxVehicleDirectDriveThrottleCommandResponseParams* directDriveThrottleResponseParams = NULL;
|
||||
const PxVehicleDirectDriveTransmissionCommandState* directDriveTransmissionState = NULL;
|
||||
VEHICLE_FLOAT_ARRAY_DATA(directDrivethrottleResponseState);
|
||||
const PxVehicleClutchCommandResponseParams* clutchResponseParams = NULL;
|
||||
const PxVehicleClutchParams* clutchParams = NULL;
|
||||
const PxVehicleEngineParams* engineParams = NULL;
|
||||
const PxVehicleGearboxParams* gearboxParams = NULL;
|
||||
const PxVehicleAutoboxParams* autoboxParams = NULL;
|
||||
const PxVehicleMultiWheelDriveDifferentialParams* multiWheelDiffParams = NULL;
|
||||
const PxVehicleFourWheelDriveDifferentialParams* fourWheelDiffParams = NULL;
|
||||
const PxVehicleTankDriveDifferentialParams* tankDiffParams = NULL;
|
||||
const PxVehicleEngineDriveTransmissionCommandState* engineDriveTransmissionCommandState = NULL;
|
||||
const PxVehicleTankDriveTransmissionCommandState* tankDriveTransmissionCommandState = NULL;
|
||||
const PxVehicleClutchCommandResponseState* clutchResponseState = NULL;
|
||||
const PxVehicleEngineDriveThrottleCommandResponseState* throttleResponseState = NULL;
|
||||
const PxVehicleEngineState* engineState = NULL;
|
||||
const PxVehicleGearboxState* gearboxState = NULL;
|
||||
const PxVehicleAutoboxState* autoboxState = NULL;
|
||||
const PxVehicleDifferentialState* diffState = NULL;
|
||||
const PxVehicleClutchSlipState* clutchSlipState = NULL;
|
||||
VEHICLE_ARRAY_DATA(PxVehiclePhysXSuspensionLimitConstraintParams, physxConstraintParams);
|
||||
VEHICLE_ARRAY_DATA(PxVehiclePhysXMaterialFrictionParams, physxMaterialFrictionParams);
|
||||
const PxVehiclePhysXActor* physxActor = NULL;
|
||||
const PxVehiclePhysXRoadGeometryQueryParams* physxRoadGeomQryParams = NULL;
|
||||
VEHICLE_ARRAY_DATA(PxVehiclePhysXRoadGeometryQueryState, physxRoadGeomStates);
|
||||
VEHICLE_ARRAY_DATA(PxVehiclePhysXConstraintState, physxConstraintStates);
|
||||
const PxVehiclePhysXSteerState* physxSteerState = NULL;
|
||||
PxVehiclePvdObjectHandles* omniPvdObjectHandles = NULL;
|
||||
|
||||
getDataForPVDComponent(
|
||||
axleDesc,
|
||||
rbodyParams, rbodyState,
|
||||
suspStateCalcParams,
|
||||
brakeResponseParams, steerResponseParams, ackermannParams,
|
||||
brakeResponseStates, steerResponseStates,
|
||||
wheelParams,
|
||||
wheelActuationStates, wheelRigidBody1dStates, wheelLocalPoses,
|
||||
roadGeomStates,
|
||||
suspParams, suspComplianceParams, suspForceParams,
|
||||
suspStates, suspComplianceStates,
|
||||
suspForces,
|
||||
tireForceParams,
|
||||
tireDirectionStates, tireSpeedStates, tireSlipStates, tireStickyStates, tireGripStates, tireCamberStates,
|
||||
tireForces,
|
||||
antiRollParams, antiRollTorque,
|
||||
commandState,
|
||||
directDriveThrottleResponseParams, directDriveTransmissionState, directDrivethrottleResponseState,
|
||||
clutchResponseParams, clutchParams, engineParams, gearboxParams, autoboxParams,
|
||||
multiWheelDiffParams, fourWheelDiffParams, tankDiffParams,
|
||||
engineDriveTransmissionCommandState, tankDriveTransmissionCommandState,
|
||||
clutchResponseState, throttleResponseState, engineState, gearboxState, autoboxState, diffState, clutchSlipState,
|
||||
physxConstraintParams, physxMaterialFrictionParams,
|
||||
physxActor, physxRoadGeomQryParams, physxRoadGeomStates, physxConstraintStates, physxSteerState,
|
||||
omniPvdObjectHandles);
|
||||
|
||||
if(!omniPvdObjectHandles)
|
||||
return true;
|
||||
|
||||
if(firstTime)
|
||||
{
|
||||
PxVehiclePvdRigidBodyRegister(
|
||||
rbodyParams, rbodyState,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
PxVehiclePvdSuspensionStateCalculationParamsRegister(
|
||||
suspStateCalcParams,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
PxVehiclePvdCommandResponseRegister(
|
||||
brakeResponseParams, steerResponseParams, ackermannParams,
|
||||
brakeResponseStates, steerResponseStates,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
PxVehiclePvdWheelAttachmentsRegister(
|
||||
*axleDesc,
|
||||
wheelParams, wheelActuationStates, wheelRigidBody1dStates, wheelLocalPoses,
|
||||
roadGeomStates,
|
||||
suspParams, suspComplianceParams, suspForceParams, suspStates, suspComplianceStates,
|
||||
suspForces,
|
||||
tireForceParams,
|
||||
tireDirectionStates, tireSpeedStates, tireSlipStates, tireStickyStates, tireGripStates, tireCamberStates,
|
||||
tireForces,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
PxVehiclePvdAntiRollsRegister(
|
||||
antiRollParams, antiRollTorque,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
if (engineParams)
|
||||
{
|
||||
PxVehiclePvdEngineDrivetrainRegister(
|
||||
commandState, engineDriveTransmissionCommandState, tankDriveTransmissionCommandState,
|
||||
clutchResponseParams, clutchParams, engineParams, gearboxParams, autoboxParams,
|
||||
multiWheelDiffParams, fourWheelDiffParams, tankDiffParams,
|
||||
clutchResponseState, throttleResponseState, engineState, gearboxState, autoboxState, diffState, clutchSlipState,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
}
|
||||
else
|
||||
{
|
||||
PxVehiclePvdDirectDrivetrainRegister(
|
||||
commandState, directDriveTransmissionState,
|
||||
directDriveThrottleResponseParams,
|
||||
directDrivethrottleResponseState,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
}
|
||||
|
||||
PxVehiclePvdPhysXWheelAttachmentRegister(
|
||||
*axleDesc,
|
||||
physxConstraintParams, physxMaterialFrictionParams,
|
||||
physxActor, physxRoadGeomQryParams, physxRoadGeomStates, physxConstraintStates,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
PxVehiclePvdPhysXRigidActorRegister(
|
||||
physxActor,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
PxVehiclePvdPhysXSteerStateRegister(
|
||||
physxSteerState,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
firstTime = false;
|
||||
}
|
||||
|
||||
PxVehiclePvdRigidBodyWrite(
|
||||
rbodyParams, rbodyState,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
PxVehiclePvdSuspensionStateCalculationParamsWrite(
|
||||
suspStateCalcParams,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
PxVehiclePvdCommandResponseWrite(
|
||||
*axleDesc, brakeResponseParams, steerResponseParams, ackermannParams,
|
||||
brakeResponseStates, steerResponseStates,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
PxVehiclePvdWheelAttachmentsWrite(
|
||||
*axleDesc,
|
||||
wheelParams, wheelActuationStates, wheelRigidBody1dStates, wheelLocalPoses,
|
||||
roadGeomStates,
|
||||
suspParams, suspComplianceParams, suspForceParams, suspStates, suspComplianceStates,
|
||||
suspForces,
|
||||
tireForceParams,
|
||||
tireDirectionStates, tireSpeedStates, tireSlipStates, tireStickyStates, tireGripStates, tireCamberStates,
|
||||
tireForces,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
PxVehiclePvdAntiRollsWrite(
|
||||
antiRollParams, antiRollTorque,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
if (engineParams)
|
||||
{
|
||||
PxVehiclePvdEngineDrivetrainWrite(
|
||||
commandState, engineDriveTransmissionCommandState, tankDriveTransmissionCommandState,
|
||||
clutchResponseParams, clutchParams, engineParams, gearboxParams, autoboxParams,
|
||||
multiWheelDiffParams, fourWheelDiffParams, tankDiffParams,
|
||||
clutchResponseState, throttleResponseState, engineState, gearboxState, autoboxState, diffState, clutchSlipState,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
}
|
||||
else
|
||||
{
|
||||
PxVehiclePvdDirectDrivetrainWrite(
|
||||
*axleDesc,
|
||||
commandState, directDriveTransmissionState,
|
||||
directDriveThrottleResponseParams,
|
||||
directDrivethrottleResponseState,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
}
|
||||
|
||||
PxVehiclePvdPhysXWheelAttachmentWrite(
|
||||
*axleDesc,
|
||||
physxConstraintParams, physxMaterialFrictionParams,
|
||||
physxActor, physxRoadGeomQryParams, physxRoadGeomStates, physxConstraintStates,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
PxVehiclePvdPhysXRigidActorWrite(
|
||||
physxActor,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
PxVehiclePvdPhysXSteerStateWrite(
|
||||
physxSteerState,
|
||||
*context.pvdContext.attributeHandles, *omniPvdObjectHandles, *pvdWriter);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool firstTime;
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
634
engine/third_party/physx/include/vehicle2/pvd/PxVehiclePvdFunctions.h
vendored
Normal file
634
engine/third_party/physx/include/vehicle2/pvd/PxVehiclePvdFunctions.h
vendored
Normal file
@@ -0,0 +1,634 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "vehicle2/braking/PxVehicleBrakingParams.h"
|
||||
#include "vehicle2/commands/PxVehicleCommandStates.h"
|
||||
#include "vehicle2/drivetrain/PxVehicleDrivetrainParams.h"
|
||||
#include "vehicle2/drivetrain/PxVehicleDrivetrainStates.h"
|
||||
#include "vehicle2/physxActor/PxVehiclePhysXActorStates.h"
|
||||
#include "vehicle2/physxConstraints/PxVehiclePhysXConstraintParams.h"
|
||||
#include "vehicle2/physxConstraints/PxVehiclePhysXConstraintStates.h"
|
||||
#include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryParams.h"
|
||||
#include "vehicle2/physxRoadGeometry/PxVehiclePhysXRoadGeometryState.h"
|
||||
#include "vehicle2/roadGeometry/PxVehicleRoadGeometryState.h"
|
||||
#include "vehicle2/steering/PxVehicleSteeringParams.h"
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionParams.h"
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionStates.h"
|
||||
#include "vehicle2/tire/PxVehicleTireParams.h"
|
||||
#include "vehicle2/tire/PxVehicleTireStates.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelParams.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelStates.h"
|
||||
|
||||
class OmniPvdWriter;
|
||||
namespace physx
|
||||
{
|
||||
class PxAllocatorCallback;
|
||||
namespace vehicle2
|
||||
{
|
||||
struct PxVehiclePvdAttributeHandles;
|
||||
struct PxVehiclePvdObjectHandles;
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Create object instances in omnipvd that will be used to reflect the parameters and state of the rigid body of a vehicle instance.
|
||||
Handles to the created object instances will be stored in a PxVehiclePvdObjectHandles instance.
|
||||
\param[in] rbodyParams describes the parameters of the vehicle's rigid body.
|
||||
\param[in] rbodyState describes the state of the vehicle's rigid body.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If rbodyParams is NULL, omnipvd will not reflect rigid body parameters.
|
||||
\note If rbodyState is NULL, omnipvd will not reflect rigid body state.
|
||||
\note PxVehiclePvdRigidBodyRegister should be called once for each vehicle instance.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdRigidBodyWrite
|
||||
*/
|
||||
void PxVehiclePvdRigidBodyRegister
|
||||
(const PxVehicleRigidBodyParams* rbodyParams, const PxVehicleRigidBodyState* rbodyState,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Write the parameters and state of the rigid body of a vehicle instance to omnipvd.
|
||||
\param[in] rbodyParams describes the parameters of the vehicle's rigid body.
|
||||
\param[in] rbodyState describes the state of the vehicle's rigid body.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If rbodyParams is NULL but a non-NULL value was used in PxVehiclePvdRigidBodyRegister(), the rigid body parameters will not be updated in omnipvd.
|
||||
\note If rbodyState is NULL but a non-NULL value was used in PxVehiclePvdRigidBodyRegister(), the rigid body state will not be updated in omnipvd.
|
||||
\note omniWriter must be the same instance used in PxVehiclePvdRigidBodyRegister().
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdRigidBodyRegister
|
||||
*/
|
||||
void PxVehiclePvdRigidBodyWrite
|
||||
(const PxVehicleRigidBodyParams* rbodyParams, const PxVehicleRigidBodyState* rbodyState,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Register object instances in omnipvd that will be used to reflect the suspension state calculation parameters of a vehicle instance.
|
||||
\param[in] suspStateCalcParams describes parameters used to calculate suspension state.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If suspStateCalcParams is NULL, omnipvd will not reflect the suspension state calculation parameters.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdSuspensionStateCalculationParamsWrite
|
||||
*/
|
||||
void PxVehiclePvdSuspensionStateCalculationParamsRegister
|
||||
(const PxVehicleSuspensionStateCalculationParams* suspStateCalcParams,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Write the parameters and state of the rigid body of a vehicle instance to omnipvd.
|
||||
\param[in] suspStateCalcParams describes parameters used to calculate suspension state.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If suspStateCalcParams is NULL but a non-NULL value was used in void PxVehiclePvdSuspensionStateCalculationParamsRegister(),
|
||||
the suspension state calculation parameters will not be updated in omnipvd.
|
||||
\note omniWriter must be the same instance used in PxVehiclePvdSuspensionStateCalculationParamsRegister().
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdSuspensionStateCalculationParamsRegister
|
||||
*/
|
||||
void PxVehiclePvdSuspensionStateCalculationParamsWrite
|
||||
(const PxVehicleSuspensionStateCalculationParams* suspStateCalcParams,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Register object instances in omnipvd that will be used to reflect the brake and steer command response parameters of a vehicle instance.
|
||||
\param[in] brakeResponseParams is an array of brake command response parameters.
|
||||
\param[in] steerResponseParams describes the steer command response parameters.
|
||||
\param[in] ackermannParams defines the Ackermann steer correction.
|
||||
\param[in] brakeResponseStates is an array of brake responses torqyes,
|
||||
\param[in] steerResponseStates is an array of steer response angles.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If brakeResponseParams is empty, omnipvd will not reflect any brake command response parameters.
|
||||
\note If steerResponseParams is NULL, omnipvd will not reflect the steer command response parameters.
|
||||
\note If ackermannParams is NULL, omnipvd will not reflect any Ackermann steer correction parameters.
|
||||
\note If brakeResponseStates is empty, omnipvd will not reflect any brake command response state.
|
||||
\note If steerResponseStates is empty, omnipvd will not reflect any steer command response state.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdCommandResponseWrite
|
||||
*/
|
||||
void PxVehiclePvdCommandResponseRegister
|
||||
(const PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams>& brakeResponseParams,
|
||||
const PxVehicleSteerCommandResponseParams* steerResponseParams,
|
||||
const PxVehicleAckermannParams* ackermannParams,
|
||||
const PxVehicleArrayData<PxReal>& brakeResponseStates,
|
||||
const PxVehicleArrayData<PxReal>& steerResponseStates,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Write brake and steer command response parameters to omnipvd.
|
||||
\param[in] axleDesc is a description of the wheels and axles of a vehicle.
|
||||
\param[in] brakeResponseParams is an array of brake command response parameters.
|
||||
\param[in] steerResponseParams describes the steer command response parameters.
|
||||
\param[in] ackermannParams defines the Ackermann steer correction.
|
||||
\param[in] brakeResponseStates is an array of brake response torques.
|
||||
\param[in] steerResponseStates is an array of steer response angles.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If brakeResponseParams is empty but a non-empty array was used in PxVehiclePvdCommandResponseRegister(),
|
||||
the brake command response parameters will not be updated in omnipvd.
|
||||
\note If steerResponseParams is non-NULL but a NULL value was used in PxVehiclePvdCommandResponseRegister(),
|
||||
the steer command parameters will not be updated in omnipvd.
|
||||
\note If ackermannParams is non-NULL but a NULL value was used in PxVehiclePvdCommandResponseRegister(),
|
||||
the Ackermann steer correction parameters will not be updated in omnipvd.
|
||||
\note If brakeResponseStates is empty but a non-empty array was used in PxVehiclePvdCommandResponseRegister(),
|
||||
the brake response states will not be updated in omnipvd.
|
||||
\note If steerResponseStates is empty but a non-empty array was used in PxVehiclePvdCommandResponseRegister(),
|
||||
the steer response states will not be updated in omnipvd.
|
||||
\note omniWriter must be the same instance used in PxVehiclePvdCommandResponseRegister().
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdCommandResponseRegister
|
||||
*/
|
||||
void PxVehiclePvdCommandResponseWrite
|
||||
(const PxVehicleAxleDescription& axleDesc,
|
||||
const PxVehicleSizedArrayData<const PxVehicleBrakeCommandResponseParams>& brakeResponseParams,
|
||||
const PxVehicleSteerCommandResponseParams* steerResponseParams,
|
||||
const PxVehicleAckermannParams* ackermannParams,
|
||||
const PxVehicleArrayData<PxReal>& brakeResponseStates,
|
||||
const PxVehicleArrayData<PxReal>& steerResponseStates,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Register object instances in omnipvd that will be used to reflect wheel attachment data such as tires, suspensions and wheels.
|
||||
\param[in] axleDesc is a description of the wheels and axles of a vehicle.
|
||||
\param[in] wheelParams is an array of wheel parameters.
|
||||
\param[in] wheelActuationStates is an array of wheel actuation states.
|
||||
\param[in] wheelRigidBody1dStates is an array of wheel rigid body states.
|
||||
\param[in] wheelLocalPoses is an array of wheel local poses.
|
||||
\param[in] roadGeometryStates is an array of road geometry states.
|
||||
\param[in] suspParams is an array of suspension parameters.
|
||||
\param[in] suspCompParams is an array of suspension compliance parameters.
|
||||
\param[in] suspForceParams is an array of suspension force parameters.
|
||||
\param[in] suspStates is an array of suspension states.
|
||||
\param[in] suspCompStates is an array of suspension compliance states.
|
||||
\param[in] suspForces is an array of suspension forces.
|
||||
\param[in] tireForceParams is an array of tire force parameters.
|
||||
\param[in] tireDirectionStates is an array of tire direction states.
|
||||
\param[in] tireSpeedStates is an array of tire speed states.
|
||||
\param[in] tireSlipStates is an array of tire slip states.
|
||||
\param[in] tireStickyStates is an array of tire sticky states.
|
||||
\param[in] tireGripStates is an array of tire grip states.
|
||||
\param[in] tireCamberStates is an array of tire camber states.
|
||||
\param[in] tireForces is an array of tire forces.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If any array is empty, the corresponding data will not be reflected in omnipvd.
|
||||
\note Each array must either be empty or contain an entry for each wheel present in axleDesc.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdWheelAttachmentsWrite
|
||||
*/
|
||||
void PxVehiclePvdWheelAttachmentsRegister
|
||||
(const PxVehicleAxleDescription& axleDesc,
|
||||
const PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
const PxVehicleArrayData<const PxVehicleWheelActuationState>& wheelActuationStates,
|
||||
const PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates,
|
||||
const PxVehicleArrayData<const PxVehicleWheelLocalPose>& wheelLocalPoses,
|
||||
const PxVehicleArrayData<const PxVehicleRoadGeometryState>& roadGeometryStates,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionParams>& suspParams,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionComplianceParams>& suspCompParams,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionForceParams>& suspForceParams,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionState>& suspStates,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspCompStates,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionForce>& suspForces,
|
||||
const PxVehicleArrayData<const PxVehicleTireForceParams>& tireForceParams,
|
||||
const PxVehicleArrayData<const PxVehicleTireDirectionState>& tireDirectionStates,
|
||||
const PxVehicleArrayData<const PxVehicleTireSpeedState>& tireSpeedStates,
|
||||
const PxVehicleArrayData<const PxVehicleTireSlipState>& tireSlipStates,
|
||||
const PxVehicleArrayData<const PxVehicleTireStickyState>& tireStickyStates,
|
||||
const PxVehicleArrayData<const PxVehicleTireGripState>& tireGripStates,
|
||||
const PxVehicleArrayData<const PxVehicleTireCamberAngleState>& tireCamberStates,
|
||||
const PxVehicleArrayData<const PxVehicleTireForce>& tireForces,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Write wheel attachment data such as tire, suspension and wheel data to omnipvd.
|
||||
\param[in] axleDesc is a description of the wheels and axles of a vehicle.
|
||||
\param[in] wheelParams is an array of wheel parameters.
|
||||
\param[in] wheelActuationStates is an array of wheel actuation states.
|
||||
\param[in] wheelRigidBody1dStates is an array of wheel rigid body states.
|
||||
\param[in] wheelLocalPoses is an array of wheel local poses.
|
||||
\param[in] roadGeometryStates is an array of road geometry states.
|
||||
\param[in] suspParams is an array of suspension parameters.
|
||||
\param[in] suspCompParams is an array of suspension compliance parameters.
|
||||
\param[in] suspForceParams is an array of suspension force parameters.
|
||||
\param[in] suspStates is an array of suspension states.
|
||||
\param[in] suspCompStates is an array of suspension compliance states.
|
||||
\param[in] suspForces is an array of suspension forces.
|
||||
\param[in] tireForceParams is an array of tire force parameters.
|
||||
\param[in] tireDirectionStates is an array of tire direction states.
|
||||
\param[in] tireSpeedStates is an array of tire speed states.
|
||||
\param[in] tireSlipStates is an array of tire slip states.
|
||||
\param[in] tireStickyStates is an array of tire sticky states.
|
||||
\param[in] tireGripStates is an array of tire grip states.
|
||||
\param[in] tireCamberStates is an array of tire camber states.
|
||||
\param[in] tireForces is an array of tire forces.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If any array is empty but the corresponding argument in PxVehiclePvdWheelAttachmentsRegister was not empty, the corresponding data will not be updated in omnipvd.
|
||||
\note Each array must either be empty or contain an entry for each wheel present in axleDesc.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdWheelAttachmentsRegister
|
||||
*/
|
||||
void PxVehiclePvdWheelAttachmentsWrite
|
||||
(const PxVehicleAxleDescription& axleDesc,
|
||||
const PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
const PxVehicleArrayData<const PxVehicleWheelActuationState>& wheelActuationStates,
|
||||
const PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates,
|
||||
const PxVehicleArrayData<const PxVehicleWheelLocalPose>& wheelLocalPoses,
|
||||
const PxVehicleArrayData<const PxVehicleRoadGeometryState>& roadGeometryStates,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionParams>& suspParams,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionComplianceParams>& suspCompParams,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionForceParams>& suspForceParams,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionState>& suspStates,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspCompStates,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionForce>& suspForces,
|
||||
const PxVehicleArrayData<const PxVehicleTireForceParams>& tireForceParams,
|
||||
const PxVehicleArrayData<const PxVehicleTireDirectionState>& tireDirectionStates,
|
||||
const PxVehicleArrayData<const PxVehicleTireSpeedState>& tireSpeedStates,
|
||||
const PxVehicleArrayData<const PxVehicleTireSlipState>& tireSlipStates,
|
||||
const PxVehicleArrayData<const PxVehicleTireStickyState>& tireStickyStates,
|
||||
const PxVehicleArrayData<const PxVehicleTireGripState>& tireGripStates,
|
||||
const PxVehicleArrayData<const PxVehicleTireCamberAngleState>& tireCamberStates,
|
||||
const PxVehicleArrayData<const PxVehicleTireForce>& tireForces,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Register object instances in omnipvd that will be used to reflect the antiroll bars of a vehicle instance.
|
||||
\param[in] antiRollForceParams is an array of antiroll parameters.
|
||||
\param[in] antiRollTorque describes the instantaneous accumulated torque from all antiroll bas.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If antiRollForceParams is empty, the corresponding data will not be reflected in omnipvd.
|
||||
\note If antiRollTorque is NULL, the corresponding data will not be reflected in omnipvd.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdAntiRollsWrite
|
||||
*/
|
||||
void PxVehiclePvdAntiRollsRegister
|
||||
(const PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams>& antiRollForceParams, const PxVehicleAntiRollTorque* antiRollTorque,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Write antiroll data to omnipvd.
|
||||
\param[in] antiRollForceParams is an array of antiroll parameters.
|
||||
\param[in] antiRollTorque describes the instantaneous accumulated torque from all antiroll bas.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If antiRollForceParams is empty but the corresponding argument was not empty, the corresponding data will not be updated in omnipvd.
|
||||
\note If antiRollTorque is NULL but the corresponding argument was not NULL, the corresponding data will not be updated in omnipvd.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdAntiRollsRegister
|
||||
*/
|
||||
void PxVehiclePvdAntiRollsWrite
|
||||
(const PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams>& antiRollForceParams, const PxVehicleAntiRollTorque* antiRollTorque,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Register object instances in omnipvd that will be used to reflect the direct drivetrain of a vehicle instance.
|
||||
\param[in] commandState describes the control values applied to the vehicle.
|
||||
\param[in] transmissionCommandState describes the state of the direct drive transmission.
|
||||
\param[in] directDriveThrottleResponseParams describes the vehicle's torque response to a throttle command.
|
||||
\param[in] directDriveThrottleResponseState is the instantaneous torque response of each wheel to a throttle command.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If commandState is NULL, the corresponding data will not be reflected in omnipvd.
|
||||
\note If transmissionCommandState is NULL, the corresponding data will not be reflected in omnipvd.
|
||||
\note If directDriveThrottleResponseParams is NULL, the corresponding data will not be reflected in omnipvd.
|
||||
\note If directDriveThrottleResponseState is empty, the corresponding data will not be reflected in omnipvd.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdDirectDrivetrainWrite
|
||||
*/
|
||||
void PxVehiclePvdDirectDrivetrainRegister
|
||||
(const PxVehicleCommandState* commandState, const PxVehicleDirectDriveTransmissionCommandState* transmissionCommandState,
|
||||
const PxVehicleDirectDriveThrottleCommandResponseParams* directDriveThrottleResponseParams,
|
||||
const PxVehicleArrayData<PxReal>& directDriveThrottleResponseState,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Write direct drivetrain data to omnipvd.
|
||||
\param[in] axleDesc is a description of the wheels and axles of a vehicle.
|
||||
\param[in] commandState describes the control values applied to the vehicle.
|
||||
\param[in] transmissionCommandState describes the state of the direct drive transmission.
|
||||
\param[in] directDriveThrottleResponseParams describes the vehicle's torque response to a throttle command.
|
||||
\param[in] directDriveThrottleResponseState is the instantaneous torque response of each wheel to a throttle command.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If commandState is NULL but the corresponding entry in PxVehiclePvdDirectDrivetrainRegister() was not NULL, the corresponding data will not be updated in omnipvd.
|
||||
\note If transmissionCommandState is NULL but the corresponding entry in PxVehiclePvdDirectDrivetrainRegister() was not NULL, the corresponding data will not be updated in omnipvd.
|
||||
\note If directDriveThrottleResponseParams is NULL but the corresponding entry in PxVehiclePvdDirectDrivetrainRegister() was not NULL, the corresponding data will not be updated in omnipvd.
|
||||
\note If directDriveThrottleResponseState is empty but the corresponding entry in PxVehiclePvdDirectDrivetrainRegister() was not empty, the corresponding data will not be updated in omnipvd.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdDirectDrivetrainRegister
|
||||
*/
|
||||
void PxVehiclePvdDirectDrivetrainWrite
|
||||
(const PxVehicleAxleDescription& axleDesc,
|
||||
const PxVehicleCommandState* commandState, const PxVehicleDirectDriveTransmissionCommandState* transmissionCommandState,
|
||||
const PxVehicleDirectDriveThrottleCommandResponseParams* directDriveThrottleResponseParams,
|
||||
const PxVehicleArrayData<PxReal>& directDriveThrottleResponseState,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Register object instances in omnipvd that will be used to reflect the engine drivetrain of a vehicle instance.
|
||||
\param[in] commandState describes the control values applied to the vehicle.
|
||||
\param[in] engineDriveTransmissionCommandState describes the state of the engine drive transmission.
|
||||
\param[in] tankDriveTransmissionCommandState describes the state of the tank drive transmission.
|
||||
\param[in] clutchResponseParams describes the vehicle's response to a clutch command.
|
||||
\param[in] clutchParams describes the vehicle's clutch.
|
||||
\param[in] engineParams describes the engine.
|
||||
\param[in] gearboxParams describes the gearbox.
|
||||
\param[in] autoboxParams describes the automatic gearbox.
|
||||
\param[in] multiWheelDiffParams describes a multiwheel differential without limited slip compensation.
|
||||
\param[in] fourWheelDiffPrams describes a differential that delivers torque to four drive wheels with limited slip compensation.
|
||||
\param[in] tankDiffParams describes the operation of the tank differential.
|
||||
\param[in] clutchResponseState is the instantaneous reponse of the clutch to a clutch command.
|
||||
\param[in] throttleResponseState is the instantaneous response to a throttle command.
|
||||
\param[in] engineState is the instantaneous state of the engine.
|
||||
\param[in] gearboxState is the instantaneous state of the gearbox.
|
||||
\param[in] autoboxState is the instantaneous state of the automatic gearbox.
|
||||
\param[in] diffState is the instantaneous state of the differential.
|
||||
\param[in] clutchSlipState is the instantaneous slip recorded at the clutch.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If any pointer is NULL, the corresponding data will not be reflected in omnipvd.
|
||||
\note At most one of engineDriveTransmissionCommandState and tankDriveTransmissionCommandState is expected to be non-NULL.
|
||||
\note At most one of multiWheelDiffParams, fourWheelDiffParams and tankDiffParams is expected to be non-NULL.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdEngineDrivetrainWrite
|
||||
*/
|
||||
void PxVehiclePvdEngineDrivetrainRegister
|
||||
(const PxVehicleCommandState* commandState,
|
||||
const PxVehicleEngineDriveTransmissionCommandState* engineDriveTransmissionCommandState,
|
||||
const PxVehicleTankDriveTransmissionCommandState* tankDriveTransmissionCommandState,
|
||||
const PxVehicleClutchCommandResponseParams* clutchResponseParams,
|
||||
const PxVehicleClutchParams* clutchParams,
|
||||
const PxVehicleEngineParams* engineParams,
|
||||
const PxVehicleGearboxParams* gearboxParams,
|
||||
const PxVehicleAutoboxParams* autoboxParams,
|
||||
const PxVehicleMultiWheelDriveDifferentialParams* multiWheelDiffParams,
|
||||
const PxVehicleFourWheelDriveDifferentialParams* fourWheelDiffPrams,
|
||||
const PxVehicleTankDriveDifferentialParams* tankDiffParams,
|
||||
const PxVehicleClutchCommandResponseState* clutchResponseState,
|
||||
const PxVehicleEngineDriveThrottleCommandResponseState* throttleResponseState,
|
||||
const PxVehicleEngineState* engineState,
|
||||
const PxVehicleGearboxState* gearboxState,
|
||||
const PxVehicleAutoboxState* autoboxState,
|
||||
const PxVehicleDifferentialState* diffState,
|
||||
const PxVehicleClutchSlipState* clutchSlipState,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Write engine drivetrain data of a vehicle instance to omnipvd.
|
||||
\param[in] commandState describes the control values applied to the vehicle.
|
||||
\param[in] engineDriveTransmissionCommandState describes the state of the engine drive transmission.
|
||||
\param[in] tankDriveTransmissionCommandState describes the state of the tank drive transmission.
|
||||
\param[in] clutchResponseParams describes the vehicle's response to a clutch command.
|
||||
\param[in] clutchParams describes the vehicle's clutch.
|
||||
\param[in] engineParams describes the engine.
|
||||
\param[in] gearboxParams describes the gearbox.
|
||||
\param[in] autoboxParams describes the automatic gearbox.
|
||||
\param[in] multiWheelDiffParams describes a multiwheel differential without limited slip compensation.
|
||||
\param[in] fourWheelDiffParams describes a differential that delivers torque to four drive wheels with limited slip compensation.
|
||||
\param[in] tankDiffParams describes the operation of the tank differential.
|
||||
\param[in] clutchResponseState is the instantaneous reponse of the clutch to a clutch command.
|
||||
\param[in] throttleResponseState is the instantaneous response to a throttle command.
|
||||
\param[in] engineState is the instantaneous state of the engine.
|
||||
\param[in] gearboxState is the instantaneous state of the gearbox.
|
||||
\param[in] autoboxState is the instantaneous state of the automatic gearbox.
|
||||
\param[in] diffState is the instantaneous state of the differential.
|
||||
\param[in] clutchSlipState is the instantaneous slip recorded at the clutch.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If any pointer is NULL and the corresponding argument in PxVehiclePvdEngineDrivetrainRegister() was not NULL, the corresponding data will not be reflected in omnipvd.
|
||||
\note At most one of engineDriveTransmissionCommandState and tankDriveTransmissionCommandState is expected to be non-NULL.
|
||||
\note At most one of multiWheelDiffParams, fourWheelDiffParams and tankDiffParams is expected to be non-NULL.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdEngineDrivetrainRegister
|
||||
*/
|
||||
void PxVehiclePvdEngineDrivetrainWrite
|
||||
(const PxVehicleCommandState* commandState,
|
||||
const PxVehicleEngineDriveTransmissionCommandState* engineDriveTransmissionCommandState,
|
||||
const PxVehicleTankDriveTransmissionCommandState* tankDriveTransmissionCommandState,
|
||||
const PxVehicleClutchCommandResponseParams* clutchResponseParams,
|
||||
const PxVehicleClutchParams* clutchParams,
|
||||
const PxVehicleEngineParams* engineParams,
|
||||
const PxVehicleGearboxParams* gearboxParams,
|
||||
const PxVehicleAutoboxParams* autoboxParams,
|
||||
const PxVehicleMultiWheelDriveDifferentialParams* multiWheelDiffParams,
|
||||
const PxVehicleFourWheelDriveDifferentialParams* fourWheelDiffParams,
|
||||
const PxVehicleTankDriveDifferentialParams* tankDiffParams,
|
||||
const PxVehicleClutchCommandResponseState* clutchResponseState,
|
||||
const PxVehicleEngineDriveThrottleCommandResponseState* throttleResponseState,
|
||||
const PxVehicleEngineState* engineState,
|
||||
const PxVehicleGearboxState* gearboxState,
|
||||
const PxVehicleAutoboxState* autoboxState,
|
||||
const PxVehicleDifferentialState* diffState,
|
||||
const PxVehicleClutchSlipState* clutchSlipState,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Register per wheel attachment data that involves the vehicle's integration with a PhysX scene.
|
||||
\param[in] axleDesc is a description of the wheels and axles of a vehicle.
|
||||
\param[in] physxSuspLimitConstraintParams describes the method used by PhysX to enforce suspension travel limits.
|
||||
\param[in] physxMaterialFrictionParams describes the friction response of each wheel to a set of PxMaterial instances.
|
||||
\param[in] physxActor describes the PxRigidActor and PxShape instances that are used to represent the vehicle's rigid body and wheel shapes in PhysX.
|
||||
\param[in] physxRoadGeometryQueryParams describes the physx scene query method used to place each wheel on the ground.
|
||||
\param[in] physxRoadGeomState is an array of per wheel physx scene query results.
|
||||
\param[in] physxConstraintStates is an array of constraints states used by PhysX to enforce sticky tire and suspension travel limit constraints.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If any array is empty, the corresponding data will not be reflected in omnipvd.
|
||||
\note If physxActor is NULL, the corresponding data will not be reflected in omnipvd.
|
||||
\note If physxRoadGeometryQueryParams is NULL, the corresponding data will not be reflected in omnipvd.
|
||||
\note Each array must either be empty or contain an entry for each wheel present in axleDesc.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdPhysXWheelAttachmentWrite
|
||||
*/
|
||||
void PxVehiclePvdPhysXWheelAttachmentRegister
|
||||
(const PxVehicleAxleDescription& axleDesc,
|
||||
const PxVehicleArrayData<const PxVehiclePhysXSuspensionLimitConstraintParams>& physxSuspLimitConstraintParams,
|
||||
const PxVehicleArrayData<const PxVehiclePhysXMaterialFrictionParams>& physxMaterialFrictionParams,
|
||||
const PxVehiclePhysXActor* physxActor, const PxVehiclePhysXRoadGeometryQueryParams* physxRoadGeometryQueryParams,
|
||||
const PxVehicleArrayData<const PxVehiclePhysXRoadGeometryQueryState>& physxRoadGeomState,
|
||||
const PxVehicleArrayData<const PxVehiclePhysXConstraintState>& physxConstraintStates,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Write to omnipvd the per wheel attachment data that involves the vehicle's integration with a PhysX scene.
|
||||
\param[in] axleDesc is a description of the wheels and axles of a vehicle.
|
||||
\param[in] physxSuspLimitConstraintParams describes the method used by PhysX to enforce suspension travel limits.
|
||||
\param[in] physxMaterialFrictionParams describes the friction response of each wheel to a set of PxMaterial instances.
|
||||
\param[in] physxActor describes the PxShape instances that are used to represent the vehicle's wheel shapes in PhysX.
|
||||
\param[in] physxRoadGeometryQueryParams describes the physx scene query method used to place each wheel on the ground.
|
||||
\param[in] physxRoadGeomState is an array of per wheel physx scene query results.
|
||||
\param[in] physxConstraintStates is an array of constraints states used by PhysX to enforce sticky tire and suspension travel limit constraints.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If any array is empty but the corresponding array in PxVehiclePvdPhysXWheelAttachmentRegister() was not empty, the corresponding data will not be updated in omnipvd.
|
||||
\note If physxActor is NULL but the corresponding argument in PxVehiclePvdPhysXWheelAttachmentRegister was not NULL, the corresponding data will not be reflected in omnipvd.
|
||||
\note If physxRoadGeometryQueryParams is NULL but the corresponding argument in PxVehiclePvdPhysXWheelAttachmentRegister was not NULL, the corresponding data will not be reflected in omnipvd.
|
||||
\note Each array must either be empty or contain an entry for each wheel present in axleDesc.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdPhysXWheelAttachmentWrite
|
||||
*/
|
||||
void PxVehiclePvdPhysXWheelAttachmentWrite
|
||||
(const PxVehicleAxleDescription& axleDesc,
|
||||
const PxVehicleArrayData<const PxVehiclePhysXSuspensionLimitConstraintParams>& physxSuspLimitConstraintParams,
|
||||
const PxVehicleArrayData<const PxVehiclePhysXMaterialFrictionParams>& physxMaterialFrictionParams,
|
||||
const PxVehiclePhysXActor* physxActor, const PxVehiclePhysXRoadGeometryQueryParams* physxRoadGeometryQueryParams,
|
||||
const PxVehicleArrayData<const PxVehiclePhysXRoadGeometryQueryState>& physxRoadGeomState,
|
||||
const PxVehicleArrayData<const PxVehiclePhysXConstraintState>& physxConstraintStates,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Register the PxRigidActor instance that represents the vehicle's rigid body in a PhysX scene.
|
||||
\param[in] physxActor describes the PxRigidActor instance that is used to represent the vehicle's rigid body in PhysX.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If physxActor is NULL, the corresponding data will not be reflected in omnipvd.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdPhysXRigidActorWrite
|
||||
*/
|
||||
void PxVehiclePvdPhysXRigidActorRegister
|
||||
(const PxVehiclePhysXActor* physxActor,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Write the PxRigidActor instance to omnipvd.
|
||||
\param[in] physxActor describes the PxRigidActor instance that is used to represent the vehicle's rigid body in PhysX.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If physxActor is NULL and the corresponding argument in PxVehiclePvdPhysXRigidActorRegister was not NULL, the corresponding data will not be updated in omnipvd.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdPhysXRigidActorRegister
|
||||
*/
|
||||
void PxVehiclePvdPhysXRigidActorWrite
|
||||
(const PxVehiclePhysXActor* physxActor,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Register the PhysX related steer state class.
|
||||
\param[in] physxSteerState describes the PxVehiclePhysXSteerState instance that holds steer related state information.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If physxSteerState is NULL, the corresponding data will not be reflected in omnipvd.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdPhysXSteerStateWrite
|
||||
*/
|
||||
void PxVehiclePvdPhysXSteerStateRegister
|
||||
(const PxVehiclePhysXSteerState* physxSteerState,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Write the PxVehiclePhysXSteerState instance to omnipvd.
|
||||
\param[in] physxSteerState describes the PxVehiclePhysXSteerState instance that holds steer related state information.
|
||||
\param[in] attributeHandles contains a general description of vehicle parameters and states that will be reflected in omnipvd.
|
||||
\param[in] objectHandles contains unique handles for the parameters and states of each vehicle instance.
|
||||
\param[in] omniWriter is an OmniPvdWriter instance used to communicate state and parameter data to omnipvd.
|
||||
\note If physxSteerState is NULL and the corresponding argument in PxVehiclePvdPhysXSteerStateRegister was not NULL, the corresponding data will not be updated in omnipvd.
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
\see PxVehiclePvdObjectCreate
|
||||
\see PxVehiclePvdPhysXSteerStateRegister
|
||||
*/
|
||||
void PxVehiclePvdPhysXSteerStateWrite
|
||||
(const PxVehiclePhysXSteerState* physxSteerState,
|
||||
const PxVehiclePvdAttributeHandles& attributeHandles,
|
||||
const PxVehiclePvdObjectHandles& objectHandles, OmniPvdWriter& omniWriter);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
103
engine/third_party/physx/include/vehicle2/pvd/PxVehiclePvdHelpers.h
vendored
Normal file
103
engine/third_party/physx/include/vehicle2/pvd/PxVehiclePvdHelpers.h
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
|
||||
class OmniPvdWriter;
|
||||
namespace physx
|
||||
{
|
||||
class PxAllocatorCallback;
|
||||
namespace vehicle2
|
||||
{
|
||||
struct PxVehiclePvdAttributeHandles;
|
||||
struct PxVehiclePvdObjectHandles;
|
||||
}
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Create the attribute handles necessary to reflect vehicles in omnipvd.
|
||||
\param[in] allocator is used to allocate the memory used to store the attribute handles.
|
||||
\param[in] omniWriter is used to register the attribute handles with omnipvd.
|
||||
\see PxVehicleSimulationContext
|
||||
\see PxVehiclePVDComponent
|
||||
\see PxVehiclePvdAttributesRelease
|
||||
*/
|
||||
PxVehiclePvdAttributeHandles* PxVehiclePvdAttributesCreate
|
||||
(PxAllocatorCallback& allocator, OmniPvdWriter& omniWriter);
|
||||
|
||||
/**
|
||||
\brief Destory the attribute handles created by PxVehiclePvdAttributesCreate().
|
||||
\param[in] allocator must be the instance used by PxVehiclePvdObjectCreate().
|
||||
\param[in] attributeHandles is the PxVehiclePvdAttributeHandles created by PxVehiclePvdAttributesCreate().
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
*/
|
||||
void PxVehiclePvdAttributesRelease
|
||||
(PxAllocatorCallback& allocator, PxVehiclePvdAttributeHandles& attributeHandles);
|
||||
|
||||
/**
|
||||
\brief Create omnipvd objects that will be used to reflect an individual veicle in omnipvd.
|
||||
\param[in] nbWheels must be greater than or equal to the number of wheels on the vehicle.
|
||||
\param[in] nbAntirolls must be greater than or equal to the number of antiroll bars on the vehicle.
|
||||
\param[in] maxNbPhysxMaterialFrictions must be greater than or equal to the number of PxPhysXMaterialFriction instances associated with any wheel of the vehicle.
|
||||
\param[in] contextHandle is typically used to associated vehicles with a particular scene or group.
|
||||
\param[in] allocator is used to allocate the memory used to store handles to the created omnipvd objects.
|
||||
\note PxVehiclePvdObjectCreate() must be called after PxVehiclePvdAttributesCreate().
|
||||
\see PxVehicleAxleDescription
|
||||
\see PxVehicleAntiRollForceParams
|
||||
\see PxVehiclePhysXMaterialFrictionParams
|
||||
\see PxVehiclePVDComponent
|
||||
\see PxVehiclePvdAttributesCreate
|
||||
*/
|
||||
PxVehiclePvdObjectHandles* PxVehiclePvdObjectCreate
|
||||
(const PxU32 nbWheels, const PxU32 nbAntirolls, const PxU32 maxNbPhysxMaterialFrictions,
|
||||
const PxU64 contextHandle, PxAllocatorCallback& allocator);
|
||||
|
||||
/**
|
||||
\brief Destroy the PxVehiclePvdObjectHandles instance created by PxVehiclePvdObjectCreate().
|
||||
\param[in] omniWriter is used to register the attribute handles with omnipvd.
|
||||
\param[in] allocator must be the instance used by PxVehiclePvdObjectCreate().
|
||||
\param[in] objectHandles is the PxVehiclePvdObjectHandles that was created by PxVehiclePvdObjectCreate().
|
||||
*/
|
||||
void PxVehiclePvdObjectRelease
|
||||
(OmniPvdWriter& omniWriter, PxAllocatorCallback& allocator, PxVehiclePvdObjectHandles& objectHandles);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
110
engine/third_party/physx/include/vehicle2/rigidBody/PxVehicleRigidBodyComponents.h
vendored
Normal file
110
engine/third_party/physx/include/vehicle2/rigidBody/PxVehicleRigidBodyComponents.h
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "vehicle2/PxVehicleComponent.h"
|
||||
|
||||
#include "PxVehicleRigidBodyFunctions.h"
|
||||
|
||||
#include "common/PxProfileZone.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Forward integrate the momentum and pose of the vehicle's rigid body after applying forces and torques
|
||||
from the suspension, tires and anti-roll bars.
|
||||
*/
|
||||
class PxVehicleRigidBodyComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleRigidBodyComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleRigidBodyComponent() {}
|
||||
|
||||
/**
|
||||
\brief Retrieve pointers to the parameter and state data required to update the dynamic state of a rigid body.
|
||||
\param[out] axleDescription must be returned as a non-null pointer to a single PxVehicleAxleDescription instance that describes the wheels and axles
|
||||
of the vehicle.
|
||||
\param[out] rigidBodyParams must be returned as a non-null pointer to a single PxVehicleRigidBodyParams instance that describes the mass and moment of
|
||||
inertia of the rigid body.
|
||||
\param[out] suspensionForces must be returned as a non-null pointer to an array of suspension forces and torques in the world frame.
|
||||
The suspension forces and torques will be applied to the rigid body to update *rigidBodyState*.
|
||||
\param[out] tireForces must be returned as a non-null pointer to an array of tire forces and torques in the world frame.
|
||||
The tire forces and torques will be applied to the rigid body to update *rigidBodyState*.
|
||||
\param[out] antiRollTorque may be returned an optionally non-null pointer to a single PxVehicleAntiRollTorque instance that contains the accumulated anti-roll
|
||||
torque to apply to the rigid body.
|
||||
\param[out] rigidBodyState imust be returned as a non-null pointer to a single PxVehicleRigidBodyState instance that is to be forward integrated.
|
||||
\note The suspensionForces array must contain an entry for each wheel listed as an active wheel in axleDescription.
|
||||
\note The tireForces array must contain an entry for each wheel listed as an active wheel in axleDescription.
|
||||
\note If antiRollTorque is returned as a null pointer then zero anti-roll torque will be applied to the rigid body.
|
||||
*/
|
||||
virtual void getDataForRigidBodyComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
const PxVehicleRigidBodyParams*& rigidBodyParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionForce>& suspensionForces,
|
||||
PxVehicleArrayData<const PxVehicleTireForce>& tireForces,
|
||||
const PxVehicleAntiRollTorque*& antiRollTorque,
|
||||
PxVehicleRigidBodyState*& rigidBodyState) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_PROFILE_ZONE("PxVehicleRigidBodyComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
const PxVehicleRigidBodyParams* rigidBodyParams;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionForce> suspensionForces;
|
||||
PxVehicleArrayData<const PxVehicleTireForce> tireForces;
|
||||
const PxVehicleAntiRollTorque* antiRollTorque;
|
||||
PxVehicleRigidBodyState* rigidBodyState;
|
||||
|
||||
getDataForRigidBodyComponent(axleDescription, rigidBodyParams,
|
||||
suspensionForces, tireForces, antiRollTorque,
|
||||
rigidBodyState);
|
||||
|
||||
PxVehicleRigidBodyUpdate(
|
||||
*axleDescription, *rigidBodyParams,
|
||||
suspensionForces, tireForces, antiRollTorque,
|
||||
dt, context.gravity,
|
||||
*rigidBodyState);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
76
engine/third_party/physx/include/vehicle2/rigidBody/PxVehicleRigidBodyFunctions.h
vendored
Normal file
76
engine/third_party/physx/include/vehicle2/rigidBody/PxVehicleRigidBodyFunctions.h
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleRigidBodyParams;
|
||||
struct PxVehicleSuspensionForce;
|
||||
struct PxVehicleTireForce;
|
||||
struct PxVehicleAntiRollTorque;
|
||||
struct PxVehicleRigidBodyState;
|
||||
|
||||
/**
|
||||
\brief Forward integrate rigid body state.
|
||||
\param[in] axleDescription is a description of the axles of the vehicle and the wheels on each axle.
|
||||
\param[in] rigidBodyParams is a description of rigid body mass and moment of inertia.
|
||||
\param[in] suspensionForces is an array of suspension forces and torques in the world frame to be applied to the rigid body.
|
||||
\param[in] tireForces is an array of tire forces and torques in the world frame to be applied to the rigid body.
|
||||
\param[in] antiRollTorque is an optional pointer to a single PxVehicleAntiRollTorque instance that contains the accumulated anti-roll
|
||||
torque to apply to the rigid body.
|
||||
\param[in] dt is the timestep of the forward integration.
|
||||
\param[in] gravity is gravitational acceleration.
|
||||
\param[in,out] rigidBodyState is the rigid body state that is to be updated.
|
||||
\note The suspensionForces array must contain an entry for each wheel listed as an active wheel in axleDescription.
|
||||
\note The tireForces array must contain an entry for each wheel listed as an active wheel in axleDescription.
|
||||
\note If antiRollTorque is a null pointer then zero anti-roll torque will be applied to the rigid body.
|
||||
*/
|
||||
void PxVehicleRigidBodyUpdate
|
||||
(const PxVehicleAxleDescription& axleDescription, const PxVehicleRigidBodyParams& rigidBodyParams,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionForce>& suspensionForces,
|
||||
const PxVehicleArrayData<const PxVehicleTireForce>& tireForces,
|
||||
const PxVehicleAntiRollTorque* antiRollTorque,
|
||||
const PxReal dt, const PxVec3& gravity,
|
||||
PxVehicleRigidBodyState& rigidBodyState);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
87
engine/third_party/physx/include/vehicle2/rigidBody/PxVehicleRigidBodyParams.h
vendored
Normal file
87
engine/third_party/physx/include/vehicle2/rigidBody/PxVehicleRigidBodyParams.h
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxFoundation.h"
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "vehicle2/PxVehicleFunctions.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief The properties of the rigid body.
|
||||
*/
|
||||
struct PxVehicleRigidBodyParams
|
||||
{
|
||||
/**
|
||||
\brief The mass of the rigid body.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> mass
|
||||
*/
|
||||
PxReal mass;
|
||||
|
||||
/**
|
||||
\brief The moment of inertia of the rigid body.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> mass * (length^2)
|
||||
*/
|
||||
PxVec3 moi;
|
||||
|
||||
PX_FORCE_INLINE PxVehicleRigidBodyParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PxVehicleRigidBodyParams r = *this;
|
||||
r.moi = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, moi).abs();
|
||||
const PxReal scale = trgScale.scale/srcScale.scale;
|
||||
r.moi *= (scale*scale);
|
||||
return r;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(mass > 0.0f, "PxVehicleRigidBodyParams.mass must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(moi.x > 0.0f && moi.y > 0.0f && moi.z> 0.0f, "PxVehicleRigidBodyParams.moi must be greater than zero", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
|
||||
94
engine/third_party/physx/include/vehicle2/rigidBody/PxVehicleRigidBodyStates.h
vendored
Normal file
94
engine/third_party/physx/include/vehicle2/rigidBody/PxVehicleRigidBodyStates.h
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleRigidBodyState
|
||||
{
|
||||
PxTransform pose; //!< the body's pose (in world space)
|
||||
PxVec3 linearVelocity; //!< the body's linear velocity (in world space)
|
||||
PxVec3 angularVelocity; //!< the body's angular velocity (in world space)
|
||||
PxVec3 previousLinearVelocity; //!< the previous linear velocity of the body (in world space)
|
||||
PxVec3 previousAngularVelocity; //!< the previous angular velocity of the body (in world space)
|
||||
PxVec3 externalForce; //!< external force (in world space) affecting the rigid body (usually excluding gravitational force)
|
||||
PxVec3 externalTorque; //!< external torque (in world space) affecting the rigid body
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
pose = PxTransform(PxIdentity);
|
||||
linearVelocity = PxVec3(PxZero);
|
||||
angularVelocity = PxVec3(PxZero);
|
||||
externalForce = PxVec3(PxZero);
|
||||
externalTorque = PxVec3(PxZero);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the vertical speed of the rigid body transformed to the world frame.
|
||||
\param[in] frame describes the axes of the vehicle
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal getVerticalSpeed(const PxVehicleFrame& frame) const
|
||||
{
|
||||
return linearVelocity.dot(pose.q.rotate(frame.getVrtAxis()));
|
||||
}
|
||||
|
||||
/**
|
||||
\param[in] frame describes the axes of the vehicle
|
||||
\brief Compute the lateral speed of the rigid body transformed to the world frame.
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal getLateralSpeed(const PxVehicleFrame& frame) const
|
||||
{
|
||||
return linearVelocity.dot(pose.q.rotate(frame.getLatAxis()));
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the longitudinal speed of the rigid body transformed to the world frame.
|
||||
\param[in] frame describes the axes of the vehicle
|
||||
*/
|
||||
PX_FORCE_INLINE PxReal getLongitudinalSpeed(const PxVehicleFrame& frame) const
|
||||
{
|
||||
return linearVelocity.dot(pose.q.rotate(frame.getLngAxis()));
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
59
engine/third_party/physx/include/vehicle2/roadGeometry/PxVehicleRoadGeometryState.h
vendored
Normal file
59
engine/third_party/physx/include/vehicle2/roadGeometry/PxVehicleRoadGeometryState.h
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxPlane.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleRoadGeometryState
|
||||
{
|
||||
PxPlane plane; //!< the plane under the wheel
|
||||
PxReal friction; //!< the friction to be used by the tire model
|
||||
PxVec3 velocity; //!< the velocity of the road geometry
|
||||
bool hitState; //!< true if a plane is found, false if there is no plane.
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleRoadGeometryState));
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
76
engine/third_party/physx/include/vehicle2/steering/PxVehicleSteeringFunctions.h
vendored
Normal file
76
engine/third_party/physx/include/vehicle2/steering/PxVehicleSteeringFunctions.h
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "PxVehicleSteeringParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleCommandState;
|
||||
|
||||
/**
|
||||
\brief Compute the yaw angle response to a steer command.
|
||||
\param[in] steer is the input steer command value.
|
||||
\param[in] longitudinalSpeed is the longitudinal speed of the vehicle.
|
||||
\param[in] wheelId specifies the wheel to have its steer response computed.
|
||||
\param[in] steerResponseParams specifies the per wheel yaw angle response to the steer command as a nonlinear function of steer command and longitudinal speed.
|
||||
\param[out] steerResponseState is the yaw angle response to the input steer command.
|
||||
*/
|
||||
void PxVehicleSteerCommandResponseUpdate
|
||||
(const PxReal steer, const PxReal longitudinalSpeed,
|
||||
const PxU32 wheelId, const PxVehicleSteerCommandResponseParams& steerResponseParams,
|
||||
PxReal& steerResponseState);
|
||||
|
||||
/**
|
||||
\brief Account for Ackermann correction by modifying the per wheel steer response multipliers to engineer an asymmetric steer response across axles.
|
||||
\param[in] steer is the input steer command value.
|
||||
\param[in] steerResponseParams describes the maximum response and a response multiplier per axle.
|
||||
\param[in] ackermannParams is an array that describes the wheels affected by Ackermann steer correction.
|
||||
\param[in,out] steerResponseStates contains the corrected per wheel steer response multipliers that take account of Ackermann steer correction.
|
||||
*/
|
||||
void PxVehicleAckermannSteerUpdate
|
||||
(const PxReal steer, const PxVehicleSteerCommandResponseParams& steerResponseParams,
|
||||
const PxVehicleSizedArrayData<const PxVehicleAckermannParams>& ackermannParams,
|
||||
PxVehicleArrayData<PxReal>& steerResponseStates);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
118
engine/third_party/physx/include/vehicle2/steering/PxVehicleSteeringParams.h
vendored
Normal file
118
engine/third_party/physx/include/vehicle2/steering/PxVehicleSteeringParams.h
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "foundation/PxFoundation.h"
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
|
||||
#include "vehicle2/commands/PxVehicleCommandParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleFrame;
|
||||
struct PxVehicleScale;
|
||||
|
||||
/**
|
||||
\brief Distribute a steer response to the wheels of a vehicle.
|
||||
\note The steer angle applied to each wheel on the ith wheel is steerCommand * maxResponse * wheelResponseMultipliers[i].
|
||||
\note A typical use case is to set maxResponse to be the vehicle's maximum achievable steer angle
|
||||
that occurs when the steer command is equal to 1.0. The array wheelResponseMultipliers[i] would then be used
|
||||
to specify the maximum achievable steer angle per wheel as a fractional multiplier of the vehicle's maximum achievable steer angle.
|
||||
*/
|
||||
struct PxVehicleSteerCommandResponseParams : public PxVehicleCommandResponseParams
|
||||
{
|
||||
PX_FORCE_INLINE PxVehicleSteerCommandResponseParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PX_UNUSED(srcScale);
|
||||
PX_UNUSED(trgScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
|
||||
{
|
||||
if (!axleDesc.isValid())
|
||||
return false;
|
||||
for (PxU32 i = 0; i < axleDesc.nbWheels; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(PxAbs(maxResponse*wheelResponseMultipliers[axleDesc.wheelIdsInAxleOrder[i]]) <= PxPi,
|
||||
"PxVehicleSteerCommandResponseParams.maxResponse*PxVehicleSteerCommandResponseParams.wheelResponseMultipliers[i] must be in range [-Pi, Pi]", false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief A description of a single axle that is to be affected by Ackermann steer correction.
|
||||
*/
|
||||
struct PxVehicleAckermannParams
|
||||
{
|
||||
PxU32 wheelIds[2]; //!< wheelIds[0] is the id of the wheel that is negative along the lateral axis, wheelIds[1] is the wheel id that is positive along the lateral axis.
|
||||
PxReal wheelBase; //!< wheelBase is the longitudinal distance between the axle that is affected by Ackermann correction and a reference axle.
|
||||
PxReal trackWidth; //!< trackWidth is the width of the axle specified by #wheelIds
|
||||
PxReal strength; //!< is the strength of the correction with 0 denoting no correction and 1 denoting perfect correction.
|
||||
|
||||
PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(0.0f == strength || wheelIds[0] < axleDesc.getNbWheels(), "PxVehicleAckermannParams.wheelIds[0] must be valid wheel", false);
|
||||
PX_CHECK_AND_RETURN_VAL(0.0f == strength || wheelIds[1] < axleDesc.getNbWheels(), "PxVehicleAckermannParams.wheelIds[1] must be a valid wheel", false);
|
||||
PX_CHECK_AND_RETURN_VAL(0.0f == strength || wheelIds[0] != wheelIds[1], "PxVehicleAckermannParams.wheelIds[0] and PxVehicleAckermannParams.wheelIds[1] must reference two different wheels", false);
|
||||
PX_CHECK_AND_RETURN_VAL(0.0f == strength || wheelBase > 0.0f, "PxVehicleAckermannParams.wheelBase must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(0.0f == strength || trackWidth > 0.0f, "PxVehicleAckermannParams.trackWidth must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(strength >= 0.0f && strength <= 1.0f, "PxVehicleAckermannParams.strength must be in range [0,1]", false);
|
||||
PX_UNUSED(axleDesc);
|
||||
return true;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE PxVehicleAckermannParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PxVehicleAckermannParams r = *this;
|
||||
const PxReal scale = trgScale.scale / srcScale.scale;
|
||||
r.wheelBase *= scale;
|
||||
r.trackWidth *= scale;
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
324
engine/third_party/physx/include/vehicle2/suspension/PxVehicleSuspensionComponents.h
vendored
Normal file
324
engine/third_party/physx/include/vehicle2/suspension/PxVehicleSuspensionComponents.h
vendored
Normal file
@@ -0,0 +1,324 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "vehicle2/PxVehicleComponent.h"
|
||||
|
||||
#include "vehicle2/commands/PxVehicleCommandStates.h"
|
||||
#include "vehicle2/commands/PxVehicleCommandHelpers.h"
|
||||
#include "vehicle2/rigidBody/PxVehicleRigidBodyParams.h"
|
||||
#include "vehicle2/roadGeometry/PxVehicleRoadGeometryState.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelParams.h"
|
||||
|
||||
#include "PxVehicleSuspensionParams.h"
|
||||
#include "PxVehicleSuspensionStates.h"
|
||||
#include "PxVehicleSuspensionFunctions.h"
|
||||
|
||||
#include "common/PxProfileZone.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
class PxVehicleSuspensionComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleSuspensionComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleSuspensionComponent() {}
|
||||
|
||||
/**
|
||||
\brief Retrieve pointers to the parameter and state data required to compute the suspension state and the forces/torques that arise from the suspension state.
|
||||
\param[out] axleDescription must be returned as a non-null pointer to a single PxVehicleAxleDescription instance that describes the wheels and axles
|
||||
of the vehicle.
|
||||
\param[out] rigidBodyParams must be returned as a a non-null pointer to a single PxVehicleRigidBodyParams instance that describes the mass and moment
|
||||
of inertia of the vehicle's rigid body.
|
||||
\param[out] suspensionStateCalculationParams must be returned as a non-null pointer to a single PxVehicleSuspensionStateCalculationParams instance
|
||||
that describes the jounce computation type etc.
|
||||
\param[out] steerResponseStates must be returned as a non-null pointer to a single PxVehicleSteerCommandResponseStates instance that describes the steer
|
||||
state of the wheels.
|
||||
\param[out] rigidBodyState must be returned as a non-null pointer to a single PxVehicleRigidBodyState instance that describes the pose and momentum of
|
||||
the vehicle's rigid body.
|
||||
\param[out] wheelParams must be set to a non-null pointer to an array of PxVehicleWheelParams containing per-wheel parameters for each wheel
|
||||
referenced by axleDescription.
|
||||
\param[out] suspensionParams must be set to a non-null pointer to an array of PxVehicleSuspensionParams containing per-wheel parameters for each
|
||||
wheel referenced by axleDescription.
|
||||
\param[out] suspensionComplianceParams must be set to a non-null pointer to an array of PxVehicleSuspensionComplianceParams containing per-wheel
|
||||
parameters for each wheel referenced by axleDescription.
|
||||
\param[out] suspensionForceParams must be set to a non-null pointer to an array of PxVehicleSuspensionForceParams containing per-wheel parameters
|
||||
for each wheel referenced by axleDescription.
|
||||
\param[out] antiRollForceParams is optionally returned as a non-null pointer to an array of PxVehicleAntiRollForceParams with each element in the array
|
||||
describing a unique anti-roll bar connecting a pair of wheels.
|
||||
\param[out] wheelRoadGeomStates must be set to non-null pointer to an array of PxVehicleRoadGeometryState containing per-wheel road geometry for
|
||||
each wheel referenced by axleDescription.
|
||||
\param[out] suspensionStates must be set to a non-null pointer to an array of PxVehicleSuspensionState containing per-wheel suspension state for each
|
||||
wheel referenced by axleDescription.
|
||||
\param[out] suspensionComplianceStates must be set to a non-null pointer to an array of PxVehicleSuspensionComplianceState containing per-wheel suspension
|
||||
compliance state for each wheel referenced by axleDescription.
|
||||
\param[out] suspensionForces must be set to a non-null pointer to an array of PxVehicleSuspensionForce containing per-wheel suspension forces for each
|
||||
wheel referenced by axleDescription.
|
||||
\param[out] antiRollTorque is optionally returned as a non-null pointer to a single PxVehicleAntiRollTorque instance that will store the accumulated anti-roll
|
||||
torque to be applied to the vheicle's rigid body.
|
||||
\note antiRollForceParams and antiRollTorque should be returned either both non-NULL or both NULL.
|
||||
*/
|
||||
virtual void getDataForSuspensionComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
const PxVehicleRigidBodyParams*& rigidBodyParams,
|
||||
const PxVehicleSuspensionStateCalculationParams*& suspensionStateCalculationParams,
|
||||
PxVehicleArrayData<const PxReal>& steerResponseStates,
|
||||
const PxVehicleRigidBodyState*& rigidBodyState,
|
||||
PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceParams>& suspensionComplianceParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionForceParams>& suspensionForceParams,
|
||||
PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams>& antiRollForceParams,
|
||||
PxVehicleArrayData<const PxVehicleRoadGeometryState>& wheelRoadGeomStates,
|
||||
PxVehicleArrayData<PxVehicleSuspensionState>& suspensionStates,
|
||||
PxVehicleArrayData<PxVehicleSuspensionComplianceState>& suspensionComplianceStates,
|
||||
PxVehicleArrayData<PxVehicleSuspensionForce>& suspensionForces,
|
||||
PxVehicleAntiRollTorque*& antiRollTorque) = 0;
|
||||
|
||||
/**
|
||||
\brief Update the suspension state and suspension compliance state and use those updated states to compute suspension and anti-roll forces/torques
|
||||
to apply to the vehicle's rigid body.
|
||||
\param[in] dt is the simulation time that has passed since the last call to PxVehicleSuspensionComponent::update()
|
||||
\param[in] context describes a variety of global simulation constants such as frame and scale of the simulation and the gravitational acceleration
|
||||
of the simulated environment.
|
||||
\note The suspension and anti-roll forces/torques are computed in the world frame.
|
||||
*/
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_PROFILE_ZONE("PxVehicleSuspensionComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
const PxVehicleRigidBodyParams* rigidBodyParams;
|
||||
const PxVehicleSuspensionStateCalculationParams* suspensionStateCalculationParams;
|
||||
PxVehicleArrayData<const PxReal> steerResponseStates;
|
||||
const PxVehicleRigidBodyState* rigidBodyState;
|
||||
PxVehicleArrayData<const PxVehicleWheelParams> wheelParams;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceParams> suspensionComplianceParams;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionForceParams> suspensionForceParams;
|
||||
PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams> antiRollForceParams;
|
||||
PxVehicleArrayData<const PxVehicleRoadGeometryState> wheelRoadGeomStates;
|
||||
PxVehicleArrayData<PxVehicleSuspensionState> suspensionStates;
|
||||
PxVehicleArrayData<PxVehicleSuspensionComplianceState> suspensionComplianceStates;
|
||||
PxVehicleArrayData<PxVehicleSuspensionForce> suspensionForces;
|
||||
PxVehicleAntiRollTorque* antiRollTorque;
|
||||
|
||||
getDataForSuspensionComponent(axleDescription, rigidBodyParams, suspensionStateCalculationParams,
|
||||
steerResponseStates, rigidBodyState,
|
||||
wheelParams, suspensionParams,
|
||||
suspensionComplianceParams, suspensionForceParams, antiRollForceParams,
|
||||
wheelRoadGeomStates, suspensionStates, suspensionComplianceStates,
|
||||
suspensionForces, antiRollTorque);
|
||||
|
||||
for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
|
||||
//Update the suspension state (jounce, jounce speed)
|
||||
PxVehicleSuspensionStateUpdate(
|
||||
wheelParams[wheelId], suspensionParams[wheelId], *suspensionStateCalculationParams,
|
||||
suspensionForceParams[wheelId].stiffness, suspensionForceParams[wheelId].damping,
|
||||
steerResponseStates[wheelId], wheelRoadGeomStates[wheelId],
|
||||
*rigidBodyState,
|
||||
dt, context.frame, context.gravity,
|
||||
suspensionStates[wheelId]);
|
||||
|
||||
//Update the compliance from the suspension state.
|
||||
PxVehicleSuspensionComplianceUpdate(
|
||||
suspensionParams[wheelId], suspensionComplianceParams[wheelId],
|
||||
suspensionStates[wheelId],
|
||||
suspensionComplianceStates[wheelId]);
|
||||
|
||||
//Compute the suspension force from the suspension and compliance states.
|
||||
PxVehicleSuspensionForceUpdate(
|
||||
suspensionParams[wheelId], suspensionForceParams[wheelId],
|
||||
wheelRoadGeomStates[wheelId], suspensionStates[wheelId],
|
||||
suspensionComplianceStates[wheelId], *rigidBodyState,
|
||||
context.gravity, rigidBodyParams->mass,
|
||||
suspensionForces[wheelId]);
|
||||
}
|
||||
|
||||
if (antiRollForceParams.size>0 && antiRollTorque)
|
||||
{
|
||||
PxVehicleAntiRollForceUpdate(
|
||||
suspensionParams, antiRollForceParams,
|
||||
suspensionStates.getConst(), suspensionComplianceStates.getConst(), *rigidBodyState,
|
||||
*antiRollTorque);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\deprecated This API was introduced with the new Vehicle API for transition purposes but will be removed in a future version.
|
||||
*/
|
||||
class PX_DEPRECATED PxVehicleLegacySuspensionComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleLegacySuspensionComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleLegacySuspensionComponent() {}
|
||||
|
||||
/**
|
||||
\brief Retrieve pointers to the parameter and state data required to compute the suspension state and the forces/torques that arise from the suspension state.
|
||||
\param[out] axleDescription must be returned as a non-null pointer to a single PxVehicleAxleDescription instance that describes the wheels and axles
|
||||
of the vehicle.
|
||||
\param[out] suspensionStateCalculationParams must be returned as a non-null pointer to a single PxVehicleSuspensionStateCalculationParams instance
|
||||
that describes the jounce computation type etc.
|
||||
\param[out] steerResponseStates must be returned as a non-null pointer to a single PxVehicleSteerCommandResponseStates instance that describes the steer
|
||||
state of the wheels.
|
||||
\param[out] rigidBodyState must be returned as a non-null pointer to a single PxVehicleRigidBodyState instance that describes the pose and momentum of
|
||||
the vehicle's rigid body.
|
||||
\param[out] wheelParams must be set to a non-null pointer to an array of PxVehicleWheelParams containing per-wheel parameters for each wheel
|
||||
referenced by axleDescription.
|
||||
\param[out] suspensionParams must be set to a non-null pointer to an array of PxVehicleSuspensionParams containing per-wheel parameters for each
|
||||
wheel referenced by axleDescription.
|
||||
\param[out] suspensionComplianceParams must be set to a non-null pointer to an array of PxVehicleSuspensionComplianceParams containing per-wheel
|
||||
parameters for each wheel referenced by axleDescription.
|
||||
\param[out] suspensionForceParams must be set to a non-null pointer to an array of PxVehicleSuspensionForceLegacyParams containing per-wheel parameters
|
||||
for each wheel referenced by axleDescription.
|
||||
\param[out] antiRollForceParams is optionally returned as a non-null pointer to an array of PxVehicleAntiRollForceParams with each element in the array
|
||||
describing a unique anti-roll bar connecting a pair of wheels.
|
||||
\param[out] wheelRoadGeomStates must be set to non-null pointer to an array of PxVehicleRoadGeometryState containing per-wheel road geometry for
|
||||
each wheel referenced by axleDescription.
|
||||
\param[out] suspensionStates must be set to a non-null pointer to an array of PxVehicleSuspensionState containing per-wheel suspension state for each
|
||||
wheel referenced by axleDescription.
|
||||
\param[out] suspensionComplianceStates must be set to a non-null pointer to an array of PxVehicleSuspensionComplianceState containing per-wheel suspension
|
||||
compliance state for each wheel referenced by axleDescription.
|
||||
\param[out] suspensionForces must be set to a non-null pointer to an array of PxVehicleSuspensionForce containing per-wheel suspension forces for each
|
||||
wheel referenced by axleDescription.
|
||||
\param[out] antiRollTorque is optionally returned as a non-null pointer to a single PxVehicleAntiRollTorque instance that will store the accumulated anti-roll
|
||||
torque to be applied to the vheicle's rigid body.
|
||||
\note antiRollForceParams and antiRollTorque should be returned either both non-NULL or both NULL.
|
||||
*/
|
||||
virtual void getDataForLegacySuspensionComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
const PxVehicleSuspensionStateCalculationParams*& suspensionStateCalculationParams,
|
||||
PxVehicleArrayData<const PxReal>& steerResponseStates,
|
||||
const PxVehicleRigidBodyState*& rigidBodyState,
|
||||
PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceParams>& suspensionComplianceParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionForceLegacyParams>& suspensionForceParams,
|
||||
PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams>& antiRollForceParams,
|
||||
PxVehicleArrayData<const PxVehicleRoadGeometryState>& wheelRoadGeomStates,
|
||||
PxVehicleArrayData<PxVehicleSuspensionState>& suspensionStates,
|
||||
PxVehicleArrayData<PxVehicleSuspensionComplianceState>& suspensionComplianceStates,
|
||||
PxVehicleArrayData<PxVehicleSuspensionForce>& suspensionForces,
|
||||
PxVehicleAntiRollTorque*& antiRollTorque) = 0;
|
||||
|
||||
/**
|
||||
\brief Update the suspension state and suspension compliance state and use those updated states to compute suspension and anti-roll forces/torques
|
||||
to apply to the vehicle's rigid body.
|
||||
\param[in] dt is the simulation time that has passed since the last call to PxVehicleSuspensionComponent::update()
|
||||
\param[in] context describes a variety of global simulation constants such as frame and scale of the simulation and the gravitational acceleration
|
||||
of the simulated environment.
|
||||
\note The suspension and anti-roll forces are computed in the world frame.
|
||||
\note PxVehicleLegacySuspensionComponent::update() implements legacy suspension behaviour.
|
||||
*/
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_PROFILE_ZONE("PxVehicleLegacySuspensionComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
const PxVehicleSuspensionStateCalculationParams* suspensionStateCalculationParams;
|
||||
PxVehicleArrayData<const PxReal> steerResponseStates;
|
||||
const PxVehicleRigidBodyState* rigidBodyState;
|
||||
PxVehicleArrayData<const PxVehicleWheelParams> wheelParams;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceParams> suspensionComplianceParams;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionForceLegacyParams> suspensionForceParams;
|
||||
PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams> antiRollForceParams;
|
||||
PxVehicleArrayData<const PxVehicleRoadGeometryState> wheelRoadGeomStates;
|
||||
PxVehicleArrayData<PxVehicleSuspensionState> suspensionStates;
|
||||
PxVehicleArrayData<PxVehicleSuspensionComplianceState> suspensionComplianceStates;
|
||||
PxVehicleArrayData<PxVehicleSuspensionForce> suspensionForces;
|
||||
PxVehicleAntiRollTorque* antiRollTorque;
|
||||
|
||||
getDataForLegacySuspensionComponent(axleDescription, suspensionStateCalculationParams,
|
||||
steerResponseStates, rigidBodyState, wheelParams,
|
||||
suspensionParams, suspensionComplianceParams,
|
||||
suspensionForceParams, antiRollForceParams,
|
||||
wheelRoadGeomStates, suspensionStates, suspensionComplianceStates,
|
||||
suspensionForces, antiRollTorque);
|
||||
|
||||
for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
|
||||
//Update the suspension state (jounce, jounce speed)
|
||||
PxVehicleSuspensionStateUpdate(
|
||||
wheelParams[wheelId], suspensionParams[wheelId], *suspensionStateCalculationParams,
|
||||
suspensionForceParams[wheelId].stiffness, suspensionForceParams[wheelId].damping,
|
||||
steerResponseStates[wheelId], wheelRoadGeomStates[wheelId], *rigidBodyState,
|
||||
dt, context.frame, context.gravity,
|
||||
suspensionStates[wheelId]);
|
||||
|
||||
//Update the compliance from the suspension state.
|
||||
PxVehicleSuspensionComplianceUpdate(
|
||||
suspensionParams[wheelId], suspensionComplianceParams[wheelId],
|
||||
suspensionStates[wheelId],
|
||||
suspensionComplianceStates[wheelId]);
|
||||
|
||||
//Compute the suspension force from the suspension and compliance states.
|
||||
PxVehicleSuspensionLegacyForceUpdate(
|
||||
suspensionParams[wheelId], suspensionForceParams[wheelId],
|
||||
wheelRoadGeomStates[wheelId], suspensionStates[wheelId],
|
||||
suspensionComplianceStates[wheelId], *rigidBodyState,
|
||||
context.gravity,
|
||||
suspensionForces[wheelId]);
|
||||
}
|
||||
|
||||
if (antiRollForceParams.size>0 && antiRollTorque)
|
||||
{
|
||||
PxVehicleAntiRollForceUpdate(
|
||||
suspensionParams, antiRollForceParams,
|
||||
suspensionStates.getConst(), suspensionComplianceStates.getConst(), *rigidBodyState,
|
||||
*antiRollTorque);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
163
engine/third_party/physx/include/vehicle2/suspension/PxVehicleSuspensionFunctions.h
vendored
Normal file
163
engine/third_party/physx/include/vehicle2/suspension/PxVehicleSuspensionFunctions.h
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleWheelParams;
|
||||
struct PxVehicleSuspensionParams;
|
||||
struct PxVehicleSuspensionStateCalculationParams;
|
||||
struct PxVehicleRoadGeometryState;
|
||||
struct PxVehicleRigidBodyState;
|
||||
struct PxVehicleSuspensionState;
|
||||
struct PxVehicleSuspensionComplianceParams;
|
||||
struct PxVehicleSuspensionComplianceState;
|
||||
struct PxVehicleSuspensionForceParams;
|
||||
struct PxVehicleSuspensionForce;
|
||||
struct PxVehicleSuspensionForceLegacyParams;
|
||||
struct PxVehicleAntiRollForceParams;
|
||||
struct PxVehicleAntiRollTorque;
|
||||
|
||||
/**
|
||||
\brief Compute the suspension compression and compression speed for a single suspension.
|
||||
\param[in] wheelParams is a description of the radius and half-width of the wheel on the suspension.
|
||||
\param[in] suspensionParams is a description of the suspension and wheel frames.
|
||||
\param[in] suspensionStateCalcParams specifies whether to compute the suspension compression by either
|
||||
raycasting or sweeping against the plane of the road geometry under the wheel.
|
||||
\param[in] suspensionStiffness is the stiffness of the suspension
|
||||
\param[in] suspensionDamping is the damping rate of the suspension.
|
||||
or whether to apply a limit to the expansion speed so that the wheel may not reach the ground.
|
||||
\param[in] steerAngle is the yaw angle (in radians) of the wheel.
|
||||
\param[in] roadGeometryState describes the plane under the wheel.
|
||||
\param[in] rigidBodyState describes the pose of the rigid body.
|
||||
\param[in] dt is the simulation time that has lapsed since the last call to PxVehicleSuspensionStateUpdate
|
||||
\param[in] frame describes the longitudinal, lateral and vertical axes of the vehicle.
|
||||
\param[in] gravity is the gravitational acceleration that acts on the suspension sprung mass.
|
||||
\param[in,out] suspState is the compression (jounce) and compression speed of the suspension.
|
||||
*/
|
||||
void PxVehicleSuspensionStateUpdate
|
||||
(const PxVehicleWheelParams& wheelParams, const PxVehicleSuspensionParams& suspensionParams, const PxVehicleSuspensionStateCalculationParams& suspensionStateCalcParams,
|
||||
const PxReal suspensionStiffness, const PxReal suspensionDamping,
|
||||
const PxReal steerAngle, const PxVehicleRoadGeometryState& roadGeometryState, const PxVehicleRigidBodyState& rigidBodyState,
|
||||
const PxReal dt, const PxVehicleFrame& frame, const PxVec3& gravity,
|
||||
PxVehicleSuspensionState& suspState);
|
||||
|
||||
/**
|
||||
\brief Compute the toe, camber and force application points that are affected by suspension compression.
|
||||
\param[in] suspensionParams is a description of the suspension and wheel frames.
|
||||
\param[in] complianceParams describes how toe, camber and force application points are affected by suspension compression.
|
||||
\param[in] suspensionState describes the current suspension compression.
|
||||
\param[in] complianceState is the computed toe, camber and force application points.
|
||||
*/
|
||||
void PxVehicleSuspensionComplianceUpdate
|
||||
(const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxVehicleSuspensionComplianceParams& complianceParams,
|
||||
const PxVehicleSuspensionState& suspensionState,
|
||||
PxVehicleSuspensionComplianceState& complianceState);
|
||||
|
||||
/**
|
||||
\brief Compute the suspension force and torque arising from suspension compression and speed.
|
||||
\param[in] suspensionParams is a description of the suspension and wheel frames.
|
||||
\param[in] suspensionForceParams describes the conversion of suspension state to suspension force.
|
||||
\param[in] roadGeometryState describes the plane under the wheel of the suspension.
|
||||
\param[in] suspensionState is the current compression state of the suspension.
|
||||
\param[in] complianceState is the current compliance state of the suspension.
|
||||
\param[in] rigidBodyState describes the current pose of the rigid body.
|
||||
\param[in] gravity is the gravitational acceleration.
|
||||
\param[in] vehicleMass is the rigid body mass.
|
||||
\param[out] suspensionForce is the force and torque to apply to the rigid body arising from the suspension state.
|
||||
*/
|
||||
void PxVehicleSuspensionForceUpdate
|
||||
(const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxVehicleSuspensionForceParams& suspensionForceParams,
|
||||
const PxVehicleRoadGeometryState& roadGeometryState, const PxVehicleSuspensionState& suspensionState,
|
||||
const PxVehicleSuspensionComplianceState& complianceState, const PxVehicleRigidBodyState& rigidBodyState,
|
||||
const PxVec3& gravity, const PxReal vehicleMass,
|
||||
PxVehicleSuspensionForce& suspensionForce);
|
||||
|
||||
|
||||
/**
|
||||
\deprecated This API was introduced with the new Vehicle API for transition purposes but will be removed in a future version.
|
||||
|
||||
\brief Compute the suspension force and torque arising from suspension compression and speed.
|
||||
\param[in] suspensionParams is a description of the suspension and wheel frames.
|
||||
\param[in] suspensionForceParams describes the conversion of suspension state to suspension force.
|
||||
\param[in] roadGeometryState describes the plane under the wheel of the suspension.
|
||||
\param[in] suspensionState is the current compression state of the suspension.
|
||||
\param[in] complianceState is the current compliance state of the suspension.
|
||||
\param[in] rigidBodyState describes the current pose of the rigid body.
|
||||
\param[in] gravity is the gravitational acceleration.
|
||||
\param[out] suspensionForce is the force and torque to apply to the rigid body arising from the suspension state.
|
||||
\note PxVehicleSuspensionLegacyForceUpdate implements the legacy force computation of PhysX 5.0 and earlier.
|
||||
*/
|
||||
PX_DEPRECATED void PxVehicleSuspensionLegacyForceUpdate
|
||||
(const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxVehicleSuspensionForceLegacyParams& suspensionForceParams,
|
||||
const PxVehicleRoadGeometryState& roadGeometryState, const PxVehicleSuspensionState& suspensionState,
|
||||
const PxVehicleSuspensionComplianceState& complianceState, const PxVehicleRigidBodyState& rigidBodyState,
|
||||
const PxVec3& gravity,
|
||||
PxVehicleSuspensionForce& suspensionForce);
|
||||
|
||||
/**
|
||||
\brief Compute the accumulated anti-roll torque to apply to the vehicle's rigid body.
|
||||
\param[in] suspensionParams The suspension parameters for each wheel.
|
||||
\param[in] antiRollParams describes the wheel pairs connected by anti-roll bars and the strength of each anti-roll bar.
|
||||
\param[in] suspensionStates The suspension states for each wheel.
|
||||
\param[in] complianceStates The suspension compliance states for each wheel.
|
||||
\param[in] rigidBodyState describes the pose and momentum of the vehicle's rigid body in the world frame.
|
||||
\param[in] antiRollTorque is the accumulated anti-roll torque that is computed by iterating over all anti-roll bars
|
||||
describes in *antiRollParams*.
|
||||
\note suspensionParams must contain an entry for each wheel index referenced by *antiRollParams*.
|
||||
\note suspensionStates must contain an entry for each wheel index referenced by *antiRollParams*.
|
||||
\note complianceStates must contain an entry for each wheel index referenced by *antiRollParams*.
|
||||
\note antiRollTorque is expressed in the world frame.
|
||||
*/
|
||||
void PxVehicleAntiRollForceUpdate
|
||||
(const PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams,
|
||||
const PxVehicleSizedArrayData<const PxVehicleAntiRollForceParams>& antiRollParams,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionState>& suspensionStates,
|
||||
const PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& complianceStates,
|
||||
const PxVehicleRigidBodyState& rigidBodyState,
|
||||
PxVehicleAntiRollTorque& antiRollTorque);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
149
engine/third_party/physx/include/vehicle2/suspension/PxVehicleSuspensionHelpers.h
vendored
Normal file
149
engine/third_party/physx/include/vehicle2/suspension/PxVehicleSuspensionHelpers.h
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "foundation/PxTransform.h"
|
||||
|
||||
#include "vehicle2/wheel/PxVehicleWheelParams.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelHelpers.h"
|
||||
|
||||
#include "PxVehicleSuspensionParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Compute suspension travel direction in the world frame.
|
||||
\param[in] suspensionParams is a description of the suspension frame.
|
||||
\param[in] rigidBodyPose is the current pose of the vehicle's rigid body.
|
||||
\return The return value is the suspension travel direction in the world frame.
|
||||
\note The suspension travel direction is used to perform queries against the road geometry.
|
||||
*/
|
||||
PX_FORCE_INLINE PxVec3 PxVehicleComputeSuspensionDirection(const PxVehicleSuspensionParams& suspensionParams, const PxTransform& rigidBodyPose)
|
||||
{
|
||||
const PxVec3 suspDir = rigidBodyPose.rotate(suspensionParams.suspensionTravelDir);
|
||||
return suspDir;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the start pose of a suspension query.
|
||||
\param[in] frame is a description of the longitudinal, lateral and vertical axes.
|
||||
\param[in] suspensionParams is a description of the suspension frame.
|
||||
\param[in] steerAngle is the yaw angle of the wheel in radians.
|
||||
\param[in] rigidBodyPose is the pose of the rigid body in the world frame.
|
||||
*/
|
||||
PX_FORCE_INLINE PxTransform PxVehicleComputeWheelPoseForSuspensionQuery(const PxVehicleFrame& frame, const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxReal steerAngle, const PxTransform& rigidBodyPose)
|
||||
{
|
||||
//Compute the wheel pose with zero travel from attachment point, zero compliance,
|
||||
//zero wheel pitch (ignore due to radial symmetry).
|
||||
//Zero travel from attachment point (we want the wheel pose at the top of the suspension, i.e., at max compression)
|
||||
PxVehicleSuspensionState suspState;
|
||||
suspState.setToDefault();
|
||||
//Compute the wheel pose.
|
||||
const PxTransform wheelPose = PxVehicleComputeWheelPose(frame, suspensionParams, suspState, 0.0f, 0.0f, steerAngle, rigidBodyPose,
|
||||
0.0f);
|
||||
|
||||
return wheelPose;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the start point, direction and length of a suspension scene raycast.
|
||||
\param[in] frame is a description of the longitudinal, lateral and vertical axes.
|
||||
\param[in] wheelParams describes the radius and halfwidth of the wheel.
|
||||
\param[in] suspensionParams describes the suspension frame and the maximum suspension travel.
|
||||
\param[in] steerAngle is the yaw angle of the wheel in radians.
|
||||
\param[in] rigidBodyPose is the pose of the rigid body in the world frame.
|
||||
\param[out] start is the starting point of the raycast in the world frame.
|
||||
\param[out] dir is the direction of the raycast in the world frame.
|
||||
\param[out] dist is the length of the raycast.
|
||||
\note start, dir and dist together describe a raycast that begins at the top of wheel at maximum compression
|
||||
and ends at the bottom of wheel at maximum droop.
|
||||
*/
|
||||
PX_FORCE_INLINE void PxVehicleComputeSuspensionRaycast
|
||||
(const PxVehicleFrame& frame, const PxVehicleWheelParams& wheelParams, const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxF32 steerAngle, const PxTransform& rigidBodyPose,
|
||||
PxVec3& start, PxVec3& dir, PxReal& dist)
|
||||
{
|
||||
const PxTransform wheelPose = PxVehicleComputeWheelPoseForSuspensionQuery(frame, suspensionParams, steerAngle, rigidBodyPose);
|
||||
|
||||
//Raycast from top of wheel at max compression to bottom of wheel at max droop.
|
||||
dir = PxVehicleComputeSuspensionDirection(suspensionParams, rigidBodyPose);
|
||||
start = wheelPose.p - dir * wheelParams.radius;
|
||||
dist = suspensionParams.suspensionTravelDist + 2.0f*wheelParams.radius;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the start pose, direction and length of a suspension scene sweep.
|
||||
\param[in] frame is a description of the longitudinal, lateral and vertical axes.
|
||||
\param[in] suspensionParams describes the suspension frame and the maximum suspension travel.
|
||||
\param[in] steerAngle is the yaw angle of the wheel in radians.
|
||||
\param[in] rigidBodyPose is the pose of the rigid body in the world frame.
|
||||
\param[out] start is the start pose of the sweep in the world frame.
|
||||
\param[out] dir is the direction of the sweep in the world frame.
|
||||
\param[out] dist is the length of the sweep.
|
||||
\note start, dir and dist together describe a sweep that begins with the wheel placed at maximum
|
||||
compression and ends at the maximum droop pose.
|
||||
*/
|
||||
PX_FORCE_INLINE void PxVehicleComputeSuspensionSweep
|
||||
(const PxVehicleFrame& frame, const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxReal steerAngle, const PxTransform& rigidBodyPose,
|
||||
PxTransform& start, PxVec3& dir, PxReal& dist)
|
||||
{
|
||||
start = PxVehicleComputeWheelPoseForSuspensionQuery(frame, suspensionParams, steerAngle, rigidBodyPose);
|
||||
dir = PxVehicleComputeSuspensionDirection(suspensionParams, rigidBodyPose);
|
||||
dist = suspensionParams.suspensionTravelDist;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Compute the sprung masses of the suspension springs given (i) the number of sprung masses,
|
||||
(ii) coordinates of the sprung masses in the rigid body frame, (iii) the center of mass offset of the rigid body, (iv) the
|
||||
total mass of the rigid body, and (v) the direction of gravity
|
||||
\param[in] nbSprungMasses is the number of sprung masses of the vehicle. This value corresponds to the number of wheels on the vehicle.
|
||||
\param[in] sprungMassCoordinates are the coordinates of the sprung masses in the rigid body frame. The array sprungMassCoordinates must be of
|
||||
length nbSprungMasses or greater.
|
||||
\param[in] totalMass is the total mass of all the sprung masses.
|
||||
\param[in] gravityDirection describes the direction of gravitational acceleration.
|
||||
\param[out] sprungMasses are the masses to set in the associated suspension data with PxVehicleSuspensionData::mSprungMass. The sprungMasses array must be of length
|
||||
nbSprungMasses or greater. Each element in the sprungMasses array corresponds to the suspension located at the same array element in sprungMassCoordinates.
|
||||
The center of mass of the masses in sprungMasses with the coordinates in sprungMassCoordinates satisfy the specified centerOfMass.
|
||||
\return True if the sprung masses were successfully computed, false if the sprung masses were not successfully computed.
|
||||
*/
|
||||
bool PxVehicleComputeSprungMasses(const PxU32 nbSprungMasses, const PxVec3* sprungMassCoordinates, const PxReal totalMass, const PxVehicleAxes::Enum gravityDirection, PxReal* sprungMasses);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
411
engine/third_party/physx/include/vehicle2/suspension/PxVehicleSuspensionParams.h
vendored
Normal file
411
engine/third_party/physx/include/vehicle2/suspension/PxVehicleSuspensionParams.h
vendored
Normal file
@@ -0,0 +1,411 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxFoundation.h"
|
||||
|
||||
#include "common/PxCoreUtilityTypes.h"
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "vehicle2/PxVehicleFunctions.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleSuspensionParams
|
||||
{
|
||||
/**
|
||||
\brief suspensionAttachment specifies the wheel pose at maximum compression.
|
||||
\note suspensionAttachment is specified in the frame of the rigid body.
|
||||
\note camber, steer and toe angles are all applied in the suspension frame.
|
||||
*/
|
||||
PxTransform suspensionAttachment;
|
||||
|
||||
/**
|
||||
\brief suspensionTravelDir specifies the direction of suspension travel.
|
||||
\note suspensionTravelDir is specified in the frame of the rigid body.
|
||||
*/
|
||||
PxVec3 suspensionTravelDir;
|
||||
|
||||
/**
|
||||
\brief suspensionTravelDist is the maximum distance that the suspenson can elongate along #suspensionTravelDir
|
||||
from the pose specified by #suspensionAttachment.
|
||||
\note The position suspensionAttachment.p + #suspensionTravelDir*#suspensionTravelDist corresponds to the
|
||||
the suspension at maximum droop in the rigid body frame.
|
||||
*/
|
||||
PxReal suspensionTravelDist;
|
||||
|
||||
/**
|
||||
\brief wheelAttachment is the pose of the wheel in the suspension frame.
|
||||
\note The rotation angle around the wheel's lateral axis is applied in the wheel attachment frame.
|
||||
*/
|
||||
PxTransform wheelAttachment;
|
||||
|
||||
|
||||
PX_FORCE_INLINE PxVehicleSuspensionParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PxVehicleSuspensionParams r = *this;
|
||||
r.suspensionAttachment = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, srcScale, trgScale, suspensionAttachment);
|
||||
r.suspensionTravelDir = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, suspensionTravelDir);
|
||||
r.suspensionTravelDist *= (trgScale.scale/srcScale.scale);
|
||||
r.wheelAttachment = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, srcScale, trgScale, wheelAttachment);
|
||||
return r;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(suspensionAttachment.isValid(), "PxVehicleSuspensionParams.suspensionAttachment must be a valid transform", false);
|
||||
PX_CHECK_AND_RETURN_VAL(suspensionTravelDir.isFinite(), "PxVehicleSuspensionParams.suspensionTravelDir must be a valid vector", false);
|
||||
PX_CHECK_AND_RETURN_VAL(suspensionTravelDir.isNormalized(), "PxVehicleSuspensionParams.suspensionTravelDir must be a unit vector", false);
|
||||
PX_CHECK_AND_RETURN_VAL(suspensionTravelDist > 0.0f, "PxVehicleSuspensionParams.suspensionTravelDist must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(wheelAttachment.isValid(), "PxVehicleSuspensionParams.wheelAttachment must be a valid transform", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct PxVehicleSuspensionJounceCalculationType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
eRAYCAST, //!< The jounce is calculated using a raycast against the plane of the road geometry state
|
||||
eSWEEP, //!< The jounce is calculated by sweeping a cylinder against the plane of the road geometry state
|
||||
eMAX_NB
|
||||
};
|
||||
};
|
||||
|
||||
struct PxVehicleSuspensionStateCalculationParams
|
||||
{
|
||||
PxVehicleSuspensionJounceCalculationType::Enum suspensionJounceCalculationType;
|
||||
|
||||
/**
|
||||
\brief Limit the suspension expansion dynamics.
|
||||
|
||||
If a hit with the ground is detected, the suspension jounce will be set such that the wheel
|
||||
is placed on the ground. This can result in large changes to jounce within a single
|
||||
simulation frame, if the ground surface has high frequency or if the simulation time step
|
||||
is large. As a result, large damping forces can evolve and cause undesired behavior. If this
|
||||
parameter is set to true, the suspension expansion speed will be limited to what can be
|
||||
achieved given the time step, suspension stiffness etc. As a consequence, handling of the
|
||||
vehicle will be affected as the wheel might loose contact with the ground more easily.
|
||||
*/
|
||||
bool limitSuspensionExpansionVelocity;
|
||||
|
||||
PX_FORCE_INLINE PxVehicleSuspensionStateCalculationParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PX_UNUSED(srcScale);
|
||||
PX_UNUSED(trgScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Compliance describes how toe and camber angle and force application points are affected by suspension compression.
|
||||
\note Each compliance term is in the form of a graph with up to 3 points.
|
||||
\note Each point in the graph has form (jounce/suspensionTravelDist, complianceValue).
|
||||
\note The sequence of points must respresent monotonically increasing values of jounce.
|
||||
\note The compliance value can be computed by linear interpolation.
|
||||
\note If any graph has zero points in it, a value of 0.0 is used for the compliance value.
|
||||
\note If any graph has 1 point in it, the compliance value of that point is used directly.
|
||||
*/
|
||||
struct PxVehicleSuspensionComplianceParams
|
||||
{
|
||||
/**
|
||||
\brief A graph of toe angle against jounce/suspensionTravelDist with the toe angle expressed in radians.
|
||||
\note The toe angle is applied in the suspension frame.
|
||||
*/
|
||||
PxVehicleFixedSizeLookupTable<PxReal, 3> wheelToeAngle;
|
||||
|
||||
/**
|
||||
\brief A graph of camber angle against jounce/suspensionTravelDist with the camber angle expressed in radians.
|
||||
\note The camber angle is applied in the suspension frame.
|
||||
*/
|
||||
PxVehicleFixedSizeLookupTable<PxReal, 3> wheelCamberAngle;
|
||||
|
||||
/**
|
||||
\brief Suspension forces are applied at an offset from the suspension frame. suspForceAppPoint
|
||||
specifies the (X, Y, Z) components of that offset as a function of jounce/suspensionTravelDist.
|
||||
*/
|
||||
PxVehicleFixedSizeLookupTable<PxVec3, 3> suspForceAppPoint;
|
||||
|
||||
/**
|
||||
\brief Tire forces are applied at an offset from the suspension frame. tireForceAppPoint
|
||||
specifies the (X, Y, Z) components of that offset as a function of jounce/suspensionTravelDist.
|
||||
*/
|
||||
PxVehicleFixedSizeLookupTable<PxVec3, 3> tireForceAppPoint;
|
||||
|
||||
PX_FORCE_INLINE PxVehicleSuspensionComplianceParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PxVehicleSuspensionComplianceParams r = *this;
|
||||
|
||||
const PxReal scale = trgScale.scale / srcScale.scale;
|
||||
for (PxU32 i = 0; i < r.suspForceAppPoint.nbDataPairs; i++)
|
||||
{
|
||||
r.suspForceAppPoint.yVals[i] = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, suspForceAppPoint.yVals[i]);
|
||||
r.suspForceAppPoint.yVals[i] *= scale;
|
||||
}
|
||||
for (PxU32 i = 0; i < r.tireForceAppPoint.nbDataPairs; i++)
|
||||
{
|
||||
r.tireForceAppPoint.yVals[i] = PxVehicleTransformFrameToFrame(srcFrame, trgFrame, tireForceAppPoint.yVals[i]);
|
||||
r.tireForceAppPoint.yVals[i] *= scale;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(wheelToeAngle.isValid(), "PxVehicleSuspensionComplianceParams.wheelToeAngle is invalid", false);
|
||||
PX_CHECK_AND_RETURN_VAL(wheelCamberAngle.isValid(), "PxVehicleSuspensionComplianceParams.wheelCamberAngle is invalid", false);
|
||||
PX_CHECK_AND_RETURN_VAL(suspForceAppPoint.isValid(), "PxVehicleSuspensionComplianceParams.wheelToeAngle is invalid", false);
|
||||
PX_CHECK_AND_RETURN_VAL(tireForceAppPoint.isValid(), "PxVehicleSuspensionComplianceParams.wheelCamberAngle is invalid", false);
|
||||
|
||||
for (PxU32 i = 0; i < wheelToeAngle.nbDataPairs; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(wheelToeAngle.xVals[i] >= 0.0f && wheelToeAngle.xVals[i] <= 1.0f, "PxVehicleSuspensionComplianceParams.wheelToeAngle must be an array of points (x,y) with x in range [0, 1]", false);
|
||||
PX_CHECK_AND_RETURN_VAL(wheelToeAngle.yVals[i] >= -PxPi && wheelToeAngle.yVals[i] <= PxPi, "PxVehicleSuspensionComplianceParams.wheelToeAngle must be an array of points (x,y) with y in range [-Pi, Pi]", false);
|
||||
}
|
||||
for (PxU32 i = 0; i < wheelCamberAngle.nbDataPairs; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(wheelCamberAngle.xVals[i] >= 0.0f && wheelCamberAngle.xVals[i] <= 1.0f, "PxVehicleSuspensionComplianceParams.wheelCamberAngle must be an array of points (x,y) with x in range [0, 1]", false);
|
||||
PX_CHECK_AND_RETURN_VAL(wheelCamberAngle.yVals[i] >= -PxPi && wheelCamberAngle.yVals[i] <= PxPi, "PxVehicleSuspensionComplianceParams.wheelCamberAngle must be an array of points (x,y) with y in range [-Pi, Pi]", false);
|
||||
}
|
||||
|
||||
for (PxU32 i = 0; i < suspForceAppPoint.nbDataPairs; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(suspForceAppPoint.xVals[i] >= 0.0f && suspForceAppPoint.xVals[i] <= 1.0f, "PxVehicleSuspensionComplianceParams.suspForceAppPoint[0] must be an array of points (x,y) with x in range [0, 1]", false);
|
||||
}
|
||||
for (PxU32 i = 0; i < tireForceAppPoint.nbDataPairs; i++)
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(tireForceAppPoint.xVals[i] >= 0.0f && tireForceAppPoint.xVals[i] <= 1.0f, "PxVehicleSuspensionComplianceParams.tireForceAppPoint[0] must be an array of points (x,y) with x in range [0, 1]", false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Suspension force is computed by converting suspenson state to suspension force under the assumption of a linear spring.
|
||||
\see PxVehicleSuspensionForceUpdate
|
||||
*/
|
||||
struct PxVehicleSuspensionForceParams
|
||||
{
|
||||
/**
|
||||
\brief Spring strength of suspension.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> mass / (time^2)
|
||||
*/
|
||||
PxReal stiffness;
|
||||
|
||||
/**
|
||||
\brief Spring damper rate of suspension.
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> mass / time
|
||||
*/
|
||||
PxReal damping;
|
||||
|
||||
/**
|
||||
\brief Part of the vehicle mass that is supported by the suspension spring.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> mass
|
||||
*/
|
||||
PxReal sprungMass;
|
||||
|
||||
PX_FORCE_INLINE PxVehicleSuspensionForceParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PX_UNUSED(srcScale);
|
||||
PX_UNUSED(trgScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(stiffness > 0.0f, "PxVehicleSuspensionForceParams.stiffness must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(damping >= 0.0f, "PxVehicleSuspensionForceParams.damping must be greater than or equal to zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(sprungMass > 0.0f, "PxVehicleSuspensionForceParams.sprungMass must be greater than zero", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\deprecated This API was introduced with the new Vehicle API for transition purposes but will be removed in a future version.
|
||||
|
||||
\brief Suspension force is computed by converting suspenson state to suspension force under the assumption of a linear spring.
|
||||
\see PxVehicleSuspensionLegacyForceUpdate
|
||||
*/
|
||||
struct PX_DEPRECATED PxVehicleSuspensionForceLegacyParams
|
||||
{
|
||||
/**
|
||||
\brief Spring strength of suspension.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> mass / (time^2)
|
||||
*/
|
||||
PxReal stiffness;
|
||||
|
||||
/**
|
||||
\brief Spring damper rate of suspension.
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> mass / time
|
||||
*/
|
||||
PxReal damping;
|
||||
|
||||
/**
|
||||
\brief The suspension compression that balances the gravitational force acting on the sprung mass.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> length
|
||||
*/
|
||||
PxReal restDistance;
|
||||
|
||||
/**
|
||||
\brief The mass supported by the suspension spring.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> mass
|
||||
*/
|
||||
PxReal sprungMass;
|
||||
|
||||
PX_FORCE_INLINE PxVehicleSuspensionForceLegacyParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PxVehicleSuspensionForceLegacyParams r = *this;
|
||||
r.restDistance *= (trgScale.scale / srcScale.scale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(stiffness > 0.0f, "PxVehicleSuspensionForceLegacyParams.stiffness must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(damping >= 0.0f, "PxVehicleSuspensionForceLegacyParams.damping must be greater than or equal to zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(restDistance > 0.0f, "PxVehicleSuspensionForceLegacyParams.restDistance must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(sprungMass > 0.0f, "PxVehicleSuspensionForceLegacyParams.sprungMass must be greater than zero", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
\brief The purpose of the anti-roll bar is to generate a torque to apply to the vehicle's rigid body that will reduce the jounce difference arising
|
||||
between any pair of chosen wheels. If the chosen wheels share an axle, the anti-roll bar will attempt to reduce the roll angle of the vehicle's rigid body.
|
||||
Alternatively, if the chosen wheels are the front and rear wheels along one side of the vehicle, the anti-roll bar will attempt to reduce the pitch angle of the
|
||||
vehicle's rigid body.
|
||||
*/
|
||||
struct PxVehicleAntiRollForceParams
|
||||
{
|
||||
/*
|
||||
\brief The anti-roll bar connects two wheels with indices wheel0 and wheel1
|
||||
\note wheel0 and wheel1 may be chosen to have the effect of an anti-dive bar or to have the effect of an anti-roll bar.
|
||||
*/
|
||||
PxU32 wheel0;
|
||||
|
||||
/*
|
||||
\brief The anti-roll bar connects two wheels with indices wheel0 and wheel1
|
||||
\note wheel0 and wheel1 may be chosen to have the effect of an anti-dive bar or to have the effect of an anti-roll bar.
|
||||
*/
|
||||
PxU32 wheel1;
|
||||
|
||||
/*
|
||||
\brief The linear stiffness of the anti-roll bar.
|
||||
\note A positive stiffness will work to reduce the discrepancy in jounce between wheel0 and wheel1.
|
||||
\note A negative stiffness will work to increase the discrepancy in jounce between wheel0 and wheel1.
|
||||
|
||||
<b>Unit:</b> mass / (time^2)
|
||||
*/
|
||||
PxReal stiffness;
|
||||
|
||||
PX_FORCE_INLINE PxVehicleAntiRollForceParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PX_UNUSED(srcScale);
|
||||
PX_UNUSED(trgScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid(const PxVehicleAxleDescription& axleDesc) const
|
||||
{
|
||||
if (!PxIsFinite(stiffness))
|
||||
return false;
|
||||
if (wheel0 == wheel1)
|
||||
return false;
|
||||
|
||||
//Check that each wheel id is a valid wheel.
|
||||
const PxU32 wheelIds[2] = { wheel0, wheel1 };
|
||||
for (PxU32 k = 0; k < 2; k++)
|
||||
{
|
||||
const PxU32 wheelToFind = wheelIds[k];
|
||||
bool foundWheelInAxleDescription = false;
|
||||
for (PxU32 i = 0; i < axleDesc.nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheel = axleDesc.wheelIdsInAxleOrder[i];
|
||||
if (wheel == wheelToFind)
|
||||
{
|
||||
foundWheelInAxleDescription = true;
|
||||
}
|
||||
}
|
||||
if (!foundWheelInAxleDescription)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
185
engine/third_party/physx/include/vehicle2/suspension/PxVehicleSuspensionStates.h
vendored
Normal file
185
engine/third_party/physx/include/vehicle2/suspension/PxVehicleSuspensionStates.h
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
#define PX_VEHICLE_UNSPECIFIED_JOUNCE PX_MAX_F32
|
||||
#define PX_VEHICLE_UNSPECIFIED_SEPARATION PX_MAX_F32
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
struct PxVehicleSuspensionState
|
||||
{
|
||||
/**
|
||||
\brief jounce is the distance from maximum droop.
|
||||
\note jounce is positive semi-definite
|
||||
\note A value of 0.0 represents the suspension at maximum droop and zero suspension force.
|
||||
\note A value of suspensionTravelDist represents the suspension at maximum compression.
|
||||
\note jounce is clamped in range [0, suspensionTravelDist].
|
||||
*/
|
||||
PxReal jounce;
|
||||
|
||||
/**
|
||||
\brief jounceSpeed is the rate of change of jounce.
|
||||
*/
|
||||
PxReal jounceSpeed;
|
||||
|
||||
/**
|
||||
\brief separation holds extra information about the contact state of the wheel with the ground.
|
||||
|
||||
If the suspension travel range is enough to place the wheel on the ground, then separation will be 0.
|
||||
If separation holds a negative value, then the wheel penetrates into the ground at maximum compression
|
||||
as well as maximum droop. The suspension would need to go beyond maximum compression (ground normal
|
||||
pointing in opposite direction of suspension) or beyond maximum droop (ground normal pointing in same
|
||||
direction as suspension) to place the wheel on the ground. In that case the separation value defines
|
||||
how much the wheel penetrates into the ground along the ground plane normal. This penetration may be
|
||||
resolved by using a constraint that simulates the effect of a bump stop.
|
||||
If separation holds a positive value, then the wheel does not penetrate the ground at maximum droop
|
||||
but can not touch the ground because the suspension would need to expand beyond max droop to reach it
|
||||
or because the suspension could not expand fast enough to reach the ground.
|
||||
*/
|
||||
PxReal separation;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault(const PxReal _jounce = PX_VEHICLE_UNSPECIFIED_JOUNCE,
|
||||
const PxReal _separation = PX_VEHICLE_UNSPECIFIED_SEPARATION)
|
||||
{
|
||||
jounce = _jounce;
|
||||
jounceSpeed = 0;
|
||||
separation = _separation;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief The effect of suspension compliance on toe and camber angle and on the tire and suspension force application points.
|
||||
*/
|
||||
struct PxVehicleSuspensionComplianceState
|
||||
{
|
||||
/**
|
||||
\brief The toe angle in radians that arises from suspension compliance.
|
||||
\note toe is expressed in the suspension frame.
|
||||
*/
|
||||
PxReal toe;
|
||||
|
||||
/**
|
||||
\brief The camber angle in radians that arises from suspension compliance.
|
||||
\note camber is expressed in the suspension frame.
|
||||
*/
|
||||
PxReal camber;
|
||||
|
||||
/**
|
||||
\brief The tire force application point that arises from suspension compliance.
|
||||
\note tireForceAppPoint is expressed in the suspension frame.
|
||||
*/
|
||||
PxVec3 tireForceAppPoint;
|
||||
|
||||
/**
|
||||
\brief The suspension force application point that arises from suspension compliance.
|
||||
\note suspForceAppPoint is expressed in the suspension frame.
|
||||
*/
|
||||
PxVec3 suspForceAppPoint;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleSuspensionComplianceState));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief The force and torque for a single suspension to apply to the vehicle's rigid body.
|
||||
*/
|
||||
struct PxVehicleSuspensionForce
|
||||
{
|
||||
/**
|
||||
\brief The force to apply to the rigid body.
|
||||
\note force is expressed in the world frame.
|
||||
|
||||
<b>Unit:</b> mass * length / (time^2)
|
||||
*/
|
||||
PxVec3 force;
|
||||
|
||||
/**
|
||||
\brief The torque to apply to the rigid body.
|
||||
\note torque is expressed in the world frame.
|
||||
|
||||
<b>Unit:</b> mass * (length^2) / (time^2)
|
||||
*/
|
||||
PxVec3 torque;
|
||||
|
||||
/**
|
||||
\brief The component of force that lies along the normal of the plane under the wheel.
|
||||
\note normalForce may be used by the tire model as the tire load.
|
||||
|
||||
<b>Unit:</b> mass * length / (time^2)
|
||||
*/
|
||||
PxReal normalForce;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleSuspensionForce));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief The anti-roll torque of all anti-roll bars accumulates in a single torque to apply
|
||||
to the vehicle's rigid body.
|
||||
*/
|
||||
struct PxVehicleAntiRollTorque
|
||||
{
|
||||
/**
|
||||
\brief The accumulated torque to apply to the rigid body.
|
||||
\note antiRollTorque is expressed in the world frame.
|
||||
|
||||
<b>Unit:</b> mass * (length^2) / (time^2)
|
||||
*/
|
||||
PxVec3 antiRollTorque;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleAntiRollTorque));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
341
engine/third_party/physx/include/vehicle2/tire/PxVehicleTireComponents.h
vendored
Normal file
341
engine/third_party/physx/include/vehicle2/tire/PxVehicleTireComponents.h
vendored
Normal file
@@ -0,0 +1,341 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "vehicle2/PxVehicleComponent.h"
|
||||
|
||||
#include "vehicle2/commands/PxVehicleCommandHelpers.h"
|
||||
#include "vehicle2/roadGeometry/PxVehicleRoadGeometryState.h"
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionParams.h"
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionStates.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelStates.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelParams.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelHelpers.h"
|
||||
|
||||
#include "PxVehicleTireFunctions.h"
|
||||
#include "PxVehicleTireParams.h"
|
||||
|
||||
#include "common/PxProfileZone.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxVehicleTireComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleTireComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleTireComponent() {}
|
||||
|
||||
virtual void getDataForTireComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
PxVehicleArrayData<const PxReal>& steerResponseStates,
|
||||
const PxVehicleRigidBodyState*& rigidBodyState,
|
||||
PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates,
|
||||
PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams,
|
||||
PxVehicleArrayData<const PxVehicleTireForceParams>& tireForceParams,
|
||||
PxVehicleArrayData<const PxVehicleRoadGeometryState>& roadGeomStates,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionState>& suspensionStates,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspensionComplianceStates,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionForce>& suspensionForces,
|
||||
PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1DStates,
|
||||
PxVehicleArrayData<PxVehicleTireGripState>& tireGripStates,
|
||||
PxVehicleArrayData<PxVehicleTireDirectionState>& tireDirectionStates,
|
||||
PxVehicleArrayData<PxVehicleTireSpeedState>& tireSpeedStates,
|
||||
PxVehicleArrayData<PxVehicleTireSlipState>& tireSlipStates,
|
||||
PxVehicleArrayData<PxVehicleTireCamberAngleState>& tireCamberAngleStates,
|
||||
PxVehicleArrayData<PxVehicleTireStickyState>& tireStickyStates,
|
||||
PxVehicleArrayData<PxVehicleTireForce>& tireForces) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_PROFILE_ZONE("PxVehicleTireComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
PxVehicleArrayData<const PxReal> steerResponseStates;
|
||||
const PxVehicleRigidBodyState* rigidBodyState;
|
||||
PxVehicleArrayData<const PxVehicleWheelActuationState> actuationStates;
|
||||
PxVehicleArrayData<const PxVehicleWheelParams> wheelParams;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams;
|
||||
PxVehicleArrayData<const PxVehicleTireForceParams> tireForceParams;
|
||||
PxVehicleArrayData<const PxVehicleRoadGeometryState> roadGeomStates;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionState> suspensionStates;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceState> suspensionComplianceStates;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionForce> suspensionForces;
|
||||
PxVehicleArrayData<const PxVehicleWheelRigidBody1dState> wheelRigidBody1DStates;
|
||||
PxVehicleArrayData<PxVehicleTireGripState> tireGripStates;
|
||||
PxVehicleArrayData<PxVehicleTireDirectionState> tireDirectionStates;
|
||||
PxVehicleArrayData<PxVehicleTireSpeedState> tireSpeedStates;
|
||||
PxVehicleArrayData<PxVehicleTireSlipState> tireSlipStates;
|
||||
PxVehicleArrayData<PxVehicleTireCamberAngleState> tireCamberAngleStates;
|
||||
PxVehicleArrayData<PxVehicleTireStickyState> tireStickyStates;
|
||||
PxVehicleArrayData<PxVehicleTireForce> tireForces;
|
||||
|
||||
getDataForTireComponent(axleDescription, steerResponseStates,
|
||||
rigidBodyState, actuationStates, wheelParams, suspensionParams, tireForceParams,
|
||||
roadGeomStates, suspensionStates, suspensionComplianceStates, suspensionForces,
|
||||
wheelRigidBody1DStates, tireGripStates, tireDirectionStates, tireSpeedStates,
|
||||
tireSlipStates, tireCamberAngleStates, tireStickyStates, tireForces);
|
||||
|
||||
for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
|
||||
const bool isWheelOnGround = PxVehicleIsWheelOnGround(suspensionStates[wheelId]);
|
||||
|
||||
//Compute the tire slip directions
|
||||
PxVehicleTireDirsUpdate(
|
||||
suspensionParams[wheelId],
|
||||
steerResponseStates[wheelId],
|
||||
roadGeomStates[wheelId].plane.n, isWheelOnGround,
|
||||
suspensionComplianceStates[wheelId],
|
||||
*rigidBodyState,
|
||||
context.frame,
|
||||
tireDirectionStates[wheelId]);
|
||||
|
||||
//Compute the rigid body speeds along the tire slip directions.
|
||||
PxVehicleTireSlipSpeedsUpdate(
|
||||
wheelParams[wheelId], suspensionParams[wheelId],
|
||||
steerResponseStates[wheelId], suspensionStates[wheelId], tireDirectionStates[wheelId],
|
||||
*rigidBodyState, roadGeomStates[wheelId],
|
||||
context.frame,
|
||||
tireSpeedStates[wheelId]);
|
||||
|
||||
//Compute the tire slip angles.
|
||||
PxVehicleTireSlipsUpdate(
|
||||
wheelParams[wheelId], context.tireSlipParams,
|
||||
actuationStates[wheelId], tireSpeedStates[wheelId],
|
||||
wheelRigidBody1DStates[wheelId],
|
||||
tireSlipStates[wheelId]);
|
||||
|
||||
//Update the camber angle
|
||||
PxVehicleTireCamberAnglesUpdate(
|
||||
suspensionParams[wheelId], steerResponseStates[wheelId],
|
||||
roadGeomStates[wheelId].plane.n, isWheelOnGround,
|
||||
suspensionComplianceStates[wheelId], *rigidBodyState,
|
||||
context.frame,
|
||||
tireCamberAngleStates[wheelId]);
|
||||
|
||||
//Compute the friction
|
||||
PxVehicleTireGripUpdate(
|
||||
tireForceParams[wheelId], roadGeomStates[wheelId].friction,
|
||||
isWheelOnGround, suspensionForces[wheelId],
|
||||
tireSlipStates[wheelId], tireGripStates[wheelId]);
|
||||
|
||||
//Update the tire sticky state
|
||||
//
|
||||
//Note: this should be skipped if tires do not use the sticky feature
|
||||
PxVehicleTireStickyStateUpdate(
|
||||
*axleDescription,
|
||||
wheelParams[wheelId],
|
||||
context.tireStickyParams,
|
||||
actuationStates, tireGripStates[wheelId],
|
||||
tireSpeedStates[wheelId], wheelRigidBody1DStates[wheelId],
|
||||
dt,
|
||||
tireStickyStates[wheelId]);
|
||||
|
||||
//If sticky tire is active set the slip angle to zero.
|
||||
//
|
||||
//Note: this should be skipped if tires do not use the sticky feature
|
||||
PxVehicleTireSlipsAccountingForStickyStatesUpdate(
|
||||
tireStickyStates[wheelId],
|
||||
tireSlipStates[wheelId]);
|
||||
|
||||
//Compute the tire forces
|
||||
PxVehicleTireForcesUpdate(
|
||||
wheelParams[wheelId], suspensionParams[wheelId],
|
||||
tireForceParams[wheelId],
|
||||
suspensionComplianceStates[wheelId],
|
||||
tireGripStates[wheelId], tireDirectionStates[wheelId],
|
||||
tireSlipStates[wheelId], tireCamberAngleStates[wheelId],
|
||||
*rigidBodyState,
|
||||
tireForces[wheelId]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\deprecated This API was introduced with the new Vehicle API for transition purposes but will be removed in a future version.
|
||||
*/
|
||||
class PX_DEPRECATED PxVehicleLegacyTireComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleLegacyTireComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleLegacyTireComponent() {}
|
||||
|
||||
virtual void getDataForLegacyTireComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
PxVehicleArrayData<const PxReal>& steerResponseStates,
|
||||
const PxVehicleRigidBodyState*& rigidBodyState,
|
||||
PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates,
|
||||
PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams,
|
||||
PxVehicleArrayData<const PxVehicleTireForceParams>& tireForceParams,
|
||||
PxVehicleArrayData<const PxVehicleRoadGeometryState>& roadGeomStates,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionState>& suspensionStates,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspensionComplianceStates,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionForce>& suspensionForces,
|
||||
PxVehicleArrayData<const PxVehicleWheelRigidBody1dState>& wheelRigidBody1DStates,
|
||||
PxVehicleArrayData<PxVehicleTireGripState>& tireGripStates,
|
||||
PxVehicleArrayData<PxVehicleTireDirectionState>& tireDirectionStates,
|
||||
PxVehicleArrayData<PxVehicleTireSpeedState>& tireSpeedStates,
|
||||
PxVehicleArrayData<PxVehicleTireSlipState>& tireSlipStates,
|
||||
PxVehicleArrayData<PxVehicleTireCamberAngleState>& tireCamberAngleStates,
|
||||
PxVehicleArrayData<PxVehicleTireStickyState>& tireStickyStates,
|
||||
PxVehicleArrayData<PxVehicleTireForce>& tireForces) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_PROFILE_ZONE("PxVehicleLegacyTireComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
PxVehicleArrayData<const PxReal> steerResponseStates;
|
||||
const PxVehicleRigidBodyState* rigidBodyState;
|
||||
PxVehicleArrayData<const PxVehicleWheelActuationState> actuationStates;
|
||||
PxVehicleArrayData<const PxVehicleWheelParams> wheelParams;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams;
|
||||
PxVehicleArrayData<const PxVehicleTireForceParams> tireForceParams;
|
||||
PxVehicleArrayData<const PxVehicleRoadGeometryState> roadGeomStates;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionState> suspensionStates;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceState> suspensionComplianceStates;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionForce> suspensionForces;
|
||||
PxVehicleArrayData<const PxVehicleWheelRigidBody1dState> wheelRigidBody1DStates;
|
||||
PxVehicleArrayData<PxVehicleTireGripState> tireGripStates;
|
||||
PxVehicleArrayData<PxVehicleTireDirectionState> tireDirectionStates;
|
||||
PxVehicleArrayData<PxVehicleTireSpeedState> tireSpeedStates;
|
||||
PxVehicleArrayData<PxVehicleTireSlipState> tireSlipStates;
|
||||
PxVehicleArrayData<PxVehicleTireCamberAngleState> tireCamberAngleStates;
|
||||
PxVehicleArrayData<PxVehicleTireStickyState> tireStickyStates;
|
||||
PxVehicleArrayData<PxVehicleTireForce> tireForces;
|
||||
|
||||
getDataForLegacyTireComponent(axleDescription, steerResponseStates,
|
||||
rigidBodyState, actuationStates,
|
||||
wheelParams, suspensionParams, tireForceParams,
|
||||
roadGeomStates, suspensionStates, suspensionComplianceStates,
|
||||
suspensionForces, wheelRigidBody1DStates,
|
||||
tireGripStates, tireDirectionStates, tireSpeedStates, tireSlipStates,
|
||||
tireCamberAngleStates, tireStickyStates, tireForces);
|
||||
|
||||
for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
|
||||
const bool isWheelOnGround = roadGeomStates[wheelId].hitState;
|
||||
// note: since this is the legacy component, PxVehicleIsWheelOnGround() is not used
|
||||
// here
|
||||
|
||||
//Compute the tire slip directions
|
||||
PxVehicleTireDirsLegacyUpdate(
|
||||
suspensionParams[wheelId],
|
||||
steerResponseStates[wheelId],
|
||||
roadGeomStates[wheelId], *rigidBodyState,
|
||||
context.frame,
|
||||
tireDirectionStates[wheelId]);
|
||||
|
||||
//Compute the rigid body speeds along the tire slip directions.
|
||||
PxVehicleTireSlipSpeedsUpdate(
|
||||
wheelParams[wheelId], suspensionParams[wheelId],
|
||||
steerResponseStates[wheelId], suspensionStates[wheelId], tireDirectionStates[wheelId],
|
||||
*rigidBodyState, roadGeomStates[wheelId],
|
||||
context.frame,
|
||||
tireSpeedStates[wheelId]);
|
||||
|
||||
//Compute the tire slip angles.
|
||||
PxVehicleTireSlipsLegacyUpdate(
|
||||
wheelParams[wheelId], context.tireSlipParams,
|
||||
actuationStates[wheelId], tireSpeedStates[wheelId],
|
||||
wheelRigidBody1DStates[wheelId],
|
||||
tireSlipStates[wheelId]);
|
||||
|
||||
//Update the camber angle
|
||||
PxVehicleTireCamberAnglesUpdate(
|
||||
suspensionParams[wheelId], steerResponseStates[wheelId],
|
||||
roadGeomStates[wheelId].plane.n, isWheelOnGround,
|
||||
suspensionComplianceStates[wheelId], *rigidBodyState,
|
||||
context.frame,
|
||||
tireCamberAngleStates[wheelId]);
|
||||
|
||||
//Compute the friction
|
||||
PxVehicleTireGripUpdate(
|
||||
tireForceParams[wheelId], roadGeomStates[wheelId].friction,
|
||||
PxVehicleIsWheelOnGround(suspensionStates[wheelId]), suspensionForces[wheelId],
|
||||
tireSlipStates[wheelId], tireGripStates[wheelId]);
|
||||
// note: PxVehicleIsWheelOnGround() used here to reflect previous behavior since this is
|
||||
// the legacy component after all
|
||||
|
||||
//Update the tire sticky state
|
||||
//
|
||||
//Note: this should be skipped if tires do not use the sticky feature
|
||||
PxVehicleTireStickyStateUpdate(
|
||||
*axleDescription,
|
||||
wheelParams[wheelId],
|
||||
context.tireStickyParams,
|
||||
actuationStates, tireGripStates[wheelId],
|
||||
tireSpeedStates[wheelId], wheelRigidBody1DStates[wheelId],
|
||||
dt,
|
||||
tireStickyStates[wheelId]);
|
||||
|
||||
//If sticky tire is active set the slip angle to zero.
|
||||
//
|
||||
//Note: this should be skipped if tires do not use the sticky feature
|
||||
PxVehicleTireSlipsAccountingForStickyStatesUpdate(
|
||||
tireStickyStates[wheelId],
|
||||
tireSlipStates[wheelId]);
|
||||
|
||||
//Compute the tire forces
|
||||
PxVehicleTireForcesUpdate(
|
||||
wheelParams[wheelId], suspensionParams[wheelId],
|
||||
tireForceParams[wheelId],
|
||||
suspensionComplianceStates[wheelId],
|
||||
tireGripStates[wheelId], tireDirectionStates[wheelId],
|
||||
tireSlipStates[wheelId], tireCamberAngleStates[wheelId],
|
||||
*rigidBodyState,
|
||||
tireForces[wheelId]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
270
engine/third_party/physx/include/vehicle2/tire/PxVehicleTireFunctions.h
vendored
Normal file
270
engine/third_party/physx/include/vehicle2/tire/PxVehicleTireFunctions.h
vendored
Normal file
@@ -0,0 +1,270 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleSuspensionParams;
|
||||
struct PxVehicleRoadGeometryState;
|
||||
struct PxVehicleRigidBodyState;
|
||||
struct PxVehicleTireDirectionState;
|
||||
struct PxVehicleSuspensionComplianceState;
|
||||
struct PxVehicleWheelParams;
|
||||
struct PxVehicleTireSpeedState;
|
||||
struct PxVehicleWheelActuationState;
|
||||
struct PxVehicleWheelRigidBody1dState;
|
||||
struct PxVehicleTireSlipState;
|
||||
struct PxVehicleSuspensionState;
|
||||
struct PxVehicleTireCamberAngleState;
|
||||
struct PxVehicleTireGripState;
|
||||
struct PxVehicleTireForceParams;
|
||||
struct PxVehicleSuspensionForce;
|
||||
struct PxVehicleTireForce;
|
||||
struct PxVehicleTireStickyState;
|
||||
|
||||
/**
|
||||
\deprecated This API was introduced with the new Vehicle API for transition purposes but will be removed in a future version.
|
||||
|
||||
\brief Compute the longitudinal and lateral tire directions in the ground plane.
|
||||
\param[in] suspensionParams describes the frame of the suspension and wheel.
|
||||
\param[in] steerAngle is the steer angle in radians to be applied to the wheel.
|
||||
\param[in] roadGeometryState describes the plane of the road geometry under the wheel
|
||||
\param[in] rigidBodyState describes the current pose of the vehicle's rigid body in the world frame.
|
||||
\param[in] frame is a description of the vehicle's lateral and longitudinal axes.
|
||||
\param[out] tireDirectionState is the computed tire longitudinal and lateral directions in the world frame.
|
||||
\note PxVehicleTireDirsLegacyUpdate replicates the tire direction calculation of PhysX 5.0 and earlier.
|
||||
*/
|
||||
PX_DEPRECATED void PxVehicleTireDirsLegacyUpdate
|
||||
(const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxReal steerAngle, const PxVehicleRoadGeometryState& roadGeometryState, const PxVehicleRigidBodyState& rigidBodyState,
|
||||
const PxVehicleFrame& frame,
|
||||
PxVehicleTireDirectionState& tireDirectionState);
|
||||
|
||||
/**
|
||||
\brief Compute the longitudinal and lateral tire directions in the ground plane.
|
||||
\param[in] suspensionParams describes the frame of the suspension and wheel.
|
||||
\param[in] steerAngle is the steer angle in radians to be applied to the wheel.
|
||||
\param[in] groundNormal describes the plane normal of the road geometry under the wheel.
|
||||
\param[in] isWheelOnGround defines whether the wheel touches the road geometry.
|
||||
\param[in] complianceState is a description of the camber and toe angle that arise from suspension compliance.
|
||||
\param[in] rigidBodyState describes the current pose of the vehicle's rigid body in the world frame.
|
||||
\param[in] frame is a description of the vehicle's lateral and longitudinal axes.
|
||||
\param[out] tireDirectionState is the computed tire longitudinal and lateral directions in the world frame.
|
||||
\note The difference between PxVehicleTireDirsUpdate and PxVehicleTireDirsLegacyUpdate is that
|
||||
PxVehicleTireDirsUpdate accounts for suspension compliance while PxVehicleTireDirsLegacyUpdate does not.
|
||||
*/
|
||||
void PxVehicleTireDirsUpdate
|
||||
(const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxReal steerAngle, const PxVec3& groundNormal, bool isWheelOnGround,
|
||||
const PxVehicleSuspensionComplianceState& complianceState,
|
||||
const PxVehicleRigidBodyState& rigidBodyState,
|
||||
const PxVehicleFrame& frame,
|
||||
PxVehicleTireDirectionState& tireDirectionState);
|
||||
|
||||
/**
|
||||
\brief Project the rigid body velocity at the tire contact point along the tire longitudinal directions.
|
||||
\param[in] wheelParams is a description of the wheel's radius and half-width.
|
||||
\param[in] suspensionParams describes the frame of the suspension and wheel.
|
||||
\param[in] steerAngle is the steer angle in radians to be applied to the wheel.
|
||||
\param[in] suspensionStates is the current suspension compression state.
|
||||
\param[in] tireDirectionState is the tire's longitudinal and lateral directions in the ground plane.
|
||||
\param[in] rigidBodyState describes the current pose and velocity of the vehicle's rigid body in the world frame.
|
||||
\param[in] roadGeometryState describes the current velocity of the road geometry under each wheel.
|
||||
\param[in] frame is a description of the vehicle's lateral and longitudinal axes.
|
||||
\param[out] tireSpeedState is the components of rigid body velocity at the tire contact point along the
|
||||
tire's longitudinal and lateral axes.
|
||||
\see PxVehicleTireDirsUpdate
|
||||
\see PxVehicleTireDirsLegacyUpdate
|
||||
*/
|
||||
void PxVehicleTireSlipSpeedsUpdate
|
||||
(const PxVehicleWheelParams& wheelParams, const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxF32 steerAngle, const PxVehicleSuspensionState& suspensionStates, const PxVehicleTireDirectionState& tireDirectionState,
|
||||
const PxVehicleRigidBodyState& rigidBodyState, const PxVehicleRoadGeometryState& roadGeometryState,
|
||||
const PxVehicleFrame& frame,
|
||||
PxVehicleTireSpeedState& tireSpeedState);
|
||||
|
||||
/**
|
||||
\brief Compute a tire's longitudinal and lateral slip angles.
|
||||
\param[in] wheelParams describes the radius of the wheel.
|
||||
\param[in] tireSlipParams describes how to manage small longitudinal speeds by setting minimum values on the
|
||||
denominator of the quotients used to calculate lateral and longitudinal slip.
|
||||
\param[in] actuationState describes whether a wheel is to be driven by a drive torque or not.
|
||||
\param[in] tireSpeedState is the component of rigid body velocity at the tire contact point projected along the
|
||||
tire's longitudinal and lateral axes.
|
||||
\param[in] wheelRigidBody1dState is the wheel rotation speed.
|
||||
\param[out] tireSlipState is the computed tire longitudinal and lateral slips.
|
||||
\note Longitudinal slip angle has the following theoretical form: (wheelRotationSpeed*wheelRadius - longitudinalSpeed)/|longitudinalSpeed|
|
||||
\note Lateral slip angle has the following theoretical form: atan(lateralSpeed/|longitudinalSpeed|)
|
||||
\note The calculation of both longitudinal and lateral slip angles avoid a zero denominator using minimum values for the denominator set in
|
||||
tireSlipParams.
|
||||
*/
|
||||
void PxVehicleTireSlipsUpdate
|
||||
(const PxVehicleWheelParams& wheelParams,
|
||||
const PxVehicleTireSlipParams& tireSlipParams,
|
||||
const PxVehicleWheelActuationState& actuationState, PxVehicleTireSpeedState& tireSpeedState, const PxVehicleWheelRigidBody1dState& wheelRigidBody1dState,
|
||||
PxVehicleTireSlipState& tireSlipState);
|
||||
|
||||
/**
|
||||
\deprecated This API was introduced with the new Vehicle API for transition purposes but will be removed in a future version.
|
||||
|
||||
\brief Compute a tire's longitudinal and lateral slip angles.
|
||||
\param[in] wheelParams describes the radius of the wheel.
|
||||
\param[in] tireSlipParams describes how to manage small longitudinal speeds by setting minimum values on the
|
||||
denominator of the quotients used to calculate lateral and longitudinal slip.
|
||||
\param[in] actuationState describes whether a wheel is to be driven by a drive torque or not.
|
||||
\param[in] tireSpeedState is the component of rigid body velocity at the tire contact point projected along the
|
||||
tire's longitudinal and lateral axes.
|
||||
\param[in] wheelRigidBody1dState is the wheel rotation speed.
|
||||
\param[out] tireSlipState is the computed tire longitudinal and lateral slips.
|
||||
\note Longitudinal slip angle has the following theoretical form: (wheelRotationSpeed*wheelRadius - longitudinalSpeed)/|longitudinalSpeed|
|
||||
\note Lateral slip angle has the following theoretical form: atan(lateralSpeed/|longitudinalSpeed|)
|
||||
\note The calculation of both longitudinal and lateral slip angles avoid a zero denominator using minimum values for the denominator set in
|
||||
tireSlipParams.
|
||||
*/
|
||||
void PX_DEPRECATED PxVehicleTireSlipsLegacyUpdate
|
||||
(const PxVehicleWheelParams& wheelParams,
|
||||
const PxVehicleTireSlipParams& tireSlipParams,
|
||||
const PxVehicleWheelActuationState& actuationState, PxVehicleTireSpeedState& tireSpeedState, const PxVehicleWheelRigidBody1dState& wheelRigidBody1dState,
|
||||
PxVehicleTireSlipState& tireSlipState);
|
||||
|
||||
|
||||
/**
|
||||
\brief Compute the camber angle of the wheel
|
||||
\param[in] suspensionParams describes the frame of the suspension and wheel.
|
||||
\param[in] steerAngle is the steer angle in radians to be applied to the wheel.
|
||||
\param[in] groundNormal describes the plane normal of the road geometry under the wheel.
|
||||
\param[in] isWheelOnGround defines whether the wheel touches the road geometry.
|
||||
\param[in] complianceState is a description of the camber and toe angle that arise from suspension compliance.
|
||||
\param[in] rigidBodyState describes the current pose of the vehicle's rigid body in the world frame.
|
||||
\param[in] frame is a description of the vehicle's lateral and longitudinal axes.
|
||||
\param[out] tireCamberAngleState is the computed camber angle of the tire expressed in radians.
|
||||
*/
|
||||
void PxVehicleTireCamberAnglesUpdate
|
||||
(const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxReal steerAngle, const PxVec3& groundNormal, bool isWheelOnGround,
|
||||
const PxVehicleSuspensionComplianceState& complianceState,
|
||||
const PxVehicleRigidBodyState& rigidBodyState,
|
||||
const PxVehicleFrame& frame,
|
||||
PxVehicleTireCamberAngleState& tireCamberAngleState);
|
||||
|
||||
/**
|
||||
\brief Compute the load and friction experienced by the tire.
|
||||
\param[in] tireForceParams describes the tire's friction response to longitudinal lip angle and its load response.
|
||||
\param[in] frictionCoefficient describes the friction coefficient for the tire and road geometry pair.
|
||||
\param[in] isWheelOnGround defines whether the wheel touches the road geometry.
|
||||
\param[in] suspensionForce is the force that the suspension exerts on the sprung mass of the suspension.
|
||||
\param[in] tireSlipState is the tire longitudinal and lateral slip angles.
|
||||
\param[out] tireGripState is the computed load and friction experienced by the tire.
|
||||
\note If the suspension cannot place the wheel on the ground the tire load and friction will be 0.0.
|
||||
*/
|
||||
void PxVehicleTireGripUpdate
|
||||
(const PxVehicleTireForceParams& tireForceParams,
|
||||
PxReal frictionCoefficient, bool isWheelOnGround, const PxVehicleSuspensionForce& suspensionForce,
|
||||
const PxVehicleTireSlipState& tireSlipState,
|
||||
PxVehicleTireGripState& tireGripState);
|
||||
|
||||
/**
|
||||
\brief When a tire has been at a very low speed for a threshold time without application of drive torque, a
|
||||
secondary tire model is applied to bring the tire to rest using velocity constraints that asymptotically approach zero speed
|
||||
along the tire's lateral and longitudinal directions. This secondary tire model is referred to as the sticky tire model and the
|
||||
tire is considered to be in the sticky tire state when the speed and time conditions are satisfied. The purpose of
|
||||
PxVehicleTireStickyStateUpdate is to compute the target speeds of the sticky state and to record whether sticky state is
|
||||
active or not.
|
||||
\param[in] axleDescription is the axles of the vehicle and the wheels on each axle.
|
||||
\param[in] wheelParams describes the radius of the wheel
|
||||
\param[in] tireStickyParams describe the threshold speeds and times for the lateral and longitudinal sticky states.
|
||||
\param[in] actuationStates describes whether each wheel experiences a drive torque.
|
||||
\param[in] tireGripState is the load and friction experienced by the tire.
|
||||
\param[in] tireSpeedState is the component of rigid body velocity at the tire contact point projected along the
|
||||
tire's longitudinal and lateral axes.
|
||||
\param[in] wheelRigidBody1dState is the wheel rotation speed.
|
||||
\param[in] dt is the simulation time that has lapsed since the last call to PxVehicleTireStickyStateUpdate
|
||||
\param[out] tireStickyState is a description of the sticky state of the tire in the longitudinal and lateral directions.
|
||||
\note The velocity constraints are maintained through integration with the PhysX scene using the function
|
||||
PxVehiclePhysXConstraintStatesUpdate. Alternative implementations independent of PhysX are possible.
|
||||
\see PxVehiclePhysXConstraintStatesUpdate
|
||||
\see PxVehicleTireSlipsAccountingForStickyStatesUpdate
|
||||
*/
|
||||
void PxVehicleTireStickyStateUpdate
|
||||
(const PxVehicleAxleDescription& axleDescription, const PxVehicleWheelParams& wheelParams,
|
||||
const PxVehicleTireStickyParams& tireStickyParams,
|
||||
const PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates,
|
||||
const PxVehicleTireGripState& tireGripState, const PxVehicleTireSpeedState& tireSpeedState, const PxVehicleWheelRigidBody1dState& wheelRigidBody1dState,
|
||||
const PxReal dt,
|
||||
PxVehicleTireStickyState& tireStickyState);
|
||||
|
||||
/**
|
||||
\brief Set the tire longitudinal and lateral slip values to 0.0 in the event that the tire has entred tire sticky state. This is
|
||||
necessary to avoid both tire models being simultaneously active and interfering with each other.
|
||||
\param[in] tireStickyState is a description of the sticky state of the tire in the longitudinal and lateral directions.
|
||||
\param[out] tireSlipState is the updated lateral and longudinal slip with either set to 0.0 in the event that the correspoinding
|
||||
sticky state is active.
|
||||
\note This function should not be invoked if there is no subsequent component to implement the sticky tire model.
|
||||
*/
|
||||
void PxVehicleTireSlipsAccountingForStickyStatesUpdate
|
||||
(const PxVehicleTireStickyState& tireStickyState,
|
||||
PxVehicleTireSlipState& tireSlipState);
|
||||
|
||||
/**
|
||||
\brief Compute the longitudinal and lateral forces in the world frame that develop on the tire as a consequence of
|
||||
the tire's slip angles, friction and load.
|
||||
\param[in] wheelParams describes the radius and half-width of the wheel.
|
||||
\param[in] suspensionParams describes the frame of the suspension and wheel.
|
||||
\param[in] tireForceParams describes the conversion of slip angle, friction and load to a force along the longitudinal
|
||||
and lateral directions of the tire.
|
||||
\param[in] complianceState is a description of the camber and toe angle that arise from suspension compliance.
|
||||
\param[out] tireGripState is the load and friction experienced by the tire.
|
||||
\param[in] tireDirectionState is the tire's longitudinal and lateral directions in the ground plane.
|
||||
\param[in] tireSlipState is the longitudinal and lateral slip angles.
|
||||
\param[in] tireCamberAngleState is the camber angle of the tire expressed in radians.
|
||||
\param[in] rigidBodyState describes the current pose of the vehicle's rigid body in the world frame.
|
||||
\param[out] tireForce is the computed tire forces in the world frame.
|
||||
*/
|
||||
void PxVehicleTireForcesUpdate
|
||||
(const PxVehicleWheelParams& wheelParams, const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxVehicleTireForceParams& tireForceParams,
|
||||
const PxVehicleSuspensionComplianceState& complianceState,
|
||||
const PxVehicleTireGripState& tireGripState, const PxVehicleTireDirectionState& tireDirectionState,
|
||||
const PxVehicleTireSlipState& tireSlipState, const PxVehicleTireCamberAngleState& tireCamberAngleState,
|
||||
const PxVehicleRigidBodyState& rigidBodyState,
|
||||
PxVehicleTireForce& tireForce);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
69
engine/third_party/physx/include/vehicle2/tire/PxVehicleTireHelpers.h
vendored
Normal file
69
engine/third_party/physx/include/vehicle2/tire/PxVehicleTireHelpers.h
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "vehicle2/wheel/PxVehicleWheelStates.h"
|
||||
#include "PxVehicleTireStates.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Compute the intention to accelerate by inspecting the actuation states of the wheels of a powered vehicle.
|
||||
\param[in] poweredVehicleAxleDesc describes the axles and wheels of a powered vehicle in a jointed ensemble of vehicles.
|
||||
\param[in] poweredVehicleActuationStates describes the drive state of each wheel of the powered vehicle.
|
||||
\see PxVehicleTireStickyStateReset
|
||||
*/
|
||||
bool PxVehicleAccelerationIntentCompute
|
||||
(const PxVehicleAxleDescription& poweredVehicleAxleDesc, const PxVehicleArrayData<const PxVehicleWheelActuationState>& poweredVehicleActuationStates);
|
||||
|
||||
/**
|
||||
\brief Reset the sticky tire states of an unpowered vehicle if it is in a jointed ensemble of vehicles with at least one powered vehicle.
|
||||
\param[in] poweredVehicleIntentionToAccelerate describes the state of the powered vehicle in an ensemble of jointed vehicles.
|
||||
\param[in] unpoweredVehicleAxleDesc describes the axles and wheels of an unpowered vehicle towed by a powered vehicle.
|
||||
\param[out] unpoweredVehicleStickyState is the sticky state of the wheels of an unpowered vehicle towed by a powered vehicle.
|
||||
\note If any wheel on the powered vehicle is to receive a drive torque, the sticky tire states of the towed vehicle will be reset to the deactivated state.
|
||||
\note poweredVehicleIntentionToAccelerate may be computed using PxVehicleAccelerationIntentCompute().
|
||||
\see PxVehicleAccelerationIntentCompute
|
||||
*/
|
||||
void PxVehicleTireStickyStateReset
|
||||
(const bool poweredVehicleIntentionToAccelerate,
|
||||
const PxVehicleAxleDescription& unpoweredVehicleAxleDesc,
|
||||
PxVehicleArrayData<PxVehicleTireStickyState>& unpoweredVehicleStickyState);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
162
engine/third_party/physx/include/vehicle2/tire/PxVehicleTireParams.h
vendored
Normal file
162
engine/third_party/physx/include/vehicle2/tire/PxVehicleTireParams.h
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxFoundation.h"
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
|
||||
#include "PxVehicleTireStates.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleTireForceParams
|
||||
{
|
||||
/**
|
||||
\brief Tire lateral stiffness is a graph of tire load that has linear behavior near zero load and
|
||||
flattens at large loads. latStiffX describes the minimum normalized load (load/restLoad) that gives a
|
||||
flat lateral stiffness response to load.
|
||||
\note A value of 0.0 indicates that the tire lateral stiffness is independent of load and will adopt
|
||||
the value #latStiffY for all values of tire load.
|
||||
*/
|
||||
PxReal latStiffX;
|
||||
|
||||
/**
|
||||
\brief Tire lateral stiffness is a graph of tire load that has linear behavior near zero load and
|
||||
flattens at large loads. latStiffY describes the maximum possible value of lateral stiffness that occurs
|
||||
when (load/restLoad) >= #latStiffX.
|
||||
|
||||
<b>Unit:</b> force per lateral slip = mass * length / (time^2)
|
||||
*/
|
||||
PxReal latStiffY;
|
||||
|
||||
/**
|
||||
\brief Tire Longitudinal stiffness
|
||||
\note Longitudinal force can be approximated as longStiff*longitudinalSlip.
|
||||
|
||||
<b>Unit:</b> force per longitudinal slip = mass * length / (time^2)
|
||||
*/
|
||||
PxReal longStiff;
|
||||
|
||||
/**
|
||||
\brief Tire camber stiffness
|
||||
\note Camber force can be approximated as camberStiff*camberAngle.
|
||||
|
||||
<b>Unit:</b> force per radian = mass * length / (time^2)
|
||||
*/
|
||||
PxReal camberStiff;
|
||||
|
||||
/**
|
||||
\brief Graph of friction vs longitudinal slip with 3 points.
|
||||
\note frictionVsSlip[0][0] is always zero.
|
||||
\note frictionVsSlip[0][1] is the friction available at zero longitudinal slip.
|
||||
\note frictionVsSlip[1][0] is the value of longitudinal slip with maximum friction.
|
||||
\note frictionVsSlip[1][1] is the maximum friction.
|
||||
\note frictionVsSlip[2][0] is the end point of the graph.
|
||||
\note frictionVsSlip[2][1] is the value of friction for slips greater than frictionVsSlip[2][0].
|
||||
\note The friction value is computed from the friction vs longitudinal slip graph using linear interpolation.
|
||||
\note The friction value computed from the friction vs longitudinal slip graph is used to scale the friction
|
||||
value of the road geometry.
|
||||
\note frictionVsSlip[2][0] > frictionVsSlip[1][0] > frictionVsSlip[0][0]
|
||||
\note frictionVsSlip[1][1] is typically greater than frictionVsSlip[0][1]
|
||||
\note frictionVsSlip[2][1] is typically smaller than frictionVsSlip[1][1]
|
||||
\note longitudinal slips > frictionVsSlip[2][0] use friction multiplier frictionVsSlip[2][1]
|
||||
*/
|
||||
PxReal frictionVsSlip[3][2]; //3 (x,y) points
|
||||
|
||||
/**
|
||||
\brief The rest load is the load that develops on the tire when the vehicle is at rest on a flat plane.
|
||||
\note The rest load is approximately the product of gravitational acceleration and (sprungMass + wheelMass).
|
||||
|
||||
<b>Unit:</b> force = mass * length / (time^2)
|
||||
*/
|
||||
PxReal restLoad;
|
||||
|
||||
/**
|
||||
\brief Tire load variation can be strongly dependent on the time-step so it is a good idea to filter it
|
||||
to give less jerky handling behavior.
|
||||
\note Tire load filtering is implemented by linear interpolating a graph containing just two points.
|
||||
The x-axis of the graph is normalized tire load, while the y-axis is the filtered normalized tire load that is
|
||||
to be applied during the tire force calculation.
|
||||
\note The normalized load is the force acting downwards on the tire divided by restLoad.
|
||||
\note The minimum possible normalized load is zero.
|
||||
\note There are two points on the graph: (minNormalisedLoad, minNormalisedFilteredLoad) and (maxNormalisedLoad, maxFilteredNormalisedLoad).
|
||||
\note Normalized loads less than minNormalisedLoad have filtered normalized load = minNormalisedFilteredLoad.
|
||||
\note Normalized loads greater than maxNormalisedLoad have filtered normalized load = maxFilteredNormalisedLoad.
|
||||
\note Normalized loads in-between are linearly interpolated between minNormalisedFilteredLoad and maxFilteredNormalisedLoad.
|
||||
\note The tire load applied as input to the tire force computation is the filtered normalized load multiplied by the rest load.
|
||||
\note loadFilter[0][0] is minNormalisedLoad
|
||||
\note loadFilter[0][1] is minFilteredNormalisedLoad
|
||||
\note loadFilter[1][0] is maxNormalisedLoad
|
||||
\note loadFilter[1][1] is maxFilteredNormalisedLoad
|
||||
*/
|
||||
PxReal loadFilter[2][2]; //2 (x,y) points
|
||||
|
||||
PX_FORCE_INLINE PxVehicleTireForceParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PxVehicleTireForceParams r = *this;
|
||||
const PxReal scale = trgScale.scale / srcScale.scale;
|
||||
r.latStiffY *= scale;
|
||||
r.longStiff *= scale;
|
||||
r.camberStiff *= scale;
|
||||
r.restLoad *= scale;
|
||||
return r;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(latStiffX >= 0, "PxVehicleTireForceParams.latStiffX must be greater than or equal to zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(latStiffY > 0, "PxVehicleTireForceParams.latStiffY must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(longStiff > 0, "PxVehicleTireForceParams.longStiff must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(camberStiff >= 0, "PxVehicleTireForceParams.camberStiff must be greater than or equal zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(restLoad > 0, "PxVehicleTireForceParams.restLoad must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(loadFilter[1][0] >= loadFilter[0][0], "PxVehicleTireForceParams.loadFilter[1][0] must be greater than or equal to PxVehicleTireForceParams.loadFilter[0][0]", false);
|
||||
PX_CHECK_AND_RETURN_VAL(loadFilter[1][1] > 0, "PxVehicleTireLoadFilterData.loadFilter[1][1] must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(0.0f == loadFilter[0][0], "PxVehicleTireLoadFilterData.loadFilter[0][0] must be equal to zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(frictionVsSlip[0][0] >= 0.0f && frictionVsSlip[0][1] >= 0.0f, "Illegal values for frictionVsSlip[0]", false);
|
||||
PX_CHECK_AND_RETURN_VAL(frictionVsSlip[1][0] >= 0.0f && frictionVsSlip[1][1] >= 0.0f, "Illegal values for frictionVsSlip[1]", false);
|
||||
PX_CHECK_AND_RETURN_VAL(frictionVsSlip[2][0] >= 0.0f && frictionVsSlip[2][1] >= 0.0f, "Illegal values for frictionVsSlip[2]", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
177
engine/third_party/physx/include/vehicle2/tire/PxVehicleTireStates.h
vendored
Normal file
177
engine/third_party/physx/include/vehicle2/tire/PxVehicleTireStates.h
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief PxVehicleTireDirectionState stores the world frame lateral and longtidinal axes of the tire after
|
||||
projecting the wheel pose in the world frame onto the road geometry plane (also in the world frame).
|
||||
*/
|
||||
struct PxVehicleTireDirectionState
|
||||
{
|
||||
PxVec3 directions[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS];
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleTireDirectionState));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\brief PxVehicleTireSpeedState stores the components of the instantaneous velocity of the rigid body at the tire contact point projected
|
||||
along the lateral and longitudinal axes of the tire.
|
||||
\see PxVehicleTireDirectionState
|
||||
*/
|
||||
struct PxVehicleTireSpeedState
|
||||
{
|
||||
PxReal speedStates[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS];
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleTireSpeedState));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief The lateral and longitudinal tire slips.
|
||||
\see PxVehicleTireSpeedState
|
||||
*/
|
||||
struct PxVehicleTireSlipState
|
||||
{
|
||||
PxReal slips[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS];
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleTireSlipState));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief The load and friction experienced by a tire.
|
||||
*/
|
||||
struct PxVehicleTireGripState
|
||||
{
|
||||
/**
|
||||
\brief The tire load
|
||||
|
||||
<b>Unit:</b> force = mass * length / (time^2)
|
||||
*/
|
||||
PxReal load;
|
||||
|
||||
/**
|
||||
\brief The tire friction is the product of the road geometry friction and a friction response multiplier.
|
||||
*/
|
||||
PxReal friction;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleTireGripState));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Camber angle of the tire relative to the ground plane.
|
||||
*/
|
||||
struct PxVehicleTireCamberAngleState
|
||||
{
|
||||
PxReal camberAngle;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleTireCamberAngleState));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Prolonged low speeds in the lateral and longitudinal directions may be handled with "sticky" velocity constraints that activate after
|
||||
a speed below a threshold has been recorded for a threshold time.
|
||||
\see PxVehicleTireStickyParams
|
||||
\see PxVehicleTireSpeedState
|
||||
*/
|
||||
struct PxVehicleTireStickyState
|
||||
{
|
||||
PxReal lowSpeedTime[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS];
|
||||
bool activeStatus[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS];
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleTireStickyState));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\brief The longitudinal/lateral forces/torques that develop on the tire.
|
||||
*/
|
||||
struct PxVehicleTireForce
|
||||
{
|
||||
/*
|
||||
\brief The tire forces that develop along the tire's longitudinal and lateral directions. Specified in the world frame.
|
||||
*/
|
||||
PxVec3 forces[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS];
|
||||
|
||||
/*
|
||||
\brief The tire torques that develop around the tire's longitudinal and lateral directions. Specified in the world frame.
|
||||
*/
|
||||
PxVec3 torques[PxVehicleTireDirectionModes::eMAX_NB_PLANAR_DIRECTIONS];
|
||||
|
||||
/**
|
||||
\brief The aligning moment may be propagated to a torque-driven steering controller.
|
||||
*/
|
||||
PxReal aligningMoment;
|
||||
|
||||
/**
|
||||
\brief The torque to apply to the wheel's 1d rigid body.
|
||||
*/
|
||||
PxReal wheelTorque;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleTireForce));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
116
engine/third_party/physx/include/vehicle2/wheel/PxVehicleWheelComponents.h
vendored
Normal file
116
engine/third_party/physx/include/vehicle2/wheel/PxVehicleWheelComponents.h
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
#include "vehicle2/PxVehicleComponent.h"
|
||||
|
||||
#include "vehicle2/commands/PxVehicleCommandHelpers.h"
|
||||
#include "vehicle2/tire/PxVehicleTireStates.h"
|
||||
|
||||
#include "PxVehicleWheelFunctions.h"
|
||||
#include "PxVehicleWheelHelpers.h"
|
||||
|
||||
#include "common/PxProfileZone.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxVehicleWheelComponent : public PxVehicleComponent
|
||||
{
|
||||
public:
|
||||
|
||||
PxVehicleWheelComponent() : PxVehicleComponent() {}
|
||||
virtual ~PxVehicleWheelComponent() {}
|
||||
|
||||
virtual void getDataForWheelComponent(
|
||||
const PxVehicleAxleDescription*& axleDescription,
|
||||
PxVehicleArrayData<const PxReal>& steerResponseStates,
|
||||
PxVehicleArrayData<const PxVehicleWheelParams>& wheelParams,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams>& suspensionParams,
|
||||
PxVehicleArrayData<const PxVehicleWheelActuationState>& actuationStates,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionState>& suspensionStates,
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceState>& suspensionComplianceStates,
|
||||
PxVehicleArrayData<const PxVehicleTireSpeedState>& tireSpeedStates,
|
||||
PxVehicleArrayData<PxVehicleWheelRigidBody1dState>& wheelRigidBody1dStates,
|
||||
PxVehicleArrayData<PxVehicleWheelLocalPose>& wheelLocalPoses) = 0;
|
||||
|
||||
virtual bool update(const PxReal dt, const PxVehicleSimulationContext& context)
|
||||
{
|
||||
PX_PROFILE_ZONE("PxVehicleWheelComponent::update", 0);
|
||||
|
||||
const PxVehicleAxleDescription* axleDescription;
|
||||
PxVehicleArrayData<const PxReal> steerResponseStates;
|
||||
PxVehicleArrayData<const PxVehicleWheelParams> wheelParams;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionParams> suspensionParams;
|
||||
PxVehicleArrayData<const PxVehicleWheelActuationState> actuationStates;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionState> suspensionStates;
|
||||
PxVehicleArrayData<const PxVehicleSuspensionComplianceState> suspensionComplianceStates;
|
||||
PxVehicleArrayData<const PxVehicleTireSpeedState> tireSpeedStates;
|
||||
PxVehicleArrayData<PxVehicleWheelRigidBody1dState> wheelRigidBody1dStates;
|
||||
PxVehicleArrayData<PxVehicleWheelLocalPose> wheelLocalPoses;
|
||||
|
||||
getDataForWheelComponent(axleDescription, steerResponseStates,
|
||||
wheelParams, suspensionParams, actuationStates, suspensionStates,
|
||||
suspensionComplianceStates, tireSpeedStates, wheelRigidBody1dStates,
|
||||
wheelLocalPoses);
|
||||
|
||||
for (PxU32 i = 0; i < axleDescription->nbWheels; i++)
|
||||
{
|
||||
const PxU32 wheelId = axleDescription->wheelIdsInAxleOrder[i];
|
||||
|
||||
PxVehicleWheelRotationAngleUpdate(
|
||||
wheelParams[wheelId],
|
||||
actuationStates[wheelId], suspensionStates[wheelId],
|
||||
tireSpeedStates[wheelId],
|
||||
context.thresholdForwardSpeedForWheelAngleIntegration, dt,
|
||||
wheelRigidBody1dStates[wheelId]);
|
||||
|
||||
wheelLocalPoses[wheelId].localPose = PxVehicleComputeWheelLocalPose(context.frame,
|
||||
suspensionParams[wheelId],
|
||||
suspensionStates[wheelId],
|
||||
suspensionComplianceStates[wheelId],
|
||||
steerResponseStates[wheelId],
|
||||
wheelRigidBody1dStates[wheelId]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
77
engine/third_party/physx/include/vehicle2/wheel/PxVehicleWheelFunctions.h
vendored
Normal file
77
engine/third_party/physx/include/vehicle2/wheel/PxVehicleWheelFunctions.h
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleWheelParams;
|
||||
struct PxVehicleWheelActuationState;
|
||||
struct PxVehicleSuspensionState;
|
||||
struct PxVehicleTireSpeedState;
|
||||
struct PxVehicleScale;
|
||||
struct PxVehicleWheelRigidBody1dState;
|
||||
|
||||
/**
|
||||
\brief Forward integrate the rotation angle of a wheel
|
||||
\note The rotation angle of the wheel plays no role in simulation but is important to compute the pose of the wheel for rendering.
|
||||
\param[in] wheelParams describes the radius and half-width of the wheel
|
||||
\param[in] actuationState describes whether the wheel has drive or brake torque applied to it.
|
||||
\param[in] suspensionState describes whether the wheel touches the ground.
|
||||
\param[in] tireSpeedState describes the components of rigid body velocity at the ground contact point along the tire's lateral and longitudinal directions.
|
||||
\param[in] thresholdForwardSpeedForWheelAngleIntegration Forward wheel speed below which the wheel rotation speed gets blended with the rolling
|
||||
speed (based on the forward wheel speed) which is then used to integrate the wheel rotation angle. At low forward wheel speed, the wheel
|
||||
rotation speed can get unstable (depending on the tire model used) and, for example, oscillate. If brake or throttle is applied, there
|
||||
will be no blending.
|
||||
\param[in] dt is the simulation time that has lapsed since the last call to PxVehicleWheelRotationAngleUpdate
|
||||
\param[in,out] wheelRigidBody1dState describes the current angular speed and angle of the wheel.
|
||||
\note At low speeds and large timesteps, wheel rotation speed can become noisy due to singularities in the tire slip computations.
|
||||
At low speeds, therefore, the wheel speed used for integrating the angle is a blend of current angular speed and rolling angular speed if the
|
||||
wheel experiences neither brake nor drive torque and can be placed on the ground. The blended rotation speed gets stored in
|
||||
PxVehicleWheelRigidBody1dState::correctedRotationSpeed.
|
||||
*/
|
||||
void PxVehicleWheelRotationAngleUpdate
|
||||
(const PxVehicleWheelParams& wheelParams,
|
||||
const PxVehicleWheelActuationState& actuationState, const PxVehicleSuspensionState& suspensionState, const PxVehicleTireSpeedState& tireSpeedState,
|
||||
const PxReal thresholdForwardSpeedForWheelAngleIntegration, const PxReal dt,
|
||||
PxVehicleWheelRigidBody1dState& wheelRigidBody1dState);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
|
||||
217
engine/third_party/physx/include/vehicle2/wheel/PxVehicleWheelHelpers.h
vendored
Normal file
217
engine/third_party/physx/include/vehicle2/wheel/PxVehicleWheelHelpers.h
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "vehicle2/PxVehicleFunctions.h"
|
||||
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionParams.h"
|
||||
#include "vehicle2/suspension/PxVehicleSuspensionStates.h"
|
||||
|
||||
#include "PxVehicleWheelParams.h"
|
||||
#include "PxVehicleWheelStates.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Compute the quaternion of a wheel in the rigid body frame.
|
||||
\param[in] frame describes the longitudinal and lateral axes of the vehicle.
|
||||
\param[in] suspensionParams describes the suspension and wheel frames.
|
||||
\param[in] camberAngle is the camber angle in radian sinduced by suspension compliance.
|
||||
\param[in] toeAngle is the toe angle in radians induced by suspension compliance.
|
||||
\param[in] steerAngle is the steer angle in radians applied to the wheel.
|
||||
\param[in] rotationAngle is the angle around the wheel's lateral axis.
|
||||
\return The quaterion of the wheel in the rigid body frame.
|
||||
\see PxVehicleComputeWheelOrientation
|
||||
*/
|
||||
PX_FORCE_INLINE PxQuat PxVehicleComputeWheelLocalOrientation
|
||||
(const PxVehicleFrame& frame,
|
||||
const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxReal camberAngle, const PxReal toeAngle, const PxReal steerAngle,
|
||||
const PxReal rotationAngle)
|
||||
{
|
||||
const PxQuat wheelLocalOrientation =
|
||||
(suspensionParams.suspensionAttachment.q * PxVehicleComputeRotation(frame, camberAngle, 0.0f, steerAngle + toeAngle))*
|
||||
(suspensionParams.wheelAttachment.q * PxVehicleComputeRotation(frame, 0.0f, rotationAngle, 0.0f));
|
||||
return wheelLocalOrientation;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the quaternion of a wheel in the world frame.
|
||||
\param[in] frame describes the longitudinal and lateral axes of the vehicle.
|
||||
\param[in] suspensionParams describes the suspension and wheel frames.
|
||||
\param[in] camberAngle is the camber angle in radian induced by suspension compliance.
|
||||
\param[in] toeAngle is the toe angle in radians induced by suspension compliance.
|
||||
\param[in] steerAngle is the steer angle in radians applied to the wheel.
|
||||
\param[in] rigidBodyOrientation is the quaterion of the rigid body in the world frame.
|
||||
\param[in] rotationAngle is the angle around the wheel's lateral axis.
|
||||
\return The quaterion of the wheel in the world frame.
|
||||
\see PxVehicleComputeWheelLocalOrientation
|
||||
*/
|
||||
PX_FORCE_INLINE PxQuat PxVehicleComputeWheelOrientation
|
||||
(const PxVehicleFrame& frame,
|
||||
const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxReal camberAngle, const PxReal toeAngle, const PxReal steerAngle,
|
||||
const PxQuat& rigidBodyOrientation, const PxReal rotationAngle)
|
||||
{
|
||||
const PxQuat wheelOrientation = rigidBodyOrientation * PxVehicleComputeWheelLocalOrientation(frame, suspensionParams,
|
||||
camberAngle, toeAngle, steerAngle, rotationAngle);
|
||||
return wheelOrientation;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the pose of the wheel in the rigid body frame.
|
||||
\param[in] frame describes the longitudinal and lateral axes of the vehicle.
|
||||
\param[in] suspensionParams describes the suspension and wheel frames.
|
||||
\param[in] suspensionState is the compression state of the suspenson.
|
||||
\param[in] camberAngle is the camber angle in radian induced by suspension compliance.
|
||||
\param[in] toeAngle is the toe angle in radians induced by suspension compliance.
|
||||
\param[in] steerAngle is the steer angle in radians applied to the wheel.
|
||||
\param[in] rotationAngle is the angle around the wheel's lateral axis.
|
||||
\return The pose of the wheel in the rigid body frame.
|
||||
*/
|
||||
PX_FORCE_INLINE PxTransform PxVehicleComputeWheelLocalPose
|
||||
(const PxVehicleFrame& frame,
|
||||
const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxVehicleSuspensionState& suspensionState,
|
||||
const PxReal camberAngle, const PxReal toeAngle, const PxReal steerAngle,
|
||||
const PxReal rotationAngle)
|
||||
{
|
||||
//Full equation:
|
||||
//PxTransform(suspAttachment.p + suspParams.suspensionTravelDir*suspDist, suspAttachment.q) *
|
||||
//PxTransform(PxVec3(0), PxQuat(camber, 0, steer+toe)) *
|
||||
//wheelAttachment *
|
||||
//PxTransform(PxVec3(0), PxQuat(0, rotation, 0))
|
||||
//Reduces to:
|
||||
//PxTransform(suspAttachment.p + suspParams.suspensionTravelDir*suspDist, suspAttachment.q * PxQuat(camber, 0, steer+toe)) *
|
||||
//PxTranfsorm(wheelAttachment.p, wheelAttachment.q * PxQuat(0, rotation, 0))
|
||||
const PxF32 suspDist = (suspensionState.jounce != PX_VEHICLE_UNSPECIFIED_JOUNCE) ? (suspensionParams.suspensionTravelDist - suspensionState.jounce) : 0.0f;
|
||||
const PxTransform wheelLocalPose =
|
||||
PxTransform(
|
||||
suspensionParams.suspensionAttachment.p + suspensionParams.suspensionTravelDir*suspDist,
|
||||
suspensionParams.suspensionAttachment.q*PxVehicleComputeRotation(frame, camberAngle, 0.0f, steerAngle + toeAngle))*
|
||||
PxTransform(
|
||||
suspensionParams.wheelAttachment.p,
|
||||
suspensionParams.wheelAttachment.q*PxVehicleComputeRotation(frame, 0.0f, rotationAngle, 0.0f));
|
||||
return wheelLocalPose;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Compute the pose of the wheel in the rigid body frame.
|
||||
\param[in] frame describes the longitudinal and lateral axes of the vehicle.
|
||||
\param[in] suspensionParams describes the suspension and wheel frames.
|
||||
\param[in] suspensionState is the compression state of the suspenson.
|
||||
\param[in] suspensionComplianceState is the camber and toe angles induced by suspension compliance.
|
||||
\param[in] steerAngle is the steer angle in radians applied to the wheel.
|
||||
\param[in] wheelState is angle around the wheel's lateral axis.
|
||||
\return The pose of the wheel in the rigid body frame.
|
||||
*/
|
||||
PX_FORCE_INLINE PxTransform PxVehicleComputeWheelLocalPose
|
||||
(const PxVehicleFrame& frame,
|
||||
const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxVehicleSuspensionState& suspensionState, const PxVehicleSuspensionComplianceState& suspensionComplianceState,
|
||||
const PxReal steerAngle,
|
||||
const PxVehicleWheelRigidBody1dState& wheelState)
|
||||
{
|
||||
return PxVehicleComputeWheelLocalPose(frame, suspensionParams, suspensionState,
|
||||
suspensionComplianceState.camber, suspensionComplianceState.toe, steerAngle,
|
||||
wheelState.rotationAngle);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the pose of the wheel in the world frame.
|
||||
\param[in] frame describes the longitudinal and lateral axes of the vehicle.
|
||||
\param[in] suspensionParams describes the suspension and wheel frames.
|
||||
\param[in] suspensionState is the compression state of the suspenson.
|
||||
\param[in] camberAngle is the camber angle in radian induced by suspension compliance.
|
||||
\param[in] toeAngle is the toe angle in radians induced by suspension compliance.
|
||||
\param[in] steerAngle is the steer angle in radians applied to the wheel.
|
||||
\param[in] rigidBodyPose is the pose of the rigid body in the world frame.
|
||||
\param[in] rotationAngle is the angle around the wheel's lateral axis.
|
||||
\return The pose of the wheel in the world frame.
|
||||
*/
|
||||
PX_FORCE_INLINE PxTransform PxVehicleComputeWheelPose
|
||||
(const PxVehicleFrame& frame,
|
||||
const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxVehicleSuspensionState& suspensionState,
|
||||
const PxReal camberAngle, const PxReal toeAngle, const PxReal steerAngle,
|
||||
const PxTransform& rigidBodyPose, const PxReal rotationAngle)
|
||||
{
|
||||
const PxTransform wheelPose = rigidBodyPose * PxVehicleComputeWheelLocalPose(frame, suspensionParams, suspensionState,
|
||||
camberAngle, toeAngle, steerAngle, rotationAngle);
|
||||
return wheelPose;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Compute the pose of the wheel in the world frame.
|
||||
\param[in] frame describes the longitudinal and lateral axes of the vehicle.
|
||||
\param[in] suspensionParams describes the suspension and wheel frames.
|
||||
\param[in] suspensionState is the compression state of the suspenson.
|
||||
\param[in] suspensionComplianceState is the camber and toe angles induced by suspension compliance.
|
||||
\param[in] steerAngle is the steer angle in radians applied to the wheel.
|
||||
\param[in] rigidBodyPose is the pose of the rigid body in the world frame.
|
||||
\param[in] wheelState is angle around the wheel's lateral axis.
|
||||
\return The pose of the wheel in the world frame.
|
||||
*/
|
||||
|
||||
PX_FORCE_INLINE PxTransform PxVehicleComputeWheelPose
|
||||
(const PxVehicleFrame& frame,
|
||||
const PxVehicleSuspensionParams& suspensionParams,
|
||||
const PxVehicleSuspensionState& suspensionState, const PxVehicleSuspensionComplianceState& suspensionComplianceState, const PxReal steerAngle,
|
||||
const PxTransform& rigidBodyPose, const PxVehicleWheelRigidBody1dState& wheelState)
|
||||
{
|
||||
return PxVehicleComputeWheelPose(frame, suspensionParams, suspensionState,
|
||||
suspensionComplianceState.camber, suspensionComplianceState.toe, steerAngle,
|
||||
rigidBodyPose, wheelState.rotationAngle);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Check if the suspension could place the wheel on the ground or not.
|
||||
|
||||
\param[in] suspState The state of the suspension to check.
|
||||
\return True if the wheel connects to the ground, else false.
|
||||
|
||||
\see PxVehicleSuspensionState
|
||||
*/
|
||||
PX_FORCE_INLINE bool PxVehicleIsWheelOnGround(const PxVehicleSuspensionState& suspState)
|
||||
{
|
||||
return (suspState.separation <= 0.0f);
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
115
engine/third_party/physx/include/vehicle2/wheel/PxVehicleWheelParams.h
vendored
Normal file
115
engine/third_party/physx/include/vehicle2/wheel/PxVehicleWheelParams.h
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxFoundation.h"
|
||||
|
||||
#include "vehicle2/PxVehicleParams.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
struct PxVehicleWheelParams
|
||||
{
|
||||
/**
|
||||
\brief Radius of unit that includes metal wheel plus rubber tire.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> length
|
||||
*/
|
||||
PxReal radius;
|
||||
|
||||
/**
|
||||
\brief Half-width of unit that includes wheel plus tire.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> length
|
||||
*/
|
||||
PxReal halfWidth;
|
||||
|
||||
/**
|
||||
\brief Mass of unit that includes wheel plus tire.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> mass
|
||||
*/
|
||||
PxReal mass;
|
||||
|
||||
/**
|
||||
\brief Moment of inertia of unit that includes wheel plus tire about the rolling axis.
|
||||
|
||||
<b>Range:</b> (0, inf)<br>
|
||||
<b>Unit:</b> mass * (length^2)
|
||||
*/
|
||||
PxReal moi;
|
||||
|
||||
/**
|
||||
\brief Damping rate applied to wheel.
|
||||
|
||||
<b>Range:</b> [0, inf)<br>
|
||||
<b>Unit:</b> torque * time = mass * (length^2) / time
|
||||
*/
|
||||
PxReal dampingRate;
|
||||
|
||||
PX_FORCE_INLINE PxVehicleWheelParams transformAndScale(
|
||||
const PxVehicleFrame& srcFrame, const PxVehicleFrame& trgFrame, const PxVehicleScale& srcScale, const PxVehicleScale& trgScale) const
|
||||
{
|
||||
PX_UNUSED(srcFrame);
|
||||
PX_UNUSED(trgFrame);
|
||||
PxVehicleWheelParams r = *this;
|
||||
const PxReal scale = trgScale.scale/srcScale.scale;
|
||||
r.radius *= scale;
|
||||
r.halfWidth *= scale;
|
||||
r.moi *= (scale*scale);
|
||||
r.dampingRate *= (scale*scale);
|
||||
return r;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool isValid() const
|
||||
{
|
||||
PX_CHECK_AND_RETURN_VAL(radius > 0.0f, "PxVehicleWheelParams.radius must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(halfWidth > 0.0f, "PxVehicleWheelParams.halfWidth must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(mass > 0.0f, "PxVehicleWheelParams.mass must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(moi > 0.0f, "PxVehicleWheelParams.moi must be greater than zero", false);
|
||||
PX_CHECK_AND_RETURN_VAL(dampingRate >= 0.0f, "PxVehicleWheelParams.dampingRate must be greater than or equal to zero", false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
|
||||
104
engine/third_party/physx/include/vehicle2/wheel/PxVehicleWheelStates.h
vendored
Normal file
104
engine/third_party/physx/include/vehicle2/wheel/PxVehicleWheelStates.h
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
#include "foundation/PxMemory.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
namespace vehicle2
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief It is useful to know if a brake or drive torque is to be applied to a wheel.
|
||||
*/
|
||||
struct PxVehicleWheelActuationState
|
||||
{
|
||||
bool isBrakeApplied; //!< True if a brake torque is applied, false if not.
|
||||
bool isDriveApplied; //!< True if a drive torque is applied, false if not.
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleWheelActuationState));
|
||||
}
|
||||
};
|
||||
|
||||
struct PxVehicleWheelRigidBody1dState
|
||||
{
|
||||
/**
|
||||
\brief The rotation speed of the wheel around the lateral axis.
|
||||
|
||||
<b>Unit:</b> radians / time
|
||||
*/
|
||||
PxReal rotationSpeed;
|
||||
|
||||
/**
|
||||
\brief The corrected rotation speed of the wheel around the lateral axis in radians per second.
|
||||
|
||||
At low forward wheel speed, the wheel rotation speed can get unstable (depending on the tire
|
||||
model used) and, for example, oscillate. To integrate the wheel rotation angle, a (potentially)
|
||||
blended rotation speed is used which gets stored in #correctedRotationSpeed.
|
||||
|
||||
<b>Unit:</b> radians / time
|
||||
|
||||
\see PxVehicleSimulationContext::thresholdForwardSpeedForWheelAngleIntegration
|
||||
*/
|
||||
PxReal correctedRotationSpeed;
|
||||
|
||||
/**
|
||||
\brief The accumulated angle of the wheel around the lateral axis in radians in range (-2*Pi,2*Pi)
|
||||
*/
|
||||
PxReal rotationAngle;
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
PxMemZero(this, sizeof(PxVehicleWheelRigidBody1dState));
|
||||
}
|
||||
};
|
||||
|
||||
struct PxVehicleWheelLocalPose
|
||||
{
|
||||
PxTransform localPose; //!< The pose of the wheel in the rigid body frame.
|
||||
|
||||
PX_FORCE_INLINE void setToDefault()
|
||||
{
|
||||
localPose = PxTransform(PxIdentity);
|
||||
}
|
||||
};
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace vehicle2
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user