llface.inl

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLFACE_INL
00033 #define LL_LLFACE_INL
00034 
00035 #include "llglheaders.h"
00036 
00037 inline BOOL LLFace::getDirty() const
00038 { 
00039         return (mGeneration != mDrawPoolp->mGeneration); 
00040 }
00041 
00042 inline void LLFace::clearDirty()
00043 {
00044         mGeneration = mDrawPoolp->mGeneration;
00045 }
00046 
00047 inline const LLTextureEntry* LLFace::getTextureEntry()   const
00048 {
00049         return mVObjp->getTE(mTEOffset);
00050 }
00051 
00052 inline LLDrawPool* LLFace::getPool()     const
00053 {
00054         return mDrawPoolp;
00055 }
00056 
00057 inline S32 LLFace::getStride()   const
00058 {
00059         return mDrawPoolp->getStride();
00060 }
00061 
00062 inline LLDrawable* LLFace::getDrawable() const
00063 {
00064         return mDrawablep;
00065 }
00066 
00067 inline LLViewerObject* LLFace::getViewerObject() const
00068 {
00069         return mVObjp;
00070 }
00071 
00072 
00073 
00074 inline S32 LLFace::getVertices(LLStrider<LLVector3> &vertices)
00075 {
00076         if (!mGeomCount)
00077         {
00078                 return -1;
00079         }
00080         if (isState(BACKLIST))
00081         {
00082                 if (!mBackupMem)
00083                 {
00084                         printDebugInfo();
00085                         llerrs << "No backup memory for face" << llendl;
00086                 }
00087                 vertices = (LLVector3*)(mBackupMem + (4 * mIndicesCount) + mDrawPoolp->mDataOffsets[LLDrawPool::DATA_VERTICES]);
00088                 vertices.setStride( mDrawPoolp->getStride());
00089                 return 0;
00090         }
00091         else
00092         {
00093                 llassert(mGeomIndex >= 0);
00094                 mDrawPoolp->getVertexStrider(vertices, mGeomIndex);
00095                 mDrawPoolp->setDirty();
00096                 return mGeomIndex;
00097         }
00098 }
00099 
00100 inline S32 LLFace::getNormals(LLStrider<LLVector3> &normals)
00101 {
00102         if (!mGeomCount)
00103         {
00104                 return -1;
00105         }
00106         if (isState(BACKLIST))
00107         {
00108                 if (!mBackupMem)
00109                 {
00110                         printDebugInfo();
00111                         llerrs << "No backup memory for face" << llendl;
00112                 }
00113                 normals   = (LLVector3*)(mBackupMem + (4 * mIndicesCount) + mDrawPoolp->mDataOffsets[LLDrawPool::DATA_NORMALS]);
00114                 normals.setStride( mDrawPoolp->getStride());
00115                 return 0;
00116         }
00117         else
00118         {
00119                 llassert(mGeomIndex >= 0);
00120                 mDrawPoolp->getNormalStrider(normals, mGeomIndex);
00121                 mDrawPoolp->setDirty();
00122                 return mGeomIndex;
00123         }
00124 }
00125 
00126 inline S32 LLFace::getBinormals(LLStrider<LLVector3> &binormals)
00127 {
00128         if (!mGeomCount)
00129         {
00130                 return -1;
00131         }
00132         if (isState(BACKLIST))
00133         {
00134                 if (!mBackupMem)
00135                 {
00136                         printDebugInfo();
00137                         llerrs << "No backup memory for face" << llendl;
00138                 }
00139                 binormals   = (LLVector3*)(mBackupMem + (4 * mIndicesCount) + mDrawPoolp->mDataOffsets[LLDrawPool::DATA_BINORMALS]);
00140                 binormals.setStride( mDrawPoolp->getStride());
00141                 return 0;
00142         }
00143         else
00144         {
00145                 llassert(mGeomIndex >= 0);
00146                 mDrawPoolp->getBinormalStrider(binormals, mGeomIndex);
00147                 mDrawPoolp->setDirty();
00148                 return mGeomIndex;
00149         }
00150 }
00151 
00152 
00153 inline S32      LLFace::getColors     (LLStrider<LLColor4U> &colors)
00154 {
00155         if (!mGeomCount)
00156         {
00157                 return -1;
00158         }
00159         LLColor4U *colorp = NULL;
00160         if (isState(BACKLIST))
00161         {
00162                 if (!mBackupMem)
00163                 {
00164                         printDebugInfo();
00165                         llerrs << "No backup memory for face" << llendl;
00166                 }
00167                 colorp = (LLColor4U*)(mBackupMem + (4 * mIndicesCount) + (mGeomCount * mDrawPoolp->getStride()));
00168                 colors = colorp;
00169                 return 0;
00170         }
00171         else
00172         {
00173                 llassert(mGeomIndex >= 0);
00174                 if (!mDrawPoolp->getColorStrider(colors, mGeomIndex))
00175                 {
00176                         printDebugInfo();
00177                         llerrs << "No color pointer for a color strider!" << llendl;
00178                 }
00179                 mDrawPoolp->setDirtyColors();
00180                 return mGeomIndex;
00181         }
00182 }
00183 
00184 inline S32      LLFace::getTexCoords  (LLStrider<LLVector2> &texCoords, S32 pass )
00185 {
00186         if (!mGeomCount)
00187         {
00188                 return -1;
00189         }
00190         if (isState(BACKLIST))
00191         {
00192                 if (!mBackupMem)
00193                 {
00194                         printDebugInfo();
00195                         llerrs << "No backup memory for face" << llendl;
00196                 }
00197                 texCoords = (LLVector2*)(mBackupMem + (4 * mIndicesCount) + mDrawPoolp->mDataOffsets[LLDrawPool::DATA_TEX_COORDS0 + pass]);
00198                 texCoords.setStride( mDrawPoolp->getStride());
00199                 return 0;
00200         }
00201         else
00202         {
00203                 llassert(mGeomIndex >= 0);
00204                 mDrawPoolp->getTexCoordStrider(texCoords, mGeomIndex, pass );
00205                 mDrawPoolp->setDirty();
00206                 return mGeomIndex;
00207         }
00208 }
00209 
00210 inline S32      LLFace::getIndices    (U32*  &indicesp)
00211 {
00212         if (isState(BACKLIST))
00213         {
00214                 indicesp = (U32*)mBackupMem;
00215                 return 0;
00216         }
00217         else
00218         {
00219                 indicesp = mDrawPoolp->getIndices(mIndicesIndex);
00220                 llassert(mGeomIndex >= 0);
00221                 return mGeomIndex;
00222         }
00223 }
00224 
00225 inline const U32* LLFace::getRawIndices() const
00226 {
00227         llassert(!isState(BACKLIST));
00228 
00229         return &mDrawPoolp->mIndices[mIndicesIndex];
00230 }
00231 
00232 
00233 inline void LLFace::bindTexture(S32 stage) const
00234 {
00235         if (mTexture)
00236         {
00237                 mTexture->bindTexture(stage);
00238         }
00239         else
00240         {
00241                 LLImageGL::unbindTexture(stage, GL_TEXTURE_2D);
00242         }
00243 }
00244 
00245 #endif

Generated on Thu Jul 1 06:08:29 2010 for Second Life Viewer by  doxygen 1.4.7