If it is a very large mesh with many vertices it will require some heavy computation to check for collisions against it. even for a well optimized physics engine.
Some physics engines can support a convex hull, which will be a better approximation of the mesh’s shape. There is a short discussion about it here - Ammo.js convex mesh hull - #3 by MackeyK24
A different approach would be to collide against the bounding sphere or bounding box, depending on the mesh you are colliding against. Another one would be to separate the mesh into smaller meshes.
The reason that would work is the algorithm that is used to check for collisions. It inspects every triangle until it finds one that collides against the player. If you are “lucky” and it is one of the first triangles then it will be rather quick. but most of the time (because that’s how things are ) the colliding triangle will be deep in the positions array. now checking 100, 200, 1000 of those - that is fast and can be done every frame. but when it gets to be very big - the performance goes bad.
Of course, the best solution IMO is making your mesh more low-end friendly. But that’s not the nicest solution is a lot of cases. It really depends on your usecase.
Best approach to me is to have meshes for rendering and meshes for collision detection. Basically, build a low-res version mesh that will not be rendered but only used for collision.
If it’s a few hundred triangles, you’ll be able to use it for camera ellipse or trimesh with Ammojs.
Maybe you can try to use a convex hull with Ammo from your rendered geometry but I think it will be counter productive to convert a geometry that big at load time. Moreover, it will be convex so a lot of detail will be missing. Making it look more like a box.
So, I’ll all for a simplified geometry!
As I understand it, this is a general approach for creating impostors for large geometry. That is, this approach is not exclusively for babylon or for browser based 3D?
Correct! It’s one of the core concepts of realtime rendering/games. Like voxelizing a scene to do global illumation computation. Or using triangles to render continuous surfaces. Use a simpler representation to do fast computation. It won’t be exact but close and good enough.
If we look into the future, to theorize… What are the possible solutions to the problem of large impostors for large geometry? Is anything being done in the world for this, and if so, what? Is it possible to read about it somewhere?
Or does it all ultimately come down to increasing the performance of computers?
Hard to tell. Maybe in the future meshes will be ahiearchy of signed distance field with a raymarching for rendering and SDF for collision detection…or not
No need to bet on distant future for today’s software.
For now, a bounding volume hierarchy and simple primitives or trimesh seems fine.
If you mean Auto LOD, then it works very slowly on such large meshes. In addition, for certain reasons, I cannot reduce the number of vertices in the mesh or change them in any way. Even if the mesh can be optimized manually and automatically, this cannot be done.