Fix #111: Voronoi tessellation repeats along x-axis on Windows#120
Merged
JonathanMaes merged 2 commits intodevfrom Jan 15, 2026
Merged
Fix #111: Voronoi tessellation repeats along x-axis on Windows#120JonathanMaes merged 2 commits intodevfrom
JonathanMaes merged 2 commits intodevfrom
Conversation
DiegoDeGusem
approved these changes
Jan 14, 2026
lamoreel
approved these changes
Jan 14, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 insrc/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 ofengine_.seed(...)has a different data type in Windows than on Linux:std::mt19937, seeded using anunsigned int,std::minstd_rand0, seeded using auint_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.