[Bf-blender-cvs] [660eea8cf4c] blender2.8: BLI_rand : add BLI_halton_3D

Clément Foucault noreply at git.blender.org
Fri Oct 27 23:28:31 CEST 2017


Commit: 660eea8cf4c21cbaf0b11e4800aa38fb83afb895
Author: Clément Foucault
Date:   Tue Oct 24 02:01:10 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB660eea8cf4c21cbaf0b11e4800aa38fb83afb895

BLI_rand : add BLI_halton_3D

===================================================================

M	source/blender/blenlib/BLI_rand.h
M	source/blender/blenlib/intern/rand.c

===================================================================

diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h
index 0ef971bf41f..69b23b2473f 100644
--- a/source/blender/blenlib/BLI_rand.h
+++ b/source/blender/blenlib/BLI_rand.h
@@ -106,6 +106,7 @@ int   BLI_rng_thread_rand(RNG_THREAD_ARRAY *rngarr, int thread) ATTR_WARN_UNUSED
 /** Return the _n_th number of the given low-discrepancy sequence. */
 void BLI_halton_1D(unsigned int prime, double offset, int n, double *r);
 void BLI_halton_2D(unsigned int prime[2], double offset[2], int n, double *r);
+void BLI_halton_3D(unsigned int prime[3], double offset[3], int n, double *r);
 void BLI_hammersley_1D(unsigned int n, double *r);
 
 /** Return the whole low-discrepancy sequence up to _n_. */
diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c
index a501d38abb7..9ab39dda9d0 100644
--- a/source/blender/blenlib/intern/rand.c
+++ b/source/blender/blenlib/intern/rand.c
@@ -402,6 +402,17 @@ void BLI_halton_2D(unsigned int prime[2], double offset[2], int n, double *r)
 	}
 }
 
+void BLI_halton_3D(unsigned int prime[3], double offset[3], int n, double *r)
+{
+	const double invprimes[3] = {1.0 / (double)prime[0], 1.0 / (double)prime[1], 1.0 / (double)prime[2]};
+
+	for (int s = 0; s < n; s++) {
+		for (int i = 0; i < 3; i++) {
+			r[i] = halton_ex(invprimes[i], &offset[i]);
+		}
+	}
+}
+
 void BLI_halton_2D_sequence(unsigned int prime[2], double offset[2], int n, double *r)
 {
 	const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]};



More information about the Bf-blender-cvs mailing list