File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 33// siv::PerlinNoise
44// Perlin noise library for modern C++
55//
6- // Copyright (C) 2013-2016 Ryo Suzuki <reputeless@gmail.com>
6+ // Copyright (C) 2013-2018 Ryo Suzuki <reputeless@gmail.com>
77//
88// Permission is hereby granted, free of charge, to any person obtaining a copy
99// of this software and associated documentation files(the "Software"), to deal
@@ -64,6 +64,12 @@ namespace siv
6464 reseed (seed);
6565 }
6666
67+ template <class URNG >
68+ explicit PerlinNoise (URNG& urng)
69+ {
70+ reseed (urng);
71+ }
72+
6773 void reseed (std::uint32_t seed)
6874 {
6975 for (size_t i = 0 ; i < 256 ; ++i)
@@ -79,6 +85,22 @@ namespace siv
7985 }
8086 }
8187
88+ template <class URNG >
89+ void reseed (URNG& urng)
90+ {
91+ for (size_t i = 0 ; i < 256 ; ++i)
92+ {
93+ p[i] = i;
94+ }
95+
96+ std::shuffle (std::begin (p), std::begin (p) + 256 , urng);
97+
98+ for (size_t i = 0 ; i < 256 ; ++i)
99+ {
100+ p[256 + i] = p[i];
101+ }
102+ }
103+
82104 double noise (double x) const
83105 {
84106 return noise (x, 0.0 , 0.0 );
You can’t perform that action at this time.
0 commit comments