Page 1 of 1

Sorting triangles inside BEPU.

Posted: Thu Apr 09, 2015 11:25 am
by ProBAR
Hello everyone, especially Norbo.

Does the physics engine some ordering of the triangles? I mean the vertices and indices. Take a look at the attached picture.

For example, we have one platform and two cubes on it. Each object has 8 vertices and 36 indices (3 index per 12 triangles). The whole scene is imported into a physics engine as a single static object, i.e. an array of vectors from 24 vertices and an array of integers from 108 indexes. So, does the physics engine reordering the elements of these arrays to optimize collision detection? In other words, sorting the vertices by their three-dimensional position to make it easier to find other nearest vertex. When faced with a red cube, may I know is near the black platform, and not a blue cube?

Re: Sorting triangles inside BEPU.

Posted: Thu Apr 09, 2015 6:13 pm
by Norbo
It does not explicitly sort the triangles right now, but it does construct an acceleration hierarchy which can be used for fast queries. For example, StaticMesh.Mesh.Tree.GetOverlaps provides a few overloads for different query shapes.

(Later, the triangles may be reorganized for performance reasons, but the exact form of that order should not be relied upon.)

Re: Sorting triangles inside BEPU.

Posted: Fri Apr 10, 2015 8:39 am
by ProBAR
Norbo wrote:StaticMesh.Mesh.Tree.GetOverlaps
Exactly what I was looking for. It's weird that I haven't found it before. Many thanks, Norbo!