Browse Source

Fix noise offset not affecting domain warp
- also added domain warp to get_noise_1d

Hendrik Brucker 3 years ago
parent
commit
1654800ed7
1 changed files with 13 additions and 2 deletions
  1. 13 2
      modules/noise/fastnoise_lite.cpp

+ 13 - 2
modules/noise/fastnoise_lite.cpp

@@ -300,6 +300,12 @@ real_t FastNoiseLite::get_domain_warp_fractal_gain() const {
 // Noise interface functions.
 // Noise interface functions.
 
 
 real_t FastNoiseLite::get_noise_1d(real_t p_x) const {
 real_t FastNoiseLite::get_noise_1d(real_t p_x) const {
+	p_x += offset.x;
+	if (domain_warp_enabled) {
+		// Needed since DomainWarp expects a reference.
+		real_t y_dummy = 0;
+		_domain_warp_noise.DomainWarp(p_x, y_dummy);
+	}
 	return get_noise_2d(p_x, 0.0);
 	return get_noise_2d(p_x, 0.0);
 }
 }
 
 
@@ -308,10 +314,12 @@ real_t FastNoiseLite::get_noise_2dv(Vector2 p_v) const {
 }
 }
 
 
 real_t FastNoiseLite::get_noise_2d(real_t p_x, real_t p_y) const {
 real_t FastNoiseLite::get_noise_2d(real_t p_x, real_t p_y) const {
+	p_x += offset.x;
+	p_y += offset.y;
 	if (domain_warp_enabled) {
 	if (domain_warp_enabled) {
 		_domain_warp_noise.DomainWarp(p_x, p_y);
 		_domain_warp_noise.DomainWarp(p_x, p_y);
 	}
 	}
-	return _noise.GetNoise(p_x + offset.x, p_y + offset.y);
+	return _noise.GetNoise(p_x, p_y);
 }
 }
 
 
 real_t FastNoiseLite::get_noise_3dv(Vector3 p_v) const {
 real_t FastNoiseLite::get_noise_3dv(Vector3 p_v) const {
@@ -319,10 +327,13 @@ real_t FastNoiseLite::get_noise_3dv(Vector3 p_v) const {
 }
 }
 
 
 real_t FastNoiseLite::get_noise_3d(real_t p_x, real_t p_y, real_t p_z) const {
 real_t FastNoiseLite::get_noise_3d(real_t p_x, real_t p_y, real_t p_z) const {
+	p_x += offset.x;
+	p_y += offset.y;
+	p_z += offset.z;
 	if (domain_warp_enabled) {
 	if (domain_warp_enabled) {
 		_domain_warp_noise.DomainWarp(p_x, p_y, p_z);
 		_domain_warp_noise.DomainWarp(p_x, p_y, p_z);
 	}
 	}
-	return _noise.GetNoise(p_x + offset.x, p_y + offset.y, p_z + offset.z);
+	return _noise.GetNoise(p_x, p_y, p_z);
 }
 }
 
 
 void FastNoiseLite::_changed() {
 void FastNoiseLite::_changed() {