0
\$\begingroup\$

I am doing a Unity project, that makes it necessary to import a mesh consisting of triangles. As it is possible to reduce the amount of triangles in a mesh and keeping the structure similar, I am wondering, what the theoretical expectation of the behaviour of the computational time and power would be. So for example, I am using a mesh with 100000 triangles vs. 50000 triangles. In the project a sphere will collide with the mesh at a certain point and time. What would be an approach to what to expect here? (From simply running the project, I did not notice a difference, but I would like to understand what happens "in the background"/ what I can expect for larger amounts of triangles.) Thank you very much in advance!

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

This depends on some specifics.

If the triangle mesh is using a convex collider, then only polygons on the convex hull contribute to the collision detection cost, while interior/co-planar triangles take time to import but are effectively ignored in collisions.

If the mesh is static, the physics engine may be able to sort it into an acceleration structure that lets it check only "nearby" triangles for collisions, rather than the full collection. So here it's the density of triangles per unit volume that matters, not necessarily the total number. (Though a larger number will still take more time and memory to import/load/distribute into the acceleration structure)

The best way to find out for your specific use case would be to take a simple mesh representative of what you'll be working with, then make a copy of it which you subdivide to some high degree. Make sure it stays curved or bumpy after subdivision, to deny Unity opportunities to auto-simplify some of the small triangles back to fewer, larger triangles in flat areas.

Import each mesh into an otherwise-identical scene where things will collide with them, and run the profiler to measure the exact time cost of the physics update in each case. Run several trials to control for flukes. Then crank up the subdivisions and try again. This will let you empirically plot the performance curve as it manifests for the collision scenarios you're using.

\$\endgroup\$
1
  • \$\begingroup\$ Ok, thanks for the answer, I didn't realize what the profiler could be used for. I will try it. \$\endgroup\$
    – the2second
    Sep 22, 2023 at 11:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .