Debian Codegraph @

modules/noise/fastnoise_lite.cpp

raw symbols SCIP
1 /**************************************************************************/
2 /* fastnoise_lite.cpp */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #include "fastnoise_lite.h"
32
33 #include "core/config/engine.h"
34
35 _FastNoiseLite::FractalType FastNoiseLite::_convert_domain_warp_fractal_type_enum(DomainWarpFractalType p_domain_warp_fractal_type) {
36 _FastNoiseLite::FractalType type;
37 switch (p_domain_warp_fractal_type) {
38 case DOMAIN_WARP_FRACTAL_NONE:
39 type = _FastNoiseLite::FractalType_None;
40 break;
41 case DOMAIN_WARP_FRACTAL_PROGRESSIVE:
42 type = _FastNoiseLite::FractalType_DomainWarpProgressive;
43 break;
44 case DOMAIN_WARP_FRACTAL_INDEPENDENT:
45 type = _FastNoiseLite::FractalType_DomainWarpIndependent;
46 break;
47 default:
48 type = _FastNoiseLite::FractalType_None;
49 }
50 return type;
51 }
52
53 FastNoiseLite::FastNoiseLite() {
54 _noise.SetNoiseType((_FastNoiseLite::NoiseType)noise_type);
55 _noise.SetSeed(seed);
56 _noise.SetFrequency(frequency);
57
58 _noise.SetFractalType((_FastNoiseLite::FractalType)fractal_type);
59 _noise.SetFractalOctaves(fractal_octaves);
60 _noise.SetFractalLacunarity(fractal_lacunarity);
61 _noise.SetFractalGain(fractal_gain);
62 _noise.SetFractalWeightedStrength(fractal_weighted_strength);
63 _noise.SetFractalPingPongStrength(fractal_ping_pong_strength);
64
65 _noise.SetCellularDistanceFunction((_FastNoiseLite::CellularDistanceFunction)cellular_distance_function);
66 _noise.SetCellularReturnType((_FastNoiseLite::CellularReturnType)cellular_return_type);
67 _noise.SetCellularJitter(cellular_jitter);
68
69 _domain_warp_noise.SetDomainWarpType((_FastNoiseLite::DomainWarpType)domain_warp_type);
70 _domain_warp_noise.SetSeed(seed);
71 _domain_warp_noise.SetDomainWarpAmp(domain_warp_amplitude);
72 _domain_warp_noise.SetFrequency(domain_warp_frequency);
73 _domain_warp_noise.SetFractalType(_convert_domain_warp_fractal_type_enum(domain_warp_fractal_type));
74 _domain_warp_noise.SetFractalOctaves(domain_warp_fractal_octaves);
75 _domain_warp_noise.SetFractalLacunarity(domain_warp_fractal_lacunarity);
76 _domain_warp_noise.SetFractalGain(domain_warp_fractal_gain);
77 }
78
79 FastNoiseLite::~FastNoiseLite() {
80 }
81
82 // General settings.
83
84 void FastNoiseLite::set_noise_type(NoiseType p_noise_type) {
85 noise_type = p_noise_type;
86 _noise.SetNoiseType((_FastNoiseLite::NoiseType)p_noise_type);
87 emit_changed();
88 notify_property_list_changed();
89 }
90
91 FastNoiseLite::NoiseType FastNoiseLite::get_noise_type() const {
92 return noise_type;
93 }
94
95 void FastNoiseLite::set_seed(int p_seed) {
96 seed = p_seed;
97 _noise.SetSeed(p_seed);
98 _domain_warp_noise.SetSeed(p_seed);
99 emit_changed();
100 }
101
102 int FastNoiseLite::get_seed() const {
103 return seed;
104 }
105
106 void FastNoiseLite::set_frequency(real_t p_freq) {
107 frequency = p_freq;
108 _noise.SetFrequency(p_freq);
109 emit_changed();
110 }
111
112 real_t FastNoiseLite::get_frequency() const {
113 return frequency;
114 }
115
116 void FastNoiseLite::set_offset(Vector3 p_offset) {
117 offset = p_offset;
118 emit_changed();
119 }
120
121 Vector3 FastNoiseLite::get_offset() const {
122 return offset;
123 }
124
125 // Fractal.
126
127 void FastNoiseLite::set_fractal_type(FractalType p_type) {
128 fractal_type = p_type;
129 _noise.SetFractalType((_FastNoiseLite::FractalType)p_type);
130 emit_changed();
131 notify_property_list_changed();
132 }
133
134 FastNoiseLite::FractalType FastNoiseLite::get_fractal_type() const {
135 return fractal_type;
136 }
137
138 void FastNoiseLite::set_fractal_octaves(int p_octaves) {
139 fractal_octaves = p_octaves;
140 _noise.SetFractalOctaves(p_octaves);
141 emit_changed();
142 }
143
144 int FastNoiseLite::get_fractal_octaves() const {
145 return fractal_octaves;
146 }
147
148 void FastNoiseLite::set_fractal_lacunarity(real_t p_lacunarity) {
149 fractal_lacunarity = p_lacunarity;
150 _noise.SetFractalLacunarity(p_lacunarity);
151 emit_changed();
152 }
153
154 real_t FastNoiseLite::get_fractal_lacunarity() const {
155 return fractal_lacunarity;
156 }
157
158 void FastNoiseLite::set_fractal_gain(real_t p_gain) {
159 fractal_gain = p_gain;
160 _noise.SetFractalGain(p_gain);
161 emit_changed();
162 }
163
164 real_t FastNoiseLite::get_fractal_gain() const {
165 return fractal_gain;
166 }
167
168 void FastNoiseLite::set_fractal_weighted_strength(real_t p_weighted_strength) {
169 fractal_weighted_strength = p_weighted_strength;
170 _noise.SetFractalWeightedStrength(p_weighted_strength);
171 emit_changed();
172 }
173 real_t FastNoiseLite::get_fractal_weighted_strength() const {
174 return fractal_weighted_strength;
175 }
176
177 void FastNoiseLite::set_fractal_ping_pong_strength(real_t p_ping_pong_strength) {
178 fractal_ping_pong_strength = p_ping_pong_strength;
179 _noise.SetFractalPingPongStrength(p_ping_pong_strength);
180 emit_changed();
181 }
182 real_t FastNoiseLite::get_fractal_ping_pong_strength() const {
183 return fractal_ping_pong_strength;
184 }
185
186 // Cellular.
187
188 void FastNoiseLite::set_cellular_distance_function(CellularDistanceFunction p_func) {
189 cellular_distance_function = p_func;
190 _noise.SetCellularDistanceFunction((_FastNoiseLite::CellularDistanceFunction)p_func);
191 emit_changed();
192 }
193
194 FastNoiseLite::CellularDistanceFunction FastNoiseLite::get_cellular_distance_function() const {
195 return cellular_distance_function;
196 }
197
198 void FastNoiseLite::set_cellular_jitter(real_t p_jitter) {
199 cellular_jitter = p_jitter;
200 _noise.SetCellularJitter(p_jitter);
201 emit_changed();
202 }
203
204 real_t FastNoiseLite::get_cellular_jitter() const {
205 return cellular_jitter;
206 }
207
208 void FastNoiseLite::set_cellular_return_type(CellularReturnType p_ret) {
209 cellular_return_type = p_ret;
210 _noise.SetCellularReturnType((_FastNoiseLite::CellularReturnType)p_ret);
211 emit_changed();
212 }
213
214 FastNoiseLite::CellularReturnType FastNoiseLite::get_cellular_return_type() const {
215 return cellular_return_type;
216 }
217
218 // Domain warp specific.
219
220 void FastNoiseLite::set_domain_warp_enabled(bool p_enabled) {
221 if (domain_warp_enabled != p_enabled) {
222 domain_warp_enabled = p_enabled;
223 emit_changed();
224 notify_property_list_changed();
225 }
226 }
227
228 bool FastNoiseLite::is_domain_warp_enabled() const {
229 return domain_warp_enabled;
230 }
231
232 void FastNoiseLite::set_domain_warp_type(DomainWarpType p_domain_warp_type) {
233 domain_warp_type = p_domain_warp_type;
234 _domain_warp_noise.SetDomainWarpType((_FastNoiseLite::DomainWarpType)p_domain_warp_type);
235 emit_changed();
236 }
237
238 FastNoiseLite::DomainWarpType FastNoiseLite::get_domain_warp_type() const {
239 return domain_warp_type;
240 }
241
242 void FastNoiseLite::set_domain_warp_amplitude(real_t p_amplitude) {
243 domain_warp_amplitude = p_amplitude;
244 _domain_warp_noise.SetDomainWarpAmp(p_amplitude);
245 emit_changed();
246 }
247 real_t FastNoiseLite::get_domain_warp_amplitude() const {
248 return domain_warp_amplitude;
249 }
250
251 void FastNoiseLite::set_domain_warp_frequency(real_t p_frequency) {
252 domain_warp_frequency = p_frequency;
253 _domain_warp_noise.SetFrequency(p_frequency);
254 emit_changed();
255 }
256
257 real_t FastNoiseLite::get_domain_warp_frequency() const {
258 return domain_warp_frequency;
259 }
260
261 void FastNoiseLite::set_domain_warp_fractal_type(DomainWarpFractalType p_domain_warp_fractal_type) {
262 domain_warp_fractal_type = p_domain_warp_fractal_type;
263
264 _domain_warp_noise.SetFractalType(_convert_domain_warp_fractal_type_enum(p_domain_warp_fractal_type));
265 emit_changed();
266 }
267
268 FastNoiseLite::DomainWarpFractalType FastNoiseLite::get_domain_warp_fractal_type() const {
269 return domain_warp_fractal_type;
270 }
271
272 void FastNoiseLite::set_domain_warp_fractal_octaves(int p_octaves) {
273 domain_warp_fractal_octaves = p_octaves;
274 _domain_warp_noise.SetFractalOctaves(p_octaves);
275 emit_changed();
276 }
277
278 int FastNoiseLite::get_domain_warp_fractal_octaves() const {
279 return domain_warp_fractal_octaves;
280 }
281
282 void FastNoiseLite::set_domain_warp_fractal_lacunarity(real_t p_lacunarity) {
283 domain_warp_fractal_lacunarity = p_lacunarity;
284 _domain_warp_noise.SetFractalLacunarity(p_lacunarity);
285 emit_changed();
286 }
287
288 real_t FastNoiseLite::get_domain_warp_fractal_lacunarity() const {
289 return domain_warp_fractal_lacunarity;
290 }
291
292 void FastNoiseLite::set_domain_warp_fractal_gain(real_t p_gain) {
293 domain_warp_fractal_gain = p_gain;
294 _domain_warp_noise.SetFractalGain(p_gain);
295 emit_changed();
296 }
297
298 real_t FastNoiseLite::get_domain_warp_fractal_gain() const {
299 return domain_warp_fractal_gain;
300 }
301
302 // Noise interface functions.
303
304 real_t FastNoiseLite::get_noise_1d(real_t p_x) const {
305 p_x += offset.x;
306 if (domain_warp_enabled) {
307 // Needed since DomainWarp expects a reference.
308 real_t y_dummy = 0;
309 _domain_warp_noise.DomainWarp(p_x, y_dummy);
310 }
311 return get_noise_2d(p_x, 0.0);
312 }
313
314 real_t FastNoiseLite::get_noise_2dv(Vector2 p_v) const {
315 return get_noise_2d(p_v.x, p_v.y);
316 }
317
318 real_t FastNoiseLite::get_noise_2d(real_t p_x, real_t p_y) const {
319 p_x += offset.x;
320 p_y += offset.y;
321 if (domain_warp_enabled) {
322 _domain_warp_noise.DomainWarp(p_x, p_y);
323 }
324 return _noise.GetNoise(p_x, p_y);
325 }
326
327 real_t FastNoiseLite::get_noise_3dv(Vector3 p_v) const {
328 return get_noise_3d(p_v.x, p_v.y, p_v.z);
329 }
330
331 real_t FastNoiseLite::get_noise_3d(real_t p_x, real_t p_y, real_t p_z) const {
332 p_x += offset.x;
333 p_y += offset.y;
334 p_z += offset.z;
335 if (domain_warp_enabled) {
336 _domain_warp_noise.DomainWarp(p_x, p_y, p_z);
337 }
338 return _noise.GetNoise(p_x, p_y, p_z);
339 }
340
341 void FastNoiseLite::_changed() {
342 emit_changed();
343 }
344
345 void FastNoiseLite::_bind_methods() {
346 // General settings.
347
348 ClassDB::bind_method(D_METHOD("set_noise_type", "type"), &FastNoiseLite::set_noise_type);
349 ClassDB::bind_method(D_METHOD("get_noise_type"), &FastNoiseLite::get_noise_type);
350
351 ClassDB::bind_method(D_METHOD("set_seed", "seed"), &FastNoiseLite::set_seed);
352 ClassDB::bind_method(D_METHOD("get_seed"), &FastNoiseLite::get_seed);
353
354 ClassDB::bind_method(D_METHOD("set_frequency", "freq"), &FastNoiseLite::set_frequency);
355 ClassDB::bind_method(D_METHOD("get_frequency"), &FastNoiseLite::get_frequency);
356
357 ClassDB::bind_method(D_METHOD("set_offset", "offset"), &FastNoiseLite::set_offset);
358 ClassDB::bind_method(D_METHOD("get_offset"), &FastNoiseLite::get_offset);
359
360 // Fractal.
361
362 ClassDB::bind_method(D_METHOD("set_fractal_type", "type"), &FastNoiseLite::set_fractal_type);
363 ClassDB::bind_method(D_METHOD("get_fractal_type"), &FastNoiseLite::get_fractal_type);
364
365 ClassDB::bind_method(D_METHOD("set_fractal_octaves", "octave_count"), &FastNoiseLite::set_fractal_octaves);
366 ClassDB::bind_method(D_METHOD("get_fractal_octaves"), &FastNoiseLite::get_fractal_octaves);
367
368 ClassDB::bind_method(D_METHOD("set_fractal_lacunarity", "lacunarity"), &FastNoiseLite::set_fractal_lacunarity);
369 ClassDB::bind_method(D_METHOD("get_fractal_lacunarity"), &FastNoiseLite::get_fractal_lacunarity);
370
371 ClassDB::bind_method(D_METHOD("set_fractal_gain", "gain"), &FastNoiseLite::set_fractal_gain);
372 ClassDB::bind_method(D_METHOD("get_fractal_gain"), &FastNoiseLite::get_fractal_gain);
373
374 ClassDB::bind_method(D_METHOD("set_fractal_weighted_strength", "weighted_strength"), &FastNoiseLite::set_fractal_weighted_strength);
375 ClassDB::bind_method(D_METHOD("get_fractal_weighted_strength"), &FastNoiseLite::get_fractal_weighted_strength);
376
377 ClassDB::bind_method(D_METHOD("set_fractal_ping_pong_strength", "ping_pong_strength"), &FastNoiseLite::set_fractal_ping_pong_strength);
378 ClassDB::bind_method(D_METHOD("get_fractal_ping_pong_strength"), &FastNoiseLite::get_fractal_ping_pong_strength);
379
380 // Cellular.
381
382 ClassDB::bind_method(D_METHOD("set_cellular_distance_function", "func"), &FastNoiseLite::set_cellular_distance_function);
383 ClassDB::bind_method(D_METHOD("get_cellular_distance_function"), &FastNoiseLite::get_cellular_distance_function);
384
385 ClassDB::bind_method(D_METHOD("set_cellular_jitter", "jitter"), &FastNoiseLite::set_cellular_jitter);
386 ClassDB::bind_method(D_METHOD("get_cellular_jitter"), &FastNoiseLite::get_cellular_jitter);
387
388 ClassDB::bind_method(D_METHOD("set_cellular_return_type", "ret"), &FastNoiseLite::set_cellular_return_type);
389 ClassDB::bind_method(D_METHOD("get_cellular_return_type"), &FastNoiseLite::get_cellular_return_type);
390
391 // Domain warp.
392
393 ClassDB::bind_method(D_METHOD("set_domain_warp_enabled", "domain_warp_enabled"), &FastNoiseLite::set_domain_warp_enabled);
394 ClassDB::bind_method(D_METHOD("is_domain_warp_enabled"), &FastNoiseLite::is_domain_warp_enabled);
395
396 ClassDB::bind_method(D_METHOD("set_domain_warp_type", "domain_warp_type"), &FastNoiseLite::set_domain_warp_type);
397 ClassDB::bind_method(D_METHOD("get_domain_warp_type"), &FastNoiseLite::get_domain_warp_type);
398
399 ClassDB::bind_method(D_METHOD("set_domain_warp_amplitude", "domain_warp_amplitude"), &FastNoiseLite::set_domain_warp_amplitude);
400 ClassDB::bind_method(D_METHOD("get_domain_warp_amplitude"), &FastNoiseLite::get_domain_warp_amplitude);
401
402 ClassDB::bind_method(D_METHOD("set_domain_warp_frequency", "domain_warp_frequency"), &FastNoiseLite::set_domain_warp_frequency);
403 ClassDB::bind_method(D_METHOD("get_domain_warp_frequency"), &FastNoiseLite::get_domain_warp_frequency);
404
405 ClassDB::bind_method(D_METHOD("set_domain_warp_fractal_type", "domain_warp_fractal_type"), &FastNoiseLite::set_domain_warp_fractal_type);
406 ClassDB::bind_method(D_METHOD("get_domain_warp_fractal_type"), &FastNoiseLite::get_domain_warp_fractal_type);
407
408 ClassDB::bind_method(D_METHOD("set_domain_warp_fractal_octaves", "domain_warp_octave_count"), &FastNoiseLite::set_domain_warp_fractal_octaves);
409 ClassDB::bind_method(D_METHOD("get_domain_warp_fractal_octaves"), &FastNoiseLite::get_domain_warp_fractal_octaves);
410
411 ClassDB::bind_method(D_METHOD("set_domain_warp_fractal_lacunarity", "domain_warp_lacunarity"), &FastNoiseLite::set_domain_warp_fractal_lacunarity);
412 ClassDB::bind_method(D_METHOD("get_domain_warp_fractal_lacunarity"), &FastNoiseLite::get_domain_warp_fractal_lacunarity);
413
414 ClassDB::bind_method(D_METHOD("set_domain_warp_fractal_gain", "domain_warp_gain"), &FastNoiseLite::set_domain_warp_fractal_gain);
415 ClassDB::bind_method(D_METHOD("get_domain_warp_fractal_gain"), &FastNoiseLite::get_domain_warp_fractal_gain);
416
417 ClassDB::bind_method(D_METHOD("_changed"), &FastNoiseLite::_changed);
418
419 ADD_PROPERTY(PropertyInfo(Variant::INT, "noise_type", PROPERTY_HINT_ENUM, "Simplex,Simplex Smooth,Cellular,Perlin,Value Cubic,Value"), "set_noise_type", "get_noise_type");
420 ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
421 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "frequency", PROPERTY_HINT_RANGE, ".0001,1,.0001,exp"), "set_frequency", "get_frequency");
422 ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "offset", PROPERTY_HINT_RANGE, "-1000,1000,0.01,or_less,or_greater"), "set_offset", "get_offset");
423
424 ADD_GROUP("Fractal", "fractal_");
425 ADD_PROPERTY(PropertyInfo(Variant::INT, "fractal_type", PROPERTY_HINT_ENUM, "None,FBM,Ridged,Ping-Pong"), "set_fractal_type", "get_fractal_type");
426 ADD_PROPERTY(PropertyInfo(Variant::INT, "fractal_octaves", PROPERTY_HINT_RANGE, "1,10,1"), "set_fractal_octaves", "get_fractal_octaves");
427 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fractal_lacunarity"), "set_fractal_lacunarity", "get_fractal_lacunarity");
428 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fractal_gain"), "set_fractal_gain", "get_fractal_gain");
429 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fractal_weighted_strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_fractal_weighted_strength", "get_fractal_weighted_strength");
430 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fractal_ping_pong_strength"), "set_fractal_ping_pong_strength", "get_fractal_ping_pong_strength");
431
432 ADD_GROUP("Cellular", "cellular_");
433 ADD_PROPERTY(PropertyInfo(Variant::INT, "cellular_distance_function", PROPERTY_HINT_ENUM, "Euclidean,Euclidean Squared,Manhattan,Hybrid"), "set_cellular_distance_function", "get_cellular_distance_function");
434 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cellular_jitter"), "set_cellular_jitter", "get_cellular_jitter");
435 ADD_PROPERTY(PropertyInfo(Variant::INT, "cellular_return_type", PROPERTY_HINT_ENUM, "Cell Value,Distance,Distance2,Distance2Add,Distance2Sub,Distance2Mul,Distance2Div"), "set_cellular_return_type", "get_cellular_return_type");
436
437 ADD_GROUP("Domain Warp", "domain_warp_");
438 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "domain_warp_enabled", PROPERTY_HINT_GROUP_ENABLE), "set_domain_warp_enabled", "is_domain_warp_enabled");
439 ADD_PROPERTY(PropertyInfo(Variant::INT, "domain_warp_type", PROPERTY_HINT_ENUM, "Simplex,Simplex Reduced,Basic Grid"), "set_domain_warp_type", "get_domain_warp_type");
440 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "domain_warp_amplitude"), "set_domain_warp_amplitude", "get_domain_warp_amplitude");
441 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "domain_warp_frequency"), "set_domain_warp_frequency", "get_domain_warp_frequency");
442 ADD_PROPERTY(PropertyInfo(Variant::INT, "domain_warp_fractal_type", PROPERTY_HINT_ENUM, "None,Progressive,Independent"), "set_domain_warp_fractal_type", "get_domain_warp_fractal_type");
443 ADD_PROPERTY(PropertyInfo(Variant::INT, "domain_warp_fractal_octaves", PROPERTY_HINT_RANGE, "1,10,1"), "set_domain_warp_fractal_octaves", "get_domain_warp_fractal_octaves");
444 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "domain_warp_fractal_lacunarity"), "set_domain_warp_fractal_lacunarity", "get_domain_warp_fractal_lacunarity");
445 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "domain_warp_fractal_gain"), "set_domain_warp_fractal_gain", "get_domain_warp_fractal_gain");
446
447 BIND_ENUM_CONSTANT(TYPE_VALUE);
448 BIND_ENUM_CONSTANT(TYPE_VALUE_CUBIC);
449 BIND_ENUM_CONSTANT(TYPE_PERLIN);
450 BIND_ENUM_CONSTANT(TYPE_CELLULAR);
451 BIND_ENUM_CONSTANT(TYPE_SIMPLEX);
452 BIND_ENUM_CONSTANT(TYPE_SIMPLEX_SMOOTH);
453
454 BIND_ENUM_CONSTANT(FRACTAL_NONE);
455 BIND_ENUM_CONSTANT(FRACTAL_FBM);
456 BIND_ENUM_CONSTANT(FRACTAL_RIDGED);
457 BIND_ENUM_CONSTANT(FRACTAL_PING_PONG);
458
459 BIND_ENUM_CONSTANT(DISTANCE_EUCLIDEAN);
460 BIND_ENUM_CONSTANT(DISTANCE_EUCLIDEAN_SQUARED);
461 BIND_ENUM_CONSTANT(DISTANCE_MANHATTAN);
462 BIND_ENUM_CONSTANT(DISTANCE_HYBRID);
463
464 BIND_ENUM_CONSTANT(RETURN_CELL_VALUE);
465 BIND_ENUM_CONSTANT(RETURN_DISTANCE);
466 BIND_ENUM_CONSTANT(RETURN_DISTANCE2);
467 BIND_ENUM_CONSTANT(RETURN_DISTANCE2_ADD);
468 BIND_ENUM_CONSTANT(RETURN_DISTANCE2_SUB);
469 BIND_ENUM_CONSTANT(RETURN_DISTANCE2_MUL);
470 BIND_ENUM_CONSTANT(RETURN_DISTANCE2_DIV);
471
472 BIND_ENUM_CONSTANT(DOMAIN_WARP_SIMPLEX);
473 BIND_ENUM_CONSTANT(DOMAIN_WARP_SIMPLEX_REDUCED);
474 BIND_ENUM_CONSTANT(DOMAIN_WARP_BASIC_GRID);
475
476 BIND_ENUM_CONSTANT(DOMAIN_WARP_FRACTAL_NONE);
477 BIND_ENUM_CONSTANT(DOMAIN_WARP_FRACTAL_PROGRESSIVE);
478 BIND_ENUM_CONSTANT(DOMAIN_WARP_FRACTAL_INDEPENDENT);
479 }
480
481 void FastNoiseLite::_validate_property(PropertyInfo &p_property) const {
482 if (!Engine::get_singleton()->is_editor_hint()) {
483 return;
484 }
485 if (p_property.name.begins_with("cellular") && get_noise_type() != TYPE_CELLULAR) {
486 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
487 return;
488 }
489
490 if (p_property.name != "fractal_type" && p_property.name.begins_with("fractal") && get_fractal_type() == FRACTAL_NONE) {
491 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
492 return;
493 }
494
495 if (p_property.name == "fractal_ping_pong_strength" && get_fractal_type() != FRACTAL_PING_PONG) {
496 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
497 return;
498 }
499 }