summaryrefslogtreecommitdiff
path: root/indra/newview/llface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llface.cpp')
-rwxr-xr-x[-rw-r--r--]indra/newview/llface.cpp200
1 files changed, 94 insertions, 106 deletions
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 8f8b35c578..6a79e68c6a 100644..100755
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -51,7 +51,7 @@
#include "llviewerregion.h"
#include "llviewerwindow.h"
#include "llviewershadermgr.h"
-#include "llviewertexture.h"
+
#define LL_MAX_INDICES_COUNT 1000000
@@ -167,11 +167,13 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp)
//special value to indicate uninitialized position
mIndicesIndex = 0xFFFFFFFF;
- for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i)
- {
- mIndexInTex[i] = 0;
- mTexture[i] = NULL;
- }
+ mIndexInTex[LLRender::DIFFUSE_MAP] =
+ mIndexInTex[LLRender::NORMAL_MAP] =
+ mIndexInTex[LLRender::SPECULAR_MAP] = 0;
+
+ mTexture[LLRender::DIFFUSE_MAP] =
+ mTexture[LLRender::NORMAL_MAP] =
+ mTexture[LLRender::SPECULAR_MAP] = NULL;
mTEOffset = -1;
mTextureIndex = 255;
@@ -199,14 +201,21 @@ void LLFace::destroy()
gPipeline.checkReferences(this);
}
- for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i)
+ if(!mTexture[LLRender::DIFFUSE_MAP].isNull())
{
- if(mTexture[i].notNull())
- {
- mTexture[i]->removeFace(i, this) ;
- }
+ mTexture[LLRender::DIFFUSE_MAP]->removeFace(LLRender::DIFFUSE_MAP, this) ;
}
+ if(!mTexture[LLRender::NORMAL_MAP].isNull())
+ {
+ mTexture[LLRender::NORMAL_MAP]->removeFace(LLRender::NORMAL_MAP, this) ;
+ }
+
+ if(!mTexture[LLRender::SPECULAR_MAP].isNull())
+ {
+ mTexture[LLRender::SPECULAR_MAP]->removeFace(LLRender::SPECULAR_MAP, this) ;
+ }
+
if (isState(LLFace::PARTICLE))
{
LLVOPartGroup::freeVBSlot(getGeomIndex()/4);
@@ -244,7 +253,7 @@ void LLFace::destroy()
}
setDrawInfo(NULL);
-
+
mDrawablep = NULL;
mVObjp = NULL;
}
@@ -297,16 +306,29 @@ void LLFace::setPool(LLFacePool* new_pool, LLViewerTexture *texturep)
setTexture(texturep) ;
}
-void LLFace::setTexture(U32 ch, LLViewerTexture* tex)
+void LLFace::setTexture(LLViewerTexture* tex)
{
- llassert(ch < LLRender::NUM_TEXTURE_CHANNELS);
+ setTexture(LLRender::DIFFUSE_MAP, tex);
+}
+
+void LLFace::setNormalMap(LLViewerTexture* tex)
+{
+ setTexture(LLRender::NORMAL_MAP, tex);
+}
+
+void LLFace::setSpecularMap(LLViewerTexture* tex)
+{
+ setTexture(LLRender::SPECULAR_MAP, tex);
+}
+void LLFace::setTexture(U32 ch, LLViewerTexture* tex)
+{
if(mTexture[ch] == tex)
{
return ;
}
- if(mTexture[ch].notNull())
+ if(!mTexture[ch].isNull())
{
mTexture[ch]->removeFace(ch, this) ;
}
@@ -319,53 +341,26 @@ void LLFace::setTexture(U32 ch, LLViewerTexture* tex)
mTexture[ch] = tex ;
}
-void LLFace::setTexture(LLViewerTexture* tex)
-{
- setDiffuseMap(tex);
-}
-
-void LLFace::setDiffuseMap(LLViewerTexture* tex)
-{
- setTexture(LLRender::DIFFUSE_MAP, tex);
-}
-
-void LLFace::setNormalMap(LLViewerTexture* tex)
-{
- setTexture(LLRender::NORMAL_MAP, tex);
-}
-
-void LLFace::setSpecularMap(LLViewerTexture* tex)
-{
- setTexture(LLRender::SPECULAR_MAP, tex);
-}
-
void LLFace::dirtyTexture()
{
LLDrawable* drawablep = getDrawable();
- if (mVObjp.notNull() && mVObjp->getVolume())
- {
- for (U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch)
+ if (mVObjp.notNull() && mVObjp->getVolume() &&
+ !mTexture[LLRender::DIFFUSE_MAP].isNull() && (mTexture[LLRender::DIFFUSE_MAP]->getComponents() == 4))
+ { //dirty texture on an alpha object should be treated as an LoD update
+ LLVOVolume* vobj = drawablep->getVOVolume();
+ if (vobj)
{
- if (mTexture[ch].notNull() && mTexture[ch]->getComponents() == 4)
- { //dirty texture on an alpha object should be treated as an LoD update
- LLVOVolume* vobj = drawablep->getVOVolume();
- if (vobj)
- {
- vobj->mLODChanged = TRUE;
- }
- gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_VOLUME, FALSE);
- }
+ vobj->mLODChanged = TRUE;
}
- }
+ gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_VOLUME, FALSE);
+ }
gPipeline.markTextured(drawablep);
}
void LLFace::switchTexture(U32 ch, LLViewerTexture* new_texture)
{
- llassert(ch < LLRender::NUM_TEXTURE_CHANNELS);
-
if(mTexture[ch] == new_texture)
{
return ;
@@ -376,16 +371,9 @@ void LLFace::switchTexture(U32 ch, LLViewerTexture* new_texture)
llerrs << "Can not switch to a null texture." << llendl;
return;
}
-
- llassert(mTexture[ch].notNull());
-
new_texture->addTextureStats(mTexture[ch]->getMaxVirtualSize()) ;
- if (ch == LLRender::DIFFUSE_MAP)
- {
- getViewerObject()->changeTEImage(mTEOffset, new_texture) ;
- }
-
+ getViewerObject()->changeTEImage(mTEOffset, new_texture) ;
setTexture(ch, new_texture) ;
dirtyTexture();
}
@@ -594,8 +582,8 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color)
/* removed in lieu of raycast uv detection
void LLFace::renderSelectedUV()
{
- LLViewerTexture* red_blue_imagep = LLViewerTextureManager::getFetchedTextureFromFile("uv_test1.j2c", TRUE, LLViewerTexture::BOOST_UI);
- LLViewerTexture* green_imagep = LLViewerTextureManager::getFetchedTextureFromFile("uv_test2.tga", TRUE, LLViewerTexture::BOOST_UI);
+ LLViewerTexture* red_blue_imagep = LLViewerTextureManager::getFetchedTextureFromFile("uv_test1.j2c", TRUE, LLGLTexture::BOOST_UI);
+ LLViewerTexture* green_imagep = LLViewerTextureManager::getFetchedTextureFromFile("uv_test2.tga", TRUE, LLGLTexture::BOOST_UI);
LLGLSUVSelect object_select;
@@ -1664,7 +1652,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
}
bool do_tex_mat = tex_mode && mTextureMatrix;
-
+
if (!do_bump)
{ //not bump mapped, might be able to do a cheap update
mVertexBuffer->getTexCoord0Strider(tex_coords0, mGeomIndex, mGeomCount);
@@ -1781,9 +1769,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
else
{ //bump mapped or has material, just do the whole expensive loop
LLFastTimer t(FTM_FACE_TEX_DEFAULT);
-
- std::vector<LLVector2> bump_tc;
+ std::vector<LLVector2> bump_tc;
+
if (mat)
{ //writing out normal and specular texture coordinates, not bump offsets
do_bump = false;
@@ -1840,55 +1828,55 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
}
- for (S32 i = 0; i < num_vertices; i++)
- {
- LLVector2 tc(vf.mTexCoords[i]);
+ for (S32 i = 0; i < num_vertices; i++)
+ {
+ LLVector2 tc(vf.mTexCoords[i]);
- LLVector4a& norm = vf.mNormals[i];
+ LLVector4a& norm = vf.mNormals[i];
- LLVector4a& center = *(vf.mCenter);
+ LLVector4a& center = *(vf.mCenter);
- if (texgen != LLTextureEntry::TEX_GEN_DEFAULT)
- {
- LLVector4a vec = vf.mPositions[i];
+ if (texgen != LLTextureEntry::TEX_GEN_DEFAULT)
+ {
+ LLVector4a vec = vf.mPositions[i];
- vec.mul(scalea);
-
- switch (texgen)
- {
- case LLTextureEntry::TEX_GEN_PLANAR:
- planarProjection(tc, norm, center, vec);
- break;
- case LLTextureEntry::TEX_GEN_SPHERICAL:
- sphericalProjection(tc, norm, center, vec);
- break;
- case LLTextureEntry::TEX_GEN_CYLINDRICAL:
- cylindricalProjection(tc, norm, center, vec);
- break;
- default:
- break;
- }
- }
+ vec.mul(scalea);
- if (tex_mode && mTextureMatrix)
+ switch (texgen)
{
- LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f);
- tmp = tmp * *mTextureMatrix;
- tc.mV[0] = tmp.mV[0];
- tc.mV[1] = tmp.mV[1];
- }
- else
- {
- xform(tc, cos_ang, sin_ang, os, ot, ms, mt);
- }
+ case LLTextureEntry::TEX_GEN_PLANAR:
+ planarProjection(tc, norm, center, vec);
+ break;
+ case LLTextureEntry::TEX_GEN_SPHERICAL:
+ sphericalProjection(tc, norm, center, vec);
+ break;
+ case LLTextureEntry::TEX_GEN_CYLINDRICAL:
+ cylindricalProjection(tc, norm, center, vec);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (tex_mode && mTextureMatrix)
+ {
+ LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f);
+ tmp = tmp * *mTextureMatrix;
+ tc.mV[0] = tmp.mV[0];
+ tc.mV[1] = tmp.mV[1];
+ }
+ else
+ {
+ xform(tc, cos_ang, sin_ang, os, ot, ms, mt);
+ }
*dst++ = tc;
- if (do_bump)
- {
- bump_tc.push_back(tc);
- }
+ if (do_bump)
+ {
+ bump_tc.push_back(tc);
}
}
+ }
if (map_range)
{
@@ -2028,11 +2016,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
LLFastTimer t(FTM_FACE_GEOM_BINORMAL);
mVertexBuffer->getBinormalStrider(binorm, mGeomIndex, mGeomCount, map_range);
F32* binormals = (F32*) binorm.get();
-
+
mVObjp->getVolume()->genBinormals(f);
for (S32 i = 0; i < num_vertices; i++)
- {
+ {
LLVector4a binormal;
mat_normal.rotate(vf.mBinormals[i], binormal);
binormal.normalize3fast();
@@ -2578,11 +2566,11 @@ LLVector3 LLFace::getPositionAgent() const
}
LLViewerTexture* LLFace::getTexture(U32 ch) const
-{
+ {
llassert(ch < LLRender::NUM_TEXTURE_CHANNELS);
return mTexture[ch] ;
-}
+ }
void LLFace::setVertexBuffer(LLVertexBuffer* buffer)
{