diff options
| -rw-r--r-- | indra/newview/llvosky.cpp | 118 | 
1 files changed, 58 insertions, 60 deletions
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 0799d63cbb..cb2b2e8dfb 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -113,7 +113,7 @@ void LLSkyTex::init(bool isShiny)  		mTexture[i] = LLViewerTextureManager::getLocalTexture(FALSE);  		mTexture[i]->setAddressMode(LLTexUnit::TAM_CLAMP);  		mImageRaw[i] = new LLImageRaw(sResolution, sResolution, sComponents); -		 +  		initEmpty(i);  	}  } @@ -208,7 +208,7 @@ void LLSkyTex::create()  }  void LLSkyTex::createGLImage(S32 which) -{	 +{  	mTexture[which]->setExplicitFormat(GL_RGBA8, GL_RGBA);  	mTexture[which]->createGLTexture(0, mImageRaw[which], 0, TRUE, LLGLTexture::LOCAL);  	mTexture[which]->setAddressMode(LLTexUnit::TAM_CLAMP); @@ -433,7 +433,7 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)  	{  		mFace[i] = NULL;  	} -	 +  	mCameraPosAgent = gAgentCamera.getCameraPositionAgent();  	mAtmHeight = ATM_HEIGHT;  	mEarthCenter = LLVector3(mCameraPosAgent.mV[0], mCameraPosAgent.mV[1], -EARTH_RADIUS); @@ -547,7 +547,7 @@ void LLVOSky::initCubeMap()  	{  		images.push_back(mShinyTex[side].getImageRaw());  	} -	 +  	if (!mCubeMap && gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps)  	{          mCubeMap = new LLCubeMap(false); @@ -594,9 +594,9 @@ void LLVOSky::restoreGL()  	updateDirections(psky);  	if (gSavedSettings.getBOOL("RenderWater") && gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) -		{ +	{  		initCubeMap(); -		} +	}      forceSkyUpdate(); @@ -706,7 +706,7 @@ bool LLVOSky::updateSky()  	static S32 next_frame = 0;  	const S32 total_no_tiles = NUM_CUBEMAP_FACES * NUM_TILES;  	const S32 cycle_frame_no = total_no_tiles + 1; -	 +      mNeedUpdate = mForceUpdate;  	++next_frame; @@ -722,7 +722,7 @@ bool LLVOSky::updateSky()          mForceUpdate = FALSE;          return TRUE;  	} -	 +      if (mCubeMapUpdateStage < 0)      {          LL_RECORD_BLOCK_TIME(FTM_VOSKY_CALC); @@ -886,10 +886,10 @@ void LLVOSky::setSunScale(F32 sun_scale)  void LLVOSky::setMoonScale(F32 moon_scale)  {      mMoonScale = moon_scale; -	} -	 +} +  void LLVOSky::setSunTextures(const LLUUID& sun_texture, const LLUUID& sun_texture_next) -	{ +{      // We test the UUIDs here because we explicitly do not want the default image returned by getFetchedTexture in that case...      mSunTexturep[0] = sun_texture.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(sun_texture, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);      mSunTexturep[1] = sun_texture_next.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(sun_texture_next, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); @@ -907,32 +907,32 @@ void LLVOSky::setSunTextures(const LLUUID& sun_texture, const LLUUID& sun_textur          LLViewerTexture* current_tex1 = mFace[FACE_SUN]->getTexture(LLRender::ALTERNATE_DIFFUSE_MAP);          if (current_tex0 && (mSunTexturep[0] != current_tex0) && current_tex0->isViewerMediaTexture()) -			{ +        {              static_cast<LLViewerMediaTexture*>(current_tex0)->removeMediaFromFace(mFace[FACE_SUN]);          }          if (current_tex1 && (mSunTexturep[1] != current_tex1) && current_tex1->isViewerMediaTexture()) -				{ +        {              static_cast<LLViewerMediaTexture*>(current_tex1)->removeMediaFromFace(mFace[FACE_SUN]); -						} +        }          mFace[FACE_SUN]->setTexture(LLRender::DIFFUSE_MAP, mSunTexturep[0]);          if (can_use_wl)          {              if (mSunTexturep[1]) -						{ -	            mSunTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP); -						} +            { +                mSunTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP); +            }              mFace[FACE_SUN]->setTexture(LLRender::ALTERNATE_DIFFUSE_MAP, mSunTexturep[1]); -					} -				} -			} +        } +    } +}  void LLVOSky::setMoonTextures(const LLUUID& moon_texture, const LLUUID& moon_texture_next) -			{ +{      LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); -			 +      bool can_use_wl = gPipeline.canUseWindLightShaders();      mMoonTexturep[0] = moon_texture.isNull()      ? nullptr : LLViewerTextureManager::getFetchedTexture(moon_texture, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); @@ -941,17 +941,17 @@ void LLVOSky::setMoonTextures(const LLUUID& moon_texture, const LLUUID& moon_tex      if (mFace[FACE_MOON])      {          if (mMoonTexturep[0]) -		{ -	        mMoonTexturep[0]->setAddressMode(LLTexUnit::TAM_CLAMP); -	} +        { +            mMoonTexturep[0]->setAddressMode(LLTexUnit::TAM_CLAMP); +        }          mFace[FACE_MOON]->setTexture(LLRender::DIFFUSE_MAP, mMoonTexturep[0]);          if (mMoonTexturep[1] && can_use_wl) -	{ -	        mMoonTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP); +        { +            mMoonTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP);              mFace[FACE_MOON]->setTexture(LLRender::ALTERNATE_DIFFUSE_MAP, mMoonTexturep[1]); -	} -	} +        } +    }  }  void LLVOSky::setCloudNoiseTextures(const LLUUID& cloud_noise_texture, const LLUUID& cloud_noise_texture_next) @@ -960,7 +960,7 @@ void LLVOSky::setCloudNoiseTextures(const LLUUID& cloud_noise_texture, const LLU      mCloudNoiseTexturep[0] = cloud_noise_texture.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(cloud_noise_texture, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);      mCloudNoiseTexturep[1] = cloud_noise_texture_next.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(cloud_noise_texture_next, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); -	 +      if (mCloudNoiseTexturep[0])  	{  	    mCloudNoiseTexturep[0]->setAddressMode(LLTexUnit::TAM_WRAP); @@ -983,15 +983,15 @@ void LLVOSky::setBloomTextures(const LLUUID& bloom_texture, const LLUUID& bloom_      mBloomTexturep[1] = bloom_tex_next.isNull() ? nullptr : LLViewerTextureManager::getFetchedTexture(bloom_tex_next, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);      if (mBloomTexturep[0]) -{	 -	    mBloomTexturep[0]->setAddressMode(LLTexUnit::TAM_CLAMP); +    { +        mBloomTexturep[0]->setAddressMode(LLTexUnit::TAM_CLAMP);      }      if (mBloomTexturep[1]) -	{ -	    mBloomTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP); +    { +        mBloomTexturep[1]->setAddressMode(LLTexUnit::TAM_CLAMP);      } -	} +}  static LLTrace::BlockTimerStatHandle FTM_GEO_SKY("Sky Geometry"); @@ -1026,7 +1026,7 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable)  	LLStrider<LLVector2> texCoordsp;  	LLStrider<U16> indicesp;  	U16 index_offset; -	LLFace *face;	 +	LLFace *face;  	for (S32 side = 0; side < NUM_CUBEMAP_FACES; ++side)  	{ @@ -1042,7 +1042,7 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable)  			face->setVertexBuffer(buff);  			index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp); -			 +  			S32 vtx = 0;  			S32 curr_bit = side >> 1; // 0/1 = Z axis, 2/3 = Y, 4/5 = X  			S32 side_dir = side & 1;  // even - 0, odd - 1 @@ -1165,7 +1165,7 @@ bool LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, F32 scale, const  	if (!facep->getVertexBuffer())  	{ -		facep->setSize(4, 6);	 +		facep->setSize(4, 6);  		LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolSky::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB);  		if (!buff->allocateBuffer(facep->getGeomCount(), facep->getIndicesCount(), TRUE))  		{ @@ -1417,13 +1417,13 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H,  		face->setGeomIndex(0);  		face->setVertexBuffer(buff);  	} -	 +  	LLStrider<LLVector3> verticesp;  	LLStrider<LLVector3> normalsp;  	LLStrider<LLVector2> texCoordsp;  	LLStrider<U16> indicesp;  	S32 index_offset; -	 +  	index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp);  	if (-1 == index_offset)  	{ @@ -1441,7 +1441,7 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H,          LLColor4 hb_refl_col = (1 - attenuation) * hb_col + attenuation * getSkyFogColor();  	face->setFaceColor(hb_refl_col); -	 +  	LLVector3 v_far[2];  	v_far[0] = v_refl_corner[1];  	v_far[1] = v_refl_corner[3]; @@ -1565,16 +1565,15 @@ void LLVOSky::updateFog(const F32 distance)  	}  void LLVOSky::setSunAndMoonDirectionsCFR(const LLVector3 &sun_dir_cfr, const LLVector3 &moon_dir_cfr) -	{ -    mSun.setDirection(sun_dir_cfr);	 -	mMoon.setDirection(moon_dir_cfr); +{ +    mSun.setDirection(sun_dir_cfr); +    mMoon.setDirection(moon_dir_cfr); -	// Push the sun "South" as it approaches directly overhead so that we can always see bump mapping -	// on the upward facing faces of cubes. -	{ -	    // Same as dot product with the up direction + clamp. -	    F32 sunDot = llmax(0.f, sun_dir_cfr.mV[2]); -	    sunDot *= sunDot;	 +    // Push the sun "South" as it approaches directly overhead so that we can always see bump mapping +    // on the upward facing faces of cubes. +    // Same as dot product with the up direction + clamp. +    F32 sunDot = llmax(0.f, sun_dir_cfr.mV[2]); +    sunDot *= sunDot;      // Create normalized vector that has the sunDir pushed south about an hour and change.      LLVector3 adjustedDir = (sun_dir_cfr + LLVector3(0.f, -0.70711f, 0.70711f)) * 0.5f; @@ -1589,18 +1588,17 @@ void LLVOSky::setSunAndMoonDirectionsCFR(const LLVector3 &sun_dir_cfr, const LLV  }  void LLVOSky::setSunDirectionCFR(const LLVector3 &sun_dir_cfr) -	{ -    mSun.setDirection(sun_dir_cfr);	 +{ +    mSun.setDirection(sun_dir_cfr); -	// Push the sun "South" as it approaches directly overhead so that we can always see bump mapping -	// on the upward facing faces of cubes. -    { -	// Same as dot product with the up direction + clamp. -	    F32 sunDot = llmax(0.f, sun_dir_cfr.mV[2]); -	sunDot *= sunDot;	 +    // Push the sun "South" as it approaches directly overhead so that we can always see bump mapping +    // on the upward facing faces of cubes. +    // Same as dot product with the up direction + clamp. +    F32 sunDot = llmax(0.f, sun_dir_cfr.mV[2]); +    sunDot *= sunDot; -	// Create normalized vector that has the sunDir pushed south about an hour and change. -	    LLVector3 adjustedDir = (sun_dir_cfr + LLVector3(0.f, -0.70711f, 0.70711f)) * 0.5f; +    // Create normalized vector that has the sunDir pushed south about an hour and change. +    LLVector3 adjustedDir = (sun_dir_cfr + LLVector3(0.f, -0.70711f, 0.70711f)) * 0.5f;      // Blend between normal sun dir and adjusted sun dir based on how close we are      // to having the sun overhead.  | 
