summaryrefslogtreecommitdiff
path: root/indra/llmath/llquantize.h
diff options
context:
space:
mode:
authorDon Kjer <don@lindenlab.com>2007-09-28 23:32:53 +0000
committerDon Kjer <don@lindenlab.com>2007-09-28 23:32:53 +0000
commitb089fc559a5dc527ed5e0422e82abf3b1dd5f1b2 (patch)
treebaa68e98452406c03a3dbe21c99a901f769c8890 /indra/llmath/llquantize.h
parentab8dd2b55008090a1f18fb107f897c736d98a760 (diff)
EFFECTIVE MERGE: svn merge -r 68999:69916 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance into release
** This should be the last merge from branches/maintenance. All future merges will be from new maintenance-# branches off release ** ACTUAL MERGE: svn merge -r70609:70621 svn+ssh://svn/svn/linden/branches/maintenance-0-qa-r70556 RELATED MERGE: svn merge -r69921:70316 svn+ssh://svn/svn/linden/branches/maintenance-0-qa
Diffstat (limited to 'indra/llmath/llquantize.h')
-rw-r--r--indra/llmath/llquantize.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/indra/llmath/llquantize.h b/indra/llmath/llquantize.h
index 8aa03628f2..93cd16c13a 100644
--- a/indra/llmath/llquantize.h
+++ b/indra/llmath/llquantize.h
@@ -20,6 +20,18 @@ const U8 FIRSTVALIDCHAR = 54;
const U8 MAXSTRINGVAL = U8MAX - FIRSTVALIDCHAR; //we don't allow newline or null
+inline U16 F32_to_U16_ROUND(F32 val, F32 lower, F32 upper)
+{
+ val = llclamp(val, lower, upper);
+ // make sure that the value is positive and normalized to <0, 1>
+ val -= lower;
+ val /= (upper - lower);
+
+ // round the value. Sreturn the U16
+ return (U16)(llround(val*U16MAX));
+}
+
+
inline U16 F32_to_U16(F32 val, F32 lower, F32 upper)
{
val = llclamp(val, lower, upper);
@@ -47,6 +59,19 @@ inline F32 U16_to_F32(U16 ival, F32 lower, F32 upper)
return val;
}
+
+inline U8 F32_to_U8_ROUND(F32 val, F32 lower, F32 upper)
+{
+ val = llclamp(val, lower, upper);
+ // make sure that the value is positive and normalized to <0, 1>
+ val -= lower;
+ val /= (upper - lower);
+
+ // return the rounded U8
+ return (U8)(llround(val*U8MAX));
+}
+
+
inline U8 F32_to_U8(F32 val, F32 lower, F32 upper)
{
val = llclamp(val, lower, upper);