1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/**
* @file llcriticaldamp.h
* @brief A lightweight class that calculates critical damping constants once
* per frame.
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLCRITICALDAMP_H
#define LL_LLCRITICALDAMP_H
#include <map>
#include "llframetimer.h"
// These enums each represent one fixed-time delta value
// that we interpolate once given the actual sTimeDelta time
// that has passed. This allows us to calculate the interp portion
// of those values once and then look them up repeatedly per frame.
//
enum InterpDelta
{
InterpDelta_0_025, // 0.025
InterpDeltaTeenier = InterpDelta_0_025,
InterpDeltaFolderOpenTime = InterpDelta_0_025,
InterpDeltaFolderCloseTime = InterpDelta_0_025,
InterpDeltaCameraFocusHalfLife = InterpDelta_0_025, // USED TO BE ZERO....
InterpDelta_0_05, // 0.05
InterpDeltaTeeny = InterpDelta_0_05,
InterpDelta_0_06, // 0.06
InterpDeltaObjectDampingConstant = InterpDelta_0_06,
InterpDeltaCameraZoomHalfLife = InterpDelta_0_06,
InterpDeltaFovZoomHalfLife = InterpDelta_0_06,
InterpDeltaManipulatorScaleHalfLife = InterpDelta_0_06,
InterpDeltaContextFadeTime = InterpDelta_0_06,
InterpDelta_0_10, // 0.10
InterpDeltaSmaller = InterpDelta_0_10,
InterpDeltaTargetLagHalfLife = InterpDelta_0_10,
InterpDeltaSpeedAdjustTime = InterpDelta_0_10,
InterpDelta_0_15, // 0.15
InterpDeltaFadeWeight = InterpDelta_0_15,
InterpDeltaHeadLookAtLagHalfLife = InterpDelta_0_15,
InterpDelta_0_20, // 0.20
InterpDeltaSmall = InterpDelta_0_20,
InterpDeltaTorsoLagHalfLife = InterpDelta_0_20,
InterpDeltaPositionDampingTC = InterpDelta_0_20,
InterpDelta_0_25, // 0.25
InterpDeltaCameraLagHalfLife = InterpDelta_0_25,
InterpDeltaTorsoTargetLagHalfLife = InterpDelta_0_25,
InterpDeltaTorsoLookAtLagHalfLife = InterpDelta_0_25,
InterpDelta_0_30, // 0.3
InterpDeltaSmallish = InterpDelta_0_30,
// Dynamically set interpolants which use setInterpolantConstant
//
InterpDeltaCameraSmoothingHalfLife,
InterpDeltaBehindnessLag,
InterpDeltaFocusLag,
InterpDeltaPositionLag,
InterpDeltaOpenTime,
InterpDeltaCloseTime,
kNumCachedInterpolants
};
class LL_COMMON_API LLCriticalDamp
{
public:
LLCriticalDamp();
// Updates all the known interp delta values for fast lookup in calls to getInterpolant(InterpDelta)
//
static void updateInterpolants();
static inline void setInterpolantConstant(InterpDelta whichDelta, const F32 time_constant)
{
llassert(whichDelta < kNumCachedInterpolants);
sInterpolants[whichDelta] = time_constant;
}
// ACCESSORS
static inline F32 getInterpolant(InterpDelta whichDelta)
{
llassert(whichDelta < kNumCachedInterpolants);
return sInterpolatedValues[whichDelta];
}
static inline F32 getInterpolant(const F32 time_constant)
{
return llclamp((sTimeDelta / time_constant), 0.0f, 1.0f);
}
protected:
static LLFrameTimer sInternalTimer; // frame timer for calculating deltas
//static std::map<F32, F32> sInterpolants;
static F32 sInterpolants[kNumCachedInterpolants];
static F32 sInterpolatedValues[kNumCachedInterpolants];
static F32 sTimeDelta;
};
#endif // LL_LLCRITICALDAMP_H
|