Closed Overdrivr closed 8 years ago
tuples looked like a first option http://www.cplusplus.com/reference/tuple/tie/
But tuples need to have their containing types in their template definition. That means one mixer definition per noise dimension
std::initializer_list is interesting http://en.cppreference.com/w/cpp/utility/initializer_list
It would allow such construct
FBM.Get({1.0, 3.2, 1.4});
Then FBM could pass the std::initializer_list to noise, and then the API could gain enormously in genericity:
Perlin(std::initializer_list coordinates)
{
switch(coordinates.size()):
case 2:
return _Perlin2D(...)
default:
// Dimensions non supported
return 0;
}
Last option is to use << overloading but it forces user to use this syntax simply for expressing coordinates, it's not good enough.
Also, don't forget to use thread_local for improving heap usage http://en.cppreference.com/w/cpp/language/storage_duration
The Set() method should disappear. Instead, noises should receive their coordinates like it was originally implemented. Also, the SetScale method should disappear and be re-integrated in the call to Get.
The problem is to keep genericity of the mixers (FBM, HMF). They should be able to pass any number of arguments to noises.
In the end, the goal is to make Get() const. This will allow to parrallelize calls without having to create one noise per thread.