diff options
author | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
commit | 89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch) | |
tree | bcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/llcharacter/lljoint.cpp | |
parent | Second Life viewer sources 1.13.3.2 (diff) | |
download | meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2 meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz |
Second Life viewer sources 1.14.0.0
Diffstat (limited to 'linden/indra/llcharacter/lljoint.cpp')
-rw-r--r-- | linden/indra/llcharacter/lljoint.cpp | 87 |
1 files changed, 60 insertions, 27 deletions
diff --git a/linden/indra/llcharacter/lljoint.cpp b/linden/indra/llcharacter/lljoint.cpp index 4ef9835..4102612 100644 --- a/linden/indra/llcharacter/lljoint.cpp +++ b/linden/indra/llcharacter/lljoint.cpp | |||
@@ -69,8 +69,9 @@ LLJoint::LLJoint(const std::string &name, LLJoint *parent) | |||
69 | 69 | ||
70 | setName(name); | 70 | setName(name); |
71 | if (parent) | 71 | if (parent) |
72 | { | ||
72 | parent->addChild( this ); | 73 | parent->addChild( this ); |
73 | 74 | } | |
74 | touch(); | 75 | touch(); |
75 | } | 76 | } |
76 | 77 | ||
@@ -80,6 +81,10 @@ LLJoint::LLJoint(const std::string &name, LLJoint *parent) | |||
80 | //----------------------------------------------------------------------------- | 81 | //----------------------------------------------------------------------------- |
81 | LLJoint::~LLJoint() | 82 | LLJoint::~LLJoint() |
82 | { | 83 | { |
84 | if (mParent) | ||
85 | { | ||
86 | mParent->removeChild( this ); | ||
87 | } | ||
83 | removeAllChildren(); | 88 | removeAllChildren(); |
84 | } | 89 | } |
85 | 90 | ||
@@ -91,7 +96,9 @@ void LLJoint::setup(const std::string &name, LLJoint *parent) | |||
91 | { | 96 | { |
92 | setName(name); | 97 | setName(name); |
93 | if (parent) | 98 | if (parent) |
99 | { | ||
94 | parent->addChild( this ); | 100 | parent->addChild( this ); |
101 | } | ||
95 | } | 102 | } |
96 | 103 | ||
97 | //----------------------------------------------------------------------------- | 104 | //----------------------------------------------------------------------------- |
@@ -109,11 +116,11 @@ void LLJoint::touch(U32 flags) | |||
109 | { | 116 | { |
110 | child_flags |= POSITION_DIRTY; | 117 | child_flags |= POSITION_DIRTY; |
111 | } | 118 | } |
112 | 119 | ||
113 | for ( LLJoint *joint = mChildren.getFirstData(); | 120 | for (child_list_t::iterator iter = mChildren.begin(); |
114 | joint != NULL; | 121 | iter != mChildren.end(); ++iter) |
115 | joint = mChildren.getNextData() ) | ||
116 | { | 122 | { |
123 | LLJoint* joint = *iter; | ||
117 | joint->touch(child_flags); | 124 | joint->touch(child_flags); |
118 | } | 125 | } |
119 | } | 126 | } |
@@ -140,13 +147,15 @@ LLJoint *LLJoint::findJoint( const std::string &name ) | |||
140 | if (name == getName()) | 147 | if (name == getName()) |
141 | return this; | 148 | return this; |
142 | 149 | ||
143 | for ( LLJoint *j = mChildren.getFirstData(); | 150 | for (child_list_t::iterator iter = mChildren.begin(); |
144 | j != NULL; | 151 | iter != mChildren.end(); ++iter) |
145 | j = mChildren.getNextData() ) | ||
146 | { | 152 | { |
147 | LLJoint *found = j->findJoint(name); | 153 | LLJoint* joint = *iter; |
154 | LLJoint *found = joint->findJoint(name); | ||
148 | if (found) | 155 | if (found) |
156 | { | ||
149 | return found; | 157 | return found; |
158 | } | ||
150 | } | 159 | } |
151 | 160 | ||
152 | return NULL; | 161 | return NULL; |
@@ -156,12 +165,12 @@ LLJoint *LLJoint::findJoint( const std::string &name ) | |||
156 | //-------------------------------------------------------------------- | 165 | //-------------------------------------------------------------------- |
157 | // addChild() | 166 | // addChild() |
158 | //-------------------------------------------------------------------- | 167 | //-------------------------------------------------------------------- |
159 | void LLJoint::addChild(LLJoint *joint) | 168 | void LLJoint::addChild(LLJoint* joint) |
160 | { | 169 | { |
161 | if (joint->mParent) | 170 | if (joint->mParent) |
162 | joint->mParent->removeChild(joint); | 171 | joint->mParent->removeChild(joint); |
163 | 172 | ||
164 | mChildren.addDataAtEnd(joint); | 173 | mChildren.push_back(joint); |
165 | joint->mXform.setParent(&mXform); | 174 | joint->mXform.setParent(&mXform); |
166 | joint->mParent = this; | 175 | joint->mParent = this; |
167 | joint->touch(); | 176 | joint->touch(); |
@@ -171,9 +180,13 @@ void LLJoint::addChild(LLJoint *joint) | |||
171 | //-------------------------------------------------------------------- | 180 | //-------------------------------------------------------------------- |
172 | // removeChild() | 181 | // removeChild() |
173 | //-------------------------------------------------------------------- | 182 | //-------------------------------------------------------------------- |
174 | void LLJoint::removeChild(LLJoint *joint) | 183 | void LLJoint::removeChild(LLJoint* joint) |
175 | { | 184 | { |
176 | this->mChildren.removeData(joint); | 185 | child_list_t::iterator iter = std::find(mChildren.begin(), mChildren.end(), joint); |
186 | if (iter != mChildren.end()) | ||
187 | { | ||
188 | this->mChildren.erase(iter); | ||
189 | } | ||
177 | joint->mXform.setParent(NULL); | 190 | joint->mXform.setParent(NULL); |
178 | joint->mParent = NULL; | 191 | joint->mParent = NULL; |
179 | joint->touch(); | 192 | joint->touch(); |
@@ -185,11 +198,15 @@ void LLJoint::removeChild(LLJoint *joint) | |||
185 | //-------------------------------------------------------------------- | 198 | //-------------------------------------------------------------------- |
186 | void LLJoint::removeAllChildren() | 199 | void LLJoint::removeAllChildren() |
187 | { | 200 | { |
188 | for ( LLJoint *joint = mChildren.getFirstData(); | 201 | for (child_list_t::iterator iter = mChildren.begin(); |
189 | joint != NULL; | 202 | iter != mChildren.end();) |
190 | joint = mChildren.getNextData() ) | ||
191 | { | 203 | { |
192 | removeChild(joint); | 204 | child_list_t::iterator curiter = iter++; |
205 | LLJoint* joint = *curiter; | ||
206 | mChildren.erase(curiter); | ||
207 | joint->mXform.setParent(NULL); | ||
208 | joint->mParent = NULL; | ||
209 | joint->touch(); | ||
193 | } | 210 | } |
194 | } | 211 | } |
195 | 212 | ||
@@ -208,8 +225,11 @@ const LLVector3& LLJoint::getPosition() | |||
208 | //-------------------------------------------------------------------- | 225 | //-------------------------------------------------------------------- |
209 | void LLJoint::setPosition( const LLVector3& pos ) | 226 | void LLJoint::setPosition( const LLVector3& pos ) |
210 | { | 227 | { |
211 | mXform.setPosition(pos); | 228 | // if (mXform.getPosition() != pos) |
212 | touch(MATRIX_DIRTY | POSITION_DIRTY); | 229 | { |
230 | mXform.setPosition(pos); | ||
231 | touch(MATRIX_DIRTY | POSITION_DIRTY); | ||
232 | } | ||
213 | } | 233 | } |
214 | 234 | ||
215 | 235 | ||
@@ -276,8 +296,11 @@ void LLJoint::setRotation( const LLQuaternion& rot ) | |||
276 | { | 296 | { |
277 | if (rot.isFinite()) | 297 | if (rot.isFinite()) |
278 | { | 298 | { |
279 | mXform.setRotation(rot); | 299 | // if (mXform.getRotation() != rot) |
280 | touch(MATRIX_DIRTY | ROTATION_DIRTY); | 300 | { |
301 | mXform.setRotation(rot); | ||
302 | touch(MATRIX_DIRTY | ROTATION_DIRTY); | ||
303 | } | ||
281 | } | 304 | } |
282 | } | 305 | } |
283 | 306 | ||
@@ -339,8 +362,12 @@ const LLVector3& LLJoint::getScale() | |||
339 | //-------------------------------------------------------------------- | 362 | //-------------------------------------------------------------------- |
340 | void LLJoint::setScale( const LLVector3& scale ) | 363 | void LLJoint::setScale( const LLVector3& scale ) |
341 | { | 364 | { |
342 | mXform.setScale(scale); | 365 | // if (mXform.getScale() != scale) |
343 | touch(); | 366 | { |
367 | mXform.setScale(scale); | ||
368 | touch(); | ||
369 | } | ||
370 | |||
344 | } | 371 | } |
345 | 372 | ||
346 | 373 | ||
@@ -412,14 +439,18 @@ void LLJoint::updateWorldPRSParent() | |||
412 | // updateWorldMatrixChildren() | 439 | // updateWorldMatrixChildren() |
413 | //----------------------------------------------------------------------------- | 440 | //----------------------------------------------------------------------------- |
414 | void LLJoint::updateWorldMatrixChildren() | 441 | void LLJoint::updateWorldMatrixChildren() |
415 | { | 442 | { |
443 | if (!this->mUpdateXform) return; | ||
444 | |||
416 | if (mDirtyFlags & MATRIX_DIRTY) | 445 | if (mDirtyFlags & MATRIX_DIRTY) |
417 | { | 446 | { |
418 | updateWorldMatrix(); | 447 | updateWorldMatrix(); |
419 | } | 448 | } |
420 | for (LLJoint *child = mChildren.getFirstData(); child; child = mChildren.getNextData()) | 449 | for (child_list_t::iterator iter = mChildren.begin(); |
450 | iter != mChildren.end(); ++iter) | ||
421 | { | 451 | { |
422 | child->updateWorldMatrixChildren(); | 452 | LLJoint* joint = *iter; |
453 | joint->updateWorldMatrixChildren(); | ||
423 | } | 454 | } |
424 | } | 455 | } |
425 | 456 | ||
@@ -494,8 +525,10 @@ void LLJoint::clampRotation(LLQuaternion old_rot, LLQuaternion new_rot) | |||
494 | { | 525 | { |
495 | LLVector3 main_axis(1.f, 0.f, 0.f); | 526 | LLVector3 main_axis(1.f, 0.f, 0.f); |
496 | 527 | ||
497 | for (LLJoint* joint = mChildren.getFirstData(); joint; joint = mChildren.getNextData()) | 528 | for (child_list_t::iterator iter = mChildren.begin(); |
529 | iter != mChildren.end(); ++iter) | ||
498 | { | 530 | { |
531 | LLJoint* joint = *iter; | ||
499 | if (joint->isAnimatable()) | 532 | if (joint->isAnimatable()) |
500 | { | 533 | { |
501 | main_axis = joint->getPosition(); | 534 | main_axis = joint->getPosition(); |