Sorting triangles inside BEPU.

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
ProBAR
Posts: 10
Joined: Tue Aug 05, 2014 9:46 pm

Sorting triangles inside BEPU.

Post 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?
Attachments
Drawn in Paint, too lazy to do it in a true 3d :)
Drawn in Paint, too lazy to do it in a true 3d :)
Platform_Cubes.png (2.69 KiB) Viewed 3341 times
P.S.:
Speech: English is not my native language, so I apologize in advance for my mistakes.
Language: Mainly Visual Basic.Net, of course not excluded C#.
Using BEPU: I get it from the NuGet Packages (very handy, thanks!).
Render: SharpDX.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Sorting triangles inside BEPU.

Post 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.)
ProBAR
Posts: 10
Joined: Tue Aug 05, 2014 9:46 pm

Re: Sorting triangles inside BEPU.

Post 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!
P.S.:
Speech: English is not my native language, so I apologize in advance for my mistakes.
Language: Mainly Visual Basic.Net, of course not excluded C#.
Using BEPU: I get it from the NuGet Packages (very handy, thanks!).
Render: SharpDX.
Post Reply