diff options
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/llviewerobject.cpp | 134 | ||||
| -rw-r--r-- | indra/newview/llviewerobject.h | 12 | ||||
| -rw-r--r-- | indra/newview/llviewerobjectlist.cpp | 51 | ||||
| -rw-r--r-- | indra/newview/llviewerregion.cpp | 134 | ||||
| -rw-r--r-- | indra/newview/llviewerregion.h | 19 | ||||
| -rw-r--r-- | indra/newview/llvocache.cpp | 28 | ||||
| -rw-r--r-- | indra/newview/llvocache.h | 4 | 
7 files changed, 354 insertions, 28 deletions
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index f5f5bdffbd..e50509374d 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -123,6 +123,7 @@ BOOL		LLViewerObject::sUseSharedDrawables(FALSE); // TRUE  F64			LLViewerObject::sMaxUpdateInterpolationTime = 3.0;		// For motion interpolation: after X seconds with no updates, don't predict object motion  F64			LLViewerObject::sPhaseOutUpdateInterpolationTime = 2.0;	// For motion interpolation: after Y seconds with no updates, taper off motion prediction +std::map<std::string, U32> LLViewerObject::sObjectDataMap;  static LLFastTimer::DeclareTimer FTM_CREATE_OBJECT("Create Object"); @@ -501,6 +502,8 @@ void LLViewerObject::initVOClasses()  	LLVOGrass::initClass();  	LLVOWater::initClass();  	LLVOVolume::initClass(); + +	initObjectDataMap();  }  void LLViewerObject::cleanupVOClasses() @@ -510,6 +513,118 @@ void LLViewerObject::cleanupVOClasses()  	LLVOTree::cleanupClass();  	LLVOAvatar::cleanupClass();  	LLVOVolume::cleanupClass(); + +	sObjectDataMap.clear(); +} + +//object data map for compressed && !OUT_TERSE_IMPROVED +//static +void LLViewerObject::initObjectDataMap() +{ +	U32 count = 0; + +	sObjectDataMap["ID"] = count; //full id //LLUUID +	count += sizeof(LLUUID); + +	sObjectDataMap["LocalID"] = count; //U32 +	count += sizeof(U32); + +	sObjectDataMap["PCode"] = count;   //U8 +	count += sizeof(U8); + +	sObjectDataMap["State"] = count;   //U8 +	count += sizeof(U8); + +	sObjectDataMap["CRC"] = count;     //U32 +	count += sizeof(U32); + +	sObjectDataMap["Material"] = count; //U8 +	count += sizeof(U8); + +	sObjectDataMap["ClickAction"] = count; //U8 +	count += sizeof(U8); + +	sObjectDataMap["Scale"] = count; //LLVector3 +	count += sizeof(LLVector3); + +	sObjectDataMap["Pos"] = count;   //LLVector3 +	count += sizeof(LLVector3); + +	sObjectDataMap["Rot"] = count;    //LLVector3 +	count += sizeof(LLVector3); + +	sObjectDataMap["SpecialCode"] = count; //U32 +	count += sizeof(U32); + +	sObjectDataMap["Owner"] = count; //LLUUID +	count += sizeof(LLUUID); + +	sObjectDataMap["Omega"] = count; //LLVector3, when SpecialCode & 0x80 is set +	count += sizeof(LLVector3); + +	//ParentID is after Omega if there is Omega, otherwise is after Owner +	sObjectDataMap["ParentID"] = count;//U32, when SpecialCode & 0x20 is set +	count += sizeof(U32); + +	//------- +	//The rest items are not included here +	//------- +} + +//static  +void LLViewerObject::unpackVector3(LLDataPackerBinaryBuffer* dp, LLVector3& value, std::string name) +{ +	dp->shift(sObjectDataMap[name]); +	dp->unpackVector3(value, name.c_str()); +	dp->reset(); +} + +//static  +void LLViewerObject::unpackUUID(LLDataPackerBinaryBuffer* dp, LLUUID& value, std::string name) +{ +	dp->shift(sObjectDataMap[name]); +	dp->unpackUUID(value, name.c_str()); +	dp->reset(); +} +	 +//static  +void LLViewerObject::unpackU32(LLDataPackerBinaryBuffer* dp, U32& value, std::string name) +{ +	dp->shift(sObjectDataMap[name]); +	dp->unpackU32(value, name.c_str()); +	dp->reset(); +} +	 +//static  +void LLViewerObject::unpackU8(LLDataPackerBinaryBuffer* dp, U8& value, std::string name) +{ +	dp->shift(sObjectDataMap[name]); +	dp->unpackU8(value, name.c_str()); +	dp->reset(); +} + +//static  +U32 LLViewerObject::unpackParentID(LLDataPackerBinaryBuffer* dp, U32& parent_id) +{ +	dp->shift(sObjectDataMap["SpecialCode"]); +	U32 value; +	dp->unpackU32(value, "SpecialCode"); + +	parent_id = 0; +	if(value & 0x20) +	{ +		S32 offset = sObjectDataMap["ParentID"]; +		if(!(value & 0x80)) +		{ +			offset -= sizeof(LLVector3); +		} + +		dp->shift(offset); +		dp->unpackU32(parent_id, "ParentID"); +	} +	dp->reset(); + +	return parent_id;  }  // Replaces all name value pairs with data from \n delimited list @@ -890,6 +1005,25 @@ U32 LLViewerObject::checkMediaURL(const std::string &media_url)      return retval;  } +//extract spatial information from object update message +//return parent_id +//static +U32 LLViewerObject::extractSpatialExtents(LLDataPackerBinaryBuffer *dp, LLVector3& pos, LLVector3& scale, LLQuaternion& rot) +{ +	U32	parent_id = 0; +	 +	LLViewerObject::unpackVector3(dp, scale, "Scale"); +	LLViewerObject::unpackVector3(dp, pos, "Pos"); +	 +	LLVector3 vec; +	LLViewerObject::unpackVector3(dp, vec, "Rot"); +	rot.unpackFromVector3(vec); +	 +	LLViewerObject::unpackParentID(dp, parent_id); +	 +	return parent_id; +} +  U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,  					 void **user_data,  					 U32 block_num, diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 20254bfe02..2db30f1e24 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -70,6 +70,7 @@ class LLViewerRegion;  class LLViewerObjectMedia;  class LLVOInventoryListener;  class LLVOAvatar; +class LLDataPackerBinaryBuffer;  typedef enum e_object_update_type  { @@ -162,6 +163,7 @@ public:          INVALID_UPDATE = 0x80000000      }; +	static  U32     extractSpatialExtents(LLDataPackerBinaryBuffer *dp, LLVector3& pos, LLVector3& scale, LLQuaternion& rot);  	virtual U32		processUpdateMessage(LLMessageSystem *mesgsys,  										void **user_data,  										U32 block_num, @@ -540,6 +542,13 @@ public:  	friend class LLViewerMediaList;  public: +	static void unpackVector3(LLDataPackerBinaryBuffer* dp, LLVector3& value, std::string name); +	static void unpackUUID(LLDataPackerBinaryBuffer* dp, LLUUID& value, std::string name); +	static void unpackU32(LLDataPackerBinaryBuffer* dp, U32& value, std::string name); +	static void unpackU8(LLDataPackerBinaryBuffer* dp, U8& value, std::string name); +	static U32 unpackParentID(LLDataPackerBinaryBuffer* dp, U32& parent_id); + +public:  	//counter-translation  	void resetChildrenPosition(const LLVector3& offset, BOOL simplified = FALSE) ;  	//counter-rotation @@ -562,6 +571,8 @@ private:  	// Motion prediction between updates  	void interpolateLinearMotion(const F64 & time, const F32 & dt); +	static void initObjectDataMap(); +  public:  	//  	// Viewer-side only types - use the LL_PCODE_APP mask. @@ -610,6 +621,7 @@ private:  	// Grabbed from UPDATE_FLAGS  	U32				mFlags; +	static std::map<std::string, U32> sObjectDataMap;  public:  	// Sent to sim in UPDATE_FLAGS, received in ObjectPhysicsProperties  	U8              mPhysicsShapeType; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index dce963c5c5..995c3e7351 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -455,12 +455,54 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,  			uncompressed_length = mesgsys->getSizeFast(_PREHASH_ObjectData, i, _PREHASH_Data);  			mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_Data, compressed_dpbuffer, 0, i);  			compressed_dp.assignBuffer(compressed_dpbuffer, uncompressed_length); +#if 0 +			if (compressed) +			{ +				if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only? +				{ +					U32 flags = 0; +					mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, i); +					 +					if(!(flags & FLAGS_TEMPORARY_ON_REZ)) +					{ +						//bCached = true; +						 +						compressed_dp.unpackU32(local_id, "LocalID"); +						//------------- +						compressed_dp.unpackUUID(fullid, "ID"); +						//if(fullid == LLUUID("1e5183db-8f28-47f1-abe0-23de9f9042b7")) +						{ +							llinfos << fullid << llendl; +						} +						//------------- + +						U32 crc; +						compressed_dp.unpackU32(crc, "CRC"); +						/*LLViewerRegion::eCacheUpdateResult result = */regionp->cacheFullUpdate(local_id, crc, compressed_dp); +						//recorder.cacheFullUpdate(local_id, update_type, result, objectp, msg_size); +						 +						continue; //do not creat LLViewerObject for cacheable object, object cache will do the job. +					} +				} +			} +#endif  			if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?  			{ -				compressed_dp.unpackUUID(fullid, "ID"); -				compressed_dp.unpackU32(local_id, "LocalID"); -				compressed_dp.unpackU8(pcode, "PCode"); +				U32 flags = 0; +				mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, i); +			 +				if(flags & FLAGS_TEMPORARY_ON_REZ) +				{ +					compressed_dp.unpackUUID(fullid, "ID"); +					compressed_dp.unpackU32(local_id, "LocalID"); +					compressed_dp.unpackU8(pcode, "PCode"); +				} +				else //send to object cache +				{ +					regionp->cacheFullUpdate(compressed_dp); +					continue; +				}  			}  			else  			{ @@ -594,6 +636,8 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,  				objectp->mLocalID = local_id;  			}  			processUpdateCore(objectp, user_data, i, update_type, &compressed_dp, justCreated); + +#if 0  			if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?  			{  				U32 flags = 0; @@ -606,6 +650,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,  					recorder.cacheFullUpdate(local_id, update_type, result, objectp, msg_size);  				}  			} +#endif  		}  		else  		{ diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index e5cb2a1b08..040b39bc43 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -880,7 +880,7 @@ void LLViewerRegion::addVisibleGroup(LLviewerOctreeGroup* group)  	mImpl->mVisibleGroups.insert(group);  } -void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry) +void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry, bool forced)  {  	if(!sVOCacheCullingEnabled)  	{ @@ -895,7 +895,7 @@ void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)  	{  		return;  	} -	if(!entry->hasState(LLVOCacheEntry::ADD_TO_CACHE_TREE)) +	if(!forced && !entry->hasState(LLVOCacheEntry::ADD_TO_CACHE_TREE))  	{  		return; //can not add to vo cache tree.  	} @@ -1647,14 +1647,91 @@ void LLViewerRegion::setSimulatorFeatures(const LLSD& sim_features)  	mSimulatorFeatures = sim_features;  } -LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp) +void LLViewerRegion::postProcesNewEntry(LLVOCacheEntry* entry) +{ +	if(entry != NULL && !entry->getEntry()) +	{ +		entry->setOctreeEntry(NULL); +	} +	else  +	{ +		return; //not new entry, no post processing. +	} + +	LLVector3 pos; +	LLVector3 scale; +	LLQuaternion rot; +	U32 parent_id = LLViewerObject::extractSpatialExtents(entry->getDP(), pos, scale, rot); +	 +	entry->setBoundingInfo(pos, scale); +	 +	if(parent_id > 0) //has parent +	{ +		//1, find parent, update position +		LLVOCacheEntry* parent = getCacheEntry(parent_id); +		 +		//2, if can not, put into the orphan lists: a parents list and a children list +		if(!parent) +		{ +			std::map<U32, OrphanList>::iterator iter = mOrphanMap.find(parent_id); +			if(iter != mOrphanMap.end()) +			{ +				iter->second.addChild(entry->getLocalID()); +			} +			else  +			{ +				OrphanList o_list(entry->getLocalID()); +				mOrphanMap[parent_id] = o_list; +			} +			 +			return; +		} +		else +		{ +			entry->updateBoundingInfo(parent); +		} +	} +	 +	if(!entry->getGroup() && entry->isState(LLVOCacheEntry::INACTIVE))
 +	{
 +		addToVOCacheTree(entry, true); +	} + +	if(!parent_id) //a potential parent +	{ +		//find all children and update their bounding info +		std::map<U32, OrphanList>::iterator iter = mOrphanMap.find(entry->getLocalID()); +		if(iter != mOrphanMap.end()) +		{ +			std::set<U32>* children = mOrphanMap[parent_id].getChildList(); +			for(std::set<U32>::iterator child_iter = children->begin(); child_iter != children->end(); ++child_iter) +			{ +				LLVOCacheEntry* child = getCacheEntry(*child_iter); +				if(child) +				{ +					child->updateBoundingInfo(entry); +					addToVOCacheTree(child); +				} +			} +			 +			mOrphanMap.erase(entry->getLocalID()); +		} +	} +	 +	return ; +} + +LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerBinaryBuffer &dp)  { -	U32 local_id = objectp->getLocalID(); -	U32 crc = objectp->getCRC();  	eCacheUpdateResult result; +	U32 crc; +	U32 local_id; -	LLVOCacheEntry* entry = getCacheEntry(local_id); +	LLViewerObject::unpackU32(&dp, local_id, "LocalID"); +	LLViewerObject::unpackU32(&dp, crc, "CRC"); +	LLVOCacheEntry* entry = getCacheEntry(local_id); +	  	if (entry)  	{  		// we've seen this object before @@ -1668,9 +1745,22 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec  		{  			// Update the cache entry  			LLPointer<LLVOCacheEntry> new_entry = new LLVOCacheEntry(local_id, crc, dp); -			replaceCacheEntry(entry, new_entry); -			entry = new_entry; - +			 +			//if visible, update it +			if(!entry->isState(LLVOCacheEntry::INACTIVE)) +			{ +				replaceCacheEntry(entry, new_entry); +			} +			else //invisible +			{ +				//remove old entry +				killCacheEntry(entry); +				entry = new_entry; +				 +				mImpl->mCacheMap[local_id] = entry; +				postProcesNewEntry(entry); +			} +			  			result = CACHE_UPDATE_CHANGED;  		}  	} @@ -1679,17 +1769,21 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec  		// we haven't seen this object before  		// Create new entry and add to map  		result = CACHE_UPDATE_ADDED; -		//if (mImpl->mCacheMap.size() > MAX_OBJECT_CACHE_ENTRIES) -		//{ -		//	delete mImpl->mCacheMap.begin()->second ; -		//	mImpl->mCacheMap.erase(mImpl->mCacheMap.begin()); -		//	result = CACHE_UPDATE_REPLACED; -		// -		//}  		entry = new LLVOCacheEntry(local_id, crc, dp); - +		  		mImpl->mCacheMap[local_id] = entry; +		 +		postProcesNewEntry(entry);  	} +	 +	return result; +} + +LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp) +{ +	eCacheUpdateResult result = cacheFullUpdate(dp); + +	LLVOCacheEntry* entry = mImpl->mCacheMap[objectp->getLocalID()];  	if(objectp->mDrawable.notNull() && !entry->getEntry())  	{ @@ -1754,13 +1848,13 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss  			// Record a hit  			entry->recordHit();  			cache_miss_type = CACHE_MISS_TYPE_NONE; - +			  			if(entry->getGroup() || !entry->isState(LLVOCacheEntry::INACTIVE))  			{  				return true;  			} - -			addVisibleCacheEntry(entry); +			//addVisibleCacheEntry(entry); +			addToVOCacheTree(entry, true);  			return true;  		}  		else diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index de14c0fe27..6da8c191a4 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -317,6 +317,7 @@ public:  	} eCacheUpdateResult;  	// handle a full update message +	eCacheUpdateResult cacheFullUpdate(LLDataPackerBinaryBuffer &dp);  	eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp);	  	LLVOCacheEntry* getCacheEntryForOctree(U32 local_id);  	bool probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss_type); @@ -347,7 +348,7 @@ public:  	void getNeighboringRegionsStatus( std::vector<S32>& regions );  private: -	void addToVOCacheTree(LLVOCacheEntry* entry); +	void addToVOCacheTree(LLVOCacheEntry* entry, bool forced = false);  	LLViewerObject* addNewObject(LLVOCacheEntry* entry);  	void killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& delete_list);  	LLVOCacheEntry* getCacheEntry(U32 local_id); @@ -360,6 +361,7 @@ private:  	F32 updateVisibleEntries(F32 max_time); //update visible entries  	void addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type, F32 weight); +	void postProcesNewEntry(LLVOCacheEntry* entry);  public:  	struct CompareDistance  	{ @@ -445,6 +447,21 @@ private:  	BOOL    mReleaseNotesRequested;  	BOOL    mDead;  //if true, this region is in the process of deleting. +	class OrphanList +	{ +	public: +		OrphanList(){} +		OrphanList(U32 child_id){addChild(child_id);} +		 +		void addChild(U32 child_id) {mChildList.insert(child_id);} +		std::set<U32>* getChildList() {return &mChildList;} +		 +	private: +		std::set<U32> mChildList; +	}; +	 +	std::map<U32, OrphanList> mOrphanMap; +	  	class CacheMissItem  	{  	public: diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 86cfbb1d74..26c3e04b92 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -198,10 +198,8 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry)  	if(!entry && mDP.getBufferSize() > 0)  	{  		LLUUID fullid; -		mDP.reset(); -		mDP.unpackUUID(fullid, "ID"); -		mDP.reset(); - +		LLViewerObject::unpackUUID(&mDP, fullid, "ID"); +		  		LLViewerObject* obj = gObjectList.findObject(fullid);  		if(obj && obj->mDrawable)  		{ @@ -402,6 +400,28 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool  	setVisible();  } +void LLVOCacheEntry::setBoundingInfo(const LLVector3& pos, const LLVector3& scale) +{ +	LLVector4a center, newMin, newMax; +	center.load3(pos.mV); +	LLVector4a size; +	size.load3(scale.mV); +	newMin.setSub(center, size); +	newMax.setAdd(center, size); +	 +	setPositionGroup(center); +	setSpatialExtents(newMin, newMax); +	setBinRadius(llmin(size.getLength3().getF32() * 4.f, 256.f)); +} + +void LLVOCacheEntry::updateBoundingInfo(LLVOCacheEntry* parent) +{ +	//LLVector4a old_pos = getPositionGroup(); +	//parent->getPositionRegion() + (getPosition() * parent->getRotation()); +	 +	shift(parent->getPositionGroup()); +} +  //-------------------------------------------------------------------  //LLVOCachePartition  //------------------------------------------------------------------- diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h index c631e12739..7c1706e650 100644 --- a/indra/newview/llvocache.h +++ b/indra/newview/llvocache.h @@ -116,6 +116,10 @@ public:  	S32  getNumOfChildren()         {return mChildrenList.size();}  	void clearChildrenList()        {mChildrenList.clear();} +	//called from processing object update message +	void setBoundingInfo(const LLVector3& pos, const LLVector3& scale); +	void updateBoundingInfo(LLVOCacheEntry* parent); +	  public:  	typedef std::map<U32, LLPointer<LLVOCacheEntry> >	   vocache_entry_map_t;  	typedef std::set<LLVOCacheEntry*>                      vocache_entry_set_t;  | 
