Skip to content

Commit

Permalink
Update PhysX to 5.4.2 at 9950ad0d
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoub-belarbi authored and preist-nvidia committed Sep 18, 2024
1 parent 44667a2 commit 19542b6
Show file tree
Hide file tree
Showing 18 changed files with 263 additions and 186 deletions.
21 changes: 21 additions & 0 deletions physx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# v5.4.2-106.1

## Articulations

### Fixed

* A bug in the GPU pipeline where setting the maximum joint velocity to zero resulted in a crash.

### Changed

* In the CPU codepath, constraints involving the root link of a fixed-base articulation are now resolved simultaneously with constraints that couple pairs of dynamic rigid bodies and/or articulation links. As a consequence of this change, the CPU and GPU codepaths now resolve constraints and contacts involving the root link of an articulation in the same order. This historic inconsistency, which has now been resolved, may have caused a difference in behavior between CPU and GPU simulation.

## Rigid Body

### Fixed

* In cases where TGS was used with a non-zero number of velocity iterations on CPU, an incorrect timestep was used in part of the rigid-body and articulation solver pipeline.
* A bug in collision resolution where a sphere could fall through a flat triangle mesh when it landed precisely on a mesh vertex.
* Acceleration computation for rigid bodies was incorrect for both CPU and GPU APIs if velocities were updated by the user in-between simulation steps. This is fixed now. Affected API: PxRigidBody::getLinearAcceleration(), PxRigidBody::getAngularAcceleration(), PxDirectGPUAPI::getRigidDynamicData().
* The CPU-side computations of accelerations (controlled with eENABLE_BODY_ACCELERATIONS) have been disabled when eENABLE_DIRECT_GPU_API is enabled. Previously both the CPU and GPU computations happened, which was redundant.

# v5.4.1-106.0

## General
Expand Down
30 changes: 25 additions & 5 deletions physx/buildtools/steps/build_all_win_x86_64_vc16.bat
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
:: Setup VS2019 build environment
IF EXIST "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer" SET PATH=%PATH%;%ProgramFiles(x86)%\Microsoft Visual Studio\Installer
@echo off
SETLOCAL EnableDelayedExpansion

for /f "usebackq tokens=*" %%i in (`vswhere -version "[16.0,17.0)" -latest -property installationPath`) do (
SET "COMNTOOLS=%%i\Common7\Tools\"
:: Locate Visual Studio using vswhere
IF EXIST "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer" (
SET "VS_INSTALLER_DIR=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
echo VS_INSTALLER_DIR: "!VS_INSTALLER_DIR!"

:: Check if VS_INSTALLER_DIR is already in PATH
echo !PATH! | findstr /i /c:"!VS_INSTALLER_DIR!" >nul
if !errorlevel! neq 0 (
SET PATH=!PATH!;!VS_INSTALLER_DIR!
echo Updated PATH: !PATH!
) else (
echo VS_INSTALLER_DIR is already in PATH
)
)

@call "%COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsx86_amd64.bat"
:: Use vswhere to locate the latest Visual Studio installation
for /f "usebackq tokens=*" %%i in (`vswhere -version "[16.0,17.0)" -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
SET "VSINSTALLPATH=%%i"
echo VSINSTALLPATH: "!VSINSTALLPATH!"
)

:: Set COMNTOOLS to point to the correct path
SET "COMNTOOLS=!VSINSTALLPATH!\VC\Auxiliary\Build\vcvarsx86_amd64.bat"
echo COMNTOOLS: "!COMNTOOLS!"
@call "!COMNTOOLS!"

:: When run with no arguments we always perform a rebuild (clean & build)
@if [%1] == [] (
Expand Down
29 changes: 24 additions & 5 deletions physx/buildtools/steps/build_all_win_x86_64_vc17.bat
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
:: Setup VS2022 build environment
@echo off
SETLOCAL EnableDelayedExpansion

IF EXIST "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer" SET PATH=%PATH%;%ProgramFiles(x86)%\Microsoft Visual Studio\Installer
:: Locate Visual Studio using vswhere
IF EXIST "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer" (
SET "VS_INSTALLER_DIR=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
echo VS_INSTALLER_DIR: "!VS_INSTALLER_DIR!"

:: Check if VS_INSTALLER_DIR is already in PATH
echo !PATH! | findstr /i /c:"!VS_INSTALLER_DIR!" >nul
if !errorlevel! neq 0 (
SET PATH=!PATH!;!VS_INSTALLER_DIR!
echo Updated PATH: !PATH!
) else (
echo VS_INSTALLER_DIR is already in PATH
)
)

for /f "usebackq tokens=*" %%i in (`vswhere -version "[17.0,18.0)" -latest -property installationPath`) do (
SET "COMNTOOLS=%%i\Common7\Tools\"
:: Use vswhere to locate the latest Visual Studio installation
for /f "usebackq tokens=*" %%i in (`vswhere -version "[17.0,18.0)" -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
SET "VSINSTALLPATH=%%i"
echo VSINSTALLPATH: "!VSINSTALLPATH!"
)

@call "%COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsx86_amd64.bat"
:: Set COMNTOOLS to point to the correct path
SET "COMNTOOLS=!VSINSTALLPATH!\VC\Auxiliary\Build\vcvarsx86_amd64.bat"
echo COMNTOOLS: "!COMNTOOLS!"
@call "!COMNTOOLS!"

:: When run with no arguments we always perform a rebuild (clean & build)
@if [%1] == [] (
Expand Down
6 changes: 3 additions & 3 deletions physx/dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
</dependency>

<dependency name="PhysXGpu">
<package name="PhysXGpu" version="5.4.1.86cd1749-release-106.0-windows-public" platforms="vc15win64 vc16win64 vc17win64"/>
<package name="PhysXGpu" version="5.4.1.86cd1749-release-106.0-linux-x86_64-public" platforms="linux"/>
<package name="PhysXGpu" version="5.4.1.86cd1749-release-106.0-linux-aarch64-public" platforms="linux-aarch64"/>
<package name="PhysXGpu" version="5.4.2.e5f54faf-release-106.1-windows-public" platforms="vc15win64 vc16win64 vc17win64"/>
<package name="PhysXGpu" version="5.4.2.e5f54faf-release-106.1-linux-x86_64-public" platforms="linux"/>
<package name="PhysXGpu" version="5.4.2.e5f54faf-release-106.1-linux-aarch64-public" platforms="linux-aarch64"/>
</dependency>

<dependency name="opengllinux" tags="requiredForDistro">
Expand Down
2 changes: 1 addition & 1 deletion physx/include/extensions/PxSerialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
PX_BINARY_SERIAL_VERSION is used to version the PhysX binary data and meta data. The global unique identifier of the PhysX SDK needs to match
the one in the data and meta data, otherwise they are considered incompatible. A 32 character wide GUID can be generated with https://www.guidgenerator.com/ for example.
*/
#define PX_BINARY_SERIAL_VERSION "B57177A5EF424885A73E41854E472FC4"
#define PX_BINARY_SERIAL_VERSION "3B794FCE39C34CE58F6065FA172B0A36"


#if !PX_DOXYGEN
Expand Down
2 changes: 1 addition & 1 deletion physx/include/foundation/PxPhysicsVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ sometimes they are stored in a byte.

#define PX_PHYSICS_VERSION_MAJOR 5
#define PX_PHYSICS_VERSION_MINOR 4
#define PX_PHYSICS_VERSION_BUGFIX 1
#define PX_PHYSICS_VERSION_BUGFIX 2

/**
The constant PX_PHYSICS_VERSION is used when creating certain PhysX module objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,6 @@ namespace Dy

Cm::SpatialVector getMotionAcceleration(const PxU32 linkID, const bool isGpuSimEnabled) const;

void fillIndexType(const PxU32 linkId, PxU8& indexType);

PxReal getLinkMaxPenBias(const PxU32 linkID) const;

PxReal getCfm(const PxU32 linkID) const;
Expand Down
118 changes: 118 additions & 0 deletions physx/source/lowleveldynamics/shared/DyCpuGpuArticulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,124 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal computeDriveImpulse
return unclampedForce;
}

/**
\brief Apply limit constraints to an articulation joint dof.
1) Compute the delta impulse required to maintain limit constraints.
2) Individually accumulate the impulses that have been applied to maintain both the lower and upper limit.
3) Compute the updated joint speed after applying the delta impulse.
\param[in] dt is the timestep of the simulation
\param[in] recipDt has value 1/dt
\param[in] isVelIter is true if we are performing a velocity iteration, false if performing a position iteration.
\param[in] response is the deltaSpeed response of the joint dof to a unit impulse.
\param[in] recipResponse has value 1/response.
\param[in] erp is the Baumgarte multiplier used to resolve a fraction of the limit error.
\param[in] errorLow is the lower bound of the limit.
\param[in] errorHigh is the upper bound of the limit.
\param[in] jointPDelta is the change to the joint position that has accumulated over solver iterations.
\param[in,out] lowImpulse_ is the accumulated impulse that has been applied to maintain the limit's lower bound.
\param[in,out] highImpulse_ is the accumulated impulse that has applied to maintain the limit's upper bound.
\param[in,out] jointV_ is the joint speed before and after applying the limit impulses.
\return deltaImpulse required to enforce the upper and lower limits.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal computeLimitImpulse
(const PxReal dt, const PxReal recipDt, const bool isVelIter,
const PxReal response, const PxReal recipResponse, const PxReal erp,
const PxReal errorLow, const PxReal errorHigh,
const PxReal jointPDelta,
PxReal& lowImpulse_, PxReal& highImpulse_, PxReal& jointV_)
{
// PT: avoid aliasing
PxReal jointV = jointV_;
PxReal lowImpulse = lowImpulse_;
PxReal highImpulse = highImpulse_;

const PxReal futureDeltaJointP = jointPDelta + jointV * dt;

// for all errors: Negative means violated
const PxReal currErrLow = errorLow + jointPDelta;
const PxReal nextErrLow = errorLow + futureDeltaJointP;
const PxReal currErrHigh = errorHigh - jointPDelta;
const PxReal nextErrHigh = errorHigh - futureDeltaJointP;

bool limited = false;

const PxReal tolerance = 0.f;

PxReal deltaF = 0.f;
if (currErrLow < tolerance || nextErrLow < tolerance)
{
PxReal newJointV = jointV;
limited = true;
if (currErrLow < tolerance)
{
if (!isVelIter)
newJointV = -currErrLow * recipDt * erp;
}
else
{
// Currently we're not in violation of the limit but would be after this time step given the current velocity.
// To prevent that future violation, we want the current velocity to only take us right to the limit, not across it
newJointV = -currErrLow * recipDt;
}

// In position iterations, the newJointV is now such that we end up exactly on the limit after this time step (ignoring erp)
// However, we ignored the current velocity, which may already take us further away from the limit than the newJointV.
// Therefore, we additionally have to check now that the impulse we're applying is only repulsive overall.

const PxReal deltaV = newJointV - jointV;
deltaF = PxMax(lowImpulse + deltaV * recipResponse, 0.f) - lowImpulse; // accumulated limit impulse must be repulsive
lowImpulse += deltaF;
}
else if (currErrHigh < tolerance || nextErrHigh < tolerance)
{
PxReal newJointV = jointV;
limited = true;
if (currErrHigh < tolerance)
{
if (!isVelIter)
newJointV = currErrHigh * recipDt * erp;
}
else
newJointV = currErrHigh * recipDt;

const PxReal deltaV = newJointV - jointV;
deltaF = PxMin(highImpulse + deltaV * recipResponse, 0.f) - highImpulse;
highImpulse += deltaF;
}

if (!limited)
{
// If no limit is violated right now, it could still be that a limit was active in an earlier iteration and
// overshot. Therefore, we give that limit from which the joint position is currently moving away a chance to
// pull back and correct the overshoot.
// The pull-back impulse is the smaller of
// a) The impulse needed to bring the joint velocity to zero.
// b) The opposite impulse of the already applied joint limit impulse, thereby cancelling out the accumulated effect of the limit.

const PxReal impulseForZeroVel = -jointV * recipResponse;
if (jointV > 0.f) // moving away from the lower limit
{
deltaF = PxMax(impulseForZeroVel, -lowImpulse);
lowImpulse += deltaF;

}
else // moving away from the higher limit
{
deltaF = PxMin(impulseForZeroVel, -highImpulse);
highImpulse += deltaF;
}
}

jointV += deltaF * response;

lowImpulse_ = lowImpulse;
highImpulse_ = highImpulse;
jointV_ = jointV;

return deltaF;
}


/**
\brief Translate a spatial vector from the frame of one link (the source link) to the frame of another link (the target link).
\param[in] offset is the vector from the source link to the target link (== posTargetLink - posSourceLlink)
Expand Down
39 changes: 6 additions & 33 deletions physx/source/lowleveldynamics/src/DyDynamics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,8 @@ void DynamicsContext::setDescFromIndices(PxSolverConstraintDesc& desc, IG::EdgeI
{
Dy::FeatherstoneArticulation* a = islandSim.getLLArticulation(node1);

PxU8 type;

a->fillIndexType(node1.articulationLinkId(), type);

if (type == PxsIndexedInteraction::eARTICULATION)
{
desc.articulationA = a;
desc.linkIndexA = node1.articulationLinkId();
}
else
{
desc.bodyA = &mWorldSolverBody;
desc.bodyADataIndex = 0;
desc.linkIndexA = PxSolverConstraintDesc::RIGID_BODY;
}
desc.articulationA = a;
desc.linkIndexA = node1.articulationLinkId();
}
else
{
Expand All @@ -308,21 +295,9 @@ void DynamicsContext::setDescFromIndices(PxSolverConstraintDesc& desc, IG::EdgeI
if (node.getNodeType() == IG::Node::eARTICULATION_TYPE)
{
Dy::FeatherstoneArticulation* b = islandSim.getLLArticulation(node2);
PxU8 type;

b->fillIndexType(node2.articulationLinkId(), type);

if (type == PxsIndexedInteraction::eARTICULATION)
{
desc.articulationB = b;
desc.linkIndexB = node2.articulationLinkId();
}
else
{
desc.bodyB = &mWorldSolverBody;
desc.bodyBDataIndex = 0;
desc.linkIndexB = PxSolverConstraintDesc::RIGID_BODY;
}
desc.articulationB = b;
desc.linkIndexB = node2.articulationLinkId();
}
else
{
Expand Down Expand Up @@ -941,8 +916,7 @@ class PxsSolverStartTask : public Cm::Task
if(node1.getNodeType() == IG::Node::eARTICULATION_TYPE)
{
indexedManager.articulation0 = nodeIndex1.getInd();
const PxU32 linkId = nodeIndex1.articulationLinkId();
node1.getArticulation()->fillIndexType(linkId, indexedManager.indexType0);
indexedManager.indexType0 = PxsIndexedInteraction::eARTICULATION;
}
else
{
Expand Down Expand Up @@ -972,8 +946,7 @@ class PxsSolverStartTask : public Cm::Task
if(node2.getNodeType() == IG::Node::eARTICULATION_TYPE)
{
indexedManager.articulation1 = nodeIndex2.getInd();
const PxU32 linkId = nodeIndex2.articulationLinkId();
node2.getArticulation()->fillIndexType(linkId, indexedManager.indexType1);
indexedManager.indexType1 = PxsIndexedInteraction::eARTICULATION;
}
else
{
Expand Down
11 changes: 0 additions & 11 deletions physx/source/lowleveldynamics/src/DyFeatherstoneArticulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,17 +936,6 @@ namespace Dy
return a;
}

void FeatherstoneArticulation::fillIndexType(const PxU32 linkId, PxU8& indexType)
{
ArticulationLink& link = mArticulationData.getLink(linkId);

//turn the fixed-base links to static for the solver
if(link.bodyCore->fixedBaseLink)
indexType = PxsIndexedInteraction::eWORLD;
else
indexType = PxsIndexedInteraction::eARTICULATION;
}

PxReal FeatherstoneArticulation::getLinkMaxPenBias(const PxU32 linkID) const
{
return mArticulationData.getLinkData(linkID).maxPenBias;
Expand Down
4 changes: 0 additions & 4 deletions physx/source/lowleveldynamics/src/DySolverControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ void SolverCoreGeneral::solveVParallelAndWriteBack(SolverIslandParams& params, C
const PxReal invDt = params.invDt;

const PxI32 positionIterations = PxI32(params.positionIterations);
const PxI32 velocityIterations = PxI32(params.velocityIterations);

PxI32* constraintIndex = &params.constraintIndex; // counter for distributing constraints to tasks, incremented before they're solved
PxI32* constraintIndexCompleted = &params.constraintIndexCompleted; // counter for completed constraints, incremented after they're solved
Expand All @@ -307,9 +306,6 @@ void SolverCoreGeneral::solveVParallelAndWriteBack(SolverIslandParams& params, C

const PxU32* headersPerPartition = params.headersPerPartition;

PX_UNUSED(velocityIterations);

PX_ASSERT(velocityIterations >= 1);
PX_ASSERT(positionIterations >= 1);

PxI32 endIndexCount = UnrollCount;
Expand Down
Loading

0 comments on commit 19542b6

Please sign in to comment.