Hello - I’m looking for a way to detect all mesh triangles of a single mesh within a given area.
I’ve actually gotten this working, but ever method I’ve used is simply not performant enough - it totally crushes my framerate.
My current method of detection is to iterate through all mesh vertices and check their proximity to a RaycastHit.point on the mesh’s surface.
When the icospherical mesh is sparse, as you can see in IcoPerformance_1.JPG, performance is good.
However, when the icospherical mesh becomes more dense, as you can see in IcoPerformance_2.JPG and IcoPerformance_3.JPG, performance simply tanks (as there are many more mesh vertices to iterate through).
Some other methods I’ve tried:
- SphereCast and SphereCastAll only register the first impact with the mesh; not all impacted triangles.
- I have tried casting a “cone” of RayCasts out to the surface of the mesh from the camera. This sortof works, but because of the nature of casting hundreds of individual rays, sometimes triangles get missed, especially small ones.
- All of my triangles are linked to an abstract icospherical model in code. This model’s triangular faces all have adjacency data; I have tried doing an adjacency search, and this works correctly, but unfortunately it also tanks performance.
There has got to be some method of simply detecting all mesh triangles within an area that I’m missing. Thank you in advance!
IcoPerformance 1:
IcoPerformance 2:
IcoPerformance 3: