aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/llsmoothstep.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:42 -0500
committerJacek Antonelli2008-08-15 23:45:42 -0500
commitce28e056c20bf2723f565bbf464b87781ec248a2 (patch)
treeef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/llcommon/llsmoothstep.h
parentSecond Life viewer sources 1.19.1.4b (diff)
downloadmeta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz
Second Life viewer sources 1.20.2
Diffstat (limited to 'linden/indra/llcommon/llsmoothstep.h')
-rw-r--r--linden/indra/llcommon/llsmoothstep.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llsmoothstep.h b/linden/indra/llcommon/llsmoothstep.h
new file mode 100644
index 0000000..c2b3447
--- /dev/null
+++ b/linden/indra/llcommon/llsmoothstep.h
@@ -0,0 +1,50 @@
1/**
2 * @file llsmoothstep.h
3 * @brief Smoothstep - transition from 0 to 1 - function, first and second derivatives all continuous (smooth)
4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LL_LLSMOOTHSTEP_H
33#define LL_LLSMOOTHSTEP_H
34
35template <class LLDATATYPE>
36inline LLDATATYPE llsmoothstep(const LLDATATYPE& edge0, const LLDATATYPE& edge1, const LLDATATYPE& value)
37{
38 if (value < edge0)
39 return (LLDATATYPE)0;
40
41 if (value >= edge1)
42 return (LLDATATYPE)1;
43
44 // Scale/bias into [0..1] range
45 LLDATATYPE scaled_value = (value - edge0) / (edge1 - edge0);
46
47 return scaled_value * scaled_value * (3 - 2 * scaled_value);
48}
49
50#endif // LL_LLSMOOTHSTEP_H