Skip to content

Octree should allow each leaf to store more than 8 triangles #25264

@ButzYung

Description

@ButzYung

Description

The current Octree implementation in three.js is often slow and can use up a lot of memory when dealing with geometry containing lots of triangles, especially when some of the triangles are large. Octree as a data structure has no problem storing points as each point occupies only one leaf. However, in the case of triangle it can occupy multiple leaves depending on its size. This reduces the efficiency of using Octree to store triangles because of the overlaps. A geometry with more than 200k triangles could end up being 100+ times bigger in triangle count in Octree due to overlaps, taking more than 20 seconds to build and occupying a few giga bytes of memory, making it practically unusable.

Solution

The simplest solution is to allow each leaf to store more than 8 triangles. In my test case, I increased the limit from 8 to 32, and it reduced the triangle count in Octree by nearly 10 times with no impact on collision detection performance.

Alternatives

I can't think of any alternative simpler than a static increase in triangle limit.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions