lltoolbrushland.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /**
  2. * @file lltoolbrushland.h
  3. * @brief LLToolBrushLand 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_LLTOOLBRUSHLAND_H
  33. #define LL_LLTOOLBRUSHLAND_H
  34. #include "hbfastset.h"
  35. #include "lleditmenuhandler.h"
  36. #include "lltool.h"
  37. class LLSurface;
  38. class LLViewerRegion;
  39. // A toolbrush that modifies the land.
  40. class LLToolBrushLand final : public LLTool, public LLEditMenuHandler
  41. {
  42. protected:
  43. LOG_CLASS(LLToolBrushLand);
  44. public:
  45. LLToolBrushLand();
  46. // x, y in window coords with 0, 0 = left, bottom
  47. bool handleMouseDown(S32 x, S32 y, MASK mask) override;
  48. bool handleMouseUp(S32 x, S32 y, MASK mask) override;
  49. bool handleHover(S32 x, S32 y, MASK mask) override;
  50. void onMouseCaptureLost() override;
  51. void handleSelect() override;
  52. void handleDeselect() override;
  53. // Returns true if this is a tool that should always be rendered regardless
  54. // of selection.
  55. LL_INLINE bool isAlwaysRendered() override { return true; }
  56. // Draws the area that will be affected.
  57. void render() override;
  58. // This is where the land modification actually occurs
  59. static void onIdle(void* brush_tool);
  60. void modifyLandInSelectionGlobal();
  61. void undo() override;
  62. LL_INLINE bool canUndo() const override { return true; }
  63. protected:
  64. void brush();
  65. void modifyLandAtPointGlobal(const LLVector3d& spot, MASK mask);
  66. typedef fast_hset<LLViewerRegion*> region_list_t;
  67. void determineAffectedRegions(region_list_t& regions,
  68. const LLVector3d& spot) const;
  69. void renderOverlay(LLSurface& land, const LLVector3& pos_region,
  70. const LLVector3& pos_world);
  71. // Does region allow terraform, or are we a god ?
  72. bool canTerraform(LLViewerRegion* regionp) const;
  73. // Modal dialog alerting you cannot terraform the region
  74. void alertNoTerraform(LLViewerRegion* regionp);
  75. private:
  76. U8 getBrushIndex();
  77. protected:
  78. region_list_t mLastAffectedRegions;
  79. F32 mStartingZ;
  80. S32 mMouseX;
  81. S32 mMouseY;
  82. bool mGotHover;
  83. bool mBrushSelected;
  84. };
  85. extern LLToolBrushLand gToolBrushLand;
  86. #endif // LL_LLTOOLBRUSHLAND_H