3d: Fix initialization call
The vector duplication call was invalid as growing the vector invalidates the iterators.
This commit is contained in:
parent
a60fb9a4b8
commit
79972a3867
|
@ -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 };
|
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180 };
|
||||||
|
|
||||||
// Duplicate the permutation vector
|
// 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
|
// 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 );
|
std::shuffle( p.begin(), p.end(), engine );
|
||||||
|
|
||||||
// Duplicate the permutation vector
|
// 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
|
float PerlinNoise::noise( float x, float y, float z ) const
|
||||||
|
|
Loading…
Reference in New Issue