Arash
Arash

Reputation: 139

Storing triangles with shared edge in Octrees

I am trying to load an STL mesh file and store its triangles an in octree data structures for some scientific analysis (not for gaming).

an example of two triangles with a shared edge

as shown in the image, Triangle 1 is stored in octree nodes NE, SE, SW and NW while triangle 2 is stored in octree nodes NW and SW. (2d representation but it's the same story in 3d).

it would be pointless to divided nodes NW and SW the since the two triangles shares the red edge. and this problem becomes more troublesome if I have more than two triangles spanning over several cells.

so, what is the correct way of storing triangles in octree?

ps- I don't want to clip triangles.

Upvotes: 3

Views: 791

Answers (1)

Michal Butterweck
Michal Butterweck

Reputation: 438

I have used two most common approaches:

  • store triangle in every leaf node which intersects with triangle; so, one triangle may be in multiple leafs;
  • store triangle in a node (branch or leaf) which entirely encloses the triangle; no duplicates.

The first approach was useful for rough, axis-aligned, estimate of object's shape - to solve tight packing problem. Basically it was non-uniform voxelization. The second approach was quite good for collision detection. Each triangle needed to be collided with other triangles in the same node and its children. The second approach produced quite lightweight implementation (you can add linked-list next-pointer directly to triangle).

Upvotes: 2

Related Questions