feat(physics): wire physx sdk into build
This commit is contained in:
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
|
||||
|
||||
Reference in New Issue
Block a user