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_FastNoiseLite::FractalType FastNoiseLite::_convert_domain_warp_fractal_type_enum(DomainWarpFractalType p_domain_warp_fractal_type) {
34 _FastNoiseLite::FractalType type;
35 switch (p_domain_warp_fractal_type) {
36 case DOMAIN_WARP_FRACTAL_NONE:
37 type = _FastNoiseLite::FractalType_None;
38 break;
39 case DOMAIN_WARP_FRACTAL_PROGRESSIVE:
40 type = _FastNoiseLite::FractalType_DomainWarpProgressive;
41 break;
42 case DOMAIN_WARP_FRACTAL_INDEPENDENT:
43 type = _FastNoiseLite::FractalType_DomainWarpIndependent;
44 break;
45 default:
46 type = _FastNoiseLite::FractalType_None;
47 }
48 return type;
49}
50
51FastNoiseLite::FastNoiseLite() {
52 _noise.SetNoiseType((_FastNoiseLite::NoiseType)noise_type);
53 _noise.SetSeed(seed);
54 _noise.SetFrequency(frequency);
55
56 _noise.SetFractalType((_FastNoiseLite::FractalType)fractal_type);
57 _noise.SetFractalOctaves(fractal_octaves);
58 _noise.SetFractalLacunarity(fractal_lacunarity);
59 _noise.SetFractalGain(fractal_gain);
60 _noise.SetFractalWeightedStrength(fractal_weighted_strength);
61 _noise.SetFractalPingPongStrength(fractal_ping_pong_strength);
62
63 _noise.SetCellularDistanceFunction((_FastNoiseLite::CellularDistanceFunction)cellular_distance_function);
64 _noise.SetCellularReturnType((_FastNoiseLite::CellularReturnType)cellular_return_type);
65 _noise.SetCellularJitter(cellular_jitter);
66
67 _domain_warp_noise.SetDomainWarpType((_FastNoiseLite::DomainWarpType)domain_warp_type);
68 _domain_warp_noise.SetSeed(seed);
69 _domain_warp_noise.SetDomainWarpAmp(domain_warp_amplitude);
70 _domain_warp_noise.SetFrequency(domain_warp_frequency);
71 _domain_warp_noise.SetFractalType(_convert_domain_warp_fractal_type_enum(domain_warp_fractal_type));
72 _domain_warp_noise.SetFractalOctaves(domain_warp_fractal_octaves);
73 _domain_warp_noise.SetFractalLacunarity(domain_warp_fractal_lacunarity);
74 _domain_warp_noise.SetFractalGain(domain_warp_fractal_gain);
75}
76
77FastNoiseLite::~FastNoiseLite() {
78}
79
80// General settings.
81
82void FastNoiseLite::set_noise_type(NoiseType p_noise_type) {
83 noise_type = p_noise_type;
84 _noise.SetNoiseType((_FastNoiseLite::NoiseType)p_noise_type);
85 emit_changed();
86 notify_property_list_changed();
87}
88
89FastNoiseLite::NoiseType FastNoiseLite::get_noise_type() const {
90 return noise_type;
91}
92
93void FastNoiseLite::set_seed(int p_seed) {
94 seed = p_seed;
95 _noise.SetSeed(p_seed);
96 _domain_warp_noise.SetSeed(p_seed);
97 emit_changed();
98}
99
100int FastNoiseLite::get_seed() const {
101 return seed;
102}
103
104void FastNoiseLite::set_frequency(real_t p_freq) {
105 frequency = p_freq;
106 _noise.SetFrequency(p_freq);
107 emit_changed();
108}
109
110real_t FastNoiseLite::get_frequency() const {
111 return frequency;
112}
113
114void FastNoiseLite::set_offset(Vector3 p_offset) {
115 offset = p_offset;
116 emit_changed();
117}
118
119Vector3 FastNoiseLite::get_offset() const {
120 return offset;
121}
122
123// Fractal.
124
125void FastNoiseLite::set_fractal_type(FractalType p_type) {
126 fractal_type = p_type;
127 _noise.SetFractalType((_FastNoiseLite::FractalType)p_type);
128 emit_changed();
129 notify_property_list_changed();
130}
131
132FastNoiseLite::FractalType FastNoiseLite::get_fractal_type() const {
133 return fractal_type;
134}
135
136void FastNoiseLite::set_fractal_octaves(int p_octaves) {
137 fractal_octaves = p_octaves;
138 _noise.SetFractalOctaves(p_octaves);
139 emit_changed();
140}
141
142int FastNoiseLite::get_fractal_octaves() const {
143 return fractal_octaves;
144}
145
146void FastNoiseLite::set_fractal_lacunarity(real_t p_lacunarity) {
147 fractal_lacunarity = p_lacunarity;
148 _noise.SetFractalLacunarity(p_lacunarity);
149 emit_changed();
150}
151
152real_t FastNoiseLite::get_fractal_lacunarity() const {
153 return fractal_lacunarity;
154}
155
156void FastNoiseLite::set_fractal_gain(real_t p_gain) {
157 fractal_gain = p_gain;
158 _noise.SetFractalGain(p_gain);
159 emit_changed();
160}
161
162real_t FastNoiseLite::get_fractal_gain() const {
163 return fractal_gain;
164}
165
166void FastNoiseLite::set_fractal_weighted_strength(real_t p_weighted_strength) {
167 fractal_weighted_strength = p_weighted_strength;
168 _noise.SetFractalWeightedStrength(p_weighted_strength);
169 emit_changed();
170}
171real_t FastNoiseLite::get_fractal_weighted_strength() const {
172 return fractal_weighted_strength;
173}
174
175void FastNoiseLite::set_fractal_ping_pong_strength(real_t p_ping_pong_strength) {
176 fractal_ping_pong_strength = p_ping_pong_strength;
177 _noise.SetFractalPingPongStrength(p_ping_pong_strength);
178 emit_changed();
179}
180real_t FastNoiseLite::get_fractal_ping_pong_strength() const {
181 return fractal_ping_pong_strength;
182}
183
184// Cellular.
185
186void FastNoiseLite::set_cellular_distance_function(CellularDistanceFunction p_func) {
187 cellular_distance_function = p_func;
188 _noise.SetCellularDistanceFunction((_FastNoiseLite::CellularDistanceFunction)p_func);
189 emit_changed();
190}
191
192FastNoiseLite::CellularDistanceFunction FastNoiseLite::get_cellular_distance_function() const {
193 return cellular_distance_function;
194}
195
196void FastNoiseLite::set_cellular_jitter(real_t p_jitter) {
197 cellular_jitter = p_jitter;
198 _noise.SetCellularJitter(p_jitter);
199 emit_changed();
200}
201
202real_t FastNoiseLite::get_cellular_jitter() const {
203 return cellular_jitter;
204}
205
206void FastNoiseLite::set_cellular_return_type(CellularReturnType p_ret) {
207 cellular_return_type = p_ret;
208 _noise.SetCellularReturnType((_FastNoiseLite::CellularReturnType)p_ret);
209 emit_changed();
210}
211
212FastNoiseLite::CellularReturnType FastNoiseLite::get_cellular_return_type() const {
213 return cellular_return_type;
214}
215
216// Domain warp specific.
217
218void FastNoiseLite::set_domain_warp_enabled(bool p_enabled) {
219 if (domain_warp_enabled != p_enabled) {
220 domain_warp_enabled = p_enabled;
221 emit_changed();
222 notify_property_list_changed();
223 }
224}
225
226bool FastNoiseLite::is_domain_warp_enabled() const {
227 return domain_warp_enabled;
228}
229
230void FastNoiseLite::set_domain_warp_type(DomainWarpType p_domain_warp_type) {
231 domain_warp_type = p_domain_warp_type;
232 _domain_warp_noise.SetDomainWarpType((_FastNoiseLite::DomainWarpType)p_domain_warp_type);
233 emit_changed();
234}
235
236FastNoiseLite::DomainWarpType FastNoiseLite::get_domain_warp_type() const {
237 return domain_warp_type;
238}
239
240void FastNoiseLite::set_domain_warp_amplitude(real_t p_amplitude) {
241 domain_warp_amplitude = p_amplitude;
242 _domain_warp_noise.SetDomainWarpAmp(p_amplitude);
243 emit_changed();
244}
245real_t FastNoiseLite::get_domain_warp_amplitude() const {
246 return domain_warp_amplitude;
247}
248
249void FastNoiseLite::set_domain_warp_frequency(real_t p_frequency) {
250 domain_warp_frequency = p_frequency;
251 _domain_warp_noise.SetFrequency(p_frequency);
252 emit_changed();
253}
254
255real_t FastNoiseLite::get_domain_warp_frequency() const {
256 return domain_warp_frequency;
257}
258
259void FastNoiseLite::set_domain_warp_fractal_type(DomainWarpFractalType p_domain_warp_fractal_type) {
260 domain_warp_fractal_type = p_domain_warp_fractal_type;
261
262 _domain_warp_noise.SetFractalType(_convert_domain_warp_fractal_type_enum(p_domain_warp_fractal_type));
263 emit_changed();
264}
265
266FastNoiseLite::DomainWarpFractalType FastNoiseLite::get_domain_warp_fractal_type() const {
267 return domain_warp_fractal_type;
268}
269
270void FastNoiseLite::set_domain_warp_fractal_octaves(int p_octaves) {
271 domain_warp_fractal_octaves = p_octaves;
272 _domain_warp_noise.SetFractalOctaves(p_octaves);
273 emit_changed();
274}
275
276int FastNoiseLite::get_domain_warp_fractal_octaves() const {
277 return domain_warp_fractal_octaves;
278}
279
280void FastNoiseLite::set_domain_warp_fractal_lacunarity(real_t p_lacunarity) {
281 domain_warp_fractal_lacunarity = p_lacunarity;
282 _domain_warp_noise.SetFractalLacunarity(p_lacunarity);
283 emit_changed();
284}
285
286real_t FastNoiseLite::get_domain_warp_fractal_lacunarity() const {
287 return domain_warp_fractal_lacunarity;
288}
289
290void FastNoiseLite::set_domain_warp_fractal_gain(real_t p_gain) {
291 domain_warp_fractal_gain = p_gain;
292 _domain_warp_noise.SetFractalGain(p_gain);
293 emit_changed();
294}
295
296real_t FastNoiseLite::get_domain_warp_fractal_gain() const {
297 return domain_warp_fractal_gain;
298}
299
300// Noise interface functions.
301
302real_t FastNoiseLite::get_noise_1d(real_t p_x) const {
303 p_x += offset.x;
304 if (domain_warp_enabled) {
305 // Needed since DomainWarp expects a reference.
306 real_t y_dummy = 0;
307 _domain_warp_noise.DomainWarp(p_x, y_dummy);
308 }
309 return get_noise_2d(p_x, 0.0);
310}
311
312real_t FastNoiseLite::get_noise_2dv(Vector2 p_v) const {
313 return get_noise_2d(p_v.x, p_v.y);
314}
315
316real_t FastNoiseLite::get_noise_2d(real_t p_x, real_t p_y) const {
317 p_x += offset.x;
318 p_y += offset.y;
319 if (domain_warp_enabled) {
320 _domain_warp_noise.DomainWarp(p_x, p_y);
321 }
322 return _noise.GetNoise(p_x, p_y);
323}
324
325real_t FastNoiseLite::get_noise_3dv(Vector3 p_v) const {
326 return get_noise_3d(p_v.x, p_v.y, p_v.z);
327}
328
329real_t FastNoiseLite::get_noise_3d(real_t p_x, real_t p_y, real_t p_z) const {
330 p_x += offset.x;
331 p_y += offset.y;
332 p_z += offset.z;
333 if (domain_warp_enabled) {
334 _domain_warp_noise.DomainWarp(p_x, p_y, p_z);
335 }
336 return _noise.GetNoise(p_x, p_y, p_z);
337}
338
339void FastNoiseLite::_changed() {
340 emit_changed();
341}
342
343void FastNoiseLite::_bind_methods() {
344 // General settings.
345
346 ClassDB::bind_method(D_METHOD("set_noise_type", "type"), &FastNoiseLite::set_noise_type);
347 ClassDB::bind_method(D_METHOD("get_noise_type"), &FastNoiseLite::get_noise_type);
348
349 ClassDB::bind_method(D_METHOD("set_seed", "seed"), &FastNoiseLite::set_seed);
350 ClassDB::bind_method(D_METHOD("get_seed"), &FastNoiseLite::get_seed);
351
352 ClassDB::bind_method(D_METHOD("set_frequency", "freq"), &FastNoiseLite::set_frequency);
353 ClassDB::bind_method(D_METHOD("get_frequency"), &FastNoiseLite::get_frequency);
354
355 ClassDB::bind_method(D_METHOD("set_offset", "offset"), &FastNoiseLite::set_offset);
356 ClassDB::bind_method(D_METHOD("get_offset"), &FastNoiseLite::get_offset);
357
358 // Fractal.
359
360 ClassDB::bind_method(D_METHOD("set_fractal_type", "type"), &FastNoiseLite::set_fractal_type);
361 ClassDB::bind_method(D_METHOD("get_fractal_type"), &FastNoiseLite::get_fractal_type);
362
363 ClassDB::bind_method(D_METHOD("set_fractal_octaves", "octave_count"), &FastNoiseLite::set_fractal_octaves);
364 ClassDB::bind_method(D_METHOD("get_fractal_octaves"), &FastNoiseLite::get_fractal_octaves);
365
366 ClassDB::bind_method(D_METHOD("set_fractal_lacunarity", "lacunarity"), &FastNoiseLite::set_fractal_lacunarity);
367 ClassDB::bind_method(D_METHOD("get_fractal_lacunarity"), &FastNoiseLite::get_fractal_lacunarity);
368
369 ClassDB::bind_method(D_METHOD("set_fractal_gain", "gain"), &FastNoiseLite::set_fractal_gain);
370 ClassDB::bind_method(D_METHOD("get_fractal_gain"), &FastNoiseLite::get_fractal_gain);
371
372 ClassDB::bind_method(D_METHOD("set_fractal_weighted_strength", "weighted_strength"), &FastNoiseLite::set_fractal_weighted_strength);
373 ClassDB::bind_method(D_METHOD("get_fractal_weighted_strength"), &FastNoiseLite::get_fractal_weighted_strength);
374
375 ClassDB::bind_method(D_METHOD("set_fractal_ping_pong_strength", "ping_pong_strength"), &FastNoiseLite::set_fractal_ping_pong_strength);
376 ClassDB::bind_method(D_METHOD("get_fractal_ping_pong_strength"), &FastNoiseLite::get_fractal_ping_pong_strength);
377
378 // Cellular.
379
380 ClassDB::bind_method(D_METHOD("set_cellular_distance_function", "func"), &FastNoiseLite::set_cellular_distance_function);
381 ClassDB::bind_method(D_METHOD("get_cellular_distance_function"), &FastNoiseLite::get_cellular_distance_function);
382
383 ClassDB::bind_method(D_METHOD("set_cellular_jitter", "jitter"), &FastNoiseLite::set_cellular_jitter);
384 ClassDB::bind_method(D_METHOD("get_cellular_jitter"), &FastNoiseLite::get_cellular_jitter);
385
386 ClassDB::bind_method(D_METHOD("set_cellular_return_type", "ret"), &FastNoiseLite::set_cellular_return_type);
387 ClassDB::bind_method(D_METHOD("get_cellular_return_type"), &FastNoiseLite::get_cellular_return_type);
388
389 // Domain warp.
390
391 ClassDB::bind_method(D_METHOD("set_domain_warp_enabled", "domain_warp_enabled"), &FastNoiseLite::set_domain_warp_enabled);
392 ClassDB::bind_method(D_METHOD("is_domain_warp_enabled"), &FastNoiseLite::is_domain_warp_enabled);
393
394 ClassDB::bind_method(D_METHOD("set_domain_warp_type", "domain_warp_type"), &FastNoiseLite::set_domain_warp_type);
395 ClassDB::bind_method(D_METHOD("get_domain_warp_type"), &FastNoiseLite::get_domain_warp_type);
396
397 ClassDB::bind_method(D_METHOD("set_domain_warp_amplitude", "domain_warp_amplitude"), &FastNoiseLite::set_domain_warp_amplitude);
398 ClassDB::bind_method(D_METHOD("get_domain_warp_amplitude"), &FastNoiseLite::get_domain_warp_amplitude);
399
400 ClassDB::bind_method(D_METHOD("set_domain_warp_frequency", "domain_warp_frequency"), &FastNoiseLite::set_domain_warp_frequency);
401 ClassDB::bind_method(D_METHOD("get_domain_warp_frequency"), &FastNoiseLite::get_domain_warp_frequency);
402
403 ClassDB::bind_method(D_METHOD("set_domain_warp_fractal_type", "domain_warp_fractal_type"), &FastNoiseLite::set_domain_warp_fractal_type);
404 ClassDB::bind_method(D_METHOD("get_domain_warp_fractal_type"), &FastNoiseLite::get_domain_warp_fractal_type);
405
406 ClassDB::bind_method(D_METHOD("set_domain_warp_fractal_octaves", "domain_warp_octave_count"), &FastNoiseLite::set_domain_warp_fractal_octaves);
407 ClassDB::bind_method(D_METHOD("get_domain_warp_fractal_octaves"), &FastNoiseLite::get_domain_warp_fractal_octaves);
408
409 ClassDB::bind_method(D_METHOD("set_domain_warp_fractal_lacunarity", "domain_warp_lacunarity"), &FastNoiseLite::set_domain_warp_fractal_lacunarity);
410 ClassDB::bind_method(D_METHOD("get_domain_warp_fractal_lacunarity"), &FastNoiseLite::get_domain_warp_fractal_lacunarity);
411
412 ClassDB::bind_method(D_METHOD("set_domain_warp_fractal_gain", "domain_warp_gain"), &FastNoiseLite::set_domain_warp_fractal_gain);
413 ClassDB::bind_method(D_METHOD("get_domain_warp_fractal_gain"), &FastNoiseLite::get_domain_warp_fractal_gain);
414
415 ClassDB::bind_method(D_METHOD("_changed"), &FastNoiseLite::_changed);
416
417 ADD_PROPERTY(PropertyInfo(Variant::INT, "noise_type", PROPERTY_HINT_ENUM, "Simplex,Simplex Smooth,Cellular,Perlin,Value Cubic,Value"), "set_noise_type", "get_noise_type");
418 ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
419 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "frequency", PROPERTY_HINT_RANGE, ".0001,1,.0001"), "set_frequency", "get_frequency");
420 ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "offset", PROPERTY_HINT_RANGE, "-999999999,999999999,0.01"), "set_offset", "get_offset");
421
422 ADD_GROUP("Fractal", "fractal_");
423 ADD_PROPERTY(PropertyInfo(Variant::INT, "fractal_type", PROPERTY_HINT_ENUM, "None,FBM,Ridged,Ping-Pong"), "set_fractal_type", "get_fractal_type");
424 ADD_PROPERTY(PropertyInfo(Variant::INT, "fractal_octaves", PROPERTY_HINT_RANGE, "1,10,1"), "set_fractal_octaves", "get_fractal_octaves");
425 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fractal_lacunarity"), "set_fractal_lacunarity", "get_fractal_lacunarity");
426 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fractal_gain"), "set_fractal_gain", "get_fractal_gain");
427 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fractal_weighted_strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_fractal_weighted_strength", "get_fractal_weighted_strength");
428 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fractal_ping_pong_strength"), "set_fractal_ping_pong_strength", "get_fractal_ping_pong_strength");
429
430 ADD_GROUP("Cellular", "cellular_");
431 ADD_PROPERTY(PropertyInfo(Variant::INT, "cellular_distance_function", PROPERTY_HINT_ENUM, "Euclidean,Euclidean Squared,Manhattan,Hybrid"), "set_cellular_distance_function", "get_cellular_distance_function");
432 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cellular_jitter"), "set_cellular_jitter", "get_cellular_jitter");
433 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");
434
435 ADD_GROUP("Domain Warp", "domain_warp_");
436 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "domain_warp_enabled"), "set_domain_warp_enabled", "is_domain_warp_enabled");
437 ADD_PROPERTY(PropertyInfo(Variant::INT, "domain_warp_type", PROPERTY_HINT_ENUM, "Simplex,Simplex Reduced,Basic Grid"), "set_domain_warp_type", "get_domain_warp_type");
438 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "domain_warp_amplitude"), "set_domain_warp_amplitude", "get_domain_warp_amplitude");
439 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "domain_warp_frequency"), "set_domain_warp_frequency", "get_domain_warp_frequency");
440 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");
441 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");
442 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "domain_warp_fractal_lacunarity"), "set_domain_warp_fractal_lacunarity", "get_domain_warp_fractal_lacunarity");
443 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "domain_warp_fractal_gain"), "set_domain_warp_fractal_gain", "get_domain_warp_fractal_gain");
444
445 BIND_ENUM_CONSTANT(TYPE_VALUE);
446 BIND_ENUM_CONSTANT(TYPE_VALUE_CUBIC);
447 BIND_ENUM_CONSTANT(TYPE_PERLIN);
448 BIND_ENUM_CONSTANT(TYPE_CELLULAR);
449 BIND_ENUM_CONSTANT(TYPE_SIMPLEX);
450 BIND_ENUM_CONSTANT(TYPE_SIMPLEX_SMOOTH);
451
452 BIND_ENUM_CONSTANT(FRACTAL_NONE);
453 BIND_ENUM_CONSTANT(FRACTAL_FBM);
454 BIND_ENUM_CONSTANT(FRACTAL_RIDGED);
455 BIND_ENUM_CONSTANT(FRACTAL_PING_PONG);
456
457 BIND_ENUM_CONSTANT(DISTANCE_EUCLIDEAN);
458 BIND_ENUM_CONSTANT(DISTANCE_EUCLIDEAN_SQUARED);
459 BIND_ENUM_CONSTANT(DISTANCE_MANHATTAN);
460 BIND_ENUM_CONSTANT(DISTANCE_HYBRID);
461
462 BIND_ENUM_CONSTANT(RETURN_CELL_VALUE);
463 BIND_ENUM_CONSTANT(RETURN_DISTANCE);
464 BIND_ENUM_CONSTANT(RETURN_DISTANCE2);
465 BIND_ENUM_CONSTANT(RETURN_DISTANCE2_ADD);
466 BIND_ENUM_CONSTANT(RETURN_DISTANCE2_SUB);
467 BIND_ENUM_CONSTANT(RETURN_DISTANCE2_MUL);
468 BIND_ENUM_CONSTANT(RETURN_DISTANCE2_DIV);
469
470 BIND_ENUM_CONSTANT(DOMAIN_WARP_SIMPLEX);
471 BIND_ENUM_CONSTANT(DOMAIN_WARP_SIMPLEX_REDUCED);
472 BIND_ENUM_CONSTANT(DOMAIN_WARP_BASIC_GRID);
473
474 BIND_ENUM_CONSTANT(DOMAIN_WARP_FRACTAL_NONE);
475 BIND_ENUM_CONSTANT(DOMAIN_WARP_FRACTAL_PROGRESSIVE);
476 BIND_ENUM_CONSTANT(DOMAIN_WARP_FRACTAL_INDEPENDENT);
477}
478
479void FastNoiseLite::_validate_property(PropertyInfo &p_property) const {
480 if (p_property.name.begins_with("cellular") && get_noise_type() != TYPE_CELLULAR) {
481 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
482 return;
483 }
484
485 if (p_property.name != "fractal_type" && p_property.name.begins_with("fractal") && get_fractal_type() == FRACTAL_NONE) {
486 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
487 return;
488 }
489
490 if (p_property.name == "fractal_ping_pong_strength" && get_fractal_type() != FRACTAL_PING_PONG) {
491 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
492 return;
493 }
494
495 if (p_property.name != "domain_warp_enabled" && p_property.name.begins_with("domain_warp") && !domain_warp_enabled) {
496 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
497 return;
498 }
499}
500