aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcharacter/llkeyframemotionparam.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llcharacter/llkeyframemotionparam.cpp')
-rw-r--r--linden/indra/llcharacter/llkeyframemotionparam.cpp53
1 files changed, 27 insertions, 26 deletions
diff --git a/linden/indra/llcharacter/llkeyframemotionparam.cpp b/linden/indra/llcharacter/llkeyframemotionparam.cpp
index 106c02c..0e7388c 100644
--- a/linden/indra/llcharacter/llkeyframemotionparam.cpp
+++ b/linden/indra/llcharacter/llkeyframemotionparam.cpp
@@ -76,7 +76,7 @@ LLKeyframeMotionParam::~LLKeyframeMotionParam()
76 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) 76 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
77 { 77 {
78 const ParameterizedMotion& paramMotion = *iter2; 78 const ParameterizedMotion& paramMotion = *iter2;
79 delete paramMotion.first; // note - deletes the structure; ParameterizedMotion pair remains intact 79 delete paramMotion.mMotion;
80 } 80 }
81 motionList.clear(); 81 motionList.clear();
82 } 82 }
@@ -102,32 +102,32 @@ LLMotion::LLMotionInitStatus LLKeyframeMotionParam::onInitialize(LLCharacter *ch
102 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) 102 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
103 { 103 {
104 const ParameterizedMotion& paramMotion = *iter2; 104 const ParameterizedMotion& paramMotion = *iter2;
105 LLMotion* motion = paramMotion.mMotion;
106 motion->onInitialize(character);
105 107
106 paramMotion.first->onInitialize(character); 108 if (motion->getDuration() > mEaseInDuration)
107
108 if (paramMotion.first->getDuration() > mEaseInDuration)
109 { 109 {
110 mEaseInDuration = paramMotion.first->getEaseInDuration(); 110 mEaseInDuration = motion->getEaseInDuration();
111 } 111 }
112 112
113 if (paramMotion.first->getEaseOutDuration() > mEaseOutDuration) 113 if (motion->getEaseOutDuration() > mEaseOutDuration)
114 { 114 {
115 mEaseOutDuration = paramMotion.first->getEaseOutDuration(); 115 mEaseOutDuration = motion->getEaseOutDuration();
116 } 116 }
117 117
118 if (paramMotion.first->getDuration() > mDuration) 118 if (motion->getDuration() > mDuration)
119 { 119 {
120 mDuration = paramMotion.first->getDuration(); 120 mDuration = motion->getDuration();
121 } 121 }
122 122
123 if (paramMotion.first->getPriority() > mPriority) 123 if (motion->getPriority() > mPriority)
124 { 124 {
125 mPriority = paramMotion.first->getPriority(); 125 mPriority = motion->getPriority();
126 } 126 }
127 127
128 LLPose *pose = paramMotion.first->getPose(); 128 LLPose *pose = motion->getPose();
129 129
130 mPoseBlender.addMotion(paramMotion.first); 130 mPoseBlender.addMotion(motion);
131 for (LLJointState *jsp = pose->getFirstJointState(); jsp; jsp = pose->getNextJointState()) 131 for (LLJointState *jsp = pose->getFirstJointState(); jsp; jsp = pose->getNextJointState())
132 { 132 {
133 LLPose *blendedPose = mPoseBlender.getBlendedPose(); 133 LLPose *blendedPose = mPoseBlender.getBlendedPose();
@@ -151,7 +151,7 @@ BOOL LLKeyframeMotionParam::onActivate()
151 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) 151 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
152 { 152 {
153 const ParameterizedMotion& paramMotion = *iter2; 153 const ParameterizedMotion& paramMotion = *iter2;
154 paramMotion.first->activate(); 154 paramMotion.mMotion->activate(mActivationTimestamp);
155 } 155 }
156 } 156 }
157 return TRUE; 157 return TRUE;
@@ -173,8 +173,8 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask)
173 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) 173 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
174 { 174 {
175 const ParameterizedMotion& paramMotion = *iter2; 175 const ParameterizedMotion& paramMotion = *iter2;
176// llinfos << "Weight for pose " << paramMotion.first->getName() << " is " << paramMotion.first->getPose()->getWeight() << llendl; 176// llinfos << "Weight for pose " << paramMotion.mMotion->getName() << " is " << paramMotion.mMotion->getPose()->getWeight() << llendl;
177 paramMotion.first->getPose()->setWeight(0.f); 177 paramMotion.mMotion->getPose()->setWeight(0.f);
178 } 178 }
179 } 179 }
180 180
@@ -190,6 +190,7 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask)
190 continue; 190 continue;
191 } 191 }
192 192
193 // DANGER! Do not modify mParameterizedMotions while using these pointers!
193 const ParameterizedMotion* firstMotion = NULL; 194 const ParameterizedMotion* firstMotion = NULL;
194 const ParameterizedMotion* secondMotion = NULL; 195 const ParameterizedMotion* secondMotion = NULL;
195 196
@@ -197,9 +198,9 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask)
197 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) 198 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
198 { 199 {
199 const ParameterizedMotion& paramMotion = *iter2; 200 const ParameterizedMotion& paramMotion = *iter2;
200 paramMotion.first->onUpdate(time, joint_mask); 201 paramMotion.mMotion->onUpdate(time, joint_mask);
201 202
202 F32 distToParam = paramMotion.second - *paramValue; 203 F32 distToParam = paramMotion.mParam - *paramValue;
203 204
204 if ( distToParam <= 0.f) 205 if ( distToParam <= 0.f)
205 { 206 {
@@ -227,12 +228,12 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask)
227 LLPose *secondPose; 228 LLPose *secondPose;
228 229
229 if (firstMotion) 230 if (firstMotion)
230 firstPose = firstMotion->first->getPose(); 231 firstPose = firstMotion->mMotion->getPose();
231 else 232 else
232 firstPose = NULL; 233 firstPose = NULL;
233 234
234 if (secondMotion) 235 if (secondMotion)
235 secondPose = secondMotion->first->getPose(); 236 secondPose = secondMotion->mMotion->getPose();
236 else 237 else
237 secondPose = NULL; 238 secondPose = NULL;
238 239
@@ -243,7 +244,7 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask)
243 { 244 {
244 firstPose->setWeight(weightFactor); 245 firstPose->setWeight(weightFactor);
245 } 246 }
246 else if (firstMotion->second == secondMotion->second) 247 else if (firstMotion->mParam == secondMotion->mParam)
247 { 248 {
248 firstPose->setWeight(0.5f * weightFactor); 249 firstPose->setWeight(0.5f * weightFactor);
249 secondPose->setWeight(0.5f * weightFactor); 250 secondPose->setWeight(0.5f * weightFactor);
@@ -251,8 +252,8 @@ BOOL LLKeyframeMotionParam::onUpdate(F32 time, U8* joint_mask)
251 else 252 else
252 { 253 {
253 F32 first_weight = 1.f - 254 F32 first_weight = 1.f -
254 ((llclamp(*paramValue - firstMotion->second, 0.f, (secondMotion->second - firstMotion->second))) / 255 ((llclamp(*paramValue - firstMotion->mParam, 0.f, (secondMotion->mParam - firstMotion->mParam))) /
255 (secondMotion->second - firstMotion->second)); 256 (secondMotion->mParam - firstMotion->mParam));
256 first_weight = llclamp(first_weight, 0.f, 1.f); 257 first_weight = llclamp(first_weight, 0.f, 1.f);
257 258
258 F32 second_weight = 1.f - first_weight; 259 F32 second_weight = 1.f - first_weight;
@@ -290,7 +291,7 @@ void LLKeyframeMotionParam::onDeactivate()
290 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) 291 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
291 { 292 {
292 const ParameterizedMotion& paramMotion = *iter2; 293 const ParameterizedMotion& paramMotion = *iter2;
293 paramMotion.first->onDeactivate(); 294 paramMotion.mMotion->onDeactivate();
294 } 295 }
295 } 296 }
296} 297}
@@ -328,9 +329,9 @@ void LLKeyframeMotionParam::setDefaultKeyframeMotion(char *name)
328 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) 329 for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2)
329 { 330 {
330 const ParameterizedMotion& paramMotion = *iter2; 331 const ParameterizedMotion& paramMotion = *iter2;
331 if (paramMotion.first->getName() == name) 332 if (paramMotion.mMotion->getName() == name)
332 { 333 {
333 mDefaultKeyframeMotion = paramMotion.first; 334 mDefaultKeyframeMotion = paramMotion.mMotion;
334 } 335 }
335 } 336 }
336 } 337 }