ER-398 viewer's encroachment logic only uses bounding box of root prim

Adding LLBBox::join() to allow us to compute the bounding box of a linked object
master
Andrew Meadows 2010-12-14 08:52:33 -08:00
parent e040f16a4f
commit 64512b681e
3 changed files with 27 additions and 3 deletions

View File

@ -102,6 +102,19 @@ LLBBox LLBBox::getAxisAligned() const
return aligned;
}
// Increases the size to contain other_box
void LLBBox::join(const LLBBox& other_box)
{
LLVector3 other_min = (other_box.mPosAgent - mPosAgent) - other_box.mMinLocal;
mMinLocal.mV[VX] = llmin( other_min.mV[VX], mMinLocal.mV[VX] );
mMinLocal.mV[VY] = llmin( other_min.mV[VY], mMinLocal.mV[VY] );
mMinLocal.mV[VZ] = llmin( other_min.mV[VZ], mMinLocal.mV[VZ] );
LLVector3 other_max = (other_box.mPosAgent - mPosAgent) + other_box.mMaxLocal;
mMaxLocal.mV[VX] = llmax( other_max.mV[VX], mMaxLocal.mV[VX] );
mMaxLocal.mV[VY] = llmax( other_max.mV[VY], mMaxLocal.mV[VY] );
mMaxLocal.mV[VZ] = llmax( other_max.mV[VZ], mMaxLocal.mV[VZ] );
}
void LLBBox::expand( F32 delta )

View File

@ -83,7 +83,10 @@ public:
LLVector3 agentToLocalBasis(const LLVector3& v) const;
// Get the smallest possible axis aligned bbox that contains this bbox
LLBBox getAxisAligned() const;
LLBBox getAxisAligned() const;
// Increases the size to contain other_box
void join(const LLBBox& other_box);
// friend LLBBox operator*(const LLBBox& a, const LLMatrix4& b);

View File

@ -518,10 +518,18 @@ void LLViewerObject::setNameValueList(const std::string& name_value_list)
// agent.
bool LLViewerObject::isReturnable()
{
LLBBox box_in_region_frame(getPositionRegion(), getRotationRegion(), getScale() * -0.5f, getScale() * 0.5f);
LLBBox bounding_box(getPositionRegion(), getRotationRegion(), getScale() * -0.5f, getScale() * 0.5f);
for (child_list_t::iterator iter = mChildList.begin();
iter != mChildList.end(); iter++)
{
LLViewerObject* child = *iter;
LLBBox child_box(child->getPositionRegion(), child->getRotationRegion(), child->getScale() * -0.5f, child->getScale() * 0.5f);
bounding_box.join(child_box);
}
return !isAttachment()
&& mRegionp
&& mRegionp->objectIsReturnable(getPositionRegion(), box_in_region_frame);
&& mRegionp->objectIsReturnable(getPositionRegion(), bounding_box);
}
BOOL LLViewerObject::setParent(LLViewerObject* parent)