llvosurfacepatch.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /**
  2. * @file llvosurfacepatch.h
  3. * @brief Description of LLVOSurfacePatch class
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_VOSURFACEPATCH_H
  33. #define LL_VOSURFACEPATCH_H
  34. #include "llstrider.h"
  35. #include "llface.h"
  36. #include "llviewerobject.h"
  37. #include "llviewerregion.h"
  38. class LLDrawPool;
  39. class LLFace;
  40. class LLFacePool;
  41. class LLSurfacePatch;
  42. class LLVector2;
  43. class LLVOSurfacePatch final : public LLStaticViewerObject
  44. {
  45. protected:
  46. LOG_CLASS(LLVOSurfacePatch);
  47. public:
  48. enum
  49. {
  50. VERTEX_DATA_MASK = (1 << LLVertexBuffer::TYPE_VERTEX) |
  51. (1 << LLVertexBuffer::TYPE_NORMAL) |
  52. (1 << LLVertexBuffer::TYPE_TEXCOORD0) |
  53. (1 << LLVertexBuffer::TYPE_TEXCOORD1)
  54. };
  55. LLVOSurfacePatch(const LLUUID& id, LLViewerRegion* regionp);
  56. void markDead() override;
  57. static void initClass();
  58. LL_INLINE U32 getPartitionType() const override { return LLViewerRegion::PARTITION_TERRAIN; }
  59. LLDrawable* createDrawable() override;
  60. void updateGL() override;
  61. bool updateGeometry(LLDrawable* drawable) override;
  62. LL_INLINE bool updateLOD() override { return true; }
  63. void updateFaceSize(S32 idx) override;
  64. void getTerrainGeometry(LLStrider<LLVector3>& verticesp,
  65. LLStrider<LLVector3>& normalsp,
  66. LLStrider<LLVector2>& texCoords0p,
  67. LLStrider<LLVector2>& texCoords1p,
  68. LLStrider<U16>& indicesp);
  69. LL_INLINE void updateTextures() override {}
  70. // Generates accurate apparent angle and area:
  71. void setPixelAreaAndAngle() override;
  72. void updateSpatialExtents(LLVector4a& new_min,
  73. LLVector4a& new_max) override;
  74. // Whether this object needs to do an idleUpdate:
  75. LL_INLINE bool isActive() const override { return false; }
  76. void setPatch(LLSurfacePatch* patchp);
  77. LL_INLINE LLSurfacePatch* getPatch() const { return mPatchp; }
  78. void dirtyPatch();
  79. void dirtyGeom();
  80. bool lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
  81. // Which face to check, -1=ALL_SIDES
  82. S32 face = -1,
  83. bool pick_transparent = false,
  84. bool pick_rigged = false,
  85. // Which face was hit
  86. S32* face_hit = NULL,
  87. // Intersection point
  88. LLVector4a* intersection = NULL,
  89. // Texture coordinates of the intersection point
  90. LLVector2* tex_coord = NULL,
  91. // Surface normal at the intersection point
  92. LLVector4a* normal = NULL,
  93. // Surface tangent at the intersection point
  94. LLVector4a* tangent = NULL) override;
  95. protected:
  96. ~LLVOSurfacePatch() override;
  97. LLFacePool* getPool();
  98. void getGeomSizesMain(S32 stride, S32& num_vertices, S32& num_indices);
  99. void getGeomSizesNorth(S32 stride, S32 north_stride, S32& num_vertices,
  100. S32& num_indices);
  101. void getGeomSizesEast(S32 stride, S32 east_stride, S32& num_vertices,
  102. S32& num_indices);
  103. void updateMainGeometry(LLFace* facep,
  104. LLStrider<LLVector3>& verticesp,
  105. LLStrider<LLVector3>& normalsp,
  106. LLStrider<LLVector2>& texCoords0p,
  107. LLStrider<LLVector2>& texCoords1p,
  108. LLStrider<U16>& indicesp,
  109. U32& index_offset);
  110. void updateNorthGeometry(LLFace* facep,
  111. LLStrider<LLVector3>& verticesp,
  112. LLStrider<LLVector3>& normalsp,
  113. LLStrider<LLVector2>& texCoords0p,
  114. LLStrider<LLVector2>& texCoords1p,
  115. LLStrider<U16>& indicesp,
  116. U32& index_offset);
  117. void updateEastGeometry(LLFace* facep,
  118. LLStrider<LLVector3>& verticesp,
  119. LLStrider<LLVector3>& normalsp,
  120. LLStrider<LLVector2>& texCoords0p,
  121. LLStrider<LLVector2>& texCoords1p,
  122. LLStrider<U16>& indicesp,
  123. U32& index_offset);
  124. protected:
  125. LLFacePool* mPool;
  126. LLSurfacePatch* mPatchp;
  127. S32 mBaseComp;
  128. S32 mLastNorthStride;
  129. S32 mLastEastStride;
  130. S32 mLastStride;
  131. S32 mLastLength;
  132. bool mDirtyTexture;
  133. bool mDirtyTerrain;
  134. public:
  135. bool mDirtiedPatch;
  136. static F32 sLODFactor;
  137. };
  138. #endif // LL_VOSURFACEPATCH_H