llviewerparceloverlay.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /**
  2. * @file llviewerparceloverlay.h
  3. * @brief LLViewerParcelOverlay class header file
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-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_LLVIEWERPARCELOVERLAY_H
  33. #define LL_LLVIEWERPARCELOVERLAY_H
  34. // The ownership data for land parcels.
  35. // One of these structures per region.
  36. #include <vector>
  37. #include "llbbox.h"
  38. #include "llframetimer.h"
  39. #include "llgl.h"
  40. #include "lluuid.h"
  41. #include "llviewertexture.h"
  42. class LLViewerRegion;
  43. class LLVector3;
  44. class LLColor4U;
  45. class LLVector2;
  46. class LLViewerParcelOverlay : public LLGLUpdate
  47. {
  48. public:
  49. LLViewerParcelOverlay(LLViewerRegion* region, F32 region_width_meters);
  50. ~LLViewerParcelOverlay();
  51. // ACCESS
  52. LL_INLINE LLViewerTexture* getTexture() const { return mTexture; }
  53. bool isOwned(const LLVector3& pos) const;
  54. bool isOwnedSelf(const LLVector3& pos) const;
  55. bool isOwnedGroup(const LLVector3& pos) const;
  56. bool isOwnedOther(const LLVector3& pos) const;
  57. // "Encroaches" means the prim hangs over the parcel, but its center might
  58. // be in another parcel. for now, we simply test axis aligned bounding
  59. // boxes which isn't perfect, but is close.
  60. bool encroachesOwned(const std::vector<LLBBox>& boxes) const;
  61. bool encroachesOnUnowned(const std::vector<LLBBox>& boxes) const;
  62. bool encroachesOnNearbyParcel(const std::vector<LLBBox>& boxes) const;
  63. F32 getOwnedRatio() const;
  64. void renderPropertyLines() const;
  65. U8 ownership(const LLVector3& pos) const;
  66. U8 parcelLineFlags(S32 row, S32 col) const;
  67. bool isSoundLocal(const LLVector3& pos) const;
  68. LL_INLINE S32 getParcelGridsPerEdge() const { return mParcelGridsPerEdge; }
  69. // MANIPULATE
  70. void uncompressLandOverlay(S32 chunk, U8* compressed_overlay);
  71. // Indicate property lines and overlay texture need to be rebuilt.
  72. LL_INLINE void setDirty() { mDirty = true; }
  73. void idleUpdate(bool update_now = false);
  74. LL_INLINE void updateGL() { updateOverlayTexture(); }
  75. void resetCollisionBitmap();
  76. void readCollisionBitmap(U8* bitmap);
  77. void renderParcelBorders(F32 scale, const F32* color) const;
  78. // Returns true when at least one banned parcel got drawn
  79. bool renderBannedParcels(F32 scale, const F32* color) const;
  80. private:
  81. U8 parcelFlags(S32 row, S32 col, U8 mask) const;
  82. // This is in parcel rows and columns, not grid rows and columns. Stored in
  83. // bottom three bits.
  84. LL_INLINE U8 ownership(S32 row, S32 col) const
  85. {
  86. return parcelFlags(row, col, (U8)0x7);
  87. }
  88. void addPropertyLine(std::vector<LLVector3>& vertex_array,
  89. std::vector<LLColor4U>& color_array,
  90. std::vector<LLVector2>& coord_array,
  91. F32 start_x, F32 start_y, U32 edge,
  92. const LLColor4U& color);
  93. void updateOverlayTexture();
  94. void updatePropertyLines();
  95. private:
  96. // Back pointer to the region that owns this structure.
  97. LLViewerRegion* mRegion;
  98. S32 mParcelGridsPerEdge;
  99. S32 mRegionSize; // Variable region size support
  100. S32 mVertexCount;
  101. F32* mVertexArray;
  102. U8* mColorArray;
  103. LLPointer<LLViewerTexture> mTexture;
  104. LLPointer<LLImageRaw> mImageRaw;
  105. // Size: mParcelGridsPerEdge * mParcelGridsPerEdge
  106. // Each value is 0-3, PARCEL_AVAIL to PARCEL_SELF in the two low bits
  107. // and other flags in the upper bits.
  108. U8* mOwnership;
  109. std::vector<bool> mCollisionBitmap;
  110. // Update propery lines and overlay texture
  111. LLFrameTimer mTimeSinceLastUpdate;
  112. S32 mOverlayTextureIdx;
  113. bool mDirty;
  114. // This is set to true whenever mCollisionBitmap contains at least one true
  115. // entry (i.e. when info about a banned parcel has been received). Used to
  116. // speed-up the mini-map rendering when there is nothing to render... HB
  117. bool mHasCollisions;
  118. };
  119. #endif