Auburn/FastNoise2

SetGain, SetLacunarity, etc functions dont seem to be respecting values after doing work

Closed this issue · 4 comments

I have some code along these lines

FastNoise::SmartNode<FastNoise::FractalFBm>` m_noiseGenerator;

m_noiseGenerator = FastNoise::New<FastNoise::FractalFBm>();
auto fnSimplex = FastNoise::New<FastNoise::Simplex>();
m_noiseGenerator->SetSource(fnSimplex);
m_noiseGenerator->SetOctaveCount(4);
m_noiseGenerator->SetGain(2);
m_noiseGenerator->SetLacunarity(2);
m_noiseGenerator->SetOctaveCount(3);

   // ... do some work, call m_noiseGenerator->GenUniformGrid2D a bunch of times
 m_noiseGenerator->SetLacunarity(3);
	m_noiseGenerator->SetGain(3);
	m_noiseGenerator->SetOctaveCount(4);
   // generate more stuff, but its wrong this time.

The second call to SetGain seems to not be working correctly. I see the correct value go in and populate mGain. But then the noise it generates acts as if the value is 0, even though it was never set to that value

Is there any threading at play here?

GenUniformGrid2D and similar functions are const and thread-safe. Setting variables is not however

There is, but I only call these Set functions from the main thread. and make sure that none of my worker threads are doing anything while the main thread is calling them. I just tried adding a lock around any calls to m_noiseGenerator (both Set's and Gen's) and I still have the same issue.

If you create a new instance of the node does that resolve the issue?
If you look at the node in the debugger can you see the member value set at 0?

Hmm i think this might have been some weird C++ nonsense. I had the node as a static variable in the global namespace, and setting the values there didn't work. I made one of my classes own the node and now its working. Sorry to waste your time :(