aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon
diff options
context:
space:
mode:
authorMcCabe Maxsted2011-07-20 17:52:25 -0700
committerMcCabe Maxsted2011-09-08 16:10:56 -0700
commit2a4afedf90d055cca16bb0ec53542ac67d2ae2c6 (patch)
tree14a88f35d396251443575e625495af4d852627a2 /linden/indra/llcommon
parentCommitting a useful .bat file for windows (diff)
downloadmeta-impy-2a4afedf90d055cca16bb0ec53542ac67d2ae2c6.zip
meta-impy-2a4afedf90d055cca16bb0ec53542ac67d2ae2c6.tar.gz
meta-impy-2a4afedf90d055cca16bb0ec53542ac67d2ae2c6.tar.bz2
meta-impy-2a4afedf90d055cca16bb0ec53542ac67d2ae2c6.tar.xz
Added ll_frand(min, max) function
Diffstat (limited to 'linden/indra/llcommon')
-rw-r--r--linden/indra/llcommon/llrand.cpp15
-rw-r--r--linden/indra/llcommon/llrand.h5
2 files changed, 20 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llrand.cpp b/linden/indra/llcommon/llrand.cpp
index 0b2f8b8..fb2bcd3 100644
--- a/linden/indra/llcommon/llrand.cpp
+++ b/linden/indra/llcommon/llrand.cpp
@@ -156,6 +156,21 @@ F32 ll_frand(F32 val)
156 return rv; 156 return rv;
157} 157}
158 158
159F32 ll_frand(F32 min, F32 max)
160{
161 llassert(min <= max);
162 F32 rv = min + ((max - min) * ll_internal_random_float());
163 if (rv > 0)
164 {
165 if (rv >= max) return 0.0f;
166 }
167 else
168 {
169 if (rv <= min) return 0.0f;
170 }
171 return rv;
172}
173
159F64 ll_drand() 174F64 ll_drand()
160{ 175{
161 return ll_internal_random_double(); 176 return ll_internal_random_double();
diff --git a/linden/indra/llcommon/llrand.h b/linden/indra/llcommon/llrand.h
index 73ea179..0b68a17 100644
--- a/linden/indra/llcommon/llrand.h
+++ b/linden/indra/llcommon/llrand.h
@@ -83,6 +83,11 @@ LL_COMMON_API F32 ll_frand();
83LL_COMMON_API F32 ll_frand(F32 val); 83LL_COMMON_API F32 ll_frand(F32 val);
84 84
85/** 85/**
86 *@brief Generate a float from [min, max].
87 */
88LL_COMMON_API F32 ll_frand(F32 min, F32 max);
89
90/**
86 *@brief Generate a double from [0, 1.0). 91 *@brief Generate a double from [0, 1.0).
87 */ 92 */
88LL_COMMON_API F64 ll_drand(); 93LL_COMMON_API F64 ll_drand();