added "only on selection" to PerVertexAddNoise and PerVertexPerlinNoise functions
This commit is contained in:
parent
667d3034dd
commit
497a42dffe
|
@ -331,14 +331,16 @@ Note: The faux bit is used to color polygonal faces uniformly
|
|||
Period is expressed in absolute terms.
|
||||
So as period it is meaningful could be to use something in the range of 1/10 of the bbox diag.
|
||||
*/
|
||||
static void PerVertexPerlinNoise(MeshType& m, CoordType period, CoordType offset=CoordType(0,0,0))
|
||||
static void PerVertexPerlinNoise(MeshType& m, CoordType period, CoordType offset = CoordType(0, 0, 0), bool onSelected = false)
|
||||
{
|
||||
RequirePerVertexColor(m);
|
||||
|
||||
CoordType p[3];
|
||||
|
||||
for(VertexIterator vi = m.vert.begin(); vi!=m.vert.end(); ++vi)
|
||||
if(!(*vi).IsD())
|
||||
if ((!onSelected) || ((*vi).IsS()))
|
||||
{
|
||||
if(!(*vi).IsD()){
|
||||
// perlin noise is defined in 022
|
||||
p[0] = (vi->P()/period[0])+offset;
|
||||
p[1] = (vi->P()/period[1])+offset;
|
||||
|
@ -348,13 +350,13 @@ Note: The faux bit is used to color polygonal faces uniformly
|
|||
int(127+128.0*math::Perlin::Noise(p[2][0],p[2][1],p[2][2])),
|
||||
255 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*! \brief Simple Noise adding function.
|
||||
It simply add signed noise to the color of the mesh. The noise has uniform distribution and the amplitude is +/-2^(noisebits-1).
|
||||
*/
|
||||
static void PerVertexAddNoise(MeshType& m, int noiseBits)
|
||||
static void PerVertexAddNoise(MeshType& m, int noiseBits, bool onSelected=false)
|
||||
{
|
||||
RequirePerVertexColor(m);
|
||||
|
||||
|
@ -363,13 +365,14 @@ Note: The faux bit is used to color polygonal faces uniformly
|
|||
|
||||
math::SubtractiveRingRNG randomGen = math::SubtractiveRingRNG(time(NULL));
|
||||
for(VertexIterator vi = m.vert.begin(); vi!=m.vert.end(); ++vi)
|
||||
if(!(*vi).IsD())
|
||||
if ((!onSelected) || ((*vi).IsS()))
|
||||
{
|
||||
if(!(*vi).IsD()){
|
||||
(*vi).C()[0] = math::Clamp<int>((*vi).C()[0] + randomGen.generate(int(2*pow(2.0f,noiseBits))) - int(pow(2.0f,noiseBits)),0,255);
|
||||
(*vi).C()[1] = math::Clamp<int>((*vi).C()[1] + randomGen.generate(int(2*pow(2.0f,noiseBits))) - int(pow(2.0f,noiseBits)),0,255);
|
||||
(*vi).C()[2] = math::Clamp<int>((*vi).C()[2] + randomGen.generate(int(2*pow(2.0f,noiseBits))) - int(pow(2.0f,noiseBits)),0,255);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue