summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llcontrolavatar.cpp55
-rw-r--r--indra/newview/llcontrolavatar.h4
-rw-r--r--indra/newview/llviewermessage.cpp8
3 files changed, 64 insertions, 3 deletions
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;