diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llcharacter/llmotion.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llcharacter/llmotion.cpp')
-rw-r--r-- | linden/indra/llcharacter/llmotion.cpp | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/linden/indra/llcharacter/llmotion.cpp b/linden/indra/llcharacter/llmotion.cpp new file mode 100644 index 0000000..d2343ab --- /dev/null +++ b/linden/indra/llcharacter/llmotion.cpp | |||
@@ -0,0 +1,150 @@ | |||
1 | /** | ||
2 | * @file llmotion.cpp | ||
3 | * @brief Implementation of LLMotion class. | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | //----------------------------------------------------------------------------- | ||
29 | // Header Files | ||
30 | //----------------------------------------------------------------------------- | ||
31 | #include "linden_common.h" | ||
32 | |||
33 | #include "llmotion.h" | ||
34 | #include "llcriticaldamp.h" | ||
35 | |||
36 | //----------------------------------------------------------------------------- | ||
37 | //----------------------------------------------------------------------------- | ||
38 | // LLMotion class | ||
39 | //----------------------------------------------------------------------------- | ||
40 | //----------------------------------------------------------------------------- | ||
41 | |||
42 | //----------------------------------------------------------------------------- | ||
43 | // LLMotion() | ||
44 | // Class Constructor | ||
45 | //----------------------------------------------------------------------------- | ||
46 | LLMotion::LLMotion( const LLUUID &id ) | ||
47 | { | ||
48 | mActivationTimestamp = 0.f; | ||
49 | mStopTimestamp = 0.f; | ||
50 | mSendStopTimestamp = F32_MAX; | ||
51 | mResidualWeight = 0.f; | ||
52 | mFadeWeight = 1.f; | ||
53 | mStopped = TRUE; | ||
54 | mActive = FALSE; | ||
55 | mDeactivateCallback = NULL; | ||
56 | |||
57 | memset(&mJointSignature[0][0], 0, sizeof(U8) * LL_CHARACTER_MAX_JOINTS); | ||
58 | memset(&mJointSignature[1][0], 0, sizeof(U8) * LL_CHARACTER_MAX_JOINTS); | ||
59 | memset(&mJointSignature[2][0], 0, sizeof(U8) * LL_CHARACTER_MAX_JOINTS); | ||
60 | |||
61 | mID = id; | ||
62 | } | ||
63 | |||
64 | //----------------------------------------------------------------------------- | ||
65 | // ~LLMotion() | ||
66 | // Class Destructor | ||
67 | //----------------------------------------------------------------------------- | ||
68 | LLMotion::~LLMotion() | ||
69 | { | ||
70 | } | ||
71 | |||
72 | //----------------------------------------------------------------------------- | ||
73 | // fadeOut() | ||
74 | //----------------------------------------------------------------------------- | ||
75 | void LLMotion::fadeOut() | ||
76 | { | ||
77 | if (mFadeWeight > 0.01f) | ||
78 | { | ||
79 | mFadeWeight = lerp(mFadeWeight, 0.f, LLCriticalDamp::getInterpolant(0.15f)); | ||
80 | } | ||
81 | else | ||
82 | { | ||
83 | mFadeWeight = 0.f; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | //----------------------------------------------------------------------------- | ||
88 | // fadeIn() | ||
89 | //----------------------------------------------------------------------------- | ||
90 | void LLMotion::fadeIn() | ||
91 | { | ||
92 | if (mFadeWeight < 0.99f) | ||
93 | { | ||
94 | mFadeWeight = lerp(mFadeWeight, 1.f, LLCriticalDamp::getInterpolant(0.15f)); | ||
95 | } | ||
96 | else | ||
97 | { | ||
98 | mFadeWeight = 1.f; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | //----------------------------------------------------------------------------- | ||
103 | // addJointState() | ||
104 | //----------------------------------------------------------------------------- | ||
105 | void LLMotion::addJointState(LLJointState* jointState) | ||
106 | { | ||
107 | mPose.addJointState(jointState); | ||
108 | S32 priority = jointState->getPriority(); | ||
109 | if (priority == LLJoint::USE_MOTION_PRIORITY) | ||
110 | { | ||
111 | priority = getPriority(); | ||
112 | } | ||
113 | |||
114 | U32 usage = jointState->getUsage(); | ||
115 | |||
116 | // for now, usage is everything | ||
117 | mJointSignature[0][jointState->getJoint()->getJointNum()] = (usage & LLJointState::POS) ? (0xff >> (7 - priority)) : 0; | ||
118 | mJointSignature[1][jointState->getJoint()->getJointNum()] = (usage & LLJointState::ROT) ? (0xff >> (7 - priority)) : 0; | ||
119 | mJointSignature[2][jointState->getJoint()->getJointNum()] = (usage & LLJointState::SCALE) ? (0xff >> (7 - priority)) : 0; | ||
120 | } | ||
121 | |||
122 | void LLMotion::setDeactivateCallback( void (*cb)(void *), void* userdata ) | ||
123 | { | ||
124 | mDeactivateCallback = cb; | ||
125 | mDeactivateCallbackUserData = userdata; | ||
126 | } | ||
127 | |||
128 | //----------------------------------------------------------------------------- | ||
129 | // activate() | ||
130 | //----------------------------------------------------------------------------- | ||
131 | void LLMotion::activate() | ||
132 | { | ||
133 | mStopped = FALSE; | ||
134 | mActive = TRUE; | ||
135 | onActivate(); | ||
136 | } | ||
137 | |||
138 | //----------------------------------------------------------------------------- | ||
139 | // deactivate() | ||
140 | //----------------------------------------------------------------------------- | ||
141 | void LLMotion::deactivate() | ||
142 | { | ||
143 | mActive = FALSE; | ||
144 | |||
145 | if (mDeactivateCallback) (*mDeactivateCallback)(mDeactivateCallbackUserData); | ||
146 | |||
147 | onDeactivate(); | ||
148 | } | ||
149 | |||
150 | // End | ||