Skip to content

Help bullet optimize collisions with very complex collision meshes by making small collision tests if possible

wareya requested to merge wareya/openmw:phys_perf_test into master

Short traces into complex objects cause bullet to do less work than long traces, even if the end result position is the same. This means that bullet is doing some kind of intra-collision-mesh optimization for collisions, but one that works based on the collision motion volume (or an approximation of it) instead of based on proximity. This means that we can optimize traces into such complex objects by doing a short trace first, then doing a long trace only if those short trace doesn't hit anything.

This makes every non-colliding collision test with motion length greater than five do two traces instead of one, so it's possible that this could cause a minor physics performance regression. Requires testing. If it does cause a minor physics performance regression, I can add a flag to bypass the short trace for collision tests that are unlikely to benefit from it (like the ones in the core loop of the movement solver).

Refactor how ActorConvexCallbacks are constructed and used to use a helper function while I'm at it. There was some duplication before, and this patch would have made even more duplication if I didn't refactor this. doTrace and findGround had some differences in how they set things up, but aside from the actor filtering that findGround does, I'm going to assume that the differences weren't important. Please correct me if I'm wrong.

Partially alleviates #6352 (tested, see images) and maybe #5577 (closed) (did not test).

With extra trace test:

openmw_2021-10-22_23-07-41

Without extra trace test:

openmw_2021-10-22_23-08-20

Merge request reports