Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cjordog opened this issue Oct 7, 2022 · 4 comments

Comments

@cjordog
Copy link

cjordog commented Oct 7, 2022

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

@Auburn
Copy link
Owner

Auburn commented Oct 7, 2022

Is there any threading at play here?

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

@cjordog
Copy link
Author

cjordog commented Oct 7, 2022

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.

@Auburn
Copy link
Owner

Auburn commented Oct 7, 2022

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?

@cjordog
Copy link
Author

cjordog commented Oct 8, 2022

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 :(

@cjordog cjordog closed this as completed Oct 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants