Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-06-14 17:24:55 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-06-14 17:25:39 +0300
commitb9c9b87fa62edfd880074ca4a5e39cdc3fb20206 (patch)
treef1c4c153ce1bb68b2ee06ca3c7416c08e6bb3ad2 /source/blender/compositor
parent3a36cbdfde85aa4461e6907d49e3afa45ac2dfbb (diff)
Cleanup: remove BLI_frand ugly global random generator usage from compositor.
Diffstat (limited to 'source/blender/compositor')
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h1
2 files changed, 8 insertions, 1 deletions
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
index 651c336452e..1ebb0f93939 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
@@ -26,6 +26,7 @@ extern "C" {
# include "BLI_math.h"
# include "BLI_utildefines.h"
# include "BLI_rand.h"
+# include "PIL_time.h"
}
ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation()
@@ -59,6 +60,10 @@ void ScreenLensDistortionOperation::initExecution()
{
this->m_inputProgram = this->getInputSocketReader(0);
this->initMutex();
+
+ uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX);
+ rng_seed ^= (uint)GET_INT_FROM_POINTER(m_inputProgram);
+ this->m_rng = BLI_rng_new(rng_seed);
this->m_cx = 0.5f * (float)getWidth();
this->m_cy = 0.5f * (float)getHeight();
@@ -142,7 +147,7 @@ void ScreenLensDistortionOperation::accumulate(MemoryBuffer *buffer,
float dk4 = m_dk4[a];
for (float z = 0; z < ds; ++z) {
- float tz = (z + (m_jitter ? BLI_frand() : 0.5f)) * sd;
+ float tz = (z + (m_jitter ? BLI_rng_get_float(m_rng) : 0.5f)) * sd;
float t = 1.0f - (k4 + tz * dk4) * r_sq;
float xy[2];
@@ -192,6 +197,7 @@ void ScreenLensDistortionOperation::deinitExecution()
{
this->deinitMutex();
this->m_inputProgram = NULL;
+ BLI_rng_free(this->m_rng);
}
void ScreenLensDistortionOperation::determineUV(float result[6], float x, float y) const
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
index 648a7a6e551..71df73ebd8c 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
@@ -31,6 +31,7 @@ private:
* Cached reference to the inputProgram
*/
SocketReader *m_inputProgram;
+ struct RNG *m_rng;
bool m_fit;
bool m_jitter;