3d: Fix initialization call

The vector duplication call was invalid as growing the vector
invalidates the iterators.
This commit is contained in:
Seth Hillbrand 2019-11-07 04:45:46 -08:00
parent a60fb9a4b8
commit 79972a3867
1 changed files with 6 additions and 2 deletions

View File

@ -74,7 +74,9 @@ PerlinNoise::PerlinNoise()
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180 };
// Duplicate the permutation vector
p.insert(p.end(), p.begin(), p.end());
auto oldsize = p.size();
p.resize( 2 * p.size() );
std::copy_n( p.begin(), oldsize, p.begin() + oldsize );
}
// Generate a new permutation vector based on the value of seed
@ -92,7 +94,9 @@ PerlinNoise::PerlinNoise( unsigned int seed )
std::shuffle( p.begin(), p.end(), engine );
// Duplicate the permutation vector
p.insert( p.end(), p.begin(), p.end() );
auto oldsize = p.size();
p.resize( 2 * p.size() );
std::copy_n( p.begin(), oldsize, p.begin() + oldsize );
}
float PerlinNoise::noise( float x, float y, float z ) const