The evolution of PhysX (9/12) - Raycasts vs meshes

Now, simple shapes are one thing but as for rigid body simulation, what really matters are triangle meshes. So let’s start the serious tests.

The first scene involving meshes (“SceneRaycastVsStaticMeshes_Archipelago16384”) does 16K vertical raycasts against the Archipelago mesh level.

No big surprise here. All engines find the same number of hits. On the right side of the screenshot you can see all the rays that missed the mesh level. It’s all correct.

Each PhysX version is faster than the one before. Bullet is the slowest but remains competitive (“only” about 2X slower than 3.3 here).

—-

The next scene (“SceneRaycastVsStaticMeshes_TessBunny16384”) does again 16K raycasts, but this time they’re radial rays instead of vertical, and we cast them against a single highly tessellated mesh (yes, I guarantee you there is a mesh underneath that mass of raycasts :))

Using a single highly tessellated mesh means that this test stresses the “midphase” structure from that mesh, rather than the scene-level structure. Using radial rays means that engines not using node sorting in the tree traversal will be disadvantaged.

As before, each PhysX version is faster than the previous one. Bullet is slowest, and about 4X slower than 3.3.

—-

The next scene (“SceneRaycastVsStaticMeshes_KP16384”) is the opposite of what we just tested: it now contains a lot of small meshes, none of them having a lot of triangles. So the test stresses the scene-level “broadphase” structure, more than the individual “midphase” mesh structures.

The scene is just the mesh level from Konoko Payne: it contains 4104 meshes, for a total of 592267 triangles. We perform 16K radial raycasts again, from a random position deep inside the level.

The results are in line with what we saw so far. Each PhysX version is faster than the one before. Bullet is slowest, about 4.7X slower than 3.3 on average.

—-

I repeated the same test from another initial ray position in the level, to see if we got the same results (“SceneRaycastVsStaticMeshes_KP16384_2”). This time some of the rays hit a mesh, some don’t.

Each library (pretty much) reports the same number of hits, that’s good.

Each PhysX version is faster than the one before, that’s good.

Bullet is slowest, about 3.47X slower than 3.3 on average. It’s slightly better than before but not exactly fast. Still, I wanted to see if the better performance was due to the rays not hitting anything, so I created a last test in the same scene, where none of the rays hit anything (“SceneRaycastVsStaticMeshes_KP16384_NoHit”).

But it did not change much of the results. Bullet is still slowest, and about 4X slower than 3.3. Well these are pretty consistent results at least.

—-

The final test for this section (“Terrain_RT”) is a raytracing test against a large terrain (the same terrain we previously used for the ragdoll test).

Compared to the KP scene the mesh level is different, the raycasts are neither radial nor vertical anymore, but the results are quite similar to what we saw so far.

All engines find the same number of hits, that’s good. Each PhysX version is faster than before, that’s good. PhysX 3.3 is again a bit more than 2X faster than 2.8.4, and a bit more than 4X faster than Bullet.

Well, contrary to what people may say on the Internet, we do optimize our code for the CPU.

Comments are closed.

shopfr.org cialis