PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llface.inl

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 160 lines | 118 code | 17 blank | 25 comment | 10 complexity | d1b25b87d86fd4e2dd4de983741f3634 MD5 | raw file
  1/** 
  2 * @file llface.inl
  3 * @brief Inline functions for LLFace
  4 *
  5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLFACE_INL
 28#define LL_LLFACE_INL
 29
 30#include "llglheaders.h"
 31#include "llrender.h"
 32
 33inline BOOL LLFace::getDirty() const
 34{ 
 35	return (mGeneration != mDrawPoolp->mGeneration); 
 36}
 37
 38inline void LLFace::clearDirty()
 39{
 40	mGeneration = mDrawPoolp->mGeneration;
 41}
 42
 43inline const LLTextureEntry* LLFace::getTextureEntry()   const
 44{
 45	return mVObjp->getTE(mTEOffset);
 46}
 47
 48inline LLDrawPool* LLFace::getPool()     const
 49{
 50	return mDrawPoolp;
 51}
 52
 53inline S32 LLFace::getStride()   const
 54{
 55	return mDrawPoolp->getStride();
 56}
 57
 58inline LLDrawable* LLFace::getDrawable() const
 59{
 60	return mDrawablep;
 61}
 62
 63inline LLViewerObject* LLFace::getViewerObject() const
 64{
 65	return mVObjp;
 66}
 67
 68inline S32	LLFace::getColors     (LLStrider<LLColor4U> &colors)
 69{
 70	if (!mGeomCount)
 71	{
 72		return -1;
 73	}
 74	LLColor4U *colorp = NULL;
 75	if (isState(BACKLIST))
 76	{
 77		if (!mBackupMem)
 78		{
 79			printDebugInfo();
 80			llerrs << "No backup memory for face" << llendl;
 81		}
 82		colorp = (LLColor4U*)(mBackupMem + (4 * mIndicesCount) + (mGeomCount * mDrawPoolp->getStride()));
 83		colors = colorp;
 84		return 0;
 85	}
 86	else
 87	{
 88		llassert(mGeomIndex >= 0);
 89		if (!mDrawPoolp->getColorStrider(colors, mGeomIndex))
 90		{
 91			printDebugInfo();
 92			llerrs << "No color pointer for a color strider!" << llendl;
 93		}
 94		mDrawPoolp->setDirtyColors();
 95		return mGeomIndex;
 96	}
 97}
 98
 99inline S32	LLFace::getTexCoords  (LLStrider<LLVector2> &texCoords, S32 pass )
100{
101	if (!mGeomCount)
102	{
103		return -1;
104	}
105	if (isState(BACKLIST))
106	{
107		if (!mBackupMem)
108		{
109			printDebugInfo();
110			llerrs << "No backup memory for face" << llendl;
111		}
112		texCoords = (LLVector2*)(mBackupMem + (4 * mIndicesCount) + mDrawPoolp->mDataOffsets[LLDrawPool::DATA_TEX_COORDS0 + pass]);
113		texCoords.setStride( mDrawPoolp->getStride());
114		return 0;
115	}
116	else
117	{
118		llassert(mGeomIndex >= 0);
119		mDrawPoolp->getTexCoordStrider(texCoords, mGeomIndex, pass );
120		mDrawPoolp->setDirty();
121		return mGeomIndex;
122	}
123}
124
125inline S32	LLFace::getIndices    (U32*  &indicesp)
126{
127	if (isState(BACKLIST))
128	{
129		indicesp = (U32*)mBackupMem;
130		return 0;
131	}
132	else
133	{
134		indicesp = mDrawPoolp->getIndices(mIndicesIndex);
135		llassert(mGeomIndex >= 0);
136		return mGeomIndex;
137	}
138}
139
140inline const U32* LLFace::getRawIndices() const
141{
142	llassert(!isState(BACKLIST));
143
144	return &mDrawPoolp->mIndices[mIndicesIndex];
145}
146
147
148inline void LLFace::bindTexture(S32 stage) const
149{
150	if (mTexture)
151	{
152		mTexture->bindTexture(stage);
153	}
154	else
155	{
156		LLImageGL::unbindTexture(stage, GL_TEXTURE_2D);
157	}
158}
159
160#endif