MAINT-8317 Fixed Local Textures for Advanced Lighting Projectors do not keep the selected texture.

Tue, 27 Feb 2018 15:49:15 +0200

author
andreykproductengine <andreykproductengine@lindenlab.com>
date
Tue, 27 Feb 2018 15:49:15 +0200
changeset 55309
19a13b5829e8
parent 55304
f0a2a79633cf
child 55310
473367dd6196

MAINT-8317 Fixed Local Textures for Advanced Lighting Projectors do not keep the selected texture.

indra/llrender/llrender.h file | annotate | diff | revisions
indra/newview/lllocalbitmaps.cpp file | annotate | diff | revisions
indra/newview/lllocalbitmaps.h file | annotate | diff | revisions
indra/newview/llviewertexture.cpp file | annotate | diff | revisions
indra/newview/llviewertexture.h file | annotate | diff | revisions
indra/newview/llvovolume.cpp file | annotate | diff | revisions
indra/newview/llvovolume.h file | annotate | diff | revisions
     1.1 --- a/indra/llrender/llrender.h	Mon Feb 26 18:03:59 2018 +0200
     1.2 +++ b/indra/llrender/llrender.h	Tue Feb 27 15:49:15 2018 +0200
     1.3 @@ -269,6 +269,13 @@
     1.4  		SPECULAR_MAP,
     1.5  		NUM_TEXTURE_CHANNELS,
     1.6  	};
     1.7 +
     1.8 +	enum eVolumeTexIndex
     1.9 +	{
    1.10 +		LIGHT_TEX = 0,
    1.11 +		SCULPT_TEX,
    1.12 +		NUM_VOLUME_TEXTURE_CHANNELS,
    1.13 +	};
    1.14  	
    1.15  	typedef enum {
    1.16  		TRIANGLES = 0,
     2.1 --- a/indra/newview/lllocalbitmaps.cpp	Mon Feb 26 18:03:59 2018 +0200
     2.2 +++ b/indra/newview/lllocalbitmaps.cpp	Tue Feb 27 15:49:15 2018 +0200
     2.3 @@ -358,8 +358,9 @@
     2.4  	updateUserPrims(old_id, new_id, LLRender::DIFFUSE_MAP);
     2.5  	updateUserPrims(old_id, new_id, LLRender::NORMAL_MAP);
     2.6  	updateUserPrims(old_id, new_id, LLRender::SPECULAR_MAP);
     2.7 -	
     2.8 -	updateUserSculpts(old_id, new_id); // isn't there supposed to be an IMG_DEFAULT_SCULPT or something?
     2.9 +
    2.10 +	updateUserVolumes(old_id, new_id, LLRender::LIGHT_TEX);	
    2.11 +	updateUserVolumes(old_id, new_id, LLRender::SCULPT_TEX); // isn't there supposed to be an IMG_DEFAULT_SCULPT or something?
    2.12  	
    2.13  	// default safeguard image for layers
    2.14  	if( new_id == IMG_DEFAULT )
    2.15 @@ -502,26 +503,39 @@
    2.16  			}
    2.17  		}
    2.18  	}
    2.19 -	
    2.20  }
    2.21  
    2.22 -void LLLocalBitmap::updateUserSculpts(LLUUID old_id, LLUUID new_id)
    2.23 +void LLLocalBitmap::updateUserVolumes(LLUUID old_id, LLUUID new_id, U32 channel)
    2.24  {
    2.25  	LLViewerFetchedTexture* old_texture = gTextureList.findImage(old_id, TEX_LIST_STANDARD);
    2.26 -	for(U32 volume_iter = 0; volume_iter < old_texture->getNumVolumes(); volume_iter++)
    2.27 +	for (U32 volume_iter = 0; volume_iter < old_texture->getNumVolumes(channel); volume_iter++)
    2.28  	{
    2.29 -		LLVOVolume* volume_to_object = (*old_texture->getVolumeList())[volume_iter];
    2.30 -		LLViewerObject* object = (LLViewerObject*)volume_to_object;
    2.31 -	
    2.32 -		if(object)
    2.33 +		LLVOVolume* volobjp = (*old_texture->getVolumeList(channel))[volume_iter];
    2.34 +		switch (channel)
    2.35  		{
    2.36 -			if (object->isSculpted() && object->getVolume() &&
    2.37 -				object->getVolume()->getParams().getSculptID() == old_id)
    2.38 +			case LLRender::LIGHT_TEX:
    2.39  			{
    2.40 -				LLSculptParams* old_params = (LLSculptParams*)object->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
    2.41 -				LLSculptParams new_params(*old_params);
    2.42 -				new_params.setSculptTexture(new_id, (*old_params).getSculptType());
    2.43 -				object->setParameterEntry(LLNetworkData::PARAMS_SCULPT, new_params, TRUE);
    2.44 +				if (volobjp->getLightTextureID() == old_id)
    2.45 +				{
    2.46 +					volobjp->setLightTextureID(new_id);
    2.47 +				}
    2.48 +				break;
    2.49 +			}
    2.50 +			case LLRender::SCULPT_TEX:
    2.51 +			{
    2.52 +				LLViewerObject* object = (LLViewerObject*)volobjp;
    2.53 +
    2.54 +				if (object)
    2.55 +				{
    2.56 +					if (object->isSculpted() && object->getVolume() &&
    2.57 +						object->getVolume()->getParams().getSculptID() == old_id)
    2.58 +					{
    2.59 +						LLSculptParams* old_params = (LLSculptParams*)object->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
    2.60 +						LLSculptParams new_params(*old_params);
    2.61 +						new_params.setSculptTexture(new_id, (*old_params).getSculptType());
    2.62 +						object->setParameterEntry(LLNetworkData::PARAMS_SCULPT, new_params, TRUE);
    2.63 +					}
    2.64 +				}
    2.65  			}
    2.66  		}
    2.67  	}
     3.1 --- a/indra/newview/lllocalbitmaps.h	Mon Feb 26 18:03:59 2018 +0200
     3.2 +++ b/indra/newview/lllocalbitmaps.h	Tue Feb 27 15:49:15 2018 +0200
     3.3 @@ -64,7 +64,7 @@
     3.4  		void replaceIDs(LLUUID old_id, LLUUID new_id);
     3.5  		std::vector<LLViewerObject*> prepUpdateObjects(LLUUID old_id, U32 channel);
     3.6  		void updateUserPrims(LLUUID old_id, LLUUID new_id, U32 channel);
     3.7 -		void updateUserSculpts(LLUUID old_id, LLUUID new_id);
     3.8 +		void updateUserVolumes(LLUUID old_id, LLUUID new_id, U32 channel);
     3.9  		void updateUserLayers(LLUUID old_id, LLUUID new_id, LLWearableType::EType type);
    3.10  		LLAvatarAppearanceDefines::ETextureIndex getTexIndex(LLWearableType::EType type, LLAvatarAppearanceDefines::EBakedTextureIndex baked_texind);
    3.11  
     4.1 --- a/indra/newview/llviewertexture.cpp	Mon Feb 26 18:03:59 2018 +0200
     4.2 +++ b/indra/newview/llviewertexture.cpp	Tue Feb 27 15:49:15 2018 +0200
     4.3 @@ -651,14 +651,16 @@
     4.4  	mAdditionalDecodePriority = 0.f;	
     4.5  	mParcelMedia = NULL;
     4.6  	
     4.7 -	mNumVolumes = 0;
     4.8 +	memset(&mNumVolumes, 0, sizeof(U32)* LLRender::NUM_VOLUME_TEXTURE_CHANNELS);
     4.9  	mFaceList[LLRender::DIFFUSE_MAP].clear();
    4.10  	mFaceList[LLRender::NORMAL_MAP].clear();
    4.11  	mFaceList[LLRender::SPECULAR_MAP].clear();
    4.12  	mNumFaces[LLRender::DIFFUSE_MAP] = 
    4.13  	mNumFaces[LLRender::NORMAL_MAP] = 
    4.14  	mNumFaces[LLRender::SPECULAR_MAP] = 0;
    4.15 -	mVolumeList.clear();
    4.16 +	
    4.17 +	mVolumeList[LLRender::LIGHT_TEX].clear();
    4.18 +	mVolumeList[LLRender::SCULPT_TEX].clear();
    4.19  }
    4.20  
    4.21  //virtual 
    4.22 @@ -674,7 +676,8 @@
    4.23  	mFaceList[LLRender::DIFFUSE_MAP].clear();
    4.24  	mFaceList[LLRender::NORMAL_MAP].clear();
    4.25  	mFaceList[LLRender::SPECULAR_MAP].clear();
    4.26 -	mVolumeList.clear();
    4.27 +	mVolumeList[LLRender::LIGHT_TEX].clear();
    4.28 +	mVolumeList[LLRender::SCULPT_TEX].clear();
    4.29  }
    4.30  
    4.31  void LLViewerTexture::notifyAboutCreatingTexture()
    4.32 @@ -891,40 +894,40 @@
    4.33  
    4.34  
    4.35  //virtual
    4.36 -void LLViewerTexture::addVolume(LLVOVolume* volumep) 
    4.37 +void LLViewerTexture::addVolume(U32 ch, LLVOVolume* volumep)
    4.38  {
    4.39 -	if( mNumVolumes >= mVolumeList.size())
    4.40 +	if (mNumVolumes[ch] >= mVolumeList[ch].size())
    4.41  	{
    4.42 -		mVolumeList.resize(2 * mNumVolumes + 1);		
    4.43 +		mVolumeList[ch].resize(2 * mNumVolumes[ch] + 1);
    4.44  	}
    4.45 -	mVolumeList[mNumVolumes] = volumep;
    4.46 -	volumep->setIndexInTex(mNumVolumes);
    4.47 -	mNumVolumes++;
    4.48 +	mVolumeList[ch][mNumVolumes[ch]] = volumep;
    4.49 +	volumep->setIndexInTex(ch, mNumVolumes[ch]);
    4.50 +	mNumVolumes[ch]++;
    4.51  	mLastVolumeListUpdateTimer.reset();
    4.52  }
    4.53  
    4.54  //virtual
    4.55 -void LLViewerTexture::removeVolume(LLVOVolume* volumep) 
    4.56 +void LLViewerTexture::removeVolume(U32 ch, LLVOVolume* volumep)
    4.57  {
    4.58 -	if(mNumVolumes > 1)
    4.59 +	if (mNumVolumes[ch] > 1)
    4.60  	{
    4.61 -		S32 index = volumep->getIndexInTex(); 
    4.62 -		llassert(index < mVolumeList.size());
    4.63 -		llassert(index < mNumVolumes);
    4.64 -		mVolumeList[index] = mVolumeList[--mNumVolumes];
    4.65 -		mVolumeList[index]->setIndexInTex(index);
    4.66 +		S32 index = volumep->getIndexInTex(ch); 
    4.67 +		llassert(index < mVolumeList[ch].size());
    4.68 +		llassert(index < mNumVolumes[ch]);
    4.69 +		mVolumeList[ch][index] = mVolumeList[ch][--mNumVolumes[ch]];
    4.70 +		mVolumeList[ch][index]->setIndexInTex(ch, index);
    4.71  	}
    4.72  	else 
    4.73  	{
    4.74 -		mVolumeList.clear();
    4.75 -		mNumVolumes = 0;
    4.76 +		mVolumeList[ch].clear();
    4.77 +		mNumVolumes[ch] = 0;
    4.78  	}
    4.79  	mLastVolumeListUpdateTimer.reset();
    4.80  }
    4.81  
    4.82 -S32 LLViewerTexture::getNumVolumes() const
    4.83 +S32 LLViewerTexture::getNumVolumes(U32 ch) const
    4.84  {
    4.85 -	return mNumVolumes;
    4.86 +	return mNumVolumes[ch];
    4.87  }
    4.88  
    4.89  void LLViewerTexture::reorganizeFaceList()
    4.90 @@ -955,9 +958,13 @@
    4.91  	static const F32 MAX_WAIT_TIME = 20.f; // seconds
    4.92  	static const U32 MAX_EXTRA_BUFFER_SIZE = 4;
    4.93  
    4.94 -	if(mNumVolumes + MAX_EXTRA_BUFFER_SIZE > mVolumeList.size())
    4.95 +
    4.96 +	for (U32 i = 0; i < LLRender::NUM_VOLUME_TEXTURE_CHANNELS; ++i)
    4.97  	{
    4.98 -		return;
    4.99 +		if (mNumVolumes[i] + MAX_EXTRA_BUFFER_SIZE > mVolumeList[i].size())
   4.100 +		{
   4.101 +			return;
   4.102 +		}
   4.103  	}
   4.104  
   4.105  	if(mLastVolumeListUpdateTimer.getElapsedTimeF32() < MAX_WAIT_TIME)
   4.106 @@ -966,7 +973,10 @@
   4.107  	}
   4.108  
   4.109  	mLastVolumeListUpdateTimer.reset();
   4.110 -	mVolumeList.erase(mVolumeList.begin() + mNumVolumes, mVolumeList.end());
   4.111 +	for (U32 i = 0; i < LLRender::NUM_VOLUME_TEXTURE_CHANNELS; ++i)
   4.112 +	{
   4.113 +		mVolumeList[i].erase(mVolumeList[i].begin() + mNumVolumes[i], mVolumeList[i].end());
   4.114 +	}
   4.115  }
   4.116  
   4.117  //virtual
     5.1 --- a/indra/newview/llviewertexture.h	Mon Feb 26 18:03:59 2018 +0200
     5.2 +++ b/indra/newview/llviewertexture.h	Tue Feb 27 15:49:15 2018 +0200
     5.3 @@ -156,10 +156,10 @@
     5.4  	S32 getNumFaces(U32 ch) const;
     5.5  	const ll_face_list_t* getFaceList(U32 channel) const {llassert(channel < LLRender::NUM_TEXTURE_CHANNELS); return &mFaceList[channel];}
     5.6  
     5.7 -	virtual void addVolume(LLVOVolume* volumep);
     5.8 -	virtual void removeVolume(LLVOVolume* volumep);
     5.9 -	S32 getNumVolumes() const;
    5.10 -	const ll_volume_list_t* getVolumeList() const { return &mVolumeList; }
    5.11 +	virtual void addVolume(U32 channel, LLVOVolume* volumep);
    5.12 +	virtual void removeVolume(U32 channel, LLVOVolume* volumep);
    5.13 +	S32 getNumVolumes(U32 channel) const;
    5.14 +	const ll_volume_list_t* getVolumeList(U32 channel) const { return &mVolumeList[channel]; }
    5.15  
    5.16  	
    5.17  	virtual void setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) ;
    5.18 @@ -201,8 +201,8 @@
    5.19  	U32               mNumFaces[LLRender::NUM_TEXTURE_CHANNELS];
    5.20  	LLFrameTimer      mLastFaceListUpdateTimer ;
    5.21  
    5.22 -	ll_volume_list_t  mVolumeList;
    5.23 -	U32					mNumVolumes;
    5.24 +	ll_volume_list_t  mVolumeList[LLRender::NUM_VOLUME_TEXTURE_CHANNELS];
    5.25 +	U32					mNumVolumes[LLRender::NUM_VOLUME_TEXTURE_CHANNELS];
    5.26  	LLFrameTimer	  mLastVolumeListUpdateTimer;
    5.27  
    5.28  	//do not use LLPointer here.
     6.1 --- a/indra/newview/llvovolume.cpp	Mon Feb 26 18:03:59 2018 +0200
     6.2 +++ b/indra/newview/llvovolume.cpp	Tue Feb 27 15:49:15 2018 +0200
     6.3 @@ -222,7 +222,7 @@
     6.4  
     6.5  	mMediaImplList.resize(getNumTEs());
     6.6  	mLastFetchedMediaVersion = -1;
     6.7 -	mIndexInTex = 0;
     6.8 +	memset(&mIndexInTex, 0, sizeof(S32) * LLRender::NUM_VOLUME_TEXTURE_CHANNELS);
     6.9  	mMDCImplCount = 0;
    6.10  }
    6.11  
    6.12 @@ -264,7 +264,11 @@
    6.13  
    6.14  		if (mSculptTexture.notNull())
    6.15  		{
    6.16 -			mSculptTexture->removeVolume(this);
    6.17 +			mSculptTexture->removeVolume(LLRender::SCULPT_TEX, this);
    6.18 +		}
    6.19 +		if (hasLightTexture())
    6.20 +		{
    6.21 +			getLightTexture()->removeVolume(LLRender::LIGHT_TEX, this);
    6.22  		}
    6.23  	}
    6.24  	
    6.25 @@ -1086,11 +1090,11 @@
    6.26  	{
    6.27  		if (old_sculpt.notNull())
    6.28  		{
    6.29 -			old_sculpt->removeVolume(this);
    6.30 +			old_sculpt->removeVolume(LLRender::SCULPT_TEX, this);
    6.31  		}
    6.32  		if (mSculptTexture.notNull())
    6.33  		{
    6.34 -			mSculptTexture->addVolume(this);
    6.35 +			mSculptTexture->addVolume(LLRender::SCULPT_TEX, this);
    6.36  		}
    6.37  	}
    6.38  	
    6.39 @@ -1203,9 +1207,9 @@
    6.40  		getVolume()->sculpt(sculpt_width, sculpt_height, sculpt_components, sculpt_data, discard_level, mSculptTexture->isMissingAsset());
    6.41  
    6.42  		//notify rebuild any other VOVolumes that reference this sculpty volume
    6.43 -		for (S32 i = 0; i < mSculptTexture->getNumVolumes(); ++i)
    6.44 -		{
    6.45 -			LLVOVolume* volume = (*(mSculptTexture->getVolumeList()))[i];
    6.46 +		for (S32 i = 0; i < mSculptTexture->getNumVolumes(LLRender::SCULPT_TEX); ++i)
    6.47 +		{
    6.48 +			LLVOVolume* volume = (*(mSculptTexture->getVolumeList(LLRender::SCULPT_TEX)))[i];
    6.49  			if (volume != this && volume->getVolume() == getVolume())
    6.50  			{
    6.51  				gPipeline.markRebuild(volume->mDrawable, LLDrawable::REBUILD_GEOMETRY, FALSE);
    6.52 @@ -2839,23 +2843,30 @@
    6.53  
    6.54  void LLVOVolume::setLightTextureID(LLUUID id)
    6.55  {
    6.56 +	LLViewerTexture* old_texturep = getLightTexture(); // same as mLightTexture, but inits if nessesary
    6.57  	if (id.notNull())
    6.58  	{
    6.59  		if (!hasLightTexture())
    6.60  		{
    6.61  			setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE, TRUE, true);
    6.62  		}
    6.63 +		else
    6.64 +		{
    6.65 +			old_texturep->removeVolume(LLRender::LIGHT_TEX, this);
    6.66 +		}
    6.67  		LLLightImageParams* param_block = (LLLightImageParams*) getParameterEntry(LLNetworkData::PARAMS_LIGHT_IMAGE);
    6.68  		if (param_block && param_block->getLightTexture() != id)
    6.69  		{
    6.70  			param_block->setLightTexture(id);
    6.71  			parameterChanged(LLNetworkData::PARAMS_LIGHT_IMAGE, true);
    6.72  		}
    6.73 +		getLightTexture()->addVolume(LLRender::LIGHT_TEX, this); // new texture
    6.74  	}
    6.75  	else
    6.76  	{
    6.77  		if (hasLightTexture())
    6.78  		{
    6.79 +			old_texturep->removeVolume(LLRender::LIGHT_TEX, this);
    6.80  			setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT_IMAGE, FALSE, true);
    6.81  			parameterChanged(LLNetworkData::PARAMS_LIGHT_IMAGE, true);
    6.82  			mLightTexture = NULL;
     7.1 --- a/indra/newview/llvovolume.h	Mon Feb 26 18:03:59 2018 +0200
     7.2 +++ b/indra/newview/llvovolume.h	Tue Feb 27 15:49:15 2018 +0200
     7.3 @@ -202,10 +202,10 @@
     7.4  	/*virtual*/ BOOL 	setMaterial(const U8 material);
     7.5  
     7.6  				void	setTexture(const S32 face);
     7.7 -				S32     getIndexInTex() const {return mIndexInTex ;}
     7.8 +				S32     getIndexInTex(U32 ch) const {return mIndexInTex[ch];}
     7.9  	/*virtual*/ BOOL	setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume = false);
    7.10  				void	updateSculptTexture();
    7.11 -				void    setIndexInTex(S32 index) { mIndexInTex = index ;}
    7.12 +				void    setIndexInTex(U32 ch, S32 index) { mIndexInTex[ch] = index ;}
    7.13  				void	sculpt();
    7.14  	 static     void    rebuildMeshAssetCallback(LLVFS *vfs,
    7.15  														  const LLUUID& asset_uuid,
    7.16 @@ -370,7 +370,7 @@
    7.17  	LLPointer<LLViewerFetchedTexture> mLightTexture;
    7.18  	media_list_t mMediaImplList;
    7.19  	S32			mLastFetchedMediaVersion; // as fetched from the server, starts as -1
    7.20 -	S32 mIndexInTex;
    7.21 +	S32 mIndexInTex[LLRender::NUM_VOLUME_TEXTURE_CHANNELS];
    7.22  	S32 mMDCImplCount;
    7.23  
    7.24  	LLPointer<LLRiggedVolume> mRiggedVolume;

mercurial