diff options
Diffstat (limited to 'indra/newview/lldrawable.cpp')
| -rwxr-xr-x[-rw-r--r--] | indra/newview/lldrawable.cpp | 178 | 
1 files changed, 130 insertions, 48 deletions
| diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 108ec92f6d..8c9fd4152a 100644..100755 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -57,6 +57,8 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f;  static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound"); +extern bool gShiftFrame; +  ////////////////////////  // @@ -97,7 +99,6 @@ void LLDrawable::init()  	mPositionGroup.clear();  	mExtents[0].clear();  	mExtents[1].clear(); -	mQuietCount = 0;  	mState     = 0;  	mVObjp   = NULL; @@ -108,6 +109,8 @@ void LLDrawable::init()  	mGeneration = -1;  	mBinRadius = 1.f; +	mBinIndex = -1; +  	mSpatialBridge = NULL;  } @@ -251,11 +254,17 @@ S32 LLDrawable::findReferences(LLDrawable *drawablep)  	return count;  } +static LLFastTimer::DeclareTimer FTM_ALLOCATE_FACE("Allocate Face", true); +  LLFace*	LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep)  { -	LLMemType mt(LLMemType::MTYPE_DRAWABLE); -	LLFace *face = new LLFace(this, mVObjp); +	LLFace *face; +	{ +		LLFastTimer t(FTM_ALLOCATE_FACE); +		face = new LLFace(this, mVObjp); +	} +  	if (!face) llerrs << "Allocating new Face: " << mFaces.size() << llendl;  	if (face) @@ -277,10 +286,12 @@ LLFace*	LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep)  LLFace*	LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep)  { -	LLMemType mt(LLMemType::MTYPE_DRAWABLE); -	  	LLFace *face; -	face = new LLFace(this, mVObjp); + +	{ +		LLFastTimer t(FTM_ALLOCATE_FACE); +		face = new LLFace(this, mVObjp); +	}  	face->setTEOffset(mFaces.size());  	face->setTexture(texturep); @@ -297,6 +308,49 @@ LLFace*	LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep)  } +LLFace*	LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp) +{ +	LLFace *face; +	face = new LLFace(this, mVObjp); +	 +	face->setTEOffset(mFaces.size()); +	face->setTexture(texturep); +	face->setNormalMap(normalp); +	face->setPoolType(gPipeline.getPoolTypeFromTE(te, texturep)); +	 +	mFaces.push_back(face); +	 +	if (isState(UNLIT)) +	{ +		face->setState(LLFace::FULLBRIGHT); +	} +	 +	return face; +	 +} + +LLFace*	LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp, LLViewerTexture *specularp) +{ +	LLFace *face; +	face = new LLFace(this, mVObjp); +	 +	face->setTEOffset(mFaces.size()); +	face->setTexture(texturep); +	face->setNormalMap(normalp); +	face->setSpecularMap(specularp); +	face->setPoolType(gPipeline.getPoolTypeFromTE(te, texturep)); +	 +	mFaces.push_back(face); +	 +	if (isState(UNLIT)) +	{ +		face->setState(LLFace::FULLBRIGHT); +	} +	 +	return face; +	 +} +  void LLDrawable::setNumFaces(const S32 newFaces, LLFacePool *poolp, LLViewerTexture *texturep)  {  	if (newFaces == (S32)mFaces.size()) @@ -403,6 +457,8 @@ void LLDrawable::makeActive()  		if (!isRoot() && !mParent->isActive())  		{  			mParent->makeActive(); +			//NOTE: linked set will now NEVER become static +			mParent->setState(LLDrawable::ACTIVE_CHILD);  		}  		//all child objects must also be active @@ -422,40 +478,26 @@ void LLDrawable::makeActive()  		if (mVObjp->getPCode() == LL_PCODE_VOLUME)  		{ -			if (mVObjp->isFlexible()) -			{ -				return; -			} -		} -	 -		if (mVObjp->getPCode() == LL_PCODE_VOLUME) -		{  			gPipeline.markRebuild(this, LLDrawable::REBUILD_VOLUME, TRUE);  		}  		updatePartition();  	} -	if (isRoot()) -	{ -		mQuietCount = 0; -	} -	else -	{ -		getParent()->mQuietCount = 0; -	} +	llassert(isAvatar() || isRoot() || mParent->isActive());  }  void LLDrawable::makeStatic(BOOL warning_enabled)  { -	if (isState(ACTIVE)) +	if (isState(ACTIVE) &&  +		!isState(ACTIVE_CHILD) &&  +		!mVObjp->isAttachment() &&  +		!mVObjp->isFlexible())  	{  		clearState(ACTIVE | ANIMATED_CHILD); -		if (mParent.notNull() && mParent->isActive() && warning_enabled) -		{ -			LL_WARNS_ONCE("Drawable") << "Drawable becomes static with active parent!" << LL_ENDL; -		} +		//drawable became static with active parent, not acceptable +		llassert(mParent.isNull() || !mParent->isActive() || !warning_enabled);  		LLViewerObject::const_child_list_t& child_list = mVObjp->getChildren();  		for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); @@ -483,8 +525,8 @@ void LLDrawable::makeStatic(BOOL warning_enabled)  			mSpatialBridge->markDead();  			setSpatialBridge(NULL);  		} +		updatePartition();  	} -	updatePartition();  }  // Returns "distance" between target destination and resulting xfrom @@ -512,7 +554,6 @@ F32 LLDrawable::updateXform(BOOL undamped)  	//scaling  	LLVector3 target_scale = mVObjp->getScale();  	LLVector3 old_scale = mCurrentScale; -	LLVector3 dest_scale = target_scale;  	// Damping  	F32 dist_squared = 0.f; @@ -525,6 +566,7 @@ F32 LLDrawable::updateXform(BOOL undamped)  		dist_squared = dist_vec_squared(new_pos, target_pos);  		LLQuaternion new_rot = nlerp(lerp_amt, old_rot, target_rot); +		// FIXME: This can be negative! It is be possible for some rots to 'cancel out' pos or size changes.  		dist_squared += (1.f - dot(new_rot, target_rot)) * 10.f;  		LLVector3 new_scale = lerp(old_scale, target_scale, lerp_amt); @@ -548,6 +590,15 @@ F32 LLDrawable::updateXform(BOOL undamped)  			}  		}  	} +	else +	{ +		// The following fixes MAINT-1742 but breaks vehicles similar to MAINT-2275 +		// dist_squared = dist_vec_squared(old_pos, target_pos); + +		// The following fixes MAINT-2247 but causes MAINT-2275 +		//dist_squared += (1.f - dot(old_rot, target_rot)) * 10.f; +		//dist_squared += dist_vec_squared(old_scale, target_scale); +	}  	LLVector3 vec = mCurrentScale-target_scale; @@ -568,6 +619,12 @@ F32 LLDrawable::updateXform(BOOL undamped)  			mVObjp->dirtySpatialGroup();  		}  	} +	else if (!isRoot() && +			((dist_vec_squared(old_pos, target_pos) > 0.f) +			|| (1.f - dot(old_rot, target_rot)) > 0.f)) +	{ //fix for BUG-840, MAINT-2275, MAINT-1742, MAINT-2247 +			gPipeline.markRebuild(this, LLDrawable::REBUILD_POSITION, TRUE); +	}  	else if (!getVOVolume() && !isAvatar())  	{  		movePartition(); @@ -635,18 +692,8 @@ BOOL LLDrawable::updateMove()  	}  	makeActive(); -	 -	BOOL done; -	if (isState(MOVE_UNDAMPED)) -	{ -		done = updateMoveUndamped(); -	} -	else -	{ -		done = updateMoveDamped(); -	} -	return done; +	return isState(MOVE_UNDAMPED) ? updateMoveUndamped() : updateMoveDamped();  }  BOOL LLDrawable::updateMoveUndamped() @@ -714,6 +761,11 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update)  		return;  	} +	if (gShiftFrame) +	{ +		return; +	} +  	//switch LOD with the spatial group to avoid artifacts  	//LLSpatialGroup* sg = getSpatialGroup(); @@ -768,8 +820,6 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update)  void LLDrawable::updateTexture()  { -	LLMemType mt(LLMemType::MTYPE_DRAWABLE); -	  	if (isDead())  	{  		llwarns << "Dead drawable updating texture!" << llendl; @@ -811,14 +861,19 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector)  		mXform.setPosition(mVObjp->getPositionAgent());  	} -	mXform.setRotation(mVObjp->getRotation()); -	mXform.setScale(1,1,1);  	mXform.updateMatrix();  	if (isStatic())  	{  		LLVOVolume* volume = getVOVolume(); -		if (!volume) + +		bool rebuild = (!volume &&  +						getRenderType() != LLPipeline::RENDER_TYPE_TREE && +						getRenderType() != LLPipeline::RENDER_TYPE_TERRAIN && +						getRenderType() != LLPipeline::RENDER_TYPE_SKY && +						getRenderType() != LLPipeline::RENDER_TYPE_GROUND); + +		if (rebuild)  		{  			gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE);  		} @@ -832,7 +887,7 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector)  				facep->mExtents[0].add(shift_vector);  				facep->mExtents[1].add(shift_vector); -				if (!volume && facep->hasGeometry()) +				if (rebuild && facep->hasGeometry())  				{  					facep->clearVertexBuffer();  				} @@ -943,8 +998,20 @@ void LLDrawable::updateUVMinMax()  {  } +LLSpatialGroup* LLDrawable::getSpatialGroup() const +{  +	llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1); +	return mSpatialGroupp;  +} +  void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)  { +	//precondition: mSpatialGroupp MUST be null or DEAD or mSpatialGroupp MUST NOT contain this +	llassert(!mSpatialGroupp || mSpatialGroupp->isDead() || !mSpatialGroupp->hasElement(this)); + +	//precondition: groupp MUST be null or groupp MUST contain this +	llassert(!groupp || groupp->hasElement(this)); +  /*if (mSpatialGroupp && (groupp != mSpatialGroupp))  	{  		mSpatialGroupp->setState(LLSpatialGroup::GEOM_DIRTY); @@ -964,6 +1031,11 @@ void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)  		}  	} +	//postcondition: if next group is NULL, previous group must be dead OR NULL OR binIndex must be -1 +	//postcondition: if next group is NOT NULL, binIndex must not be -1 +	llassert(groupp == NULL ? (mSpatialGroupp == NULL || mSpatialGroupp->isDead()) || getBinIndex() == -1 : +							getBinIndex() != -1); +  	mSpatialGroupp = groupp;  } @@ -1087,6 +1159,8 @@ LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 dat  	mDrawable = root;  	root->setSpatialBridge(this); +	mBinIndex = -1; +  	mRenderType = mDrawable->mRenderType;  	mDrawableType = mDrawable->mRenderType; @@ -1205,7 +1279,6 @@ LLCamera LLSpatialBridge::transformCamera(LLCamera& camera)  	LLCamera ret = camera;  	LLXformMatrix* mat = mDrawable->getXform();  	LLVector3 center = LLVector3(0,0,0) * mat->getWorldMatrix(); -	LLQuaternion rotation = LLQuaternion(mat->getWorldMatrix());  	LLVector3 delta = ret.getOrigin() - center;  	LLQuaternion rot = ~mat->getRotation(); @@ -1391,6 +1464,11 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update)  		return;  	} +	if (gShiftFrame) +	{ +		return; +	} +  	if (mDrawable->getVObj())  	{  		if (mDrawable->getVObj()->isAttachment()) @@ -1468,6 +1546,10 @@ void LLSpatialBridge::cleanupReferences()  	LLDrawable::cleanupReferences();  	if (mDrawable)  	{ +		/* +		 +		DON'T DO THIS -- this should happen through octree destruction +  		mDrawable->setSpatialGroup(NULL);  		if (mDrawable->getVObj())  		{ @@ -1482,7 +1564,7 @@ void LLSpatialBridge::cleanupReferences()  					drawable->setSpatialGroup(NULL);  				}  			} -		} +		}*/  		LLDrawable* drawablep = mDrawable;  		mDrawable = NULL; | 
