star-sf

Set of surface and volume scattering functions
git clone git://git.meso-star.fr/star-sf.git
Log | Files | Refs | README | LICENSE

commit 5d6ed65f64f2cd87d92abb8953dc307606b3e349
parent a4e69f379e5389abcea746f2ed54a1f7184769e8
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Thu, 24 Aug 2017 17:56:02 +0200

Small performance improvement.

Diffstat:
Msrc/ssf_bsdf.c | 12++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/ssf_bsdf.c b/src/ssf_bsdf.c @@ -151,7 +151,7 @@ ssf_bsdf_sample int* type, double* out_pdf) { - double cumul[MAX_BxDFs]; + double cumul; double R; double r; double pdf; @@ -170,16 +170,12 @@ ssf_bsdf_sample bsdf_normalize_weights(bsdf); - /* Compute the cumulative from the normalized weights of the BxDFs */ - cumul[0] = bsdf->weights[0]; - FOR_EACH(i, 1, bsdf->nbxdfs) { - cumul[i] = bsdf->weights[i] + cumul[i-1]; - } - /* Sample a component */ r = ssp_rng_canonical(rng); + cumul = bsdf->weights[0]; FOR_EACH(i, 0, bsdf->nbxdfs-1) { - if(r <= cumul[i]) break; + if(r <= cumul) break; + cumul += bsdf->weights[i]; } /* Sample a direction from the selected component */