/indra/newview/llsurfacepatch.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 185 lines · 102 code · 42 blank · 41 comment · 0 complexity · 217c86bfd05c4d7f98a72bd4a86d6924 MD5 · raw file

  1. /**
  2. * @file llsurfacepatch.h
  3. * @brief LLSurfacePatch class definition
  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_LLSURFACEPATCH_H
  27. #define LL_LLSURFACEPATCH_H
  28. #include "v3math.h"
  29. #include "v3dmath.h"
  30. #include "llpointer.h"
  31. class LLSurface;
  32. class LLVOSurfacePatch;
  33. class LLVector2;
  34. class LLColor4U;
  35. class LLAgent;
  36. // A patch shouldn't know about its visibility since that really depends on the
  37. // camera that is looking (or not looking) at it. So, anything about a patch
  38. // that is specific to a camera should be in the class below.
  39. class LLPatchVisibilityInfo
  40. {
  41. public:
  42. LLPatchVisibilityInfo() :
  43. mbIsVisible(FALSE),
  44. mDistance(0.f),
  45. mRenderLevel(0),
  46. mRenderStride(0) { };
  47. ~LLPatchVisibilityInfo() { };
  48. BOOL mbIsVisible;
  49. F32 mDistance; // Distance from camera
  50. S32 mRenderLevel;
  51. U32 mRenderStride;
  52. };
  53. class LLSurfacePatch
  54. {
  55. public:
  56. LLSurfacePatch();
  57. ~LLSurfacePatch();
  58. void reset(const U32 id);
  59. void connectNeighbor(LLSurfacePatch *neighborp, const U32 direction);
  60. void disconnectNeighbor(LLSurface *surfacep);
  61. void setNeighborPatch(const U32 direction, LLSurfacePatch *neighborp);
  62. LLSurfacePatch *getNeighborPatch(const U32 direction) const;
  63. void colorPatch(const U8 r, const U8 g, const U8 b);
  64. BOOL updateTexture();
  65. void updateVerticalStats();
  66. void updateCompositionStats();
  67. void updateNormals();
  68. void updateEastEdge();
  69. void updateNorthEdge();
  70. void updateCameraDistanceRegion( const LLVector3 &pos_region);
  71. void updateVisibility();
  72. void updateGL();
  73. void dirtyZ(); // Dirty the z values of this patch
  74. void setHasReceivedData();
  75. BOOL getHasReceivedData() const;
  76. F32 getDistance() const;
  77. F32 getMaxZ() const;
  78. F32 getMinZ() const;
  79. F32 getMeanComposition() const;
  80. F32 getMinComposition() const;
  81. F32 getMaxComposition() const;
  82. const LLVector3 &getCenterRegion() const;
  83. const U64 &getLastUpdateTime() const;
  84. LLSurface *getSurface() const { return mSurfacep; }
  85. LLVector3 getPointAgent(const U32 x, const U32 y) const; // get the point at the offset.
  86. LLVector2 getTexCoords(const U32 x, const U32 y) const;
  87. void calcNormal(const U32 x, const U32 y, const U32 stride);
  88. const LLVector3 &getNormal(const U32 x, const U32 y) const;
  89. void eval(const U32 x, const U32 y, const U32 stride,
  90. LLVector3 *vertex, LLVector3 *normal, LLVector2 *tex0, LLVector2 *tex1);
  91. LLVector3 getOriginAgent() const;
  92. const LLVector3d &getOriginGlobal() const;
  93. void setOriginGlobal(const LLVector3d &origin_global);
  94. // connectivity -- each LLPatch points at 5 neighbors (or NULL)
  95. // +---+---+---+
  96. // | | 2 | 5 |
  97. // +---+---+---+
  98. // | 3 | 0 | 1 |
  99. // +---+---+---+
  100. // | 6 | 4 | |
  101. // +---+---+---+
  102. BOOL getVisible() const;
  103. U32 getRenderStride() const;
  104. S32 getRenderLevel() const;
  105. void setSurface(LLSurface *surfacep);
  106. void setDataZ(F32 *data_z) { mDataZ = data_z; }
  107. void setDataNorm(LLVector3 *data_norm) { mDataNorm = data_norm; }
  108. F32 *getDataZ() const { return mDataZ; }
  109. void dirty(); // Mark this surface patch as dirty...
  110. void clearDirty() { mDirty = FALSE; }
  111. void clearVObj();
  112. public:
  113. BOOL mHasReceivedData; // has the patch EVER received height data?
  114. BOOL mSTexUpdate; // Does the surface texture need to be updated?
  115. protected:
  116. LLSurfacePatch *mNeighborPatches[8]; // Adjacent patches
  117. BOOL mNormalsInvalid[9]; // Which normals are invalid
  118. BOOL mDirty;
  119. BOOL mDirtyZStats;
  120. BOOL mHeightsGenerated;
  121. U32 mDataOffset;
  122. F32 *mDataZ;
  123. LLVector3 *mDataNorm;
  124. // Pointer to the LLVOSurfacePatch object which is used in the new renderer.
  125. LLPointer<LLVOSurfacePatch> mVObjp;
  126. // All of the camera-dependent stuff should be in its own class...
  127. LLPatchVisibilityInfo mVisInfo;
  128. // pointers to beginnings of patch data fields
  129. LLVector3d mOriginGlobal;
  130. LLVector3 mOriginRegion;
  131. // height field stats
  132. LLVector3 mCenterRegion; // Center in region-local coords
  133. F32 mMinZ, mMaxZ, mMeanZ;
  134. F32 mRadius;
  135. F32 mMinComposition;
  136. F32 mMaxComposition;
  137. F32 mMeanComposition;
  138. U8 mConnectedEdge; // This flag is non-zero iff patch is on at least one edge
  139. // of LLSurface that is "connected" to another LLSurface
  140. U64 mLastUpdateTime; // Time patch was last updated
  141. LLSurface *mSurfacep; // Pointer to "parent" surface
  142. };
  143. #endif // LL_LLSURFACEPATCH_H