subdgtl / Monoceros

Wave Function Collapse plug-in for Grasshopper
MIT License
63 stars 13 forks source link

Update solver component to use wfc v0.1.0 #22

Closed yanchith closed 3 years ago

yanchith commented 3 years ago

This patch updates the DLL bindings to the new Rust solver v0.1.0.

The two major changes are:

1) RNG and World state are now initialized and freed separately 2) Grasshopper solver component is now responsible for the attempt loop

Besides that I took the liberty of changing some vars back to uints/ushorts, etc... For bit manipulation we want to be exact. It may be that C# inferred the correct types, but there were at least a few sites where it inferred them incorrectly - when I replaced var with the correct numeric type, it caused a type error which I had to fixup with explicit casts. I wonder if this already caused bugs. Also I find it better documentation to use explicit types if they are this important. I am fine with var everywhere else, where it can not cause subtle and dangerous errors.

I also added a TODO to bring back AdjacencyKind enum. It was there to model the type as exposed by the C API of the Rust solver. The Axis enum actually does not belong to Monoceros, but this wasn't documented anywhere. This could lead to potentially deadly bugs in the future, if anyone forgets the type is actually volatile and always has to mirror the WFC one.

I only tested on the Mondieu project and it seemed to behave well, but @janper please test extensively on all examples. I don't know this codebase well.

Fixes #15