summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermenu.cpp
diff options
context:
space:
mode:
authorCosmic Linden <cosmic@lindenlab.com>2024-08-08 11:04:35 -0700
committerCosmic Linden <cosmic@lindenlab.com>2024-10-11 10:39:21 -0700
commit4811e4263216a2f282cfe146e247578b50005e42 (patch)
treea39534c2facd1530ab36440023ac289aa54ee0b0 /indra/newview/llviewermenu.cpp
parente62b7d391c748244c074f935b94a0588c2043683 (diff)
(WIP) Local paintmap modification test
Diffstat (limited to 'indra/newview/llviewermenu.cpp')
-rw-r--r--indra/newview/llviewermenu.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 10506e0e74..fa6e8870b3 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -117,6 +117,7 @@
#include "lltoolmgr.h"
#include "lltoolpie.h"
#include "lltoolselectland.h"
+#include "llterrainpaintmap.h"
#include "lltrans.h"
#include "llviewerdisplay.h" //for gWindowResized
#include "llviewergenericmessage.h"
@@ -1448,6 +1449,50 @@ class LLAdvancedTerrainCreateLocalPaintMap : public view_listener_t
}
};
+class LLAdvancedTerrainEditLocalPaintMap : public view_listener_t
+{
+ bool handleEvent(const LLSD& userdata)
+ {
+ LLViewerTexture* tex = gLocalTerrainMaterials.getPaintMap();
+ if (!tex)
+ {
+ LL_WARNS() << "No local paint map available to edit" << LL_ENDL;
+ return false;
+ }
+
+ LLTerrainPaintQueue& paint_queue = gLocalTerrainMaterials.getPaintQueue();
+
+ // Enqueue a paint
+ // Overrides an entire region patch with the material in the last slot
+ // It is currently the responsibility of the paint queue to convert
+ // incoming bits to the right bit depth for the paintmap (this could
+ // change in the future).
+ LLTerrainPaint::ptr_t paint = std::make_shared<LLTerrainPaint>();
+ const U16 width = U16(tex->getWidth() / 16);
+ paint->mStartX = width - 1;
+ paint->mStartY = width - 1;
+ paint->mWidthX = width;
+ paint->mWidthY = width;
+ constexpr U8 bit_depth = 5;
+ paint->mBitDepth = bit_depth;
+ constexpr U8 max_value = (1 << bit_depth) - 1;
+ const size_t pixel_count = width * width;
+ paint->mData.resize(LLTerrainPaint::COMPONENTS * pixel_count);
+ for (size_t pixel = 0; pixel < pixel_count; ++pixel)
+ {
+ paint->mData[(LLTerrainPaint::COMPONENTS*pixel) + LLTerrainPaint::COMPONENTS - 1] = max_value;
+ }
+ paint_queue.enqueue(paint);
+
+ // Apply the paint queue ad-hoc right here for now.
+ // *TODO: Eventually the paint queue should be applied at a predictable
+ // time in the viewer frame loop.
+ LLTerrainPaintMap::applyPaintQueue(*tex, paint_queue);
+
+ return true;
+ }
+};
+
class LLAdvancedTerrainDeleteLocalPaintMap : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
@@ -9813,6 +9858,7 @@ void initialize_menus()
// Develop > Terrain
view_listener_t::addMenu(new LLAdvancedRebuildTerrain(), "Advanced.RebuildTerrain");
view_listener_t::addMenu(new LLAdvancedTerrainCreateLocalPaintMap(), "Advanced.TerrainCreateLocalPaintMap");
+ view_listener_t::addMenu(new LLAdvancedTerrainEditLocalPaintMap(), "Advanced.TerrainEditLocalPaintMap");
view_listener_t::addMenu(new LLAdvancedTerrainDeleteLocalPaintMap(), "Advanced.TerrainDeleteLocalPaintMap");
// Advanced > UI