secondlife / secondlife/viewer
Update animesh size by manual edit and script
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 299
- Forks
- 146
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 88
Description
Currently we can't update animesh size and have to upload multiple versions of the mesh in different sizes, and upload all animations for each size.
I did some research in the viewer's code, and it appears to me that it's extremely easy to add a feature to adjust the global size of an animesh by modifying the llcontrolavatar.cpp file. Here is the current setGlobalScale() function:
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;
// should we be scaling from the pelvis or the root?
recursiveScaleJoint(mPelvisp,adjust_scale);
mGlobalScale = scale;
}
}
And here is a modified version that currently takes into account the X size of the main prim:
void LLControlAvatar::setGlobalScale(F32 scale)
{
if (scale <= 0.0)
{
LL_WARNS() << "invalid global scale " << scale << LL_ENDL;
return;
}
scale *= mRootVolp->getScale().mV[0];
if (scale != mGlobalScale)
{
F32 adjust_scale = scale/mGlobalScale;
LL_INFOS() << "scale " << scale << " adjustment " << adjust_scale << LL_ENDL;
recursiveScaleJoint(mRoot,adjust_scale);
mGlobalScale = scale;
}
}
Note that I replaced mPelvisp by mRoot because using mPelvisp does not correctly adjust the animesh's movement during the animation."
It works wonderfully. Of course, this modification as it stands could affect many existing animesh objects, so we need to add a parameter to the object, 'ANIMESH_SCALE_FACTOR', which would be set to 1 by default, adjustable via script and by manual editing of the object. We would then have something like this:
scale *= mRootVolp->getAnimeshScaleFactor;
Here is a gif, you can take a look, the 4 dogs are all the exact same animesh, I only changed there main prim X scale :
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in llcontrolavatar.cpp at LLControlAvatar::setGlobalScale(), comparing the existing and proposed implementations and the use of mRootVolp. Trace how animesh object parameters are exposed for manual editing and scripting. Done means an ANIMESH_SCALE_FACTOR parameter defaults to 1, can be edited and scripted, and scales animesh movement correctly without changing existing objects by default.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics, game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100