/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. #ifndef LL_LLFACE_INL
  27. #define LL_LLFACE_INL
  28. #include "llglheaders.h"
  29. #include "llrender.h"
  30. inline BOOL LLFace::getDirty() const
  31. {
  32. return (mGeneration != mDrawPoolp->mGeneration);
  33. }
  34. inline void LLFace::clearDirty()
  35. {
  36. mGeneration = mDrawPoolp->mGeneration;
  37. }
  38. inline const LLTextureEntry* LLFace::getTextureEntry() const
  39. {
  40. return mVObjp->getTE(mTEOffset);
  41. }
  42. inline LLDrawPool* LLFace::getPool() const
  43. {
  44. return mDrawPoolp;
  45. }
  46. inline S32 LLFace::getStride() const
  47. {
  48. return mDrawPoolp->getStride();
  49. }
  50. inline LLDrawable* LLFace::getDrawable() const
  51. {
  52. return mDrawablep;
  53. }
  54. inline LLViewerObject* LLFace::getViewerObject() const
  55. {
  56. return mVObjp;
  57. }
  58. inline S32 LLFace::getColors (LLStrider<LLColor4U> &colors)
  59. {
  60. if (!mGeomCount)
  61. {
  62. return -1;
  63. }
  64. LLColor4U *colorp = NULL;
  65. if (isState(BACKLIST))
  66. {
  67. if (!mBackupMem)
  68. {
  69. printDebugInfo();
  70. llerrs << "No backup memory for face" << llendl;
  71. }
  72. colorp = (LLColor4U*)(mBackupMem + (4 * mIndicesCount) + (mGeomCount * mDrawPoolp->getStride()));
  73. colors = colorp;
  74. return 0;
  75. }
  76. else
  77. {
  78. llassert(mGeomIndex >= 0);
  79. if (!mDrawPoolp->getColorStrider(colors, mGeomIndex))
  80. {
  81. printDebugInfo();
  82. llerrs << "No color pointer for a color strider!" << llendl;
  83. }
  84. mDrawPoolp->setDirtyColors();
  85. return mGeomIndex;
  86. }
  87. }
  88. inline S32 LLFace::getTexCoords (LLStrider<LLVector2> &texCoords, S32 pass )
  89. {
  90. if (!mGeomCount)
  91. {
  92. return -1;
  93. }
  94. if (isState(BACKLIST))
  95. {
  96. if (!mBackupMem)
  97. {
  98. printDebugInfo();
  99. llerrs << "No backup memory for face" << llendl;
  100. }
  101. texCoords = (LLVector2*)(mBackupMem + (4 * mIndicesCount) + mDrawPoolp->mDataOffsets[LLDrawPool::DATA_TEX_COORDS0 + pass]);
  102. texCoords.setStride( mDrawPoolp->getStride());
  103. return 0;
  104. }
  105. else
  106. {
  107. llassert(mGeomIndex >= 0);
  108. mDrawPoolp->getTexCoordStrider(texCoords, mGeomIndex, pass );
  109. mDrawPoolp->setDirty();
  110. return mGeomIndex;
  111. }
  112. }
  113. inline S32 LLFace::getIndices (U32* &indicesp)
  114. {
  115. if (isState(BACKLIST))
  116. {
  117. indicesp = (U32*)mBackupMem;
  118. return 0;
  119. }
  120. else
  121. {
  122. indicesp = mDrawPoolp->getIndices(mIndicesIndex);
  123. llassert(mGeomIndex >= 0);
  124. return mGeomIndex;
  125. }
  126. }
  127. inline const U32* LLFace::getRawIndices() const
  128. {
  129. llassert(!isState(BACKLIST));
  130. return &mDrawPoolp->mIndices[mIndicesIndex];
  131. }
  132. inline void LLFace::bindTexture(S32 stage) const
  133. {
  134. if (mTexture)
  135. {
  136. mTexture->bindTexture(stage);
  137. }
  138. else
  139. {
  140. LLImageGL::unbindTexture(stage, GL_TEXTURE_2D);
  141. }
  142. }
  143. #endif