How to use built in Voronoi in C++?

There is a Voronoi lib built in the UE4. It uses voro++ under the hood.


And there is the struct FVoronoiCellInfo.

Documentation says that it is “All the info you would typically want about a single cell in the Voronoi diagram”, but I dont understand what does the Neighbors member of the struct means. It’s some kind of random numbers in there (positive and negative) wich does not make any sense for me :frowning:

All I need to know is what is the index of the neighbor of the current cell in the result array of cells from FVoronoiDiagram::ComputeCells(). But how can I use that random numbers? What does negative numbers means?

Somebody, help me, please!

The neighbor index in the Voro++ library is negative for a few different reasons. One reason is that the index is used to represent a “ghost” or “virtual” particle, which is a particle that is not actually present in the system but is used in the Voronoi tessellation calculation to help determine the properties of the real particles. Ghost particles can have negative indices because they do not correspond to actual particles in the system, so they are not subject to the same constraints as real particles.

Another reason the neighbor index may be negative is that it is used to represent a “null” or “empty” neighbor. In other words, if a particle does not have any neighbors within a certain distance, its neighbor index may be set to a negative value to indicate that it has no neighbors. This can be useful in situations where it is important to know whether a particle has neighbors or not, such as when calculating certain physical properties of a system.

Overall, the use of negative indices for neighbor particles in the Voro++ library is a way to represent special cases and exceptions that arise in the calculation of Voronoi tessellations.