mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-25 13:17:22 +01:00
116 lines
7.3 KiB
C++
116 lines
7.3 KiB
C++
/*************************************************************************/
|
|
/* fastnoise_noise_params.cpp */
|
|
/*************************************************************************/
|
|
/* This file is part of: */
|
|
/* PANDEMONIUM ENGINE */
|
|
/* https://github.com/Relintai/pandemonium_engine */
|
|
/*************************************************************************/
|
|
/* Copyright (c) 2022-present Péter Magyar. */
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
/* */
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
/* a copy of this software and associated documentation files (the */
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
/* the following conditions: */
|
|
/* */
|
|
/* The above copyright notice and this permission notice shall be */
|
|
/* included in all copies or substantial portions of the Software. */
|
|
/* */
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
/*************************************************************************/
|
|
|
|
#include "fastnoise_noise_params.h"
|
|
|
|
void FastnoiseNoiseParams::setup_noise(Ref<FastNoise> noise) {
|
|
noise->set_seed(_seed);
|
|
noise->set_noise_type(_noise_type);
|
|
noise->set_interpolation(_interp);
|
|
noise->set_frequency(_freq);
|
|
noise->set_fractal_octaves(_octave_count);
|
|
noise->set_fractal_lacunarity(_lacunarity);
|
|
noise->set_fractal_gain(_gain);
|
|
noise->set_fractal_type(_type);
|
|
noise->set_cellular_distance_function(_func);
|
|
noise->set_cellular_return_type(_ret);
|
|
noise->set_gradient_perturbation_amplitude(_amp);
|
|
}
|
|
|
|
FastnoiseNoiseParams::FastnoiseNoiseParams() {
|
|
_seed = 1337;
|
|
_noise_type = FastNoise::TYPE_SIMPLEX;
|
|
_interp = FastNoise::INTERP_QUINTIC;
|
|
_freq = 0.01;
|
|
_octave_count = 3;
|
|
_lacunarity = 2;
|
|
_gain = 0.5;
|
|
_type = FastNoise::FRACTAL_FBM;
|
|
_func = FastNoise::DISTANCE_EUCLIDEAN;
|
|
_ret = FastNoise::RETURN_CELL_VALUE;
|
|
_jitter = 0.45;
|
|
_amp = 1;
|
|
}
|
|
FastnoiseNoiseParams::~FastnoiseNoiseParams() {
|
|
}
|
|
|
|
void FastnoiseNoiseParams::_bind_methods() {
|
|
ClassDB::bind_method(D_METHOD("set_seed", "seed"), &FastnoiseNoiseParams::set_seed);
|
|
ClassDB::bind_method(D_METHOD("get_seed"), &FastnoiseNoiseParams::get_seed);
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
|
|
|
|
ClassDB::bind_method(D_METHOD("set_noise_type", "type"), &FastnoiseNoiseParams::set_noise_type);
|
|
ClassDB::bind_method(D_METHOD("get_noise_type"), &FastnoiseNoiseParams::get_noise_type);
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "noise_type", PROPERTY_HINT_ENUM, FastNoise::BINDING_STRING_TYPE), "set_noise_type", "get_noise_type");
|
|
|
|
ClassDB::bind_method(D_METHOD("set_interpolation", "interp"), &FastnoiseNoiseParams::set_interpolation);
|
|
ClassDB::bind_method(D_METHOD("get_interpolation"), &FastnoiseNoiseParams::get_interpolation);
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "interpolation", PROPERTY_HINT_ENUM, FastNoise::BINDING_STRING_INTERPOLATION), "set_interpolation", "get_interpolation");
|
|
|
|
ClassDB::bind_method(D_METHOD("set_frequency", "freq"), &FastnoiseNoiseParams::set_frequency);
|
|
ClassDB::bind_method(D_METHOD("get_frequency"), &FastnoiseNoiseParams::get_frequency);
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "frequency"), "set_frequency", "get_frequency");
|
|
|
|
ClassDB::bind_method(D_METHOD("set_fractal_gain", "gain"), &FastnoiseNoiseParams::set_fractal_gain);
|
|
ClassDB::bind_method(D_METHOD("get_fractal_gain"), &FastnoiseNoiseParams::get_fractal_gain);
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "fractal_gain"), "set_fractal_gain", "get_fractal_gain");
|
|
|
|
ClassDB::bind_method(D_METHOD("set_fractal_type", "type"), &FastnoiseNoiseParams::set_fractal_type);
|
|
ClassDB::bind_method(D_METHOD("get_fractal_type"), &FastnoiseNoiseParams::get_fractal_type);
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "fractal_type", PROPERTY_HINT_ENUM, FastNoise::BINDING_STRING_FRACTAL_TYPE), "set_fractal_type", "get_fractal_type");
|
|
|
|
ClassDB::bind_method(D_METHOD("set_fractal_octaves", "octave_count"), &FastnoiseNoiseParams::set_fractal_octaves);
|
|
ClassDB::bind_method(D_METHOD("get_fractal_octaves"), &FastnoiseNoiseParams::get_fractal_octaves);
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "fractal_octaves"), "set_fractal_octaves", "get_fractal_octaves");
|
|
|
|
ClassDB::bind_method(D_METHOD("set_fractal_lacunarity", "lacunarity"), &FastnoiseNoiseParams::set_fractal_lacunarity);
|
|
ClassDB::bind_method(D_METHOD("get_fractal_lacunarity"), &FastnoiseNoiseParams::get_fractal_lacunarity);
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "fractal_lacunarity"), "set_fractal_lacunarity", "get_fractal_lacunarity");
|
|
|
|
ClassDB::bind_method(D_METHOD("set_cellular_distance_function", "func"), &FastnoiseNoiseParams::set_cellular_distance_function);
|
|
ClassDB::bind_method(D_METHOD("get_cellular_distance_function"), &FastnoiseNoiseParams::get_cellular_distance_function);
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "cellular_distance_function", PROPERTY_HINT_ENUM, FastNoise::BINDING_STRING_CELLULAR_DISTANCE_FUNCTION), "set_cellular_distance_function", "get_cellular_distance_function");
|
|
|
|
ClassDB::bind_method(D_METHOD("set_cellular_return_type", "ret"), &FastnoiseNoiseParams::set_cellular_return_type);
|
|
ClassDB::bind_method(D_METHOD("get_cellular_return_type"), &FastnoiseNoiseParams::get_cellular_return_type);
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "cellular_return_type", PROPERTY_HINT_ENUM, FastNoise::BINDING_STRING_CELLULAR_RETURN_TYPE), "set_cellular_return_type", "get_cellular_return_type");
|
|
|
|
ClassDB::bind_method(D_METHOD("set_cellular_jitter", "jitter"), &FastnoiseNoiseParams::set_cellular_jitter);
|
|
ClassDB::bind_method(D_METHOD("get_cellular_jitter"), &FastnoiseNoiseParams::get_cellular_jitter);
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "cellular_jitter"), "set_cellular_jitter", "get_cellular_jitter");
|
|
|
|
ClassDB::bind_method(D_METHOD("set_gradient_perturbation_amplitude", "amp"), &FastnoiseNoiseParams::set_gradient_perturbation_amplitude);
|
|
ClassDB::bind_method(D_METHOD("get_gradient_perturbation_amplitude"), &FastnoiseNoiseParams::get_gradient_perturbation_amplitude);
|
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "gradient_perturbation_amplitude"), "set_gradient_perturbation_amplitude", "get_gradient_perturbation_amplitude");
|
|
|
|
ClassDB::bind_method(D_METHOD("setup_noise", "noise"), &FastnoiseNoiseParams::setup_noise);
|
|
}
|