SL-697 - global scale function for LLControlAvatar, to support arbitrary scaling of animated objects. Not currently used.

master
Brad Payne (Vir Linden) 2017-06-16 16:03:06 +01:00
parent c5dc0ee36e
commit b2a0657818
4 changed files with 65 additions and 4 deletions

View File

@ -881,7 +881,7 @@ void LLJoint::setWorldRotation( const LLQuaternion& rot )
//--------------------------------------------------------------------
const LLVector3& LLJoint::getScale()
{
return mXform.getScale();
return mXform.getScale();
}
//--------------------------------------------------------------------

View File

@ -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)

View File

@ -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

View File

@ -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;