I have added the following lines to your code to compile (basically no changes except for cleaning the cache):
struct NoiseppNoise
{
NoiseppNoise();
double Generate( double x, double y );
noisepp::ThreadedPipeline2D mPipeline2d;
noisepp::ElementID mThreadCount;
noisepp::PerlinModule mPerlin;
noisepp::ElementID mNoiseID2D;
noisepp::Cache* mCache2d;
};
/* constructor as in the question */
double NoiseppNoise::Generate( double x, double y )
{
mPipeline2d.cleanCache (mCache2d); // clean the cache before calculating value
return mPipeline2d.getElement( mNoiseID2D )->getValue ( x, y, mCache2d );
}
Calling it with
NoiseppNoise np;
std::cout<<np.Generate(1.5,1)<<std::endl;
actually outputs a good value, 0.0909 for me.
However if you call it with two "integers" (e.g. 3.0 and 5.0) the output will be 0 because at some point something similar to the following statement is executed:
const Real xs = Math::CubicCurve3 (x - Real(x0));
If the parameters are integers then x
and Real(x0)
are always the same because Real(x0)
is basically the integer part of x
and so xs
will be set to 0. After this there are more calculations to get the actual value but it becomes deterministically 0.