X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fnoise.cpp;h=6d59224c2f41f4de89ae982627387fcacd7235a2;hb=c877ddd21f402381d88a6bebdd5c7c0b4ac28ba9;hp=c86f833ac3c126c894a53eeb5ad6df6c9c835d02;hpb=e065961dc9af7968d734457ce716231bb51807b7;p=blank.git diff --git a/src/noise.cpp b/src/noise.cpp index c86f833..6d59224 100644 --- a/src/noise.cpp +++ b/src/noise.cpp @@ -12,6 +12,24 @@ constexpr float one_sixth = 1.0f/6.0f; namespace blank { +GaloisLFSR::GaloisLFSR(std::uint64_t seed) +: state(seed) { + +} + +bool GaloisLFSR::operator ()() { + bool result = state & 1; + state >>= 1; + if (result) { + state |= 0x8000000000000000; + state ^= mask; + } else { + state &= 0x7FFFFFFFFFFFFFFF; + } + return result; +} + + SimplexNoise::SimplexNoise(unsigned int seed) : grad({ { 1.0f, 1.0f, 0.0f },