summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2018-06-01 15:08:59 +0100
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2018-06-01 15:08:59 +0100
commite86839fac19753d0fa4006296c7f8909fe781013 (patch)
treef65f6ae403736fb48012a9334a95730f88e2ae1e /indra/newview
parent39bcae574f410f93d26c95ec2398f3653678e997 (diff)
SL-915 - WIP on dynamic joint box tracking
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llface.cpp92
-rw-r--r--indra/newview/llvoavatar.cpp39
2 files changed, 57 insertions, 74 deletions
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index efd57ec39f..7bc7814392 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -810,17 +810,11 @@ bool less_than_max_mag(const LLVector4a& vec)
}
BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
- const LLMatrix4& mat_vert_in, BOOL global_volume)
+ const LLMatrix4& mat_vert_in, BOOL global_volume)
{
//get bounding box
if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION | LLDrawable::REBUILD_RIGGED))
{
- //VECTORIZE THIS
- LLMatrix4a mat_vert;
- mat_vert.loadu(mat_vert_in);
-
- LLVector4a min,max;
-
if (f >= volume.getNumVolumeFaces())
{
LL_WARNS() << "Generating bounding box for invalid face index!" << LL_ENDL;
@@ -828,39 +822,11 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
}
const LLVolumeFace &face = volume.getVolumeFace(f);
- min = face.mExtents[0];
- max = face.mExtents[1];
- LL_DEBUGS("RiggedBox") << "updating extents for face " << f << " starting extents " << mExtents[0] << ", " << mExtents[1] << LL_ENDL;
- LL_DEBUGS("RiggedBox") << "updating extents for face " << f << " starting vf extents " << face.mExtents[0] << ", " << face.mExtents[1] << " num verts " << face.mNumVertices << LL_ENDL;
-
- llassert(less_than_max_mag(min));
- llassert(less_than_max_mag(max));
-
- //min, max are in volume space, convert to drawable render space
-
- //get 8 corners of bounding box
- LLVector4Logical mask[6];
-
- for (U32 i = 0; i < 6; ++i)
- {
- mask[i].clear();
- }
-
- mask[0].setElement<2>(); //001
- mask[1].setElement<1>(); //010
- mask[2].setElement<1>(); //011
- mask[2].setElement<2>();
- mask[3].setElement<0>(); //100
- mask[4].setElement<0>(); //101
- mask[4].setElement<2>();
- mask[5].setElement<0>(); //110
- mask[5].setElement<1>();
-
- LLVector4a v[8];
-
- v[6] = min;
- v[7] = max;
+ LL_DEBUGS("RiggedBox") << "updating extents for face " << f
+ << " starting extents " << mExtents[0] << ", " << mExtents[1]
+ << " starting vf extents " << face.mExtents[0] << ", " << face.mExtents[1]
+ << " num verts " << face.mNumVertices << LL_ENDL;
// MAINT-8264 - stray vertices, especially in low LODs, cause bounding box errors.
if (face.mNumVertices < 3)
@@ -870,52 +836,38 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
return FALSE;
}
- for (U32 i = 0; i < 6; ++i)
- {
- v[i].setSelectWithMask(mask[i], min, max);
- }
-
- LLVector4a tv[8];
-
- LL_DEBUGS("RiggedBox") << "updating extents for face " << f << " mat is " << mat_vert << LL_ENDL;
+ //VECTORIZE THIS
+ LLMatrix4a mat_vert;
+ mat_vert.loadu(mat_vert_in);
+ LLVector4a new_extents[2];
- //transform bounding box into drawable space
- for (U32 i = 0; i < 8; ++i)
- {
- mat_vert.affineTransform(v[i], tv[i]);
- LL_DEBUGS("RiggedBox") << "updating extents for face " << f << " i " << i << " v and tv " << v[i] << ", " << tv[i] << LL_ENDL;
- }
-
- //find bounding box
- LLVector4a& newMin = mExtents[0];
- LLVector4a& newMax = mExtents[1];
+ llassert(less_than_max_mag(face.mExtents[0]));
+ llassert(less_than_max_mag(face.mExtents[1]));
- newMin = newMax = tv[0];
+ matMulBoundBox(mat_vert, face.mExtents, mExtents);
- for (U32 i = 1; i < 8; ++i)
- {
- newMin.setMin(newMin, tv[i]);
- newMax.setMax(newMax, tv[i]);
- }
- LL_DEBUGS("RiggedBox") << "updating extents for face " << f << " bbox gave extents " << mExtents[0] << ", " << mExtents[1] << LL_ENDL;
+ LL_DEBUGS("RiggedBox") << "updated extents for face " << f
+ << " bbox gave extents " << mExtents[0] << ", " << mExtents[1] << LL_ENDL;
if (!mDrawablep->isActive())
{ // Shift position for region
LLVector4a offset;
offset.load3(mDrawablep->getRegion()->getOriginAgent().mV);
- newMin.add(offset);
- newMax.add(offset);
- LL_DEBUGS("RiggedBox") << "updating extents for face " << f << " not active, added offset " << offset << LL_ENDL;
+ mExtents[0].add(offset);
+ mExtents[1].add(offset);
+ LL_DEBUGS("RiggedBox") << "updating extents for face " << f
+ << " not active, added offset " << offset << LL_ENDL;
}
- LL_DEBUGS("RiggedBox") << "updated extents for face " << f << " to " << mExtents[0] << ", " << mExtents[1] << LL_ENDL;
+ LL_DEBUGS("RiggedBox") << "updated extents for face " << f
+ << " to " << mExtents[0] << ", " << mExtents[1] << LL_ENDL;
LLVector4a t;
- t.setAdd(newMin,newMax);
+ t.setAdd(mExtents[0],mExtents[1]);
t.mul(0.5f);
mCenterLocal.set(t.getF32ptr());
- t.setSub(newMax,newMin);
+ t.setSub(mExtents[1],mExtents[0]);
mBoundingSphereRadius = t.getLength3().getF32()*0.5f;
updateCenterAgent();
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 0ea29bae58..277f8e4533 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -1277,13 +1277,11 @@ void LLVOAvatar::updateSpatialExtents(LLVector4a& newMin, LLVector4a &newMax)
mImpostorOffset = LLVector3(pos_group.getF32ptr())-getRenderPosition();
mDrawable->setPositionGroup(pos_group);
}
-
-
}
void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
{
- LLVector4a buffer(0.25f);
+ LLVector4a buffer(0.0);
LLVector4a pos;
pos.load3(getRenderPosition().mV);
newMin.setSub(pos, buffer);
@@ -1312,7 +1310,7 @@ void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
mPixelArea = LLPipeline::calcPixelArea(center, size, *LLViewerCamera::getInstance());
- //stretch bounding box by attachments
+ //stretch bounding box by static attachments
for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
iter != mAttachmentPoints.end();
++iter)
@@ -1356,6 +1354,39 @@ void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
}
}
+ // Stretch bounding box by rigged mesh joint boxes
+ for (S32 joint_num = 0; joint_num < LL_CHARACTER_MAX_ANIMATED_JOINTS; joint_num++)
+ {
+ LLJoint *joint = getJoint(joint_num);
+
+ // FIXME TEMP HACK FOR TESTING
+ if (joint)
+ {
+ joint->getRiggingInfo().setIsRiggedTo(true);
+ }
+
+ if (joint && joint->getRiggingInfo().isRiggedTo())
+ {
+ LLViewerJointAttachment *as_joint_attach = dynamic_cast<LLViewerJointAttachment*>(joint);
+ if (as_joint_attach && as_joint_attach->getIsHUDAttachment())
+ {
+ // Ignore bounding box of HUD joints
+ continue;
+ }
+ LLMatrix4a mat;
+ LLVector4a new_extents[2];
+ mat.loadu(joint->getWorldMatrix());
+ matMulBoundBox(mat, joint->getRiggingInfo().getRiggedExtents(), new_extents);
+ update_min_max(newMin, newMax, new_extents[0]);
+ update_min_max(newMin, newMax, new_extents[1]);
+ //if (isSelf())
+ //{
+ // LL_INFOS() << joint->getName() << " extents " << new_extents[0] << "," << new_extents[1] << LL_ENDL;
+ // LL_INFOS() << joint->getName() << " av box is " << newMin << "," << newMax << LL_ENDL;
+ //}
+ }
+ }
+
//pad bounding box
newMin.sub(buffer);