4 ms·
I also struggled to find the answer online. I found it in only 2 books. Chapter 12 of Real-Time Collision Detection has a section on vertex welding. The 1st e
by OnionBlender 2y ago
I also struggled to find the answer online. I found it in only 2 books.
Chapter 12 of Real-Time Collision Detection has a section on vertex welding.
The 1st edition of 3D Math Primer has it in Chapter 14.4.2: Vertex Welding.
If you want to merge vertices that are within WELD_EPSILON then you can create a 3D grid of cells with cell sizes being at least as large as 2*WELD_EPSILON and put each vertex in its cell. For each cell, you only need to check the 8 neighboring cells to see if the vertex should be merged with a nearby vertex.
The worst case could be worse than O(N) if most of the vertices end up in the same grid cell but don't require merging.
- animal531 2y agoAwesome thanks, grids work really well for a lot of optimization tricks.