Vehicles and very large Maps and height maps

Hello,

I want to have about 500 vehicles (tanks, 4W cars) run on a 100x100 km heightmap with a grid resolution of 0.7m (we use only the part of the map from disk that is needed).

Here is my plan how to do it.

-Every vehicle drives on its own PxHeightFieldGeometry, which represents a 50x50 meter part of the heightmap.
-The heightfield geometry is adapted if the vehicle reaches the border of the 50x50m map.
-If there is no chance that vehicles can collide, they are run in their own local mapgrid and and their own PxScene
-So basically I create something like 500 times the scene in the sample application

Now this sounds like a good approach to me. Does anyone have any suggestions?

-Is there a way to get rid of the heightfield? I just want to tell the vehicle simulation the map height by using our own height map - this should give the simulation enough data to simulate the driving without the collision stuff and this would be enough for the simulation most of the time.
-Is there a better way than to create 500 scenes? I think this is better than to put everything in one scene.

Greetings,
maxmus

I think having a scene per vehicle wouldn’t be the best approach. The PhysX scene provides a lot of parallelism that you’ll lose if you have one vehicle per scene. There’s also a fixed cost per scene doing book-keeping, thread management, memory management that will be done 500 times if you have 500 scenes. I strongly recommend having just a single scene and adding all heightfields and vehicles to that scene.

Let’s imagine you have a single scene with 500 vehicles. You might want to look at activating the MBP broadphase algorithm. This can be done with the PxBroadPhaseType::eMBP flag. You seem to have a natural boundary for each vehicle defined by the limits of its heightfield. That boundary could provide a good boundary for each MBP cell. SnippetMBP illustrates this feature, provided you’re on 3.3.2 or later.

Cutting up the map into smaller parts almost always provides a good performance gain. Experimentation will reveal the best trade-off between number of heightfields and heightfield extent.

500 cars is quite a large number. I’d recommend multi-threading the vehicle raycasts and updates. If you’re on 3.3.2 or later there’s a snippet called SnippetVehicleMultiThreading that demonstrates how to achieve this.

One word of caution is that 100km x 100km is quite a large area. You might start running into numerical issues far from the origin. We’ve found that up to 10km there is no real issue with numerical losses but have less experience at 100km. It really depends on what you’re doing, the PhysX feature set that is being used, the timestep and what fidelity is considered acceptable.

Gordon