Skip to content

Fix #111: Voronoi tessellation repeats along x-axis on Windows#120

Merged
JonathanMaes merged 2 commits intodevfrom
bugfix/voronoi
Jan 15, 2026
Merged

Fix #111: Voronoi tessellation repeats along x-axis on Windows#120
JonathanMaes merged 2 commits intodevfrom
bugfix/voronoi

Conversation

@JonathanMaes
Copy link
Contributor

As reported in #111, the Voronoi tessellation exhibited periodicity along the x-axis on Windows.
The culprit is engine_.seed(seed ^ seed_); on line 127 in src/core/voronoi.cpp.

Cause

The Voronoi tessellation uses "tiles" for efficiency: the RNG generates some Voronoi centres in each of these. The seed for this RNG is based on the (x,y,z)-index of the current tile: it was a 64-bit number constructed by taking the last 24 bits of the x-index, the last 20 bits of the y-index, and the last 20 bits of the z-index. The issue was that the argument of engine_.seed(...) has a different data type in Windows than on Linux:

  • MSVC's default RNG is std::mt19937, seeded using an unsigned int,
  • GCC's default RNG is std::minstd_rand0, seeded using a uint_fast32_t.

Somehow, passing a 64-bit seed on MSVC cuts off the first 32 bits, while on GCC the 64-bit number stays intact. Hence, on Windows, the x-index of the tile was completely disregarded, explaining the periodicity along x.

Fix

The seed was changed to a 32-bit integer consisting of 12 x-, 10 y-, and 10 z-bits. Hence, the periodicity now occurs over a length scale of ⪆2048 Voronoi cells, rather than 2 as was the case for the x-axis. I believe this should suffice for all but the most extreme simulations.

@JonathanMaes JonathanMaes added the Windows Issue/PR only affects installation/simulations on Microsoft Windows. label Jan 13, 2026
@JonathanMaes JonathanMaes merged commit 27bfbe5 into dev Jan 15, 2026
@JonathanMaes JonathanMaes deleted the bugfix/voronoi branch January 15, 2026 09:59
@JonathanMaes JonathanMaes mentioned this pull request Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Windows Issue/PR only affects installation/simulations on Microsoft Windows.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants