diff options
Diffstat (limited to 'indra/newview/llviewerobject.cpp')
| -rw-r--r-- | indra/newview/llviewerobject.cpp | 96 | 
1 files changed, 92 insertions, 4 deletions
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index be9ff872c0..c3a7d345f5 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -519,7 +519,6 @@ void LLViewerObject::setNameValueList(const std::string& name_value_list)  	}  } -  // This method returns true if the object is over land owned by the  // agent.  bool LLViewerObject::isReturnable() @@ -528,17 +527,106 @@ bool LLViewerObject::isReturnable()  	{  		return false;  	} +		  	std::vector<LLBBox> boxes;  	boxes.push_back(LLBBox(getPositionRegion(), getRotationRegion(), getScale() * -0.5f, getScale() * 0.5f).getAxisAligned());  	for (child_list_t::iterator iter = mChildList.begin();  		 iter != mChildList.end(); iter++)  	{  		LLViewerObject* child = *iter; -		boxes.push_back(LLBBox(child->getPositionRegion(), child->getRotationRegion(), child->getScale() * -0.5f, child->getScale() * 0.5f).getAxisAligned()); +		boxes.push_back( LLBBox(child->getPositionRegion(), child->getRotationRegion(), child->getScale() * -0.5f, child->getScale() * 0.5f).getAxisAligned()); +	} + +	bool result = (mRegionp && mRegionp->objectIsReturnable(getPositionRegion(), boxes)) ? 1 : 0; +	 +	if ( !result ) +	{		 +		//Get list of neighboring regions relative to this vo's region +		std::vector<LLViewerRegion*> uniqueRegions; +		mRegionp->getNeighboringRegions( uniqueRegions ); +	 +		//Build aabb's - for root and all children +		std::vector<PotentialReturnableObject> returnables; +		typedef std::vector<LLViewerRegion*>::iterator RegionIt; +		RegionIt regionStart = uniqueRegions.begin(); +		RegionIt regionEnd   = uniqueRegions.end(); +		 +		for (; regionStart != regionEnd; ++regionStart ) +		{ +			LLViewerRegion* pTargetRegion = *regionStart; +			//Add the root vo as there may be no children and we still want +			//to test for any edge overlap +			buildReturnablesForChildrenVO( returnables, this, pTargetRegion ); +			//Add it's children +			for (child_list_t::iterator iter = mChildList.begin();  iter != mChildList.end(); iter++) +			{ +				LLViewerObject* pChild = *iter;		 +				buildReturnablesForChildrenVO( returnables, pChild, pTargetRegion ); +			} +		}	 +	 +		//TBD#Eventually create a region -> box list map  +		typedef std::vector<PotentialReturnableObject>::iterator ReturnablesIt; +		ReturnablesIt retCurrentIt = returnables.begin(); +		ReturnablesIt retEndIt = returnables.end(); +	 +		for ( ; retCurrentIt !=retEndIt; ++retCurrentIt ) +		{ +			boxes.clear(); +			LLViewerRegion* pRegion = (*retCurrentIt).pRegion; +			boxes.push_back( (*retCurrentIt).box );	 +			bool retResult = (pRegion && pRegion->childrenObjectReturnable( boxes )) ? 1 : 0; +			if ( retResult ) +			{  +				result = true; +				break; +			} +		} +	} +	return result; +} + +void LLViewerObject::buildReturnablesForChildrenVO( std::vector<PotentialReturnableObject>& returnables, LLViewerObject* pChild, LLViewerRegion* pTargetRegion ) +{ +	if ( !pChild ) +	{ +		llerrs<<"child viewerobject is NULL "<<llendl; +	} +	 +	constructAndAddReturnable( returnables, pChild, pTargetRegion ); +	 +	//We want to handle any children VO's as well +	for (child_list_t::iterator iter = pChild->mChildList.begin();  iter != pChild->mChildList.end(); iter++) +	{ +		LLViewerObject* pChildofChild = *iter; +		buildReturnablesForChildrenVO( returnables, pChildofChild, pTargetRegion );  	} +} -	return mRegionp -		&& mRegionp->objectIsReturnable(getPositionRegion(), boxes); +void LLViewerObject::constructAndAddReturnable( std::vector<PotentialReturnableObject>& returnables, LLViewerObject* pChild, LLViewerRegion* pTargetRegion ) +{ +	 +	LLVector3 targetRegionPos; +	targetRegionPos.setVec( pChild->getPositionGlobal() );	 +	 +	LLBBox childBBox = LLBBox( targetRegionPos, pChild->getRotationRegion(), pChild->getScale() * -0.5f,  +							    pChild->getScale() * 0.5f).getAxisAligned(); +	 +	LLVector3 edgeA = targetRegionPos + childBBox.getMinLocal(); +	LLVector3 edgeB = targetRegionPos + childBBox.getMaxLocal(); +	 +	LLVector3d edgeAd, edgeBd; +	edgeAd.setVec(edgeA); +	edgeBd.setVec(edgeB); +	 +	//Only add the box when either of the extents are in a neighboring region +	if ( pTargetRegion->pointInRegionGlobal( edgeAd ) || pTargetRegion->pointInRegionGlobal( edgeBd ) ) +	{ +		PotentialReturnableObject returnableObj; +		returnableObj.box		= childBBox; +		returnableObj.pRegion	= pTargetRegion; +		returnables.push_back( returnableObj ); +	}  }  BOOL LLViewerObject::setParent(LLViewerObject* parent)  | 
