Update the bundled PhysX to 5.9.0


Import a clean copy of the PhysX 5.9.0 sources, as produced by
copy_sources.py from tag 110.1-omni-and-physx-5.9.0 of
https://github.com/NVIDIA-Omniverse/PhysX, regenerate the source and
include lists of the CMake project from it, and adapt Qt Quick 3D
Physics to the PhysX 5 API. Note that PhysX moved from NVIDIAGameWorks
to NVIDIA-Omniverse on GitHub with the 5.x series, so the attribution
metadata points at the new repository.

The copy is about the size of the 4.1 one it replaces, 423 sources
against 415, even though PhysX itself has grown a great deal since: the
vehicle library, the GPU implementation and OmniPVD are left out, since
we build none of them. Three new defines say so to the parts of PhysX
that ask:

- DISABLE_CUDA_PHYSX, since we only run the CPU simulation, and never
  ship the PhysXGpu library that the GPU pipeline would need.
- PX_SUPPORT_OMNI_PVD=0, as in the upstream release configuration.
- PX_PUBLIC_RELEASE=1, since this is the public distribution of PhysX,
  which does not carry the NVIDIA internal sources that the core would
  otherwise expect to find.

PX_SIMD_DISABLED, which the MinGW builds set, now has to reach
everything that includes the PhysX headers rather than the library
alone: it decides whether the vecmath types are registers or plain
structs, and PhysX 5 moved that vecmath from source/foundation/include,
where only PhysX itself could see it, into include/foundation, which
PxPhysicsAPI.h reaches. Left to the library, it gives the module and the
library two layouts for the same types.

The parts of the PhysX API we use that changed with PhysX 5:

- Cooking no longer goes through a PxCooking object, but through free
  functions taking a PxCookingParams. They still need the foundation, so
  QPhysicsWorld::getCooking() becomes getCookingParams(), which returns
  null until the foundation exists, keeping the guard the call sites
  already had.

- PxShape has a single getGeometry(), returning the geometry as a
  PxGeometry reference, instead of one getter per geometry type. The
  switch in the debug drawing already knows the type, so it can cast.
  PxGeometryType also gained values for the geometries that PhysX 5 can
  simulate but Qt Quick 3D Physics does not expose.

- PxRigidBody lost setLinearVelocity()/setAngularVelocity() to
  PxRigidDynamic, so that is what the physics commands operate on. Their
  only caller already had a PxRigidDynamic.

- PxTransform is a typedef for PxTransformT<float>, and can no longer be
  forward declared as a class.

- PxFlags has no set(), the flags are combined with |=, and
  PxFoundation.h and PxPhysicsVersion.h moved into the foundation
  directory.

The serialized formats of convex meshes, triangle meshes and
heightfields all changed too, so the pre-cooked files the tests load are
regenerated with the cooker built from this commit. The convex mesh was
rejected outright by PhysX 5, and the triangle mesh loaded but simulated
as nothing, which made the cooked test time out waiting for a ball to
land on it.

pxshared is gone from PhysX 5, its headers now live in
include/foundation, the include paths that the module and the cooker had
for it are gone with it, and the 4.1 patches in this directory are
dropped along with the sources they applied to. Seventeen patches are
still needed, and they are part of this commit rather than of one commit
each, stored in the patches directory, as the other bundled libraries in
Qt Quick 3D keep theirs, and numbered in the order they are applied.

Fourteen of them because without them PhysX does not build: on any
platform for the vehicle include, on musl for the two glibc ones and the
SSE types, on OpenHarmony for pthread_cancel() and, together with
Android, for the mutex attributes that PhysX 5 asks every Linux pthreads
for now that it has no Android platform of its own, on arm64 macOS for
the FPU guard and for the store in the padded matrix, which is written
for the vector intrinsics that PhysX 5 only has on the Intel family and
on Switch, on WebAssembly for the rest of the paths taken when SSE2 is
off and for the spin hint that is written as an x86 instruction, on
mips64 for the architecture itself, which PhysX 5 does not know and
whose glibc versions the math symbols differently from the x86-64 one
PhysX binds them to, on 32-bit x86 for the size assertion on the indexed
contact manager, which the alignment there cannot satisfy, with MinGW
for the thread naming, which it has no structured exceptions to compile,
and for the packing check, which probes the pack value with a type that
is only 8 bytes where a long is, and with the GCC versions that see
through the inlining for the uninitialized contact iterator. The MinGW
one carries a second half that is not about building at all: PhysX asks
for alignment in the Microsoft compilers' spelling on every Windows
compiler, and the ones that ignore it leave PxSListEntry 8 byte aligned,
which is not what the Windows interlocked singly linked lists pack their
pointers for, so the task queue of the default CPU dispatcher hands
worker threads entries that were never pushed. One because the
serialization sources are not copied, so PxInitExtensions() cannot
register the RepX serializers with them.

The last two are forward ports of patches the 4.1 copy already carried,
and are here rather than in commits of their own so that no commit in
between is one where the 4.1 copy had a fix and this one does not:

- The stack-buffer-overflow in the bucket pruner raycasts, which is as
  live as it was: without it, AddressSanitizer reports a 16 byte SSE
  read from a 12 byte PxVec3 in the ground detection raycast of every
  CharacterController move, which the query_structure test does.

- The uninitialized ray distance in the RTree midphase. That is the
  eBVH33 midphase, which PhysX 4.1 cooked triangle meshes with by
  default, and which PhysX 5 deprecated in favour of eBVH34, so with the
  cooking parameters we use nothing reaches it any more. The file is
  still compiled and linked, and the fix is a single initializer, so it
  is kept rather than dropped.

[ChangeLog][Third-Party Code] The bundled NVIDIA PhysX SDK was updated
from 4.1.2 to 5.9.0.

[ChangeLog][Important Behavior Changes] PhysX 5 writes cooked meshes and
height fields in formats that PhysX 4 did not use, so the files a cooker
tool from an earlier Qt version produced, the ones a shape source
property points at with a .cooked.cvx, .cooked.tri or .cooked.hf suffix,
no longer load and have to be cooked again with the cooker tool of this
version. Meshes in the cache that QT_PHYSICS_CACHE_PATH points at need
no attention: they are cooked again on the first run.

Change-Id: Ib4263db089298bc7756a38eb166daf6ad0c5b207
Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io>
commit7533abcc02b7f9bd7953203c489ee86d55e8c909
parent0fb51d2712d807058a44c0d8572c7eddfd97f01a
authorJonas Karlsson <jonas.karlsson@qt.io>
committerJonas Karlsson <jonas.karlsson@qt.io>
commit timeWed, 16 Sep 2026 13:16:10 +0000