| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "noise.h" |
| 34 |
|
| 35 |
#include "thirdparty/misc/FastNoiseLite.h" |
| 36 |
|
| 37 |
typedef fastnoiselite::FastNoiseLite _FastNoiseLite; |
| 38 |
|
| 39 |
class FastNoiseLite : public Noise { |
| 40 |
GDCLASS(FastNoiseLite, Noise); |
| 41 |
OBJ_SAVE_TYPE(FastNoiseLite); |
| 42 |
|
| 43 |
public: |
| 44 |
enum NoiseType { |
| 45 |
TYPE_SIMPLEX = _FastNoiseLite::NoiseType_OpenSimplex2, |
| 46 |
TYPE_SIMPLEX_SMOOTH = _FastNoiseLite::NoiseType_OpenSimplex2S, |
| 47 |
TYPE_CELLULAR = _FastNoiseLite::NoiseType_Cellular, |
| 48 |
TYPE_PERLIN = _FastNoiseLite::NoiseType_Perlin, |
| 49 |
TYPE_VALUE_CUBIC = _FastNoiseLite::NoiseType_ValueCubic, |
| 50 |
TYPE_VALUE = _FastNoiseLite::NoiseType_Value, |
| 51 |
}; |
| 52 |
|
| 53 |
enum FractalType { |
| 54 |
FRACTAL_NONE = _FastNoiseLite::FractalType_None, |
| 55 |
FRACTAL_FBM = _FastNoiseLite::FractalType_FBm, |
| 56 |
FRACTAL_RIDGED = _FastNoiseLite::FractalType_Ridged, |
| 57 |
FRACTAL_PING_PONG = _FastNoiseLite::FractalType_PingPong, |
| 58 |
}; |
| 59 |
|
| 60 |
enum CellularDistanceFunction { |
| 61 |
DISTANCE_EUCLIDEAN = _FastNoiseLite::CellularDistanceFunction_Euclidean, |
| 62 |
DISTANCE_EUCLIDEAN_SQUARED = _FastNoiseLite::CellularDistanceFunction_EuclideanSq, |
| 63 |
DISTANCE_MANHATTAN = _FastNoiseLite::CellularDistanceFunction_Manhattan, |
| 64 |
DISTANCE_HYBRID = _FastNoiseLite::CellularDistanceFunction_Hybrid |
| 65 |
}; |
| 66 |
|
| 67 |
enum CellularReturnType { |
| 68 |
RETURN_CELL_VALUE = _FastNoiseLite::CellularReturnType_CellValue, |
| 69 |
RETURN_DISTANCE = _FastNoiseLite::CellularReturnType_Distance, |
| 70 |
RETURN_DISTANCE2 = _FastNoiseLite::CellularReturnType_Distance2, |
| 71 |
RETURN_DISTANCE2_ADD = _FastNoiseLite::CellularReturnType_Distance2Add, |
| 72 |
RETURN_DISTANCE2_SUB = _FastNoiseLite::CellularReturnType_Distance2Sub, |
| 73 |
RETURN_DISTANCE2_MUL = _FastNoiseLite::CellularReturnType_Distance2Mul, |
| 74 |
RETURN_DISTANCE2_DIV = _FastNoiseLite::CellularReturnType_Distance2Div |
| 75 |
}; |
| 76 |
|
| 77 |
enum DomainWarpType { |
| 78 |
DOMAIN_WARP_SIMPLEX = _FastNoiseLite::DomainWarpType_OpenSimplex2, |
| 79 |
DOMAIN_WARP_SIMPLEX_REDUCED = _FastNoiseLite::DomainWarpType_OpenSimplex2Reduced, |
| 80 |
DOMAIN_WARP_BASIC_GRID = _FastNoiseLite::DomainWarpType_BasicGrid |
| 81 |
}; |
| 82 |
|
| 83 |
enum DomainWarpFractalType { |
| 84 |
DOMAIN_WARP_FRACTAL_NONE, |
| 85 |
DOMAIN_WARP_FRACTAL_PROGRESSIVE, |
| 86 |
DOMAIN_WARP_FRACTAL_INDEPENDENT |
| 87 |
}; |
| 88 |
|
| 89 |
protected: |
| 90 |
static void _bind_methods(); |
| 91 |
void _validate_property(PropertyInfo &p_property) const; |
| 92 |
|
| 93 |
private: |
| 94 |
_FastNoiseLite _noise; |
| 95 |
_FastNoiseLite _domain_warp_noise; |
| 96 |
|
| 97 |
Vector3 offset; |
| 98 |
NoiseType noise_type = TYPE_SIMPLEX_SMOOTH; |
| 99 |
|
| 100 |
int seed = 0; |
| 101 |
real_t frequency = 0.01; |
| 102 |
|
| 103 |
|
| 104 |
FractalType fractal_type = FRACTAL_FBM; |
| 105 |
int fractal_octaves = 5; |
| 106 |
real_t fractal_lacunarity = 2; |
| 107 |
real_t fractal_gain = 0.5; |
| 108 |
real_t fractal_weighted_strength = 0; |
| 109 |
real_t fractal_ping_pong_strength = 2; |
| 110 |
|
| 111 |
|
| 112 |
CellularDistanceFunction cellular_distance_function = DISTANCE_EUCLIDEAN; |
| 113 |
CellularReturnType cellular_return_type = RETURN_DISTANCE; |
| 114 |
real_t cellular_jitter = 1.0; |
| 115 |
|
| 116 |
|
| 117 |
bool domain_warp_enabled = false; |
| 118 |
DomainWarpType domain_warp_type = DOMAIN_WARP_SIMPLEX; |
| 119 |
real_t domain_warp_amplitude = 30.0; |
| 120 |
real_t domain_warp_frequency = 0.05; |
| 121 |
DomainWarpFractalType domain_warp_fractal_type = DOMAIN_WARP_FRACTAL_PROGRESSIVE; |
| 122 |
int domain_warp_fractal_octaves = 5; |
| 123 |
real_t domain_warp_fractal_lacunarity = 6; |
| 124 |
real_t domain_warp_fractal_gain = 0.5; |
| 125 |
|
| 126 |
|
| 127 |
_FastNoiseLite::FractalType _convert_domain_warp_fractal_type_enum(DomainWarpFractalType p_domain_warp_fractal_type); |
| 128 |
|
| 129 |
public: |
| 130 |
FastNoiseLite(); |
| 131 |
~FastNoiseLite(); |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
void set_noise_type(NoiseType p_noise_type); |
| 136 |
NoiseType get_noise_type() const; |
| 137 |
|
| 138 |
void set_seed(int p_seed); |
| 139 |
int get_seed() const; |
| 140 |
|
| 141 |
void set_frequency(real_t p_freq); |
| 142 |
real_t get_frequency() const; |
| 143 |
|
| 144 |
void set_offset(Vector3 p_offset); |
| 145 |
Vector3 get_offset() const; |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
void set_fractal_type(FractalType p_type); |
| 150 |
FractalType get_fractal_type() const; |
| 151 |
|
| 152 |
void set_fractal_octaves(int p_octaves); |
| 153 |
int get_fractal_octaves() const; |
| 154 |
|
| 155 |
void set_fractal_lacunarity(real_t p_lacunarity); |
| 156 |
real_t get_fractal_lacunarity() const; |
| 157 |
|
| 158 |
void set_fractal_gain(real_t p_gain); |
| 159 |
real_t get_fractal_gain() const; |
| 160 |
|
| 161 |
void set_fractal_weighted_strength(real_t p_weighted_strength); |
| 162 |
real_t get_fractal_weighted_strength() const; |
| 163 |
|
| 164 |
void set_fractal_ping_pong_strength(real_t p_ping_pong_strength); |
| 165 |
real_t get_fractal_ping_pong_strength() const; |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
void set_cellular_distance_function(CellularDistanceFunction p_func); |
| 170 |
CellularDistanceFunction get_cellular_distance_function() const; |
| 171 |
|
| 172 |
void set_cellular_return_type(CellularReturnType p_ret); |
| 173 |
CellularReturnType get_cellular_return_type() const; |
| 174 |
|
| 175 |
void set_cellular_jitter(real_t p_jitter); |
| 176 |
real_t get_cellular_jitter() const; |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
void set_domain_warp_enabled(bool p_enabled); |
| 181 |
bool is_domain_warp_enabled() const; |
| 182 |
|
| 183 |
void set_domain_warp_type(DomainWarpType p_domain_warp_type); |
| 184 |
DomainWarpType get_domain_warp_type() const; |
| 185 |
|
| 186 |
void set_domain_warp_amplitude(real_t p_amplitude); |
| 187 |
real_t get_domain_warp_amplitude() const; |
| 188 |
|
| 189 |
void set_domain_warp_frequency(real_t p_frequency); |
| 190 |
real_t get_domain_warp_frequency() const; |
| 191 |
|
| 192 |
void set_domain_warp_fractal_type(DomainWarpFractalType p_domain_warp_fractal_type); |
| 193 |
DomainWarpFractalType get_domain_warp_fractal_type() const; |
| 194 |
|
| 195 |
void set_domain_warp_fractal_octaves(int p_octaves); |
| 196 |
int get_domain_warp_fractal_octaves() const; |
| 197 |
|
| 198 |
void set_domain_warp_fractal_lacunarity(real_t p_lacunarity); |
| 199 |
real_t get_domain_warp_fractal_lacunarity() const; |
| 200 |
|
| 201 |
void set_domain_warp_fractal_gain(real_t p_gain); |
| 202 |
real_t get_domain_warp_fractal_gain() const; |
| 203 |
|
| 204 |
|
| 205 |
real_t get_noise_1d(real_t p_x) const override; |
| 206 |
|
| 207 |
real_t get_noise_2dv(Vector2 p_v) const override; |
| 208 |
real_t get_noise_2d(real_t p_x, real_t p_y) const override; |
| 209 |
|
| 210 |
real_t get_noise_3dv(Vector3 p_v) const override; |
| 211 |
real_t get_noise_3d(real_t p_x, real_t p_y, real_t p_z) const override; |
| 212 |
|
| 213 |
void _changed(); |
| 214 |
}; |
| 215 |
|
| 216 |
VARIANT_ENUM_CAST(FastNoiseLite::NoiseType); |
| 217 |
VARIANT_ENUM_CAST(FastNoiseLite::FractalType); |
| 218 |
VARIANT_ENUM_CAST(FastNoiseLite::CellularDistanceFunction); |
| 219 |
VARIANT_ENUM_CAST(FastNoiseLite::CellularReturnType); |
| 220 |
VARIANT_ENUM_CAST(FastNoiseLite::DomainWarpType); |
| 221 |
VARIANT_ENUM_CAST(FastNoiseLite::DomainWarpFractalType); |