summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2017-06-16 16:03:06 +0100
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2017-06-16 16:03:06 +0100
commitb2a06578187af5446b5e24379abc8764f0cd731f (patch)
tree7392a0b4ff299c49145adcfd0cf61f51ae3a9445 /indra
parentc5dc0ee36e8d17fd0cf25f5a1fbdfb8609a64ee0 (diff)
SL-697 - global scale function for LLControlAvatar, to support arbitrary scaling of animated objects. Not currently used.
Diffstat (limited to 'indra')
-rw-r--r--indra/llcharacter/lljoint.cpp2
-rw-r--r--indra/newview/llcontrolavatar.cpp55
-rw-r--r--indra/newview/llcontrolavatar.h4
-rw-r--r--indra/newview/llviewermessage.cpp8
4 files changed, 65 insertions, 4 deletions
diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index a3d5679f65..89335a20f5 100644
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -881,7 +881,7 @@ void LLJoint::setWorldRotation( const LLQuaternion& rot )
//--------------------------------------------------------------------
const LLVector3& LLJoint::getScale()
{
- return mXform.getScale();
+ return mXform.getScale();
}
//--------------------------------------------------------------------
diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp
index a8caba08af..03a374ebdb 100644
--- a/indra/newview/llcontrolavatar.cpp
+++ b/indra/newview/llcontrolavatar.cpp
@@ -33,7 +33,8 @@
LLControlAvatar::LLControlAvatar(const LLUUID& id, const LLPCode pcode, LLViewerRegion* regionp) :
LLVOAvatar(id, pcode, regionp),
- mPlaying(false)
+ mPlaying(false),
+ mGlobalScale(1.0f)
{
mIsControlAvatar = true;
}
@@ -56,6 +57,35 @@ void LLControlAvatar::matchTransform(LLVOVolume *obj)
mRoot->setPosition(obj->getRenderPosition());
}
+void LLControlAvatar::setGlobalScale(F32 scale)
+{
+ if (scale <= 0.0)
+ {
+ LL_WARNS() << "invalid global scale " << scale << LL_ENDL;
+ return;
+ }
+ if (scale != mGlobalScale)
+ {
+ F32 adjust_scale = scale/mGlobalScale;
+ LL_INFOS() << "scale " << scale << " adjustment " << adjust_scale << LL_ENDL;
+ // AXON - should we be scaling from the pelvis or the root?
+ recursiveScaleJoint(mPelvisp,adjust_scale);
+ mGlobalScale = scale;
+ }
+}
+
+void LLControlAvatar::recursiveScaleJoint(LLJoint* joint, F32 factor)
+{
+ joint->setScale(factor * joint->getScale());
+
+ for (LLJoint::child_list_t::iterator iter = joint->mChildren.begin();
+ iter != joint->mChildren.end(); ++iter)
+ {
+ LLJoint* child = *iter;
+ recursiveScaleJoint(child, factor);
+ }
+}
+
// Based on LLViewerJointAttachment::setupDrawable(), without the attaching part.
void LLControlAvatar::updateGeom(LLVOVolume *obj)
{
@@ -86,8 +116,29 @@ void LLControlAvatar::updateGeom(LLVOVolume *obj)
gPipeline.markRebuild(obj->mDrawable, LLDrawable::REBUILD_ALL, TRUE);
obj->markForUpdate(TRUE);
+ // Note that attachment overrides aren't needed here, have already
+ // been applied at the time the mControlAvatar was created, in
+ // llvovolume.cpp.
+
matchTransform(obj);
- //addAttachmentOverridesForObject(obj);
+
+ // AXON testing scale
+
+ // What should the scale be? What we really want is the ratio
+ // between the scale at which the object was originally designed
+ // and rigged, and the scale to which it has been subsequently
+ // modified - for example, if the object has been scaled down by a
+ // factor of 2 then we should use 0.5 as the global scale. But we
+ // don't have the original scale stored anywhere, just the current
+ // scale. Possibilities - 1) remember the original scale
+ // somewhere, 2) add another field to let the user specify the
+ // global scale, 3) approximate the original scale by looking at
+ // the proportions of the skeleton after joint positions have
+ // been applied
+
+ //LLVector3 obj_scale = obj->getScale();
+ //F32 obj_scale_z = llmax(obj_scale[2],0.1f);
+ //setGlobalScale(obj_scale_z/2.0f); // roughly fit avatar height range (2m) into object height
}
LLControlAvatar *LLControlAvatar::createControlAvatar(LLVOVolume *obj)
diff --git a/indra/newview/llcontrolavatar.h b/indra/newview/llcontrolavatar.h
index c8b1039363..a783b9228f 100644
--- a/indra/newview/llcontrolavatar.h
+++ b/indra/newview/llcontrolavatar.h
@@ -42,9 +42,13 @@ public:
void matchTransform(LLVOVolume *obj);
void updateGeom(LLVOVolume *obj);
+ void setGlobalScale(F32 scale);
+ void recursiveScaleJoint(LLJoint *joint, F32 factor);
static LLControlAvatar *createControlAvatar(LLVOVolume *obj);
bool mPlaying;
+
+ F32 mGlobalScale;
};
#endif //LL_CONTROLAVATAR_H
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index db237d30ea..f359c1455f 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -5097,10 +5097,16 @@ void process_object_animation(LLMessageSystem *mesgsys, void **user_data)
return;
}
+ LLControlAvatar *avatarp = volp->mControlAvatar;
+ if (!avatarp)
+ {
+ LL_WARNS() << "AXON no control avatar, ignoring" << LL_ENDL;
+ return;
+ }
+
S32 num_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_AnimationList);
LL_WARNS() << "AXON handle object animation here, num_blocks " << num_blocks << LL_ENDL;
- LLControlAvatar *avatarp = volp->mControlAvatar;
if (!avatarp->mPlaying)
{
avatarp->mPlaying = true;