From 244566cc3fcde45e555011c520ed7107b591663d Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 24 Jun 2024 18:24:57 +0300 Subject: viewer#1506 The Dynamic probe checkbox wasn't working --- indra/newview/llpanelvolume.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index 16c38bf1f0..4e096ecc95 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -151,6 +151,7 @@ bool LLPanelVolume::postBuild() { childSetCommitCallback("Reflection Probe", onCommitIsReflectionProbe, this); childSetCommitCallback("Probe Update Type", onCommitProbe, this); + childSetCommitCallback("Probe Dynamic", onCommitProbe, this); childSetCommitCallback("Probe Volume Type", onCommitProbe, this); childSetCommitCallback("Probe Ambiance", onCommitProbe, this); childSetCommitCallback("Probe Near Clip", onCommitProbe, this); @@ -412,6 +413,7 @@ void LLPanelVolume::getState( ) getChild("Probe Ambiance", true)->clear(); getChild("Probe Near Clip", true)->clear(); getChild("Probe Update Type", true)->clear(); + getChild("Probe Dynamic")->setValue(false); } else { @@ -446,6 +448,7 @@ void LLPanelVolume::getState( ) getChild("Probe Ambiance", true)->setValue(volobjp->getReflectionProbeAmbiance()); getChild("Probe Near Clip", true)->setValue(volobjp->getReflectionProbeNearClip()); getChild("Probe Update Type", true)->setValue(update_type); + getChild("Probe Dynamic")->setValue(volobjp->getReflectionProbeIsDynamic()); } // Animated Mesh @@ -733,6 +736,7 @@ void LLPanelVolume::clearCtrls() getChildView("Reflection Probe")->setEnabled(false);; getChildView("Probe Volume Type")->setEnabled(false); getChildView("Probe Update Type")->setEnabled(false); + getChildView("Probe Dynamic")->setEnabled(false); getChildView("Probe Ambiance")->setEnabled(false); getChildView("Probe Near Clip")->setEnabled(false); getChildView("Animated Mesh Checkbox Ctrl")->setEnabled(false); @@ -1428,15 +1432,26 @@ void LLPanelVolume::onCommitProbe(LLUICtrl* ctrl, void* userdata) volobjp->setReflectionProbeAmbiance((F32)self->getChild("Probe Ambiance")->getValue().asReal()); volobjp->setReflectionProbeNearClip((F32)self->getChild("Probe Near Clip")->getValue().asReal()); - std::string update_type = self->getChild("Probe Update Type")->getValue().asString(); + bool mirrors_enabled = LLPipeline::RenderMirrors; + bool is_mirror = false; - bool is_mirror = update_type.find("Mirror") != std::string::npos; + if (mirrors_enabled) + { + std::string update_type = self->getChild("Probe Update Type")->getValue().asString(); - self->getChildView("Probe Volume Type")->setEnabled(!is_mirror); + is_mirror = update_type.find("Mirror") != std::string::npos; - volobjp->setReflectionProbeIsDynamic(update_type.find("Dynamic") != std::string::npos); - volobjp->setReflectionProbeIsMirror(is_mirror); + volobjp->setReflectionProbeIsDynamic(update_type.find("Dynamic") != std::string::npos); + volobjp->setReflectionProbeIsMirror(is_mirror); + } + else + { + is_mirror = volobjp->getReflectionProbeIsMirror(); + bool is_dynamic = self->getChild("Probe Dynamic")->getValue().asBoolean(); + volobjp->setReflectionProbeIsDynamic(is_dynamic); + } + self->getChildView("Probe Volume Type")->setEnabled(!is_mirror); self->getChildView("Probe Ambiance")->setEnabled(!is_mirror); self->getChildView("Probe Near Clip")->setEnabled(!is_mirror); -- cgit v1.2.3 From 8804c019a817812828aa8b4602fd7af11c276478 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 26 Jun 2024 20:38:51 +0200 Subject: Increase texture discard bias if system memory gets low --- indra/newview/app_settings/settings.xml | 22 +++++++++++++++ indra/newview/lltextureview.cpp | 2 -- indra/newview/llviewertexture.cpp | 48 +++++++++++++++++++++++++++------ indra/newview/llviewertexture.h | 1 + 4 files changed, 63 insertions(+), 10 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 50632a7b07..e7e9fc5b88 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -7716,6 +7716,28 @@ Value 0 + RenderMinFreeMainMemoryThreshold + + Comment + Minimum of available physical memory in MB before textures get scaled down + Persist + 1 + Type + U32 + Value + 512 + + RenderLowMemMinDiscardIncrement + + Comment + Minimum increment of discard level if system memory gets low + Persist + 1 + Type + F32 + Value + 0.1 + RenderMaxTextureIndex Comment diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index f521293b96..b51bcc5601 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -59,8 +59,6 @@ #include "llvoavatarself.h" #include "lltexlayer.h" -extern F32 texmem_lower_bound_scale; - LLTextureView *gTextureView = NULL; #define HIGH_PRIORITY 100000000.f diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index c1062b9a01..c716eb4e86 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -101,6 +101,7 @@ U32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA; bool LLViewerTexture::sFreezeImageUpdates = false; F32 LLViewerTexture::sCurrentTime = 0.0f; +constexpr F32 MEMORY_CHECK_WAIT_TIME = 1.0f; constexpr F32 MIN_VRAM_BUDGET = 768.f; F32 LLViewerTexture::sFreeVRAMMegabytes = MIN_VRAM_BUDGET; @@ -484,10 +485,6 @@ void LLViewerTexture::initClass() LLImageGL::sDefaultGLTexture = LLViewerFetchedTexture::sDefaultImagep->getGLTexture(); } -// non-const (used externally -F32 texmem_lower_bound_scale = 0.85f; -F32 texmem_middle_bound_scale = 0.925f; - //static void LLViewerTexture::updateClass() { @@ -519,14 +516,49 @@ void LLViewerTexture::updateClass() sFreeVRAMMegabytes = target - used; F32 over_pct = llmax((used-target) / target, 0.f); - sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.f + over_pct); - if (sDesiredDiscardBias > 1.f) + if (isSystemMemoryLow()) + { + // System RAM is low -> ramp up discard bias over time to free memory + if (sEvaluationTimer.getElapsedTimeF32() > MEMORY_CHECK_WAIT_TIME) + { + static LLCachedControl low_mem_min_discard_increment(gSavedSettings, "RenderLowMemMinDiscardIncrement", .1f); + sDesiredDiscardBias += llmax(low_mem_min_discard_increment, over_pct); + sEvaluationTimer.reset(); + } + } + else { - sDesiredDiscardBias -= gFrameIntervalSeconds * 0.01; + sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.f + over_pct); + + if (sDesiredDiscardBias > 1.f) + { + sDesiredDiscardBias -= gFrameIntervalSeconds * 0.01; + } } - LLViewerTexture::sFreezeImageUpdates = false; // sDesiredDiscardBias > (desired_discard_bias_max - 1.0f); + LLViewerTexture::sFreezeImageUpdates = false; +} + +//static +bool LLViewerTexture::isSystemMemoryLow() +{ + static LLFrameTimer timer; + static U32Megabytes physical_res = U32Megabytes(U32_MAX); + + static LLCachedControl min_free_main_memory(gSavedSettings, "RenderMinFreeMainMemoryThreshold", 512); + const U32Megabytes MIN_FREE_MAIN_MEMORY(min_free_main_memory); + + if (timer.getElapsedTimeF32() < MEMORY_CHECK_WAIT_TIME) //call this once per second. + { + return physical_res < MIN_FREE_MAIN_MEMORY; + } + + timer.reset(); + + LLMemory::updateMemoryInfo(); + physical_res = LLMemory::getAvailableMemKB(); + return physical_res < MIN_FREE_MAIN_MEMORY; } //end of static functions diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index dc9182bf1b..9963626ada 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -117,6 +117,7 @@ protected: public: static void initClass(); static void updateClass(); + static bool isSystemMemoryLow(); LLViewerTexture(bool usemipmaps = true); LLViewerTexture(const LLUUID& id, bool usemipmaps) ; -- cgit v1.2.3 From ab87978cbc71cd4c83648627998055a010700f05 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 27 Jun 2024 13:12:43 -0500 Subject: 1836 dont store texture in system memory unless absolutely necessary (#1843) * #1836 Texture memory usage overhaul. Much decrufting - don't keep a copy of textures in system memory - use GPU to downrez textures instead of reloading from cache - use GPU to generate brightness/darkness bumpmaps --- .../shaders/class1/deferred/normgenF.glsl | 41 +- indra/newview/gltf/buffer_util.h | 10 + indra/newview/gltfscenemanager.cpp | 3 +- indra/newview/lldebugview.cpp | 6 +- indra/newview/lldrawpoolbump.cpp | 388 +++++-------------- indra/newview/lldrawpoolbump.h | 5 +- indra/newview/llfloaterchangeitemthumbnail.cpp | 22 +- indra/newview/lllocalbitmaps.cpp | 1 - indra/newview/llnetmap.cpp | 20 - indra/newview/llsurface.cpp | 169 +-------- indra/newview/llsurface.h | 11 +- indra/newview/llsurfacepatch.cpp | 9 +- indra/newview/lltextureview.cpp | 65 +++- indra/newview/llviewermedia.cpp | 65 ++-- indra/newview/llviewerobject.cpp | 4 +- indra/newview/llviewerregion.cpp | 6 +- indra/newview/llviewerregion.h | 2 +- indra/newview/llviewertexture.cpp | 312 ++-------------- indra/newview/llviewertexture.h | 25 +- indra/newview/llviewertexturelist.cpp | 24 +- indra/newview/llviewertexturelist.h | 18 +- indra/newview/llviewerwindow.cpp | 134 +------ indra/newview/llviewerwindow.h | 9 +- indra/newview/llvlcomposition.cpp | 412 +-------------------- indra/newview/llvlcomposition.h | 2 - indra/newview/llvovolume.cpp | 36 +- indra/newview/llvowater.cpp | 15 +- indra/newview/llvowater.h | 3 - indra/newview/llworld.cpp | 2 - indra/newview/llworldmipmap.cpp | 1 + indra/newview/llworldmipmap.h | 6 +- 31 files changed, 354 insertions(+), 1472 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl b/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl index 902746366d..6d05d983f3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl @@ -25,24 +25,53 @@ /*[EXTRA_CODE_HERE]*/ + + +// generate a normal map using an approximation of the old emboss bump map "brightness/darkness" technique +// srcMap is a source color image, output should be a normal + out vec4 frag_color; -uniform sampler2D alphaMap; +uniform sampler2D srcMap; in vec2 vary_texcoord0; uniform float stepX; uniform float stepY; uniform float norm_scale; +uniform int bump_code; + +#define BE_BRIGHTNESS 1 +#define BE_DARKNESS 2 + +// get luminance or inverse luminance depending on bump_code +float getBumpValue(vec2 texcoord) +{ + vec3 c = texture(srcMap, texcoord).rgb; + + vec3 WEIGHT = vec3(0.2995, 0.5875, 0.1145); + + float l = dot(c, WEIGHT); + + if (bump_code == BE_DARKNESS) + { + l = 1.0 - l; + } + + return l; +} + void main() { - float c = texture(alphaMap, vary_texcoord0).r; + float c = getBumpValue(vary_texcoord0).r; + + float scaler = 512.0; - vec3 right = vec3(norm_scale, 0, (texture(alphaMap, vary_texcoord0+vec2(stepX, 0)).r-c)*255); - vec3 left = vec3(-norm_scale, 0, (texture(alphaMap, vary_texcoord0-vec2(stepX, 0)).r-c)*255); - vec3 up = vec3(0, -norm_scale, (texture(alphaMap, vary_texcoord0-vec2(0, stepY)).r-c)*255); - vec3 down = vec3(0, norm_scale, (texture(alphaMap, vary_texcoord0+vec2(0, stepY)).r-c)*255); + vec3 right = vec3(norm_scale, 0, (getBumpValue(vary_texcoord0+vec2(stepX, 0)).r-c)*scaler); + vec3 left = vec3(-norm_scale, 0, (getBumpValue(vary_texcoord0-vec2(stepX, 0)).r-c)*scaler); + vec3 up = vec3(0, -norm_scale, (getBumpValue(vary_texcoord0-vec2(0, stepY)).r-c)*scaler); + vec3 down = vec3(0, norm_scale, (getBumpValue(vary_texcoord0+vec2(0, stepY)).r-c)*scaler); vec3 norm = cross(right, down) + cross(down, left) + cross(left,up) + cross(up, right); diff --git a/indra/newview/gltf/buffer_util.h b/indra/newview/gltf/buffer_util.h index 40f9448aaf..89cedf4a47 100644 --- a/indra/newview/gltf/buffer_util.h +++ b/indra/newview/gltf/buffer_util.h @@ -180,6 +180,16 @@ namespace LL data[3] = src[3]; } + template<> + inline void copyVec4(U8* src, U64& dst) + { + U8* data = (U8*)&dst; + data[0] = src[0]; + data[1] = src[1]; + data[2] = src[2]; + data[3] = src[3]; + } + template<> inline void copyVec4(U16* src, LLColor4U& dst) { diff --git a/indra/newview/gltfscenemanager.cpp b/indra/newview/gltfscenemanager.cpp index 7b2de4d6de..a0cbe9290c 100644 --- a/indra/newview/gltfscenemanager.cpp +++ b/indra/newview/gltfscenemanager.cpp @@ -144,7 +144,7 @@ void GLTFSceneManager::uploadSelection() } else { - raw = image.mTexture->getCachedRawImage(); + raw = image.mTexture->getRawImage(); } if (raw.notNull()) @@ -339,6 +339,7 @@ void GLTFSceneManager::renderAlpha() void GLTFSceneManager::addGLTFObject(LLViewerObject* obj, LLUUID gltf_id) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_GLTF; llassert(obj->getVolume()->getParams().getSculptID() == gltf_id); llassert(obj->getVolume()->getParams().getSculptType() == LL_SCULPT_TYPE_GLTF); diff --git a/indra/newview/lldebugview.cpp b/indra/newview/lldebugview.cpp index b88d11886a..0596a8fe7d 100644 --- a/indra/newview/lldebugview.cpp +++ b/indra/newview/lldebugview.cpp @@ -105,10 +105,7 @@ void LLDebugView::init() addChild(gSceneMonitorView); gSceneMonitorView->setRect(rect); - r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f), - (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f)); - - r.set(150, rect.getHeight() - 50, 820, 100); + r.set(150, rect.getHeight() - 60, 820, 110); LLTextureView::Params tvp; tvp.name("gTextureView"); tvp.rect(r); @@ -116,7 +113,6 @@ void LLDebugView::init() tvp.visible(false); gTextureView = LLUICtrlFactory::create(tvp); addChild(gTextureView); - //gTextureView->reshape(r.getWidth(), r.getHeight(), true); } void LLDebugView::draw() diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 055f99d764..7289e95b6e 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -79,11 +79,6 @@ static S32 diffuse_channel = -1; static S32 bump_channel = -1; static bool shiny = false; -// Enabled after changing LLViewerTexture::mNeedsCreateTexture to an -// LLAtomicBool; this should work just fine, now. HB -#define LL_BUMPLIST_MULTITHREADED 1 - - // static void LLStandardBumpmap::shutdown() { @@ -764,24 +759,21 @@ LLViewerTexture* LLBumpImageList::getBrightnessDarknessImage(LLViewerFetchedText LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; llassert( (bump_code == BE_BRIGHTNESS) || (bump_code == BE_DARKNESS) ); - LLViewerTexture* bump = NULL; + LLViewerTexture* bump = nullptr; - bump_image_map_t* entries_list = NULL; - void (*callback_func)( bool success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata ) = NULL; + bump_image_map_t* entries_list = nullptr; switch( bump_code ) { case BE_BRIGHTNESS: entries_list = &mBrightnessEntries; - callback_func = LLBumpImageList::onSourceBrightnessLoaded; break; case BE_DARKNESS: entries_list = &mDarknessEntries; - callback_func = LLBumpImageList::onSourceDarknessLoaded; break; default: llassert(0); - return NULL; + return nullptr; } bump_image_map_t::iterator iter = entries_list->find(src_image->getID()); @@ -789,51 +781,18 @@ LLViewerTexture* LLBumpImageList::getBrightnessDarknessImage(LLViewerFetchedText { bump = iter->second; } - else - { - (*entries_list)[src_image->getID()] = LLViewerTextureManager::getLocalTexture( true ); - bump = (*entries_list)[src_image->getID()]; // In case callback was called immediately and replaced the image - } - - if (!src_image->hasCallbacks()) - { //if image has no callbacks but resolutions don't match, trigger raw image loaded callback again - if (src_image->getWidth() != bump->getWidth() || - src_image->getHeight() != bump->getHeight())// || - //(LLPipeline::sRenderDeferred && bump->getComponents() != 4)) - { - src_image->setBoostLevel(LLGLTexture::BOOST_BUMP) ; - src_image->setLoadedCallback( callback_func, 0, true, false, new LLUUID(src_image->getID()), NULL ); - src_image->forceToSaveRawImage(0) ; - } - } - - return bump; -} - -// static -void LLBumpImageList::onSourceBrightnessLoaded( bool success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata ) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - LLUUID* source_asset_id = (LLUUID*)userdata; - LLBumpImageList::onSourceLoaded( success, src_vi, src, *source_asset_id, BE_BRIGHTNESS ); - if( final ) + if (bump == nullptr || + src_image->getWidth() != bump->getWidth() || + src_image->getHeight() != bump->getHeight()) { - delete source_asset_id; + onSourceUpdated(src_image, (EBumpEffect) bump_code); } -} -// static -void LLBumpImageList::onSourceDarknessLoaded( bool success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata ) -{ - LLUUID* source_asset_id = (LLUUID*)userdata; - LLBumpImageList::onSourceLoaded( success, src_vi, src, *source_asset_id, BE_DARKNESS ); - if( final ) - { - delete source_asset_id; - } + return (*entries_list)[src_image->getID()]; } + void LLBumpImageList::onSourceStandardLoaded( bool success, LLViewerFetchedTexture* src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata) { if (success && LLPipeline::sRenderDeferred) @@ -909,289 +868,108 @@ void LLBumpImageList::generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nr } // static -void LLBumpImageList::onSourceLoaded( bool success, LLViewerTexture *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump_code ) +void LLBumpImageList::onSourceUpdated(LLViewerTexture* src, EBumpEffect bump_code) { - LL_PROFILE_ZONE_SCOPED; - - if( success ) - { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - - LLImageDataSharedLock lock(src); - - bump_image_map_t& entries_list(bump_code == BE_BRIGHTNESS ? gBumpImageList.mBrightnessEntries : gBumpImageList.mDarknessEntries ); - bump_image_map_t::iterator iter = entries_list.find(source_asset_id); - - { - if (iter == entries_list.end() || - iter->second.isNull() || - iter->second->getWidth() != src->getWidth() || - iter->second->getHeight() != src->getHeight()) // bump not cached yet or has changed resolution - { //make sure an entry exists for this image - entries_list[src_vi->getID()] = LLViewerTextureManager::getLocalTexture(true); - iter = entries_list.find(src_vi->getID()); - } - } - - if (iter->second->getWidth() != src->getWidth() || - iter->second->getHeight() != src->getHeight()) // bump not cached yet or has changed resolution - { - LLPointer dst_image = new LLImageRaw(src->getWidth(), src->getHeight(), 1); - U8* dst_data = dst_image->getData(); - S32 dst_data_size = dst_image->getDataSize(); - - const U8* src_data = src->getData(); - S32 src_data_size = src->getDataSize(); - - S32 src_components = src->getComponents(); - - // Convert to luminance and then scale and bias that to get ready for - // embossed bump mapping. (0-255 maps to 127-255) - - // Convert to fixed point so we don't have to worry about precision/clamping. - const S32 FIXED_PT = 8; - const S32 R_WEIGHT = S32(0.2995f * (1< maximum ) - { - maximum = dst_data[i]; - } - } - } - else - { - llassert(0); - dst_image->clear(); - } - } - break; - case 3: - case 4: - { - if( src_data_size == dst_data_size * src_components ) - { - for( S32 i = 0, j=0; i < dst_data_size; i++, j+= src_components ) - { - // RGB to luminance - dst_data[i] = (R_WEIGHT * src_data[j] + G_WEIGHT * src_data[j+1] + B_WEIGHT * src_data[j+2]) >> FIXED_PT; - //llassert( dst_data[i] <= 255 );true because it's 8bit - if( dst_data[i] < minimum ) - { - minimum = dst_data[i]; - } - if( dst_data[i] > maximum ) - { - maximum = dst_data[i]; - } - } - } - else - { - llassert(0); - dst_image->clear(); - } - } - break; - default: - llassert(0); - dst_image->clear(); - break; - } - - if( maximum > minimum ) - { - U8 bias_and_scale_lut[256]; - F32 twice_one_over_range = 2.f / (maximum - minimum); - S32 i; - - const F32 ARTIFICIAL_SCALE = 2.f; // Advantage: exaggerates the effect in midrange. Disadvantage: clamps at the extremes. - if (BE_DARKNESS == bump_code) - { - for( i = minimum; i <= maximum; i++ ) - { - F32 minus_one_to_one = F32(maximum - i) * twice_one_over_range - 1.f; - bias_and_scale_lut[i] = llclampb(ll_round(127 * minus_one_to_one * ARTIFICIAL_SCALE + 128)); - } - } - else - { - for( i = minimum; i <= maximum; i++ ) - { - F32 minus_one_to_one = F32(i - minimum) * twice_one_over_range - 1.f; - bias_and_scale_lut[i] = llclampb(ll_round(127 * minus_one_to_one * ARTIFICIAL_SCALE + 128)); - } - } - - for( i = 0; i < dst_data_size; i++ ) - { - dst_data[i] = bias_and_scale_lut[dst_data[i]]; - } - } - - //--------------------------------------------------- - // immediately assign bump to a smart pointer in case some local smart pointer - // accidentally releases it. - LLPointer bump = iter->second; - - if (!LLPipeline::sRenderDeferred) - { - bump->setExplicitFormat(GL_ALPHA8, GL_ALPHA); - -#if LL_BUMPLIST_MULTITHREADED - auto tex_queue = LLImageGLThread::sEnabledTextures ? sTexUpdateQueue.lock() : nullptr; - - if (tex_queue) - { //dispatch creation to background thread - LLImageRaw* dst_ptr = dst_image; - LLViewerTexture* bump_ptr = bump; - dst_ptr->ref(); - bump_ptr->ref(); - tex_queue->post( - [=]() - { - LL_PROFILE_ZONE_NAMED("bil - create texture"); - bump_ptr->createGLTexture(0, dst_ptr); - bump_ptr->unref(); - dst_ptr->unref(); - }); - - } - else -#endif - { - bump->createGLTexture(0, dst_image); - } - } - else - { //convert to normal map - LL_PROFILE_ZONE_NAMED("bil - create normal map"); - LLImageGL* img = bump->getGLTexture(); - LLImageRaw* dst_ptr = dst_image.get(); - LLGLTexture* bump_ptr = bump.get(); - - dst_ptr->ref(); - img->ref(); - bump_ptr->ref(); - auto create_func = [=]() - { - img->setUseMipMaps(true); - // upload dst_image to GPU (greyscale in red channel) - img->setExplicitFormat(GL_RED, GL_RED); + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - bump_ptr->createGLTexture(0, dst_ptr); - dst_ptr->unref(); - }; + const LLUUID& src_id = src->getID(); - auto generate_func = [=]() - { - // Allocate an empty RGBA texture at "tex_name" the same size as bump - // Note: bump will still point at GPU copy of dst_image - bump_ptr->setExplicitFormat(GL_RGBA, GL_RGBA); - LLGLuint tex_name; - img->createGLTexture(0, nullptr, false, 0, true, &tex_name); + bump_image_map_t& entries_list(bump_code == BE_BRIGHTNESS ? gBumpImageList.mBrightnessEntries : gBumpImageList.mDarknessEntries); + bump_image_map_t::iterator iter = entries_list.find(src_id); - // point render target at empty buffer - sRenderTarget.setColorAttachment(img, tex_name); + if (iter == entries_list.end()) + { //make sure an entry exists for this image + entries_list[src_id] = LLViewerTextureManager::getLocalTexture(true); + iter = entries_list.find(src_id); + } - // generate normal map in empty texture - { - sRenderTarget.bindTarget(); + //--------------------------------------------------- + // immediately assign bump to a smart pointer in case some local smart pointer + // accidentally releases it. + LLPointer bump = iter->second; - LLGLDepthTest depth(GL_FALSE); - LLGLDisable cull(GL_CULL_FACE); - LLGLDisable blend(GL_BLEND); - gGL.setColorMask(true, true); + if (bump->getWidth() != src->getWidth() || + bump->getHeight() != src->getHeight()) // bump not cached yet or has changed resolution + { + //convert to normal map + LL_PROFILE_ZONE_NAMED("bil - create normal map"); - gNormalMapGenProgram.bind(); + bump->setExplicitFormat(GL_RGBA, GL_RGBA); - static LLStaticHashedString sNormScale("norm_scale"); - static LLStaticHashedString sStepX("stepX"); - static LLStaticHashedString sStepY("stepY"); + LLImageGL* src_img = src->getGLTexture(); + LLImageGL* dst_img = bump->getGLTexture(); + dst_img->setSize(src->getWidth(), src->getHeight(), 4, 0); + dst_img->setUseMipMaps(true); + dst_img->setDiscardLevel(0); + dst_img->createGLTexture(); - gNormalMapGenProgram.uniform1f(sNormScale, gSavedSettings.getF32("RenderNormalMapScale")); - gNormalMapGenProgram.uniform1f(sStepX, 1.f / bump_ptr->getWidth()); - gNormalMapGenProgram.uniform1f(sStepY, 1.f / bump_ptr->getHeight()); + gGL.getTexUnit(0)->bind(bump); - gGL.getTexUnit(0)->bind(bump_ptr); + LLImageGL::setManualImage(GL_TEXTURE_2D, 0, dst_img->getPrimaryFormat(), dst_img->getWidth(), dst_img->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, nullptr, false); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(0, 0); - gGL.vertex2f(0, 0); + LLGLuint tex_name = dst_img->getTexName(); + // point render target at empty buffer + sRenderTarget.setColorAttachment(bump->getGLTexture(), tex_name); - gGL.texCoord2f(0, 1); - gGL.vertex2f(0, 1); + // generate normal map in empty texture + { + sRenderTarget.bindTarget(); - gGL.texCoord2f(1, 0); - gGL.vertex2f(1, 0); + LLGLDepthTest depth(GL_FALSE); + LLGLDisable cull(GL_CULL_FACE); + LLGLDisable blend(GL_BLEND); + gGL.setColorMask(true, true); - gGL.texCoord2f(1, 1); - gGL.vertex2f(1, 1); + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + gNormalMapGenProgram.bind(); - gGL.end(); + static LLStaticHashedString sNormScale("norm_scale"); + static LLStaticHashedString sStepX("stepX"); + static LLStaticHashedString sStepY("stepY"); + static LLStaticHashedString sBumpCode("bump_code"); - gGL.flush(); + gNormalMapGenProgram.uniform1f(sNormScale, gSavedSettings.getF32("RenderNormalMapScale")); + gNormalMapGenProgram.uniform1f(sStepX, 1.f / bump->getWidth()); + gNormalMapGenProgram.uniform1f(sStepY, 1.f / bump->getHeight()); + gNormalMapGenProgram.uniform1i(sBumpCode, bump_code); - gNormalMapGenProgram.unbind(); + gGL.getTexUnit(0)->bind(src); - sRenderTarget.flush(); - sRenderTarget.releaseColorAttachment(); - } + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(0, 0); + gGL.vertex2f(0, 0); - // point bump at normal map and free gpu copy of dst_image - img->syncTexName(tex_name); + gGL.texCoord2f(0, 1); + gGL.vertex2f(0, 1); - // generate mipmap - gGL.getTexUnit(0)->bind(img); - glGenerateMipmap(GL_TEXTURE_2D); - gGL.getTexUnit(0)->disable(); + gGL.texCoord2f(1, 0); + gGL.vertex2f(1, 0); - bump_ptr->unref(); - img->unref(); - }; + gGL.texCoord2f(1, 1); + gGL.vertex2f(1, 1); -#if LL_BUMPLIST_MULTITHREADED - auto main_queue = LLImageGLThread::sEnabledTextures ? sMainQueue.lock() : nullptr; + gGL.end(); - if (main_queue) - { //dispatch texture upload to background thread, issue GPU commands to generate normal map on main thread - main_queue->postTo( - sTexUpdateQueue, - create_func, - generate_func); - } - else -#endif - { // immediate upload texture and generate normal map - create_func(); - generate_func(); - } + gGL.flush(); + sRenderTarget.flush(); + sRenderTarget.releaseColorAttachment(); + if (shader) + { + shader->bind(); } - - iter->second = bump; // derefs (and deletes) old image - //--------------------------------------------------- } + + // generate mipmap + gGL.getTexUnit(0)->bind(bump); + glGenerateMipmap(GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } + + iter->second = bump; // derefs (and deletes) old image + //--------------------------------------------------- + } void LLDrawPoolBump::pushBumpBatches(U32 type) diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h index 65cb9af015..15976884ca 100644 --- a/indra/newview/lldrawpoolbump.h +++ b/indra/newview/lldrawpoolbump.h @@ -140,14 +140,13 @@ public: LLViewerTexture* getBrightnessDarknessImage(LLViewerFetchedTexture* src_image, U8 bump_code); void addTextureStats(U8 bump, const LLUUID& base_image_id, F32 virtual_size); - static void onSourceBrightnessLoaded( bool success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata ); - static void onSourceDarknessLoaded( bool success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata ); static void onSourceStandardLoaded( bool success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata ); static void generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nrm_image); private: - static void onSourceLoaded( bool success, LLViewerTexture *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump ); + // should be called whenever resolution of src_vi changes compared to the current entry + static void onSourceUpdated( LLViewerTexture *src_vi, EBumpEffect bump ); private: typedef std::unordered_map > bump_image_map_t; diff --git a/indra/newview/llfloaterchangeitemthumbnail.cpp b/indra/newview/llfloaterchangeitemthumbnail.cpp index 3e2e7cb7a3..fb31361fd9 100644 --- a/indra/newview/llfloaterchangeitemthumbnail.cpp +++ b/indra/newview/llfloaterchangeitemthumbnail.cpp @@ -951,8 +951,8 @@ void LLFloaterChangeItemThumbnail::onTexturePickerCommit() || texturep->getFullWidth() == 0) { if (texturep->isFullyLoaded() - && (texturep->getCachedRawImageLevel() == 0 || texturep->getRawImageLevel() == 0) - && (texturep->isCachedRawImageReady() || texturep->isRawImageValid())) + && (texturep->getRawImageLevel() == 0) + && (texturep->isRawImageValid())) { LLUUID task_id = mTaskId; uuid_set_t inventory_ids = mItemList; @@ -962,20 +962,10 @@ void LLFloaterChangeItemThumbnail::onTexturePickerCommit() { onUploadComplete(asset_id, task_id, inventory_ids, handle); }; - if (texturep->isRawImageValid()) - { - LLFloaterSimpleSnapshot::uploadThumbnail(texturep->getRawImage(), - *mItemList.begin(), - mTaskId, - callback); - } - else - { - LLFloaterSimpleSnapshot::uploadThumbnail(texturep->getCachedRawImage(), - *mItemList.begin(), - mTaskId, - callback); - } + LLFloaterSimpleSnapshot::uploadThumbnail(texturep->getRawImage(), + *mItemList.begin(), + mTaskId, + callback); } else { diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp index 6ab5e05b7d..0e2b3cb409 100644 --- a/indra/newview/lllocalbitmaps.cpp +++ b/indra/newview/lllocalbitmaps.cpp @@ -215,7 +215,6 @@ bool LLLocalBitmap::updateSelf(EUpdateType optional_firstupdate) ("file://"+mFilename, FTT_LOCAL_FILE, mWorldID, LL_LOCAL_USE_MIPMAPS); texture->createGLTexture(LL_LOCAL_DISCARD_LEVEL, raw_image); - texture->setCachedRawImage(LL_LOCAL_DISCARD_LEVEL, raw_image); texture->ref(); gTextureList.addImage(texture, TEX_LIST_STANDARD); diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 1410232a0f..fd968d9027 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -296,8 +296,6 @@ void LLNetMap::draw() gGL.color4f(1.f, 0.5f, 0.5f, 1.f); } - - // Draw using texture. gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture()); gGL.begin(LLRender::QUADS); @@ -311,24 +309,6 @@ void LLNetMap::draw() gGL.vertex2f(right, top); gGL.end(); - // Draw water - gGL.flush(); - { - if (regionp->getLand().getWaterTexture()) - { - gGL.getTexUnit(0)->bind(regionp->getLand().getWaterTexture()); - gGL.begin(LLRender::QUADS); - gGL.texCoord2f(0.f, 1.f); - gGL.vertex2f(left, top); - gGL.texCoord2f(0.f, 0.f); - gGL.vertex2f(left, bottom); - gGL.texCoord2f(1.f, 0.f); - gGL.vertex2f(right, bottom); - gGL.texCoord2f(1.f, 1.f); - gGL.vertex2f(right, top); - gGL.end(); - } - } gGL.flush(); } diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp index e6bced5c92..1826885069 100644 --- a/indra/newview/llsurface.cpp +++ b/indra/newview/llsurface.cpp @@ -54,6 +54,7 @@ #include "llglheaders.h" #include "lldrawpoolterrain.h" #include "lldrawable.h" +#include "llworldmipmap.h" extern LLPipeline gPipeline; extern bool gShiftFrame; @@ -74,7 +75,6 @@ LLSurface::LLSurface(U32 type, LLViewerRegion *regionp) : mDetailTextureScale(0.f), mOriginGlobal(0.0, 0.0, 0.0), mSTexturep(NULL), - mWaterTexturep(NULL), mGridsPerPatchEdge(0), mMetersPerGrid(1.0f), mMetersPerEdge(1.0f), @@ -129,14 +129,7 @@ LLSurface::~LLSurface() { gPipeline.removePool(poolp); // Don't enable this until we blitz the draw pool for it as well. -- djs - if (mSTexturep) - { - mSTexturep = NULL; - } - if (mWaterTexturep) - { - mWaterTexturep = NULL; - } + mSTexturep = NULL; } else { @@ -216,62 +209,17 @@ LLViewerTexture* LLSurface::getSTexture() return mSTexturep; } -LLViewerTexture* LLSurface::getWaterTexture() -{ - if (mWaterTexturep.notNull() && !mWaterTexturep->hasGLTexture()) - { - createWaterTexture(); - } - return mWaterTexturep; -} - void LLSurface::createSTexture() { if (!mSTexturep) { - // Fill with dummy gray data. - // GL NOT ACTIVE HERE - LLPointer raw = new LLImageRaw(sTextureSize, sTextureSize, 3); - U8 *default_texture = raw->getData(); - for (S32 i = 0; i < sTextureSize; i++) - { - for (S32 j = 0; j < sTextureSize; j++) - { - *(default_texture + (i*sTextureSize + j)*3) = 128; - *(default_texture + (i*sTextureSize + j)*3 + 1) = 128; - *(default_texture + (i*sTextureSize + j)*3 + 2) = 128; - } - } + U64 handle = mRegionp->getHandle(); - mSTexturep = LLViewerTextureManager::getLocalTexture(raw.get(), false); - mSTexturep->dontDiscard(); - gGL.getTexUnit(0)->bind(mSTexturep); - mSTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - } -} + U32 grid_x, grid_y; -void LLSurface::createWaterTexture() -{ - if (!mWaterTexturep) - { - // Create the water texture - LLPointer raw = new LLImageRaw(sTextureSize/2, sTextureSize/2, 4); - U8 *default_texture = raw->getData(); - for (S32 i = 0; i < sTextureSize/2; i++) - { - for (S32 j = 0; j < sTextureSize/2; j++) - { - *(default_texture + (i*sTextureSize/2 + j)*4) = MAX_WATER_COLOR.mV[0]; - *(default_texture + (i*sTextureSize/2 + j)*4 + 1) = MAX_WATER_COLOR.mV[1]; - *(default_texture + (i*sTextureSize/2 + j)*4 + 2) = MAX_WATER_COLOR.mV[2]; - *(default_texture + (i*sTextureSize/2 + j)*4 + 3) = MAX_WATER_COLOR.mV[3]; - } - } + grid_from_region_handle(handle, &grid_x, &grid_y); - mWaterTexturep = LLViewerTextureManager::getLocalTexture(raw.get(), false); - mWaterTexturep->dontDiscard(); - gGL.getTexUnit(0)->bind(mWaterTexturep); - mWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); + mSTexturep = LLWorldMipmap::loadObjectsTile(grid_x, grid_y, 1); } } @@ -285,11 +233,10 @@ void LLSurface::initTextures() /////////////////////// // - // Water texture + // Water object // if (gSavedSettings.getBOOL("RenderWater") ) { - createWaterTexture(); mWaterObjp = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_WATER, mRegionp); gPipeline.createObject(mWaterObjp); LLVector3d water_pos_global = from_region_handle(mRegionp->getHandle()); @@ -683,11 +630,8 @@ bool LLSurface::idleUpdate(F32 max_update_time) } } - if (did_update) - { - // some patches changed, update region reflection probes - mRegionp->updateReflectionProbes(); - } + // some patches changed, update region reflection probes + mRegionp->updateReflectionProbes(did_update); return did_update; } @@ -1221,98 +1165,3 @@ F32 LLSurface::getWaterHeight() const } } - -bool LLSurface::generateWaterTexture(const F32 x, const F32 y, - const F32 width, const F32 height) -{ - LL_PROFILE_ZONE_SCOPED - if (!getWaterTexture()) - { - return false; - } - - S32 tex_width = mWaterTexturep->getWidth(); - S32 tex_height = mWaterTexturep->getHeight(); - S32 tex_comps = mWaterTexturep->getComponents(); - S32 tex_stride = tex_width * tex_comps; - LLPointer raw = new LLImageRaw(tex_width, tex_height, tex_comps); - U8 *rawp = raw->getData(); - - F32 scale = 256.f * getMetersPerGrid() / (F32)tex_width; - F32 scale_inv = 1.f / scale; - - S32 x_begin, y_begin, x_end, y_end; - - x_begin = ll_round(x * scale_inv); - y_begin = ll_round(y * scale_inv); - x_end = ll_round((x + width) * scale_inv); - y_end = ll_round((y + width) * scale_inv); - - if (x_end > tex_width) - { - x_end = tex_width; - } - if (y_end > tex_width) - { - y_end = tex_width; - } - - // OK, for now, just have the composition value equal the height at the point. - LLVector3 location; - LLColor4U coloru; - - const F32 WATER_HEIGHT = getWaterHeight(); - - S32 i, j, offset; - for (j = y_begin; j < y_end; j++) - { - for (i = x_begin; i < x_end; i++) - { - //F32 nv[2]; - //nv[0] = i/256.f; - //nv[1] = j/256.f; - // const S32 modulation = noise2(nv)*40; - offset = j*tex_stride + i*tex_comps; - location.mV[VX] = i*scale; - location.mV[VY] = j*scale; - - // Sample multiple points - const F32 height = resolveHeightRegion(location); - - if (height > WATER_HEIGHT) - { - // Above water... - coloru = MAX_WATER_COLOR; - coloru.mV[3] = ABOVE_WATERLINE_ALPHA; - *(rawp + offset++) = coloru.mV[0]; - *(rawp + offset++) = coloru.mV[1]; - *(rawp + offset++) = coloru.mV[2]; - *(rawp + offset++) = coloru.mV[3]; - } - else - { - // Want non-linear curve for transparency gradient - coloru = MAX_WATER_COLOR; - const F32 frac = 1.f - 2.f/(2.f - (height - WATER_HEIGHT)); - S32 alpha = 64 + ll_round((255-64)*frac); - - alpha = llmin(ll_round((F32)MAX_WATER_COLOR.mV[3]), alpha); - alpha = llmax(64, alpha); - - coloru.mV[3] = alpha; - *(rawp + offset++) = coloru.mV[0]; - *(rawp + offset++) = coloru.mV[1]; - *(rawp + offset++) = coloru.mV[2]; - *(rawp + offset++) = coloru.mV[3]; - } - } - } - - if (!mWaterTexturep->hasGLTexture()) - { - mWaterTexturep->createGLTexture(0, raw); - } - - mWaterTexturep->setSubImage(raw, x_begin, y_begin, x_end - x_begin, y_end - y_begin); - return true; -} diff --git a/indra/newview/llsurface.h b/indra/newview/llsurface.h index 324296a4d3..68295225b6 100644 --- a/indra/newview/llsurface.h +++ b/indra/newview/llsurface.h @@ -128,7 +128,7 @@ public: F32 getWaterHeight() const; LLViewerTexture *getSTexture(); - LLViewerTexture *getWaterTexture(); + bool hasZData() const { return mHasZData; } void dirtyAllPatches(); // Use this to dirty all patches when changing terrain parameters @@ -171,19 +171,11 @@ public: protected: void createSTexture(); - void createWaterTexture(); void initTextures(); - void initWater(); - void createPatchData(); // Allocates memory for patches. void destroyPatchData(); // Deallocates memory for patches. - bool generateWaterTexture(const F32 x, const F32 y, - const F32 width, const F32 height); // Generate texture from composition values. - - //F32 updateTexture(LLSurfacePatch *ppatch); - LLSurfacePatch *getPatch(const S32 x, const S32 y) const; protected: @@ -201,7 +193,6 @@ protected: // The textures should never be directly initialized - use the setter methods! LLPointer mSTexturep; // Texture for surface - LLPointer mWaterTexturep; // Water texture LLPointer mWaterObjp; diff --git a/indra/newview/llsurfacepatch.cpp b/indra/newview/llsurfacepatch.cpp index 042d770550..2a21170b07 100644 --- a/indra/newview/llsurfacepatch.cpp +++ b/indra/newview/llsurfacepatch.cpp @@ -906,15 +906,8 @@ void LLSurfacePatch::updateGL() updateCompositionStats(); F32 tex_patch_size = meters_per_grid*grids_per_patch_edge; - if (comp->generateMinimapTileLand((F32)origin_region[VX], (F32)origin_region[VY], - tex_patch_size, tex_patch_size)) - { - mSTexUpdate = false; - // Also generate the water texture - mSurfacep->generateWaterTexture((F32)origin_region.mdV[VX], (F32)origin_region.mdV[VY], - tex_patch_size, tex_patch_size); - } + mSTexUpdate = false; } void LLSurfacePatch::dirtyZ() diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index b51bcc5601..9d7319d5b8 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -461,7 +461,7 @@ public: : texture_view("texture_view") { S32 line_height = LLFontGL::getFontMonospace()->getLineHeight(); - changeDefault(rect, LLRect(0,0,100,line_height * 4)); + changeDefault(rect, LLRect(0,0,0,line_height * 7)); } }; @@ -492,19 +492,51 @@ void LLGLTexMemBar::draw() U32 total_objects = gObjectList.getNumObjects(); F32 x_right = 0.0; + U32 image_count = gTextureList.getNumImages(); + U32 raw_image_count = 0; + U64 raw_image_bytes = 0; + + U32 saved_raw_image_count = 0; + U64 saved_raw_image_bytes = 0; + + U32 aux_raw_image_count = 0; + U64 aux_raw_image_bytes = 0; + + for (auto& image : gTextureList) + { + const LLImageRaw* raw_image = image->getRawImage(); + + if (raw_image) + { + raw_image_count++; + raw_image_bytes += raw_image->getDataSize(); + } + + raw_image = image->getSavedRawImage(); + if (raw_image) + { + saved_raw_image_count++; + saved_raw_image_bytes += raw_image->getDataSize(); + } + + raw_image = image->getAuxRawImage(); + if (raw_image) + { + aux_raw_image_count++; + aux_raw_image_bytes += raw_image->getDataSize(); + } + } + + F64 raw_image_bytes_MB = raw_image_bytes / (1024.0 * 1024.0); + F64 saved_raw_image_bytes_MB = saved_raw_image_bytes / (1024.0 * 1024.0); + F64 aux_raw_image_bytes_MB = aux_raw_image_bytes / (1024.0 * 1024.0); + //---------------------------------------------------------------------------- LLGLSUIDefault gls_ui; LLColor4 text_color(1.f, 1.f, 1.f, 0.75f); LLColor4 color; - // Gray background using completely magic numbers - gGL.color4f(0.f, 0.f, 0.f, 0.25f); - // const LLRect & rect(getRect()); - // gl_rect_2d(-4, v_offset, rect.mRight - rect.mLeft + 2, v_offset + line_height*4); - std::string text = ""; - LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*6, - text_color, LLFontGL::LEFT, LLFontGL::TOP); LLTrace::Recording& recording = LLViewerStats::instance().getRecording(); @@ -525,6 +557,10 @@ void LLGLTexMemBar::draw() U32 texFetchLatMed = U32(recording.getMean(LLTextureFetch::sTexFetchLatency).value() * 1000.0f); U32 texFetchLatMax = U32(recording.getMax(LLTextureFetch::sTexFetchLatency).value() * 1000.0f); + // draw a background above first line.... no idea where the rest of the background comes from for the below text + gGL.color4f(0.f, 0.f, 0.f, 0.25f); + gl_rect_2d(-10, getRect().getHeight() + line_height + 1, getRect().getWidth()+2, getRect().getHeight()+2); + text = llformat("Est. Free: %d MB Sys Free: %d MB FBO: %d MB Bias: %.2f Cache: %.1f/%.1f MB", (S32)LLViewerTexture::sFreeVRAMMegabytes, LLMemory::getAvailableMemKB()/1024, @@ -532,11 +568,15 @@ void LLGLTexMemBar::draw() discard_bias, cache_usage, cache_max_usage); - //, cache_entries, cache_max_entries - - LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*6, + LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*7, text_color, LLFontGL::LEFT, LLFontGL::TOP); + text = llformat("Images: %d Raw: %d (%.2f MB) Saved: %d (%.2f MB) Aux: %d (%.2f MB)", image_count, raw_image_count, raw_image_bytes_MB, + saved_raw_image_count, saved_raw_image_bytes_MB, + aux_raw_image_count, aux_raw_image_bytes_MB); + LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height * 6, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + U32 cache_read(0U), cache_write(0U), res_wait(0U); LLAppViewer::getTextureFetch()->getStateStats(&cache_read, &cache_write, &res_wait); @@ -549,7 +589,6 @@ void LLGLTexMemBar::draw() cache_read, cache_write, res_wait); - LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*5, text_color, LLFontGL::LEFT, LLFontGL::TOP); @@ -789,7 +828,7 @@ void LLTextureView::draw() LL_INFOS() << "ID\tMEM\tBOOST\tPRI\tWIDTH\tHEIGHT\tDISCARD" << LL_ENDL; } - for (LLViewerTextureList::image_priority_list_t::iterator iter = gTextureList.mImageList.begin(); + for (LLViewerTextureList::image_list_t::iterator iter = gTextureList.mImageList.begin(); iter != gTextureList.mImageList.end(); ) { LLPointer imagep = *iter++; diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 23931ecf03..f62d929e9a 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1253,41 +1253,46 @@ void LLViewerMedia::getOpenIDCookieCoro(std::string url) hostEnd = authority.size(); } - LLViewerMedia* inst = getInstance(); if (url.length()) { - LLMediaCtrl* media_instance = LLFloaterReg::getInstance("destinations")->getChild("destination_guide_contents"); - if (media_instance) - { - std::string cookie_host = authority.substr(hostStart, hostEnd - hostStart); - std::string cookie_name = ""; - std::string cookie_value = ""; - std::string cookie_path = ""; - bool httponly = true; - bool secure = true; - if (inst->parseRawCookie(inst->mOpenIDCookie, cookie_name, cookie_value, cookie_path, httponly, secure) && - media_instance->getMediaPlugin()) + LLAppViewer::instance()->postToMainCoro([=]() { - // MAINT-5711 - inexplicably, the CEF setCookie function will no longer set the cookie if the - // url and domain are not the same. This used to be my.sl.com and id.sl.com respectively and worked. - // For now, we use the URL for the OpenID POST request since it will have the same authority - // as the domain field. - // (Feels like there must be a less dirty way to construct a URL from component LLURL parts) - // MAINT-6392 - Rider: Do not change, however, the original URI requested, since it is used further - // down. - std::string cefUrl(std::string(inst->mOpenIDURL.mURI) + "://" + std::string(inst->mOpenIDURL.mAuthority)); - - media_instance->getMediaPlugin()->setCookie(cefUrl, cookie_name, cookie_value, cookie_host, - cookie_path, httponly, secure); - - // Now that we have parsed the raw cookie, we must store it so that each new media instance - // can also get a copy and faciliate logging into internal SL sites. - media_instance->getMediaPlugin()->storeOpenIDCookie(cefUrl, cookie_name, cookie_value, - cookie_host, cookie_path, httponly, secure); - } - } + LLMediaCtrl* media_instance = LLFloaterReg::getInstance("destinations")->getChild("destination_guide_contents"); + if (media_instance) + { + LLViewerMedia* inst = getInstance(); + std::string cookie_host = authority.substr(hostStart, hostEnd - hostStart); + std::string cookie_name = ""; + std::string cookie_value = ""; + std::string cookie_path = ""; + bool httponly = true; + bool secure = true; + if (inst->parseRawCookie(inst->mOpenIDCookie, cookie_name, cookie_value, cookie_path, httponly, secure) && + media_instance->getMediaPlugin()) + { + // MAINT-5711 - inexplicably, the CEF setCookie function will no longer set the cookie if the + // url and domain are not the same. This used to be my.sl.com and id.sl.com respectively and worked. + // For now, we use the URL for the OpenID POST request since it will have the same authority + // as the domain field. + // (Feels like there must be a less dirty way to construct a URL from component LLURL parts) + // MAINT-6392 - Rider: Do not change, however, the original URI requested, since it is used further + // down. + std::string cefUrl(std::string(inst->mOpenIDURL.mURI) + "://" + std::string(inst->mOpenIDURL.mAuthority)); + + media_instance->getMediaPlugin()->setCookie(cefUrl, cookie_name, cookie_value, cookie_host, + cookie_path, httponly, secure); + + // Now that we have parsed the raw cookie, we must store it so that each new media instance + // can also get a copy and faciliate logging into internal SL sites. + media_instance->getMediaPlugin()->storeOpenIDCookie(cefUrl, cookie_name, cookie_value, + cookie_host, cookie_path, httponly, secure); + } + } + }); } + LLViewerMedia* inst = getInstance(); + // Note: Rider: MAINT-6392 - Some viewer code requires access to the my.sl.com openid cookie for such // actions as posting snapshots to the feed. This is handled through HTTPCore rather than CEF and so // we must learn to SHARE the cookies. diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 8af0057c88..232b020d3d 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -3676,7 +3676,9 @@ bool LLViewerObject::updateLOD() bool LLViewerObject::updateGeometry(LLDrawable *drawable) { - return false; + // return true means "update complete", return false means "try again next frame" + // default should be return true + return true; } void LLViewerObject::updateGL() diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 19a1990665..39244c8246 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1269,8 +1269,12 @@ U32 LLViewerRegion::getNumOfVisibleGroups() const return mImpl ? static_cast(mImpl->mVisibleGroups.size()) : 0; } -void LLViewerRegion::updateReflectionProbes() +void LLViewerRegion::updateReflectionProbes(bool full_update) { + if (!full_update && mReflectionMaps.empty()) + { + return; + } LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; const F32 probe_spacing = 32.f; const F32 probe_radius = sqrtf((probe_spacing * 0.5f) * (probe_spacing * 0.5f) * 3.f); diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 68247dc18e..d0ec1fe877 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -428,7 +428,7 @@ public: static bool isNewObjectCreationThrottleDisabled() {return sNewObjectCreationThrottle < 0;} // rebuild reflection probe list - void updateReflectionProbes(); + void updateReflectionProbes(bool full_update); private: void addToVOCacheTree(LLVOCacheEntry* entry); diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index c716eb4e86..b2ed86707c 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -414,8 +414,6 @@ void LLViewerTextureManager::init() } } imagep->createGLTexture(0, image_raw); - //cache the raw image - imagep->setCachedRawImage(0, image_raw); image_raw = NULL; #else LLViewerFetchedTexture::sDefaultImagep = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, true, LLGLTexture::BOOST_UI); @@ -728,9 +726,6 @@ bool LLViewerTexture::bindDefaultImage(S32 stage) } stop_glerror(); - //check if there is cached raw image and switch to it if possible - switchToCachedImage(); - LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); if (tester) { @@ -931,18 +926,6 @@ void LLViewerTexture::reorganizeVolumeList() } } -//virtual -void LLViewerTexture::switchToCachedImage() -{ - //nothing here. -} - -//virtual -void LLViewerTexture::setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) -{ - //nothing here. -} - bool LLViewerTexture::isLargeImage() { return (S32)mTexelsPerImage > LLViewerTexture::sMinLargeImageSize; @@ -1077,10 +1060,6 @@ void LLViewerFetchedTexture::init(bool firstinit) mIsFetched = false; mInFastCacheList = false; - mCachedRawImage = NULL; - mCachedRawDiscardLevel = -1; - mCachedRawImageReady = false; - mSavedRawImage = NULL; mForceToSaveRawImage = false; mSaveRawImage = false; @@ -1138,9 +1117,6 @@ void LLViewerFetchedTexture::cleanup() // Clean up image data destroyRawImage(); - mCachedRawImage = NULL; - mCachedRawDiscardLevel = -1; - mCachedRawImageReady = false; mSavedRawImage = NULL; mSavedRawDiscardLevel = -1; } @@ -1220,13 +1196,17 @@ void LLViewerFetchedTexture::setForSculpt() { static const S32 MAX_INTERVAL = 8; //frames + forceToSaveRawImage(0, F32_MAX); + + setBoostLevel(llmax((S32)getBoostLevel(), + (S32)LLGLTexture::BOOST_SCULPTED)); + mForSculpt = true; if(isForSculptOnly() && hasGLTexture() && !getBoundRecently()) { destroyGLTexture(); //sculpt image does not need gl texture. mTextureState = ACTIVE; } - checkCachedRawSculptImage(); setMaxVirtualSizeResetInterval(MAX_INTERVAL); } @@ -1339,10 +1319,6 @@ void LLViewerFetchedTexture::addToCreateTexture() } } - //discard the cached raw image and the saved raw image - mCachedRawImageReady = false; - mCachedRawDiscardLevel = -1; - mCachedRawImage = NULL; mSavedRawDiscardLevel = -1; mSavedRawImage = NULL; } @@ -2043,13 +2019,6 @@ bool LLViewerFetchedTexture::updateFetch() LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - current < min"); make_request = false; } - else if(mCachedRawImage.notNull() // can be empty - && mCachedRawImageReady - && (current_discard < 0 || current_discard > mCachedRawDiscardLevel)) - { - make_request = false; - switchToCachedImage(); //use the cached raw data first - } if (make_request) { @@ -2542,20 +2511,6 @@ bool LLViewerFetchedTexture::doLoadedCallbacks() } } - // - // Do a readback if required, OR start off a texture decode - // - if (need_readback && (getMaxDiscardLevel() > gl_discard)) - { - // Do a readback to get the GL data into the raw image - // We have GL data. - - destroyRawImage(); - reloadRawImage(mLoadedCallbackDesiredDiscardLevel); - llassert(mRawImage.notNull()); - llassert(!mNeedsAux || mAuxRawImage.notNull()); - } - // // Run raw/auxiliary data callbacks // @@ -2663,61 +2618,6 @@ void LLViewerFetchedTexture::forceImmediateUpdate() return; } -LLImageRaw* LLViewerFetchedTexture::reloadRawImage(S8 discard_level) -{ - llassert(mGLTexturep.notNull()); - llassert(discard_level >= 0); - llassert(mComponents > 0); - - if (mRawImage.notNull()) - { - //mRawImage is in use by somebody else, do not delete it. - return NULL; - } - - if(mSavedRawDiscardLevel >= 0 && mSavedRawDiscardLevel <= discard_level) - { - if (mSavedRawDiscardLevel != discard_level - && mBoostLevel != BOOST_ICON - && mBoostLevel != BOOST_THUMBNAIL) - { - mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), getComponents()); - mRawImage->copy(getSavedRawImage()); - } - else - { - mRawImage = getSavedRawImage(); - } - mRawDiscardLevel = discard_level; - } - else - { - //force to fetch raw image again if cached raw image is not good enough. - if(mCachedRawDiscardLevel > discard_level) - { - mRawImage = mCachedRawImage; - mRawDiscardLevel = mCachedRawDiscardLevel; - } - else //cached raw image is good enough, copy it. - { - if(mCachedRawDiscardLevel != discard_level) - { - mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), getComponents()); - mRawImage->copy(mCachedRawImage); - } - else - { - mRawImage = mCachedRawImage; - } - mRawDiscardLevel = discard_level; - } - } - mIsRawImageValid = true; - sRawCount++; - - return mRawImage; -} - bool LLViewerFetchedTexture::needsToSaveRawImage() { return mForceToSaveRawImage || mSaveRawImage; @@ -2742,7 +2642,6 @@ void LLViewerFetchedTexture::destroyRawImage() { saveRawImage(); } - setCachedRawImage(); } mRawImage = NULL; @@ -2752,151 +2651,6 @@ void LLViewerFetchedTexture::destroyRawImage() } } -//use the mCachedRawImage to (re)generate the gl texture. -//virtual -void LLViewerFetchedTexture::switchToCachedImage() -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - if(mCachedRawImage.notNull() && - !mNeedsCreateTexture) // <--- texture creation is pending, don't step on it - { - mRawImage = mCachedRawImage; - - if (getComponents() != mRawImage->getComponents()) - { - // We've changed the number of components, so we need to move any - // objects using this pool to a different pool. - mComponents = mRawImage->getComponents(); - mGLTexturep->setComponents(mComponents); - gTextureList.dirtyImage(this); - } - - mIsRawImageValid = true; - mRawDiscardLevel = mCachedRawDiscardLevel; - - scheduleCreateTexture(); - } -} - -//cache the imageraw forcefully. -//virtual -void LLViewerFetchedTexture::setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) -{ - if(imageraw != mRawImage.get()) - { - if (mBoostLevel == LLGLTexture::BOOST_ICON) - { - S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENSIONS; - S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENSIONS; - if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height) - { - mCachedRawImage = new LLImageRaw(expected_width, expected_height, imageraw->getComponents()); - mCachedRawImage->copyScaled(imageraw); - } - else - { - mCachedRawImage = imageraw; - } - } - else if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL) - { - S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS; - S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS; - if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height) - { - mCachedRawImage = new LLImageRaw(expected_width, expected_height, imageraw->getComponents()); - mCachedRawImage->copyScaled(imageraw); - } - else - { - mCachedRawImage = imageraw; - } - } - else - { - mCachedRawImage = imageraw; - } - mCachedRawDiscardLevel = discard_level; - mCachedRawImageReady = true; - } -} - -void LLViewerFetchedTexture::setCachedRawImage() -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - if(mRawImage == mCachedRawImage) - { - return; - } - if(!mIsRawImageValid) - { - return; - } - - if(mCachedRawImageReady) - { - return; - } - - if(mCachedRawDiscardLevel < 0 || mCachedRawDiscardLevel > mRawDiscardLevel) - { - S32 i = 0; - S32 w = mRawImage->getWidth(); - S32 h = mRawImage->getHeight(); - - S32 max_size = MAX_CACHED_RAW_IMAGE_AREA; - if(LLGLTexture::BOOST_TERRAIN == mBoostLevel) - { - max_size = MAX_CACHED_RAW_TERRAIN_IMAGE_AREA; - } - if(mForSculpt) - { - max_size = MAX_CACHED_RAW_SCULPT_IMAGE_AREA; - mCachedRawImageReady = !mRawDiscardLevel; - } - else - { - mCachedRawImageReady = (!mRawDiscardLevel || ((w * h) >= max_size)); - } - - while(((w >> i) * (h >> i)) > max_size) - { - ++i; - } - - if(i) - { - if(!(w >> i) || !(h >> i)) - { - --i; - } - - { - //make a duplicate in case somebody else is using this raw image - mRawImage = mRawImage->scaled(w >> i, h >> i); - } - } - mCachedRawImage = mRawImage; - mRawDiscardLevel += i; - mCachedRawDiscardLevel = mRawDiscardLevel; - } -} - -void LLViewerFetchedTexture::checkCachedRawSculptImage() -{ - if(mCachedRawImageReady && mCachedRawDiscardLevel > 0) - { - if(getDiscardLevel() != 0) - { - mCachedRawImageReady = false; - } - else if(isForSculptOnly()) - { - resetTextureStats(); //do not update this image any more. - } - } -} - void LLViewerFetchedTexture::saveRawImage() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; @@ -2936,6 +2690,20 @@ void LLViewerFetchedTexture::saveRawImage() mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents()); } } + else if (mBoostLevel == LLGLTexture::BOOST_SCULPTED) + { + S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : sMaxSculptRez; + S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : sMaxSculptRez; + if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height) + { + mSavedRawImage = new LLImageRaw(expected_width, expected_height, mRawImage->getComponents()); + mSavedRawImage->copyScaled(mRawImage); + } + else + { + mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents()); + } + } else { mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents()); @@ -2981,20 +2749,23 @@ void LLViewerFetchedTexture::forceToSaveRawImage(S32 desired_discard, F32 kept_t { mForceToSaveRawImage = true; mDesiredSavedRawDiscardLevel = desired_discard; + } +} - //copy from the cached raw image if exists. - if(mCachedRawImage.notNull() && mRawImage.isNull() ) - { - mRawImage = mCachedRawImage; - mRawDiscardLevel = mCachedRawDiscardLevel; - - saveRawImage(); +void LLViewerFetchedTexture::readbackRawImage() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - mRawImage = NULL; - mRawDiscardLevel = INVALID_DISCARD_LEVEL; + if (mGLTexturep.notNull() && mGLTexturep->getTexName() != 0 && mRawImage.isNull()) + { + mRawImage = new LLImageRaw(); + if (!mGLTexturep->readBackRaw(-1, mRawImage, false)) + { + mRawImage = nullptr; } } } + void LLViewerFetchedTexture::destroySavedRawImage() { if(mLastReferencedSavedRawImageTime < mKeptSavedRawImageTime) @@ -3029,6 +2800,11 @@ LLImageRaw* LLViewerFetchedTexture::getSavedRawImage() return mSavedRawImage; } +const LLImageRaw* LLViewerFetchedTexture::getSavedRawImage() const +{ + return mSavedRawImage; +} + bool LLViewerFetchedTexture::hasSavedRawImage() const { return mSavedRawImage.notNull(); @@ -3205,20 +2981,14 @@ void LLViewerLODTexture::processTextureStats() bool LLViewerLODTexture::scaleDown() { - if(hasGLTexture() && mCachedRawDiscardLevel > getDiscardLevel()) + if (mGLTexturep.isNull()) { - switchToCachedImage(); - - LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); - if (tester) - { - tester->setStablizingTime(); - } - - return true; + return false; } - return false; + + return mGLTexturep->scaleDown(mDesiredDiscardLevel); } + //---------------------------------------------------------------------------------------------- //end of LLViewerLODTexture //---------------------------------------------------------------------------------------------- diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 9963626ada..b1e0494a30 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -166,8 +166,6 @@ public: S32 getNumVolumes(U32 channel) const; const ll_volume_list_t* getVolumeList(U32 channel) const { return &mVolumeList[channel]; } - - virtual void setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) ; bool isLargeImage() ; void setParcelMedia(LLViewerMediaTexture* media) {mParcelMedia = media;} @@ -185,8 +183,6 @@ private: friend class LLBumpImageList; friend class LLUIImageList; - virtual void switchToCachedImage(); - protected: friend class LLViewerTextureList; LLUUID mID; @@ -371,7 +367,6 @@ public: U32 getFetchPriority() const { return mFetchPriority ;} F32 getDownloadProgress() const {return mDownloadProgress ;} - LLImageRaw* reloadRawImage(S8 discard_level) ; void destroyRawImage(); bool needsToSaveRawImage(); @@ -390,17 +385,20 @@ public: bool isForSculptOnly() const; //raw image management - void checkCachedRawSculptImage() ; LLImageRaw* getRawImage()const { return mRawImage ;} S32 getRawImageLevel() const {return mRawDiscardLevel;} - LLImageRaw* getCachedRawImage() const { return mCachedRawImage ;} - S32 getCachedRawImageLevel() const {return mCachedRawDiscardLevel;} - bool isCachedRawImageReady() const {return mCachedRawImageReady ;} bool isRawImageValid()const { return mIsRawImageValid ; } void forceToSaveRawImage(S32 desired_discard = 0, F32 kept_time = 0.f) ; - /*virtual*/ void setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) override; + + // readback the raw image from OpenGL if mRawImage is not valid + void readbackRawImage(); + void destroySavedRawImage() ; LLImageRaw* getSavedRawImage() ; + S32 getSavedRawImageLevel() const {return mSavedRawDiscardLevel; } + + const LLImageRaw* getSavedRawImage() const; + const LLImageRaw* getAuxRawImage() const { return mAuxRawImage; } bool hasSavedRawImage() const ; F32 getElapsedLastReferencedSavedRawImageTime() const ; bool isFullyLoaded() const; @@ -417,7 +415,6 @@ public: /*virtual*/bool isActiveFetching() override; //is actively in fetching by the fetching pipeline. protected: - /*virtual*/ void switchToCachedImage() override; S32 getCurrentDiscardLevelForFetching() ; void forceToRefetchTexture(S32 desired_discard = 0, F32 kept_time = 60.f); @@ -426,7 +423,6 @@ private: void cleanup() ; void saveRawImage() ; - void setCachedRawImage() ; //for atlas void resetFaceAtlas() ; @@ -498,11 +494,6 @@ protected: F32 mLastReferencedSavedRawImageTime ; F32 mKeptSavedRawImageTime ; - //a small version of the copy of the raw image (<= 64 * 64) - LLPointer mCachedRawImage; - S32 mCachedRawDiscardLevel; - bool mCachedRawImageReady; //the rez of the mCachedRawImage reaches the upper limit. - LLHost mTargetHost; // if invalid, just request from agent's simulator // Timers diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index b90c1868fc..4d8fd8ddd5 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -296,7 +296,7 @@ void LLViewerTextureList::shutdown() // Write out list of currently loaded textures for precaching on startup typedef std::set > image_area_list_t; image_area_list_t image_area_list; - for (image_priority_list_t::iterator iter = mImageList.begin(); + for (image_list_t::iterator iter = mImageList.begin(); iter != mImageList.end(); ++iter) { LLViewerFetchedTexture* image = *iter; @@ -367,7 +367,7 @@ void LLViewerTextureList::dump() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; LL_INFOS() << "LLViewerTextureList::dump()" << LL_ENDL; - for (image_priority_list_t::iterator it = mImageList.begin(); it != mImageList.end(); ++it) + for (image_list_t::iterator it = mImageList.begin(); it != mImageList.end(); ++it) { LLViewerFetchedTexture* image = *it; @@ -381,15 +381,9 @@ void LLViewerTextureList::dump() } } -void LLViewerTextureList::destroyGL(bool save_state) +void LLViewerTextureList::destroyGL() { - LLImageGL::destroyGL(save_state); -} - -void LLViewerTextureList::restoreGL() -{ - llassert_always(mInitialized) ; - LLImageGL::restoreGL(); + LLImageGL::destroyGL(); } /* Vertical tab container button image IDs @@ -895,7 +889,7 @@ void LLViewerTextureList::clearFetchingRequests() LLAppViewer::getTextureFetch()->deleteAllRequests(); - for (image_priority_list_t::iterator iter = mImageList.begin(); + for (image_list_t::iterator iter = mImageList.begin(); iter != mImageList.end(); ++iter) { LLViewerFetchedTexture* imagep = *iter; @@ -1208,7 +1202,7 @@ void LLViewerTextureList::updateImagesUpdateStats() LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; if (mForceResetTextureStats) { - for (image_priority_list_t::iterator iter = mImageList.begin(); + for (image_list_t::iterator iter = mImageList.begin(); iter != mImageList.end(); ) { LLViewerFetchedTexture* imagep = *iter++; @@ -1228,7 +1222,7 @@ void LLViewerTextureList::decodeAllImages(F32 max_time) // Update texture stats and priorities std::vector > image_list; - for (image_priority_list_t::iterator iter = mImageList.begin(); + for (image_list_t::iterator iter = mImageList.begin(); iter != mImageList.end(); ) { LLViewerFetchedTexture* imagep = *iter++; @@ -1248,7 +1242,7 @@ void LLViewerTextureList::decodeAllImages(F32 max_time) image_list.clear(); // Update fetch (decode) - for (image_priority_list_t::iterator iter = mImageList.begin(); + for (image_list_t::iterator iter = mImageList.begin(); iter != mImageList.end(); ) { LLViewerFetchedTexture* imagep = *iter++; @@ -1275,7 +1269,7 @@ void LLViewerTextureList::decodeAllImages(F32 max_time) } } // Update fetch again - for (image_priority_list_t::iterator iter = mImageList.begin(); + for (image_list_t::iterator iter = mImageList.begin(); iter != mImageList.end(); ) { LLViewerFetchedTexture* imagep = *iter++; diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index e4ebb7b0e8..2779ad9f91 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -33,7 +33,7 @@ #include "llviewertexture.h" #include "llui.h" #include -#include +#include #include "lluiimage.h" const U32 LL_IMAGE_REZ_LOSSLESS_CUTOFF = 128; @@ -115,8 +115,7 @@ public: void init(); void shutdown(); void dump(); - void destroyGL(bool save_state = true); - void restoreGL(); + void destroyGL(); bool isInitialized() const {return mInitialized;} void findTexturesByID(const LLUUID &image_id, std::vector &output); @@ -188,7 +187,7 @@ private: LLViewerTexture::EBoostLevel boost_priority = LLGLTexture::BOOST_NONE, // Get the requested level immediately upon creation. S8 texture_type = LLViewerTexture::FETCHED_TEXTURE, LLGLint internal_format = 0, - LLGLenum primary_format = 0, + LLGLenum primary_format = 0, const LLUUID& force_id = LLUUID::null ); @@ -211,7 +210,7 @@ private: { return getImage(image_id, f_type, true, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, host); } public: - typedef std::set > image_list_t; + typedef std::unordered_set > image_list_t; image_list_t mLoadingStreamList; image_list_t mCreateTextureList; image_list_t mCallbackList; @@ -222,16 +221,19 @@ public: bool mForceResetTextureStats; + // to make "for (auto& imagep : gTextureList)" work + const image_list_t::iterator begin() const { return mImageList.begin(); } + const image_list_t::iterator end() const { return mImageList.end(); } + private: typedef std::map< LLTextureKey, LLPointer > uuid_map_t; uuid_map_t mUUIDMap; LLTextureKey mLastUpdateKey; - typedef std::set < LLPointer > image_priority_list_t; - image_priority_list_t mImageList; + image_list_t mImageList; // simply holds on to LLViewerFetchedTexture references to stop them from being purged too soon - std::set > mImagePreloads; + std::unordered_set > mImagePreloads; bool mInitialized ; LLFrameTimer mForceDecodeTimer; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index cfa12bf178..ef85d57416 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1827,10 +1827,8 @@ LLViewerWindow::LLViewerWindow(const Params& p) mToolStored( NULL ), mHideCursorPermanent( false ), mCursorHidden(false), - mIgnoreActivate( false ), mResDirty(false), mStatesDirty(false), - mCurrResolutionIndex(0), mProgressView(NULL) { // gKeyboard is still NULL, so it doesn't do LLWindowListener any good to @@ -2402,7 +2400,7 @@ void LLViewerWindow::shutdownGL() LLSelectMgr::getInstance()->cleanup(); LL_INFOS() << "Stopping GL during shutdown" << LL_ENDL; - stopGL(false); + stopGL(); stop_glerror(); gGL.shutdown(); @@ -5715,7 +5713,7 @@ void LLViewerWindow::dumpState() << LL_ENDL; } -void LLViewerWindow::stopGL(bool save_state) +void LLViewerWindow::stopGL() { //Note: --bao //if not necessary, do not change the order of the function calls in this function. @@ -5761,7 +5759,7 @@ void LLViewerWindow::stopGL(bool save_state) gPostProcess->invalidate(); } - gTextureList.destroyGL(save_state); + gTextureList.destroyGL(); stop_glerror(); gGLManager.mIsDisabled = true; @@ -5778,6 +5776,14 @@ void LLViewerWindow::stopGL(bool save_state) void LLViewerWindow::restoreGL(const std::string& progress_message) { + llassert(false); + // DEPRECATED -- this is left over from when we would completely destroy and restore a GL context + // when switching from windowed to fullscreen. None of this machinery has been exercised in years + // and is unreliable. If we ever *do* have another use case where completely unloading and reloading + // everthing is necessary, requiring a viewer restart for that operation is a fine thing to do. + // -- davep + + //Note: --bao //if not necessary, do not change the order of the function calls in this function. //if change something, make sure it will not break anything. @@ -5790,8 +5796,6 @@ void LLViewerWindow::restoreGL(const std::string& progress_message) initGLDefaults(); LLGLState::restoreGL(); - gTextureList.restoreGL(); - // for future support of non-square pixels, and fonts that are properly stretched //LLFontGL::destroyDefaultFonts(); initFonts(); @@ -5867,122 +5871,6 @@ void LLViewerWindow::checkSettings() } } -void LLViewerWindow::restartDisplay(bool show_progress_bar) -{ - LL_INFOS() << "Restaring GL" << LL_ENDL; - stopGL(); - if (show_progress_bar) - { - restoreGL(LLTrans::getString("ProgressChangingResolution")); - } - else - { - restoreGL(); - } -} - -bool LLViewerWindow::changeDisplaySettings(LLCoordScreen size, bool enable_vsync, bool show_progress_bar) -{ - //bool was_maximized = gSavedSettings.getBOOL("WindowMaximized"); - - //gResizeScreenTexture = true; - - - //U32 fsaa = gSavedSettings.getU32("RenderFSAASamples"); - //U32 old_fsaa = mWindow->getFSAASamples(); - - // if not maximized, use the request size - if (!mWindow->getMaximized()) - { - mWindow->setSize(size); - } - - //if (fsaa == old_fsaa) - { - return true; - } - -/* - - // Close floaters that don't handle settings change - LLFloaterReg::hideInstance("snapshot"); - - bool result_first_try = false; - bool result_second_try = false; - - LLFocusableElement* keyboard_focus = gFocusMgr.getKeyboardFocus(); - send_agent_pause(); - LL_INFOS() << "Stopping GL during changeDisplaySettings" << LL_ENDL; - stopGL(); - mIgnoreActivate = true; - LLCoordScreen old_size; - LLCoordScreen old_pos; - mWindow->getSize(&old_size); - - //mWindow->setFSAASamples(fsaa); - - result_first_try = mWindow->switchContext(false, size, disable_vsync); - if (!result_first_try) - { - // try to switch back - //mWindow->setFSAASamples(old_fsaa); - result_second_try = mWindow->switchContext(false, old_size, disable_vsync); - - if (!result_second_try) - { - // we are stuck...try once again with a minimal resolution? - send_agent_resume(); - mIgnoreActivate = false; - return false; - } - } - send_agent_resume(); - - LL_INFOS() << "Restoring GL during resolution change" << LL_ENDL; - if (show_progress_bar) - { - restoreGL(LLTrans::getString("ProgressChangingResolution")); - } - else - { - restoreGL(); - } - - if (!result_first_try) - { - LLSD args; - args["RESX"] = llformat("%d",size.mX); - args["RESY"] = llformat("%d",size.mY); - LLNotificationsUtil::add("ResolutionSwitchFail", args); - size = old_size; // for reshape below - } - - bool success = result_first_try || result_second_try; - - if (success) - { - // maximize window if was maximized, else reposition - if (was_maximized) - { - mWindow->maximize(); - } - else - { - S32 windowX = gSavedSettings.getS32("WindowX"); - S32 windowY = gSavedSettings.getS32("WindowY"); - - mWindow->setPosition(LLCoordScreen ( windowX, windowY ) ); - } - } - - mIgnoreActivate = false; - gFocusMgr.setKeyboardFocus(keyboard_focus); - - return success; - - */ -} - F32 LLViewerWindow::getWorldViewAspectRatio() const { F32 world_aspect = (F32)mWorldViewRectRaw.getWidth() / (F32)mWorldViewRectRaw.getHeight(); diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 4a6b901b33..ba59ce4141 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -455,9 +455,7 @@ public: // handle shutting down GL and bringing it back up void requestResolutionUpdate(); void checkSettings(); - void restartDisplay(bool show_progress_bar); - bool changeDisplaySettings(LLCoordScreen size, bool enable_vsync, bool show_progress_bar); - bool getIgnoreDestroyWindow() { return mIgnoreActivate; } + F32 getWorldViewAspectRatio() const; const LLVector2& getDisplayScale() const { return mDisplayScale; } void calcDisplayScale(); @@ -471,7 +469,7 @@ private: void switchToolByMask(MASK mask); void destroyWindow(); void drawMouselookInstructions(); - void stopGL(bool save_state = true); + void stopGL(); void restoreGL(const std::string& progress_message = LLStringUtil::null); void initFonts(F32 zoom_factor = 1.f); void schedulePick(LLPickInfo& pick_info); @@ -528,8 +526,6 @@ private: std::string mOverlayTitle; // Used for special titles such as "Second Life - Special E3 2003 Beta" - bool mIgnoreActivate; - std::string mInitAlert; // Window / GL initialization requires an alert LLHandle mWorldViewPlaceholder; // widget that spans the portion of screen dedicated to rendering the 3d world @@ -542,7 +538,6 @@ private: bool mResDirty; bool mStatesDirty; - U32 mCurrResolutionIndex; std::unique_ptr mWindowListener; std::unique_ptr mViewerWindowListener; diff --git a/indra/newview/llvlcomposition.cpp b/indra/newview/llvlcomposition.cpp index ba255f2b24..f5f058a080 100644 --- a/indra/newview/llvlcomposition.cpp +++ b/indra/newview/llvlcomposition.cpp @@ -317,7 +317,7 @@ bool LLTerrainMaterials::makeMaterialsReady(bool boost, bool strict) // static bool LLTerrainMaterials::makeTextureReady(LLPointer& tex, bool boost) { - llassert(tex); + //llassert(tex); ??? maybe ok ??? if (!tex) { return false; } if (tex->getDiscardLevel() < 0) @@ -571,416 +571,6 @@ bool LLVLComposition::generateComposition() return LLTerrainMaterials::generateMaterials(); } -namespace -{ - void prepare_fallback_image(LLImageRaw* raw_image) - { - raw_image->resize(BASE_SIZE, BASE_SIZE, 4); - raw_image->fill(LLColor4U::white); - } - - // Check if the raw image is loaded for this texture at a discard - // level the minimap can use, and if not then try to get it loaded. - bool prepare_raw_image(LLPointer& raw_image, bool emissive, LLViewerFetchedTexture* tex, bool& delete_raw_post) - { - if (!tex) - { - if (!emissive) - { - prepare_fallback_image(raw_image); - } - else - { - llassert(!raw_image); - raw_image = nullptr; - } - return true; - } - if (raw_image) - { - // Callback already initiated - if (raw_image->getDataSize() > 0) - { - // Callback finished - delete_raw_post = true; - return true; - } - else - { - return false; - } - } - - raw_image = new LLImageRaw(); - - S32 ddiscard = 0; - { - S32 min_dim = llmin(tex->getFullWidth(), tex->getFullHeight()); - while (min_dim > BASE_SIZE && ddiscard < MAX_DISCARD_LEVEL) - { - ddiscard++; - min_dim /= 2; - } - } - - struct PendingImage - { - LLImageRaw* mRawImage; - S32 mDesiredDiscard; - LLUUID mTextureId; - PendingImage(LLImageRaw* raw_image, S32 ddiscard, const LLUUID& texture_id) - : mRawImage(raw_image) - , mDesiredDiscard(ddiscard) - , mTextureId(texture_id) - { - mRawImage->ref(); - } - ~PendingImage() - { - mRawImage->unref(); - } - }; - PendingImage* pending_image = new PendingImage(raw_image, ddiscard, tex->getID()); - - loaded_callback_func cb = [](bool success, LLViewerFetchedTexture * src_vi, LLImageRaw * src, LLImageRaw * src_aux, S32 discard_level, bool is_final, void* userdata) { - PendingImage* pending = (PendingImage*)userdata; - // Owning LLVLComposition still exists - - // Assume mRawImage only used by single LLVLComposition for now - const bool in_use_by_composition = pending->mRawImage->getNumRefs() > 1; - llassert(pending->mRawImage->getNumRefs()); - llassert(pending->mRawImage->getNumRefs() <= 2); - const bool needs_data = !pending->mRawImage->getDataSize(); - if (in_use_by_composition && needs_data) - { - if (success && pending->mDesiredDiscard == discard_level) - { - pending->mRawImage->resize(BASE_SIZE, BASE_SIZE, src->getComponents()); - pending->mRawImage->copyScaled(src); - } - else if (is_final) - { - prepare_fallback_image(pending->mRawImage); - } - } - - if (is_final) { delete pending; } - }; - tex->setLoadedCallback(cb, ddiscard, true, false, pending_image, nullptr); - tex->forceToSaveRawImage(ddiscard); - - return false; - } -}; - -bool LLVLComposition::generateMinimapTileLand(const F32 x, const F32 y, - const F32 width, const F32 height) -{ - LL_PROFILE_ZONE_SCOPED - llassert(mSurfacep); - llassert(x >= 0.f); - llassert(y >= 0.f); - - /////////////////////////// - // - // Generate raw data arrays for surface textures - // - // - - // These have already been validated by generateComposition. - U8* st_data[ASSET_COUNT]; - S32 st_data_size[ASSET_COUNT]; // for debugging - - const bool use_textures = getMaterialType() != LLTerrainMaterials::Type::PBR; - if (use_textures) - { - if (!makeTexturesReady(true, true)) { return false; } - } - else - { - if (!makeMaterialsReady(true, true)) { return false; } - } - - for (S32 i = 0; i < ASSET_COUNT; i++) - { - if (mRawImages[i].isNull()) - { - // Read back a raw image for this discard level, if it exists - LLViewerFetchedTexture* tex; - LLViewerFetchedTexture* tex_emissive; // Can be null - bool has_base_color_factor; - bool has_emissive_factor; - bool has_alpha; - LLColor3 base_color_factor; - LLColor3 emissive_factor; - if (use_textures) - { - tex = mDetailTextures[i]; - tex_emissive = nullptr; - has_base_color_factor = false; - has_emissive_factor = false; - has_alpha = false; - llassert(tex); - } - else - { - LLPointer& mat = mDetailRenderMaterials[i]; - tex = mat->mBaseColorTexture; - tex_emissive = mat->mEmissiveTexture; - base_color_factor = LLColor3(mat->mBaseColor); - // *HACK: Treat alpha as black - base_color_factor *= (mat->mBaseColor.mV[VW]); - emissive_factor = mat->mEmissiveColor; - has_base_color_factor = (base_color_factor.mV[VX] != 1.f || - base_color_factor.mV[VY] != 1.f || - base_color_factor.mV[VZ] != 1.f); - has_emissive_factor = (emissive_factor.mV[VX] != 1.f || - emissive_factor.mV[VY] != 1.f || - emissive_factor.mV[VZ] != 1.f); - has_alpha = mat->mAlphaMode != LLGLTFMaterial::ALPHA_MODE_OPAQUE; - } - - if (!tex) { tex = LLViewerFetchedTexture::sWhiteImagep; } - - bool delete_raw_post = false; - bool delete_raw_post_emissive = false; - if (!prepare_raw_image(mRawImagesBaseColor[i], false, tex, delete_raw_post)) { return false; } - if (tex_emissive && !prepare_raw_image(mRawImagesEmissive[i], true, tex_emissive, delete_raw_post_emissive)) { return false; } - // tex_emissive can be null, and then will be ignored - - // In the simplest case, the minimap image is just the base color. - // This will be replaced if we need to do any tinting/compositing. - mRawImages[i] = mRawImagesBaseColor[i]; - - // *TODO: This isn't quite right for PBR: - // 1) It does not convert the color images from SRGB to linear - // before mixing (which will always require copying the image). - // 2) It mixes emissive and base color before mixing terrain - // materials, but it should be the other way around - // Long-term, we should consider a method that is more - // maintainable. Shaders, perhaps? Bake shaders to textures? - LLPointer raw_emissive; - if (tex_emissive) - { - raw_emissive = mRawImagesEmissive[i]; - if (has_emissive_factor || - tex_emissive->getWidth(tex_emissive->getRawImageLevel()) != BASE_SIZE || - tex_emissive->getHeight(tex_emissive->getRawImageLevel()) != BASE_SIZE || - tex_emissive->getComponents() != 4) - { - LLPointer newraw_emissive = new LLImageRaw(BASE_SIZE, BASE_SIZE, 4); - // Copy RGB, leave alpha alone (set to opaque by default) - newraw_emissive->copy(mRawImagesEmissive[i]); - if (has_emissive_factor) - { - newraw_emissive->tint(emissive_factor); - } - raw_emissive = newraw_emissive; - } - } - if (has_base_color_factor || - raw_emissive || - has_alpha || - tex->getWidth(tex->getRawImageLevel()) != BASE_SIZE || - tex->getHeight(tex->getRawImageLevel()) != BASE_SIZE || - tex->getComponents() != 3) - { - LLPointer newraw = new LLImageRaw(BASE_SIZE, BASE_SIZE, 3); - if (has_alpha) - { - // Approximate the water underneath terrain alpha with solid water color - newraw->clear( - MAX_WATER_COLOR.mV[VX], - MAX_WATER_COLOR.mV[VY], - MAX_WATER_COLOR.mV[VZ], - 255); - } - newraw->composite(mRawImagesBaseColor[i]); - if (has_base_color_factor) - { - newraw->tint(base_color_factor); - } - // Apply emissive texture - if (raw_emissive) - { - newraw->addEmissive(raw_emissive); - } - - mRawImages[i] = newraw; // deletes old - } - - if (delete_raw_post) - { - tex->destroyRawImage(); - } - if (delete_raw_post_emissive) - { - tex_emissive->destroyRawImage(); - } - - // Remove intermediary image references - mRawImagesBaseColor[i] = nullptr; - mRawImagesEmissive[i] = nullptr; - } - st_data[i] = mRawImages[i]->getData(); - st_data_size[i] = mRawImages[i]->getDataSize(); - } - - /////////////////////////////////////// - // - // Generate and clamp x/y bounding box. - // - // - - S32 x_begin, y_begin, x_end, y_end; - x_begin = (S32)(x * mScaleInv); - y_begin = (S32)(y * mScaleInv); - x_end = ll_round( (x + width) * mScaleInv ); - y_end = ll_round( (y + width) * mScaleInv ); - - if (x_end > mWidth) - { - llassert(false); - x_end = mWidth; - } - if (y_end > mWidth) - { - llassert(false); - y_end = mWidth; - } - - - /////////////////////////////////////////// - // - // Generate target texture information, stride ratios. - // - // - - LLViewerTexture *texturep; - U32 tex_width, tex_height, tex_comps; - U32 tex_stride; - F32 tex_x_scalef, tex_y_scalef; - S32 tex_x_begin, tex_y_begin, tex_x_end, tex_y_end; - F32 tex_x_ratiof, tex_y_ratiof; - - texturep = mSurfacep->getSTexture(); - tex_width = texturep->getWidth(); - tex_height = texturep->getHeight(); - tex_comps = texturep->getComponents(); - tex_stride = tex_width * tex_comps; - - U32 st_comps = 3; - U32 st_width = BASE_SIZE; - U32 st_height = BASE_SIZE; - - if (tex_comps != st_comps) - { - llassert(false); - return false; - } - - tex_x_scalef = (F32)tex_width / (F32)mWidth; - tex_y_scalef = (F32)tex_height / (F32)mWidth; - tex_x_begin = (S32)((F32)x_begin * tex_x_scalef); - tex_y_begin = (S32)((F32)y_begin * tex_y_scalef); - tex_x_end = (S32)((F32)x_end * tex_x_scalef); - tex_y_end = (S32)((F32)y_end * tex_y_scalef); - - tex_x_ratiof = (F32)mWidth*mScale / (F32)tex_width; - tex_y_ratiof = (F32)mWidth*mScale / (F32)tex_height; - - LLPointer raw = new LLImageRaw(tex_width, tex_height, tex_comps); - U8 *rawp = raw->getData(); - - F32 st_x_stride, st_y_stride; - st_x_stride = ((F32)st_width / (F32)mTexScaleX)*((F32)mWidth / (F32)tex_width); - st_y_stride = ((F32)st_height / (F32)mTexScaleY)*((F32)mWidth / (F32)tex_height); - - llassert(st_x_stride > 0.f); - llassert(st_y_stride > 0.f); - //////////////////////////////// - // - // Iterate through the target texture, striding through the - // subtextures and interpolating appropriately. - // - // - - F32 sti, stj; - S32 st_offset; - sti = (tex_x_begin * st_x_stride) - st_width*(llfloor((tex_x_begin * st_x_stride)/st_width)); - stj = (tex_y_begin * st_y_stride) - st_height*(llfloor((tex_y_begin * st_y_stride)/st_height)); - - st_offset = (llfloor(stj * st_width) + llfloor(sti)) * st_comps; - for (S32 j = tex_y_begin; j < tex_y_end; j++) - { - U32 offset = j * tex_stride + tex_x_begin * tex_comps; - sti = (tex_x_begin * st_x_stride) - st_width*((U32)(tex_x_begin * st_x_stride)/st_width); - for (S32 i = tex_x_begin; i < tex_x_end; i++) - { - S32 tex0, tex1; - F32 composition = getValueScaled(i*tex_x_ratiof, j*tex_y_ratiof); - - tex0 = llfloor( composition ); - tex0 = llclamp(tex0, 0, 3); - composition -= tex0; - tex1 = tex0 + 1; - tex1 = llclamp(tex1, 0, 3); - - st_offset = (lltrunc(sti) + lltrunc(stj)*st_width) * st_comps; - for (U32 k = 0; k < tex_comps; k++) - { - // Linearly interpolate based on composition. - if (st_offset >= st_data_size[tex0] || st_offset >= st_data_size[tex1]) - { - // SJB: This shouldn't be happening, but does... Rounding error? - //LL_WARNS() << "offset 0 [" << tex0 << "] =" << st_offset << " >= size=" << st_data_size[tex0] << LL_ENDL; - //LL_WARNS() << "offset 1 [" << tex1 << "] =" << st_offset << " >= size=" << st_data_size[tex1] << LL_ENDL; - } - else - { - F32 a = *(st_data[tex0] + st_offset); - F32 b = *(st_data[tex1] + st_offset); - rawp[ offset ] = (U8)lltrunc( a + composition * (b - a) ); - } - offset++; - st_offset++; - } - - sti += st_x_stride; - if (sti >= st_width) - { - sti -= st_width; - } - } - - stj += st_y_stride; - if (stj >= st_height) - { - stj -= st_height; - } - } - - if (!texturep->hasGLTexture()) - { - texturep->createGLTexture(0, raw); - } - texturep->setSubImage(raw, tex_x_begin, tex_y_begin, tex_x_end - tex_x_begin, tex_y_end - tex_y_begin); - - // Un-boost detail textures (will get re-boosted if rendering in high detail) - for (S32 i = 0; i < ASSET_COUNT; i++) - { - unboost_minimap_texture(mDetailTextures[i]); - } - - // Un-boost textures for each detail material (will get re-boosted if rendering in high detail) - for (S32 i = 0; i < ASSET_COUNT; i++) - { - unboost_minimap_material(mDetailMaterials[i]); - } - - return true; -} - F32 LLVLComposition::getStartHeight(S32 corner) { return mStartHeight[corner]; diff --git a/indra/newview/llvlcomposition.h b/indra/newview/llvlcomposition.h index 61c35ade28..2637d77183 100644 --- a/indra/newview/llvlcomposition.h +++ b/indra/newview/llvlcomposition.h @@ -114,8 +114,6 @@ public: // Viewer side hack to generate composition values bool generateHeights(const F32 x, const F32 y, const F32 width, const F32 height); bool generateComposition(); - // Generate texture from composition values. - bool generateMinimapTileLand(const F32 x, const F32 y, const F32 width, const F32 height); // Use these as indeces ito the get/setters below that use 'corner' enum ECorner diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index de62256134..7d9a3378f9 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -851,19 +851,9 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) if (mSculptTexture.notNull()) { - mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(), - (S32)LLGLTexture::BOOST_SCULPTED)); mSculptTexture->setForSculpt() ; - if(!mSculptTexture->isCachedRawImageReady()) - { - S32 lod = llmin(mLOD, 3); - F32 lodf = ((F32)(lod + 1.0f)/4.f); - F32 tex_size = lodf * LLViewerTexture::sMaxSculptRez ; - mSculptTexture->addTextureStats(2.f * tex_size * tex_size, false); - } - - S32 texture_discard = mSculptTexture->getCachedRawImageLevel(); //try to match the texture + S32 texture_discard = mSculptTexture->getRawImageLevel(); //try to match the texture S32 current_discard = getVolume() ? getVolume()->getSculptLevel() : -2 ; if (texture_discard >= 0 && //texture has some data available @@ -1159,7 +1149,9 @@ void LLVOVolume::updateSculptTexture() LLUUID id = sculpt_params->getSculptTexture(); if (id.notNull()) { - mSculptTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, true, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + mSculptTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, true, LLGLTexture::BOOST_SCULPTED, LLViewerTexture::LOD_TEXTURE); + mSculptTexture->forceToSaveRawImage(0, F32_MAX); + mSculptTexture->addTextureStats(256.f*256.f); } mSkinInfoUnavaliable = false; @@ -1252,8 +1244,22 @@ void LLVOVolume::sculpt() S8 sculpt_components = 0; const U8* sculpt_data = NULL; - S32 discard_level = mSculptTexture->getCachedRawImageLevel() ; - LLImageRaw* raw_image = mSculptTexture->getCachedRawImage() ; + S32 discard_level = mSculptTexture->getRawImageLevel() ; + LLImageRaw* raw_image = mSculptTexture->getRawImage() ; + + if (!raw_image) + { + raw_image = mSculptTexture->getSavedRawImage(); + S32 discard_level = mSculptTexture->getSavedRawImageLevel(); + } + + if (!raw_image) + { + // last resort, read back from GL + mSculptTexture->readbackRawImage(); + raw_image = mSculptTexture->getRawImage(); + discard_level = mSculptTexture->getRawImageLevel(); + } S32 max_discard = mSculptTexture->getMaxDiscardLevel(); if (discard_level > max_discard) @@ -1310,8 +1316,6 @@ void LLVOVolume::sculpt() if(!raw_image) { - llassert(discard_level < 0) ; - sculpt_width = 0; sculpt_height = 0; sculpt_data = NULL ; diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp index 34040e1aca..2bc849a74f 100644 --- a/indra/newview/llvowater.cpp +++ b/indra/newview/llvowater.cpp @@ -59,7 +59,6 @@ LLVOWater::LLVOWater(const LLUUID &id, mbCanSelect = false; setScale(LLVector3(256.f, 256.f, 0.f)); // Hack for setting scale for bounding boxes/visibility. - mUseTexture = true; mIsEdgePatch = false; } @@ -101,14 +100,7 @@ LLDrawable *LLVOWater::createDrawable(LLPipeline *pipeline) LLDrawPoolWater *pool = (LLDrawPoolWater*) gPipeline.getPool(LLDrawPool::POOL_WATER); - if (mUseTexture) - { - mDrawable->setNumFaces(1, pool, mRegionp->getLand().getWaterTexture()); - } - else - { - mDrawable->setNumFaces(1, pool, LLWorld::getInstance()->getDefaultWaterTexture()); - } + mDrawable->setNumFaces(1, pool, LLWorld::getInstance()->getDefaultWaterTexture()); return mDrawable; } @@ -249,11 +241,6 @@ void setVecZ(LLVector3& v) v.mV[VZ] = 1; } -void LLVOWater::setUseTexture(const bool use_texture) -{ - mUseTexture = use_texture; -} - void LLVOWater::setIsEdgePatch(const bool edge_patch) { mIsEdgePatch = edge_patch; diff --git a/indra/newview/llvowater.h b/indra/newview/llvowater.h index adae86691a..ba3da510c4 100644 --- a/indra/newview/llvowater.h +++ b/indra/newview/llvowater.h @@ -70,13 +70,10 @@ public: /*virtual*/ bool isActive() const; // Whether this object needs to do an idleUpdate. - void setUseTexture(const bool use_texture); void setIsEdgePatch(const bool edge_patch); - bool getUseTexture() const { return mUseTexture; } bool getIsEdgePatch() const { return mIsEdgePatch; } protected: - bool mUseTexture; bool mIsEdgePatch; S32 mRenderType; }; diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 2eadea20ef..6470c81aaa 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -961,7 +961,6 @@ void LLWorld::updateWaterObjects() if (!getRegionFromHandle(region_handle)) { // No region at that area, so make water LLVOWater* waterp = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_WATER, gAgent.getRegion()); - waterp->setUseTexture(false); waterp->setPositionGlobal(LLVector3d(x + rwidth/2, y + rwidth/2, 256.f + water_height)); @@ -1015,7 +1014,6 @@ void LLWorld::updateWaterObjects() mEdgeWaterObjects[dir] = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_VOID_WATER, gAgent.getRegion()); waterp = mEdgeWaterObjects[dir]; - waterp->setUseTexture(false); waterp->setIsEdgePatch(true); gPipeline.createObject(waterp); } diff --git a/indra/newview/llworldmipmap.cpp b/indra/newview/llworldmipmap.cpp index e226fd4748..d8ea2b884f 100644 --- a/indra/newview/llworldmipmap.cpp +++ b/indra/newview/llworldmipmap.cpp @@ -178,6 +178,7 @@ LLPointer LLWorldMipmap::getObjectsTile(U32 grid_x, U32 } } +//static LLPointer LLWorldMipmap::loadObjectsTile(U32 grid_x, U32 grid_y, S32 level) { // Get the grid coordinates diff --git a/indra/newview/llworldmipmap.h b/indra/newview/llworldmipmap.h index ab98b55b72..907f24d1e7 100644 --- a/indra/newview/llworldmipmap.h +++ b/indra/newview/llworldmipmap.h @@ -74,11 +74,13 @@ public: // Convert world coordinates to mipmap grid coordinates at a given level static void globalToMipmap(F64 global_x, F64 global_y, S32 level, U32* grid_x, U32* grid_y); + // Load the relevant tile from S3 + static LLPointer loadObjectsTile(U32 grid_x, U32 grid_y, S32 level); + private: // Get a handle (key) from grid coordinates U64 convertGridToHandle(U32 grid_x, U32 grid_y) { return to_region_handle(grid_x * REGION_WIDTH_UNITS, grid_y * REGION_WIDTH_UNITS); } - // Load the relevant tile from S3 - LLPointer loadObjectsTile(U32 grid_x, U32 grid_y, S32 level); + // Clear a level from its "missing" tiles void cleanMissedTilesFromLevel(S32 level); -- cgit v1.2.3 From 59cc1802814eff0742c8051b2d9200a1d4a2dc62 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Mon, 1 Jul 2024 11:56:41 +0200 Subject: Remove include of format library that isn't used and can't be used without C++20 support anyway --- indra/newview/llvoicewebrtc.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index ede1542bd1..8049bb7a73 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -24,7 +24,6 @@ * $/LicenseInfo$ */ #include -#include #include "llvoicewebrtc.h" #include "llsdutil.h" -- cgit v1.2.3 From fcc7d161083547e53b2210e20e850794b8faf4c8 Mon Sep 17 00:00:00 2001 From: Beq Date: Mon, 1 Jul 2024 17:13:15 +0100 Subject: Fix for various TP where a mirror is present these manifest as crashes in isDynamic, isBox and similar calls that are accessed through a dangling probe. --- indra/newview/llheroprobemanager.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index 66ccdd2b32..cbe1105024 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -121,6 +121,7 @@ void LLHeroProbeManager::update() // Find our nearest hero candidate. float last_distance = 99999.f; float camera_center_distance = 99999.f; + mNearestHero = nullptr; for (auto vo : mHeroVOList) { if (vo && !vo->isDead() && vo->mDrawable.notNull() && vo->isReflectionProbe() && vo->getReflectionProbeIsBox()) @@ -194,11 +195,17 @@ void LLHeroProbeManager::update() else { mNearestHero = nullptr; + mDefaultProbe->mViewerObject = nullptr; } mHeroProbeStrength = 1; } + else + { + mNearestHero = nullptr; + mDefaultProbe->mViewerObject = nullptr; } +} void LLHeroProbeManager::renderProbes() { -- cgit v1.2.3 From c7bd4528a7bc295a17a12951389fcc499483f6c5 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 25 Jun 2024 19:18:23 +0300 Subject: viewer#1131 gltf model upload UI WIP --- indra/newview/CMakeLists.txt | 4 + indra/newview/gltfscenemanager.cpp | 2 + indra/newview/llfloateravatar.cpp | 5 - indra/newview/llfloaterdestinations.cpp | 5 - indra/newview/llfloaterfonttest.cpp | 5 - indra/newview/llfloatergltfasseteditor.cpp | 111 ++++++++++++++++ indra/newview/llfloatergltfasseteditor.h | 114 ++++++++++++++++ indra/newview/llgltffolderviews.cpp | 143 +++++++++++++++++++++ indra/newview/llgltffolderviews.h | 110 ++++++++++++++++ indra/newview/llviewerfloaterreg.cpp | 2 + indra/newview/llviewermenu.cpp | 10 ++ .../default/xui/en/floater_gltf_asset_editor.xml | 21 +++ indra/newview/skins/default/xui/en/menu_viewer.xml | 8 ++ 13 files changed, 525 insertions(+), 15 deletions(-) create mode 100644 indra/newview/llfloatergltfasseteditor.cpp create mode 100644 indra/newview/llfloatergltfasseteditor.h create mode 100644 indra/newview/llgltffolderviews.cpp create mode 100644 indra/newview/llgltffolderviews.h create mode 100644 indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 3aaeb426da..67bcab86ff 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -219,6 +219,7 @@ set(viewer_SOURCE_FILES llfloaterfonttest.cpp llfloaterforgetuser.cpp llfloatergesture.cpp + llfloatergltfasseteditor.cpp llfloatergodtools.cpp llfloatergotoline.cpp llfloatergridstatus.cpp @@ -313,6 +314,7 @@ set(viewer_SOURCE_FILES llgesturemgr.cpp llgiveinventory.cpp llglsandbox.cpp + llgltffolderviews.cpp llgltfmateriallist.cpp llgltfmaterialpreviewmgr.cpp llgroupactions.cpp @@ -879,6 +881,7 @@ set(viewer_HEADER_FILES llfloaterfonttest.h llfloaterforgetuser.h llfloatergesture.h + llfloatergltfasseteditor.h llfloatergodtools.h llfloatergotoline.h llfloatergridstatus.h @@ -975,6 +978,7 @@ set(viewer_HEADER_FILES llgesturelistener.h llgesturemgr.h llgiveinventory.h + llgltffolderviews.h llgltfmateriallist.h llgltfmaterialpreviewmgr.h llgroupactions.h diff --git a/indra/newview/gltfscenemanager.cpp b/indra/newview/gltfscenemanager.cpp index a0cbe9290c..b161ec8492 100644 --- a/indra/newview/gltfscenemanager.cpp +++ b/indra/newview/gltfscenemanager.cpp @@ -42,6 +42,7 @@ #include "llviewertexturelist.h" #include "llimagej2c.h" #include "llfloaterperms.h" +#include "llfloaterreg.h" #include "llagentbenefits.h" #include "llfilesystem.h" #include "boost/json.hpp" @@ -314,6 +315,7 @@ void GLTFSceneManager::load(const std::string& filename) { mObjects.push_back(obj); } + LLFloaterReg::showInstance("gltf_asset_editor"); } } else diff --git a/indra/newview/llfloateravatar.cpp b/indra/newview/llfloateravatar.cpp index 6a38d7549c..404316275d 100644 --- a/indra/newview/llfloateravatar.cpp +++ b/indra/newview/llfloateravatar.cpp @@ -25,11 +25,6 @@ * $/LicenseInfo$ */ -/** - * Floater that appears when buying an object, giving a preview - * of its contents and their permissions. - */ - #include "llviewerprecompiledheaders.h" #include "llfloateravatar.h" diff --git a/indra/newview/llfloaterdestinations.cpp b/indra/newview/llfloaterdestinations.cpp index 93cf02e835..fad9693e8f 100644 --- a/indra/newview/llfloaterdestinations.cpp +++ b/indra/newview/llfloaterdestinations.cpp @@ -25,11 +25,6 @@ * $/LicenseInfo$ */ -/** - * Floater that appears when buying an object, giving a preview - * of its contents and their permissions. - */ - #include "llviewerprecompiledheaders.h" #include "llfloaterdestinations.h" diff --git a/indra/newview/llfloaterfonttest.cpp b/indra/newview/llfloaterfonttest.cpp index 95d08cb9ce..d39b061d40 100644 --- a/indra/newview/llfloaterfonttest.cpp +++ b/indra/newview/llfloaterfonttest.cpp @@ -25,11 +25,6 @@ * $/LicenseInfo$ */ -/** - * Floater that appears when buying an object, giving a preview - * of its contents and their permissions. - */ - #include "llviewerprecompiledheaders.h" #include "llfloaterfonttest.h" diff --git a/indra/newview/llfloatergltfasseteditor.cpp b/indra/newview/llfloatergltfasseteditor.cpp new file mode 100644 index 0000000000..a2b5f573bb --- /dev/null +++ b/indra/newview/llfloatergltfasseteditor.cpp @@ -0,0 +1,111 @@ +/** + * @file llfloatergltfasseteditor.cpp + * @author Brad Payne + * @brief LLFloaterFontTest class implementation + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloatergltfasseteditor.h" + +#include "llfolderviewitem.h" +#include "llgltffolderviews.h" + +bool LLGLTFSort::operator()(const LLGLTFItem* const& a, const LLGLTFItem* const& b) const +{ + // Comparison operator: returns "true" is a comes before b, "false" otherwise + S32 compare = LLStringUtil::compareDict(a->getName(), b->getName()); + return (compare < 0); +} + +/// LLGLTFViewModel + +LLGLTFViewModel::LLGLTFViewModel() + : base_t(new LLGLTFSort(), new LLGLTFFilter()) +{} + +void LLGLTFViewModel::sort(LLFolderViewFolder* folder) +{ + base_t::sort(folder); +} + + /// LLGLTFNode +// LLUICtrlFactory::create(params); +class LLGLTFNode : public LLFolderViewItem +{ +public: + struct Params : public LLInitParam::Block + { + Params(); + }; + ~LLGLTFNode(); +protected: + LLGLTFNode(const Params& p); +}; + +LLGLTFNode::LLGLTFNode(const LLGLTFNode::Params& p) + : LLFolderViewItem(p) +{ +} + +LLGLTFNode::~LLGLTFNode() +{ +} + +LLFloaterGltfAssetEditor::LLFloaterGltfAssetEditor(const LLSD& key) + : LLFloater(key) +{ + setTitle("GLTF Asset Editor (WIP)"); +} + +/// LLFloaterGltfAssetEditor + +LLFloaterGltfAssetEditor::~LLFloaterGltfAssetEditor() +{ +} + +bool LLFloaterGltfAssetEditor::postBuild() +{ + mItemListPanel = getChild("item_list_panel"); + + // Create the root model and view for all conversation sessions + LLGLTFItem* base_item = new LLGLTFItem(mGLTFViewModel); + + LLFolderView::Params p(LLUICtrlFactory::getDefaultParams()); + p.name = getName(); + p.title = getLabel(); + p.rect = LLRect(0, 0, getRect().getWidth(), 0); + p.parent_panel = mItemListPanel; + p.tool_tip = p.name; + p.listener = base_item; + p.view_model = &mGLTFViewModel; + p.root = NULL; + p.use_ellipses = true; + p.options_menu = "menu_gltf.xml"; // *TODO : create this or fix to be optional + mConversationsRoot = LLUICtrlFactory::create(p); + mConversationsRoot->setCallbackRegistrar(&mCommitCallbackRegistrar); + mConversationsRoot->setEnableRegistrar(&mEnableCallbackRegistrar); + + return true; +} diff --git a/indra/newview/llfloatergltfasseteditor.h b/indra/newview/llfloatergltfasseteditor.h new file mode 100644 index 0000000000..30000506ae --- /dev/null +++ b/indra/newview/llfloatergltfasseteditor.h @@ -0,0 +1,114 @@ +/** + * @file llfloatergltfasseteditor.h + * @author Brad Payne + * @brief floater to exercise standard fonts + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATERGLTFASSETEDITOR_H +#define LL_LLFLOATERGLTFASSETEDITOR_H + +#include "llfloater.h" + +#include "llfolderviewmodel.h" +#include "llgltffolderviews.h" + +class LLGLTFViewModel; +class LLFolderViewFolder; +class LLFolderViewModelItem; + +class LLGLTFSort +{ +public: + LLGLTFSort() { } + bool operator()(const LLGLTFItem* const& a, const LLGLTFItem* const& b) const; +private: +}; + +class LLGLTFFilter : public LLFolderViewFilter +{ +public: + LLGLTFFilter() { mEmpty = ""; } + ~LLGLTFFilter() {} + + bool check(const LLFolderViewModelItem* item) { return true; } + bool checkFolder(const LLFolderViewModelItem* folder) const { return true; } + void setEmptyLookupMessage(const std::string& message) { } + std::string getEmptyLookupMessage(bool is_empty_folder = false) const { return mEmpty; } + bool showAllResults() const { return true; } + std::string::size_type getStringMatchOffset(LLFolderViewModelItem* item) const { return std::string::npos; } + std::string::size_type getFilterStringSize() const { return 0; } + + bool isActive() const { return false; } + bool isModified() const { return false; } + void clearModified() { } + const std::string& getName() const { return mEmpty; } + const std::string& getFilterText() { return mEmpty; } + void setModified(EFilterModified behavior = FILTER_RESTART) { } + + void resetTime(S32 timeout) { } + bool isTimedOut() { return false; } + + bool isDefault() const { return true; } + bool isNotDefault() const { return false; } + void markDefault() { } + void resetDefault() { } + + S32 getCurrentGeneration() const { return 0; } + S32 getFirstSuccessGeneration() const { return 0; } + S32 getFirstRequiredGeneration() const { return 0; } +private: + std::string mEmpty; +}; + +class LLGLTFViewModel + : public LLFolderViewModel +{ +public: + typedef LLFolderViewModel< LLGLTFSort, LLGLTFItem, LLGLTFItem, LLGLTFFilter> base_t; + LLGLTFViewModel(); + + void sort(LLFolderViewFolder* folder); + bool startDrag(std::vector& items) { return false; } + +private: +}; + +class LLFloaterGltfAssetEditor : public LLFloater +{ +public: + LLFloaterGltfAssetEditor(const LLSD& key); + ~LLFloaterGltfAssetEditor(); + + bool postBuild() override; + + LLGLTFViewModel& getRootViewModel() { return mGLTFViewModel; } + +private: + LLGLTFViewModel mGLTFViewModel; + + LLPanel* mItemListPanel = nullptr; + LLFolderView* mConversationsRoot = nullptr; +}; + +#endif LL_LLFLOATERGLTFASSETEDITOR_H diff --git a/indra/newview/llgltffolderviews.cpp b/indra/newview/llgltffolderviews.cpp new file mode 100644 index 0000000000..911b6262ca --- /dev/null +++ b/indra/newview/llgltffolderviews.cpp @@ -0,0 +1,143 @@ +/** + * @file llgltffolderviews.cpp + * @author Andrey Kleshchev + * @brief LLFloaterFontTest class implementation + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llgltffolderviews.h" +#include "llinventoryicon.h" + +/// LLGLTFItem + +LLGLTFItem::LLGLTFItem(std::string display_name, LLFolderViewModelInterface& root_view_model) + : LLFolderViewModelItemCommon(root_view_model) + , mName(display_name) +{ + init(); +} + +LLGLTFItem::LLGLTFItem(LLFolderViewModelInterface& root_view_model) + : LLFolderViewModelItemCommon(root_view_model) +{ + init(); +} + +LLGLTFItem::~LLGLTFItem() +{ + +} + +void LLGLTFItem::init() +{ + pIcon = LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_OBJECT); +} + + +bool LLGLTFItem::filterChildItem(LLFolderViewModelItem* item, LLFolderViewFilter& filter) +{ + S32 filter_generation = filter.getCurrentGeneration(); + + bool continue_filtering = true; + if (item) + { + if (item->getLastFilterGeneration() < filter_generation) + { + // Recursive application of the filter for child items (CHUI-849) + continue_filtering = item->filter(filter); + } + + // Update latest generation to pass filter in parent and propagate up to root + if (item->passedFilter()) + { + LLGLTFItem* view_model = this; + + while (view_model && view_model->mMostFilteredDescendantGeneration < filter_generation) + { + view_model->mMostFilteredDescendantGeneration = filter_generation; + view_model = static_cast(view_model->mParent); + } + } + } + return continue_filtering; +} + +bool LLGLTFItem::filter(LLFolderViewFilter& filter) +{ + + const S32 filter_generation = filter.getCurrentGeneration(); + const S32 must_pass_generation = filter.getFirstRequiredGeneration(); + + if (getLastFilterGeneration() >= must_pass_generation + && getLastFolderFilterGeneration() >= must_pass_generation + && !passedFilter(must_pass_generation)) + { + // failed to pass an earlier filter that was a subset of the current one + // go ahead and flag this item as not pass + setPassedFilter(false, filter_generation); + setPassedFolderFilter(false, filter_generation); + return true; + } + + bool is_folder = true; + const bool passed_filter_folder = is_folder ? filter.checkFolder(this) : true; + setPassedFolderFilter(passed_filter_folder, filter_generation); + + bool continue_filtering = true; + + if (!mChildren.empty() + && (getLastFilterGeneration() < must_pass_generation // haven't checked descendants against minimum required generation to pass + || descendantsPassedFilter(must_pass_generation))) // or at least one descendant has passed the minimum requirement + { + // now query children + for (child_list_t::iterator iter = mChildren.begin(), end_iter = mChildren.end(); iter != end_iter; ++iter) + { + continue_filtering = filterChildItem((*iter), filter); + if (!continue_filtering) + { + break; + } + } + } + + // If we didn't use all the filter time that means we filtered all of our descendants so we can filter ourselves now + if (continue_filtering) + { + // This is where filter check on the item done (CHUI-849) + const bool passed_filter = filter.check(this); + if (passed_filter && mChildren.empty() && is_folder) // Update the latest filter generation for empty folders + { + LLGLTFItem* view_model = this; + while (view_model && view_model->mMostFilteredDescendantGeneration < filter_generation) + { + view_model->mMostFilteredDescendantGeneration = filter_generation; + view_model = static_cast(view_model->mParent); + } + } + setPassedFilter(passed_filter, filter_generation, filter.getStringMatchOffset(this), filter.getFilterStringSize()); + continue_filtering = !filter.isTimedOut(); + } + return continue_filtering; +} diff --git a/indra/newview/llgltffolderviews.h b/indra/newview/llgltffolderviews.h new file mode 100644 index 0000000000..294074fd9f --- /dev/null +++ b/indra/newview/llgltffolderviews.h @@ -0,0 +1,110 @@ +/** + * @file llgltffolderviews.h + * @author Andrey Kleshchev + * @brief floater to exercise standard fonts + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATERGLTFFOLDERVIEWS_H +#define LL_LLFLOATERGLTFFOLDERVIEWS_H + +#include "llfloater.h" + +#include "llfolderviewmodel.h" + +class LLGLTFItem : public LLFolderViewModelItemCommon +{ +public: + LLGLTFItem(std::string display_name, LLFolderViewModelInterface& root_view_model); + LLGLTFItem(LLFolderViewModelInterface& root_view_model); + virtual ~LLGLTFItem(); + + void init(); + + const std::string& getName() const override { return mName; } + const std::string& getDisplayName() const override { return mName; } + const std::string& getSearchableName() const override { return mName; } + + std::string getSearchableDescription() const override { return std::string(); } + std::string getSearchableCreatorName()const override { return std::string(); } + std::string getSearchableUUIDString() const override { return std::string(); } + + LLPointer getIcon() const override { return pIcon; } + LLPointer getIconOpen() const { return getIcon(); } + LLPointer getIconOverlay() const { return NULL; } + + LLFontGL::StyleFlags getLabelStyle() const override { return LLFontGL::NORMAL; } + std::string getLabelSuffix() const override { return std::string(); } + + void openItem(void) override {} + void closeItem(void) override {} + void selectItem(void) override {} + + void navigateToFolder(bool new_window = false, bool change_mode = false) override {} + + bool isItemWearable() const { return false; } + + bool isItemRenameable() const override { return false; } + bool renameItem(const std::string& new_name) override { return false; } + + bool isItemMovable(void) const override { return false; } // Can be moved to another folder + void move(LLFolderViewModelItem* parent_listener) override {} + + bool isItemRemovable(bool check_worn = true) const override { return false; } + bool removeItem() override { return false; } + void removeBatch(std::vector& batch) override {} + + bool isItemCopyable(bool can_copy_as_link = true) const override { return false; } + bool copyToClipboard() const override { return false; } + bool cutToClipboard() override { return false; } + bool isCutToClipboard() { return false; } + + bool isClipboardPasteable() const override { return false; } + void pasteFromClipboard() override {} + void pasteLinkFromClipboard() override {} + + void buildContextMenu(LLMenuGL& menu, U32 flags) override {}; + + bool potentiallyVisible() override { return true; }; // is the item definitely visible or we haven't made up our minds yet? + + bool hasChildren() const override { return mChildren.size() > 0; } + + bool dragOrDrop( + MASK mask, + bool drop, + EDragAndDropType cargo_type, + void* cargo_data, + std::string& tooltip_msg) override + { + return false; + } + + bool filterChildItem(LLFolderViewModelItem* item, LLFolderViewFilter& filter); + bool filter(LLFolderViewFilter& filter) override; + +private: + LLUIImagePtr pIcon; + std::string mName; +}; + +#endif LL_LLFLOATERGLTFFOLDERVIEWS_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index ceda2675d5..36fd1015f6 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -76,6 +76,7 @@ #include "llfloaterfonttest.h" #include "llfloaterforgetuser.h" #include "llfloatergesture.h" +#include "llfloatergltfasseteditor.h" #include "llfloatergodtools.h" #include "llfloatergridstatus.h" #include "llfloatergroups.h" @@ -372,6 +373,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("forget_username", "floater_forget_user.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("gestures", "floater_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("gltf_asset_editor", "floater_gltf_asset_editor.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("god_tools", "floater_god_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("grid_status", "floater_grid_status.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("group_picker", "floater_choose_group.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 9a9a316adf..2687938b35 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -8139,6 +8139,15 @@ class LLAdvancedClickGLTFUpload: public view_listener_t } }; +class LLAdvancedClickGLTFEdit : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + LLFloaterReg::showInstance("gltf_asset_editor"); + return true; + } +}; + class LLAdvancedClickResizeWindow : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -9794,6 +9803,7 @@ void initialize_menus() view_listener_t::addMenu(new LLAdvancedClickGLTFOpen(), "Advanced.ClickGLTFOpen"); view_listener_t::addMenu(new LLAdvancedClickGLTFSaveAs(), "Advanced.ClickGLTFSaveAs"); view_listener_t::addMenu(new LLAdvancedClickGLTFUpload(), "Advanced.ClickGLTFUpload"); + view_listener_t::addMenu(new LLAdvancedClickGLTFEdit(), "Advanced.ClickGLTFEdit"); view_listener_t::addMenu(new LLAdvancedClickResizeWindow(), "Advanced.ClickResizeWindow"); view_listener_t::addMenu(new LLAdvancedPurgeShaderCache(), "Advanced.ClearShaderCache"); view_listener_t::addMenu(new LLAdvancedRebuildTerrain(), "Advanced.RebuildTerrain"); diff --git a/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml b/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml new file mode 100644 index 0000000000..9082486d84 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml @@ -0,0 +1,21 @@ + + + + diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index d5d2d00630..347638249b 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -2851,6 +2851,14 @@ function="World.EnvPreset" + + + + Date: Thu, 27 Jun 2024 18:03:30 +0300 Subject: viewer#1131 gltf model upload UI WIP #2 --- indra/newview/CMakeLists.txt | 6 +- indra/newview/llfloatergltfasseteditor.cpp | 251 ++++++++++++++++----- indra/newview/llfloatergltfasseteditor.h | 89 ++------ indra/newview/llgltffolderitem.cpp | 164 ++++++++++++++ indra/newview/llgltffolderitem.h | 128 +++++++++++ indra/newview/llgltffoldermodel.cpp | 73 ++++++ indra/newview/llgltffoldermodel.h | 91 ++++++++ indra/newview/llgltffolderviews.cpp | 143 ------------ indra/newview/llgltffolderviews.h | 110 --------- indra/newview/llviewerfloaterreg.cpp | 2 +- .../default/xui/en/floater_gltf_asset_editor.xml | 15 +- 11 files changed, 690 insertions(+), 382 deletions(-) create mode 100644 indra/newview/llgltffolderitem.cpp create mode 100644 indra/newview/llgltffolderitem.h create mode 100644 indra/newview/llgltffoldermodel.cpp create mode 100644 indra/newview/llgltffoldermodel.h delete mode 100644 indra/newview/llgltffolderviews.cpp delete mode 100644 indra/newview/llgltffolderviews.h (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 67bcab86ff..cbcc85cc1c 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -314,7 +314,8 @@ set(viewer_SOURCE_FILES llgesturemgr.cpp llgiveinventory.cpp llglsandbox.cpp - llgltffolderviews.cpp + llgltffolderitem.cpp + llgltffoldermodel.cpp llgltfmateriallist.cpp llgltfmaterialpreviewmgr.cpp llgroupactions.cpp @@ -978,7 +979,8 @@ set(viewer_HEADER_FILES llgesturelistener.h llgesturemgr.h llgiveinventory.h - llgltffolderviews.h + llgltffolderitem.h + llgltffoldermodel.h llgltfmateriallist.h llgltfmaterialpreviewmgr.h llgroupactions.h diff --git a/indra/newview/llfloatergltfasseteditor.cpp b/indra/newview/llfloatergltfasseteditor.cpp index a2b5f573bb..62546c6ed9 100644 --- a/indra/newview/llfloatergltfasseteditor.cpp +++ b/indra/newview/llfloatergltfasseteditor.cpp @@ -1,7 +1,7 @@ /** * @file llfloatergltfasseteditor.cpp - * @author Brad Payne - * @brief LLFloaterFontTest class implementation + * @author Andrii Kleshchev + * @brief LLFloaterGltfAssetEditor class implementation * * $LicenseInfo:firstyear=2008&license=viewerlgpl$ * Second Life Viewer Source Code @@ -29,72 +29,48 @@ #include "llfloatergltfasseteditor.h" -#include "llfolderviewitem.h" -#include "llgltffolderviews.h" +#include "gltf/asset.h" +#include "llcallbacklist.h" +#include "llselectmgr.h" +#include "llviewerobject.h" -bool LLGLTFSort::operator()(const LLGLTFItem* const& a, const LLGLTFItem* const& b) const -{ - // Comparison operator: returns "true" is a comes before b, "false" otherwise - S32 compare = LLStringUtil::compareDict(a->getName(), b->getName()); - return (compare < 0); -} - -/// LLGLTFViewModel - -LLGLTFViewModel::LLGLTFViewModel() - : base_t(new LLGLTFSort(), new LLGLTFFilter()) -{} - -void LLGLTFViewModel::sort(LLFolderViewFolder* folder) -{ - base_t::sort(folder); -} +const LLColor4U DEFAULT_WHITE(255, 255, 255); - /// LLGLTFNode -// LLUICtrlFactory::create(params); -class LLGLTFNode : public LLFolderViewItem -{ -public: - struct Params : public LLInitParam::Block - { - Params(); - }; - ~LLGLTFNode(); -protected: - LLGLTFNode(const Params& p); -}; - -LLGLTFNode::LLGLTFNode(const LLGLTFNode::Params& p) - : LLFolderViewItem(p) -{ -} - -LLGLTFNode::~LLGLTFNode() -{ -} +/// LLFloaterGLTFAssetEditor -LLFloaterGltfAssetEditor::LLFloaterGltfAssetEditor(const LLSD& key) +LLFloaterGLTFAssetEditor::LLFloaterGLTFAssetEditor(const LLSD& key) : LLFloater(key) + , mUIColor(LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE)) { setTitle("GLTF Asset Editor (WIP)"); } -/// LLFloaterGltfAssetEditor - -LLFloaterGltfAssetEditor::~LLFloaterGltfAssetEditor() +LLFloaterGLTFAssetEditor::~LLFloaterGLTFAssetEditor() { + gIdleCallbacks.deleteFunction(idle, this); } -bool LLFloaterGltfAssetEditor::postBuild() +bool LLFloaterGLTFAssetEditor::postBuild() { mItemListPanel = getChild("item_list_panel"); + LLRect scroller_view_rect = mItemListPanel->getRect(); + scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom); + LLScrollContainer::Params scroller_params(LLUICtrlFactory::getDefaultParams()); + scroller_params.rect(scroller_view_rect); + scroller_params.name("folder_scroller"); + mScroller = LLUICtrlFactory::create(scroller_params); + mScroller->setFollowsAll(); + + // Insert that scroller into the panel widgets hierarchy + mItemListPanel->addChild(mScroller); + // Create the root model and view for all conversation sessions - LLGLTFItem* base_item = new LLGLTFItem(mGLTFViewModel); + LLGLTFFolderItem* base_item = new LLGLTFFolderItem(mGLTFViewModel); LLFolderView::Params p(LLUICtrlFactory::getDefaultParams()); - p.name = getName(); - p.title = getLabel(); + p.name = "Root"; + p.title = "Root"; p.rect = LLRect(0, 0, getRect().getWidth(), 0); p.parent_panel = mItemListPanel; p.tool_tip = p.name; @@ -103,9 +79,176 @@ bool LLFloaterGltfAssetEditor::postBuild() p.root = NULL; p.use_ellipses = true; p.options_menu = "menu_gltf.xml"; // *TODO : create this or fix to be optional - mConversationsRoot = LLUICtrlFactory::create(p); - mConversationsRoot->setCallbackRegistrar(&mCommitCallbackRegistrar); - mConversationsRoot->setEnableRegistrar(&mEnableCallbackRegistrar); + mFolderRoot = LLUICtrlFactory::create(p); + mFolderRoot->setCallbackRegistrar(&mCommitCallbackRegistrar); + mFolderRoot->setEnableRegistrar(&mEnableCallbackRegistrar); + // Attach root to the scroller + mScroller->addChild(mFolderRoot); + mFolderRoot->setScrollContainer(mScroller); + mFolderRoot->setFollowsAll(); + mFolderRoot->setOpen(true); + mScroller->setVisible(true); + + gIdleCallbacks.addFunction(idle, this); return true; } + +void LLFloaterGLTFAssetEditor::onOpen(const LLSD& key) +{ + loadFromSelection(); +} + +void LLFloaterGLTFAssetEditor::idle(void* user_data) +{ + LLFloaterGLTFAssetEditor* floater = (LLFloaterGLTFAssetEditor*)user_data; + + if (floater->mFolderRoot) + { + floater->mFolderRoot->update(); + } +} + +void LLFloaterGLTFAssetEditor::loadItem(S32 id, const std::string& name, LLGLTFFolderItem::EType type, LLFolderViewFolder* parent) +{ + LLGLTFFolderItem* listener = new LLGLTFFolderItem(id, name, type, mGLTFViewModel); + + LLFolderViewItem::Params params; + params.name(name); + params.creation_date(0); + params.root(mFolderRoot); + params.listener(listener); + params.rect(LLRect()); + params.tool_tip = params.name; + params.font_color = mUIColor; + params.font_highlight_color = mUIColor; + LLFolderViewItem* view = LLUICtrlFactory::create(params); + + view->addToFolder(parent); + view->setVisible(true); +} + +void LLFloaterGLTFAssetEditor::loadFromNode(S32 node_id, LLFolderViewFolder* parent) +{ + if (mAsset->mNodes.size() <= node_id) + { + return; + } + + LL::GLTF::Node& node = mAsset->mNodes[node_id]; + + std::string name = node.mName; + if (node.mName.empty()) + { + name = getString("node_tittle"); + } + else + { + name = node.mName; + } + + LLGLTFFolderItem* listener = new LLGLTFFolderItem(node_id, name, LLGLTFFolderItem::TYPE_NODE, mGLTFViewModel); + + LLFolderViewFolder::Params p; + p.root = mFolderRoot; + p.listener = listener; + p.name = name; + p.tool_tip = name; + p.font_color = mUIColor; + p.font_highlight_color = mUIColor; + LLFolderViewFolder* view = LLUICtrlFactory::create(p); + + view->addToFolder(parent); + view->setVisible(true); + view->setOpen(true); + + for (S32& node_id : node.mChildren) + { + loadFromNode(node_id, view); + } + + if (node.mMesh != LL::GLTF::INVALID_INDEX && mAsset->mMeshes.size() > node.mMesh) + { + std::string name = mAsset->mMeshes[node.mMesh].mName; + if (name.empty()) + { + name = getString("mesh_tittle"); + } + loadItem(node.mMesh, name, LLGLTFFolderItem::TYPE_MESH, view); + } + + if (node.mSkin != LL::GLTF::INVALID_INDEX && mAsset->mSkins.size() > node.mSkin) + { + std::string name = mAsset->mSkins[node.mSkin].mName; + if (name.empty()) + { + name = getString("skin_tittle"); + } + loadItem(node.mSkin, name, LLGLTFFolderItem::TYPE_SKIN, view); + } + + view->setChildrenInited(true); +} + +void LLFloaterGLTFAssetEditor::loadFromSelection() +{ + if (!mFolderRoot || LLSelectMgr::getInstance()->getSelection()->getObjectCount() != 1) + { + return; + } + + LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); + if (!objectp) + { + return; + } + + mAsset = objectp->mGLTFAsset; + if (!mAsset) + { + return; + } + + LLUIColor item_color = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE); + for (S32 i = 0; i < mAsset->mScenes.size(); i++) + { + LL::GLTF::Scene& scene = mAsset->mScenes[i]; + std::string name = scene.mName; + if (scene.mName.empty()) + { + name = getString("scene_tittle"); + } + else + { + name = scene.mName; + } + + LLGLTFFolderItem* listener = new LLGLTFFolderItem(i, name, LLGLTFFolderItem::TYPE_SCENE, mGLTFViewModel); + + + LLFolderViewFolder::Params p; + p.name = name; + p.root = mFolderRoot; + p.listener = listener; + p.tool_tip = name; + p.font_color = mUIColor; + p.font_highlight_color = mUIColor; + LLFolderViewFolder* view = LLUICtrlFactory::create(p); + + view->addToFolder(mFolderRoot); + view->setVisible(true); + view->setOpen(true); + + for (S32& node_id : scene.mNodes) + { + loadFromNode(node_id, view); + } + view->setChildrenInited(true); + } + + mGLTFViewModel.requestSortAll(); + mFolderRoot->setChildrenInited(true); + mFolderRoot->arrangeAll(); + mFolderRoot->update(); +} + diff --git a/indra/newview/llfloatergltfasseteditor.h b/indra/newview/llfloatergltfasseteditor.h index 30000506ae..49c5aa4ae7 100644 --- a/indra/newview/llfloatergltfasseteditor.h +++ b/indra/newview/llfloatergltfasseteditor.h @@ -1,7 +1,7 @@ /** * @file llfloatergltfasseteditor.h - * @author Brad Payne - * @brief floater to exercise standard fonts + * @author Andrii Kleshchev + * @brief LLFloaterGltfAssetEditor header file * * $LicenseInfo:firstyear=2024&license=viewerlgpl$ * Second Life Viewer Source Code @@ -30,85 +30,40 @@ #include "llfloater.h" -#include "llfolderviewmodel.h" -#include "llgltffolderviews.h" +#include "llgltffoldermodel.h" -class LLGLTFViewModel; -class LLFolderViewFolder; -class LLFolderViewModelItem; - -class LLGLTFSort -{ -public: - LLGLTFSort() { } - bool operator()(const LLGLTFItem* const& a, const LLGLTFItem* const& b) const; -private: -}; - -class LLGLTFFilter : public LLFolderViewFilter -{ -public: - LLGLTFFilter() { mEmpty = ""; } - ~LLGLTFFilter() {} - - bool check(const LLFolderViewModelItem* item) { return true; } - bool checkFolder(const LLFolderViewModelItem* folder) const { return true; } - void setEmptyLookupMessage(const std::string& message) { } - std::string getEmptyLookupMessage(bool is_empty_folder = false) const { return mEmpty; } - bool showAllResults() const { return true; } - std::string::size_type getStringMatchOffset(LLFolderViewModelItem* item) const { return std::string::npos; } - std::string::size_type getFilterStringSize() const { return 0; } - - bool isActive() const { return false; } - bool isModified() const { return false; } - void clearModified() { } - const std::string& getName() const { return mEmpty; } - const std::string& getFilterText() { return mEmpty; } - void setModified(EFilterModified behavior = FILTER_RESTART) { } - - void resetTime(S32 timeout) { } - bool isTimedOut() { return false; } - - bool isDefault() const { return true; } - bool isNotDefault() const { return false; } - void markDefault() { } - void resetDefault() { } - - S32 getCurrentGeneration() const { return 0; } - S32 getFirstSuccessGeneration() const { return 0; } - S32 getFirstRequiredGeneration() const { return 0; } -private: - std::string mEmpty; -}; - -class LLGLTFViewModel - : public LLFolderViewModel +namespace LL { -public: - typedef LLFolderViewModel< LLGLTFSort, LLGLTFItem, LLGLTFItem, LLGLTFFilter> base_t; - LLGLTFViewModel(); + namespace GLTF + { + class Asset; + } +} - void sort(LLFolderViewFolder* folder); - bool startDrag(std::vector& items) { return false; } - -private: -}; - -class LLFloaterGltfAssetEditor : public LLFloater +class LLFloaterGLTFAssetEditor : public LLFloater { public: - LLFloaterGltfAssetEditor(const LLSD& key); - ~LLFloaterGltfAssetEditor(); + LLFloaterGLTFAssetEditor(const LLSD& key); + ~LLFloaterGLTFAssetEditor(); bool postBuild() override; + void onOpen(const LLSD& key) override; LLGLTFViewModel& getRootViewModel() { return mGLTFViewModel; } + static void idle(void* user_data); + void loadItem(S32 id, const std::string& name, LLGLTFFolderItem::EType type, LLFolderViewFolder* parent); + void loadFromNode(S32 node, LLFolderViewFolder* parent); + void loadFromSelection(); + private: LLGLTFViewModel mGLTFViewModel; + LLUIColor mUIColor; LLPanel* mItemListPanel = nullptr; - LLFolderView* mConversationsRoot = nullptr; + LLFolderView* mFolderRoot = nullptr; + LLScrollContainer* mScroller = nullptr; + std::shared_ptr mAsset; }; #endif LL_LLFLOATERGLTFASSETEDITOR_H diff --git a/indra/newview/llgltffolderitem.cpp b/indra/newview/llgltffolderitem.cpp new file mode 100644 index 0000000000..c4fcb4f5ce --- /dev/null +++ b/indra/newview/llgltffolderitem.cpp @@ -0,0 +1,164 @@ +/** + * @file llgltffolderitem.cpp + * @author Andrey Kleshchev + * @brief LLGLTFFolderItem class implementation + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llgltffolderitem.h" + +#include "llinventoryicon.h" + +/// LLGLTFItem + +LLGLTFFolderItem::LLGLTFFolderItem(S32 id, const std::string &display_name, EType type, LLFolderViewModelInterface& root_view_model) + : LLFolderViewModelItemCommon(root_view_model) + , mName(display_name) + , mItemType(type) + , mItemId(id) +{ + init(); +} + +LLGLTFFolderItem::LLGLTFFolderItem(LLFolderViewModelInterface& root_view_model) + : LLFolderViewModelItemCommon(root_view_model) +{ + init(); +} + +LLGLTFFolderItem::~LLGLTFFolderItem() +{ + +} + +void LLGLTFFolderItem::init() +{ + // using inventory icons as a placeholder. + // Todo: GLTF needs to have own icons + switch (mItemType) + { + case TYPE_SCENE: + pIcon = LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_OBJECT_MULTI); + break; + case TYPE_NODE: + pIcon = LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_OBJECT); + break; + case TYPE_MESH: + pIcon = LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_MESH); + break; + case TYPE_SKIN: + pIcon = LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_BODYPART_SKIN); + break; + default: + pIcon = LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_OBJECT); + break; + } +} + + +bool LLGLTFFolderItem::filterChildItem(LLFolderViewModelItem* item, LLFolderViewFilter& filter) +{ + S32 filter_generation = filter.getCurrentGeneration(); + + bool continue_filtering = true; + if (item) + { + if (item->getLastFilterGeneration() < filter_generation) + { + // Recursive application of the filter for child items (CHUI-849) + continue_filtering = item->filter(filter); + } + + // Update latest generation to pass filter in parent and propagate up to root + if (item->passedFilter()) + { + LLGLTFFolderItem* view_model = this; + + while (view_model && view_model->mMostFilteredDescendantGeneration < filter_generation) + { + view_model->mMostFilteredDescendantGeneration = filter_generation; + view_model = static_cast(view_model->mParent); + } + } + } + return continue_filtering; +} + +bool LLGLTFFolderItem::filter(LLFolderViewFilter& filter) +{ + const S32 filter_generation = filter.getCurrentGeneration(); + const S32 must_pass_generation = filter.getFirstRequiredGeneration(); + + if (getLastFilterGeneration() >= must_pass_generation + && getLastFolderFilterGeneration() >= must_pass_generation + && !passedFilter(must_pass_generation)) + { + // failed to pass an earlier filter that was a subset of the current one + // go ahead and flag this item as not pass + setPassedFilter(false, filter_generation); + setPassedFolderFilter(false, filter_generation); + return true; + } + + bool is_folder = true; + const bool passed_filter_folder = is_folder ? filter.checkFolder(this) : true; + setPassedFolderFilter(passed_filter_folder, filter_generation); + + bool continue_filtering = true; + + if (!mChildren.empty() + && (getLastFilterGeneration() < must_pass_generation // haven't checked descendants against minimum required generation to pass + || descendantsPassedFilter(must_pass_generation))) // or at least one descendant has passed the minimum requirement + { + // now query children + for (child_list_t::iterator iter = mChildren.begin(), end_iter = mChildren.end(); iter != end_iter; ++iter) + { + continue_filtering = filterChildItem((*iter), filter); + if (!continue_filtering) + { + break; + } + } + } + + // If we didn't use all the filter time that means we filtered all of our descendants so we can filter ourselves now + if (continue_filtering) + { + // This is where filter check on the item done (CHUI-849) + const bool passed_filter = filter.check(this); + if (passed_filter && mChildren.empty() && is_folder) // Update the latest filter generation for empty folders + { + LLGLTFFolderItem* view_model = this; + while (view_model && view_model->mMostFilteredDescendantGeneration < filter_generation) + { + view_model->mMostFilteredDescendantGeneration = filter_generation; + view_model = static_cast(view_model->mParent); + } + } + setPassedFilter(passed_filter, filter_generation, filter.getStringMatchOffset(this), filter.getFilterStringSize()); + continue_filtering = !filter.isTimedOut(); + } + return continue_filtering; +} diff --git a/indra/newview/llgltffolderitem.h b/indra/newview/llgltffolderitem.h new file mode 100644 index 0000000000..be6e264368 --- /dev/null +++ b/indra/newview/llgltffolderitem.h @@ -0,0 +1,128 @@ +/** + * @file llgltffolderitem.h + * @author Andrey Kleshchev + * @brief LLGLTFFolderItem header file + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLGLTFFOLDERITEM_H +#define LL_LLGLTFFOLDERITEM_H + +#include "llfloater.h" + +#include "llfolderviewmodel.h" + +class LLGLTFFolderItem : public LLFolderViewModelItemCommon +{ +public: + enum EType + { + TYPE_ROOT, + TYPE_SCENE, + TYPE_NODE, + TYPE_MESH, + TYPE_SKIN, + }; + + LLGLTFFolderItem(S32 id, const std::string &display_name, EType type, LLFolderViewModelInterface& root_view_model); + LLGLTFFolderItem(LLFolderViewModelInterface& root_view_model); + virtual ~LLGLTFFolderItem(); + + void init(); + + const std::string& getName() const override { return mName; } + const std::string& getDisplayName() const override { return mName; } + const std::string& getSearchableName() const override { return mName; } + + std::string getSearchableDescription() const override { return std::string(); } + std::string getSearchableCreatorName()const override { return std::string(); } + std::string getSearchableUUIDString() const override { return std::string(); } + + LLPointer getIcon() const override { return pIcon; } + LLPointer getIconOpen() const { return getIcon(); } + LLPointer getIconOverlay() const { return NULL; } + + LLFontGL::StyleFlags getLabelStyle() const override { return LLFontGL::NORMAL; } + std::string getLabelSuffix() const override { return std::string(); } + + void openItem(void) override {} + void closeItem(void) override {} + void selectItem(void) override {} + + void navigateToFolder(bool new_window = false, bool change_mode = false) override {} + + bool isItemWearable() const { return false; } + + bool isItemRenameable() const override { return false; } + bool renameItem(const std::string& new_name) override { return false; } + + bool isItemMovable(void) const override { return false; } // Can be moved to another folder + void move(LLFolderViewModelItem* parent_listener) override {} + + bool isItemRemovable(bool check_worn = true) const override { return false; } + bool removeItem() override { return false; } + void removeBatch(std::vector& batch) override {} + + bool isItemCopyable(bool can_copy_as_link = true) const override { return false; } + bool copyToClipboard() const override { return false; } + bool cutToClipboard() override { return false; } + bool isCutToClipboard() { return false; } + + bool isClipboardPasteable() const override { return false; } + void pasteFromClipboard() override {} + void pasteLinkFromClipboard() override {} + + void buildContextMenu(LLMenuGL& menu, U32 flags) override {}; + + bool potentiallyVisible() override { return true; }; // is the item definitely visible or we haven't made up our minds yet? + + bool hasChildren() const override { return mChildren.size() > 0; } + + bool dragOrDrop( + MASK mask, + bool drop, + EDragAndDropType cargo_type, + void* cargo_data, + std::string& tooltip_msg) override + { + return false; + } + + bool filterChildItem(LLFolderViewModelItem* item, LLFolderViewFilter& filter); + bool filter(LLFolderViewFilter& filter) override; + + EType getType() const { return mItemType; } + S32 getId() const { return mItemId; } + +private: + LLUIImagePtr pIcon; + std::string mName; + EType mItemType = TYPE_ROOT; + + // mItemId can be an id in a mesh vector, node vector or any other vector. + // mItemId is not nessesarily unique, ex: some nodes can reuse the same + // mesh or skin, so mesh-items can have the same id. + S32 mItemId = -1; +}; + +#endif LL_LLGLTFFOLDERITEM_H diff --git a/indra/newview/llgltffoldermodel.cpp b/indra/newview/llgltffoldermodel.cpp new file mode 100644 index 0000000000..5f22c8b710 --- /dev/null +++ b/indra/newview/llgltffoldermodel.cpp @@ -0,0 +1,73 @@ +/** + * @file llgltffoldermodel.cpp + * @author Andrey Kleshchev + * @brief gltf model's folder structure related classes + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llgltffoldermodel.h" + +#include "llfolderviewitem.h" + +bool LLGLTFSort::operator()(const LLGLTFFolderItem* const& a, const LLGLTFFolderItem* const& b) const +{ + // Comparison operator: returns "true" is a comes before b, "false" otherwise + S32 compare = LLStringUtil::compareDict(a->getName(), b->getName()); + return (compare < 0); +} + +/// LLGLTFViewModel + +LLGLTFViewModel::LLGLTFViewModel() + : base_t(new LLGLTFSort(), new LLGLTFFilter()) +{} + +void LLGLTFViewModel::sort(LLFolderViewFolder* folder) +{ + base_t::sort(folder); +} + + /// LLGLTFNode +// LLUICtrlFactory::create(params); +class LLGLTFNode : public LLFolderViewItem +{ +public: + struct Params : public LLInitParam::Block + { + Params(); + }; + ~LLGLTFNode(); +protected: + LLGLTFNode(const Params& p); +}; + +LLGLTFNode::LLGLTFNode(const LLGLTFNode::Params& p) + : LLFolderViewItem(p) +{ +} + +LLGLTFNode::~LLGLTFNode() +{ +} diff --git a/indra/newview/llgltffoldermodel.h b/indra/newview/llgltffoldermodel.h new file mode 100644 index 0000000000..26f05d1ecd --- /dev/null +++ b/indra/newview/llgltffoldermodel.h @@ -0,0 +1,91 @@ +/** + * @file llfloatergltfasseteditor.h + * @author Andrey Kleshchev + * @brief gltf model's folder structure related classes + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLGLTFFOLDERMODEL_H +#define LL_LLGLTFFOLDERMODEL_H + +#include "llfolderviewmodel.h" +#include "llgltffolderitem.h" + +class LLGLTFSort +{ +public: + LLGLTFSort() { } + bool operator()(const LLGLTFFolderItem* const& a, const LLGLTFFolderItem* const& b) const; +private: +}; + +class LLGLTFFilter : public LLFolderViewFilter +{ +public: + LLGLTFFilter() { mEmpty = ""; } + ~LLGLTFFilter() {} + + bool check(const LLFolderViewModelItem* item) { return true; } + bool checkFolder(const LLFolderViewModelItem* folder) const { return true; } + void setEmptyLookupMessage(const std::string& message) { } + std::string getEmptyLookupMessage(bool is_empty_folder = false) const { return mEmpty; } + bool showAllResults() const { return true; } + std::string::size_type getStringMatchOffset(LLFolderViewModelItem* item) const { return std::string::npos; } + std::string::size_type getFilterStringSize() const { return 0; } + + bool isActive() const { return false; } + bool isModified() const { return false; } + void clearModified() { } + const std::string& getName() const { return mEmpty; } + const std::string& getFilterText() { return mEmpty; } + void setModified(EFilterModified behavior = FILTER_RESTART) { } + + void resetTime(S32 timeout) { } + bool isTimedOut() { return false; } + + bool isDefault() const { return true; } + bool isNotDefault() const { return false; } + void markDefault() { } + void resetDefault() { } + + S32 getCurrentGeneration() const { return 0; } + S32 getFirstSuccessGeneration() const { return 0; } + S32 getFirstRequiredGeneration() const { return 0; } +private: + std::string mEmpty; +}; + +class LLGLTFViewModel + : public LLFolderViewModel +{ +public: + typedef LLFolderViewModel< LLGLTFSort, LLGLTFFolderItem, LLGLTFFolderItem, LLGLTFFilter> base_t; + LLGLTFViewModel(); + + void sort(LLFolderViewFolder* folder); + bool startDrag(std::vector& items) { return false; } + +private: +}; + +#endif LL_LLGLTFFOLDERMODEL_H diff --git a/indra/newview/llgltffolderviews.cpp b/indra/newview/llgltffolderviews.cpp deleted file mode 100644 index 911b6262ca..0000000000 --- a/indra/newview/llgltffolderviews.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/** - * @file llgltffolderviews.cpp - * @author Andrey Kleshchev - * @brief LLFloaterFontTest class implementation - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llgltffolderviews.h" -#include "llinventoryicon.h" - -/// LLGLTFItem - -LLGLTFItem::LLGLTFItem(std::string display_name, LLFolderViewModelInterface& root_view_model) - : LLFolderViewModelItemCommon(root_view_model) - , mName(display_name) -{ - init(); -} - -LLGLTFItem::LLGLTFItem(LLFolderViewModelInterface& root_view_model) - : LLFolderViewModelItemCommon(root_view_model) -{ - init(); -} - -LLGLTFItem::~LLGLTFItem() -{ - -} - -void LLGLTFItem::init() -{ - pIcon = LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_OBJECT); -} - - -bool LLGLTFItem::filterChildItem(LLFolderViewModelItem* item, LLFolderViewFilter& filter) -{ - S32 filter_generation = filter.getCurrentGeneration(); - - bool continue_filtering = true; - if (item) - { - if (item->getLastFilterGeneration() < filter_generation) - { - // Recursive application of the filter for child items (CHUI-849) - continue_filtering = item->filter(filter); - } - - // Update latest generation to pass filter in parent and propagate up to root - if (item->passedFilter()) - { - LLGLTFItem* view_model = this; - - while (view_model && view_model->mMostFilteredDescendantGeneration < filter_generation) - { - view_model->mMostFilteredDescendantGeneration = filter_generation; - view_model = static_cast(view_model->mParent); - } - } - } - return continue_filtering; -} - -bool LLGLTFItem::filter(LLFolderViewFilter& filter) -{ - - const S32 filter_generation = filter.getCurrentGeneration(); - const S32 must_pass_generation = filter.getFirstRequiredGeneration(); - - if (getLastFilterGeneration() >= must_pass_generation - && getLastFolderFilterGeneration() >= must_pass_generation - && !passedFilter(must_pass_generation)) - { - // failed to pass an earlier filter that was a subset of the current one - // go ahead and flag this item as not pass - setPassedFilter(false, filter_generation); - setPassedFolderFilter(false, filter_generation); - return true; - } - - bool is_folder = true; - const bool passed_filter_folder = is_folder ? filter.checkFolder(this) : true; - setPassedFolderFilter(passed_filter_folder, filter_generation); - - bool continue_filtering = true; - - if (!mChildren.empty() - && (getLastFilterGeneration() < must_pass_generation // haven't checked descendants against minimum required generation to pass - || descendantsPassedFilter(must_pass_generation))) // or at least one descendant has passed the minimum requirement - { - // now query children - for (child_list_t::iterator iter = mChildren.begin(), end_iter = mChildren.end(); iter != end_iter; ++iter) - { - continue_filtering = filterChildItem((*iter), filter); - if (!continue_filtering) - { - break; - } - } - } - - // If we didn't use all the filter time that means we filtered all of our descendants so we can filter ourselves now - if (continue_filtering) - { - // This is where filter check on the item done (CHUI-849) - const bool passed_filter = filter.check(this); - if (passed_filter && mChildren.empty() && is_folder) // Update the latest filter generation for empty folders - { - LLGLTFItem* view_model = this; - while (view_model && view_model->mMostFilteredDescendantGeneration < filter_generation) - { - view_model->mMostFilteredDescendantGeneration = filter_generation; - view_model = static_cast(view_model->mParent); - } - } - setPassedFilter(passed_filter, filter_generation, filter.getStringMatchOffset(this), filter.getFilterStringSize()); - continue_filtering = !filter.isTimedOut(); - } - return continue_filtering; -} diff --git a/indra/newview/llgltffolderviews.h b/indra/newview/llgltffolderviews.h deleted file mode 100644 index 294074fd9f..0000000000 --- a/indra/newview/llgltffolderviews.h +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @file llgltffolderviews.h - * @author Andrey Kleshchev - * @brief floater to exercise standard fonts - * - * $LicenseInfo:firstyear=2024&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2024, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLFLOATERGLTFFOLDERVIEWS_H -#define LL_LLFLOATERGLTFFOLDERVIEWS_H - -#include "llfloater.h" - -#include "llfolderviewmodel.h" - -class LLGLTFItem : public LLFolderViewModelItemCommon -{ -public: - LLGLTFItem(std::string display_name, LLFolderViewModelInterface& root_view_model); - LLGLTFItem(LLFolderViewModelInterface& root_view_model); - virtual ~LLGLTFItem(); - - void init(); - - const std::string& getName() const override { return mName; } - const std::string& getDisplayName() const override { return mName; } - const std::string& getSearchableName() const override { return mName; } - - std::string getSearchableDescription() const override { return std::string(); } - std::string getSearchableCreatorName()const override { return std::string(); } - std::string getSearchableUUIDString() const override { return std::string(); } - - LLPointer getIcon() const override { return pIcon; } - LLPointer getIconOpen() const { return getIcon(); } - LLPointer getIconOverlay() const { return NULL; } - - LLFontGL::StyleFlags getLabelStyle() const override { return LLFontGL::NORMAL; } - std::string getLabelSuffix() const override { return std::string(); } - - void openItem(void) override {} - void closeItem(void) override {} - void selectItem(void) override {} - - void navigateToFolder(bool new_window = false, bool change_mode = false) override {} - - bool isItemWearable() const { return false; } - - bool isItemRenameable() const override { return false; } - bool renameItem(const std::string& new_name) override { return false; } - - bool isItemMovable(void) const override { return false; } // Can be moved to another folder - void move(LLFolderViewModelItem* parent_listener) override {} - - bool isItemRemovable(bool check_worn = true) const override { return false; } - bool removeItem() override { return false; } - void removeBatch(std::vector& batch) override {} - - bool isItemCopyable(bool can_copy_as_link = true) const override { return false; } - bool copyToClipboard() const override { return false; } - bool cutToClipboard() override { return false; } - bool isCutToClipboard() { return false; } - - bool isClipboardPasteable() const override { return false; } - void pasteFromClipboard() override {} - void pasteLinkFromClipboard() override {} - - void buildContextMenu(LLMenuGL& menu, U32 flags) override {}; - - bool potentiallyVisible() override { return true; }; // is the item definitely visible or we haven't made up our minds yet? - - bool hasChildren() const override { return mChildren.size() > 0; } - - bool dragOrDrop( - MASK mask, - bool drop, - EDragAndDropType cargo_type, - void* cargo_data, - std::string& tooltip_msg) override - { - return false; - } - - bool filterChildItem(LLFolderViewModelItem* item, LLFolderViewFilter& filter); - bool filter(LLFolderViewFilter& filter) override; - -private: - LLUIImagePtr pIcon; - std::string mName; -}; - -#endif LL_LLFLOATERGLTFFOLDERVIEWS_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 36fd1015f6..3e1705b8a1 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -373,7 +373,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("forget_username", "floater_forget_user.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("gestures", "floater_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); - LLFloaterReg::add("gltf_asset_editor", "floater_gltf_asset_editor.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("gltf_asset_editor", "floater_gltf_asset_editor.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("god_tools", "floater_god_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("grid_status", "floater_grid_status.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("group_picker", "floater_choose_group.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml b/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml index 9082486d84..4dc0dffcfd 100644 --- a/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml +++ b/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml @@ -3,19 +3,24 @@ legacy_header_height="18" can_resize="true" default_tab_group="1" - height="891" + height="400" width="256" - min_height="500" - min_width="256" + min_height="200" + min_width="200" layout="topleft" name="gltf asset editor" title="[OBJECT_NAME]"> + + + + -- cgit v1.2.3 From 279ec534dd999420544b672cf84841b86d1306ae Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 1 Jul 2024 17:10:13 +0300 Subject: viewer#1131 gltf model upload UI WIP #3 --- indra/newview/llfloatergltfasseteditor.cpp | 269 +++++++++++++++++++- indra/newview/llfloatergltfasseteditor.h | 38 ++- indra/newview/llgltffolderitem.h | 2 +- .../default/xui/en/floater_gltf_asset_editor.xml | 271 ++++++++++++++++++++- 4 files changed, 566 insertions(+), 14 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloatergltfasseteditor.cpp b/indra/newview/llfloatergltfasseteditor.cpp index 62546c6ed9..ec9ccc1324 100644 --- a/indra/newview/llfloatergltfasseteditor.cpp +++ b/indra/newview/llfloatergltfasseteditor.cpp @@ -31,7 +31,9 @@ #include "gltf/asset.h" #include "llcallbacklist.h" +#include "llmenubutton.h" #include "llselectmgr.h" +#include "llspinctrl.h" #include "llviewerobject.h" const LLColor4U DEFAULT_WHITE(255, 255, 255); @@ -43,16 +45,69 @@ LLFloaterGLTFAssetEditor::LLFloaterGLTFAssetEditor(const LLSD& key) , mUIColor(LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE)) { setTitle("GLTF Asset Editor (WIP)"); + + mCommitCallbackRegistrar.add("PanelObject.menuDoToSelected", [this](LLUICtrl* ctrl, const LLSD& data) { onMenuDoToSelected(data); }); + mEnableCallbackRegistrar.add("PanelObject.menuEnable", [this](LLUICtrl* ctrl, const LLSD& data) { return onMenuEnableItem(data); }); } LLFloaterGLTFAssetEditor::~LLFloaterGLTFAssetEditor() { gIdleCallbacks.deleteFunction(idle, this); + + if (mScroller) + { + removeChild(mScroller); + delete mScroller; + mScroller = NULL; + } } bool LLFloaterGLTFAssetEditor::postBuild() { - mItemListPanel = getChild("item_list_panel"); + // Position + mMenuClipboardPos = getChild("clipboard_pos_btn"); + mCtrlPosX = getChild("Pos X", true); + mCtrlPosX->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + mCtrlPosY = getChild("Pos Y", true); + mCtrlPosY->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + mCtrlPosZ = getChild("Pos Z", true); + mCtrlPosZ->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + + // Scale + mMenuClipboardScale = getChild("clipboard_size_btn"); + mCtrlScaleX = getChild("Scale X", true); + mCtrlScaleX->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + mCtrlScaleY = getChild("Scale Y", true); + mCtrlScaleY->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + mCtrlScaleZ = getChild("Scale Z", true); + mCtrlScaleZ->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + + // Rotation + mMenuClipboardRot = getChild("clipboard_rot_btn"); + mCtrlRotX = getChild("Rot X", true); + mCtrlRotX->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + mCtrlRotY = getChild("Rot Y", true); + mCtrlRotY->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + mCtrlRotZ = getChild("Rot Z", true); + mCtrlPosZ->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + setTransformsEnabled(false); + // todo: do multiple panels based on selected element. + mTransformsPanel = getChild("transform_panel", true); + mTransformsPanel->setVisible(false); + + mItemListPanel = getChild("item_list_panel", true); + initFolderRoot(); + + return true; +} + +void LLFloaterGLTFAssetEditor::initFolderRoot() +{ + if (mScroller || mFolderRoot) + { + LL_ERRS() << "Folder root already initialized" << LL_ENDL; + return; + } LLRect scroller_view_rect = mItemListPanel->getRect(); scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom); @@ -87,11 +142,10 @@ bool LLFloaterGLTFAssetEditor::postBuild() mFolderRoot->setScrollContainer(mScroller); mFolderRoot->setFollowsAll(); mFolderRoot->setOpen(true); + mFolderRoot->setSelectCallback([this](const std::deque& items, bool user_action) { onFolderSelectionChanged(items, user_action); }); mScroller->setVisible(true); gIdleCallbacks.addFunction(idle, this); - - return true; } void LLFloaterGLTFAssetEditor::onOpen(const LLSD& key) @@ -252,3 +306,212 @@ void LLFloaterGLTFAssetEditor::loadFromSelection() mFolderRoot->update(); } +void LLFloaterGLTFAssetEditor::onFolderSelectionChanged(const std::deque& items, bool user_action) +{ + if (items.empty()) + { + setTransformsEnabled(false); + return; + } + + LLFolderViewItem* item = items.front(); + LLGLTFFolderItem* vmi = static_cast(item->getViewModelItem()); + + switch (vmi->getType()) + { + case LLGLTFFolderItem::TYPE_NODE: + { + setTransformsEnabled(true); + loadNodeTransforms(vmi->getItemId()); + break; + } + default: + { + setTransformsEnabled(false); + break; + } + } +} + +void LLFloaterGLTFAssetEditor::setTransformsEnabled(bool val) +{ + mMenuClipboardPos->setEnabled(val); + mCtrlPosX->setEnabled(val); + mCtrlPosY->setEnabled(val); + mCtrlPosZ->setEnabled(val); + mMenuClipboardScale->setEnabled(val); + mCtrlScaleX->setEnabled(val); + mCtrlScaleY->setEnabled(val); + mCtrlScaleZ->setEnabled(val); + mMenuClipboardRot->setEnabled(val); + mCtrlRotX->setEnabled(val); + mCtrlRotY->setEnabled(val); + mCtrlRotZ->setEnabled(val); +} + +void LLFloaterGLTFAssetEditor::loadNodeTransforms(S32 node_id) +{ + if (node_id < 0 || node_id >= mAsset->mNodes.size()) + { + LL_ERRS() << "Node id out of range: " << node_id << LL_ENDL; + return; + } + + LL::GLTF::Node& node = mAsset->mNodes[node_id]; + + mCtrlPosX->set(node.mTranslation[0]); + mCtrlPosY->set(node.mTranslation[1]); + mCtrlPosZ->set(node.mTranslation[2]); + + mCtrlScaleX->set(node.mScale[0]); + mCtrlScaleY->set(node.mScale[1]); + mCtrlScaleZ->set(node.mScale[2]); + + LLQuaternion object_rot = LLQuaternion(node.mRotation[0], node.mRotation[1], node.mRotation[2], node.mRotation[3]); + object_rot.getEulerAngles(&(mLastEulerDegrees.mV[VX]), &(mLastEulerDegrees.mV[VY]), &(mLastEulerDegrees.mV[VZ])); + mLastEulerDegrees *= RAD_TO_DEG; + mLastEulerDegrees.mV[VX] = fmod(ll_round(mLastEulerDegrees.mV[VX], OBJECT_ROTATION_PRECISION) + 360.f, 360.f); + mLastEulerDegrees.mV[VY] = fmod(ll_round(mLastEulerDegrees.mV[VY], OBJECT_ROTATION_PRECISION) + 360.f, 360.f); + mLastEulerDegrees.mV[VZ] = fmod(ll_round(mLastEulerDegrees.mV[VZ], OBJECT_ROTATION_PRECISION) + 360.f, 360.f); + + mCtrlRotX->set(mLastEulerDegrees.mV[VX]); + mCtrlRotY->set(mLastEulerDegrees.mV[VY]); + mCtrlRotZ->set(mLastEulerDegrees.mV[VZ]); +} + +void LLFloaterGLTFAssetEditor::onCommitTransform() +{ + if (!mFolderRoot) + { + LL_ERRS() << "Folder root not initialized" << LL_ENDL; + return; + } + + LLFolderViewItem* item = mFolderRoot->getCurSelectedItem(); + if (!item) + { + LL_ERRS() << "Nothing selected" << LL_ENDL; + return; + } + + LLGLTFFolderItem* vmi = static_cast(item->getViewModelItem()); + + if (!vmi || vmi->getType() != LLGLTFFolderItem::TYPE_NODE) + { + LL_ERRS() << "Only nodes implemented" << LL_ENDL; + return; + } + S32 node_id = vmi->getItemId(); + LL::GLTF::Node& node = mAsset->mNodes[node_id]; + + LL::GLTF::vec3 tr(mCtrlPosX->get(), mCtrlPosY->get(), mCtrlPosZ->get()); + node.setTranslation(tr); + + LL::GLTF::vec3 scale(mCtrlScaleX->get(), mCtrlScaleY->get(), mCtrlScaleZ->get()); + node.setScale(scale); + + LLVector3 new_rot(mCtrlRotX->get(), mCtrlRotY->get(), mCtrlRotZ->get()); + new_rot.mV[VX] = ll_round(new_rot.mV[VX], OBJECT_ROTATION_PRECISION); + new_rot.mV[VY] = ll_round(new_rot.mV[VY], OBJECT_ROTATION_PRECISION); + new_rot.mV[VZ] = ll_round(new_rot.mV[VZ], OBJECT_ROTATION_PRECISION); + + // Note: must compare before conversion to radians, some value can go 'around' 360 + LLVector3 delta = new_rot - mLastEulerDegrees; + + if (delta.magVec() >= 0.0005f) + { + mLastEulerDegrees = new_rot; + new_rot *= DEG_TO_RAD; + + LLQuaternion rotation; + rotation.setQuat(new_rot.mV[VX], new_rot.mV[VY], new_rot.mV[VZ]); + LL::GLTF::quat q; + q[0] = rotation.mQ[VX]; + q[1] = rotation.mQ[VY]; + q[2] = rotation.mQ[VZ]; + q[3] = rotation.mQ[VW]; + + node.setRotation(q); + } + + mAsset->updateTransforms(); +} + +void LLFloaterGLTFAssetEditor::onMenuDoToSelected(const LLSD& userdata) +{ + std::string command = userdata.asString(); + + if (command == "psr_paste") + { + // todo: implement + // onPastePos(); + // onPasteSize(); + // onPasteRot(); + } + else if (command == "pos_paste") + { + // todo: implement + } + else if (command == "size_paste") + { + // todo: implement + } + else if (command == "rot_paste") + { + // todo: implement + } + else if (command == "psr_copy") + { + // onCopyPos(); + // onCopySize(); + // onCopyRot(); + } + else if (command == "pos_copy") + { + // todo: implement + } + else if (command == "size_copy") + { + // todo: implement + } + else if (command == "rot_copy") + { + // todo: implement + } +} + +bool LLFloaterGLTFAssetEditor::onMenuEnableItem(const LLSD& userdata) +{ + if (!mFolderRoot) + { + return false; + } + + LLFolderViewItem* item = mFolderRoot->getCurSelectedItem(); + if (!item) + { + return false; + } + + LLGLTFFolderItem* vmi = static_cast(item->getViewModelItem()); + + if (!vmi || vmi->getType() != LLGLTFFolderItem::TYPE_NODE) + { + return false; + } + + std::string command = userdata.asString(); + if (command == "pos_paste" || command == "size_paste" || command == "rot_paste") + { + // todo: implement + return true; + } + if (command == "psr_copy") + { + // todo: implement + return true; + } + + return false; +} + diff --git a/indra/newview/llfloatergltfasseteditor.h b/indra/newview/llfloatergltfasseteditor.h index 49c5aa4ae7..8164928824 100644 --- a/indra/newview/llfloatergltfasseteditor.h +++ b/indra/newview/llfloatergltfasseteditor.h @@ -40,6 +40,9 @@ namespace LL } } +class LLSpinCtrl; +class LLMenuButton; + class LLFloaterGLTFAssetEditor : public LLFloater { public: @@ -48,6 +51,7 @@ public: bool postBuild() override; void onOpen(const LLSD& key) override; + void initFolderRoot(); LLGLTFViewModel& getRootViewModel() { return mGLTFViewModel; } @@ -56,14 +60,42 @@ public: void loadFromNode(S32 node, LLFolderViewFolder* parent); void loadFromSelection(); +protected: + void onFolderSelectionChanged(const std::deque& items, bool user_action); + void onCommitTransform(); + void onMenuDoToSelected(const LLSD& userdata); + bool onMenuEnableItem(const LLSD& userdata); + + void setTransformsEnabled(bool val); + void loadNodeTransforms(S32 id); + private: - LLGLTFViewModel mGLTFViewModel; - LLUIColor mUIColor; + std::shared_ptr mAsset; + + // Folder view related + LLUIColor mUIColor; + LLGLTFViewModel mGLTFViewModel; LLPanel* mItemListPanel = nullptr; LLFolderView* mFolderRoot = nullptr; LLScrollContainer* mScroller = nullptr; - std::shared_ptr mAsset; + + // Transforms panel + LLVector3 mLastEulerDegrees; + + LLPanel* mTransformsPanel = nullptr; + LLMenuButton* mMenuClipboardPos = nullptr; + LLSpinCtrl* mCtrlPosX = nullptr; + LLSpinCtrl* mCtrlPosY = nullptr; + LLSpinCtrl* mCtrlPosZ = nullptr; + LLMenuButton* mMenuClipboardScale = nullptr; + LLSpinCtrl* mCtrlScaleX = nullptr; + LLSpinCtrl* mCtrlScaleY = nullptr; + LLSpinCtrl* mCtrlScaleZ = nullptr; + LLMenuButton* mMenuClipboardRot = nullptr; + LLSpinCtrl* mCtrlRotX = nullptr; + LLSpinCtrl* mCtrlRotY = nullptr; + LLSpinCtrl* mCtrlRotZ = nullptr; }; #endif LL_LLFLOATERGLTFASSETEDITOR_H diff --git a/indra/newview/llgltffolderitem.h b/indra/newview/llgltffolderitem.h index be6e264368..83c6449f96 100644 --- a/indra/newview/llgltffolderitem.h +++ b/indra/newview/llgltffolderitem.h @@ -112,7 +112,7 @@ public: bool filter(LLFolderViewFilter& filter) override; EType getType() const { return mItemType; } - S32 getId() const { return mItemId; } + S32 getItemId() const { return mItemId; } private: LLUIImagePtr pIcon; diff --git a/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml b/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml index 4dc0dffcfd..82e0e325fb 100644 --- a/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml +++ b/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml @@ -3,9 +3,9 @@ legacy_header_height="18" can_resize="true" default_tab_group="1" - height="400" + height="530" width="256" - min_height="200" + min_height="400" min_width="200" layout="topleft" name="gltf asset editor" @@ -14,13 +14,270 @@ - + right="-1" + border_size="0"> + + + + + + + + + Position (m) + + + + + + + Size (m) + + + + + + + Rotation (°) + + + + + + + + + -- cgit v1.2.3 From b940fbc0d4b78534780de33dc9f7d41535de5ae3 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 1 Jul 2024 19:01:20 +0300 Subject: viewer#1131 MacOS build fixes and small adjustments --- indra/newview/llfloatergltfasseteditor.cpp | 16 +++++++++++++--- indra/newview/llfloatergltfasseteditor.h | 2 +- indra/newview/llgltffolderitem.cpp | 4 ++-- indra/newview/llgltffolderitem.h | 10 +++++----- indra/newview/llgltffoldermodel.cpp | 4 ++-- indra/newview/llgltffoldermodel.h | 2 +- .../skins/default/xui/en/floater_gltf_asset_editor.xml | 7 ++++--- 7 files changed, 28 insertions(+), 17 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloatergltfasseteditor.cpp b/indra/newview/llfloatergltfasseteditor.cpp index ec9ccc1324..f21b8032d0 100644 --- a/indra/newview/llfloatergltfasseteditor.cpp +++ b/indra/newview/llfloatergltfasseteditor.cpp @@ -3,9 +3,9 @@ * @author Andrii Kleshchev * @brief LLFloaterGltfAssetEditor class implementation * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2024, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -251,7 +251,8 @@ void LLFloaterGLTFAssetEditor::loadFromSelection() return; } - LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); + LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(NULL); + LLViewerObject* objectp = node->getObject(); if (!objectp) { return; @@ -263,6 +264,15 @@ void LLFloaterGLTFAssetEditor::loadFromSelection() return; } + if (node->mName.empty()) + { + setTitle(getString("floater_title")); + } + else + { + setTitle(node->mName); + } + LLUIColor item_color = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE); for (S32 i = 0; i < mAsset->mScenes.size(); i++) { diff --git a/indra/newview/llfloatergltfasseteditor.h b/indra/newview/llfloatergltfasseteditor.h index 8164928824..e35ed30ed0 100644 --- a/indra/newview/llfloatergltfasseteditor.h +++ b/indra/newview/llfloatergltfasseteditor.h @@ -98,4 +98,4 @@ private: LLSpinCtrl* mCtrlRotZ = nullptr; }; -#endif LL_LLFLOATERGLTFASSETEDITOR_H +#endif diff --git a/indra/newview/llgltffolderitem.cpp b/indra/newview/llgltffolderitem.cpp index c4fcb4f5ce..77a19c060d 100644 --- a/indra/newview/llgltffolderitem.cpp +++ b/indra/newview/llgltffolderitem.cpp @@ -3,9 +3,9 @@ * @author Andrey Kleshchev * @brief LLGLTFFolderItem class implementation * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2024, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/indra/newview/llgltffolderitem.h b/indra/newview/llgltffolderitem.h index 83c6449f96..89d90c81cc 100644 --- a/indra/newview/llgltffolderitem.h +++ b/indra/newview/llgltffolderitem.h @@ -59,8 +59,8 @@ public: std::string getSearchableUUIDString() const override { return std::string(); } LLPointer getIcon() const override { return pIcon; } - LLPointer getIconOpen() const { return getIcon(); } - LLPointer getIconOverlay() const { return NULL; } + LLPointer getIconOpen() const override { return getIcon(); } + LLPointer getIconOverlay() const override { return NULL; } LLFontGL::StyleFlags getLabelStyle() const override { return LLFontGL::NORMAL; } std::string getLabelSuffix() const override { return std::string(); } @@ -71,7 +71,7 @@ public: void navigateToFolder(bool new_window = false, bool change_mode = false) override {} - bool isItemWearable() const { return false; } + bool isItemWearable() const override { return false; } bool isItemRenameable() const override { return false; } bool renameItem(const std::string& new_name) override { return false; } @@ -86,7 +86,7 @@ public: bool isItemCopyable(bool can_copy_as_link = true) const override { return false; } bool copyToClipboard() const override { return false; } bool cutToClipboard() override { return false; } - bool isCutToClipboard() { return false; } + bool isCutToClipboard() override { return false; } bool isClipboardPasteable() const override { return false; } void pasteFromClipboard() override {} @@ -125,4 +125,4 @@ private: S32 mItemId = -1; }; -#endif LL_LLGLTFFOLDERITEM_H +#endif diff --git a/indra/newview/llgltffoldermodel.cpp b/indra/newview/llgltffoldermodel.cpp index 5f22c8b710..de2510dc4a 100644 --- a/indra/newview/llgltffoldermodel.cpp +++ b/indra/newview/llgltffoldermodel.cpp @@ -3,9 +3,9 @@ * @author Andrey Kleshchev * @brief gltf model's folder structure related classes * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2024, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/indra/newview/llgltffoldermodel.h b/indra/newview/llgltffoldermodel.h index 26f05d1ecd..69b284aa31 100644 --- a/indra/newview/llgltffoldermodel.h +++ b/indra/newview/llgltffoldermodel.h @@ -88,4 +88,4 @@ public: private: }; -#endif LL_LLGLTFFOLDERMODEL_H +#endif diff --git a/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml b/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml index 82e0e325fb..b17d0aa5b6 100644 --- a/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml +++ b/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml @@ -10,6 +10,7 @@ layout="topleft" name="gltf asset editor" title="[OBJECT_NAME]"> + @@ -39,7 +40,7 @@ name="item_list_panel" visible="true" bottom="-1" - top="16" + top="1" left="5" right="-1"/> @@ -60,8 +61,8 @@ image_selected="ClipboardSmallMenu_Press" image_unselected="ClipboardSmallMenu_Off" layout="topleft" - left_delta="0" - top_pad="13" + left="4" + top="10" name="clipboard_pos_btn" tool_tip="Paste options" width="19"/> -- cgit v1.2.3 From 2ea5ac0c43e3e28d2b1774f5367d099271a1da32 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Mon, 1 Jul 2024 13:34:50 +0200 Subject: #1111 Remove xmlrpc-epi --- indra/newview/llcurrencyuimanager.cpp | 137 ++++---- indra/newview/llfloaterbuyland.cpp | 201 +++++------- indra/newview/lllogininstance.cpp | 5 +- indra/newview/llslurl.cpp | 6 +- indra/newview/llversioninfo.cpp | 22 +- indra/newview/llversioninfo.h | 26 +- indra/newview/llxmlrpclistener.cpp | 278 +++------------- indra/newview/llxmlrpclistener.h | 3 - indra/newview/llxmlrpctransaction.cpp | 361 +++++++-------------- indra/newview/llxmlrpctransaction.h | 92 ++---- .../newview/skins/default/xui/da/floater_about.xml | 1 - .../newview/skins/default/xui/de/floater_about.xml | 1 - .../newview/skins/default/xui/en/floater_about.xml | 1 - .../newview/skins/default/xui/es/floater_about.xml | 1 - .../newview/skins/default/xui/fr/floater_about.xml | 1 - .../newview/skins/default/xui/it/floater_about.xml | 1 - .../newview/skins/default/xui/ja/floater_about.xml | 1 - .../newview/skins/default/xui/pt/floater_about.xml | 1 - .../newview/skins/default/xui/ru/floater_about.xml | 1 - .../newview/skins/default/xui/tr/floater_about.xml | 1 - .../newview/skins/default/xui/zh/floater_about.xml | 1 - 21 files changed, 360 insertions(+), 782 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llcurrencyuimanager.cpp b/indra/newview/llcurrencyuimanager.cpp index 06c87343e2..8a4ab091a3 100644 --- a/indra/newview/llcurrencyuimanager.cpp +++ b/indra/newview/llcurrencyuimanager.cpp @@ -111,16 +111,17 @@ public: bool hasEstimate() const; std::string getLocalEstimate() const; - void startTransaction(TransactionType type, - const char* method, LLXMLRPCValue params); + void startTransaction(TransactionType type, const char* method, const LLSD& params); + + // return true if update needed bool checkTransaction(); - // return true if update needed void setError(const std::string& message, const std::string& uri); void clearError(); + // return true if update needed bool considerUpdateCurrency(); - // return true if update needed + void currencyKey(S32); static void onCurrencyKey(LLLineEditor* caller, void* data); @@ -160,32 +161,29 @@ void LLCurrencyUIManager::Impl::updateCurrencyInfo() return; } - LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); - keywordArgs.appendString("agentId", gAgent.getID().asString()); - keywordArgs.appendString( - "secureSessionId", - gAgent.getSecureSessionID().asString()); - keywordArgs.appendString("language", LLUI::getLanguage()); - keywordArgs.appendInt("currencyBuy", mUserCurrencyBuy); - keywordArgs.appendString("viewerChannel", LLVersionInfo::instance().getChannel()); - keywordArgs.appendInt("viewerMajorVersion", LLVersionInfo::instance().getMajor()); - keywordArgs.appendInt("viewerMinorVersion", LLVersionInfo::instance().getMinor()); - keywordArgs.appendInt("viewerPatchVersion", LLVersionInfo::instance().getPatch()); + const LLVersionInfo& vi(LLVersionInfo::instance()); + + LLSD params = LLSD::emptyMap(); + params["agentId"] = gAgent.getID().asString(); + params["secureSessionId"] = gAgent.getSecureSessionID().asString(); + params["language"] = LLUI::getLanguage(); + params["currencyBuy"] = mUserCurrencyBuy; + params["viewerChannel"] = vi.getChannel(); + params["viewerMajorVersion"] = vi.getMajor(); + params["viewerMinorVersion"] = vi.getMinor(); + params["viewerPatchVersion"] = vi.getPatch(); // With GitHub builds, the build number is too big to fit in a 32-bit int, - // and XMLRPC_VALUE doesn't deal with integers wider than int. Use string. - keywordArgs.appendString("viewerBuildVersion", stringize(LLVersionInfo::instance().getBuild())); - - LLXMLRPCValue params = LLXMLRPCValue::createArray(); - params.append(keywordArgs); + // and XMLRPC value doesn't deal with integers wider than int. Use string. + params["viewerBuildVersion"] = std::to_string(vi.getBuild()); startTransaction(TransactionCurrency, "getCurrencyQuote", params); } void LLCurrencyUIManager::Impl::finishCurrencyInfo() { - LLXMLRPCValue result = mTransaction->responseValue(); + const LLSD& result = mTransaction->response(); - bool success = result["success"].asBool(); + bool success = result["success"].asBoolean(); if (!success) { setError( @@ -195,24 +193,24 @@ void LLCurrencyUIManager::Impl::finishCurrencyInfo() return; } - LLXMLRPCValue currency = result["currency"]; + const LLSD& currency = result["currency"]; // old XML-RPC server: estimatedCost = value in US cents - mUSDCurrencyEstimated = currency["estimatedCost"].isValid(); + mUSDCurrencyEstimated = currency.has("estimatedCost"); if (mUSDCurrencyEstimated) { - mUSDCurrencyEstimatedCost = currency["estimatedCost"].asInt(); + mUSDCurrencyEstimatedCost = currency["estimatedCost"].asInteger(); } // newer XML-RPC server: estimatedLocalCost = local currency string - mLocalCurrencyEstimated = currency["estimatedLocalCost"].isValid(); + mLocalCurrencyEstimated = currency.has("estimatedLocalCost"); if (mLocalCurrencyEstimated) { mLocalCurrencyEstimatedCost = currency["estimatedLocalCost"].asString(); mSupportsInternationalBilling = true; } - S32 newCurrencyBuy = currency["currencyBuy"].asInt(); + S32 newCurrencyBuy = currency["currencyBuy"].asInteger(); if (newCurrencyBuy != mUserCurrencyBuy) { mUserCurrencyBuy = newCurrencyBuy; @@ -224,36 +222,36 @@ void LLCurrencyUIManager::Impl::finishCurrencyInfo() void LLCurrencyUIManager::Impl::startCurrencyBuy(const std::string& password) { - LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); - keywordArgs.appendString("agentId", gAgent.getID().asString()); - keywordArgs.appendString( - "secureSessionId", - gAgent.getSecureSessionID().asString()); - keywordArgs.appendString("language", LLUI::getLanguage()); - keywordArgs.appendInt("currencyBuy", mUserCurrencyBuy); + const LLVersionInfo& vi(LLVersionInfo::instance()); + + LLSD params = LLSD::emptyMap(); + params["agentId"] = gAgent.getID().asString(); + params["secureSessionId"] = gAgent.getSecureSessionID().asString(); + params["language"] = LLUI::getLanguage(); + params["currencyBuy"] = mUserCurrencyBuy; + params["confirm"] = mSiteConfirm; + params["viewerChannel"] = vi.getChannel(); + params["viewerMajorVersion"] = vi.getMajor(); + params["viewerMinorVersion"] = vi.getMinor(); + params["viewerPatchVersion"] = vi.getPatch(); + // With GitHub builds, the build number is too big to fit in a 32-bit int, + // and XMLRPC value doesn't deal with integers wider than int. Use string. + params["viewerBuildVersion"] = std::to_string(vi.getBuild()); + if (mUSDCurrencyEstimated) { - keywordArgs.appendInt("estimatedCost", mUSDCurrencyEstimatedCost); + params["estimatedCost"] = mUSDCurrencyEstimatedCost; } + if (mLocalCurrencyEstimated) { - keywordArgs.appendString("estimatedLocalCost", mLocalCurrencyEstimatedCost); + params["estimatedLocalCost"] = mLocalCurrencyEstimatedCost; } - keywordArgs.appendString("confirm", mSiteConfirm); + if (!password.empty()) { - keywordArgs.appendString("password", password); + params["password"] = password; } - keywordArgs.appendString("viewerChannel", LLVersionInfo::instance().getChannel()); - keywordArgs.appendInt("viewerMajorVersion", LLVersionInfo::instance().getMajor()); - keywordArgs.appendInt("viewerMinorVersion", LLVersionInfo::instance().getMinor()); - keywordArgs.appendInt("viewerPatchVersion", LLVersionInfo::instance().getPatch()); - // With GitHub builds, the build number is too big to fit in a 32-bit int, - // and XMLRPC_VALUE doesn't deal with integers wider than int. Use string. - keywordArgs.appendString("viewerBuildVersion", stringize(LLVersionInfo::instance().getBuild())); - - LLXMLRPCValue params = LLXMLRPCValue::createArray(); - params.append(keywordArgs); startTransaction(TransactionBuy, "buyCurrency", params); @@ -263,9 +261,9 @@ void LLCurrencyUIManager::Impl::startCurrencyBuy(const std::string& password) void LLCurrencyUIManager::Impl::finishCurrencyBuy() { - LLXMLRPCValue result = mTransaction->responseValue(); + const LLSD& result = mTransaction->response(); - bool success = result["success"].asBool(); + bool success = result["success"].asBoolean(); if (!success) { setError( @@ -282,7 +280,7 @@ void LLCurrencyUIManager::Impl::finishCurrencyBuy() } void LLCurrencyUIManager::Impl::startTransaction(TransactionType type, - const char* method, LLXMLRPCValue params) + const char* method, const LLSD& params) { static std::string transactionURI; if (transactionURI.empty()) @@ -293,12 +291,7 @@ void LLCurrencyUIManager::Impl::startTransaction(TransactionType type, delete mTransaction; mTransactionType = type; - mTransaction = new LLXMLRPCTransaction( - transactionURI, - method, - params, - false /* don't use gzip */ - ); + mTransaction = new LLXMLRPCTransaction(transactionURI, method, params); clearError(); } @@ -352,12 +345,17 @@ bool LLCurrencyUIManager::Impl::checkTransaction() { setError(mTransaction->statusMessage(), mTransaction->statusURI()); } - else { + else + { switch (mTransactionType) { - case TransactionCurrency: finishCurrencyInfo(); break; - case TransactionBuy: finishCurrencyBuy(); break; - default: ; + case TransactionCurrency: + finishCurrencyInfo(); + break; + case TransactionBuy: + finishCurrencyBuy(); + break; + default:; } } @@ -385,9 +383,8 @@ void LLCurrencyUIManager::Impl::clearError() bool LLCurrencyUIManager::Impl::considerUpdateCurrency() { - if (mCurrencyChanged - && !mTransaction - && mCurrencyKeyTimer.getElapsedTimeF32() >= CURRENCY_ESTIMATE_FREQUENCY) + if (mCurrencyChanged && !mTransaction && + mCurrencyKeyTimer.getElapsedTimeF32() >= CURRENCY_ESTIMATE_FREQUENCY) { updateCurrencyInfo(); return true; @@ -408,7 +405,8 @@ void LLCurrencyUIManager::Impl::currencyKey(S32 value) mUserCurrencyBuy = value; - if (hasEstimate()) { + if (hasEstimate()) + { clearEstimate(); //cannot just simply refresh the whole UI, as the edit field will // get reset and the cursor will change... @@ -421,8 +419,7 @@ void LLCurrencyUIManager::Impl::currencyKey(S32 value) } // static -void LLCurrencyUIManager::Impl::onCurrencyKey( - LLLineEditor* caller, void* data) +void LLCurrencyUIManager::Impl::onCurrencyKey(LLLineEditor* caller, void* data) { S32 value = atoi(caller->getText().c_str()); LLCurrencyUIManager::Impl* self = (LLCurrencyUIManager::Impl*)data; @@ -589,14 +586,12 @@ bool LLCurrencyUIManager::inProcess() bool LLCurrencyUIManager::canCancel() { - return impl.mTransactionType != Impl::TransactionBuy; + return !buying(); } bool LLCurrencyUIManager::canBuy() { - return impl.mTransactionType == Impl::TransactionNone - && impl.hasEstimate() - && impl.mUserCurrencyBuy > 0; + return !inProcess() && impl.hasEstimate() && impl.mUserCurrencyBuy > 0; } bool LLCurrencyUIManager::buying() diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp index 570a223908..11505e3047 100644 --- a/indra/newview/llfloaterbuyland.cpp +++ b/indra/newview/llfloaterbuyland.cpp @@ -182,7 +182,7 @@ public: void refreshUI(); - void startTransaction(TransactionType type, const LLXMLRPCValue& params); + void startTransaction(TransactionType type, const LLSD& params); bool checkTransaction(); void tellUserError(const std::string& message, const std::string& uri); @@ -396,11 +396,10 @@ void LLFloaterBuyLandUI::updateParcelInfo() // Can't have more than region max tasks, regardless of parcel // object bonus factor. LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion(); - if(region) + if (region) { S32 max_tasks_per_region = (S32)region->getMaxTasks(); - mParcelSupportedObjects = llmin( - mParcelSupportedObjects, max_tasks_per_region); + mParcelSupportedObjects = llmin(mParcelSupportedObjects, max_tasks_per_region); } mParcelSoldWithObjects = parcel->getSellWithObjects(); @@ -423,7 +422,7 @@ void LLFloaterBuyLandUI::updateParcelInfo() // checks that we can buy the land - if(mIsForGroup && !gAgent.hasPowerInActiveGroup(GP_LAND_DEED)) + if (mIsForGroup && !gAgent.hasPowerInActiveGroup(GP_LAND_DEED)) { mCannotBuyReason = getString("cant_buy_for_group"); return; @@ -492,85 +491,56 @@ void LLFloaterBuyLandUI::updateParcelInfo() void LLFloaterBuyLandUI::updateCovenantInfo() { LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion(); - if(!region) return; + if (!region) + return; U8 sim_access = region->getSimAccess(); std::string rating = LLViewerRegion::accessToString(sim_access); LLTextBox* region_name = getChild("region_name_text"); - if (region_name) - { - std::string region_name_txt = region->getName() + " ("+rating +")"; - region_name->setText(region_name_txt); + std::string region_name_txt = region->getName() + " ("+rating +")"; + region_name->setText(region_name_txt); - LLIconCtrl* rating_icon = getChild("rating_icon"); - LLRect rect = rating_icon->getRect(); - S32 region_name_width = llmin(region_name->getRect().getWidth(), region_name->getTextBoundingRect().getWidth()); - S32 icon_left_pad = region_name->getRect().mLeft + region_name_width + ICON_PAD; - region_name->setToolTip(region_name->getText()); - rating_icon->setRect(rect.setOriginAndSize(icon_left_pad, rect.mBottom, rect.getWidth(), rect.getHeight())); + LLIconCtrl* rating_icon = getChild("rating_icon"); + LLRect rect = rating_icon->getRect(); + S32 region_name_width = llmin(region_name->getRect().getWidth(), region_name->getTextBoundingRect().getWidth()); + S32 icon_left_pad = region_name->getRect().mLeft + region_name_width + ICON_PAD; + region_name->setToolTip(region_name->getText()); + rating_icon->setRect(rect.setOriginAndSize(icon_left_pad, rect.mBottom, rect.getWidth(), rect.getHeight())); - switch(sim_access) - { - case SIM_ACCESS_PG: - rating_icon->setValue(getString("icon_PG")); - break; + switch (sim_access) + { + case SIM_ACCESS_PG: + rating_icon->setValue(getString("icon_PG")); + break; - case SIM_ACCESS_ADULT: - rating_icon->setValue(getString("icon_R")); - break; + case SIM_ACCESS_ADULT: + rating_icon->setValue(getString("icon_R")); + break; - default: - rating_icon->setValue(getString("icon_M")); - } + default: + rating_icon->setValue(getString("icon_M")); } LLTextBox* region_type = getChild("region_type_text"); - if (region_type) - { - region_type->setText(region->getLocalizedSimProductName()); - region_type->setToolTip(region->getLocalizedSimProductName()); - } + region_type->setText(region->getLocalizedSimProductName()); + region_type->setToolTip(region->getLocalizedSimProductName()); LLTextBox* resellable_clause = getChild("resellable_clause"); - if (resellable_clause) - { - if (region->getRegionFlag(REGION_FLAGS_BLOCK_LAND_RESELL)) - { - resellable_clause->setText(getString("can_not_resell")); - } - else - { - resellable_clause->setText(getString("can_resell")); - } - } + const char* can_resell = region->getRegionFlag(REGION_FLAGS_BLOCK_LAND_RESELL) ? "can_not_resell" : "can_resell"; + resellable_clause->setText(getString(can_resell)); LLTextBox* changeable_clause = getChild("changeable_clause"); - if (changeable_clause) - { - if (region->getRegionFlag(REGION_FLAGS_ALLOW_PARCEL_CHANGES)) - { - changeable_clause->setText(getString("can_change")); - } - else - { - changeable_clause->setText(getString("can_not_change")); - } - } + const char* can_change = region->getRegionFlag(REGION_FLAGS_ALLOW_PARCEL_CHANGES) ? "can_change" : "can_not_change"; + changeable_clause->setText(getString(can_change)); LLCheckBoxCtrl* check = getChild("agree_covenant"); - if(check) - { - check->set(false); - check->setEnabled(true); - check->setCommitCallback(onChangeAgreeCovenant, this); - } + check->set(false); + check->setEnabled(true); + check->setCommitCallback(onChangeAgreeCovenant, this); LLTextBox* box = getChild("covenant_text"); - if(box) - { - box->setVisible(false); - } + box->setVisible(false); // send EstateCovenantInfo message LLMessageSystem *msg = gMessageSystem; @@ -584,10 +554,9 @@ void LLFloaterBuyLandUI::updateCovenantInfo() // static void LLFloaterBuyLandUI::onChangeAgreeCovenant(LLUICtrl* ctrl, void* user_data) { - LLFloaterBuyLandUI* self = (LLFloaterBuyLandUI*)user_data; - if(self) + if (user_data) { - self->refreshUI(); + ((LLFloaterBuyLandUI*)user_data)->refreshUI(); } } @@ -626,13 +595,13 @@ void LLFloaterBuyLandUI::updateFloaterEstateName(const std::string& name) void LLFloaterBuyLandUI::updateFloaterLastModified(const std::string& text) { LLTextBox* editor = getChild("covenant_timestamp_text"); - if (editor) editor->setText(text); + editor->setText(text); } void LLFloaterBuyLandUI::updateFloaterEstateOwnerName(const std::string& name) { LLTextBox* box = getChild("estate_owner_text"); - if (box) box->setText(name); + box->setText(name); } void LLFloaterBuyLandUI::updateWebSiteInfo() @@ -640,9 +609,10 @@ void LLFloaterBuyLandUI::updateWebSiteInfo() S32 askBillableArea = mIsForGroup ? 0 : mParcelBillableArea; S32 askCurrencyBuy = mCurrency.getAmount(); - if (mTransaction && mTransactionType == TransactionPreflight - && mPreflightAskBillableArea == askBillableArea - && mPreflightAskCurrencyBuy == askCurrencyBuy) + if (mTransaction && + mTransactionType == TransactionPreflight && + mPreflightAskBillableArea == askBillableArea && + mPreflightAskCurrencyBuy == askCurrencyBuy) { return; } @@ -664,27 +634,21 @@ void LLFloaterBuyLandUI::updateWebSiteInfo() mSiteCurrencyEstimatedCost = 0; #endif - LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); - keywordArgs.appendString("agentId", gAgent.getID().asString()); - keywordArgs.appendString( - "secureSessionId", - gAgent.getSecureSessionID().asString()); - keywordArgs.appendString("language", LLUI::getLanguage()); - keywordArgs.appendInt("billableArea", mPreflightAskBillableArea); - keywordArgs.appendInt("currencyBuy", mPreflightAskCurrencyBuy); - - LLXMLRPCValue params = LLXMLRPCValue::createArray(); - params.append(keywordArgs); + LLSD params = LLSD::emptyMap(); + params["agentId"] = gAgent.getID().asString(); + params["secureSessionId"] = gAgent.getSecureSessionID().asString(); + params["language"] = LLUI::getLanguage(); + params["billableArea"] = mPreflightAskBillableArea; + params["currencyBuy"] = mPreflightAskCurrencyBuy; startTransaction(TransactionPreflight, params); } void LLFloaterBuyLandUI::finishWebSiteInfo() { + const LLSD& result = mTransaction->response(); - LLXMLRPCValue result = mTransaction->responseValue(); - - mSiteValid = result["success"].asBool(); + mSiteValid = result["success"].asBoolean(); if (!mSiteValid) { tellUserError( @@ -694,31 +658,30 @@ void LLFloaterBuyLandUI::finishWebSiteInfo() return; } - LLXMLRPCValue membership = result["membership"]; - mSiteMembershipUpgrade = membership["upgrade"].asBool(); + const LLSD& membership = result["membership"]; + mSiteMembershipUpgrade = membership["upgrade"].asBoolean(); mSiteMembershipAction = membership["action"].asString(); mSiteMembershipPlanIDs.clear(); mSiteMembershipPlanNames.clear(); - LLXMLRPCValue levels = membership["levels"]; - for (LLXMLRPCValue level = levels.rewind(); - level.isValid(); - level = levels.next()) + const LLSD& levels = membership["levels"]; + for (auto it = levels.beginArray(); it != levels.endArray(); ++it) { + const LLSD& level = *it; mSiteMembershipPlanIDs.push_back(level["id"].asString()); mSiteMembershipPlanNames.push_back(level["description"].asString()); } mUserPlanChoice = 0; - LLXMLRPCValue landUse = result["landUse"]; - mSiteLandUseUpgrade = landUse["upgrade"].asBool(); + const LLSD& landUse = result["landUse"]; + mSiteLandUseUpgrade = landUse["upgrade"].asBoolean(); mSiteLandUseAction = landUse["action"].asString(); - LLXMLRPCValue currency = result["currency"]; - if (currency["estimatedCost"].isValid()) + const LLSD& currency = result["currency"]; + if (currency.has("estimatedCost")) { - mCurrency.setUSDEstimate(currency["estimatedCost"].asInt()); + mCurrency.setUSDEstimate(currency["estimatedCost"].asInteger()); } - if (currency["estimatedLocalCost"].isValid()) + if (currency.has("estimatedLocalCost")) { mCurrency.setLocalEstimate(currency["estimatedLocalCost"].asString()); } @@ -760,35 +723,30 @@ void LLFloaterBuyLandUI::runWebSitePrep(const std::string& password) } } - LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); - keywordArgs.appendString("agentId", gAgent.getID().asString()); - keywordArgs.appendString( - "secureSessionId", - gAgent.getSecureSessionID().asString()); - keywordArgs.appendString("language", LLUI::getLanguage()); - keywordArgs.appendString("levelId", newLevel); - keywordArgs.appendInt("billableArea", - mIsForGroup ? 0 : mParcelBillableArea); - keywordArgs.appendInt("currencyBuy", mCurrency.getAmount()); - keywordArgs.appendInt("estimatedCost", mCurrency.getUSDEstimate()); - keywordArgs.appendString("estimatedLocalCost", mCurrency.getLocalEstimate()); - keywordArgs.appendString("confirm", mSiteConfirm); + LLSD params = LLSD::emptyMap(); + params["agentId"] = gAgent.getID().asString(); + params["secureSessionId"] = gAgent.getSecureSessionID().asString(); + params["language"] = LLUI::getLanguage(); + params["levelId"] = newLevel; + params["billableArea"] = mIsForGroup ? 0 : mParcelBillableArea; + params["currencyBuy"] = mCurrency.getAmount(); + params["estimatedCost"] = mCurrency.getUSDEstimate(); + params["estimatedLocalCost"] = mCurrency.getLocalEstimate(); + params["confirm"] = mSiteConfirm; + if (!password.empty()) { - keywordArgs.appendString("password", password); + params["password"] = password; } - LLXMLRPCValue params = LLXMLRPCValue::createArray(); - params.append(keywordArgs); - startTransaction(TransactionBuy, params); } void LLFloaterBuyLandUI::finishWebSitePrep() { - LLXMLRPCValue result = mTransaction->responseValue(); + const LLSD& result = mTransaction->response(); - bool success = result["success"].asBool(); + bool success = result["success"].asBoolean(); if (!success) { tellUserError( @@ -850,7 +808,7 @@ void LLFloaterBuyLandUI::updateGroupName(const LLUUID& id, } } -void LLFloaterBuyLandUI::startTransaction(TransactionType type, const LLXMLRPCValue& params) +void LLFloaterBuyLandUI::startTransaction(TransactionType type, const LLSD& params) { delete mTransaction; mTransaction = NULL; @@ -878,12 +836,7 @@ void LLFloaterBuyLandUI::startTransaction(TransactionType type, const LLXMLRPCVa return; } - mTransaction = new LLXMLRPCTransaction( - transaction_uri, - method, - params, - false /* don't use gzip */ - ); + mTransaction = new LLXMLRPCTransaction(transaction_uri, method, params); } bool LLFloaterBuyLandUI::checkTransaction() diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 282a273be6..d015c0ed95 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -33,9 +33,6 @@ #include "stringize.h" #include "llsdserialize.h" -// llmessage (!) -#include "llfiltersd2xmlrpc.h" // for xml_escape_string() - // login #include "lllogin.h" @@ -612,7 +609,7 @@ std::string construct_start_string() << position[VX] << "&" << position[VY] << "&" << position[VZ]); - start = xml_escape_string(unescaped_start); + start = LLStringFn::xml_encode(unescaped_start, true); break; } case LLSLURL::HOME_LOCATION: diff --git a/indra/newview/llslurl.cpp b/indra/newview/llslurl.cpp index 432ec3899a..d80cf2e80e 100644 --- a/indra/newview/llslurl.cpp +++ b/indra/newview/llslurl.cpp @@ -32,13 +32,15 @@ #include "llpanellogin.h" #include "llviewercontrol.h" #include "llviewernetwork.h" -#include "llfiltersd2xmlrpc.h" + #include "curl/curl.h" + const char* LLSLURL::SLURL_HTTP_SCHEME = "http"; const char* LLSLURL::SLURL_HTTPS_SCHEME = "https"; const char* LLSLURL::SLURL_SECONDLIFE_SCHEME = "secondlife"; const char* LLSLURL::SLURL_SECONDLIFE_PATH = "secondlife"; const char* LLSLURL::SLURL_COM = "slurl.com"; + // For DnD - even though www.slurl.com redirects to slurl.com in a browser, you can copy and drag // text with www.slurl.com or a link explicitly pointing at www.slurl.com so testing for this // version is required also. @@ -437,7 +439,7 @@ std::string LLSLURL::getLoginString() const LL_WARNS("AppInit") << "Unexpected SLURL type (" << (int)mType << ")for login string" << LL_ENDL; break; } - return xml_escape_string(unescaped_start.str()); + return LLStringFn::xml_encode(unescaped_start.str(), true); } bool LLSLURL::operator ==(const LLSLURL& rhs) diff --git a/indra/newview/llversioninfo.cpp b/indra/newview/llversioninfo.cpp index a571b5544b..4e8320b72a 100644 --- a/indra/newview/llversioninfo.cpp +++ b/indra/newview/llversioninfo.cpp @@ -76,37 +76,37 @@ LLVersionInfo::~LLVersionInfo() { } -S32 LLVersionInfo::getMajor() +S32 LLVersionInfo::getMajor() const { return LL_VIEWER_VERSION_MAJOR; } -S32 LLVersionInfo::getMinor() +S32 LLVersionInfo::getMinor() const { return LL_VIEWER_VERSION_MINOR; } -S32 LLVersionInfo::getPatch() +S32 LLVersionInfo::getPatch() const { return LL_VIEWER_VERSION_PATCH; } -U64 LLVersionInfo::getBuild() +U64 LLVersionInfo::getBuild() const { return LL_VIEWER_VERSION_BUILD; } -std::string LLVersionInfo::getVersion() +std::string LLVersionInfo::getVersion() const { return version; } -std::string LLVersionInfo::getShortVersion() +std::string LLVersionInfo::getShortVersion() const { return short_version; } -std::string LLVersionInfo::getChannelAndVersion() +std::string LLVersionInfo::getChannelAndVersion() const { if (mVersionChannel.empty()) { @@ -117,7 +117,7 @@ std::string LLVersionInfo::getChannelAndVersion() return mVersionChannel; } -std::string LLVersionInfo::getChannel() +std::string LLVersionInfo::getChannel() const { return mWorkingChannelName; } @@ -128,7 +128,7 @@ void LLVersionInfo::resetChannel(const std::string& channel) mVersionChannel.clear(); // Reset version and channel string til next use. } -LLVersionInfo::ViewerMaturity LLVersionInfo::getViewerMaturity() +LLVersionInfo::ViewerMaturity LLVersionInfo::getViewerMaturity() const { ViewerMaturity maturity; @@ -166,12 +166,12 @@ LLVersionInfo::ViewerMaturity LLVersionInfo::getViewerMaturity() } -std::string LLVersionInfo::getBuildConfig() +std::string LLVersionInfo::getBuildConfig() const { return build_configuration; } -std::string LLVersionInfo::getReleaseNotes() +std::string LLVersionInfo::getReleaseNotes() const { return mReleaseNotes; } diff --git a/indra/newview/llversioninfo.h b/indra/newview/llversioninfo.h index aed43263a6..237b37a084 100644 --- a/indra/newview/llversioninfo.h +++ b/indra/newview/llversioninfo.h @@ -52,38 +52,38 @@ public: ~LLVersionInfo(); /// return the major version number as an integer - S32 getMajor(); + S32 getMajor() const; /// return the minor version number as an integer - S32 getMinor(); + S32 getMinor() const; /// return the patch version number as an integer - S32 getPatch(); + S32 getPatch() const; /// return the build number as an integer - U64 getBuild(); + U64 getBuild() const; /// return the full viewer version as a string like "2.0.0.200030" - std::string getVersion(); + std::string getVersion() const; /// return the viewer version as a string like "2.0.0" - std::string getShortVersion(); + std::string getShortVersion() const; /// return the viewer version and channel as a string /// like "Second Life Release 2.0.0.200030" - std::string getChannelAndVersion(); + std::string getChannelAndVersion() const; /// return the channel name, e.g. "Second Life" - std::string getChannel(); + std::string getChannel() const; /// return the CMake build type - std::string getBuildConfig(); + std::string getBuildConfig() const; /// reset the channel name used by the viewer. void resetChannel(const std::string& channel); /// return the bit width of an address - S32 getAddressSize() { return ADDRESS_SIZE; } + S32 getAddressSize() const { return ADDRESS_SIZE; } typedef enum { @@ -92,11 +92,11 @@ public: BETA_VIEWER, RELEASE_VIEWER } ViewerMaturity; - ViewerMaturity getViewerMaturity(); + ViewerMaturity getViewerMaturity() const; /// get the release-notes URL, once it becomes available -- until then, /// return empty string - std::string getReleaseNotes(); + std::string getReleaseNotes() const; private: std::string version; @@ -107,7 +107,7 @@ private: std::string mWorkingChannelName; // Storage for the "version and channel" string. // This will get reset too. - std::string mVersionChannel; + mutable std::string mVersionChannel; std::string build_configuration; std::string mReleaseNotes; // Store unique_ptrs to the next couple things so we don't have to explain diff --git a/indra/newview/llxmlrpclistener.cpp b/indra/newview/llxmlrpclistener.cpp index 1148e81fd5..7c7bd98bcd 100644 --- a/indra/newview/llxmlrpclistener.cpp +++ b/indra/newview/llxmlrpclistener.cpp @@ -39,12 +39,6 @@ #include #include // boost::begin(), boost::end() -#ifdef LL_USESYSTEMLIBS -#include -#else -#include -#endif - #include "curl/curl.h" // other Linden headers @@ -178,13 +172,6 @@ public: static const CURLcodeMapper sCURLcodeMapper; -LLXMLRPCListener::LLXMLRPCListener(const std::string& pumpname): - mBoundListener(LLEventPumps::instance(). - obtain(pumpname). - listen("LLXMLRPCListener", boost::bind(&LLXMLRPCListener::process, this, _1))) -{ -} - /** * Capture an outstanding LLXMLRPCTransaction and poll it periodically until * done. @@ -213,38 +200,20 @@ public: mMethod(command["method"]), mReplyPump(command["reply"]) { - // LL_ERRS if any of these are missing - const char* required[] = { "uri", "method", "reply" }; - // optional: "options" (array of string) - // Validate the request - std::set missing; - for (const char** ri = boost::begin(required); ri != boost::end(required); ++ri) + // LL_ERRS if any of these keys are missing or empty + if (mUri.empty() || mMethod.empty() || mReplyPump.empty()) { - // If the command does not contain this required entry, add it to 'missing'. - if (! command.has(*ri)) - { - missing.insert(*ri); - } - } - if (! missing.empty()) - { - LL_ERRS("LLXMLRPCListener") << mMethod << " request missing params: "; - const char* separator = ""; - for (std::set::const_iterator mi(missing.begin()), mend(missing.end()); - mi != mend; ++mi) - { - LL_CONT << separator << *mi; - separator = ", "; - } - LL_CONT << LL_ENDL; + LL_ERRS("LLXMLRPCListener") + << "Some params are missing: " + << "reply: '" << mReplyPump << "', " + << "method: '" << mMethod << "', " + << "uri: '" << mUri << "'" + << LL_ENDL; } - // Build the XMLRPC request. - XMLRPC_REQUEST request = XMLRPC_RequestNew(); - XMLRPC_RequestSetMethodName(request, mMethod.c_str()); - XMLRPC_RequestSetRequestType(request, xmlrpc_request_call); - XMLRPC_VALUE xparams = XMLRPC_CreateVector(NULL, xmlrpc_vector_struct); - LLSD params(command["params"]); + LLSD request_params = LLSD::emptyMap(); + + LLSD params = command.get("params"); if (params.isMap()) { for (LLSD::map_const_iterator pi(params.beginMap()), pend(params.endMap()); @@ -252,44 +221,33 @@ public: { std::string name(pi->first); LLSD param(pi->second); - if (param.isString()) + switch (param.type()) { - XMLRPC_VectorAppendString(xparams, name.c_str(), param.asString().c_str(), 0); - } - else if (param.isInteger() || param.isBoolean()) - { - XMLRPC_VectorAppendInt(xparams, name.c_str(), param.asInteger()); - } - else if (param.isReal()) - { - XMLRPC_VectorAppendDouble(xparams, name.c_str(), param.asReal()); - } - else - { - LL_ERRS("LLXMLRPCListener") << mMethod << " request param " - << name << " has unknown type: " << param << LL_ENDL; + case LLSD::TypeString: + case LLSD::TypeInteger: + case LLSD::TypeReal: + request_params.insert(name, param); + break; + case LLSD::TypeBoolean: + request_params.insert(name, param.asInteger()); + break; + default: + LL_ERRS("LLXMLRPCListener") << mMethod + << " request param '" << name << "' has unknown type: " << param << LL_ENDL; } } } - LLSD options(command["options"]); + + LLSD options = command.get("options"); if (options.isArray()) { - XMLRPC_VALUE xoptions = XMLRPC_CreateVector("options", xmlrpc_vector_array); - for (LLSD::array_const_iterator oi(options.beginArray()), oend(options.endArray()); - oi != oend; ++oi) - { - XMLRPC_VectorAppendString(xoptions, NULL, oi->asString().c_str(), 0); - } - XMLRPC_AddValueToVector(xparams, xoptions); + request_params.insert("options", options); } - XMLRPC_RequestSetData(request, xparams); - mTransaction.reset(new LLXMLRPCTransaction(mUri, request, true, command.has("http_params")? LLSD(command["http_params"]) : LLSD())); + LLSD http_params = command.get("http_params"); + mTransaction.reset(new LLXMLRPCTransaction(mUri, mMethod, request_params, http_params)); mPreviousStatus = mTransaction->status(NULL); - // Free the XMLRPC_REQUEST object and the attached data values. - XMLRPC_RequestFree(request, 1); - // Now ensure that we get regular callbacks to poll for completion. mBoundListener = LLEventPumps::instance(). @@ -323,7 +281,7 @@ public: data["error"] = ""; data["transfer_rate"] = 0.0; LLEventPump& replyPump(LLEventPumps::instance().obtain(mReplyPump)); - if (! done) + if (!done) { // Not done yet, carry on. if (status == LLXMLRPCTransaction::StatusDownloading @@ -367,10 +325,8 @@ public: // Given 'message', need we care? if (status == LLXMLRPCTransaction::StatusComplete) { - // Success! Parse data. - std::string status_string(data["status"]); - data["responses"] = parseResponse(status_string); - data["status"] = status_string; + // Success! Retrieve response data. + data["responses"] = mTransaction->response(); } // whether successful or not, send reply on requested LLEventPump @@ -388,159 +344,6 @@ public: } private: - /// Derived from LLUserAuth::parseResponse() and parseOptionInto() - LLSD parseResponse(std::string& status_string) - { - // Extract every member into data["responses"] (a map of string - // values). - XMLRPC_REQUEST response = mTransaction->response(); - if (! response) - { - LL_DEBUGS("LLXMLRPCListener") << "No response" << LL_ENDL; - return LLSD(); - } - - XMLRPC_VALUE param = XMLRPC_RequestGetData(response); - if (! param) - { - LL_DEBUGS("LLXMLRPCListener") << "Response contains no data" << LL_ENDL; - return LLSD(); - } - - // Now, parse everything - return parseValues(status_string, "", param); - } - - LLSD parseValue(std::string& status_string, const std::string& key, const std::string& key_pfx, XMLRPC_VALUE param) - { - LLSD response; - - XMLRPC_VALUE_TYPE_EASY type = XMLRPC_GetValueTypeEasy(param); - switch (type) - { - case xmlrpc_type_empty: - LL_INFOS("LLXMLRPCListener") << "Empty result for key " << key_pfx << key << LL_ENDL; - break; - case xmlrpc_type_base64: - { - S32 len = XMLRPC_GetValueStringLen(param); - const char* buf = XMLRPC_GetValueBase64(param); - if ((len > 0) && buf) - { - // During implementation this code was not tested - // If you encounter this, please make sure this is correct, - // then remove llassert - llassert(0); - - LLSD::Binary data; - data.resize(len); - memcpy((void*)&data[0], (void*)buf, len); - response = data; - } - else - { - LL_WARNS("LLXMLRPCListener") << "Potentially malformed xmlrpc_type_base64 for key " - << key_pfx << key << LL_ENDL; - } - break; - } - case xmlrpc_type_boolean: - { - response = LLSD::Boolean(XMLRPC_GetValueBoolean(param)); - LL_DEBUGS("LLXMLRPCListener") << "val: " << response << LL_ENDL; - break; - } - case xmlrpc_type_datetime: - { - std::string iso8601_date(XMLRPC_GetValueDateTime_ISO8601(param)); - LL_DEBUGS("LLXMLRPCListener") << "val: " << iso8601_date << LL_ENDL; - response = LLSD::Date(iso8601_date); - break; - } - case xmlrpc_type_double: - { - response = LLSD::Real(XMLRPC_GetValueDouble(param)); - LL_DEBUGS("LLXMLRPCListener") << "val: " << response << LL_ENDL; - break; - } - case xmlrpc_type_int: - { - response = LLSD::Integer(XMLRPC_GetValueInt(param)); - LL_DEBUGS("LLXMLRPCListener") << "val: " << response << LL_ENDL; - break; - } - case xmlrpc_type_string: - { - response = LLSD::String(XMLRPC_GetValueString(param)); - LL_DEBUGS("LLXMLRPCListener") << "val: " << response << LL_ENDL; - break; - } - case xmlrpc_type_mixed: - case xmlrpc_type_array: - { - // We expect this to be an array of submaps. Walk the array, - // recursively parsing each submap and collecting them. - LLSD array; - int i = 0; // for descriptive purposes - for (XMLRPC_VALUE row = XMLRPC_VectorRewind(param); row; - row = XMLRPC_VectorNext(param), ++i) - { - // Recursive call. For the lower-level key_pfx, if 'key' - // is "foo", pass "foo[0]:", then "foo[1]:", etc. In the - // nested call, a subkey "bar" will then be logged as - // "foo[0]:bar", and so forth. - // Parse the scalar subkey/value pairs from this array - // entry into a temp submap. Collect such submaps in 'array'. - - array.append(parseValue(status_string, "", - STRINGIZE(key_pfx << key << '[' << i << "]:"), - row)); - } - // Having collected an 'array' of 'submap's, insert that whole - // 'array' as the value of this 'key'. - response = array; - break; - } - case xmlrpc_type_struct: - { - response = parseValues(status_string, - STRINGIZE(key_pfx << key << ':'), - param); - break; - } - case xmlrpc_type_none: // Not expected - default: - // whoops - unrecognized type - LL_WARNS("LLXMLRPCListener") << "Unhandled xmlrpc type " << type << " for key " - << key_pfx << key << LL_ENDL; - response = STRINGIZE("'); - status_string = "BadType"; - } - return response; - } - - /** - * Parse key/value pairs from a given XMLRPC_VALUE into an LLSD map. - * @param key_pfx Used to describe a given key in log messages. At top - * level, pass "". When parsing an options array, pass the top-level key - * name of the array plus the index of the array entry; to this we'll - * append the subkey of interest. - * @param param XMLRPC_VALUE iterator. At top level, pass - * XMLRPC_RequestGetData(XMLRPC_REQUEST). - */ - LLSD parseValues(std::string& status_string, const std::string& key_pfx, XMLRPC_VALUE param) - { - LLSD responses; - for (XMLRPC_VALUE current = XMLRPC_VectorRewind(param); current; - current = XMLRPC_VectorNext(param)) - { - std::string key(XMLRPC_GetValueID(current)); - LL_DEBUGS("LLXMLRPCListener") << "key: " << key_pfx << key << LL_ENDL; - responses.insert(key, parseValue(status_string, key, key_pfx, current)); - } - return responses; - } - const LLReqID mReqID; const std::string mUri; const std::string mMethod; @@ -550,11 +353,18 @@ private: LLXMLRPCTransaction::EStatus mPreviousStatus; // To detect state changes. }; -bool LLXMLRPCListener::process(const LLSD& command) +LLXMLRPCListener::LLXMLRPCListener(const std::string& pumpname) +: mBoundListener(LLEventPumps::instance().obtain(pumpname).listen +( + "LLXMLRPCListener", + [&](const LLSD& command) -> bool + { + // Allocate a new heap Poller, but do not save a pointer to it. Poller + // will check its own status and free itself on completion of the request. + (new Poller(command)); + // Conventional event listener return + return false; + } +)) { - // Allocate a new heap Poller, but do not save a pointer to it. Poller - // will check its own status and free itself on completion of the request. - (new Poller(command)); - // conventional event listener return - return false; } diff --git a/indra/newview/llxmlrpclistener.h b/indra/newview/llxmlrpclistener.h index aaed98eec5..fd75acb8b1 100644 --- a/indra/newview/llxmlrpclistener.h +++ b/indra/newview/llxmlrpclistener.h @@ -42,9 +42,6 @@ public: /// Specify the pump name on which to listen LLXMLRPCListener(const std::string& pumpname); - /// Handle request events on the event pump specified at construction time - bool process(const LLSD& command); - private: LLTempBoundListener mBoundListener; }; diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index ec6e22cd7a..55622fb6b7 100644 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -42,22 +42,11 @@ #include "bufferarray.h" #include "llversioninfo.h" #include "llviewercontrol.h" +#include "llxmlnode.h" #include "stringize.h" // Have to include these last to avoid queue redefinition! -#ifdef LL_USESYSTEMLIBS -#include -#else -#include -#endif -// contains a harmful #define queue xmlrpc_queue. This -// breaks any use of std::queue. Ditch that #define: if any of our code wants -// to reference xmlrpc_queue, let it reference it directly. -#if defined(queue) -#undef queue -#endif - #include "llappviewer.h" #include "lltrans.h" @@ -75,111 +64,6 @@ namespace boost // nothing. static LLXMLRPCListener listener("LLXMLRPCTransaction"); -LLXMLRPCValue LLXMLRPCValue::operator[](const char* id) const -{ - return LLXMLRPCValue(XMLRPC_VectorGetValueWithID(mV, id)); -} - -std::string LLXMLRPCValue::asString() const -{ - const char* s = XMLRPC_GetValueString(mV); - return s ? s : ""; -} - -int LLXMLRPCValue::asInt() const { return XMLRPC_GetValueInt(mV); } -bool LLXMLRPCValue::asBool() const { return XMLRPC_GetValueBoolean(mV) != 0; } -double LLXMLRPCValue::asDouble() const { return XMLRPC_GetValueDouble(mV); } - -LLXMLRPCValue LLXMLRPCValue::rewind() -{ - return LLXMLRPCValue(XMLRPC_VectorRewind(mV)); -} - -LLXMLRPCValue LLXMLRPCValue::next() -{ - return LLXMLRPCValue(XMLRPC_VectorNext(mV)); -} - -bool LLXMLRPCValue::isValid() const -{ - return mV != NULL; -} - -LLXMLRPCValue LLXMLRPCValue::createArray() -{ - return LLXMLRPCValue(XMLRPC_CreateVector(NULL, xmlrpc_vector_array)); -} - -LLXMLRPCValue LLXMLRPCValue::createStruct() -{ - return LLXMLRPCValue(XMLRPC_CreateVector(NULL, xmlrpc_vector_struct)); -} - - -void LLXMLRPCValue::append(LLXMLRPCValue& v) -{ - XMLRPC_AddValueToVector(mV, v.mV); -} - -void LLXMLRPCValue::appendString(const std::string& v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueString(NULL, v.c_str(), 0)); -} - -void LLXMLRPCValue::appendInt(int v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueInt(NULL, v)); -} - -void LLXMLRPCValue::appendBool(bool v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueBoolean(NULL, v)); -} - -void LLXMLRPCValue::appendDouble(double v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueDouble(NULL, v)); -} - - -void LLXMLRPCValue::append(const char* id, LLXMLRPCValue& v) -{ - XMLRPC_SetValueID(v.mV, id, 0); - XMLRPC_AddValueToVector(mV, v.mV); -} - -void LLXMLRPCValue::appendString(const char* id, const std::string& v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueString(id, v.c_str(), 0)); -} - -void LLXMLRPCValue::appendInt(const char* id, int v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueInt(id, v)); -} - -void LLXMLRPCValue::appendBool(const char* id, bool v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueBoolean(id, v)); -} - -void LLXMLRPCValue::appendDouble(const char* id, double v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueDouble(id, v)); -} - -void LLXMLRPCValue::cleanup() -{ - XMLRPC_CleanupValue(mV); - mV = NULL; -} - -XMLRPC_VALUE LLXMLRPCValue::getValue() const -{ - return mV; -} - - class LLXMLRPCTransaction::Handler : public LLCore::HttpHandler { public: @@ -192,6 +76,9 @@ public: private: + bool parseResponse(LLXMLNodePtr root); + bool parseValue(LLSD& target, LLXMLNodePtr source); + LLXMLRPCTransaction::Impl *mImpl; LLCore::HttpRequest::ptr_t mRequest; }; @@ -213,26 +100,26 @@ public: LLCore::HttpHandle mPostH; std::string mURI; - std::string mProxyAddress; std::string mResponseText; - XMLRPC_REQUEST mResponse; + LLSD mResponseData; + std::string mCertStore; - LLSD mErrorCertData; + LLSD mErrorCertData; - Impl(const std::string& uri, XMLRPC_REQUEST request, bool useGzip, const LLSD& httpParams); - Impl(const std::string& uri, - const std::string& method, LLXMLRPCValue params, bool useGzip); - ~Impl(); + Impl + ( + const std::string& uri, + const std::string& method, + const LLSD& params, + const LLSD& httpParams + ); bool process(); void setStatus(EStatus code, const std::string& message = "", const std::string& uri = ""); void setHttpStatus(const LLCore::HttpStatus &status); - -private: - void init(XMLRPC_REQUEST request, bool useGzip, const LLSD& httpParams); }; LLXMLRPCTransaction::Handler::Handler(LLCore::HttpRequest::ptr_t &request, @@ -275,89 +162,113 @@ void LLXMLRPCTransaction::Handler::onCompleted(LLCore::HttpHandle handle, mImpl->setStatus(LLXMLRPCTransaction::StatusComplete); mImpl->mTransferStats = response->getTransferStats(); - // the contents of a buffer array are potentially noncontiguous, so we + // The contents of a buffer array are potentially noncontiguous, so we // will need to copy them into an contiguous block of memory for XMLRPC. LLCore::BufferArray *body = response->getBody(); - char * bodydata = new char[body->size()]; + mImpl->mResponseText.resize(body->size()); - body->read(0, bodydata, body->size()); + body->read(0, mImpl->mResponseText.data(), body->size()); - mImpl->mResponse = XMLRPC_REQUEST_FromXML(bodydata, static_cast(body->size()), 0); + LLXMLNodePtr root; + if (!LLXMLNode::parseBuffer(mImpl->mResponseText.data(), body->size(), root, nullptr)) + { + LL_WARNS() << "Failed parsing XML response; request URI: " << mImpl->mURI << LL_ENDL; + return; + } - delete[] bodydata; + if (!parseResponse(root)) + return; - bool hasError = false; - bool hasFault = false; - int faultCode = 0; - std::string faultString; + LL_INFOS() << "XML response parsed successfully; request URI: " << mImpl->mURI << LL_ENDL; +} - LLXMLRPCValue error(XMLRPC_RequestGetError(mImpl->mResponse)); - if (error.isValid()) +struct XMLTreeNode final : public LLSD::TreeNode +{ + XMLTreeNode(const LLXMLNodePtr impl) + : mImpl(impl) + , mFirstChild(impl ? create(impl->getFirstChild()) : nullptr) + , mNextSibling(impl ? create(impl->getNextSibling()) : nullptr) { - hasError = true; - faultCode = error["faultCode"].asInt(); - faultString = error["faultString"].asString(); } - else if (XMLRPC_ResponseIsFault(mImpl->mResponse)) + + static XMLTreeNode* create(LLXMLNodePtr node) { return node ? new XMLTreeNode(node) : nullptr; } + + virtual bool hasName(const LLSD::String& name) const override { return mImpl && mImpl->hasName(name); } + virtual LLSD::String getTextContents() const override { return mImpl ? mImpl->getTextContents() : LLStringUtil::null; } + virtual TreeNode* getFirstChild() const override { return mFirstChild.get(); } + virtual TreeNode* getNextSibling() const override { return mNextSibling.get(); } + +private: + const LLXMLNodePtr mImpl; + const std::shared_ptr mFirstChild; + const std::shared_ptr mNextSibling; +}; + +bool LLXMLRPCTransaction::Handler::parseResponse(LLXMLNodePtr root) +{ + // We have alreasy checked in LLXMLNode::parseBuffer() + // that root contains exactly one child + if (!root->hasName("methodResponse")) { - hasFault = true; - faultCode = XMLRPC_GetResponseFaultCode(mImpl->mResponse); - faultString = XMLRPC_GetResponseFaultString(mImpl->mResponse); + LL_WARNS() << "Invalid root element in XML response; request URI: " << mImpl->mURI << LL_ENDL; + return false; } - if (hasError || hasFault) + LLXMLNodePtr first = root->getFirstChild(); + LLXMLNodePtr second = first->getFirstChild(); + if (!first->getNextSibling() && second && !second->getNextSibling()) { - mImpl->setStatus(LLXMLRPCTransaction::StatusXMLRPCError); - - LL_WARNS() << "LLXMLRPCTransaction XMLRPC " - << (hasError ? "error " : "fault ") - << faultCode << ": " - << faultString << LL_ENDL; - LL_WARNS() << "LLXMLRPCTransaction request URI: " - << mImpl->mURI << LL_ENDL; + if (first->hasName("fault")) + { + LLSD fault; + if (parseValue(fault, second) && + fault.isMap() && fault.has("faultCode") && fault.has("faultString")) + { + LL_WARNS() << "Request failed;" + << " faultCode: '" << fault.get("faultCode").asString() << "'," + << " faultString: '" << fault.get("faultString").asString() << "'," + << " request URI: " << mImpl->mURI << LL_ENDL; + return false; + } + } + else if (first->hasName("params") && + second->hasName("param") && !second->getNextSibling()) + { + LLXMLNodePtr third = second->getFirstChild(); + if (third && !third->getNextSibling() && parseValue(mImpl->mResponseData, third)) + { + return true; + } + } } -} - -//========================================================================= + LL_WARNS() << "Invalid response format; request URI: " << mImpl->mURI << LL_ENDL; -LLXMLRPCTransaction::Impl::Impl(const std::string& uri, - XMLRPC_REQUEST request, bool useGzip, const LLSD& httpParams) - : mHttpRequest(), - mStatus(LLXMLRPCTransaction::StatusNotStarted), - mURI(uri), - mResponse(0) -{ - init(request, useGzip, httpParams); + return false; } - -LLXMLRPCTransaction::Impl::Impl(const std::string& uri, - const std::string& method, LLXMLRPCValue params, bool useGzip) - : mHttpRequest(), - mStatus(LLXMLRPCTransaction::StatusNotStarted), - mURI(uri), - mResponse(0) +bool LLXMLRPCTransaction::Handler::parseValue(LLSD& target, LLXMLNodePtr source) { - XMLRPC_REQUEST request = XMLRPC_RequestNew(); - XMLRPC_RequestSetMethodName(request, method.c_str()); - XMLRPC_RequestSetRequestType(request, xmlrpc_request_call); - XMLRPC_RequestSetData(request, params.getValue()); - - init(request, useGzip, LLSD()); - // DEV-28398: without this XMLRPC_RequestFree() call, it looks as though - // the 'request' object is simply leaked. It's less clear to me whether we - // should also ask to free request value data (second param 1), since the - // data come from 'params'. - XMLRPC_RequestFree(request, 1); + XMLTreeNode tn(source); + return target.fromXMLRPCValue(&tn); } -void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip, const LLSD& httpParams) +//========================================================================= + +LLXMLRPCTransaction::Impl::Impl +( + const std::string& uri, + const std::string& method, + const LLSD& params, + const LLSD& http_params +) + : mHttpRequest() + , mStatus(LLXMLRPCTransaction::StatusNotStarted) + , mURI(uri) { LLCore::HttpOptions::ptr_t httpOpts; LLCore::HttpHeaders::ptr_t httpHeaders; - if (!mHttpRequest) { mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest); @@ -366,37 +277,34 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip, const // LLRefCounted starts with a 1 ref, so don't add a ref in the smart pointer httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()); - // delay between repeats will start from 5 sec and grow to 20 sec with each repeat + // Delay between repeats will start from 5 sec and grow to 20 sec with each repeat httpOpts->setMinBackoff(5E6L); httpOpts->setMaxBackoff(20E6L); - httpOpts->setTimeout(httpParams.has("timeout") ? httpParams["timeout"].asInteger() : 40L); - if (httpParams.has("retries")) + httpOpts->setTimeout(http_params.has("timeout") ? http_params["timeout"].asInteger() : 40L); + if (http_params.has("retries")) { - httpOpts->setRetries(httpParams["retries"].asInteger()); + httpOpts->setRetries(http_params["retries"].asInteger()); } - if (httpParams.has("DNSCacheTimeout")) + if (http_params.has("DNSCacheTimeout")) { - httpOpts->setDNSCacheTimeout(httpParams["DNSCacheTimeout"].asInteger()); + httpOpts->setDNSCacheTimeout(http_params["DNSCacheTimeout"].asInteger()); } bool vefifySSLCert = !gSavedSettings.getBOOL("NoVerifySSLCert"); mCertStore = gSavedSettings.getString("CertStore"); - httpOpts->setSSLVerifyPeer( vefifySSLCert ); - httpOpts->setSSLVerifyHost( vefifySSLCert ? 2 : 0); + httpOpts->setSSLVerifyPeer(vefifySSLCert); + httpOpts->setSSLVerifyHost(vefifySSLCert ? 2 : 0); // LLRefCounted starts with a 1 ref, so don't add a ref in the smart pointer httpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()); httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_TEXT_XML); - std::string user_agent = stringize( - LLVersionInfo::instance().getChannel(), ' ', - LLVersionInfo::instance().getMajor(), '.', - LLVersionInfo::instance().getMinor(), '.', - LLVersionInfo::instance().getPatch(), " (", - LLVersionInfo::instance().getBuild(), ')'); + const LLVersionInfo& vi(LLVersionInfo::instance()); + std::string user_agent = vi.getChannel() + llformat(" %d.%d.%d (%llu)", + vi.getMajor(), vi.getMinor(), vi.getPatch(), vi.getBuild()); httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, user_agent); @@ -404,31 +312,19 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip, const //This might help with bug #503 */ //httpOpts->setDNSCacheTimeout(-1); - LLCore::BufferArray::ptr_t body = LLCore::BufferArray::ptr_t(new LLCore::BufferArray()); + std::string request = + "" + method + + "" + params.asXMLRPCValue() + + ""; - // TODO: See if there is a way to serialize to a preallocated buffer I'm - // not fond of the copy here. - int requestSize(0); - char * requestText = XMLRPC_REQUEST_ToXML(request, &requestSize); - - body->append(requestText, requestSize); + LLCore::BufferArray::ptr_t body = LLCore::BufferArray::ptr_t(new LLCore::BufferArray()); - XMLRPC_Free(requestText); + body->append(request.c_str(), request.size()); - mHandler = LLXMLRPCTransaction::Handler::ptr_t(new Handler( mHttpRequest, this )); + mHandler = LLXMLRPCTransaction::Handler::ptr_t(new Handler(mHttpRequest, this)); mPostH = mHttpRequest->requestPost(LLCore::HttpRequest::DEFAULT_POLICY_ID, mURI, body.get(), httpOpts, httpHeaders, mHandler); - -} - - -LLXMLRPCTransaction::Impl::~Impl() -{ - if (mResponse) - { - XMLRPC_RequestFree(mResponse, 1); - } } bool LLXMLRPCTransaction::Impl::process() @@ -539,18 +435,16 @@ void LLXMLRPCTransaction::Impl::setHttpStatus(const LLCore::HttpStatus &status) } - -LLXMLRPCTransaction::LLXMLRPCTransaction( - const std::string& uri, XMLRPC_REQUEST request, bool useGzip, const LLSD& httpParams) -: impl(* new Impl(uri, request, useGzip, httpParams)) -{ } - - -LLXMLRPCTransaction::LLXMLRPCTransaction( +LLXMLRPCTransaction::LLXMLRPCTransaction +( const std::string& uri, - const std::string& method, LLXMLRPCValue params, bool useGzip) -: impl(* new Impl(uri, method, params, useGzip)) -{ } + const std::string& method, + const LLSD& params, + const LLSD& http_params +) +: impl(*new Impl(uri, method, params, http_params)) +{ +} LLXMLRPCTransaction::~LLXMLRPCTransaction() { @@ -590,14 +484,9 @@ std::string LLXMLRPCTransaction::statusURI() return impl.mStatusURI; } -XMLRPC_REQUEST LLXMLRPCTransaction::response() -{ - return impl.mResponse; -} - -LLXMLRPCValue LLXMLRPCTransaction::responseValue() +const LLSD& LLXMLRPCTransaction::response() { - return LLXMLRPCValue(XMLRPC_RequestGetData(impl.mResponse)); + return impl.mResponseData; } diff --git a/indra/newview/llxmlrpctransaction.h b/indra/newview/llxmlrpctransaction.h index 4c8796f936..f7a38f5f90 100644 --- a/indra/newview/llxmlrpctransaction.h +++ b/indra/newview/llxmlrpctransaction.h @@ -29,73 +29,22 @@ #include -typedef struct _xmlrpc_request* XMLRPC_REQUEST; -typedef struct _xmlrpc_value* XMLRPC_VALUE; - // foward decl of types from xmlrpc.h (this usage is type safe) -class LLCertificate; - -class LLXMLRPCValue - // a c++ wrapper around XMLRPC_VALUE -{ -public: - LLXMLRPCValue() : mV(NULL) { } - LLXMLRPCValue(XMLRPC_VALUE value) : mV(value) { } - - bool isValid() const; - - std::string asString() const; - int asInt() const; - bool asBool() const; - double asDouble() const; - - LLXMLRPCValue operator[](const char*) const; - - LLXMLRPCValue rewind(); - LLXMLRPCValue next(); - - static LLXMLRPCValue createArray(); - static LLXMLRPCValue createStruct(); - - void append(LLXMLRPCValue&); - void appendString(const std::string&); - void appendInt(int); - void appendBool(bool); - void appendDouble(double); - void appendValue(LLXMLRPCValue&); - - void append(const char*, LLXMLRPCValue&); - void appendString(const char*, const std::string&); - void appendInt(const char*, int); - void appendBool(const char*, bool); - void appendDouble(const char*, double); - void appendValue(const char*, LLXMLRPCValue&); - - void cleanup(); - // only call this on the top level created value - - XMLRPC_VALUE getValue() const; - -private: - XMLRPC_VALUE mV; -}; - - +/// An asynchronous request and responses via XML-RPC class LLXMLRPCTransaction - // an asynchronous request and responses via XML-RPC { public: - LLXMLRPCTransaction(const std::string& uri, - XMLRPC_REQUEST request, bool useGzip = true, const LLSD& httpParams = LLSD()); - // does not take ownership of the request object - // request can be freed as soon as the transaction is constructed - - LLXMLRPCTransaction(const std::string& uri, - const std::string& method, LLXMLRPCValue params, bool useGzip = true); - // *does* take control of the request value, you must not free it + LLXMLRPCTransaction + ( + const std::string& uri, + const std::string& method, + const LLSD& params, + const LLSD& http_params = LLSD() + ); ~LLXMLRPCTransaction(); - typedef enum e_status { + typedef enum e_status + { StatusNotStarted, StatusStarted, StatusDownloading, @@ -105,26 +54,25 @@ public: StatusOtherError } EStatus; + /// Run the request a little, returns true when done bool process(); - // run the request a little, returns true when done + /// Return a status, and extended CURL code, if code isn't null EStatus status(int* curlCode); - // return status, and extended CURL code, if code isn't null LLSD getErrorCertData(); + + /// Return a message string, suitable for showing the user std::string statusMessage(); - // return a message string, suitable for showing the user + + /// Return a URI for the user with more information (can be empty) std::string statusURI(); - // return a URI for the user with more information - // can be empty - XMLRPC_REQUEST response(); - LLXMLRPCValue responseValue(); - // only valid if StatusComplete, otherwise NULL - // retains ownership of the result object, don't free it + /// Only non-empty if StatusComplete, otherwise Undefined + const LLSD& response(); + /// Only valid if StsatusComplete, otherwise 0.0 F64 transferRate(); - // only valid if StsatusComplete, otherwise 0.0 private: class Handler; @@ -133,6 +81,4 @@ private: Impl& impl; }; - - #endif // LLXMLRPCTRANSACTION_H diff --git a/indra/newview/skins/default/xui/da/floater_about.xml b/indra/newview/skins/default/xui/da/floater_about.xml index 7bcae69779..604eb7c58f 100644 --- a/indra/newview/skins/default/xui/da/floater_about.xml +++ b/indra/newview/skins/default/xui/da/floater_about.xml @@ -69,7 +69,6 @@ OpenSSL Copyright (C) 1998-2002 The OpenSSL Project. PCRE Copyright (c) 1997-2008 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) -xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler. google-perftools Copyright (c) 2005, Google Inc. diff --git a/indra/newview/skins/default/xui/de/floater_about.xml b/indra/newview/skins/default/xui/de/floater_about.xml index 10ccf0d5da..320db7f654 100644 --- a/indra/newview/skins/default/xui/de/floater_about.xml +++ b/indra/newview/skins/default/xui/de/floater_about.xml @@ -28,7 +28,6 @@ mit Open-Source-Beiträgen von: PCRE Copyright (c) 1997-2012 University of Cambridge. SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga. SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com). - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly und Mark Adler. diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml index ff2fa93cbb..126cd84d56 100644 --- a/indra/newview/skins/default/xui/en/floater_about.xml +++ b/indra/newview/skins/default/xui/en/floater_about.xml @@ -111,7 +111,6 @@ Dummy Name replaced at run time PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler. diff --git a/indra/newview/skins/default/xui/es/floater_about.xml b/indra/newview/skins/default/xui/es/floater_about.xml index e14ba32f69..8103a95376 100644 --- a/indra/newview/skins/default/xui/es/floater_about.xml +++ b/indra/newview/skins/default/xui/es/floater_about.xml @@ -28,7 +28,6 @@ con contribuciones de código abierto de: PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly y Mark Adler. diff --git a/indra/newview/skins/default/xui/fr/floater_about.xml b/indra/newview/skins/default/xui/fr/floater_about.xml index 09da1fb5fd..b6ea621177 100644 --- a/indra/newview/skins/default/xui/fr/floater_about.xml +++ b/indra/newview/skins/default/xui/fr/floater_about.xml @@ -28,7 +28,6 @@ avec les contributions Open Source de : PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-Loup Gailly et Mark Adler. diff --git a/indra/newview/skins/default/xui/it/floater_about.xml b/indra/newview/skins/default/xui/it/floater_about.xml index 7e195d3ca9..77be47d749 100644 --- a/indra/newview/skins/default/xui/it/floater_about.xml +++ b/indra/newview/skins/default/xui/it/floater_about.xml @@ -28,7 +28,6 @@ con contributi open source da: PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly e Mark Adler. diff --git a/indra/newview/skins/default/xui/ja/floater_about.xml b/indra/newview/skins/default/xui/ja/floater_about.xml index 12d763be37..6cd22f6a31 100644 --- a/indra/newview/skins/default/xui/ja/floater_about.xml +++ b/indra/newview/skins/default/xui/ja/floater_about.xml @@ -33,7 +33,6 @@ OpenSSL Copyright (C) 1998-2008 The OpenSSL Project. PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) -xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler. diff --git a/indra/newview/skins/default/xui/pt/floater_about.xml b/indra/newview/skins/default/xui/pt/floater_about.xml index aaed728f84..0e95c53109 100644 --- a/indra/newview/skins/default/xui/pt/floater_about.xml +++ b/indra/newview/skins/default/xui/pt/floater_about.xml @@ -28,7 +28,6 @@ com contribuições de código aberto de: PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler. diff --git a/indra/newview/skins/default/xui/ru/floater_about.xml b/indra/newview/skins/default/xui/ru/floater_about.xml index a65a979ccd..22827bc397 100644 --- a/indra/newview/skins/default/xui/ru/floater_about.xml +++ b/indra/newview/skins/default/xui/ru/floater_about.xml @@ -28,7 +28,6 @@ PCRE (c) 1997-2012, Кембриджский университет SDL (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib (C) 1995-2012 Jean-loup Gailly и Mark Adler. diff --git a/indra/newview/skins/default/xui/tr/floater_about.xml b/indra/newview/skins/default/xui/tr/floater_about.xml index 40ca3707c3..ca21bee464 100644 --- a/indra/newview/skins/default/xui/tr/floater_about.xml +++ b/indra/newview/skins/default/xui/tr/floater_about.xml @@ -28,7 +28,6 @@ açık kaynak kod katkısında bulunanlar şunlardır: PCRE Telif Hakkı (c) 1997-2012 University of Cambridge SDL Telif Hakkı (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Telif Hakkı (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Telif Hakkı (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Telif Hakkı (C) 1995-2012 Jean-loup Gailly ve Mark Adler. diff --git a/indra/newview/skins/default/xui/zh/floater_about.xml b/indra/newview/skins/default/xui/zh/floater_about.xml index a56ae753d1..727f598894 100644 --- a/indra/newview/skins/default/xui/zh/floater_about.xml +++ b/indra/newview/skins/default/xui/zh/floater_about.xml @@ -28,7 +28,6 @@ PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler. -- cgit v1.2.3 From 5a60b7811fb666f2ef59abc57a3204297f6aaa1a Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Fri, 28 Jun 2024 14:54:53 -0700 Subject: secondlife/viewer#1847: Fix wrong lighting for negative texture scale on PBR materials and PBR terrain --- .../shaders/class1/deferred/pbralphaV.glsl | 7 +- .../shaders/class1/deferred/pbropaqueV.glsl | 7 +- .../shaders/class1/deferred/pbrterrainF.glsl | 29 +++++++-- .../shaders/class1/deferred/pbrterrainUtilF.glsl | 12 +++- .../shaders/class1/deferred/pbrterrainV.glsl | 23 ++++--- .../shaders/class1/deferred/textureUtilV.glsl | 74 +++++++++++++++------- 6 files changed, 105 insertions(+), 47 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl index ae179d3f37..66adf50fa9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl @@ -69,7 +69,7 @@ flat out float vary_sign; out vec3 vary_normal; vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); -vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); +vec4 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); void main() @@ -103,8 +103,9 @@ void main() n = normalize(n); - vary_tangent = normalize(tangent_space_transform(vec4(t, tangent.w), n, texture_normal_transform, texture_matrix0)); - vary_sign = tangent.w; + vec4 transformed_tangent = tangent_space_transform(vec4(t, tangent.w), n, texture_normal_transform, texture_matrix0); + vary_tangent = normalize(transformed_tangent.xyz); + vary_sign = transformed_tangent.w; vary_normal = n; vertex_color = diffuse_color; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl index fd020afd57..0ad9bf5e4b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -63,7 +63,7 @@ out vec3 vary_normal; out vec3 vary_position; vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); -vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); +vec4 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); void main() { @@ -97,8 +97,9 @@ void main() n = normalize(n); - vary_tangent = normalize(tangent_space_transform(vec4(t, tangent.w), n, texture_normal_transform, texture_matrix0)); - vary_sign = tangent.w; + vec4 transformed_tangent = tangent_space_transform(vec4(t, tangent.w), n, texture_normal_transform, texture_matrix0); + vary_tangent = normalize(transformed_tangent.xyz); + vary_sign = transformed_tangent.w; vary_normal = n; vertex_color = diffuse_color; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl index 2cb7ff196b..6ca35419f2 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl @@ -75,6 +75,9 @@ PBRMix terrain_sample_and_multiply_pbr( #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , sampler2D tex_vNt +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , float transform_sign +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , sampler2D tex_emissive @@ -139,7 +142,7 @@ in vec3 vary_position; in vec3 vary_normal; #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) in vec3 vary_tangents[4]; -flat in float vary_sign; +flat in float vary_signs[4]; #endif in vec4 vary_texcoord0; in vec4 vary_texcoord1; @@ -150,11 +153,11 @@ float terrain_mix(TerrainMix tm, vec4 tms4); #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) // from mikktspace.com -vec3 mikktspace(vec3 vNt, vec3 vT) +vec3 mikktspace(vec3 vNt, vec3 vT, float sign) { vec3 vN = vary_normal; - vec3 vB = vary_sign * cross(vN, vT); + vec3 vB = sign * cross(vN, vT); vec3 tnorm = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN ); tnorm *= gl_FrontFacing ? 1.0 : -1.0; @@ -216,6 +219,9 @@ void main() #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , detail_0_normal +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , vary_signs[0] +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , detail_0_emissive @@ -231,7 +237,7 @@ void main() #endif ); #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) - mix2.vNt = mikktspace(mix2.vNt, vary_tangents[0]); + mix2.vNt = mikktspace(mix2.vNt, vary_tangents[0], vary_signs[0]); #endif pbr_mix = mix_pbr(pbr_mix, mix2, tm.weight.x); break; @@ -258,6 +264,9 @@ void main() #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , detail_1_normal +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , vary_signs[1] +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , detail_1_emissive @@ -273,7 +282,7 @@ void main() #endif ); #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) - mix2.vNt = mikktspace(mix2.vNt, vary_tangents[1]); + mix2.vNt = mikktspace(mix2.vNt, vary_tangents[1], vary_signs[1]); #endif pbr_mix = mix_pbr(pbr_mix, mix2, tm.weight.y); break; @@ -300,6 +309,9 @@ void main() #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , detail_2_normal +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , vary_signs[2] +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , detail_2_emissive @@ -315,7 +327,7 @@ void main() #endif ); #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) - mix2.vNt = mikktspace(mix2.vNt, vary_tangents[2]); + mix2.vNt = mikktspace(mix2.vNt, vary_tangents[2], vary_signs[2]); #endif pbr_mix = mix_pbr(pbr_mix, mix2, tm.weight.z); break; @@ -342,6 +354,9 @@ void main() #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , detail_3_normal +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , vary_signs[3] +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , detail_3_emissive @@ -357,7 +372,7 @@ void main() #endif ); #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) - mix2.vNt = mikktspace(mix2.vNt, vary_tangents[3]); + mix2.vNt = mikktspace(mix2.vNt, vary_tangents[3], vary_signs[3]); #endif pbr_mix = mix_pbr(pbr_mix, mix2, tm.weight.w); break; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl index 1ae9efe544..5098de717e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl @@ -256,11 +256,12 @@ vec3 _t_normal_post_1(vec3 vNt0, float sign_or_zero) } // Triplanar-specific normal texture fixes -vec3 _t_normal_post_x(vec3 vNt0) +vec3 _t_normal_post_x(vec3 vNt0, float tangent_sign) { vec3 vNt_x = _t_normal_post_1(vNt0, sign(vary_vertex_normal.x)); // *HACK: Transform normals according to orientation of the UVs vNt_x.xy = vec2(-vNt_x.y, vNt_x.x); + vNt_x.xy *= tangent_sign; return vNt_x; } vec3 _t_normal_post_y(vec3 vNt0) @@ -285,6 +286,7 @@ PBRMix terrain_sample_pbr( #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , sampler2D tex_vNt + , float tangent_sign #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , sampler2D tex_emissive @@ -314,7 +316,7 @@ PBRMix terrain_sample_pbr( ); #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) // Triplanar-specific normal texture fix - mix_x.vNt = _t_normal_post_x(mix_x.vNt); + mix_x.vNt = _t_normal_post_x(mix_x.vNt, tangent_sign); #endif mix = mix_pbr(mix, mix_x, tw.weight.x); break; @@ -420,6 +422,9 @@ PBRMix terrain_sample_and_multiply_pbr( #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , sampler2D tex_vNt +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , float tangent_sign +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , sampler2D tex_emissive @@ -446,6 +451,9 @@ PBRMix terrain_sample_and_multiply_pbr( #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , tex_vNt +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , tangent_sign +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , tex_emissive diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl index f8e826bbdb..c90b2b5926 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl @@ -43,7 +43,7 @@ out vec3 vary_vertex_normal; // Used by pbrterrainUtilF.glsl out vec3 vary_normal; #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) out vec3 vary_tangents[4]; -flat out float vary_sign; +flat out float vary_signs[4]; #endif out vec4 vary_texcoord0; out vec4 vary_texcoord1; @@ -60,7 +60,7 @@ out vec3 vary_position; uniform vec4[5] terrain_texture_transforms; vec2 terrain_texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform); -vec3 terrain_tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform); +vec4 terrain_tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform); void main() { @@ -75,28 +75,35 @@ void main() #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) { vec4[2] ttt; + vec4 transformed_tangent; // material 1 ttt[0].xyz = terrain_texture_transforms[0].xyz; ttt[1].x = terrain_texture_transforms[0].w; ttt[1].y = terrain_texture_transforms[1].x; - vary_tangents[0] = normalize(terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt)); + transformed_tangent = terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt); + vary_tangents[0] = normalize(transformed_tangent.xyz); + vary_signs[0] = transformed_tangent.w; // material 2 ttt[0].xyz = terrain_texture_transforms[1].yzw; ttt[1].xy = terrain_texture_transforms[2].xy; - vary_tangents[1] = normalize(terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt)); + transformed_tangent = terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt); + vary_tangents[1] = normalize(transformed_tangent.xyz); + vary_signs[1] = transformed_tangent.w; // material 3 ttt[0].xy = terrain_texture_transforms[2].zw; ttt[0].z = terrain_texture_transforms[3].x; ttt[1].xy = terrain_texture_transforms[3].yz; - vary_tangents[2] = normalize(terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt)); + transformed_tangent = terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt); + vary_tangents[2] = normalize(transformed_tangent.xyz); + vary_signs[2] = transformed_tangent.w; // material 4 ttt[0].x = terrain_texture_transforms[3].w; ttt[0].yz = terrain_texture_transforms[4].xy; ttt[1].xy = terrain_texture_transforms[4].zw; - vary_tangents[3] = normalize(terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt)); + transformed_tangent = terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt); + vary_tangents[3] = normalize(transformed_tangent.xyz); + vary_signs[3] = transformed_tangent.w; } - - vary_sign = tangent.w; #endif vary_normal = normalize(n); diff --git a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl index 767416d564..c75a0e0d5d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl @@ -94,36 +94,48 @@ vec2 terrain_texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform) // Take the rotation only from both transforms and apply to the tangent. This // accounts for the change of the topology of the normal texture when a texture // rotation is applied to it. +// In practice, this applies the inverse of the texture transform to the tangent. +// It is effectively an inverse of the rotation // *HACK: Assume the imported GLTF model did not have both normal texture // transforms and tangent vertices. The use of this function is inconsistent // with the GLTF sample viewer when that is the case. See getNormalInfo in // https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Viewer/47a191931461a6f2e14de48d6da0f0eb6ec2d147/source/Renderer/shaders/material_info.glsl // We may want to account for this case during GLTF model import. // -Cosmic,2023-06-06 -vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform) +vec4 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform) { - vec2 weights = vec2(0, 1); - - // Apply texture animation first to avoid shearing and other artifacts (rotation only) - mat2 sl_rot_scale; - sl_rot_scale[0][0] = sl_animation_transform[0][0]; - sl_rot_scale[0][1] = sl_animation_transform[0][1]; - sl_rot_scale[1][0] = sl_animation_transform[1][0]; - sl_rot_scale[1][1] = sl_animation_transform[1][1]; - weights = sl_rot_scale * weights; - // Remove scale - weights = normalize(weights); - - // Convert to left-handed coordinate system - weights.y = -weights.y; + // Immediately convert to left-handed coordinate system, but it has no + // effect here because y is 0 ((1,0) -> (1,0)) + vec2 weights = vec2(1, 0); - // Apply KHR_texture_transform (rotation only) - float khr_rotation = khr_gltf_transform[0].z; + // Apply inverse KHR_texture_transform (rotation and scale sign only) + float khr_rotation = -khr_gltf_transform[0].z; mat2 khr_rotation_mat = mat2( cos(khr_rotation),-sin(khr_rotation), sin(khr_rotation), cos(khr_rotation) ); weights = khr_rotation_mat * weights; + vec2 khr_scale_sign = sign(khr_gltf_transform[0].xy); + weights *= khr_scale_sign.xy; + + // *NOTE: Delay conversion to right-handed coordinate system here, to + // remove the need for computing the inverse of the SL texture animation + // matrix. + + // Apply texture animation last to avoid shearing and other artifacts (rotation only) + mat2 inv_sl_rot_scale; + inv_sl_rot_scale[0][0] = sl_animation_transform[0][0]; + inv_sl_rot_scale[0][1] = sl_animation_transform[0][1]; + inv_sl_rot_scale[1][0] = sl_animation_transform[1][0]; + inv_sl_rot_scale[1][1] = sl_animation_transform[1][1]; + weights = inv_sl_rot_scale * weights; + // *NOTE: Scale to be removed later + + // Set weights to default if 0 for some reason + weights.x += 1.0 - abs(sign(sign(weights.x) + (0.5 * sign(weights.y)))); + + // Remove scale from SL texture animation transform + weights = normalize(weights); // Convert back to right-handed coordinate system weights.y = -weights.y; @@ -132,27 +144,41 @@ vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] kh // from the normal and tangent, as seen in the fragment shader vec3 vertex_binormal = vertex_tangent.w * cross(vertex_normal, vertex_tangent.xyz); - return (weights.x * vertex_binormal.xyz) + (weights.y * vertex_tangent.xyz); + // An additional sign flip prevents the binormal from being flipped as a + // result of a propagation of the tangent sign during the cross product. + float sign_flip = khr_scale_sign.x * khr_scale_sign.y; + return vec4((weights.x * vertex_tangent.xyz) + (weights.y * vertex_binormal.xyz), vertex_tangent.w * sign_flip); } // Similar to tangent_space_transform but no texture animation support. -vec3 terrain_tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform) +vec4 terrain_tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform) { - // Immediately convert to left-handed coordinate system ((0,1) -> (0, -1)) - vec2 weights = vec2(0, -1); + // Immediately convert to left-handed coordinate system, but it has no + // effect here because y is 0 ((1,0) -> (1,0)) + vec2 weights = vec2(1, 0); - // Apply KHR_texture_transform (rotation only) - float khr_rotation = khr_gltf_transform[0].z; + // Apply inverse KHR_texture_transform (rotation and scale sign only) + float khr_rotation = -khr_gltf_transform[0].z; mat2 khr_rotation_mat = mat2( cos(khr_rotation),-sin(khr_rotation), sin(khr_rotation), cos(khr_rotation) ); weights = khr_rotation_mat * weights; + vec2 khr_scale_sign = sign(khr_gltf_transform[0].xy); + weights *= khr_scale_sign.xy; + + // Set weights to default if 0 for some reason + weights.x += 1.0 - abs(sign(sign(weights.x) + (0.5 * sign(weights.y)))); // Convert back to right-handed coordinate system weights.y = -weights.y; + // Similar to the MikkTSpace-compatible method of extracting the binormal + // from the normal and tangent, as seen in the fragment shader vec3 vertex_binormal = vertex_tangent.w * cross(vertex_normal, vertex_tangent.xyz); - return (weights.x * vertex_binormal.xyz) + (weights.y * vertex_tangent.xyz); + // An additional sign flip prevents the binormal from being flipped as a + // result of a propagation of the tangent sign during the cross product. + float sign_flip = khr_scale_sign.x * khr_scale_sign.y; + return vec4((weights.x * vertex_tangent.xyz) + (weights.y * vertex_binormal.xyz), vertex_tangent.w * sign_flip); } -- cgit v1.2.3 From 49d60e0ded52c095c834e9ca134b67282728b389 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Mon, 1 Jul 2024 22:24:32 -0400 Subject: Reduce string temporaries from LLFloaterReg find/get --- indra/newview/llfloatersidepanelcontainer.cpp | 10 +++++----- indra/newview/llfloatersidepanelcontainer.h | 12 ++++++------ indra/newview/llfloaterwebcontent.cpp | 2 +- indra/newview/llsidetraypanelcontainer.cpp | 4 ++-- indra/newview/llsidetraypanelcontainer.h | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloatersidepanelcontainer.cpp b/indra/newview/llfloatersidepanelcontainer.cpp index 2f6d14d6b5..48547852c4 100644 --- a/indra/newview/llfloatersidepanelcontainer.cpp +++ b/indra/newview/llfloatersidepanelcontainer.cpp @@ -113,7 +113,7 @@ LLFloater* LLFloaterSidePanelContainer::getTopmostInventoryFloater() return topmost_floater; } -LLPanel* LLFloaterSidePanelContainer::openChildPanel(const std::string& panel_name, const LLSD& params) +LLPanel* LLFloaterSidePanelContainer::openChildPanel(std::string_view panel_name, const LLSD& params) { LLView* view = findChildView(panel_name, true); if (!view) @@ -144,7 +144,7 @@ LLPanel* LLFloaterSidePanelContainer::openChildPanel(const std::string& panel_na return panel; } -void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const LLSD& key) +void LLFloaterSidePanelContainer::showPanel(std::string_view floater_name, const LLSD& key) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance(floater_name); if (floaterp) @@ -153,7 +153,7 @@ void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, con } } -void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key) +void LLFloaterSidePanelContainer::showPanel(std::string_view floater_name, std::string_view panel_name, const LLSD& key) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance(floater_name); if (floaterp) @@ -162,7 +162,7 @@ void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, con } } -LLPanel* LLFloaterSidePanelContainer::getPanel(const std::string& floater_name, const std::string& panel_name) +LLPanel* LLFloaterSidePanelContainer::getPanel(std::string_view floater_name, std::string_view panel_name) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance(floater_name); @@ -174,7 +174,7 @@ LLPanel* LLFloaterSidePanelContainer::getPanel(const std::string& floater_name, return NULL; } -LLPanel* LLFloaterSidePanelContainer::findPanel(const std::string& floater_name, const std::string& panel_name) +LLPanel* LLFloaterSidePanelContainer::findPanel(std::string_view floater_name, std::string_view panel_name) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::findTypedInstance(floater_name); diff --git a/indra/newview/llfloatersidepanelcontainer.h b/indra/newview/llfloatersidepanelcontainer.h index d5d0c43cae..19d6c747cb 100644 --- a/indra/newview/llfloatersidepanelcontainer.h +++ b/indra/newview/llfloatersidepanelcontainer.h @@ -55,17 +55,17 @@ public: void cleanup() { destroy(); } - LLPanel* openChildPanel(const std::string& panel_name, const LLSD& params); + LLPanel* openChildPanel(std::string_view panel_name, const LLSD& params); static LLFloater* getTopmostInventoryFloater(); - static void showPanel(const std::string& floater_name, const LLSD& key); + static void showPanel(std::string_view floater_name, const LLSD& key); - static void showPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key); + static void showPanel(std::string_view floater_name, std::string_view panel_name, const LLSD& key); - static LLPanel* getPanel(const std::string& floater_name, const std::string& panel_name = sMainPanelName); + static LLPanel* getPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName); - static LLPanel* findPanel(const std::string& floater_name, const std::string& panel_name = sMainPanelName); + static LLPanel* findPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName); /** * Gets the panel of given type T (doesn't show it or do anything else with it). @@ -75,7 +75,7 @@ public: * @returns a pointer to the panel of given type T. */ template - static T* getPanel(const std::string& floater_name, const std::string& panel_name = sMainPanelName) + static T* getPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName) { T* panel = dynamic_cast(getPanel(floater_name, panel_name)); if (!panel) diff --git a/indra/newview/llfloaterwebcontent.cpp b/indra/newview/llfloaterwebcontent.cpp index f5b5b8293f..e1b6df6072 100644 --- a/indra/newview/llfloaterwebcontent.cpp +++ b/indra/newview/llfloaterwebcontent.cpp @@ -220,7 +220,7 @@ void LLFloaterWebContent::preCreate(LLFloaterWebContent::Params& p) // showInstance will open a new window. Figure out how many web browsers are already open, // and close the least recently opened one if this will put us over the limit. - LLFloaterReg::const_instance_list_t &instances = LLFloaterReg::getFloaterList(p.window_class); + LLFloaterReg::const_instance_list_t &instances = LLFloaterReg::getFloaterList(p.window_class()); if(instances.size() >= (size_t)browser_window_limit) { diff --git a/indra/newview/llsidetraypanelcontainer.cpp b/indra/newview/llsidetraypanelcontainer.cpp index eb8e05ec27..44e0c3b05c 100644 --- a/indra/newview/llsidetraypanelcontainer.cpp +++ b/indra/newview/llsidetraypanelcontainer.cpp @@ -62,10 +62,10 @@ void LLSideTrayPanelContainer::onOpen(const LLSD& key) getCurrentPanel()->onOpen(key); } -void LLSideTrayPanelContainer::openPanel(const std::string& panel_name, const LLSD& key) +void LLSideTrayPanelContainer::openPanel(std::string_view panel_name, const LLSD& key) { LLSD combined_key = key; - combined_key[PARAM_SUB_PANEL_NAME] = panel_name; + combined_key[PARAM_SUB_PANEL_NAME] = std::string(panel_name); onOpen(combined_key); } diff --git a/indra/newview/llsidetraypanelcontainer.h b/indra/newview/llsidetraypanelcontainer.h index 5dfd7f2d83..0017d7743f 100644 --- a/indra/newview/llsidetraypanelcontainer.h +++ b/indra/newview/llsidetraypanelcontainer.h @@ -59,7 +59,7 @@ public: /** * Opens given subpanel. */ - void openPanel(const std::string& panel_name, const LLSD& key = LLSD::emptyMap()); + void openPanel(std::string_view panel_name, const LLSD& key = LLSD::emptyMap()); /** * Opens previous panel from panel navigation history. -- cgit v1.2.3 From b0e30477e93bb16b0cf8c7b64aaee35cedf85ca8 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Mon, 1 Jul 2024 22:25:56 -0400 Subject: Use heterogeneous comparison for string_view map finds in LLControl and convert controlExists to string_view --- indra/newview/llappviewer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 85ede793e2..51099a480d 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2393,7 +2393,7 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key, std::string full_settings_path; if (file.file_name_setting.isProvided() - && gSavedSettings.controlExists(file.file_name_setting)) + && gSavedSettings.controlExists(file.file_name_setting())) { // try to find filename stored in file_name_setting control full_settings_path = gSavedSettings.getString(file.file_name_setting()); -- cgit v1.2.3 From 3fa6db9603a020402eea8c61622b0cab27dbcca3 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Mon, 1 Jul 2024 22:50:39 -0400 Subject: Reduce string temporaries from LLTrans --- indra/newview/lllogininstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index d015c0ed95..f37926a938 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -447,7 +447,7 @@ void LLLoginInstance::handleLoginFailure(const LLSD& event) gViewerWindow->setShowProgress(false); } - showMFAChallange(LLTrans::getString(response["message_id"])); + showMFAChallange(LLTrans::getString(response["message_id"].asString())); } else if( reason_response == "key" || reason_response == "presence" -- cgit v1.2.3 From fad6a3753757778d4b50d46f44aabd0d3fa3e13b Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Mon, 1 Jul 2024 22:58:25 -0400 Subject: Fix test builds --- indra/newview/tests/lldateutil_test.cpp | 15 ++++++++++----- indra/newview/tests/lllogininstance_test.cpp | 4 ++-- indra/newview/tests/llslurl_test.cpp | 4 ++-- indra/newview/tests/llviewernetwork_test.cpp | 4 ++-- indra/newview/tests/llworldmap_test.cpp | 2 +- 5 files changed, 17 insertions(+), 12 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/tests/lldateutil_test.cpp b/indra/newview/tests/lldateutil_test.cpp index e9d4982e35..151aadfd4b 100644 --- a/indra/newview/tests/lldateutil_test.cpp +++ b/indra/newview/tests/lldateutil_test.cpp @@ -38,18 +38,23 @@ // Baked-in return values for getString() -std::map< std::string, std::string > gString; +std::map< std::string, std::string, std::less<>> gString; // Baked-in return values for getCountString() // map of pairs of input xml_desc and integer count typedef std::pair< std::string, int > count_string_t; std::map< count_string_t, std::string > gCountString; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(const std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { - std::string text = gString[xml_desc]; - LLStringUtil::format(text, args); - return text; + auto it = gString.find(xml_desc); + if (it != gString.end()) + { + std::string text = it->second; + LLStringUtil::format(text, args); + return text; + } + return {}; } std::string LLTrans::getCountString(const std::string& language, const std::string& xml_desc, S32 count) diff --git a/indra/newview/tests/lllogininstance_test.cpp b/indra/newview/tests/lllogininstance_test.cpp index df0f006d02..bff2289a7c 100644 --- a/indra/newview/tests/lllogininstance_test.cpp +++ b/indra/newview/tests/lllogininstance_test.cpp @@ -79,7 +79,7 @@ LLProgressView * LLViewerWindow::getProgressView(void) const { return 0; } LLViewerWindow* gViewerWindow; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { return std::string("test_trans"); } @@ -235,7 +235,7 @@ static LLEventPump * gTOSReplyPump = NULL; LLPointer gSecAPIHandler; //static -LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key, bool focus) +LLFloater* LLFloaterReg::showInstance(std::string_view name, const LLSD& key, bool focus) { gTOSType = name; gTOSReplyPump = &LLEventPumps::instance().obtain(key["reply_pump"]); diff --git a/indra/newview/tests/llslurl_test.cpp b/indra/newview/tests/llslurl_test.cpp index 3be44a9bd5..fc9f5b707a 100644 --- a/indra/newview/tests/llslurl_test.cpp +++ b/indra/newview/tests/llslurl_test.cpp @@ -46,10 +46,10 @@ static const char * const TEST_FILENAME("llslurl_test.xml"); class LLTrans { public: - static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); + static std::string getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); }; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { return std::string(); } diff --git a/indra/newview/tests/llviewernetwork_test.cpp b/indra/newview/tests/llviewernetwork_test.cpp index 40c2059d27..d9cb9e7538 100644 --- a/indra/newview/tests/llviewernetwork_test.cpp +++ b/indra/newview/tests/llviewernetwork_test.cpp @@ -45,10 +45,10 @@ static const char * const TEST_FILENAME("llviewernetwork_test.xml"); class LLTrans { public: - static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); + static std::string getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); }; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { std::string grid_label = std::string(); if(xml_desc == "AgniGridLabel") diff --git a/indra/newview/tests/llworldmap_test.cpp b/indra/newview/tests/llworldmap_test.cpp index 8564dbeeb6..d5bf189d82 100644 --- a/indra/newview/tests/llworldmap_test.cpp +++ b/indra/newview/tests/llworldmap_test.cpp @@ -66,7 +66,7 @@ void LLWorldMipmap::equalizeBoostLevels() { } LLPointer LLWorldMipmap::getObjectsTile(U32 grid_x, U32 grid_y, S32 level, bool load) { return NULL; } // Stub other stuff -std::string LLTrans::getString(const std::string &, const LLStringUtil::format_map_t&, bool def_string) { return std::string("test_trans"); } +std::string LLTrans::getString(std::string_view, const LLStringUtil::format_map_t&, bool def_string) { return std::string("test_trans"); } void LLUIString::updateResult() const { } void LLUIString::setArg(const std::string& , const std::string& ) { } void LLUIString::assign(const std::string& ) { } -- cgit v1.2.3 From 14cbf331cbf345bac83606ee5f56c994694420b3 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Tue, 2 Jul 2024 08:56:42 -0400 Subject: Reduce string temporaries from LLTabContainer, LLMenuGL, LLLayoutStack, and LLKeywords using string_view --- indra/newview/llfloaterpreference.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 85a07f23a4..0ec2024994 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1910,7 +1910,7 @@ void LLFloaterPreference::setCacheLocation(const LLStringExplicit& location) void LLFloaterPreference::selectPanel(const LLSD& name) { LLTabContainer * tab_containerp = getChild("pref core"); - LLPanel * panel = tab_containerp->getPanelByName(name); + LLPanel * panel = tab_containerp->getPanelByName(name.asStringRef()); if (NULL != panel) { tab_containerp->selectTabPanel(panel); -- cgit v1.2.3 From c19d766812dd744fdd1c91992f92f27794735c79 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 2 Jul 2024 18:23:03 +0300 Subject: viewer#1907 Shader initialization error --- .../newview/app_settings/shaders/class1/deferred/normgenF.glsl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl b/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl index 6d05d983f3..607a8c6ef6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl @@ -64,14 +64,14 @@ float getBumpValue(vec2 texcoord) void main() { - float c = getBumpValue(vary_texcoord0).r; + float c = getBumpValue(vary_texcoord0); float scaler = 512.0; - vec3 right = vec3(norm_scale, 0, (getBumpValue(vary_texcoord0+vec2(stepX, 0)).r-c)*scaler); - vec3 left = vec3(-norm_scale, 0, (getBumpValue(vary_texcoord0-vec2(stepX, 0)).r-c)*scaler); - vec3 up = vec3(0, -norm_scale, (getBumpValue(vary_texcoord0-vec2(0, stepY)).r-c)*scaler); - vec3 down = vec3(0, norm_scale, (getBumpValue(vary_texcoord0+vec2(0, stepY)).r-c)*scaler); + vec3 right = vec3(norm_scale, 0, (getBumpValue(vary_texcoord0+vec2(stepX, 0))-c)*scaler); + vec3 left = vec3(-norm_scale, 0, (getBumpValue(vary_texcoord0-vec2(stepX, 0))-c)*scaler); + vec3 up = vec3(0, -norm_scale, (getBumpValue(vary_texcoord0-vec2(0, stepY))-c)*scaler); + vec3 down = vec3(0, norm_scale, (getBumpValue(vary_texcoord0+vec2(0, stepY))-c)*scaler); vec3 norm = cross(right, down) + cross(down, left) + cross(left,up) + cross(up, right); -- cgit v1.2.3 From cb2795748eec373b11154c2825a3ecf2633938be Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 2 Jul 2024 19:01:46 +0300 Subject: viewer#1905 Fix "Share" and "Pay" buttons' state in nearby list --- indra/newview/llpanelpeoplemenus.cpp | 7 +++++-- .../skins/default/xui/en/menu_people_nearby_multiselect.xml | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelpeoplemenus.cpp b/indra/newview/llpanelpeoplemenus.cpp index 172c7d0828..f8a73ddb46 100644 --- a/indra/newview/llpanelpeoplemenus.cpp +++ b/indra/newview/llpanelpeoplemenus.cpp @@ -245,11 +245,14 @@ bool PeopleContextMenu::enableContextMenuItem(const LLSD& userdata) { return LLLogChat::isTranscriptExist(mUUIDs.front()); } - else if (item == std::string("can_im") || item == std::string("can_invite") || - item == std::string("can_share") || item == std::string("can_pay")) + else if (item == std::string("can_im") || item == std::string("can_invite")) { return true; } + else if (item == std::string("can_share") || item == std::string("can_pay")) + { + return mUUIDs.size() == 1; + } return false; } diff --git a/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml b/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml index 63185b537c..61738e73db 100644 --- a/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml +++ b/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml @@ -48,6 +48,9 @@ name="share"> + + Date: Tue, 2 Jul 2024 11:44:14 +0300 Subject: viewer#1857 Reset texture transforms when terrain PBR is applied ctrls aren't dynamically alocated so getChild is preferable, but since other elements use findchild and validy checks used findChild as well --- indra/newview/llfloaterregioninfo.cpp | 27 ++++++++++++++++++++++++++- indra/newview/llfloaterregioninfo.h | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index c019bd047d..d6ffab5825 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -1561,7 +1561,7 @@ bool LLPanelRegionTerrainInfo::postBuild() { mTextureDetailCtrl[i]->setBakeTextureEnabled(false); } - initAndSetCtrl(mMaterialDetailCtrl[i], llformat("material_detail_%d", i)); + initMaterialCtrl(mMaterialDetailCtrl[i], llformat("material_detail_%d", i), i); initAndSetCtrl(mMaterialScaleUCtrl[i], llformat("terrain%dScaleU", i)); initAndSetCtrl(mMaterialScaleVCtrl[i], llformat("terrain%dScaleV", i)); @@ -1958,6 +1958,31 @@ bool LLPanelRegionTerrainInfo::sendUpdate() return true; } +void LLPanelRegionTerrainInfo::initMaterialCtrl(LLTextureCtrl*& ctrl, const std::string& name, S32 index) +{ + ctrl = findChild(name, true); + if (!ctrl) return; + + // consume cancel events, otherwise they will trigger commit callbacks + ctrl->setOnCancelCallback([](LLUICtrl* ctrl, const LLSD& param) {}); + ctrl->setCommitCallback( + [this, index](LLUICtrl* ctrl, const LLSD& param) + { + if (!mMaterialScaleUCtrl[index] + || !mMaterialScaleVCtrl[index] + || !mMaterialRotationCtrl[index] + || !mMaterialOffsetUCtrl[index] + || !mMaterialOffsetVCtrl[index]) return; + + mMaterialScaleUCtrl[index]->setValue(1.f); + mMaterialScaleVCtrl[index]->setValue(1.f); + mMaterialRotationCtrl[index]->setValue(0.f); + mMaterialOffsetUCtrl[index]->setValue(0.f); + mMaterialOffsetVCtrl[index]->setValue(0.f); + onChangeAnything(); + }); +} + bool LLPanelRegionTerrainInfo::callbackTextureHeights(const LLSD& notification, const LLSD& response) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 5623bc20cb..60564435d7 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -273,6 +273,8 @@ public: protected: bool sendUpdate() override; + void initMaterialCtrl(LLTextureCtrl*& ctrl, const std::string& name, S32 index); + private: bool mConfirmedTextureHeights; bool mAskedTextureHeights; -- cgit v1.2.3 From 475d0df4c152972665c978f7b0991f8726def03a Mon Sep 17 00:00:00 2001 From: Beq Janus Date: Tue, 2 Jul 2024 18:57:39 +0100 Subject: Experimental fix for blurry textures (#1875) This change removes the distance based bias (which is a large contributor to premature blurring) but adds a check using the importance factor to give some balance. importance should be between 0 and 1 and is higher when the texture is facing the camera, lower when it is side on, The unimportance setting defines the cutoff vaklue below which we'll consider the textures worth "down scaling" by the bias factor. The setting is inplace to allow us to play with this, 0.25 is current default. Note this change moves the calcPixelArea() call to the top BEFORE we user getPixelArea(). Either that call is entirely redundant (i.e. if calc was called earlier in the frame) or we were using the stale pixelArea (one frame behind). If the former is true then it might be faster to just do an AABB frustum check. --- indra/newview/app_settings/settings.xml | 13 +++++++++++++ indra/newview/llviewertexturelist.cpp | 12 +++++------- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index c455b6f5f1..e56facd615 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -11289,6 +11289,19 @@ Value 8.0 + TextureBiasUnimportantFactor + + Comment + When biasing textures to lower resolution due to lack of vram, the importance threshold below which is considered unimportant and getting an extra bias. + Persist + 1 + Type + F32 + Value + 0.25 + Backup + 0 + TextureDecodeDisabled Comment diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 4d8fd8ddd5..2f685474e1 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -931,6 +931,10 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag if (face && face->getViewerObject() && face->getTextureEntry()) { + F32 radius; + F32 cos_angle_to_view_dir; + BOOL in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius); + static LLCachedControl bias_unimportant_threshold(gSavedSettings, "TextureBiasUnimportantFactor", 0.25f); F32 vsize = face->getPixelArea(); // Scale desired texture resolution higher or lower depending on texture scale @@ -944,13 +948,7 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag min_scale = llclamp(min_scale*min_scale, texture_scale_min(), texture_scale_max()); vsize /= min_scale; - vsize /= LLViewerTexture::sDesiredDiscardBias; - vsize /= llmax(1.f, (LLViewerTexture::sDesiredDiscardBias-1.f) * (1.f + face->getDrawable()->mDistanceWRTCamera * bias_distance_scale)); - - F32 radius; - F32 cos_angle_to_view_dir; - bool in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius); - if (!in_frustum || !face->getDrawable()->isVisible()) + if (!in_frustum || !face->getDrawable()->isVisible() || face->getImportanceToCamera() < bias_unimportant_threshold) { // further reduce by discard bias when off screen or occluded vsize /= LLViewerTexture::sDesiredDiscardBias; } -- cgit v1.2.3 From 2e836ab06f934038394b46e9c861312c0441b657 Mon Sep 17 00:00:00 2001 From: Beq Janus Date: Tue, 2 Jul 2024 18:59:30 +0100 Subject: LL Issue#1835 - Input delays introduced in PBR viewers. (#1889) --- indra/newview/llappviewer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 08fbbaa390..32d3df4f83 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -338,7 +338,7 @@ private: }; // consts from viewer.h -const S32 AGENT_UPDATES_PER_SECOND = 10; +const S32 AGENT_UPDATES_PER_SECOND = 125; // Value derived experimentally to avoid Input Delays with latest PBR-Capable Viewers when viewer FPS is highly volatile. const S32 AGENT_FORCE_UPDATES_PER_SECOND = 1; // Globals with external linkage. From viewer.h -- cgit v1.2.3 From b276936ef336a17e4c124da40c1c63b2829fc680 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 2 Jul 2024 11:01:35 -0700 Subject: Quick fix for a possible merge bug from featurettes. (#1715) --- indra/newview/pipeline.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6c9c4751d7..b9b1264b16 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -776,9 +776,11 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; if (mRT == &mMainRT) { // hacky -- allocate auxillary buffer + + gCubeSnapshot = TRUE; + if (sReflectionProbesEnabled) { - gCubeSnapshot = true; mReflectionMapManager.initReflectionMaps(); } -- cgit v1.2.3 From 1adb94a89c106176e01d950170b9c4d623dd2250 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 2 Jul 2024 20:39:39 +0300 Subject: viewer#1666 Allow switching 2k textures off in bulk uploads --- indra/newview/CMakeLists.txt | 2 + indra/newview/app_settings/settings.xml | 11 ++ indra/newview/llfloaterbulkupload.cpp | 139 ++++++++++++++++++++ indra/newview/llfloaterbulkupload.h | 66 ++++++++++ indra/newview/llmaterialeditor.cpp | 4 +- indra/newview/llviewerassetupload.cpp | 5 +- indra/newview/llviewerassetupload.h | 4 +- indra/newview/llviewerfloaterreg.cpp | 10 +- indra/newview/llviewermenufile.cpp | 122 +++++++++++------ indra/newview/llviewermenufile.h | 16 ++- .../skins/default/xui/en/floater_bulk_upload.xml | 144 +++++++++++++++++++++ .../newview/skins/default/xui/en/notifications.xml | 11 -- 12 files changed, 468 insertions(+), 66 deletions(-) create mode 100644 indra/newview/llfloaterbulkupload.cpp create mode 100644 indra/newview/llfloaterbulkupload.h create mode 100644 indra/newview/skins/default/xui/en/floater_bulk_upload.xml (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index cbcc85cc1c..d4c2875c6c 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -189,6 +189,7 @@ set(viewer_SOURCE_FILES llfloaterbigpreview.cpp llfloaterbuildoptions.cpp llfloaterbulkpermission.cpp + llfloaterbulkupload.cpp llfloaterbump.cpp llfloaterbuy.cpp llfloaterbuycontents.cpp @@ -852,6 +853,7 @@ set(viewer_HEADER_FILES llfloaterbigpreview.h llfloaterbuildoptions.h llfloaterbulkpermission.h + llfloaterbulkupload.h llfloaterbump.h llfloaterbuy.h llfloaterbuycontents.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index e56facd615..09909aa9c4 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1094,6 +1094,17 @@ Value 0 + BulkUpload2KTextures + + Comment + Bulk upload scales textures to 2K if true, to 1K if false + Persist + 1 + Type + Boolean + Value + 1 + EnableButtonFlashing Comment diff --git a/indra/newview/llfloaterbulkupload.cpp b/indra/newview/llfloaterbulkupload.cpp new file mode 100644 index 0000000000..98875ee84d --- /dev/null +++ b/indra/newview/llfloaterbulkupload.cpp @@ -0,0 +1,139 @@ +/** + * @file llfloaterbulkupload.cpp + * @author Andrey Kleshchev + * @brief LLFloaterBulkUpload class implementation + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloaterbulkupload.h" + +#include "lltextbox.h" +#include "llviewercontrol.h" +#include "llviewermenufile.h" + +constexpr S32 MAX_HEIGH = 211; + +LLFloaterBulkUpload::LLFloaterBulkUpload(const LLSD& key) +: LLModalDialog(key, true) +{ + mUploadCost = key["upload_cost"].asInteger(); + mUploadCount = key["upload_count"].asInteger(); + mHas2kTextures = key["has_2k_textures"].asBoolean(); + if (key["files"].isArray()) + { + const LLSD& files = key["files"]; + for (LLSD::array_const_iterator it = files.beginArray(); + it != files.endArray(); + ++it) + { + mFiles.push_back(it->asString()); + } + } +} + +LLFloaterBulkUpload::~LLFloaterBulkUpload() +{ +} + +bool LLFloaterBulkUpload::postBuild() +{ + childSetAction("upload_btn", [this](void*) { onClickUpload(); }, this); + childSetAction("cancel_btn", [this](void*) { onClickCancel(); }, this); + + mCountLabel = getChild("number_of_items", true); + mCostLabel = getChild("upload_cost", true); + + mCheckboxPanel = getChild("checkbox_panel", true); + mLinkPanel = getChild("link_panel", true); + mWarningPanel = getChild("warning_panel", true); + + mCheckboxUpload2K = getChild("upload_2k"); + mCheckboxUpload2K->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& data) { onUpload2KCheckBox(); }); + + mAllow2kTextures = gSavedSettings.getBOOL("BulkUpload2KTextures"); + mCheckboxUpload2K->setValue(!mAllow2kTextures); + + if (!mAllow2kTextures && mHas2kTextures) + { + // provided cost is for 2K textures, recalculate cost + S32 bvh_count; + S32 textures_2k_count; + get_bulk_upload_expected_cost(mFiles, mAllow2kTextures, mUploadCost, mUploadCount, bvh_count, textures_2k_count); + + update(); + } + + + update(); + + return LLModalDialog::postBuild(); +} + +void LLFloaterBulkUpload::update() +{ + mCountLabel->setTextArg("[COUNT]", llformat("%d", mUploadCount)); + mCostLabel->setTextArg("[COST]", llformat("%d", mUploadCost)); + + mCheckboxPanel->setVisible(mHas2kTextures); + mLinkPanel->setVisible(mHas2kTextures); + mWarningPanel->setVisible(mAllow2kTextures); + + S32 new_height = MAX_HEIGH; + if (!mHas2kTextures) + { + new_height -= mCheckboxPanel->getRect().getHeight(); + new_height -= mLinkPanel->getRect().getHeight(); + } + if (!mAllow2kTextures) + { + new_height -= mWarningPanel->getRect().getHeight(); + } + reshape(getRect().getWidth(), new_height, false); +} + +void LLFloaterBulkUpload::onUpload2KCheckBox() +{ + mAllow2kTextures = !mCheckboxUpload2K->getValue().asBoolean(); + gSavedSettings.setBOOL("BulkUpload2KTextures", mAllow2kTextures); + + S32 bvh_count; + S32 textures_2k_count; + get_bulk_upload_expected_cost(mFiles, mAllow2kTextures, mUploadCost, mUploadCount, bvh_count, textures_2k_count); + // keep old value of mHas2kTextures to show checkbox + + update(); +} + +void LLFloaterBulkUpload::onClickUpload() +{ + do_bulk_upload(mFiles, mAllow2kTextures); + closeFloater(); +} + + +void LLFloaterBulkUpload::onClickCancel() +{ + closeFloater(); +} diff --git a/indra/newview/llfloaterbulkupload.h b/indra/newview/llfloaterbulkupload.h new file mode 100644 index 0000000000..d07dc8eabe --- /dev/null +++ b/indra/newview/llfloaterbulkupload.h @@ -0,0 +1,66 @@ +/** + * @file llfloaterbulkupload.h + * @author Andrey Kleshchev + * @brief LLFloaterBulkUpload class definition + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATERBULKUPLOAD_H +#define LL_LLFLOATERBULKUPLOAD_H + +#include "llmodaldialog.h" + +class LLTextBox; + +class LLFloaterBulkUpload : public LLModalDialog +{ +public: + LLFloaterBulkUpload(const LLSD& key); + ~LLFloaterBulkUpload(); + + bool postBuild() override; + + void update(); + +protected: + void onUpload2KCheckBox(); + + void onClickUpload(); + void onClickCancel(); + +private: + LLUICtrl* mCheckboxUpload2K = nullptr; + LLTextBox* mCountLabel = nullptr; + LLTextBox* mCostLabel = nullptr; + LLPanel* mCheckboxPanel = nullptr; + LLPanel* mLinkPanel = nullptr; + LLPanel* mWarningPanel = nullptr; + + std::vector mFiles; + bool mAllow2kTextures = true; + bool mHas2kTextures = false; + S32 mUploadCost = 0; + S32 mUploadCount = 0; +}; + +#endif diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 92f8ed949e..3987c6d9a3 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -2430,14 +2430,14 @@ void LLMaterialEditor::onSaveObjectsMaterialAsMsgCallback(const LLSD& notificati createInventoryItem(str.str(), new_name, std::string(), permissions); } -const void upload_bulk(const std::vector& filenames, LLFilePicker::ELoadFilter type); +const void upload_bulk(const std::vector& filenames, LLFilePicker::ELoadFilter type, bool allow_2k); void LLMaterialEditor::loadMaterial(const tinygltf::Model &model_in, const std::string &filename, S32 index, bool open_floater) { if (index == model_in.materials.size()) { // bulk upload all the things - upload_bulk({ filename }, LLFilePicker::FFLOAD_MATERIAL); + upload_bulk({ filename }, LLFilePicker::FFLOAD_MATERIAL, true); return; } diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 337c18f218..3c70d46d36 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -370,7 +370,8 @@ LLNewFileResourceUploadInfo::LLNewFileResourceUploadInfo( LLResourceUploadInfo(name, description, compressionInfo, destinationType, inventoryType, nextOWnerPerms, groupPerms, everyonePerms, expectedCost, show_inventory), - mFileName(fileName) + mFileName(fileName), + mMaxImageSize(LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT) { } @@ -422,7 +423,7 @@ LLSD LLNewFileResourceUploadInfo::exportTempFile() else if (assetType == LLAssetType::AT_TEXTURE) { // It's an image file, the upload procedure is the same for all - if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec)) + if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec, mMaxImageSize)) { errorMessage = llformat("Problem with file %s:\n\n%s\n", getFileName().c_str(), LLImage::getLastThreadError().c_str()); diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index 5a07fbf802..365436ede0 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -161,13 +161,15 @@ public: std::string getFileName() const { return mFileName; }; + void setMaxImageSize(U32 maxUploadSize) { mMaxImageSize = maxUploadSize; } + protected: virtual LLSD exportTempFile(); private: std::string mFileName; - + S32 mMaxImageSize; }; //------------------------------------------------------------------------- diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 3e1705b8a1..c97a512a57 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -47,6 +47,7 @@ #include "llfloaterbeacons.h" #include "llfloaterbuildoptions.h" #include "llfloaterbulkpermission.h" +#include "llfloaterbulkupload.h" #include "llfloaterbump.h" #include "llfloaterbuy.h" #include "llfloaterbuycontents.h" @@ -207,6 +208,7 @@ public: "camera_presets", "delete_pref_preset", "forget_username", + "gltf_asset_editor", "god_tools", "group_picker", "hud", @@ -223,7 +225,8 @@ public: "upload_image", "upload_model", "upload_script", - "upload_sound" + "upload_sound", + "bulk_upload" }; return std::find(blacklist_clicked.begin(), blacklist_clicked.end(), fl_name) == blacklist_clicked.end(); } @@ -247,6 +250,7 @@ public: "env_edit_extdaycycle", "font_test", "forget_username", + "gltf_asset_editor", "god_tools", "group_picker", "hud", @@ -272,7 +276,8 @@ public: "upload_image", "upload_model", "upload_script", - "upload_sound" + "upload_sound", + "bulk_upload" }; return std::find(blacklist_untrusted.begin(), blacklist_untrusted.end(), fl_name) == blacklist_untrusted.end(); } @@ -337,6 +342,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("buy_object_contents", "floater_buy_contents.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("build", "floater_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("build_options", "floater_build_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("bulk_upload", "floater_bulk_upload.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index e3da52fc78..c4fecf8dff 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -523,15 +523,8 @@ const void upload_single_file(const std::vector& filenames, LLFileP return; } -void do_bulk_upload(std::vector filenames, const LLSD& notification, const LLSD& response) +void do_bulk_upload(std::vector filenames, bool allow_2k) { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (option != 0) - { - // Cancel upload - return; - } - for (std::vector::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) { std::string filename = (*in_iter); @@ -551,7 +544,7 @@ void do_bulk_upload(std::vector filenames, const LLSD& notification if (LLResourceUploadInfo::findAssetTypeAndCodecOfExtension(ext, asset_type, codec)) { bool resource_upload = false; - if (asset_type == LLAssetType::AT_TEXTURE) + if (asset_type == LLAssetType::AT_TEXTURE && allow_2k) { LLPointer image_frmted = LLImageFormatted::createFromType(codec); if (gDirUtilp->fileExists(filename) && image_frmted->load(filename)) @@ -567,7 +560,7 @@ void do_bulk_upload(std::vector filenames, const LLSD& notification if (resource_upload) { - LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( + LLNewFileResourceUploadInfo* info_p = new LLNewFileResourceUploadInfo( filename, asset_name, asset_name, 0, @@ -575,7 +568,13 @@ void do_bulk_upload(std::vector filenames, const LLSD& notification LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - expected_upload_cost)); + expected_upload_cost); + + if (!allow_2k) + { + info_p->setMaxImageSize(1024); + } + LLResourceUploadInfo::ptr_t uploadInfo(info_p); upload_new_resource(uploadInfo); } @@ -601,11 +600,30 @@ void do_bulk_upload(std::vector filenames, const LLSD& notification } } -bool get_bulk_upload_expected_cost(const std::vector& filenames, S32& total_cost, S32& file_count, S32& bvh_count) +void do_bulk_upload(std::vector filenames, bool allow_2k, const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option != 0) + { + // Cancel upload + return; + } + + do_bulk_upload(filenames, allow_2k); +} + +bool get_bulk_upload_expected_cost( + const std::vector& filenames, + bool allow_2k, + S32& total_cost, + S32& file_count, + S32& bvh_count, + S32& textures_2k_count) { total_cost = 0; file_count = 0; bvh_count = 0; + textures_2k_count = 0; for (std::vector::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) { std::string filename = (*in_iter); @@ -622,12 +640,20 @@ bool get_bulk_upload_expected_cost(const std::vector& filenames, S3 if (LLResourceUploadInfo::findAssetTypeAndCodecOfExtension(ext, asset_type, codec)) { - if (asset_type == LLAssetType::AT_TEXTURE) + if (asset_type == LLAssetType::AT_TEXTURE && allow_2k) { LLPointer image_frmted = LLImageFormatted::createFromType(codec); if (gDirUtilp->fileExists(filename) && image_frmted->load(filename)) { total_cost += LLAgentBenefitsMgr::current().getTextureUploadCost(image_frmted); + if (image_frmted) + { + S32 area = image_frmted->getHeight() * image_frmted->getWidth(); + if (area >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) + { + textures_2k_count++; + } + } file_count++; } } @@ -682,38 +708,27 @@ bool get_bulk_upload_expected_cost(const std::vector& filenames, S3 return file_count > 0; } -const void upload_bulk(const std::vector& filenames, LLFilePicker::ELoadFilter type) +const void upload_bulk(const std::vector& filtered_filenames, bool allow_2k) { - // TODO: - // Check user balance for entire cost - // Charge user entire cost - // Loop, uploading - // If an upload fails, refund the user for that one - // - // Also fix single upload to charge first, then refund - - // FIXME PREMIUM what about known types that can't be bulk uploaded - // (bvh)? These will fail in the item by item upload but won't be - // mentioned in the notification. - std::vector filtered_filenames; - for (std::vector::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) - { - const std::string& filename = *in_iter; - if (check_file_extension(filename, type)) - { - filtered_filenames.push_back(filename); - } - } - S32 expected_upload_cost; S32 expected_upload_count; S32 bvh_count; - if (get_bulk_upload_expected_cost(filtered_filenames, expected_upload_cost, expected_upload_count, bvh_count)) + S32 textures_2k_count; + if (get_bulk_upload_expected_cost(filtered_filenames, allow_2k, expected_upload_cost, expected_upload_count, bvh_count, textures_2k_count)) { - LLSD args; - args["COST"] = expected_upload_cost; - args["COUNT"] = expected_upload_count; - LLNotificationsUtil::add("BulkUploadCostConfirmation", args, LLSD(), boost::bind(do_bulk_upload, filtered_filenames, _1, _2)); + LLSD key; + key["upload_cost"] = expected_upload_cost; + key["upload_count"] = expected_upload_count; + key["has_2k_textures"] = (textures_2k_count > 0); + + LLSD array; + for (const std::string& str : filtered_filenames) + { + array.append(str); + } + key["files"] = array; + + LLFloaterReg::showInstance("bulk_upload", key); if (filtered_filenames.size() > expected_upload_count) { @@ -738,6 +753,31 @@ const void upload_bulk(const std::vector& filenames, LLFilePicker:: } +const void upload_bulk(const std::vector& filenames, LLFilePicker::ELoadFilter type, bool allow_2k) +{ + // TODO: + // Check user balance for entire cost + // Charge user entire cost + // Loop, uploading + // If an upload fails, refund the user for that one + // + // Also fix single upload to charge first, then refund + + // FIXME PREMIUM what about known types that can't be bulk uploaded + // (bvh)? These will fail in the item by item upload but won't be + // mentioned in the notification. + std::vector filtered_filenames; + for (std::vector::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) + { + const std::string& filename = *in_iter; + if (check_file_extension(filename, type)) + { + filtered_filenames.push_back(filename); + } + } + upload_bulk(filtered_filenames, allow_2k); +} + class LLFileUploadImage : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -803,7 +843,7 @@ class LLFileUploadBulk : public view_listener_t { gAgentCamera.changeCameraToDefault(); } - LLFilePickerReplyThread::startPicker(boost::bind(&upload_bulk, _1, _2), LLFilePicker::FFLOAD_ALL, true); + LLFilePickerReplyThread::startPicker(boost::bind(&upload_bulk, _1, _2, true), LLFilePicker::FFLOAD_ALL, true); return true; } }; diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 1acb701d50..d99f9dc4c6 100644 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -64,13 +64,15 @@ void upload_new_resource( LLAssetStorage::LLStoreAssetCallback callback = LLAssetStorage::LLStoreAssetCallback(), void *userdata = NULL); - -void assign_defaults_and_show_upload_message( - LLAssetType::EType asset_type, - LLInventoryType::EType& inventory_type, - std::string& name, - const std::string& display_name, - std::string& description); +bool get_bulk_upload_expected_cost( + const std::vector& filenames, + bool allow_2k, + S32& total_cost, + S32& file_count, + S32& bvh_count, + S32& textures_2k_count); + +void do_bulk_upload(std::vector filenames, bool allow_2k); //consider moving all file pickers below to more suitable place class LLFilePickerThread : public LLThread diff --git a/indra/newview/skins/default/xui/en/floater_bulk_upload.xml b/indra/newview/skins/default/xui/en/floater_bulk_upload.xml new file mode 100644 index 0000000000..4c639a7c65 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_bulk_upload.xml @@ -0,0 +1,144 @@ + + + + + + Number of items to upload: [COUNT] + + + + + Because of their dimentions one or more selected textures will be scaled to 2048px. + + + + + + + + Upload cost: L$[COST] + + + + + -- cgit v1.2.3 From 3ca9af4d4ac035ed18fa747edd7e0a3bf49b7b32 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Thu, 25 Jul 2024 18:19:55 +0200 Subject: Fix commit 4b543b618b101aca9dee1f224d8dbd4fbf937d71 --- indra/newview/llhudtext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp index 78afe43ffe..35bcf65db6 100644 --- a/indra/newview/llhudtext.cpp +++ b/indra/newview/llhudtext.cpp @@ -392,7 +392,7 @@ void LLHUDText::updateVisibility() LLVector3 pos_agent_center = gAgent.getPosAgentFromGlobal(mPositionGlobal) - dir_from_camera; F32 last_distance_center = (pos_agent_center - LLViewerCamera::getInstance()->getOrigin()).magVec(); - static LLCachedControl prim_text_max_dist(gSavedSettings, "PrimTextMaxDrawDistance"); + static LLCachedControl prim_text_max_dist(gSavedSettings, "PrimTextMaxDrawDistance"); F32 max_draw_distance = prim_text_max_dist; if(max_draw_distance < 0) -- cgit v1.2.3 From 4295a1f66033f9417c7668c54128515ee0a35558 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Thu, 25 Jul 2024 19:55:05 +0200 Subject: Fix commit 66d2c846b180d58e4e90052d87e27505e2d22736 --- indra/newview/llpanelenvironment.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview') diff --git a/indra/newview/llpanelenvironment.h b/indra/newview/llpanelenvironment.h index 8942e20119..c9b95cc348 100644 --- a/indra/newview/llpanelenvironment.h +++ b/indra/newview/llpanelenvironment.h @@ -40,6 +40,7 @@ class LLViewerRegion; class LLIconCtrl; +class LLSettingsDropTarget; class LLPanelEnvironmentInfo : public LLPanel { -- cgit v1.2.3 From bc50d2c7d57618846a6cb318cd12e006270b64ae Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Thu, 25 Jul 2024 15:56:48 +0200 Subject: #1318 Pagination in the Group Interface (rework) --- indra/newview/llgroupmgr.cpp | 55 +++++++++++++++++++++++++++++-------- indra/newview/llgroupmgr.h | 6 ++-- indra/newview/llpanelgrouproles.cpp | 5 ++-- 3 files changed, 50 insertions(+), 16 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index ec2002d8c5..76d3e3e049 100644 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -2145,9 +2145,11 @@ void LLGroupMgr::processGroupBanRequest(const LLSD& content) LLGroupMgr::getInstance()->notifyObservers(GC_BANLIST); } -void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID group_id, U32 page_size, U32 page_start, std::string sort_column) +void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID group_id, U32 page_size, U32 page_start, U32 sort_column, bool sort_descending) { - LL_INFOS("GrpMgr") << "group_id: '" << group_id << "', sort_column: '" << sort_column << "', page_size: " << page_size << ", page_start: " << page_start << LL_ENDL; + LL_INFOS("GrpMgr") << "group_id: '" << group_id << "'" + << ", page_size: " << page_size << ", page_start: " << page_start + << ", sort_column: " << sort_column << ", sort_descending: " << sort_descending << LL_ENDL; LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); @@ -2156,6 +2158,7 @@ void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID group_id, U32 p LLSD postData = LLSD::emptyMap(); postData["group_id"] = group_id; + if (page_size) { postData["page_size"] = LLSD::Integer(page_size); @@ -2163,12 +2166,19 @@ void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID group_id, U32 p { postData["page_start"] = LLSD::Integer(page_start); } - if (!sort_column.empty()) + } + + if (sort_column) + { + postData["sort_column"] = LLSD::Integer(sort_column); + if (sort_descending) { - postData["sort_column"] = sort_column; + postData["sort_descending"] = 1; } } + mMemberRequestInFlight = true; + LLSD response = httpAdapter->postAndSuspend(httpRequest, url, postData, httpOpts); mMemberRequestInFlight = false; @@ -2183,10 +2193,10 @@ void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID group_id, U32 p } response.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); - processCapGroupMembersResponse(response, page_size, page_start, sort_column); + processCapGroupMembersResponse(response, url, page_size, page_start, sort_column, sort_descending); } -void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id, U32 page_size, U32 page_start, const std::string& sort_column) +void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id, U32 page_size, U32 page_start, const std::string& sort_column_name, bool sort_descending) { static U32 lastGroupMemberRequestFrame = 0; @@ -2195,6 +2205,10 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id, U32 page_siz if ((lastGroupMemberRequestFrame == gFrameCount) || mMemberRequestInFlight) return; + LL_INFOS("GrpMgr") << "group_id: '" << group_id << "'" + << ", page_size: " << page_size << ", page_start: " << page_start + << ", sort_column_name: '" << sort_column_name << "', sort_descending: " << sort_descending << LL_ENDL; + LLViewerRegion* currentRegion = gAgent.getRegion(); // Thank you FS:Ansariel! if (!currentRegion) @@ -2226,18 +2240,34 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id, U32 page_siz lastGroupMemberRequestFrame = gFrameCount; - mMemberRequestInFlight = true; + U32 sort_column = 0; // No sorting by default + if (!sort_column_name.empty()) + { + static const std::vector column_names = { "name", "donated", "online", "title" }; + auto it = std::find(column_names.begin(), column_names.end(), sort_column_name); + if (it == column_names.end()) + { + LL_WARNS("GrpMgr") << "Invalid column name: '" << sort_column_name << "'" << LL_ENDL; + } + else + { + // Use offset (1) because 0 means "no sorting" + sort_column = 1 + (U32)std::distance(column_names.begin(), it); + } + } LLCoros::instance().launch("LLGroupMgr::groupMembersRequestCoro", [&]() { - groupMembersRequestCoro(cap_url, group_id, page_size, page_start, sort_column); + groupMembersRequestCoro(cap_url, group_id, page_size, page_start, sort_column, sort_descending); }); } -void LLGroupMgr::processCapGroupMembersResponse(const LLSD& response, U32 page_size, U32 page_start, const std::string& sort_column) +void LLGroupMgr::processCapGroupMembersResponse(const LLSD& response, const std::string& url, U32 page_size, U32 page_start, U32 sort_column, bool sort_descending) { LLUUID group_id = response["group_id"].asUUID(); - LL_INFOS("GrpMgr") << "group_id: '" << group_id << "', sort_column: '" << sort_column << "', page_size: " << page_size << ", page_start: " << page_start << LL_ENDL; + LL_INFOS("GrpMgr") << "group_id: '" << group_id << "'" + << ", page_size: " << page_size << ", page_start: " << page_start + << ", sort_column: " << sort_column << ", sort_descending: " << sort_descending << LL_ENDL; // Did we get anything in content? if (!response.size()) @@ -2357,7 +2387,10 @@ void LLGroupMgr::processCapGroupMembersResponse(const LLSD& response, U32 page_s if (page_size && members_loaded >= page_size && member_count > members_before) { - sendCapGroupMembersRequest(group_id, page_size, member_count, sort_column); + LLCoros::instance().launch("LLGroupMgr::groupMembersRequestCoro", [&]() + { + groupMembersRequestCoro(url, group_id, page_size, page_start, sort_column, sort_descending); + }); } // Make the role-member data request diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index f96c5ccc14..21cf4a62b6 100644 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -414,7 +414,7 @@ public: void sendCapGroupMembersRequest(const LLUUID& group_id, - U32 page_size = 0, U32 page_start = 0, const std::string& sort_column = LLStringUtil::null); + U32 page_size = 0, U32 page_start = 0, const std::string& sort_column_name = LLStringUtil::null, bool sort_descending = false); void cancelGroupRoleChanges(const LLUUID& group_id); @@ -437,8 +437,8 @@ public: void clearGroupData(const LLUUID& group_id); private: - void groupMembersRequestCoro(std::string url, LLUUID group_id, U32 page_size, U32 page_start, std::string sort_column); - void processCapGroupMembersResponse(const LLSD& response, U32 page_size, U32 page_start, const std::string& sort_column); + void groupMembersRequestCoro(std::string url, LLUUID group_id, U32 page_size, U32 page_start, U32 sort_column, bool sort_descending); + void processCapGroupMembersResponse(const LLSD& response, const std::string& url, U32 page_size, U32 page_start, U32 sort_column, bool sort_descending); void getGroupBanRequestCoro(std::string url, LLUUID group_id); void postGroupBanRequestCoro(std::string url, LLUUID group_id, U32 action, uuid_vec_t ban_list, bool update); diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp index 864d73683e..4404efff98 100644 --- a/indra/newview/llpanelgrouproles.cpp +++ b/indra/newview/llpanelgrouproles.cpp @@ -1361,8 +1361,9 @@ void LLPanelGroupMembersSubTab::activate() if (!gdatap || !gdatap->isMemberDataComplete()) { const U32 page_size = 50; - std::string sort_column = mMembersList->getSortColumnName(); - LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mGroupID, page_size, 0, sort_column); + std::string sort_column_name = mMembersList->getSortColumnName(); + bool sort_descending = !mMembersList->getSortAscending(); + LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mGroupID, page_size, 0, sort_column_name, sort_descending); } if (!gdatap || !gdatap->isRoleMemberDataComplete()) -- cgit v1.2.3 From 005f3bd62a73040fe9a9c447f697e70a3d918bd4 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Thu, 25 Jul 2024 09:50:07 -0400 Subject: Fix findChild stall during teleport in people panel --- indra/newview/llpanelpeople.cpp | 77 ++++++++++++++++++++++++----------------- indra/newview/llpanelpeople.h | 13 ++++++- 2 files changed, 58 insertions(+), 32 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index 7f64cfca08..2f0a8f7656 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -153,8 +153,6 @@ public: id_it = uuids.begin(), id_end = uuids.end(); - LLAvatarItemDistanceComparator::id_to_pos_map_t pos_map; - mAvatarsPositions.clear(); for (;pos_it != pos_end && id_it != id_end; ++pos_it, ++id_it ) @@ -618,15 +616,13 @@ bool LLPanelPeople::postBuild() { S32 max_premium = LLAgentBenefitsMgr::get("Premium").getGroupMembershipLimit(); - mNearbyFilterCommitConnection = getChild("nearby_filter_input")->setCommitCallback(boost::bind(&LLPanelPeople::onFilterEdit, this, _2)); - mFriedsFilterCommitConnection = getChild("friends_filter_input")->setCommitCallback(boost::bind(&LLPanelPeople::onFilterEdit, this, _2)); - mGroupsFilterCommitConnection = getChild("groups_filter_input")->setCommitCallback(boost::bind(&LLPanelPeople::onFilterEdit, this, _2)); - mRecentFilterCommitConnection = getChild("recent_filter_input")->setCommitCallback(boost::bind(&LLPanelPeople::onFilterEdit, this, _2)); - + LLPanel* group_tab = getChild(GROUP_TAB_NAME); + mGroupDelBtn = group_tab->getChild("minus_btn"); + mGroupCountText = group_tab->getChild("groupcount"); if(LLAgentBenefitsMgr::current().getGroupMembershipLimit() < max_premium) { - getChild("groupcount")->setText(getString("GroupCountWithInfo")); - getChild("groupcount")->setURLClickedCallback(boost::bind(&LLPanelPeople::onGroupLimitInfo, this)); + mGroupCountText->setText(getString("GroupCountWithInfo")); + mGroupCountText->setURLClickedCallback(boost::bind(&LLPanelPeople::onGroupLimitInfo, this)); } mTabContainer = getChild("tabs"); @@ -639,40 +635,56 @@ bool LLPanelPeople::postBuild() friends_tab->setVisibleCallback(boost::bind(&Updater::setActive, mFriendListUpdater, _2)); friends_tab->setVisibleCallback(boost::bind(&LLPanelPeople::removePicker, this)); + mFriendsGearBtn = friends_tab->getChild("gear_btn"); + mFriendsDelFriendBtn = friends_tab->getChild("friends_del_btn"); + mOnlineFriendList = friends_tab->getChild("avatars_online"); mAllFriendList = friends_tab->getChild("avatars_all"); mOnlineFriendList->setNoItemsCommentText(getString("no_friends_online")); mOnlineFriendList->setShowIcons("FriendsListShowIcons"); - mOnlineFriendList->showPermissions("FriendsListShowPermissions"); + mOnlineFriendList->showPermissions(gSavedSettings.getBOOL("FriendsListShowPermissions")); mOnlineFriendList->setShowCompleteName(!gSavedSettings.getBOOL("FriendsListHideUsernames")); mAllFriendList->setNoItemsCommentText(getString("no_friends")); mAllFriendList->setShowIcons("FriendsListShowIcons"); - mAllFriendList->showPermissions("FriendsListShowPermissions"); + mAllFriendList->showPermissions(gSavedSettings.getBOOL("FriendsListShowPermissions")); mAllFriendList->setShowCompleteName(!gSavedSettings.getBOOL("FriendsListHideUsernames")); LLPanel* nearby_tab = getChild(NEARBY_TAB_NAME); nearby_tab->setVisibleCallback(boost::bind(&Updater::setActive, mNearbyListUpdater, _2)); + mNearbyList = nearby_tab->getChild("avatar_list"); mNearbyList->setNoItemsCommentText(getString("no_one_near")); mNearbyList->setNoItemsMsg(getString("no_one_near")); mNearbyList->setNoFilteredItemsMsg(getString("no_one_filtered_near")); mNearbyList->setShowIcons("NearbyListShowIcons"); mNearbyList->setShowCompleteName(!gSavedSettings.getBOOL("NearbyListHideUsernames")); - mMiniMap = (LLNetMap*)getChildView("Net Map",true); + mMiniMap = nearby_tab->getChild("Net Map", true); mMiniMap->setToolTipMsg(gSavedSettings.getBOOL("DoubleClickTeleport") ? getString("AltMiniMapToolTipMsg") : getString("MiniMapToolTipMsg")); - mRecentList = getChild(RECENT_TAB_NAME)->getChild("avatar_list"); + mNearbyGearBtn = nearby_tab->getChild("gear_btn"); + mNearbyAddFriendBtn = nearby_tab->getChild("add_friend_btn"); + + LLPanel* recent_tab = getChild(RECENT_TAB_NAME); + mRecentList = recent_tab->getChild("avatar_list"); mRecentList->setNoItemsCommentText(getString("no_recent_people")); mRecentList->setNoItemsMsg(getString("no_recent_people")); mRecentList->setNoFilteredItemsMsg(getString("no_filtered_recent_people")); mRecentList->setShowIcons("RecentListShowIcons"); - mGroupList = getChild("group_list"); + mRecentGearBtn = recent_tab->getChild("gear_btn"); + mRecentAddFriendBtn = recent_tab->getChild("add_friend_btn"); + + mGroupList = group_tab->getChild("group_list"); mGroupList->setNoItemsCommentText(getString("no_groups_msg")); mGroupList->setNoItemsMsg(getString("no_groups_msg")); mGroupList->setNoFilteredItemsMsg(getString("no_filtered_groups_msg")); + mNearbyFilterCommitConnection = nearby_tab->getChild("nearby_filter_input")->setCommitCallback(boost::bind(&LLPanelPeople::onFilterEdit, this, _2)); + mFriedsFilterCommitConnection = friends_tab->getChild("friends_filter_input")->setCommitCallback(boost::bind(&LLPanelPeople::onFilterEdit, this, _2)); + mRecentFilterCommitConnection = recent_tab->getChild("recent_filter_input")->setCommitCallback(boost::bind(&LLPanelPeople::onFilterEdit, this, _2)); + mGroupsFilterCommitConnection = group_tab->getChild("groups_filter_input")->setCommitCallback(boost::bind(&LLPanelPeople::onFilterEdit, this, _2)); + mNearbyList->setContextMenu(&LLPanelPeopleMenus::gNearbyPeopleContextMenu); mRecentList->setContextMenu(&LLPanelPeopleMenus::gPeopleContextMenu); mAllFriendList->setContextMenu(&LLPanelPeopleMenus::gPeopleContextMenu); @@ -850,10 +862,11 @@ void LLPanelPeople::updateRecentList() void LLPanelPeople::updateButtons() { - std::string cur_tab = getActiveTabName(); + const std::string& cur_tab = getActiveTabName(); + bool nearby_tab_active = (cur_tab == NEARBY_TAB_NAME); bool friends_tab_active = (cur_tab == FRIENDS_TAB_NAME); bool group_tab_active = (cur_tab == GROUP_TAB_NAME); - //bool recent_tab_active = (cur_tab == RECENT_TAB_NAME); + bool recent_tab_active = (cur_tab == RECENT_TAB_NAME); LLUUID selected_id; uuid_vec_t selected_uuids; @@ -868,14 +881,13 @@ void LLPanelPeople::updateButtons() selected_id = mGroupList->getSelectedUUID(); } - LLPanel* groups_panel = mTabContainer->getCurrentPanel(); - groups_panel->getChildView("minus_btn")->setEnabled(item_selected && selected_id.notNull()); // a real group selected + mGroupDelBtn->setEnabled(item_selected && selected_id.notNull()); // a real group selected U32 groups_count = static_cast(gAgent.mGroups.size()); U32 max_groups = LLAgentBenefitsMgr::current().getGroupMembershipLimit(); U32 groups_remaining = max_groups > groups_count ? max_groups - groups_count : 0; - groups_panel->getChild("groupcount")->setTextArg("[COUNT]", llformat("%d", groups_count)); - groups_panel->getChild("groupcount")->setTextArg("[REMAINING]", llformat("%d", groups_remaining)); + mGroupCountText->setTextArg("[COUNT]", llformat("%d", groups_count)); + mGroupCountText->setTextArg("[REMAINING]", llformat("%d", groups_remaining)); } else { @@ -889,33 +901,36 @@ void LLPanelPeople::updateButtons() is_self = gAgent.getID() == selected_id; } - LLPanel* cur_panel = mTabContainer->getCurrentPanel(); - if (cur_panel) { - if (cur_panel->hasChild("add_friend_btn", true)) - cur_panel->getChildView("add_friend_btn")->setEnabled(item_selected && !is_friend && !is_self); + if(nearby_tab_active) + { + mNearbyAddFriendBtn->setEnabled(item_selected && !is_friend && !is_self); + mNearbyGearBtn->setEnabled(multiple_selected); + } if (friends_tab_active) { - cur_panel->getChildView("friends_del_btn")->setEnabled(multiple_selected); + mFriendsDelFriendBtn->setEnabled(multiple_selected); + mFriendsGearBtn->setEnabled(multiple_selected); } - if (!group_tab_active) + if (recent_tab_active) { - cur_panel->getChildView("gear_btn")->setEnabled(multiple_selected); + mRecentAddFriendBtn->setEnabled(item_selected && !is_friend && !is_self); + mRecentGearBtn->setEnabled(multiple_selected); } } } } -std::string LLPanelPeople::getActiveTabName() const +const std::string& LLPanelPeople::getActiveTabName() const { return mTabContainer->getCurrentPanel()->getName(); } LLUUID LLPanelPeople::getCurrentItemID() const { - std::string cur_tab = getActiveTabName(); + const std::string& cur_tab = getActiveTabName(); if (cur_tab == FRIENDS_TAB_NAME) // this tab has two lists { @@ -945,7 +960,7 @@ LLUUID LLPanelPeople::getCurrentItemID() const void LLPanelPeople::getCurrentItemIDs(uuid_vec_t& selected_uuids) const { - std::string cur_tab = getActiveTabName(); + const std::string& cur_tab = getActiveTabName(); if (cur_tab == FRIENDS_TAB_NAME) { @@ -1033,7 +1048,7 @@ void LLPanelPeople::onFilterEdit(const std::string& search_string) saved_filter = search_upper; // Apply new filter to the current tab. - const std::string cur_tab = getActiveTabName(); + const std::string& cur_tab = getActiveTabName(); if (cur_tab == NEARBY_TAB_NAME) { mNearbyList->setNameFilter(filter); diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h index 768ba1ef49..445bc4c081 100644 --- a/indra/newview/llpanelpeople.h +++ b/indra/newview/llpanelpeople.h @@ -84,7 +84,7 @@ private: bool isItemsFreeOfFriends(const uuid_vec_t& uuids); void updateButtons(); - std::string getActiveTabName() const; + const std::string& getActiveTabName() const; LLUUID getCurrentItemID() const; void getCurrentItemIDs(uuid_vec_t& selected_uuids) const; void setSortOrder(LLAvatarList* list, ESortOrder order, bool save = true); @@ -139,6 +139,17 @@ private: LLGroupList* mGroupList; LLNetMap* mMiniMap; + LLButton* mNearbyGearBtn = nullptr; + LLButton* mFriendsGearBtn = nullptr; + LLButton* mRecentGearBtn = nullptr; + LLButton* mGroupDelBtn = nullptr; + + LLButton* mNearbyAddFriendBtn = nullptr; + LLButton* mRecentAddFriendBtn = nullptr; + LLUICtrl* mFriendsDelFriendBtn = nullptr; + + LLTextBox* mGroupCountText = nullptr; + std::vector mSavedOriginalFilters; std::vector mSavedFilters; -- cgit v1.2.3 From 10e5e5694668a5376378dc487b54f1045080e47e Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Thu, 25 Jul 2024 23:24:39 -0400 Subject: Reduce findChild stalls in appearance floater --- indra/newview/lloutfitgallery.cpp | 40 ++++++++++++++-------- indra/newview/lloutfitgallery.h | 1 + indra/newview/llpaneloutfitedit.cpp | 39 +++++++++++++-------- indra/newview/llpaneloutfitedit.h | 8 +++++ indra/newview/llpaneloutfitsinventory.cpp | 12 +++---- indra/newview/llpaneloutfitsinventory.h | 1 + indra/newview/llscrollingpanelparambase.cpp | 13 +++---- indra/newview/llscrollingpanelparambase.h | 1 + indra/newview/llsidepanelappearance.cpp | 7 ++-- indra/newview/llsidepanelappearance.h | 4 +++ indra/newview/llwearableitemslist.cpp | 18 ++++++---- indra/newview/llwearableitemslist.h | 2 ++ .../skins/default/xui/en/panel_edit_alpha.xml | 5 --- 13 files changed, 97 insertions(+), 54 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index b1b9f69f4f..7482890d1e 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -739,13 +739,16 @@ void LLOutfitGallery::onFilterSubStringChanged(const std::string& new_string, co void LLOutfitGallery::onHighlightBaseOutfit(LLUUID base_id, LLUUID prev_id) { - if (mOutfitMap[base_id]) + auto base_it = mOutfitMap.find(base_id); + if (base_it != mOutfitMap.end()) { - mOutfitMap[base_id]->setOutfitWorn(true); + base_it->second->setOutfitWorn(true); } - if (mOutfitMap[prev_id]) + + auto prev_it = mOutfitMap.find(prev_id); + if (prev_it != mOutfitMap.end()) { - mOutfitMap[prev_id]->setOutfitWorn(false); + prev_it->second->setOutfitWorn(false); } } @@ -859,13 +862,16 @@ void LLOutfitGallery::onChangeOutfitSelection(LLWearableItemsList* list, const L { if (mSelectedOutfitUUID == category_id) return; - if (mOutfitMap[mSelectedOutfitUUID]) + + auto selected_it = mOutfitMap.find(mSelectedOutfitUUID); + if (selected_it != mOutfitMap.end()) { - mOutfitMap[mSelectedOutfitUUID]->setSelected(false); + selected_it->second->setSelected(false); } - if (mOutfitMap[category_id]) + auto category_it = mOutfitMap.find(category_id); + if (category_it != mOutfitMap.end()) { - mOutfitMap[category_id]->setSelected(true); + category_it->second->setSelected(true); } // mSelectedOutfitUUID will be set in LLOutfitListBase::ChangeOutfitSelection } @@ -887,9 +893,10 @@ bool LLOutfitGallery::canWearSelected() bool LLOutfitGallery::hasDefaultImage(const LLUUID& outfit_cat_id) { - if (mOutfitMap[outfit_cat_id]) + auto outfit_it = mOutfitMap.find(outfit_cat_id); + if (outfit_it != mOutfitMap.end()) { - return mOutfitMap[outfit_cat_id]->isDefaultImage(); + return outfit_it->second->isDefaultImage(); } return false; } @@ -937,6 +944,7 @@ LLOutfitGalleryItem::~LLOutfitGalleryItem() bool LLOutfitGalleryItem::postBuild() { + mPreviewIcon = getChild("preview_outfit"); setDefaultImage(); mOutfitNameText = getChild("outfit_name"); @@ -952,10 +960,12 @@ void LLOutfitGalleryItem::draw() LLPanel::draw(); // Draw border - LLUIColor border_color = LLUIColorTable::instance().getColor(mSelected ? "OutfitGalleryItemSelected" : "OutfitGalleryItemUnselected", LLColor4::white); - LLRect border = getChildView("preview_outfit")->getRect(); + static LLUIColor selected_color = LLUIColorTable::instance().getColor("OutfitGalleryItemSelected", LLColor4::white); + static LLUIColor unselected_color = LLUIColorTable::instance().getColor("OutfitGalleryItemUnselected", LLColor4::white); + const LLColor4& border_color = mSelected ? selected_color : unselected_color; + LLRect border = mPreviewIcon->getRect(); border.mRight = border.mRight + 1; - gl_rect_2d(border, border_color.get(), false); + gl_rect_2d(border, border_color, false); // If the floater is focused, don't apply its alpha to the texture (STORM-677). const F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); @@ -1111,7 +1121,7 @@ bool LLOutfitGalleryItem::setImageAssetId(LLUUID image_asset_id) { mImageAssetId = image_asset_id; mTexturep = texture; - getChildView("preview_outfit")->setVisible(false); + mPreviewIcon->setVisible(false); mDefaultImage = false; mImageUpdatePending = (texture->getDiscardLevel() == -1); return true; @@ -1128,7 +1138,7 @@ void LLOutfitGalleryItem::setDefaultImage() { mTexturep = NULL; mImageAssetId.setNull(); - getChildView("preview_outfit")->setVisible(true); + mPreviewIcon->setVisible(true); mDefaultImage = true; mImageUpdatePending = false; } diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index d921a7fe72..5b2a33d0ca 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -261,6 +261,7 @@ private: LLTextBox* mOutfitNameText; LLTextBox* mOutfitWornText; LLPanel* mTextBgPanel; + LLIconCtrl* mPreviewIcon = nullptr; bool mSelected; bool mWorn; bool mDefaultImage; diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index ce545ae21d..fadf3633e8 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -434,6 +434,8 @@ LLPanelOutfitEdit::~LLPanelOutfitEdit() delete mCOFDragAndDropObserver; + delete mWearableListViewItemsComparator; + while (!mListViewItemTypes.empty()) { delete mListViewItemTypes.back(); mListViewItemTypes.pop_back(); @@ -476,8 +478,11 @@ bool LLPanelOutfitEdit::postBuild() mFolderViewBtn = getChild("folder_view_btn"); mListViewBtn = getChild("list_view_btn"); + + mFilterPanel = getChild("filter_panel"); + mFilterBtn = getChild("filter_button"); + mFilterBtn->setCommitCallback(boost::bind(&LLPanelOutfitEdit::showWearablesFilter, this)); - childSetCommitCallback("filter_button", boost::bind(&LLPanelOutfitEdit::showWearablesFilter, this), NULL); childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesFolderView, this), NULL); childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::saveListSelection, this), NULL); childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesListView, this), NULL); @@ -530,13 +535,17 @@ bool LLPanelOutfitEdit::postBuild() mSearchFilter = getChild("look_item_filter"); mSearchFilter->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onSearchEdit, this, _2)); - childSetAction("show_add_wearables_btn", boost::bind(&LLPanelOutfitEdit::onAddMoreButtonClicked, this)); + mShowAddWearablesBtn = getChild("show_add_wearables_btn"); + mShowAddWearablesBtn->setClickedCallback(boost::bind(&LLPanelOutfitEdit::onAddMoreButtonClicked, this)); mPlusBtn = getChild("plus_btn"); mPlusBtn->setClickedCallback(boost::bind(&LLPanelOutfitEdit::onPlusBtnClicked, this)); childSetAction(REVERT_BTN, boost::bind(&LLAppearanceMgr::wearBaseOutfit, LLAppearanceMgr::getInstance())); + mNoAddWearablesButtonBar = getChild("no_add_wearables_button_bar"); + mAddWearablesButtonBar = getChild("add_wearables_button_bar"); + /* * By default AT_CLOTHING are sorted by (in in MY OUTFITS): * - by type (types order determined in LLWearableType::EType) @@ -567,7 +576,11 @@ bool LLPanelOutfitEdit::postBuild() getChild(SAVE_BTN)->setCommitCallback(boost::bind(&LLPanelOutfitEdit::saveOutfit, this, false)); getChild(SAVE_AS_BTN)->setCommitCallback(boost::bind(&LLPanelOutfitEdit::saveOutfit, this, true)); + mLoadingIndicator = getChild("edit_outfit_loading_indicator"); + mOutfitNameStatusPanel = getChild("outfit_name_and_status"); + onOutfitChanging(gAgentWearables.isCOFChangeInProgress()); + return true; } @@ -603,15 +616,15 @@ void LLPanelOutfitEdit::showAddWearablesPanel(bool show_add_wearables) { mAddWearablesPanel->setVisible(show_add_wearables); - getChild("show_add_wearables_btn")->setValue(show_add_wearables); + mShowAddWearablesBtn->setValue(show_add_wearables); updateFiltersVisibility(); - getChildView("filter_button")->setVisible( show_add_wearables); + mFilterBtn->setVisible( show_add_wearables); //search filter should be disabled if (!show_add_wearables) { - getChild("filter_button")->setValue(false); + mFilterBtn->setValue(false); mFolderViewFilterCmbBox->setVisible(false); mListViewFilterCmbBox->setVisible(false); @@ -638,15 +651,15 @@ void LLPanelOutfitEdit::showAddWearablesPanel(bool show_add_wearables) } //switching button bars - getChildView("no_add_wearables_button_bar")->setVisible( !show_add_wearables); - getChildView("add_wearables_button_bar")->setVisible( show_add_wearables); + mNoAddWearablesButtonBar->setVisible( !show_add_wearables); + mAddWearablesButtonBar->setVisible( show_add_wearables); } void LLPanelOutfitEdit::showWearablesFilter() { - bool filter_visible = getChild("filter_button")->getValue(); + bool filter_visible = mFilterBtn->getValue(); - getChildView("filter_panel")->setVisible( filter_visible); + mFilterPanel->setVisible(filter_visible); if(!filter_visible) { @@ -1309,19 +1322,17 @@ static void update_status_widget_rect(LLView * widget, S32 right_border) void LLPanelOutfitEdit::onOutfitChanging(bool started) { - static LLLoadingIndicator* indicator = getChild("edit_outfit_loading_indicator"); - static LLView* status_panel = getChild("outfit_name_and_status"); - static S32 indicator_delta = status_panel->getRect().getWidth() - indicator->getRect().mLeft; + S32 indicator_delta = mOutfitNameStatusPanel->getRect().getWidth() - mLoadingIndicator->getRect().mLeft; S32 delta = started ? indicator_delta : 0; - S32 right_border = status_panel->getRect().getWidth() - delta; + S32 right_border = mOutfitNameStatusPanel->getRect().getWidth() - delta; if (mCurrentOutfitName) update_status_widget_rect(mCurrentOutfitName, right_border); if (mStatus) update_status_widget_rect(mStatus, right_border); - indicator->setVisible(started); + mLoadingIndicator->setVisible(started); } void LLPanelOutfitEdit::getCurrentItemUUID(LLUUID& selected_id) diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h index 384b7faee4..a989d93d9e 100644 --- a/indra/newview/llpaneloutfitedit.h +++ b/indra/newview/llpaneloutfitedit.h @@ -59,6 +59,7 @@ class LLMenuGL; class LLFindNonLinksByMask; class LLFindWearablesOfType; class LLWearableItemTypeNameComparator; +class LLLoadingIndicator; class LLPanelOutfitEdit : public LLPanel { @@ -218,7 +219,14 @@ private: LLButton* mFolderViewBtn; LLButton* mListViewBtn; LLButton* mPlusBtn; + LLButton* mShowAddWearablesBtn = nullptr; + LLButton* mFilterBtn = nullptr; LLPanel* mAddWearablesPanel; + LLPanel* mOutfitNameStatusPanel = nullptr; + LLLoadingIndicator* mLoadingIndicator = nullptr; + LLView* mFilterPanel = nullptr; + LLUICtrl* mNoAddWearablesButtonBar = nullptr; + LLUICtrl* mAddWearablesButtonBar = nullptr; LLComboBox* mFolderViewFilterCmbBox; LLComboBox* mListViewFilterCmbBox; diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp index 5b595a48b7..b226c2ca1a 100644 --- a/indra/newview/llpaneloutfitsinventory.cpp +++ b/indra/newview/llpaneloutfitsinventory.cpp @@ -252,7 +252,8 @@ void LLPanelOutfitsInventory::openApearanceTab(const std::string& tab_name) void LLPanelOutfitsInventory::initListCommandsHandlers() { mListCommands = getChild("bottom_panel"); - mListCommands->childSetAction("wear_btn", boost::bind(&LLPanelOutfitsInventory::onWearButtonClick, this)); + mWearBtn = mListCommands->getChild("wear_btn"); + mWearBtn->setCommitCallback(boost::bind(&LLPanelOutfitsInventory::onWearButtonClick, this)); mMyOutfitsPanel->childSetAction("trash_btn", boost::bind(&LLPanelOutfitsInventory::onTrashButtonClick, this)); mOutfitGalleryPanel->childSetAction("trash_btn", boost::bind(&LLPanelOutfitsInventory::onTrashButtonClick, this)); } @@ -263,14 +264,13 @@ void LLPanelOutfitsInventory::updateListCommands() bool wear_enabled = isActionEnabled("wear"); bool wear_visible = !isCOFPanelActive(); bool make_outfit_enabled = isActionEnabled("save_outfit"); - - LLButton* wear_btn = mListCommands->getChild("wear_btn"); + mMyOutfitsPanel->childSetEnabled("trash_btn", trash_enabled); mOutfitGalleryPanel->childSetEnabled("trash_btn", trash_enabled); - wear_btn->setEnabled(wear_enabled); - wear_btn->setVisible(wear_visible); + mWearBtn->setEnabled(wear_enabled); + mWearBtn->setVisible(wear_visible); getChild(SAVE_BTN)->setEnabled(make_outfit_enabled); - wear_btn->setToolTip(getString((!isOutfitsGalleryPanelActive() && mMyOutfitsPanel->hasItemSelected()) ? "wear_items_tooltip" : "wear_outfit_tooltip")); + mWearBtn->setToolTip(getString((!isOutfitsGalleryPanelActive() && mMyOutfitsPanel->hasItemSelected()) ? "wear_items_tooltip" : "wear_outfit_tooltip")); } void LLPanelOutfitsInventory::onTrashButtonClick() diff --git a/indra/newview/llpaneloutfitsinventory.h b/indra/newview/llpaneloutfitsinventory.h index 0c501d5c71..e046681e95 100644 --- a/indra/newview/llpaneloutfitsinventory.h +++ b/indra/newview/llpaneloutfitsinventory.h @@ -101,6 +101,7 @@ protected: private: LLPanel* mListCommands; LLMenuGL* mMenuAdd; + LLButton* mWearBtn = nullptr; // List Commands // ////////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llscrollingpanelparambase.cpp b/indra/newview/llscrollingpanelparambase.cpp index 247639aa48..d6b5434fa4 100644 --- a/indra/newview/llscrollingpanelparambase.cpp +++ b/indra/newview/llscrollingpanelparambase.cpp @@ -51,12 +51,13 @@ LLScrollingPanelParamBase::LLScrollingPanelParamBase( const LLPanel::Params& pan else buildFromFile( "panel_scrolling_param_base.xml"); - getChild("param slider")->setValue(weightToPercent(param->getWeight())); + mParamSlider = getChild("param slider"); + mParamSlider->setValue(weightToPercent(param->getWeight())); std::string display_name = LLTrans::getString(param->getDisplayName()); - getChild("param slider")->setLabelArg("[DESC]", display_name); - getChildView("param slider")->setEnabled(mAllowModify); - childSetCommitCallback("param slider", LLScrollingPanelParamBase::onSliderMoved, this); + mParamSlider->setLabelArg("[DESC]", display_name); + mParamSlider->setEnabled(mAllowModify); + mParamSlider->setCommitCallback(LLScrollingPanelParamBase::onSliderMoved, this); setVisible(false); setBorderVisible( false ); @@ -77,9 +78,9 @@ void LLScrollingPanelParamBase::updatePanel(bool allow_modify) } F32 current_weight = mWearable->getVisualParamWeight( param->getID() ); - getChild("param slider")->setValue(weightToPercent( current_weight ) ); + mParamSlider->setValue(weightToPercent( current_weight ) ); mAllowModify = allow_modify; - getChildView("param slider")->setEnabled(mAllowModify); + mParamSlider->setEnabled(mAllowModify); } // static diff --git a/indra/newview/llscrollingpanelparambase.h b/indra/newview/llscrollingpanelparambase.h index 9deafcc81a..d5477a8397 100644 --- a/indra/newview/llscrollingpanelparambase.h +++ b/indra/newview/llscrollingpanelparambase.h @@ -55,6 +55,7 @@ public: public: LLViewerVisualParam* mParam; protected: + LLUICtrl* mParamSlider = nullptr; bool mAllowModify; LLWearable *mWearable; }; diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp index 35d07d1ac8..c618483fc4 100644 --- a/indra/newview/llsidepanelappearance.cpp +++ b/indra/newview/llsidepanelappearance.cpp @@ -39,6 +39,7 @@ #include "llfloaterreg.h" #include "llfloaterworldmap.h" #include "llfolderviewmodel.h" +#include "llloadingindicator.h" #include "lloutfitobserver.h" #include "llpaneleditwearable.h" #include "llpaneloutfitsinventory.h" @@ -137,6 +138,8 @@ bool LLSidepanelAppearance::postBuild() mCurrOutfitPanel = getChild("panel_currentlook"); + mWearableLoadingIndicator = getChild("wearables_loading_indicator"); + mEditOutfitBtn = getChild("edit_outfit_btn"); setVisibleCallback(boost::bind(&LLSidepanelAppearance::onVisibilityChanged,this,_2)); @@ -541,8 +544,8 @@ void LLSidepanelAppearance::inventoryFetched() void LLSidepanelAppearance::setWearablesLoading(bool val) { - getChildView("wearables_loading_indicator")->setVisible( val); - getChildView("edit_outfit_btn")->setVisible( !val); + mWearableLoadingIndicator->setVisible(val); + mEditOutfitBtn->setVisible(!val); if (!val) { diff --git a/indra/newview/llsidepanelappearance.h b/indra/newview/llsidepanelappearance.h index f3d34a857c..1c1de99795 100644 --- a/indra/newview/llsidepanelappearance.h +++ b/indra/newview/llsidepanelappearance.h @@ -38,6 +38,7 @@ class LLCurrentlyWornFetchObserver; class LLPanelEditWearable; class LLViewerWearable; class LLPanelOutfitsInventory; +class LLLoadingIndicator; class LLSidepanelAppearance : public LLPanel { @@ -86,8 +87,11 @@ private: LLButton* mOpenOutfitBtn; LLButton* mEditAppearanceBtn; + LLButton* mEditOutfitBtn = nullptr; LLPanel* mCurrOutfitPanel; + LLLoadingIndicator* mWearableLoadingIndicator = nullptr; + LLTextBox* mCurrentLookName; LLTextBox* mOutfitStatus; diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index 5ee6aec9f9..8ce1a745c3 100644 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -102,15 +102,21 @@ LLPanelWearableOutfitItem::Params::Params() bool LLPanelWearableOutfitItem::postBuild() { + if (mShowWidgets) + { + mAddWearableBtn = getChild("add_wearable"); + mRemoveWearableBtn = getChild("remove_wearable"); + } + LLPanelWearableListItem::postBuild(); if(mShowWidgets) { - addWidgetToRightSide("add_wearable"); - addWidgetToRightSide("remove_wearable"); + addWidgetToRightSide(mAddWearableBtn); + addWidgetToRightSide(mRemoveWearableBtn); - childSetAction("add_wearable", boost::bind(&LLPanelWearableOutfitItem::onAddWearable, this)); - childSetAction("remove_wearable", boost::bind(&LLPanelWearableOutfitItem::onRemoveWearable, this)); + mAddWearableBtn->setClickedCallback(boost::bind(&LLPanelWearableOutfitItem::onAddWearable, this)); + mRemoveWearableBtn->setClickedCallback(boost::bind(&LLPanelWearableOutfitItem::onRemoveWearable, this)); setWidgetsVisible(false); reshapeWidgets(); @@ -205,12 +211,12 @@ void LLPanelWearableOutfitItem::updateItem(const std::string& name, } if(mShowWidgets) { - setShowWidget("add_wearable", !is_worn); + setShowWidget(mAddWearableBtn, !is_worn); // Body parts can't be removed, only replaced LLViewerInventoryItem* inv_item = getItem(); bool show_remove = is_worn && inv_item && (inv_item->getType() != LLAssetType::AT_BODYPART); - setShowWidget("remove_wearable", show_remove); + setShowWidget(mRemoveWearableBtn, show_remove); if(mHovered) { diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h index 7b69711154..3fe1059176 100644 --- a/indra/newview/llwearableitemslist.h +++ b/indra/newview/llwearableitemslist.h @@ -104,6 +104,8 @@ protected: bool worn_indication_enabled, const Params& params, bool show_widgets = false); private: + LLButton* mAddWearableBtn = nullptr; + LLButton* mRemoveWearableBtn = nullptr; bool mWornIndicationEnabled; bool mShowWidgets; }; diff --git a/indra/newview/skins/default/xui/en/panel_edit_alpha.xml b/indra/newview/skins/default/xui/en/panel_edit_alpha.xml index 30fee7361f..ab0e447028 100644 --- a/indra/newview/skins/default/xui/en/panel_edit_alpha.xml +++ b/indra/newview/skins/default/xui/en/panel_edit_alpha.xml @@ -33,7 +33,6 @@ top="0" width="313" > Date: Thu, 25 Jul 2024 23:26:16 -0400 Subject: Reduce findChild stalls during inventory construction --- indra/newview/llpanelmaininventory.cpp | 63 +++++++++++++++++----------------- indra/newview/llpanelmaininventory.h | 4 ++- 2 files changed, 34 insertions(+), 33 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index bbf533b694..fd7085c452 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -154,28 +154,30 @@ bool LLPanelMainInventory::postBuild() //panel->getFilter().markDefault(); // Set up the default inv. panel/filter settings. - mActivePanel = getChild(ALL_ITEMS); - if (mActivePanel) + mAllItemsPanel = getChild(ALL_ITEMS); + if (mAllItemsPanel) { // "All Items" is the previous only view, so it gets the InventorySortOrder - mActivePanel->setSortOrder(gSavedSettings.getU32(LLInventoryPanel::DEFAULT_SORT_ORDER)); - mActivePanel->getFilter().markDefault(); - mActivePanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState); - mActivePanel->setSelectCallback(boost::bind(&LLPanelMainInventory::onSelectionChange, this, mActivePanel, _1, _2)); + mAllItemsPanel->setSortOrder(gSavedSettings.getU32(LLInventoryPanel::DEFAULT_SORT_ORDER)); + mAllItemsPanel->getFilter().markDefault(); + mAllItemsPanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState); + mAllItemsPanel->setSelectCallback(boost::bind(&LLPanelMainInventory::onSelectionChange, this, mAllItemsPanel, _1, _2)); mResortActivePanel = true; } - LLInventoryPanel* recent_items_panel = getChild(RECENT_ITEMS); - if (recent_items_panel) + mActivePanel = mAllItemsPanel; + + mRecentPanel = getChild(RECENT_ITEMS); + if (mRecentPanel) { // assign default values until we will be sure that we have setting to restore - recent_items_panel->setSinceLogoff(true); - recent_items_panel->setSortOrder(LLInventoryFilter::SO_DATE); - recent_items_panel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); - LLInventoryFilter& recent_filter = recent_items_panel->getFilter(); + mRecentPanel->setSinceLogoff(true); + mRecentPanel->setSortOrder(LLInventoryFilter::SO_DATE); + mRecentPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); + LLInventoryFilter& recent_filter = mRecentPanel->getFilter(); recent_filter.setFilterObjectTypes(recent_filter.getFilterObjectTypes() & ~(0x1 << LLInventoryType::IT_CATEGORY)); recent_filter.setEmptyLookupMessage("InventoryNoMatchingRecentItems"); recent_filter.markDefault(); - recent_items_panel->setSelectCallback(boost::bind(&LLPanelMainInventory::onSelectionChange, this, recent_items_panel, _1, _2)); + mRecentPanel->setSelectCallback(boost::bind(&LLPanelMainInventory::onSelectionChange, this, mRecentPanel, _1, _2)); } mWornItemsPanel = getChild(WORN_ITEMS); @@ -211,17 +213,17 @@ bool LLPanelMainInventory::postBuild() // Load the persistent "Recent Items" settings. // Note that the "All Items" settings do not persist. - if(recent_items_panel) + if(mRecentPanel) { - if(savedFilterState.has(recent_items_panel->getFilter().getName())) + if(savedFilterState.has(mRecentPanel->getFilter().getName())) { LLSD recent_items = savedFilterState.get( - recent_items_panel->getFilter().getName()); + mRecentPanel->getFilter().getName()); LLInventoryFilter::Params p; LLParamSDParser parser; parser.readSD(recent_items, p); - recent_items_panel->getFilter().fromParams(p); - recent_items_panel->setSortOrder(gSavedSettings.getU32(LLInventoryPanel::RECENTITEMS_SORT_ORDER)); + mRecentPanel->getFilter().fromParams(p); + mRecentPanel->setSortOrder(gSavedSettings.getU32(LLInventoryPanel::RECENTITEMS_SORT_ORDER)); } } if(mActivePanel) @@ -362,7 +364,7 @@ LLPanelMainInventory::~LLPanelMainInventory( void ) LLInventoryPanel* LLPanelMainInventory::getAllItemsPanel() { - return getChild(ALL_ITEMS); + return mAllItemsPanel; } void LLPanelMainInventory::selectAllItemsPanel() @@ -372,7 +374,7 @@ void LLPanelMainInventory::selectAllItemsPanel() bool LLPanelMainInventory::isRecentItemsPanelSelected() { - return (RECENT_ITEMS == getActivePanel()->getName()); + return (mRecentPanel == getActivePanel()); } void LLPanelMainInventory::startSearch() @@ -1077,8 +1079,8 @@ void LLPanelMainInventory::toggleFindOptions() void LLPanelMainInventory::setSelectCallback(const LLFolderView::signal_t::slot_type& cb) { - getChild(ALL_ITEMS)->setSelectCallback(cb); - getChild(RECENT_ITEMS)->setSelectCallback(cb); + mAllItemsPanel->setSelectCallback(cb); + mRecentPanel->setSelectCallback(cb); } void LLPanelMainInventory::onSelectionChange(LLInventoryPanel *panel, const std::deque& items, bool user_action) @@ -1482,10 +1484,10 @@ void LLFloaterInventoryFinder::selectNoTypes(void* user_data) void LLPanelMainInventory::initListCommandsHandlers() { childSetAction("add_btn", boost::bind(&LLPanelMainInventory::onAddButtonClick, this)); - childSetAction("view_mode_btn", boost::bind(&LLPanelMainInventory::onViewModeClick, this)); - childSetAction("up_btn", boost::bind(&LLPanelMainInventory::onUpFolderClicked, this)); - childSetAction("back_btn", boost::bind(&LLPanelMainInventory::onBackFolderClicked, this)); - childSetAction("forward_btn", boost::bind(&LLPanelMainInventory::onForwardFolderClicked, this)); + mViewModeBtn->setCommitCallback(boost::bind(&LLPanelMainInventory::onViewModeClick, this)); + mUpBtn->setCommitCallback(boost::bind(&LLPanelMainInventory::onUpFolderClicked, this)); + mBackBtn->setCommitCallback(boost::bind(&LLPanelMainInventory::onBackFolderClicked, this)); + mForwardBtn->setCommitCallback(boost::bind(&LLPanelMainInventory::onForwardFolderClicked, this)); mCommitCallbackRegistrar.add("Inventory.GearDefault.Custom.Action", boost::bind(&LLPanelMainInventory::onCustomAction, this, _2)); mEnableCallbackRegistrar.add("Inventory.GearDefault.Check", boost::bind(&LLPanelMainInventory::isActionChecked, this, _2)); @@ -1550,12 +1552,9 @@ void LLPanelMainInventory::initSingleFolderRoot(const LLUUID& start_folder_id) void LLPanelMainInventory::initInventoryViews() { - LLInventoryPanel* all_item = getChild(ALL_ITEMS); - all_item->initializeViewBuilding(); - LLInventoryPanel* recent_item = getChild(RECENT_ITEMS); - recent_item->initializeViewBuilding(); - LLInventoryPanel* worn_item = getChild(WORN_ITEMS); - worn_item->initializeViewBuilding(); + mAllItemsPanel->initializeViewBuilding(); + mRecentPanel->initializeViewBuilding(); + mWornItemsPanel->initializeViewBuilding(); } void LLPanelMainInventory::toggleViewMode() diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h index cad2501645..68ac3410d8 100644 --- a/indra/newview/llpanelmaininventory.h +++ b/indra/newview/llpanelmaininventory.h @@ -184,7 +184,9 @@ private: LLUICtrl* mCounterCtrl; LLHandle mFinderHandle; LLInventoryPanel* mActivePanel; - LLInventoryPanel* mWornItemsPanel; + LLInventoryPanel* mAllItemsPanel = nullptr; + LLInventoryPanel* mRecentPanel = nullptr; + LLInventoryPanel* mWornItemsPanel = nullptr; bool mResortActivePanel; LLSaveFolderState* mSavedFolderState; std::string mFilterText; -- cgit v1.2.3 From 543dbfee498b84e440ea75ae156d8d666ba1c1c9 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Thu, 25 Jul 2024 23:26:52 -0400 Subject: Reduce findChild stalls in face panel --- indra/newview/llpanelface.cpp | 413 +++++++++++++++++------------------------- indra/newview/llpanelface.h | 27 ++- 2 files changed, 190 insertions(+), 250 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 00338d3125..0afe967839 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -201,13 +201,11 @@ LLRender::eTexIndex LLPanelFace::getTextureChannelToEdit() U32 matmedia_selection = mComboMatMedia->getCurrentIndex(); if (matmedia_selection == MATMEDIA_MATERIAL) { - LLRadioGroup* radio_mat_type = getChild("radio_material_type"); - channel_to_edit = (LLRender::eTexIndex)radio_mat_type->getSelectedIndex(); + channel_to_edit = (LLRender::eTexIndex)mRadioMaterialType->getSelectedIndex(); } if (matmedia_selection == MATMEDIA_PBR) { - LLRadioGroup* radio_mat_type = getChild("radio_pbr_type"); - channel_to_edit = (LLRender::eTexIndex)radio_mat_type->getSelectedIndex(); + channel_to_edit = (LLRender::eTexIndex)mRadioPbrType->getSelectedIndex(); } } @@ -220,8 +218,7 @@ LLRender::eTexIndex LLPanelFace::getTextureDropChannel() { if (mComboMatMedia && mComboMatMedia->getCurrentIndex() == MATMEDIA_MATERIAL) { - LLRadioGroup* radio_mat_type = getChild("radio_material_type"); - return LLRender::eTexIndex(radio_mat_type->getSelectedIndex()); + return LLRender::eTexIndex(mRadioMaterialType->getSelectedIndex()); } return LLRender::eTexIndex(MATTYPE_DIFFUSE); @@ -231,8 +228,7 @@ LLGLTFMaterial::TextureInfo LLPanelFace::getPBRDropChannel() { if (mComboMatMedia && mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR) { - LLRadioGroup* radio_pbr_type = getChild("radio_pbr_type"); - return texture_info_from_pbrtype(radio_pbr_type->getSelectedIndex()); + return texture_info_from_pbrtype(mRadioPbrType->getSelectedIndex()); } return texture_info_from_pbrtype(PBRTYPE_BASE_COLOR); @@ -240,8 +236,8 @@ LLGLTFMaterial::TextureInfo LLPanelFace::getPBRDropChannel() // Things the UI provides... // -LLUUID LLPanelFace::getCurrentNormalMap() { return getChild("bumpytexture control")->getImageAssetID(); } -LLUUID LLPanelFace::getCurrentSpecularMap() { return getChild("shinytexture control")->getImageAssetID(); } +LLUUID LLPanelFace::getCurrentNormalMap() { return mBumpyTextureCtrl->getImageAssetID(); } +LLUUID LLPanelFace::getCurrentSpecularMap() { return mShinyTextureCtrl->getImageAssetID(); } U32 LLPanelFace::getCurrentShininess() { return getChild("combobox shininess")->getCurrentIndex(); } U32 LLPanelFace::getCurrentBumpiness() { return getChild("combobox bumpiness")->getCurrentIndex(); } U8 LLPanelFace::getCurrentDiffuseAlphaMode() { return (U8)getChild("combobox alphamode")->getCurrentIndex(); } @@ -307,41 +303,26 @@ bool LLPanelFace::postBuild() childSetAction("edit_selected_pbr", &LLPanelFace::onClickBtnEditPBR, this); childSetAction("save_selected_pbr", &LLPanelFace::onClickBtnSavePBR, this); - LLTextureCtrl* mTextureCtrl; - LLTextureCtrl* mShinyTextureCtrl; - LLTextureCtrl* mBumpyTextureCtrl; - LLColorSwatchCtrl* mColorSwatch; - LLColorSwatchCtrl* mShinyColorSwatch; - - LLComboBox* mComboTexGen; - - LLCheckBoxCtrl *mCheckFullbright; - - LLTextBox* mLabelColorTransp; - LLSpinCtrl* mCtrlColorTransp; // transparency = 1 - alpha - - LLSpinCtrl* mCtrlGlow; - setMouseOpaque(false); - LLTextureCtrl* pbr_ctrl = findChild("pbr_control"); - if (pbr_ctrl) + mPBRTextureCtrl = getChild("pbr_control"); + if (mPBRTextureCtrl) { - pbr_ctrl->setDefaultImageAssetID(LLUUID::null); - pbr_ctrl->setBlankImageAssetID(BLANK_MATERIAL_ASSET_ID); - pbr_ctrl->setCommitCallback(boost::bind(&LLPanelFace::onCommitPbr, this, _2)); - pbr_ctrl->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelPbr, this, _2)); - pbr_ctrl->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectPbr, this, _2)); - pbr_ctrl->setDragCallback(boost::bind(&LLPanelFace::onDragPbr, this, _2)); - pbr_ctrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onPbrSelectionChanged, this, _1)); - pbr_ctrl->setOnCloseCallback(boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2)); + mPBRTextureCtrl->setDefaultImageAssetID(LLUUID::null); + mPBRTextureCtrl->setBlankImageAssetID(BLANK_MATERIAL_ASSET_ID); + mPBRTextureCtrl->setCommitCallback(boost::bind(&LLPanelFace::onCommitPbr, this, _2)); + mPBRTextureCtrl->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelPbr, this, _2)); + mPBRTextureCtrl->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectPbr, this, _2)); + mPBRTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragPbr, this, _2)); + mPBRTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onPbrSelectionChanged, this, _1)); + mPBRTextureCtrl->setOnCloseCallback(boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2)); - pbr_ctrl->setFollowsTop(); - pbr_ctrl->setFollowsLeft(); - pbr_ctrl->setImmediateFilterPermMask(PERM_NONE); - pbr_ctrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); - pbr_ctrl->setBakeTextureEnabled(false); - pbr_ctrl->setInventoryPickType(PICK_MATERIAL); + mPBRTextureCtrl->setFollowsTop(); + mPBRTextureCtrl->setFollowsLeft(); + mPBRTextureCtrl->setImmediateFilterPermMask(PERM_NONE); + mPBRTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); + mPBRTextureCtrl->setBakeTextureEnabled(false); + mPBRTextureCtrl->setInventoryPickType(PICK_MATERIAL); } mTextureCtrl = getChild("texture control"); @@ -454,18 +435,18 @@ bool LLPanelFace::postBuild() mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL); } - LLRadioGroup* radio_mat_type = findChild("radio_material_type"); - if(radio_mat_type) + mRadioMaterialType = getChild("radio_material_type"); + if(mRadioMaterialType) { - radio_mat_type->setCommitCallback(LLPanelFace::onCommitMaterialType, this); - radio_mat_type->selectNthItem(MATTYPE_DIFFUSE); + mRadioMaterialType->setCommitCallback(LLPanelFace::onCommitMaterialType, this); + mRadioMaterialType->selectNthItem(MATTYPE_DIFFUSE); } - LLRadioGroup* radio_pbr_type = findChild("radio_pbr_type"); - if (radio_pbr_type) + mRadioPbrType = getChild("radio_pbr_type"); + if (mRadioPbrType) { - radio_pbr_type->setCommitCallback(LLPanelFace::onCommitPbrType, this); - radio_pbr_type->selectNthItem(PBRTYPE_RENDER_MATERIAL_ID); + mRadioPbrType->setCommitCallback(LLPanelFace::onCommitPbrType, this); + mRadioPbrType->selectNthItem(PBRTYPE_RENDER_MATERIAL_ID); } mCtrlGlow = getChild("glow"); @@ -532,7 +513,6 @@ void LLPanelFace::draw() void LLPanelFace::sendTexture() { - LLTextureCtrl* mTextureCtrl = getChild("texture control"); if(!mTextureCtrl) return; if( !mTextureCtrl->getTentative() ) { @@ -553,17 +533,16 @@ void LLPanelFace::sendTexture() void LLPanelFace::sendBump(U32 bumpiness) { - LLTextureCtrl* bumpytexture_ctrl = getChild("bumpytexture control"); if (bumpiness < BUMPY_TEXTURE) { LL_DEBUGS("Materials") << "clearing bumptexture control" << LL_ENDL; - bumpytexture_ctrl->clear(); - bumpytexture_ctrl->setImageAssetID(LLUUID()); + mBumpyTextureCtrl->clear(); + mBumpyTextureCtrl->setImageAssetID(LLUUID()); } updateBumpyControls(bumpiness == BUMPY_TEXTURE, true); - LLUUID current_normal_map = bumpytexture_ctrl->getImageAssetID(); + LLUUID current_normal_map = mBumpyTextureCtrl->getImageAssetID(); U8 bump = (U8) bumpiness & TEM_BUMP_MASK; @@ -576,25 +555,21 @@ void LLPanelFace::sendBump(U32 bumpiness) // LLSelectedTEMaterial::setNormalID(this, current_normal_map); - LLSelectMgr::getInstance()->selectionSetBumpmap( bump, bumpytexture_ctrl->getImageItemID() ); + LLSelectMgr::getInstance()->selectionSetBumpmap( bump, mBumpyTextureCtrl->getImageItemID() ); } void LLPanelFace::sendTexGen() { - LLComboBox* mComboTexGen = getChild("combobox texgen"); - if(!mComboTexGen)return; U8 tex_gen = (U8) mComboTexGen->getCurrentIndex() << TEM_TEX_GEN_SHIFT; LLSelectMgr::getInstance()->selectionSetTexGen( tex_gen ); } void LLPanelFace::sendShiny(U32 shininess) { - LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); - if (shininess < SHINY_TEXTURE) { - texture_ctrl->clear(); - texture_ctrl->setImageAssetID(LLUUID()); + mShinyTextureCtrl->clear(); + mShinyTextureCtrl->setImageAssetID(LLUUID()); } LLUUID specmap = getCurrentSpecularMap(); @@ -605,7 +580,7 @@ void LLPanelFace::sendShiny(U32 shininess) LLSelectedTEMaterial::setSpecularID(this, specmap); - LLSelectMgr::getInstance()->selectionSetShiny( shiny, texture_ctrl->getImageItemID() ); + LLSelectMgr::getInstance()->selectionSetShiny( shiny, mShinyTextureCtrl->getImageItemID() ); updateShinyControls(!specmap.isNull(), true); @@ -613,7 +588,6 @@ void LLPanelFace::sendShiny(U32 shininess) void LLPanelFace::sendFullbright() { - LLCheckBoxCtrl* mCheckFullbright = getChild("checkbox fullbright"); if(!mCheckFullbright)return; U8 fullbright = mCheckFullbright->get() ? TEM_FULLBRIGHT_MASK : 0; LLSelectMgr::getInstance()->selectionSetFullbright( fullbright ); @@ -621,8 +595,6 @@ void LLPanelFace::sendFullbright() void LLPanelFace::sendColor() { - - LLColorSwatchCtrl* mColorSwatch = getChild("colorswatch"); if(!mColorSwatch)return; LLColor4 color = mColorSwatch->get(); @@ -631,7 +603,6 @@ void LLPanelFace::sendColor() void LLPanelFace::sendAlpha() { - LLSpinCtrl* mCtrlColorTransp = getChild("ColorTrans"); if(!mCtrlColorTransp)return; F32 alpha = (100.f - mCtrlColorTransp->get()) / 100.f; @@ -641,8 +612,6 @@ void LLPanelFace::sendAlpha() void LLPanelFace::sendGlow() { - LLSpinCtrl* mCtrlGlow = getChild("glow"); - llassert(mCtrlGlow); if (mCtrlGlow) { F32 glow = mCtrlGlow->get(); @@ -996,14 +965,13 @@ void LLPanelFace::sendTextureInfo() LLSelectMgr::getInstance()->getSelection()->applyToObjects(&sendfunc); } -void LLPanelFace::alignTestureLayer() +void LLPanelFace::alignTextureLayer() { LLFace* last_face = NULL; bool identical_face = false; LLSelectedTE::getFace(last_face, identical_face); - LLRadioGroup * radio_mat_type = getChild("radio_material_type"); - LLPanelFaceSetAlignedConcreteTEFunctor setfunc(this, last_face, static_cast(radio_mat_type->getSelectedIndex())); + LLPanelFaceSetAlignedConcreteTEFunctor setfunc(this, last_face, static_cast(mRadioMaterialType->getSelectedIndex())); LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc); } @@ -1055,10 +1023,6 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) bool identical_norm = false; bool identical_spec = false; - LLTextureCtrl *texture_ctrl = getChild("texture control"); - LLTextureCtrl *shinytexture_ctrl = getChild("shinytexture control"); - LLTextureCtrl *bumpytexture_ctrl = getChild("bumpytexture control"); - LLUUID id; LLUUID normmap_id; LLUUID specmap_id; @@ -1122,21 +1086,19 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) } mComboMatMedia->setEnabled(editable); - LLRadioGroup* radio_mat_type = getChild("radio_material_type"); - if (radio_mat_type->getSelectedIndex() < MATTYPE_DIFFUSE) + if (mRadioMaterialType->getSelectedIndex() < MATTYPE_DIFFUSE) { - radio_mat_type->selectNthItem(MATTYPE_DIFFUSE); + mRadioMaterialType->selectNthItem(MATTYPE_DIFFUSE); } - radio_mat_type->setEnabled(editable); + mRadioMaterialType->setEnabled(editable); - LLRadioGroup* radio_pbr_type = getChild("radio_pbr_type"); - if (radio_pbr_type->getSelectedIndex() < PBRTYPE_RENDER_MATERIAL_ID) + if (mRadioPbrType->getSelectedIndex() < PBRTYPE_RENDER_MATERIAL_ID) { - radio_pbr_type->selectNthItem(PBRTYPE_RENDER_MATERIAL_ID); + mRadioPbrType->selectNthItem(PBRTYPE_RENDER_MATERIAL_ID); } - radio_pbr_type->setEnabled(editable); + mRadioPbrType->setEnabled(editable); const bool pbr_selected = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR; - const bool texture_info_selected = pbr_selected && radio_pbr_type->getSelectedIndex() != PBRTYPE_RENDER_MATERIAL_ID; + const bool texture_info_selected = pbr_selected && mRadioPbrType->getSelectedIndex() != PBRTYPE_RENDER_MATERIAL_ID; getChildView("checkbox_sync_settings")->setEnabled(editable); childSetValue("checkbox_sync_settings", gSavedSettings.getBOOL("SyncMaterialSettings")); @@ -1147,30 +1109,28 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) { getChildView("color label")->setEnabled(editable); } - LLColorSwatchCtrl* color_swatch = findChild("colorswatch"); LLColor4 color = LLColor4::white; bool identical_color = false; - if (color_swatch) { LLSelectedTE::getColor(color, identical_color); - LLColor4 prev_color = color_swatch->get(); + LLColor4 prev_color = mColorSwatch->get(); - color_swatch->setOriginal(color); - color_swatch->set(color, force_set_values || (prev_color != color) || !editable); + mColorSwatch->setOriginal(color); + mColorSwatch->set(color, force_set_values || (prev_color != color) || !editable); - color_swatch->setValid(editable && !has_pbr_material); - color_swatch->setEnabled( editable && !has_pbr_material); - color_swatch->setCanApplyImmediately( editable && !has_pbr_material); + mColorSwatch->setValid(editable && !has_pbr_material); + mColorSwatch->setEnabled( editable && !has_pbr_material); + mColorSwatch->setCanApplyImmediately( editable && !has_pbr_material); } // Color transparency - getChildView("color trans")->setEnabled(editable); + mLabelColorTransp->setEnabled(editable); F32 transparency = (1.f - color.mV[VALPHA]) * 100.f; - getChild("ColorTrans")->setValue(editable ? transparency : 0); - getChildView("ColorTrans")->setEnabled(editable && has_material); + mCtrlColorTransp->setValue(editable ? transparency : 0); + mCtrlColorTransp->setEnabled(editable && has_material); U8 shiny = 0; bool identical_shiny = false; @@ -1200,10 +1160,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChild("combobox shininess")->setTentative(!identical_spec); getChild("glossiness")->setTentative(!identical_spec); getChild("environment")->setTentative(!identical_spec); - getChild("shinycolorswatch")->setTentative(!identical_spec); + mShinyColorSwatch->setTentative(!identical_spec); - LLColorSwatchCtrl* mShinyColorSwatch = getChild("shinycolorswatch"); - if (mShinyColorSwatch) { mShinyColorSwatch->setValid(editable); mShinyColorSwatch->setEnabled( editable ); @@ -1304,13 +1262,13 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) updateAlphaControls(); - if (texture_ctrl) + if (mTextureCtrl) { if (identical_diffuse) { - texture_ctrl->setTentative(false); - texture_ctrl->setEnabled(editable && !has_pbr_material); - texture_ctrl->setImageAssetID(id); + mTextureCtrl->setTentative(false); + mTextureCtrl->setEnabled(editable && !has_pbr_material); + mTextureCtrl->setImageAssetID(id); bool can_change_alpha = editable && mIsAlpha && !missing_asset && !has_pbr_material; getChildView("combobox alphamode")->setEnabled(can_change_alpha && transparency <= 0.f); @@ -1318,27 +1276,27 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChildView("maskcutoff")->setEnabled(can_change_alpha); getChildView("label maskcutoff")->setEnabled(can_change_alpha); - texture_ctrl->setBakeTextureEnabled(true); + mTextureCtrl->setBakeTextureEnabled(true); } else if (id.isNull()) { // None selected - texture_ctrl->setTentative(false); - texture_ctrl->setEnabled(false); - texture_ctrl->setImageAssetID(LLUUID::null); + mTextureCtrl->setTentative(false); + mTextureCtrl->setEnabled(false); + mTextureCtrl->setImageAssetID(LLUUID::null); getChildView("combobox alphamode")->setEnabled(false); getChildView("label alphamode")->setEnabled(false); getChildView("maskcutoff")->setEnabled(false); getChildView("label maskcutoff")->setEnabled(false); - texture_ctrl->setBakeTextureEnabled(false); + mTextureCtrl->setBakeTextureEnabled(false); } else { // Tentative: multiple selected with different textures - texture_ctrl->setTentative(true); - texture_ctrl->setEnabled(editable && !has_pbr_material); - texture_ctrl->setImageAssetID(id); + mTextureCtrl->setTentative(true); + mTextureCtrl->setEnabled(editable && !has_pbr_material); + mTextureCtrl->setImageAssetID(id); bool can_change_alpha = editable && mIsAlpha && !missing_asset && !has_pbr_material; getChildView("combobox alphamode")->setEnabled(can_change_alpha && transparency <= 0.f); @@ -1346,7 +1304,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChildView("maskcutoff")->setEnabled(can_change_alpha); getChildView("label maskcutoff")->setEnabled(can_change_alpha); - texture_ctrl->setBakeTextureEnabled(true); + mTextureCtrl->setBakeTextureEnabled(true); } if (attachment) @@ -1354,43 +1312,43 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) // attachments are in world and in inventory, // server doesn't support changing permissions // in such case - texture_ctrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER); + mTextureCtrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER); } else { - texture_ctrl->setImmediateFilterPermMask(PERM_NONE); + mTextureCtrl->setImmediateFilterPermMask(PERM_NONE); } } - if (shinytexture_ctrl) + if (mShinyTextureCtrl) { - shinytexture_ctrl->setTentative( !identical_spec ); - shinytexture_ctrl->setEnabled( editable && !has_pbr_material); - shinytexture_ctrl->setImageAssetID( specmap_id ); + mShinyTextureCtrl->setTentative( !identical_spec ); + mShinyTextureCtrl->setEnabled( editable && !has_pbr_material); + mShinyTextureCtrl->setImageAssetID( specmap_id ); if (attachment) { - shinytexture_ctrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER); + mShinyTextureCtrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER); } else { - shinytexture_ctrl->setImmediateFilterPermMask(PERM_NONE); + mShinyTextureCtrl->setImmediateFilterPermMask(PERM_NONE); } } - if (bumpytexture_ctrl) + if (mBumpyTextureCtrl) { - bumpytexture_ctrl->setTentative( !identical_norm ); - bumpytexture_ctrl->setEnabled( editable && !has_pbr_material); - bumpytexture_ctrl->setImageAssetID( normmap_id ); + mBumpyTextureCtrl->setTentative( !identical_norm ); + mBumpyTextureCtrl->setEnabled( editable && !has_pbr_material); + mBumpyTextureCtrl->setImageAssetID( normmap_id ); if (attachment) { - bumpytexture_ctrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER); + mBumpyTextureCtrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER); } else { - bumpytexture_ctrl->setImmediateFilterPermMask(PERM_NONE); + mBumpyTextureCtrl->setImmediateFilterPermMask(PERM_NONE); } } } @@ -1621,26 +1579,18 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) F32 glow = 0.f; bool identical_glow = false; LLSelectedTE::getGlow(glow,identical_glow); - getChild("glow")->setValue(glow); - getChild("glow")->setTentative(!identical_glow); - getChildView("glow")->setEnabled(editable); + mCtrlGlow->setValue(glow); + mCtrlGlow->setTentative(!identical_glow); + mCtrlGlow->setEnabled(editable); getChildView("glow label")->setEnabled(editable); } { - LLCtrlSelectionInterface* combobox_texgen = childGetSelectionInterface("combobox texgen"); - if (combobox_texgen) - { - // Maps from enum to combobox entry index - combobox_texgen->selectNthItem(((S32)selected_texgen) >> 1); - } - else - { - LL_WARNS() << "failed childGetSelectionInterface for 'combobox texgen'" << LL_ENDL; - } + // Maps from enum to combobox entry index + mComboTexGen->selectNthItem(((S32)selected_texgen) >> 1); - getChildView("combobox texgen")->setEnabled(editable); - getChild("combobox texgen")->setTentative(!identical); + mComboTexGen->setEnabled(editable); + mComboTexGen->setTentative(!identical); getChildView("tex gen")->setEnabled(editable); } @@ -1650,9 +1600,9 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLSelectedTE::getFullbright(fullbright_flag,identical_fullbright); - getChild("checkbox fullbright")->setValue((S32)(fullbright_flag != 0)); - getChildView("checkbox fullbright")->setEnabled(editable && !has_pbr_material); - getChild("checkbox fullbright")->setTentative(!identical_fullbright); + mCheckFullbright->setValue((S32)(fullbright_flag != 0)); + mCheckFullbright->setEnabled(editable && !has_pbr_material); + mCheckFullbright->setTentative(!identical_fullbright); mComboMatMedia->setEnabledByValue("Materials", !has_pbr_material); } @@ -1670,8 +1620,6 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLSelectedTEMaterial::getMaxNormalRepeats(repeats_norm, identical_norm_repeats); LLSelectedTEMaterial::getMaxSpecularRepeats(repeats_spec, identical_spec_repeats); - LLComboBox* mComboTexGen = getChild("combobox texgen"); - if (mComboTexGen) { S32 index = mComboTexGen ? mComboTexGen->getCurrentIndex() : 0; bool enabled = editable && (index != 1); @@ -1682,12 +1630,12 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) U32 material_type = MATTYPE_DIFFUSE; if (material_selection == MATMEDIA_MATERIAL) { - material_type = radio_mat_type->getSelectedIndex(); + material_type = mRadioMaterialType->getSelectedIndex(); } else if (material_selection == MATMEDIA_PBR) { enabled = editable && has_pbr_material; - material_type = radio_pbr_type->getSelectedIndex(); + material_type = mRadioPbrType->getSelectedIndex(); } switch (material_type) @@ -1783,8 +1731,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) // Shiny (specular) F32 offset_x, offset_y, repeat_x, repeat_y, rot; - LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); - texture_ctrl->setImageAssetID(material->getSpecularID()); + mShinyTextureCtrl->setImageAssetID(material->getSpecularID()); if (!material->getSpecularID().isNull() && (shiny == SHINY_TEXTURE)) { @@ -1814,17 +1761,15 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) // if (!material->getSpecularID().isNull()) { - LLColorSwatchCtrl* shiny_swatch = getChild("shinycolorswatch"); LLColor4 new_color = material->getSpecularLightColor(); - LLColor4 old_color = shiny_swatch->get(); + LLColor4 old_color = mShinyColorSwatch->get(); - shiny_swatch->setOriginal(new_color); - shiny_swatch->set(new_color, force_set_values || old_color != new_color || !editable); + mShinyColorSwatch->setOriginal(new_color); + mShinyColorSwatch->set(new_color, force_set_values || old_color != new_color || !editable); } // Bumpy (normal) - texture_ctrl = getChild("bumpytexture control"); - texture_ctrl->setImageAssetID(material->getNormalID()); + mBumpyTextureCtrl->setImageAssetID(material->getNormalID()); if (!material->getNormalID().isNull()) { @@ -1859,8 +1804,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) calcp->setVar(LLCalc::TEX_U_OFFSET, (F32)childGetValue("TexOffsetU").asReal()); calcp->setVar(LLCalc::TEX_V_OFFSET, (F32)childGetValue("TexOffsetV").asReal()); calcp->setVar(LLCalc::TEX_ROTATION, (F32)childGetValue("TexRot").asReal()); - calcp->setVar(LLCalc::TEX_TRANSPARENCY, (F32)childGetValue("ColorTrans").asReal()); - calcp->setVar(LLCalc::TEX_GLOW, (F32)childGetValue("glow").asReal()); + calcp->setVar(LLCalc::TEX_TRANSPARENCY, (F32)mCtrlColorTransp->getValue().asReal()); + calcp->setVar(LLCalc::TEX_GLOW, (F32)mCtrlGlow->getValue().asReal()); } else { @@ -1868,32 +1813,31 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) clearCtrls(); // Disable non-UICtrls - LLTextureCtrl* pbr_ctrl = findChild("pbr_control"); - if (pbr_ctrl) + if (mPBRTextureCtrl) { - pbr_ctrl->setImageAssetID(LLUUID::null); - pbr_ctrl->setEnabled(false); + mPBRTextureCtrl->setImageAssetID(LLUUID::null); + mPBRTextureCtrl->setEnabled(false); } - LLTextureCtrl* texture_ctrl = getChild("texture control"); - if (texture_ctrl) + + if (mTextureCtrl) { - texture_ctrl->setImageAssetID( LLUUID::null ); - texture_ctrl->setEnabled( false ); // this is a LLUICtrl, but we don't want it to have keyboard focus so we add it as a child, not a ctrl. -// texture_ctrl->setValid(false); + mTextureCtrl->setImageAssetID( LLUUID::null ); + mTextureCtrl->setEnabled( false ); // this is a LLUICtrl, but we don't want it to have keyboard focus so we add it as a child, not a ctrl. +// mTextureCtrl->setValid(false); } - LLColorSwatchCtrl* mColorSwatch = getChild("colorswatch"); + if (mColorSwatch) { mColorSwatch->setEnabled( false ); mColorSwatch->setFallbackImage(LLUI::getUIImage("locked_image.j2c") ); mColorSwatch->setValid(false); } - LLRadioGroup* radio_mat_type = getChild("radio_material_type"); - if (radio_mat_type) + + if (mRadioMaterialType) { - radio_mat_type->setSelectedIndex(0); + mRadioMaterialType->setSelectedIndex(0); } - getChildView("color trans")->setEnabled(false); + mLabelColorTransp->setEnabled(false); getChildView("rptctrl")->setEnabled(false); getChildView("tex gen")->setEnabled(false); getChildView("label shininess")->setEnabled(false); @@ -2005,23 +1949,22 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material, const bool saveable = LLMaterialEditor::canSaveObjectsMaterial(); // pbr material - LLTextureCtrl* pbr_ctrl = findChild("pbr_control"); LLUUID pbr_id; - if (pbr_ctrl) + if (mPBRTextureCtrl) { LLSelectedTE::getPbrMaterialId(pbr_id, identical_pbr, has_pbr_material, has_faces_without_pbr); - pbr_ctrl->setTentative(!identical_pbr); - pbr_ctrl->setEnabled(settable); - pbr_ctrl->setImageAssetID(pbr_id); + mPBRTextureCtrl->setTentative(!identical_pbr); + mPBRTextureCtrl->setEnabled(settable); + mPBRTextureCtrl->setImageAssetID(pbr_id); if (objectp->isAttachment()) { - pbr_ctrl->setFilterPermissionMasks(PERM_COPY | PERM_TRANSFER | PERM_MODIFY); + mPBRTextureCtrl->setFilterPermissionMasks(PERM_COPY | PERM_TRANSFER | PERM_MODIFY); } else { - pbr_ctrl->setImmediateFilterPermMask(PERM_NONE); + mPBRTextureCtrl->setImmediateFilterPermMask(PERM_NONE); } } @@ -2080,13 +2023,12 @@ void LLPanelFace::updateVisibilityGLTF(LLViewerObject* objectp /*= nullptr */) const bool show_pbr = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR && mComboMatMedia->getEnabled(); const bool inventory_pending = objectp && objectp->isInventoryPending(); - LLRadioGroup* radio_pbr_type = findChild("radio_pbr_type"); - radio_pbr_type->setVisible(show_pbr); + mRadioPbrType->setVisible(show_pbr); - const U32 pbr_type = radio_pbr_type->getSelectedIndex(); + const U32 pbr_type = mRadioPbrType->getSelectedIndex(); const bool show_pbr_render_material_id = show_pbr && (pbr_type == PBRTYPE_RENDER_MATERIAL_ID); - getChildView("pbr_control")->setVisible(show_pbr_render_material_id); + mPBRTextureCtrl->setVisible(show_pbr_render_material_id); getChildView("pbr_from_inventory")->setVisible(show_pbr_render_material_id); getChildView("edit_selected_pbr")->setVisible(show_pbr_render_material_id && !inventory_pending); @@ -2890,7 +2832,7 @@ void LLPanelFace::onCommitColor(const LLSD& data) void LLPanelFace::onCommitShinyColor(const LLSD& data) { - LLSelectedTEMaterial::setSpecularLightColor(this, getChild("shinycolorswatch")->get()); + LLSelectedTEMaterial::setSpecularLightColor(this, mShinyColorSwatch->get()); } void LLPanelFace::onCommitAlpha(const LLSD& data) @@ -2916,7 +2858,7 @@ void LLPanelFace::onSelectColor(const LLSD& data) void LLPanelFace::onSelectShinyColor(const LLSD& data) { - LLSelectedTEMaterial::setSpecularLightColor(this, getChild("shinycolorswatch")->get()); + LLSelectedTEMaterial::setSpecularLightColor(this, mShinyColorSwatch->get()); LLSelectMgr::getInstance()->saveSelectedShinyColors(); } @@ -2935,33 +2877,31 @@ void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) void LLPanelFace::updateVisibility(LLViewerObject* objectp /* = nullptr */) { - LLRadioGroup* radio_mat_type = findChild("radio_material_type"); - LLRadioGroup* radio_pbr_type = findChild("radio_pbr_type"); LLComboBox* combo_shininess = findChild("combobox shininess"); LLComboBox* combo_bumpiness = findChild("combobox bumpiness"); - if (!radio_mat_type || !radio_pbr_type || !mComboMatMedia || !combo_shininess || !combo_bumpiness) + if (!mRadioMaterialType || !mRadioPbrType || !mComboMatMedia || !combo_shininess || !combo_bumpiness) { LL_WARNS("Materials") << "Combo box not found...exiting." << LL_ENDL; return; } U32 materials_media = mComboMatMedia->getCurrentIndex(); - U32 material_type = radio_mat_type->getSelectedIndex(); + U32 material_type = mRadioMaterialType->getSelectedIndex(); bool show_media = (materials_media == MATMEDIA_MEDIA) && mComboMatMedia->getEnabled(); bool show_material = materials_media == MATMEDIA_MATERIAL; bool show_texture = (show_media || (show_material && (material_type == MATTYPE_DIFFUSE) && mComboMatMedia->getEnabled())); bool show_bumpiness = show_material && (material_type == MATTYPE_NORMAL) && mComboMatMedia->getEnabled(); bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && mComboMatMedia->getEnabled(); const bool show_pbr = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR && mComboMatMedia->getEnabled(); - const U32 pbr_type = findChild("radio_pbr_type")->getSelectedIndex(); + const U32 pbr_type = mRadioPbrType->getSelectedIndex(); const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); const bool show_pbr_asset = show_pbr && texture_info == LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; - radio_mat_type->setVisible(show_material); + mRadioMaterialType->setVisible(show_material); // Shared material controls getChildView("checkbox_sync_settings")->setVisible(show_material || show_media); getChildView("tex gen")->setVisible(show_material || show_media || show_pbr_asset); - getChildView("combobox texgen")->setVisible(show_material || show_media || show_pbr_asset); + mComboTexGen->setVisible(show_material || show_media || show_pbr_asset); getChildView("button align textures")->setVisible(show_material || show_media); // Media controls @@ -2971,7 +2911,7 @@ void LLPanelFace::updateVisibility(LLViewerObject* objectp /* = nullptr */) getChildView("button align")->setVisible(show_media); // Diffuse texture controls - getChildView("texture control")->setVisible(show_texture && show_material); + mTextureCtrl->setVisible(show_texture && show_material); getChildView("label alphamode")->setVisible(show_texture && show_material); getChildView("combobox alphamode")->setVisible(show_texture && show_material); getChildView("label maskcutoff")->setVisible(false); @@ -2988,7 +2928,7 @@ void LLPanelFace::updateVisibility(LLViewerObject* objectp /* = nullptr */) getChildView("TexOffsetV")->setVisible(show_texture); // Specular map controls - getChildView("shinytexture control")->setVisible(show_shininess); + mShinyTextureCtrl->setVisible(show_shininess); getChildView("combobox shininess")->setVisible(show_shininess); getChildView("label shininess")->setVisible(show_shininess); getChildView("label glossiness")->setVisible(false); @@ -2996,7 +2936,7 @@ void LLPanelFace::updateVisibility(LLViewerObject* objectp /* = nullptr */) getChildView("label environment")->setVisible(false); getChildView("environment")->setVisible(false); getChildView("label shinycolor")->setVisible(false); - getChildView("shinycolorswatch")->setVisible(false); + mShinyColorSwatch->setVisible(false); if (show_shininess) { updateShinyControls(); @@ -3012,7 +2952,7 @@ void LLPanelFace::updateVisibility(LLViewerObject* objectp /* = nullptr */) { updateBumpyControls(); } - getChildView("bumpytexture control")->setVisible(show_bumpiness); + mBumpyTextureCtrl->setVisible(show_bumpiness); getChildView("combobox bumpiness")->setVisible(show_bumpiness); getChildView("label bumpiness")->setVisible(show_bumpiness); getChildView("bumpyScaleU")->setVisible(show_bumpiness); @@ -3073,8 +3013,7 @@ void LLPanelFace::onCommitTexGen(LLUICtrl* ctrl, void* userdata) // static void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_shiny_combobox) { - LLTextureCtrl* texture_ctrl = getChild("shinytexture control"); - LLUUID shiny_texture_ID = texture_ctrl->getImageAssetID(); + LLUUID shiny_texture_ID = mShinyTextureCtrl->getImageAssetID(); LL_DEBUGS("Materials") << "Shiny texture selected: " << shiny_texture_ID << LL_ENDL; LLComboBox* comboShiny = getChild("combobox shininess"); @@ -3110,10 +3049,8 @@ void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_sh } } - - LLRadioGroup* radio_mat_type = getChild("radio_material_type"); U32 materials_media = mComboMatMedia->getCurrentIndex(); - U32 material_type = radio_mat_type->getSelectedIndex(); + U32 material_type = mRadioMaterialType->getSelectedIndex(); bool show_material = (materials_media == MATMEDIA_MATERIAL); bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && mComboMatMedia->getEnabled(); U32 shiny_value = comboShiny->getCurrentIndex(); @@ -3123,14 +3060,13 @@ void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_sh getChildView("label environment")->setVisible(show_shinyctrls); getChildView("environment")->setVisible(show_shinyctrls); getChildView("label shinycolor")->setVisible(show_shinyctrls); - getChildView("shinycolorswatch")->setVisible(show_shinyctrls); + mShinyColorSwatch->setVisible(show_shinyctrls); } // static void LLPanelFace::updateBumpyControls(bool is_setting_texture, bool mess_with_combobox) { - LLTextureCtrl* texture_ctrl = getChild("bumpytexture control"); - LLUUID bumpy_texture_ID = texture_ctrl->getImageAssetID(); + LLUUID bumpy_texture_ID = mBumpyTextureCtrl->getImageAssetID(); LL_DEBUGS("Materials") << "texture: " << bumpy_texture_ID << (mess_with_combobox ? "" : " do not") << " update combobox" << LL_ENDL; LLComboBox* comboBumpy = getChild("combobox bumpiness"); if (!comboBumpy) @@ -3140,10 +3076,6 @@ void LLPanelFace::updateBumpyControls(bool is_setting_texture, bool mess_with_co if (mess_with_combobox) { - LLTextureCtrl* texture_ctrl = getChild("bumpytexture control"); - LLUUID bumpy_texture_ID = texture_ctrl->getImageAssetID(); - LL_DEBUGS("Materials") << "texture: " << bumpy_texture_ID << (mess_with_combobox ? "" : " do not") << " update combobox" << LL_ENDL; - if (!bumpy_texture_ID.isNull() && is_setting_texture) { if (!comboBumpy->itemExists(USE_TEXTURE)) @@ -3196,10 +3128,9 @@ void LLPanelFace::updateAlphaControls() } U32 mat_type = MATTYPE_DIFFUSE; - LLRadioGroup* radio_mat_type = getChild("radio_material_type"); - if(radio_mat_type) + if(mRadioMaterialType) { - mat_type = radio_mat_type->getSelectedIndex(); + mat_type = mRadioMaterialType->getSelectedIndex(); } show_alphactrls = show_alphactrls && (mat_media == MATMEDIA_MATERIAL); @@ -3251,20 +3182,19 @@ bool LLPanelFace::onDragPbr(LLUICtrl*, LLInventoryItem* item) void LLPanelFace::onCommitPbr(const LLSD& data) { - LLTextureCtrl* pbr_ctrl = findChild("pbr_control"); - if (!pbr_ctrl) return; - if (!pbr_ctrl->getTentative()) + if (!mPBRTextureCtrl) return; + if (!mPBRTextureCtrl->getTentative()) { // we grab the item id first, because we want to do a // permissions check in the selection manager. ARGH! - LLUUID id = pbr_ctrl->getImageItemID(); + LLUUID id = mPBRTextureCtrl->getImageItemID(); if (id.isNull()) { - id = pbr_ctrl->getImageAssetID(); + id = mPBRTextureCtrl->getImageAssetID(); } if (!LLSelectMgr::getInstance()->selectionSetGLTFMaterial(id)) { - // If failed to set material, refresh pbr_ctrl's value + // If failed to set material, refresh mPBRTextureCtrl's value refresh(); } } @@ -3279,16 +3209,15 @@ void LLPanelFace::onSelectPbr(const LLSD& data) { LLSelectMgr::getInstance()->saveSelectedObjectTextures(); - LLTextureCtrl* pbr_ctrl = findChild("pbr_control"); - if (!pbr_ctrl) return; - if (!pbr_ctrl->getTentative()) + if (!mPBRTextureCtrl) return; + if (!mPBRTextureCtrl->getTentative()) { // we grab the item id first, because we want to do a // permissions check in the selection manager. ARGH! - LLUUID id = pbr_ctrl->getImageItemID(); + LLUUID id = mPBRTextureCtrl->getImageItemID(); if (id.isNull()) { - id = pbr_ctrl->getImageAssetID(); + id = mPBRTextureCtrl->getImageAssetID(); } if (!LLSelectMgr::getInstance()->selectionSetGLTFMaterial(id)) { @@ -3388,7 +3317,7 @@ void LLPanelFace::onCancelSpecularTexture(const LLSD& data) U8 shiny = 0; bool identical_shiny = false; LLSelectedTE::getShiny(shiny, identical_shiny); - LLUUID spec_map_id = getChild("shinytexture control")->getImageAssetID(); + LLUUID spec_map_id = mShinyTextureCtrl->getImageAssetID(); shiny = spec_map_id.isNull() ? shiny : SHINY_TEXTURE; sendShiny(shiny); } @@ -3398,7 +3327,7 @@ void LLPanelFace::onCancelNormalTexture(const LLSD& data) U8 bumpy = 0; bool identical_bumpy = false; LLSelectedTE::getBumpmap(bumpy, identical_bumpy); - LLUUID spec_map_id = getChild("bumpytexture control")->getImageAssetID(); + LLUUID spec_map_id = mBumpyTextureCtrl->getImageAssetID(); bumpy = spec_map_id.isNull() ? bumpy : BUMPY_TEXTURE; sendBump(bumpy); } @@ -3869,13 +3798,11 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) U32 material_type = 0; if (materials_media == MATMEDIA_PBR) { - LLRadioGroup *radio_mat_type = self->getChild("radio_pbr_type"); - material_type = radio_mat_type->getSelectedIndex(); + material_type = self->mRadioPbrType->getSelectedIndex(); } if (materials_media == MATMEDIA_MATERIAL) { - LLRadioGroup *radio_mat_type = self->getChild("radio_material_type"); - material_type = radio_mat_type->getSelectedIndex(); + material_type = self->mRadioMaterialType->getSelectedIndex(); } F32 repeats_per_meter = (F32) repeats_ctrl->getValue().asReal(); @@ -4003,15 +3930,14 @@ void LLPanelFace::onClickAutoFix(void* userdata) void LLPanelFace::onAlignTexture(void* userdata) { LLPanelFace* self = (LLPanelFace*)userdata; - self->alignTestureLayer(); + self->alignTextureLayer(); } void LLPanelFace::onClickBtnLoadInvPBR(void* userdata) { // Shouldn't this be "save to inventory?" LLPanelFace* self = (LLPanelFace*)userdata; - LLTextureCtrl* pbr_ctrl = self->findChild("pbr_control"); - pbr_ctrl->showPicker(true); + self->mPBRTextureCtrl->showPicker(true); } void LLPanelFace::onClickBtnEditPBR(void* userdata) @@ -4916,7 +4842,7 @@ void LLPanelFace::updateGLTFTextureTransform(float value, U32 pbr_type, std::fun void LLPanelFace::setMaterialOverridesFromSelection() { - const U32 pbr_type = findChild("radio_pbr_type")->getSelectedIndex(); + const U32 pbr_type = mRadioPbrType->getSelectedIndex(); const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); U32 texture_info_start; U32 texture_info_end; @@ -5086,7 +5012,7 @@ bool LLPanelFace::Selection::compareSelection() void LLPanelFace::onCommitGLTFTextureScaleU(LLUICtrl* ctrl) { const float value = (F32)ctrl->getValue().asReal(); - const U32 pbr_type = findChild("radio_pbr_type")->getSelectedIndex(); + const U32 pbr_type = mRadioPbrType->getSelectedIndex(); updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mScale.mV[VX] = value; @@ -5096,7 +5022,7 @@ void LLPanelFace::onCommitGLTFTextureScaleU(LLUICtrl* ctrl) void LLPanelFace::onCommitGLTFTextureScaleV(LLUICtrl* ctrl) { const float value = (F32)ctrl->getValue().asReal(); - const U32 pbr_type = findChild("radio_pbr_type")->getSelectedIndex(); + const U32 pbr_type = mRadioPbrType->getSelectedIndex(); updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mScale.mV[VY] = value; @@ -5106,7 +5032,7 @@ void LLPanelFace::onCommitGLTFTextureScaleV(LLUICtrl* ctrl) void LLPanelFace::onCommitGLTFRotation(LLUICtrl* ctrl) { const float value = (F32)ctrl->getValue().asReal() * DEG_TO_RAD; - const U32 pbr_type = findChild("radio_pbr_type")->getSelectedIndex(); + const U32 pbr_type = mRadioPbrType->getSelectedIndex(); updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mRotation = value; @@ -5116,7 +5042,7 @@ void LLPanelFace::onCommitGLTFRotation(LLUICtrl* ctrl) void LLPanelFace::onCommitGLTFTextureOffsetU(LLUICtrl* ctrl) { const float value = (F32)ctrl->getValue().asReal(); - const U32 pbr_type = findChild("radio_pbr_type")->getSelectedIndex(); + const U32 pbr_type = mRadioPbrType->getSelectedIndex(); updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mOffset.mV[VX] = value; @@ -5126,7 +5052,7 @@ void LLPanelFace::onCommitGLTFTextureOffsetU(LLUICtrl* ctrl) void LLPanelFace::onCommitGLTFTextureOffsetV(LLUICtrl* ctrl) { const float value = (F32)ctrl->getValue().asReal(); - const U32 pbr_type = findChild("radio_pbr_type")->getSelectedIndex(); + const U32 pbr_type = mRadioPbrType->getSelectedIndex(); updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mOffset.mV[VY] = value; @@ -5136,12 +5062,8 @@ void LLPanelFace::onCommitGLTFTextureOffsetV(LLUICtrl* ctrl) void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp) { LL_DEBUGS("Materials") << "item asset " << itemp->getAssetUUID() << LL_ENDL; - LLRadioGroup* radio_mat_type = findChild("radio_material_type"); - if(!radio_mat_type) - { - return; - } - U32 mattype = radio_mat_type->getSelectedIndex(); + + U32 mattype = mRadioMaterialType->getSelectedIndex(); std::string which_control="texture control"; switch (mattype) { @@ -5187,8 +5109,7 @@ void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp) void LLPanelFace::onPbrSelectionChanged(LLInventoryItem* itemp) { - LLTextureCtrl* pbr_ctrl = findChild("pbr_control"); - if (pbr_ctrl) + if (mPBRTextureCtrl) { LLUUID obj_owner_id; std::string obj_owner_name; @@ -5206,12 +5127,12 @@ void LLPanelFace::onPbrSelectionChanged(LLInventoryItem* itemp) if ((can_copy && can_transfer && can_modify) || from_library) { - pbr_ctrl->setCanApply(true, true); + mPBRTextureCtrl->setCanApply(true, true); return; } // if material has (no-transfer) attribute it can be applied only for object which we own and is not for sale - pbr_ctrl->setCanApply(false, can_transfer ? true : is_object_owner && not_for_sale); + mPBRTextureCtrl->setCanApply(false, can_transfer ? true : is_object_owner && not_for_sale); if (gSavedSettings.getBOOL("TextureLivePreview")) { diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 7e1553c80a..6e88116a2d 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -52,6 +52,7 @@ class LLFloater; class LLMaterialID; class LLMediaCtrl; class LLMenuButton; +class LLRadioGroup; class PBRPickerAgentListener; class PBRPickerObjectListener; @@ -147,7 +148,7 @@ protected: void sendFullbright(); // applies and sends full bright void sendGlow(); - void alignTestureLayer(); + void alignTextureLayer(); void updateCopyTexButton(); @@ -291,9 +292,27 @@ private: F32 getCurrentShinyOffsetU(); F32 getCurrentShinyOffsetV(); - LLComboBox *mComboMatMedia; - LLMediaCtrl *mTitleMedia; - LLTextBox *mTitleMediaText; + LLTextureCtrl* mPBRTextureCtrl = nullptr; + LLTextureCtrl* mTextureCtrl = nullptr; + LLTextureCtrl* mShinyTextureCtrl = nullptr; + LLTextureCtrl* mBumpyTextureCtrl = nullptr; + LLColorSwatchCtrl* mColorSwatch = nullptr; + LLColorSwatchCtrl* mShinyColorSwatch = nullptr; + + LLComboBox* mComboTexGen = nullptr; + + LLRadioGroup* mRadioMaterialType = nullptr; + LLRadioGroup* mRadioPbrType = nullptr; + + LLCheckBoxCtrl* mCheckFullbright = nullptr; + + LLTextBox* mLabelColorTransp = nullptr; + LLSpinCtrl* mCtrlColorTransp = nullptr; // transparency = 1 - alpha + + LLSpinCtrl* mCtrlGlow = nullptr; + LLComboBox *mComboMatMedia = nullptr; + LLMediaCtrl *mTitleMedia = nullptr; + LLTextBox *mTitleMediaText = nullptr; // Update visibility of controls to match current UI mode // (e.g. materials vs media editing) -- cgit v1.2.3 From 99b4f1dd20c01d195e9de7c1ee23e28cc198ee04 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Thu, 25 Jul 2024 23:57:22 -0400 Subject: Fix some findChild stalls when swapping to/from wearable editors --- indra/newview/llpaneleditwearable.cpp | 76 ++++++++++++++++++++++------------- indra/newview/llpaneleditwearable.h | 13 +++++- 2 files changed, 59 insertions(+), 30 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index e88f6c0470..282b6d4a0a 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -48,6 +48,7 @@ #include "llscrollingpanelparam.h" #include "llradiogroup.h" #include "llnotificationsutil.h" +#include "lliconctrl.h" #include "llcolorswatch.h" #include "lltexturectrl.h" @@ -307,8 +308,8 @@ LLEditWearableDictionary::Subparts::Subparts() addEntry(SUBPART_PHYSICS_BREASTS_UPDOWN, new SubpartEntry(SUBPART_PHYSICS_BREASTS_UPDOWN, "mTorso", "physics_breasts_updown", "physics_breasts_updown_param_list", "physics_breasts_updown_tab", LLVector3d(0.f, 0.f, 0.3f), LLVector3d(0.f, 0.f, 0.f), SEX_FEMALE)); addEntry(SUBPART_PHYSICS_BREASTS_INOUT, new SubpartEntry(SUBPART_PHYSICS_BREASTS_INOUT, "mTorso", "physics_breasts_inout", "physics_breasts_inout_param_list", "physics_breasts_inout_tab", LLVector3d(0.f, 0.f, 0.3f), LLVector3d(0.f, 0.f, 0.f),SEX_FEMALE)); addEntry(SUBPART_PHYSICS_BREASTS_LEFTRIGHT, new SubpartEntry(SUBPART_PHYSICS_BREASTS_LEFTRIGHT, "mTorso", "physics_breasts_leftright", "physics_breasts_leftright_param_list", "physics_breasts_leftright_tab", LLVector3d(0.f, 0.f, 0.3f), LLVector3d(0.f, 0.f, 0.f),SEX_FEMALE)); - addEntry(SUBPART_PHYSICS_BELLY_UPDOWN, new SubpartEntry(SUBPART_PHYSICS_BELLY_UPDOWN, "mTorso", "physics_belly_updown", "physics_belly_updown_param_list", "physics_belly_updown_tab", LLVector3d(0.f, 0.f, 0.3f), LLVector3d(0.f, 0.f, 0.f),SEX_BOTH)); - addEntry(SUBPART_PHYSICS_BUTT_UPDOWN, new SubpartEntry(SUBPART_PHYSICS_BUTT_UPDOWN, "mTorso", "physics_butt_updown", "physics_butt_updown_param_list", "physics_butt_updown_tab", LLVector3d(0.f, 0.f, 0.3f), LLVector3d(0.f, 0.f, 0.f),SEX_BOTH)); + addEntry(SUBPART_PHYSICS_BELLY_UPDOWN, new SubpartEntry(SUBPART_PHYSICS_BELLY_UPDOWN, "mTorso", "physics_belly_updown", "physics_belly_updown_param_list", "physics_belly_tab", LLVector3d(0.f, 0.f, 0.3f), LLVector3d(0.f, 0.f, 0.f),SEX_BOTH)); + addEntry(SUBPART_PHYSICS_BUTT_UPDOWN, new SubpartEntry(SUBPART_PHYSICS_BUTT_UPDOWN, "mTorso", "physics_butt_updown", "physics_butt_updown_param_list", "physics_butt_tab", LLVector3d(0.f, 0.f, 0.3f), LLVector3d(0.f, 0.f, 0.f),SEX_BOTH)); addEntry(SUBPART_PHYSICS_BUTT_LEFTRIGHT, new SubpartEntry(SUBPART_PHYSICS_BUTT_LEFTRIGHT, "mTorso", "physics_butt_leftright", "physics_butt_leftright_param_list", "physics_butt_leftright_tab", LLVector3d(0.f, 0.f, 0.f), LLVector3d(0.f, 0.f, 0.f),SEX_BOTH)); addEntry(SUBPART_PHYSICS_ADVANCED, new SubpartEntry(SUBPART_PHYSICS_ADVANCED, "mTorso", "physics_advanced", "physics_advanced_param_list", "physics_advanced_tab", LLVector3d(0.f, 0.f, 0.f), LLVector3d(0.f, 0.f, 0.f),SEX_BOTH)); } @@ -727,8 +728,14 @@ bool LLPanelEditWearable::postBuild() mPanelTitle = getChild("edit_wearable_title"); mDescTitle = getChild("description_text"); - getChild("sex_radio")->setCommitCallback(boost::bind(&LLPanelEditWearable::onCommitSexChange, this)); - getChild("save_as_button")->setCommitCallback(boost::bind(&LLPanelEditWearable::onSaveAsButtonClicked, this)); + mSexRadio = getChild("sex_radio"); + mSexRadio->setCommitCallback(boost::bind(&LLPanelEditWearable::onCommitSexChange, this)); + + mMaleIcon = getChild("male_icon"); + mFemaleIcon = getChild("female_icon"); + + mBtnSaveAs = getChild("save_as_button"); + mBtnSaveAs->setCommitCallback(boost::bind(&LLPanelEditWearable::onSaveAsButtonClicked, this)); // The following panels will be shown/hidden based on what wearable we're editing // body parts @@ -806,8 +813,20 @@ bool LLPanelEditWearable::postBuild() continue; } + mAccordionTabs.emplace(accordion_tab, tab); + // initialize callback to ensure camera view changes appropriately. tab->setDropDownStateChangedCallback(boost::bind(&LLPanelEditWearable::onTabExpandedCollapsed,this,_2,index)); + + const std::string& scrolling_panel = subpart_entry->mParamList; + if (!scrolling_panel.empty()) + { + LLScrollingPanelList* panel_list = tab->findChild(scrolling_panel); + if (panel_list) + { + mParamPanels.emplace(scrolling_panel, panel_list); + } + } } // initialize texture and color picker controls @@ -1211,19 +1230,21 @@ void LLPanelEditWearable::showWearable(LLViewerWearable* wearable, bool show, bo continue; } - LLScrollingPanelList *panel_list = findChild(scrolling_panel); - LLAccordionCtrlTab *tab = findChild(accordion_tab); - if (!panel_list) + auto accord_it = mAccordionTabs.find(accordion_tab); + if (accord_it == mAccordionTabs.end()) { - LL_WARNS() << "could not get scrolling panel list: " << scrolling_panel << LL_ENDL; - continue; + LL_WARNS() << "could not get llaccordionctrltab from UI with name: " << accordion_tab << LL_ENDL; + continue; } + LLAccordionCtrlTab* tab = accord_it->second; - if (!tab) + auto panel_it = mParamPanels.find(scrolling_panel); + if (panel_it == mParamPanels.end()) { - LL_WARNS() << "could not get llaccordionctrltab from UI with name: " << accordion_tab << LL_ENDL; - continue; + LL_WARNS() << "could not get scrolling panel list: " << scrolling_panel << LL_ENDL; + continue; } + LLScrollingPanelList *panel_list = panel_it->second; // Don't show female subparts if you're not female, etc. if (!(gAgentAvatarp->getSex() & subpart_entry->mSex)) @@ -1237,7 +1258,7 @@ void LLPanelEditWearable::showWearable(LLViewerWearable* wearable, bool show, bo } // what edit group do we want to extract params for? - const std::string edit_group = subpart_entry->mEditGroup; + const std::string& edit_group = subpart_entry->mEditGroup; // storage for ordered list of visual params value_map_t sorted_params; @@ -1337,9 +1358,9 @@ void LLPanelEditWearable::toggleTypeSpecificControls(LLWearableType::EType type) // Toggle controls specific to shape editing panel. { bool is_shape = (type == LLWearableType::WT_SHAPE); - getChildView("sex_radio")->setVisible( is_shape); - getChildView("female_icon")->setVisible( is_shape); - getChildView("male_icon")->setVisible( is_shape); + mSexRadio->setVisible(is_shape); + mFemaleIcon->setVisible(is_shape); + mMaleIcon->setVisible(is_shape); } } @@ -1400,15 +1421,15 @@ void LLPanelEditWearable::updateScrollingPanelUI() ESubpart subpart_e = wearable_entry->mSubparts[index]; const LLEditWearableDictionary::SubpartEntry *subpart_entry = LLEditWearableDictionary::getInstance()->getSubpart(subpart_e); - const std::string scrolling_panel = subpart_entry->mParamList; - - LLScrollingPanelList *panel_list = getChild(scrolling_panel); + const std::string& scrolling_panel = subpart_entry->mParamList; - if (!panel_list) + auto panel_it = mParamPanels.find(scrolling_panel); + if (panel_it == mParamPanels.end()) { - LL_WARNS() << "could not get scrolling panel list: " << scrolling_panel << LL_ENDL; - continue; + LL_WARNS() << "could not get scrolling panel list: " << scrolling_panel << LL_ENDL; + continue; } + LLScrollingPanelList* panel_list = panel_it->second; panel_list->updatePanels(true); } @@ -1542,7 +1563,7 @@ void LLPanelEditWearable::updateVerbs() bool is_dirty = isDirty(); mBtnRevert->setEnabled(is_dirty); - getChildView("save_as_button")->setEnabled(is_dirty && can_copy); + mBtnSaveAs->setEnabled(is_dirty && can_copy); if (isAgentAvatarValid()) { @@ -1580,7 +1601,7 @@ void LLPanelEditWearable::configureAlphaCheckbox(LLAvatarAppearanceDefines::ETex LLCheckBoxCtrl* checkbox = mPanelAlpha->getChild(name); checkbox->setCommitCallback(boost::bind(&LLPanelEditWearable::onInvisibilityCommit, this, checkbox, te)); - mAlphaCheckbox2Index[name] = te; + mAlphaCheckbox2Index.push_back(std::make_pair(checkbox,te)); } void LLPanelEditWearable::onInvisibilityCommit(LLCheckBoxCtrl* checkbox_ctrl, LLAvatarAppearanceDefines::ETextureIndex te) @@ -1637,11 +1658,10 @@ void LLPanelEditWearable::onInvisibilityCommit(LLCheckBoxCtrl* checkbox_ctrl, LL void LLPanelEditWearable::updateAlphaCheckboxes() { - for (string_texture_index_map_t::iterator iter = mAlphaCheckbox2Index.begin(); - iter != mAlphaCheckbox2Index.end(); ++iter ) + for (const auto& check_pair : mAlphaCheckbox2Index) { - LLAvatarAppearanceDefines::ETextureIndex te = (LLAvatarAppearanceDefines::ETextureIndex)iter->second; - LLCheckBoxCtrl* ctrl = mPanelAlpha->getChild(iter->first); + LLAvatarAppearanceDefines::ETextureIndex te = (LLAvatarAppearanceDefines::ETextureIndex)check_pair.second; + LLCheckBoxCtrl* ctrl = check_pair.first; if (ctrl) { ctrl->set(!gAgentAvatarp->isTextureVisible(te, mWearablePtr)); diff --git a/indra/newview/llpaneleditwearable.h b/indra/newview/llpaneleditwearable.h index aa4ac915c7..443b52b8fc 100644 --- a/indra/newview/llpaneleditwearable.h +++ b/indra/newview/llpaneleditwearable.h @@ -44,6 +44,8 @@ class LLViewerJointMesh; class LLAccordionCtrlTab; class LLJoint; class LLLineEditor; +class LLRadioGroup; +class LLIconCtrl; class LLPanelEditWearable : public LLPanel { @@ -123,6 +125,7 @@ private: LLViewerInventoryItem* mWearableItem; // these are constant no matter what wearable we're editing + LLButton* mBtnSaveAs; LLButton *mBtnRevert; LLButton *mBtnBack; std::string mBackBtnLabel; @@ -131,6 +134,9 @@ private: LLTextBox *mDescTitle; LLTextBox *mTxtAvatarHeight; + LLRadioGroup* mSexRadio = nullptr; + LLIconCtrl* mMaleIcon = nullptr; + LLIconCtrl* mFemaleIcon = nullptr; // localized and parameterized strings that used to build avatar_height_label std::string mMeters; @@ -170,8 +176,11 @@ private: LLPanel *mPanelUniversal; LLPanel *mPanelPhysics; - typedef std::map string_texture_index_map_t; - string_texture_index_map_t mAlphaCheckbox2Index; + std::unordered_map mAccordionTabs; + std::unordered_map mParamPanels; + + typedef std::vector> checkbox_texture_index_vec_t; + checkbox_texture_index_vec_t mAlphaCheckbox2Index; typedef std::map s32_uuid_map_t; s32_uuid_map_t mPreviousAlphaTexture; -- cgit v1.2.3 From dce1218b038f210fd6d4c19c84895fcf37e30c15 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Fri, 26 Jul 2024 00:31:51 -0400 Subject: Fix findChild during draw in conversation log floater --- indra/newview/llfloaterconversationlog.cpp | 5 +++-- indra/newview/llfloaterconversationlog.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterconversationlog.cpp b/indra/newview/llfloaterconversationlog.cpp index 648d3af5a5..97399c9cf7 100644 --- a/indra/newview/llfloaterconversationlog.cpp +++ b/indra/newview/llfloaterconversationlog.cpp @@ -55,10 +55,11 @@ bool LLFloaterConversationLog::postBuild() } // Use the context menu of the Conversation list for the Conversation tab gear menu. + mConversationsGearBtn = getChild("conversations_gear_btn"); LLToggleableMenu* conversations_gear_menu = mConversationLogList->getContextMenu(); if (conversations_gear_menu) { - getChild("conversations_gear_btn")->setMenu(conversations_gear_menu, LLMenuButton::MP_BOTTOM_LEFT); + mConversationsGearBtn->setMenu(conversations_gear_menu, LLMenuButton::MP_BOTTOM_LEFT); } getChild("people_filter_input")->setCommitCallback(boost::bind(&LLFloaterConversationLog::onFilterEdit, this, _2)); @@ -68,7 +69,7 @@ bool LLFloaterConversationLog::postBuild() void LLFloaterConversationLog::draw() { - getChild("conversations_gear_btn")->setEnabled(mConversationLogList->getSelectedItem() != NULL); + mConversationsGearBtn->setEnabled(mConversationLogList->getSelectedItem() != NULL); LLFloater::draw(); } diff --git a/indra/newview/llfloaterconversationlog.h b/indra/newview/llfloaterconversationlog.h index 85ca37c530..c82237c108 100644 --- a/indra/newview/llfloaterconversationlog.h +++ b/indra/newview/llfloaterconversationlog.h @@ -29,6 +29,7 @@ #include "llfloater.h" class LLConversationLogList; +class LLMenuButton; class LLFloaterConversationLog : public LLFloater { @@ -50,6 +51,7 @@ private: bool isActionChecked(const LLSD& userdata); LLConversationLogList* mConversationLogList; + LLMenuButton* mConversationsGearBtn = nullptr; }; -- cgit v1.2.3 From 604cb4cb4dd71c0f90633e50d5b0108e3901c4ad Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Fri, 26 Jul 2024 06:19:34 -0400 Subject: Reduce utf8 to wstring conversion and llwstring temporaries during text draw (#2115) --- indra/newview/llexpandabletextbox.cpp | 6 +++--- indra/newview/llprogressview.cpp | 2 +- indra/newview/llworldmapview.cpp | 22 ++++++++++++---------- 3 files changed, 16 insertions(+), 14 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llexpandabletextbox.cpp b/indra/newview/llexpandabletextbox.cpp index 42fe8fc6e6..748e10160c 100644 --- a/indra/newview/llexpandabletextbox.cpp +++ b/indra/newview/llexpandabletextbox.cpp @@ -41,7 +41,7 @@ public: : LLTextSegment(start, end), mEditor(editor), mStyle(style), - mExpanderLabel(more_text) + mExpanderLabel(utf8str_to_wstring(more_text)) {} /*virtual*/ bool getDimensionsF32(S32 first_char, S32 num_chars, F32& width, S32& height) const @@ -80,7 +80,7 @@ public: /*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRectf& draw_rect) { F32 right_x; - mStyle->getFont()->renderUTF8(mExpanderLabel, start, + mStyle->getFont()->render(mExpanderLabel, start, draw_rect.mRight, draw_rect.mTop, mStyle->getColor(), LLFontGL::RIGHT, LLFontGL::TOP, @@ -103,7 +103,7 @@ public: private: LLTextBase& mEditor; LLStyleSP mStyle; - std::string mExpanderLabel; + LLWString mExpanderLabel; }; LLExpandableTextBox::LLTextBoxEx::Params::Params() diff --git a/indra/newview/llprogressview.cpp b/indra/newview/llprogressview.cpp index 135e42437a..80e403dfde 100644 --- a/indra/newview/llprogressview.cpp +++ b/indra/newview/llprogressview.cpp @@ -391,7 +391,7 @@ void LLProgressView::initLogos() S32 icon_width, icon_height; // We don't know final screen rect yet, so we can't precalculate position fully - S32 texture_start_x = (S32)mLogosLabel->getFont()->getWidthF32(mLogosLabel->getText()) + default_pad; + S32 texture_start_x = (S32)mLogosLabel->getFont()->getWidthF32(mLogosLabel->getWText().c_str()) + default_pad; S32 texture_start_y = -7; // Normally we would just preload these textures from textures.xml, diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index a0eec1e941..4757bd42e0 100755 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -1023,18 +1023,20 @@ void LLWorldMapView::drawTracking(const LLVector3d& pos_global, const LLColor4& drawImage(pos_global, sTrackCircleImage, color); } - // clamp text position to on-screen - const S32 TEXT_PADDING = DEFAULT_TRACKING_ARROW_SIZE + 2; - S32 half_text_width = llfloor(font->getWidthF32(label) * 0.5f); - text_x = llclamp(text_x, half_text_width + TEXT_PADDING, getRect().getWidth() - half_text_width - TEXT_PADDING); - text_y = llclamp(text_y + vert_offset, TEXT_PADDING + vert_offset, getRect().getHeight() - font->getLineHeight() - TEXT_PADDING - vert_offset); - if (label != "") { - font->renderUTF8( - label, 0, - text_x, - text_y, + // clamp text position to on-screen + const S32 TEXT_PADDING = DEFAULT_TRACKING_ARROW_SIZE + 2; + + LLWString wlabel = utf8string_to_wstring(label); + S32 half_text_width = llfloor(font->getWidthF32(wlabel.c_str()) * 0.5f); + text_x = llclamp(text_x, half_text_width + TEXT_PADDING, getRect().getWidth() - half_text_width - TEXT_PADDING); + text_y = llclamp(text_y + vert_offset, TEXT_PADDING + vert_offset, getRect().getHeight() - font->getLineHeight() - TEXT_PADDING - vert_offset); + + font->render( + wlabel, 0, + (F32)text_x, + (F32)text_y, LLColor4::white, LLFontGL::HCENTER, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW); -- cgit v1.2.3 From a5d68b3801be0ea77259b387f3c86cca54fc59cc Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Fri, 26 Jul 2024 13:21:27 +0300 Subject: Fix trailing whitespaces to make pre-commit happy --- indra/newview/llpaneloutfitedit.cpp | 1 - indra/newview/llpaneloutfitsinventory.cpp | 1 - 2 files changed, 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index fadf3633e8..4cd4afaa5a 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -478,7 +478,6 @@ bool LLPanelOutfitEdit::postBuild() mFolderViewBtn = getChild("folder_view_btn"); mListViewBtn = getChild("list_view_btn"); - mFilterPanel = getChild("filter_panel"); mFilterBtn = getChild("filter_button"); mFilterBtn->setCommitCallback(boost::bind(&LLPanelOutfitEdit::showWearablesFilter, this)); diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp index b226c2ca1a..47c02793a3 100644 --- a/indra/newview/llpaneloutfitsinventory.cpp +++ b/indra/newview/llpaneloutfitsinventory.cpp @@ -264,7 +264,6 @@ void LLPanelOutfitsInventory::updateListCommands() bool wear_enabled = isActionEnabled("wear"); bool wear_visible = !isCOFPanelActive(); bool make_outfit_enabled = isActionEnabled("save_outfit"); - mMyOutfitsPanel->childSetEnabled("trash_btn", trash_enabled); mOutfitGalleryPanel->childSetEnabled("trash_btn", trash_enabled); mWearBtn->setEnabled(wear_enabled); -- cgit v1.2.3 From a1bdef0c159ca2ebf5f2d985d56a541101e3bf6a Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Sat, 27 Jul 2024 17:10:08 +0200 Subject: Fix rapidly triggering gestures can make them get stuck (#2126) --- indra/newview/llgesturemgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index 8ee11cdbd2..1bbeba43ec 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -536,7 +536,7 @@ void LLGestureMgr::playGesture(LLMultiGesture* gesture, bool fromKeyPress) if (!gesture) return; // Reset gesture to first step - gesture->mCurrentStep = 0; + gesture->reset(); gesture->mTriggeredByKey = fromKeyPress; // Add to list of playing -- cgit v1.2.3 From fceec45641cf6a4b7eecaf37ea080a184c279239 Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Sat, 27 Jul 2024 17:10:17 +0200 Subject: Fix a bunch of XUI warnings (#2120) --- indra/newview/llfloaterregioninfo.cpp | 3 ++- indra/newview/llfloaterworldmap.cpp | 2 -- indra/newview/llfloaterworldmap.h | 1 - indra/newview/llpanelgroup.cpp | 15 --------------- indra/newview/llpanelgroup.h | 1 - indra/newview/skins/default/xui/en/floater_im_session.xml | 1 - .../skins/default/xui/en/widgets/emoji_complete.xml | 1 - 7 files changed, 2 insertions(+), 22 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 02ef342c2a..7869abf66d 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -854,8 +854,9 @@ void LLPanelRegionInfo::initCtrl(const std::string& name) template void LLPanelRegionInfo::initAndSetCtrl(CTRL*& ctrl, const std::string& name) { - initCtrl(name); ctrl = findChild(name); + if (ctrl) + ctrl->setCommitCallback(boost::bind(&LLPanelRegionInfo::onChangeAnything, this)); } void LLPanelRegionInfo::onClickManageTelehub() diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index d459716fc4..8d74a99539 100755 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -326,7 +326,6 @@ bool LLFloaterWorldMap::postBuild() mPeopleCheck = getChild("people_chk"); mInfohubCheck = getChild("infohub_chk"); - mTelehubCheck = getChild("telehub_chk"); mLandSaleCheck = getChild("land_for_sale_chk"); mEventsCheck = getChild("event_chk"); mEventsMatureCheck = getChild("events_mature_chk"); @@ -572,7 +571,6 @@ void LLFloaterWorldMap::draw() bool enable = mMapView->showRegionInfo(); mPeopleCheck->setEnabled(enable); mInfohubCheck->setEnabled(enable); - mTelehubCheck->setEnabled(enable); mLandSaleCheck->setEnabled(enable); mEventsCheck->setEnabled(enable); mEventsMatureCheck->setEnabled(enable); diff --git a/indra/newview/llfloaterworldmap.h b/indra/newview/llfloaterworldmap.h index 269b231e37..a99100f5bd 100644 --- a/indra/newview/llfloaterworldmap.h +++ b/indra/newview/llfloaterworldmap.h @@ -206,7 +206,6 @@ private: LLCheckBoxCtrl* mPeopleCheck = nullptr; LLCheckBoxCtrl* mInfohubCheck = nullptr; - LLCheckBoxCtrl* mTelehubCheck = nullptr; LLCheckBoxCtrl* mLandSaleCheck = nullptr; LLCheckBoxCtrl* mEventsCheck = nullptr; LLCheckBoxCtrl* mEventsMatureCheck = nullptr; diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp index 3db0f90df8..079a5583d4 100644 --- a/indra/newview/llpanelgroup.cpp +++ b/indra/newview/llpanelgroup.cpp @@ -167,8 +167,6 @@ bool LLPanelGroup::postBuild() mButtonRefresh = getChild("btn_refresh"); mButtonRefresh->setClickedCallback(onBtnRefresh, this); - mButtonCancel = getChild("btn_cancel"); - mGroupNameCtrl = getChild("group_name"); childSetCommitCallback("back",boost::bind(&LLPanelGroup::onBackBtnClick,this),NULL); @@ -214,18 +212,8 @@ void LLPanelGroup::reposButton(LLButton* button) void LLPanelGroup::reposButtons() { - if(mButtonRefresh && mButtonCancel && mButtonRefresh->getVisible() && mButtonCancel->getVisible()) - { - LLRect btn_refresh_rect = mButtonRefresh->getRect(); - LLRect btn_cancel_rect = mButtonCancel->getRect(); - btn_refresh_rect.setLeftTopAndSize( btn_cancel_rect.mLeft + btn_cancel_rect.getWidth() + 2, - btn_refresh_rect.getHeight() + 2, btn_refresh_rect.getWidth(), btn_refresh_rect.getHeight()); - mButtonRefresh->setRect(btn_refresh_rect); - } - reposButton(mButtonApply); reposButton(mButtonRefresh); - reposButton(mButtonCancel); reposButton(mButtonChat); reposButton(mButtonCall); } @@ -376,9 +364,6 @@ void LLPanelGroup::setGroupID(const LLUUID& group_id) if(mButtonRefresh) mButtonRefresh->setVisible(!is_null_group_id); - if(mButtonCancel) - mButtonCancel->setVisible(!is_null_group_id); - if(mButtonCall) mButtonCall->setVisible(!is_null_group_id); if(mButtonChat) diff --git a/indra/newview/llpanelgroup.h b/indra/newview/llpanelgroup.h index d7dec94c60..fa0e1d4104 100644 --- a/indra/newview/llpanelgroup.h +++ b/indra/newview/llpanelgroup.h @@ -123,7 +123,6 @@ protected: LLButton* mButtonCall = nullptr; LLButton* mButtonChat = nullptr; LLButton* mButtonRefresh = nullptr; - LLButton* mButtonCancel = nullptr; LLUICtrl* mJoinText; }; diff --git a/indra/newview/skins/default/xui/en/floater_im_session.xml b/indra/newview/skins/default/xui/en/floater_im_session.xml index 738d448f00..7b06bed0a3 100644 --- a/indra/newview/skins/default/xui/en/floater_im_session.xml +++ b/indra/newview/skins/default/xui/en/floater_im_session.xml @@ -341,7 +341,6 @@ name="emoji_recent_empty_text" follows="top|left|right" layout="topleft" - auto_resize="false" h_pad="20" v_pad="10" top="0" diff --git a/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml b/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml index 6cc8d7118f..4a1ba169ad 100644 --- a/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml +++ b/indra/newview/skins/default/xui/en/widgets/emoji_complete.xml @@ -1,7 +1,6 @@ Date: Sat, 27 Jul 2024 11:15:00 -0400 Subject: Destroy stream process when stopping audio stream to allow restarting in the case of stuck or errored libvlc (#2124) --- indra/newview/llviewermedia_streamingaudio.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/llviewermedia_streamingaudio.cpp b/indra/newview/llviewermedia_streamingaudio.cpp index af3a21c183..b68ffbe1a2 100644 --- a/indra/newview/llviewermedia_streamingaudio.cpp +++ b/indra/newview/llviewermedia_streamingaudio.cpp @@ -70,6 +70,8 @@ void LLStreamingAudio_MediaPlugins::start(const std::string& url) LL_INFOS() << "setting stream to NULL"<< LL_ENDL; mURL.clear(); mMediaPlugin->stop(); + delete mMediaPlugin; + mMediaPlugin = nullptr; } } @@ -79,6 +81,8 @@ void LLStreamingAudio_MediaPlugins::stop() if(mMediaPlugin) { mMediaPlugin->stop(); + delete mMediaPlugin; + mMediaPlugin = nullptr; } mURL.clear(); -- cgit v1.2.3 From 817bc25b2732dc23295e6a7ac0da5ad142e33434 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sat, 27 Jul 2024 11:15:09 -0400 Subject: Fix warning for Type mismatch in LLMsgVarData::addData for SpaceIP (#2125) --- indra/newview/llcallingcard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp index 214b5f5cde..8e9ab8f87f 100644 --- a/indra/newview/llcallingcard.cpp +++ b/indra/newview/llcallingcard.cpp @@ -451,7 +451,7 @@ void LLAvatarTracker::findAgent() msg->nextBlockFast(_PREHASH_AgentBlock); msg->addUUIDFast(_PREHASH_Hunter, gAgentID); msg->addUUIDFast(_PREHASH_Prey, mTrackingData->mAvatarID); - msg->addU32Fast(_PREHASH_SpaceIP, 0); // will get filled in by simulator + msg->addIPAddrFast(_PREHASH_SpaceIP, 0); // will get filled in by simulator msg->nextBlockFast(_PREHASH_LocationBlock); const F64 NO_LOCATION = 0.0; msg->addF64Fast(_PREHASH_GlobalX, NO_LOCATION); -- cgit v1.2.3 From ed6148d6c6c554223dc4b2dab0c729d3b5698158 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 26 Jul 2024 21:49:36 +0300 Subject: viewer#2113 Optional disable eyes/head follow cursor/lookat Intended for photography, but there is curently no nice way to present it so it's in debug options until we get some critical mass of features that can be collected into a single whole. --- indra/newview/app_settings/settings.xml | 11 +++++++++++ indra/newview/llhudeffectlookat.cpp | 21 +++++++++++++++++++-- indra/newview/skins/default/xui/en/menu_viewer.xml | 10 ++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 97cab58eb1..9e5d3f09bd 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -14218,6 +14218,17 @@ Boolean Value 0 + + DisableLookAtAnimation + + Comment + Avatar follows cursor with avatars eyes, when disabled, avatar will look forward + Persist + 0 + Type + Boolean + Value + 0 WebProfileFloaterRect diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp index c8b7e00776..d0d2ee191a 100644 --- a/indra/newview/llhudeffectlookat.cpp +++ b/indra/newview/llhudeffectlookat.cpp @@ -36,6 +36,7 @@ #include "llvoavatar.h" #include "lldrawable.h" #include "llviewerobjectlist.h" +#include "llviewercontrol.h" #include "llrendersphere.h" #include "llselectmgr.h" #include "llglheaders.h" @@ -561,8 +562,16 @@ void LLHUDEffectLookAt::update() { if (calcTargetPosition()) { + static LLCachedControl disable_look_at(gSavedSettings, "DisableLookAtAnimation", true); LLMotion* head_motion = ((LLVOAvatar*)(LLViewerObject*)mSourceObject)->findMotion(ANIM_AGENT_HEAD_ROT); - if (!head_motion || head_motion->isStopped()) + if (disable_look_at()) + { + if (head_motion) + { + ((LLVOAvatar*)(LLViewerObject*)mSourceObject)->stopMotion(ANIM_AGENT_HEAD_ROT); + } + } + else if (!head_motion || head_motion->isStopped()) { ((LLVOAvatar*)(LLViewerObject*)mSourceObject)->startMotion(ANIM_AGENT_HEAD_ROT); } @@ -665,7 +674,15 @@ bool LLHUDEffectLookAt::calcTargetPosition() if (!mTargetPos.isFinite()) return false; - source_avatar->setAnimationData("LookAtPoint", (void *)&mTargetPos); + static LLCachedControl disable_look_at(gSavedSettings, "DisableLookAtAnimation", true); + if (disable_look_at()) + { + source_avatar->removeAnimationData("LookAtPoint"); + } + else + { + source_avatar->setAnimationData("LookAtPoint", (void*)&mTargetPos); + } return true; } diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 347638249b..941f0c6bb7 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -3966,6 +3966,16 @@ function="World.EnvPreset" function="ToggleControl" parameter="AllowSelectAvatar" /> + + + + -- cgit v1.2.3 From 30a859de7e728afd2a93f76a8b5314ac90894ccc Mon Sep 17 00:00:00 2001 From: Zi Ree <81702435+zi-ree@users.noreply.github.com> Date: Sun, 28 Jul 2024 03:03:31 +0200 Subject: Fix double variable name in initialization is_asset_knowable variable name is duplicated, causing a compiler warning in gcc. --- indra/newview/llinventorygallerymenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 8e56ccc01d..dbf4821ca1 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -810,7 +810,7 @@ void LLInventoryGalleryContextMenu::updateMenuItemsVisibility(LLContextMenu* men items.push_back(std::string("Copy Asset UUID")); items.push_back(std::string("Copy Separator")); - bool is_asset_knowable = is_asset_knowable = LLAssetType::lookupIsAssetIDKnowable(obj->getType()); + bool is_asset_knowable = LLAssetType::lookupIsAssetIDKnowable(obj->getType()); if ( !is_asset_knowable // disable menu item for Inventory items with unknown asset. EXT-5308 || (! ( is_full_perm_item || gAgent.isGodlike()))) { -- cgit v1.2.3 From c7c7342ed3bc17fcef5b5fe0970859ac753a6639 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sun, 28 Jul 2024 13:03:25 -0400 Subject: Update boost to 1.85 and fix deprecation warnings --- indra/newview/llappviewerwin32.cpp | 2 +- indra/newview/lltranslate.cpp | 16 ++++++++-------- indra/newview/llvoicewebrtc.cpp | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index c4c6dd3327..c5686f160a 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -711,7 +711,7 @@ bool LLAppViewerWin32::init() } else { - boost::json::error_code ec; + boost::system::error_code ec; boost::json::value build_data = boost::json::parse(inf, ec); if(ec.failed()) { diff --git a/indra/newview/lltranslate.cpp b/indra/newview/lltranslate.cpp index b6fbcaa330..72e30bd765 100644 --- a/indra/newview/lltranslate.cpp +++ b/indra/newview/lltranslate.cpp @@ -398,7 +398,7 @@ bool LLGoogleTranslationHandler::parseResponse( { const std::string& text = !body.empty() ? body : http_response["error_body"].asStringRef(); - boost::json::error_code ec; + boost::system::error_code ec; boost::json::value root = boost::json::parse(text, ec); if (ec.failed()) { @@ -431,7 +431,7 @@ void LLGoogleTranslationHandler::parseErrorResponse( int& status, std::string& err_msg) { - boost::json::error_code ec; + boost::system::error_code ec; auto message = root.find_pointer("/data/message", ec); auto code = root.find_pointer("/data/code", ec); if (!message || !code) @@ -456,7 +456,7 @@ bool LLGoogleTranslationHandler::parseTranslation( std::string& translation, std::string& detected_lang) { - boost::json::error_code ec; + boost::system::error_code ec; auto translated_text = root.find_pointer("/data/translations/0/translatedText", ec); if (!translated_text) return false; @@ -656,7 +656,7 @@ bool LLAzureTranslationHandler::checkVerificationResponse( // Expected: "{\"error\":{\"code\":400000,\"message\":\"One of the request inputs is not valid.\"}}" // But for now just verify response is a valid json - boost::json::error_code ec; + boost::system::error_code ec; boost::json::value root = boost::json::parse(response["error_body"].asString(), ec); if (ec.failed()) { @@ -686,7 +686,7 @@ bool LLAzureTranslationHandler::parseResponse( //Example: // "[{\"detectedLanguage\":{\"language\":\"en\",\"score\":1.0},\"translations\":[{\"text\":\"Hello, what is your name?\",\"to\":\"en\"}]}]" - boost::json::error_code ec; + boost::system::error_code ec; boost::json::value root = boost::json::parse(body, ec); if (ec.failed()) { @@ -726,7 +726,7 @@ std::string LLAzureTranslationHandler::parseErrorResponse( // Expected: "{\"error\":{\"code\":400000,\"message\":\"One of the request inputs is not valid.\"}}" // But for now just verify response is a valid json with an error - boost::json::error_code ec; + boost::system::error_code ec; boost::json::value root = boost::json::parse(body, ec); if (ec.failed()) { @@ -956,7 +956,7 @@ bool LLDeepLTranslationHandler::parseResponse( //Example: // "{\"translations\":[{\"detected_source_language\":\"EN\",\"text\":\"test\"}]}" - boost::json::error_code ec; + boost::system::error_code ec; boost::json::value root = boost::json::parse(body, ec); if (ec.failed()) { @@ -1004,7 +1004,7 @@ std::string LLDeepLTranslationHandler::parseErrorResponse( const std::string& body) { // Example: "{\"message\":\"One of the request inputs is not valid.\"}" - boost::json::error_code ec; + boost::system::error_code ec; boost::json::value root = boost::json::parse(body, ec); if (ec.failed()) { diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index d18a32cb05..4f08dde6e0 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -2789,7 +2789,7 @@ void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool b return; } - boost::json::error_code ec; + boost::system::error_code ec; boost::json::value voice_data_parsed = boost::json::parse(data, ec); if (!ec) // don't collect comments { -- cgit v1.2.3 From 1c50229e6e8ceff6ebddff72aa26f39eed3a561c Mon Sep 17 00:00:00 2001 From: Zi Ree <81702435+zi-ree@users.noreply.github.com> Date: Sun, 28 Jul 2024 03:21:34 +0200 Subject: fix misleading indentation compiler warnings Fix several indentation mistakes, some of them trip gcc's misleading indentation warning. --- indra/newview/llpanelprofile.cpp | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index fcf0757073..8f44b28ebe 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -1020,7 +1020,7 @@ void LLPanelProfileSecondLife::fillCommonData(const LLAvatarData* avatar_data) setDescriptionText(avatar_data->about_text); - mSecondLifePic->setValue(avatar_data->image_id); + mSecondLifePic->setValue(avatar_data->image_id); if (getSelfProfile()) { @@ -1168,10 +1168,10 @@ void LLPanelProfileSecondLife::fillAgeData(const LLAvatarData* avatar_data) } else { - std::string register_date = getString("age_format"); - LLSD args_age; + std::string register_date = getString("age_format"); + LLSD args_age; args_age["[AGE]"] = LLDateUtil::ageFromDate(avatar_data->born_on, LLDate::now()); - LLStringUtil::format(register_date, args_age); + LLStringUtil::format(register_date, args_age); userAgeCtrl->setValue(register_date); } @@ -1614,12 +1614,12 @@ void LLPanelProfileSecondLife::onShowInSearchCallback() if (value == mAllowPublish) return; - mAllowPublish = value; + mAllowPublish = value; saveAgentUserInfoCoro("allow_publish", value); - } +} void LLPanelProfileSecondLife::onHideAgeCallback() - { +{ bool value = mHideAgeCombo->getValue().asInteger(); if (value == mHideAge) return; @@ -1768,35 +1768,35 @@ void LLPanelProfileSecondLife::onCommitProfileImage(const LLUUID& id) if (mSecondLifePic->getImageAssetId() == id) return; - std::function callback = [id](bool result) + std::function callback = [id](bool result) + { + if (result) { - if (result) - { - LLAvatarIconIDCache::getInstance()->add(gAgentID, id); + LLAvatarIconIDCache::getInstance()->add(gAgentID, id); // Should trigger callbacks in icon controls (or request Legacy) - LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(gAgentID); - } - }; + LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(gAgentID); + } + }; if (!saveAgentUserInfoCoro("sl_image_id", id, callback)) return; mSecondLifePic->setValue(id); - LLFloater *floater = mFloaterProfileTextureHandle.get(); - if (floater) - { - LLFloaterProfileTexture * texture_view = dynamic_cast(floater); + LLFloater *floater = mFloaterProfileTextureHandle.get(); + if (floater) + { + LLFloaterProfileTexture * texture_view = dynamic_cast(floater); if (id == LLUUID::null) - { - texture_view->resetAsset(); - } - else - { + { + texture_view->resetAsset(); + } + else + { texture_view->loadAsset(id); - } } } +} ////////////////////////////////////////////////////////////////////////// // LLPanelProfileWeb -- cgit v1.2.3 From 3e322df4fb71cbeff27aab85bb48c7da595b548c Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sun, 28 Jul 2024 16:27:42 -0400 Subject: Replace liburiparser with boost::url --- indra/newview/CMakeLists.txt | 2 -- indra/newview/llweb.cpp | 1 - indra/newview/viewer_manifest.py | 4 ---- 3 files changed, 7 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index def2d8f0c0..a34354d287 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -44,7 +44,6 @@ include(ViewerManager) include(VisualLeakDetector) include(VulkanGltf) include(ZLIBNG) -include(URIPARSER) include(LLPrimitive) if (NOT HAVOK_TPV) @@ -1731,7 +1730,6 @@ if (WINDOWS) ${CMAKE_SOURCE_DIR}/../scripts/messages/message_template.msg ${SHARED_LIB_STAGING_DIR}/openjp2.dll ${SHARED_LIB_STAGING_DIR}/libhunspell.dll - ${SHARED_LIB_STAGING_DIR}/uriparser.dll ${SHARED_LIB_STAGING_DIR}/llwebrtc.dll #${SHARED_LIB_STAGING_DIR}/${LL_INTDIR}/SLVoice.exe #${SHARED_LIB_STAGING_DIR}/${LL_INTDIR}/libsndfile-1.dll diff --git a/indra/newview/llweb.cpp b/indra/newview/llweb.cpp index d8852de954..a319aa00bc 100644 --- a/indra/newview/llweb.cpp +++ b/indra/newview/llweb.cpp @@ -50,7 +50,6 @@ #include "llviewerwindow.h" #include "llnotificationsutil.h" #include "lluriparser.h" -#include "uriparser/Uri.h" bool on_load_url_external_response(const LLSD& notification, const LLSD& response, bool async ); diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index 5b6ac27575..a25efc5de4 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -561,9 +561,6 @@ class Windows_x86_64_Manifest(ViewerManifest): # For textures self.path("openjp2.dll") - # Uriparser - self.path("uriparser.dll") - # These need to be installed as a SxS assembly, currently a 'private' assembly. # See http://msdn.microsoft.com/en-us/library/ms235291(VS.80).aspx self.path("msvcp140.dll") @@ -1022,7 +1019,6 @@ class Darwin_x86_64_Manifest(ViewerManifest): # libnghttp2.major.dylib, which is a symlink to # libnghttp2.version.dylib. Get all of them. "libnghttp2.*dylib", - "liburiparser.*dylib", ): dylibs += path_optional(os.path.join(relpkgdir, libfile), libfile) -- cgit v1.2.3 From 7a4249937db591d146d8c91f2a85c5c721543f19 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Wed, 24 Jul 2024 20:21:11 +0200 Subject: #2103 BugSplat Crash #1497033: LLViewerTextureList::getImage --- indra/newview/llvovolume.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 2630aaf43e..9ebe648680 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5646,7 +5646,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) } // HACK -- brute force this check every time a drawable gets rebuilt - for (S32 i = 0; i < drawablep->getNumFaces(); ++i) + S32 num_tex = llmin(vobj->getNumTEs(), drawablep->getNumFaces()); + for (S32 i = 0; i < num_tex; ++i) { vobj->updateTEMaterialTextures(i); } -- cgit v1.2.3 From 5d25504f8335132d0d222b266f8772062c88b335 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Fri, 26 Jul 2024 19:32:23 +0200 Subject: #2100 BugSplat Crash #1497210: LLVOAvatar::updateImpostors()(10616) --- indra/newview/llavatarrenderinfoaccountant.cpp | 15 +- indra/newview/llcontrolavatar.cpp | 12 +- indra/newview/llfloater360capture.cpp | 7 +- indra/newview/llfloaterperformance.cpp | 10 +- indra/newview/llfloatersnapshot.cpp | 9 +- indra/newview/llscenemonitor.cpp | 7 +- indra/newview/llviewermenu.cpp | 5 +- indra/newview/llviewerwindow.cpp | 16 +- indra/newview/llvoavatar.cpp | 217 +++++++++++-------------- indra/newview/llworld.cpp | 53 +++--- indra/newview/llworld.h | 2 +- indra/newview/pipeline.cpp | 14 +- 12 files changed, 160 insertions(+), 207 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index 3fd2b7fe5d..44f35981b0 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -226,14 +226,12 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(std::string url, U // Build the render info to POST to the region LLSD agents = LLSD::emptyMap(); - std::vector::iterator iter = LLCharacter::sInstances.begin(); - while( iter != LLCharacter::sInstances.end() ) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* avatar = dynamic_cast(*iter); - if (avatar && - avatar->getRezzedStatus() >= 2 && // Mostly rezzed (maybe without baked textures downloaded) - !avatar->isDead() && // Not dead yet + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isDead() && // Not dead yet !avatar->isControlAvatar() && // Not part of an animated object + avatar->getRezzedStatus() >= 2 && // Mostly rezzed (maybe without baked textures downloaded) avatar->getObjectHost() == regionp->getHost()) // Ensure it's on the same region { LLSD info = LLSD::emptyMap(); @@ -243,15 +241,14 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoReportCoro(std::string url, U // the weight/complexity is unsigned, but LLSD only stores signed integers, // so if it's over that (which would be ridiculously high), just store the maximum signed int value info[KEY_WEIGHT] = (S32)(avatar_complexity < S32_MAX ? avatar_complexity : S32_MAX); - info[KEY_TOO_COMPLEX] = LLSD::Boolean(avatar->isTooComplex()); + info[KEY_TOO_COMPLEX] = LLSD::Boolean(avatar->isTooComplex()); agents[avatar->getID().asString()] = info; LL_DEBUGS("AvatarRenderInfo") << "Sending avatar render info for " << avatar->getID() - << ": " << info << LL_ENDL; + << ": " << info << LL_ENDL; num_avs++; } } - iter++; } // Reset this regions timer, moving to longer intervals if there are lots of avatars around diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp index 2a52b7dde9..9201241856 100644 --- a/indra/newview/llcontrolavatar.cpp +++ b/indra/newview/llcontrolavatar.cpp @@ -699,14 +699,14 @@ bool LLControlAvatar::isImpostor() return LLVOAvatar::isImpostor(); } -//static +// static void LLControlAvatar::onRegionChanged() { - std::vector::iterator it = LLCharacter::sInstances.begin(); - for ( ; it != LLCharacter::sInstances.end(); ++it) + for (LLCharacter* character : LLCharacter::sInstances) { - LLControlAvatar* cav = dynamic_cast(*it); - if (!cav) continue; - cav->mRegionChanged = true; + if (LLControlAvatar* cav = dynamic_cast(character)) + { + cav->mRegionChanged = true; + } } } diff --git a/indra/newview/llfloater360capture.cpp b/indra/newview/llfloater360capture.cpp index 01a0525d56..ff30c83f51 100644 --- a/indra/newview/llfloater360capture.cpp +++ b/indra/newview/llfloater360capture.cpp @@ -793,12 +793,9 @@ void LLFloater360Capture::freezeWorld(bool enable) LLEnvironment::instance().pauseCloudScroll(); // freeze all avatars - LLCharacter* avatarp; - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - avatarp = *iter; - mAvatarPauseHandles.push_back(avatarp->requestPause()); + mAvatarPauseHandles.push_back(character->requestPause()); } // freeze everything else diff --git a/indra/newview/llfloaterperformance.cpp b/indra/newview/llfloaterperformance.cpp index d5782accef..315508f22b 100644 --- a/indra/newview/llfloaterperformance.cpp +++ b/indra/newview/llfloaterperformance.cpp @@ -435,15 +435,12 @@ void LLFloaterPerformance::populateNearbyList() mNearbyList->updateColumns(true); static LLCachedControl max_render_cost(gSavedSettings, "RenderAvatarMaxComplexity", 0); - std::vector valid_nearby_avs; + std::vector valid_nearby_avs; mNearbyMaxGPUTime = LLWorld::getInstance()->getNearbyAvatarsAndMaxGPUTime(valid_nearby_avs); - std::vector::iterator char_iter = valid_nearby_avs.begin(); - - while (char_iter != valid_nearby_avs.end()) + for (LLVOAvatar* avatar : valid_nearby_avs) { - LLVOAvatar* avatar = dynamic_cast(*char_iter); - if (avatar && (LLVOAvatar::AOA_INVISIBLE != avatar->getOverallAppearance())) + if (LLVOAvatar::AOA_INVISIBLE != avatar->getOverallAppearance()) { F32 render_av_gpu_ms = avatar->getGPURenderTime(); @@ -508,7 +505,6 @@ void LLFloaterPerformance::populateNearbyList() } } } - char_iter++; } mNearbyList->sortByColumnIndex(1, false); mNearbyList->setScrollPos(prev_pos); diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index ddc567c029..ddd55d0c17 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -210,13 +210,10 @@ void LLFloaterSnapshotBase::ImplBase::updateLayout(LLFloaterSnapshotBase* floate previewp->setEnabled(true); } - //RN: freeze all avatars - LLCharacter* avatarp; - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + // RN: freeze all avatars + for (LLCharacter* character : LLCharacter::sInstances) { - avatarp = *iter; - floaterp->impl->mAvatarPauseHandles.push_back(avatarp->requestPause()); + floaterp->impl->mAvatarPauseHandles.push_back(character->requestPause()); } // freeze everything else diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index cdccaf44e9..7498c2d524 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -225,11 +225,10 @@ void LLSceneMonitor::freezeScene() return; } - //freeze all avatars - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + // freeze all avatars + for (LLCharacter* character : LLCharacter::sInstances) { - freezeAvatar((LLCharacter*)(*iter)); + freezeAvatar((LLCharacter*)character); } // freeze everything else diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index cd0b3dbd0c..0c8dd6dff9 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -1892,10 +1892,9 @@ class LLAdvancedForceParamsToDefault : public view_listener_t static void set_all_animation_time_factors(F32 time_factor) { LLMotionController::setCurrentTimeFactor(time_factor); - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - (*iter)->setAnimTimeFactor(time_factor); + character->setAnimTimeFactor(time_factor); } } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 9dc12c4856..f6de8377f3 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -741,18 +741,16 @@ public: if (gSavedSettings.getBOOL("DebugShowAvatarRenderInfo")) { std::map sorted_avs; - - std::vector::iterator sort_iter = LLCharacter::sInstances.begin(); - while (sort_iter != LLCharacter::sInstances.end()) { - LLVOAvatar* avatar = dynamic_cast(*sort_iter); - if (avatar && - !avatar->isDead()) // Not dead yet + for (LLCharacter* character : LLCharacter::sInstances) { - // Stuff into a sorted map so the display is ordered - sorted_avs[avatar->getFullname()] = avatar; + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isDead()) // Not dead yet + { + // Stuff into a sorted map so the display is ordered + sorted_avs[avatar->getFullname()] = avatar; + } } - sort_iter++; } std::string trunc_name; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index fcd2f74108..6e6ad485cf 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -768,6 +768,8 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, } mVisuallyMuteSetting = LLVOAvatar::VisualMuteSettings(LLRenderMuteList::getInstance()->getSavedVisualMuteSetting(getID())); + + sInstances.push_back(this); } std::string LLVOAvatar::avString() const @@ -815,6 +817,8 @@ void LLVOAvatar::debugAvatarRezTime(std::string notification_name, std::string c //------------------------------------------------------------------------ LLVOAvatar::~LLVOAvatar() { + sInstances.remove(this); + if (!mFullyLoaded) { debugAvatarRezTime("AvatarRezLeftCloudNotification","left after ruth seconds as cloud"); @@ -957,26 +961,16 @@ void LLVOAvatar::deleteLayerSetCaches(bool clearAll) // static bool LLVOAvatar::areAllNearbyInstancesBaked(S32& grey_avatars) { - bool res = true; grey_avatars = 0; - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; - if( inst->isDead() ) + LLVOAvatar* inst = (LLVOAvatar*)character; + if (!inst->isDead() && inst->mHasGrey && !inst->isFullyBaked()) { - continue; - } - else if( !inst->isFullyBaked() ) - { - res = false; - if (inst->mHasGrey) - { - ++grey_avatars; - } + ++grey_avatars; } } - return res; + return !grey_avatars; } // static @@ -987,11 +981,10 @@ void LLVOAvatar::getNearbyRezzedStats(std::vector& counts, F32& avg_cloud_t avg_cloud_time = 0; cloud_avatars = 0; S32 count_avg = 0; - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; - if (inst) + if (LLVOAvatar* inst = (LLVOAvatar*)character) { S32 rez_status = inst->getRezzedStatus(); counts[rez_status]++; @@ -1008,6 +1001,7 @@ void LLVOAvatar::getNearbyRezzedStats(std::vector& counts, F32& avg_cloud_t } } } + if (count_avg > 0) { avg_cloud_time /= count_avg; @@ -1017,11 +1011,19 @@ void LLVOAvatar::getNearbyRezzedStats(std::vector& counts, F32& avg_cloud_t // static std::string LLVOAvatar::rezStatusToString(S32 rez_status) { - if (rez_status==0) return "cloud"; - if (rez_status==1) return "gray"; - if (rez_status==2) return "downloading baked"; - if (rez_status==3) return "loading attachments"; - if (rez_status==4) return "full"; + switch (rez_status) + { + case 0: + return "cloud"; + case 1: + return "gray"; + case 2: + return "downloading baked"; + case 3: + return "loading attachments"; + case 4: + return "full"; + } return "unknown"; } @@ -1030,10 +1032,9 @@ void LLVOAvatar::dumpBakedStatus() { LLVector3d camera_pos_global = gAgentCamera.getCameraPositionGlobal(); - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; + LLVOAvatar* inst = (LLVOAvatar*)character; LL_INFOS() << "Avatar "; LLNameValue* firstname = inst->getNVPair("FirstName"); @@ -1128,10 +1129,9 @@ void LLVOAvatar::destroyGL() //static void LLVOAvatar::resetImpostors() { - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* avatar = (LLVOAvatar*) *iter; + LLVOAvatar* avatar = (LLVOAvatar*)character; avatar->mImpostor.release(); avatar->mNeedsImpostorUpdate = true; avatar->mLastImpostorUpdateReason = 1; @@ -1143,11 +1143,9 @@ void LLVOAvatar::deleteCachedImages(bool clearAll) { if (LLViewerTexLayerSet::sHasCaches) { - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; - inst->deleteLayerSetCaches(clearAll); + ((LLVOAvatar*)character)->deleteLayerSetCaches(clearAll); } LLViewerTexLayerSet::sHasCaches = false; } @@ -1202,7 +1200,7 @@ void LLVOAvatar::initInstance() //------------------------------------------------------------------------- if (LLCharacter::sInstances.size() == 1) { - registerMotion( ANIM_AGENT_DO_NOT_DISTURB, LLNullMotion::create ); + registerMotion( ANIM_AGENT_DO_NOT_DISTURB, LLNullMotion::create ); registerMotion( ANIM_AGENT_CROUCH, LLKeyframeStandMotion::create ); registerMotion( ANIM_AGENT_CROUCHWALK, LLKeyframeWalkMotion::create ); registerMotion( ANIM_AGENT_EXPRESS_AFRAID, LLEmote::create ); @@ -3628,29 +3626,28 @@ void LLVOAvatar::clearNameTag() mTimeVisible.reset(); } -//static +// static void LLVOAvatar::invalidateNameTag(const LLUUID& agent_id) { - LLViewerObject* obj = gObjectList.findObject(agent_id); - if (!obj) return; - - LLVOAvatar* avatar = dynamic_cast(obj); - if (!avatar) return; - - avatar->clearNameTag(); + if (LLViewerObject* obj = gObjectList.findObject(agent_id)) + { + if (LLVOAvatar* avatar = dynamic_cast(obj)) + { + avatar->clearNameTag(); + } + } } -//static +// static void LLVOAvatar::invalidateNameTags() { - std::vector::iterator it = LLCharacter::sInstances.begin(); - for ( ; it != LLCharacter::sInstances.end(); ++it) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* avatar = dynamic_cast(*it); - if (!avatar) continue; - if (avatar->isDead()) continue; - - avatar->clearNameTag(); + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isDead()) + { + avatar->clearNameTag(); + } } } @@ -8261,15 +8258,13 @@ void LLVOAvatar::logPendingPhases() //static void LLVOAvatar::logPendingPhasesAllAvatars() { - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; - if( inst->isDead() ) + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isDead()) { - continue; + avatar->logPendingPhases(); } - inst->logPendingPhases(); } } @@ -10443,15 +10438,16 @@ void LLVOAvatar::setVisibilityRank(U32 rank) S32 LLVOAvatar::getUnbakedPixelAreaRank() { S32 rank = 1; - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; - if (inst == this) + if (character == this) { return rank; } - else if (!inst->isDead() && !inst->isFullyBaked()) + + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isDead() && !avatar->isFullyBaked()) { rank++; } @@ -10461,49 +10457,37 @@ S32 LLVOAvatar::getUnbakedPixelAreaRank() return 0; } -struct CompareScreenAreaGreater -{ - bool operator()(const LLCharacter* const& lhs, const LLCharacter* const& rhs) - { - return lhs->getPixelArea() > rhs->getPixelArea(); - } -}; - // static void LLVOAvatar::cullAvatarsByPixelArea() { - std::sort(LLCharacter::sInstances.begin(), LLCharacter::sInstances.end(), CompareScreenAreaGreater()); + LLCharacter::sInstances.sort([](LLCharacter* lhs, LLCharacter* rhs) + { + return lhs->getPixelArea() > rhs->getPixelArea(); + }); // Update the avatars that have changed status - U32 rank = 2; //1 is reserved for self. - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) { - LLVOAvatar* inst = (LLVOAvatar*) *iter; - bool culled; - if (inst->isSelf() || inst->isFullyBaked()) - { - culled = false; - } - else + U32 rank = 2; //1 is reserved for self. + for (LLCharacter* character : LLCharacter::sInstances) { - culled = true; - } + LLVOAvatar* inst = (LLVOAvatar*)character; + bool culled = !inst->isSelf() && !inst->isFullyBaked(); - if (inst->mCulled != culled) - { - inst->mCulled = culled; - LL_DEBUGS() << "avatar " << inst->getID() << (culled ? " start culled" : " start not culled" ) << LL_ENDL; - inst->updateMeshTextures(); - } + if (inst->mCulled != culled) + { + inst->mCulled = culled; + LL_DEBUGS() << "avatar " << inst->getID() << (culled ? " start culled" : " start not culled" ) << LL_ENDL; + inst->updateMeshTextures(); + } - if (inst->isSelf()) - { - inst->setVisibilityRank(1); - } - else if (inst->mDrawable.notNull() && inst->mDrawable->isVisible()) - { - inst->setVisibilityRank(rank++); + if (inst->isSelf()) + { + inst->setVisibilityRank(1); + } + else if (inst->mDrawable.notNull() && inst->mDrawable->isVisible()) + { + inst->setVisibilityRank(rank++); + } } } @@ -10762,11 +10746,9 @@ void LLVOAvatar::updateImpostors() { LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; - std::vector instances_copy = LLCharacter::sInstances; - for (std::vector::iterator iter = instances_copy.begin(); - iter != instances_copy.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* avatar = (LLVOAvatar*) *iter; + LLVOAvatar* avatar = (LLVOAvatar*)character; if (!avatar->isDead() && avatar->isVisible() && avatar->isImpostor() @@ -10923,21 +10905,17 @@ void LLVOAvatar::updateNearbyAvatarCount() S32 avs_nearby = 0; static LLCachedControl render_far_clip(gSavedSettings, "RenderFarClip", 64); F32 radius = render_far_clip * render_far_clip; - std::vector::iterator char_iter = LLCharacter::sInstances.begin(); - while (char_iter != LLCharacter::sInstances.end()) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar *avatar = dynamic_cast(*char_iter); - if (avatar && !avatar->isDead() && !avatar->isControlAvatar()) + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isDead() && !avatar->isControlAvatar()) { - if ((dist_vec_squared(avatar->getPositionGlobal(), gAgent.getPositionGlobal()) > radius) && - (dist_vec_squared(avatar->getPositionGlobal(), gAgentCamera.getCameraPositionGlobal()) > radius)) + if ((dist_vec_squared(avatar->getPositionGlobal(), gAgent.getPositionGlobal()) <= radius) || + (dist_vec_squared(avatar->getPositionGlobal(), gAgentCamera.getCameraPositionGlobal()) <= radius)) { - char_iter++; - continue; + avs_nearby++; } - avs_nearby++; } - char_iter++; } sAvatarsNearby = avs_nearby; agent_update_timer.reset(); @@ -11710,10 +11688,9 @@ F32 LLVOAvatar::getTotalGPURenderTime() F32 ret = 0.f; - for (LLCharacter* iter : LLCharacter::sInstances) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*) iter; - ret += inst->getGPURenderTime(); + ret += ((LLVOAvatar*)character)->getGPURenderTime(); } return ret; @@ -11725,10 +11702,9 @@ F32 LLVOAvatar::getMaxGPURenderTime() F32 ret = 0.f; - for (LLCharacter* iter : LLCharacter::sInstances) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*)iter; - ret = llmax(inst->getGPURenderTime(), ret); + ret = llmax(((LLVOAvatar*)character)->getGPURenderTime(), ret); } return ret; @@ -11742,12 +11718,12 @@ F32 LLVOAvatar::getAverageGPURenderTime() S32 count = 0; - for (LLCharacter* iter : LLCharacter::sInstances) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* inst = (LLVOAvatar*)iter; - if (!inst->isTooSlow()) + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isTooSlow()) { - ret += inst->getGPURenderTime(); + ret += avatar->getGPURenderTime(); ++count; } } @@ -11759,6 +11735,7 @@ F32 LLVOAvatar::getAverageGPURenderTime() return ret; } + bool LLVOAvatar::isBuddy() const { return LLAvatarTracker::instance().isBuddy(getID()); diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 9508d33eb3..40bfa8ec83 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -1320,35 +1320,32 @@ void LLWorld::getAvatars(uuid_vec_t* avatar_ids, std::vector* positi } // get the list of avatars from the character list first, so distances are correct // when agent is above 1020m and other avatars are nearby - for (std::vector::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); ++iter) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* pVOAvatar = (LLVOAvatar*) *iter; - - if (!pVOAvatar->isDead() && !pVOAvatar->mIsDummy && !pVOAvatar->isOrphaned()) + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isDead() && !avatar->mIsDummy && !avatar->isOrphaned()) { - LLVector3d pos_global = pVOAvatar->getPositionGlobal(); - LLUUID uuid = pVOAvatar->getID(); + LLVector3d pos_global = avatar->getPositionGlobal(); + LLUUID uuid = avatar->getID(); if (!uuid.isNull() && dist_vec_squared(pos_global, relative_to) <= radius_squared) { - if(positions != NULL) + if (positions != NULL) { positions->push_back(pos_global); } - if(avatar_ids !=NULL) + if (avatar_ids != NULL) { avatar_ids->push_back(uuid); } } } } + // region avatars added for situations where radius is greater than RenderFarClip - for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); - iter != LLWorld::getInstance()->getRegionList().end(); ++iter) + for (const LLViewerRegion* regionp : LLWorld::getInstance()->getRegionList()) { - LLViewerRegion* regionp = *iter; const LLVector3d& origin_global = regionp->getOriginGlobal(); auto count = regionp->mMapAvatars.size(); for (size_t i = 0; i < count; i++) @@ -1371,33 +1368,31 @@ void LLWorld::getAvatars(uuid_vec_t* avatar_ids, std::vector* positi } } -F32 LLWorld::getNearbyAvatarsAndMaxGPUTime(std::vector &valid_nearby_avs) +F32 LLWorld::getNearbyAvatarsAndMaxGPUTime(std::vector &valid_nearby_avs) { static LLCachedControl render_far_clip(gSavedSettings, "RenderFarClip", 64); + F32 nearby_max_complexity = 0; F32 radius = render_far_clip * render_far_clip; - std::vector::iterator char_iter = LLCharacter::sInstances.begin(); - while (char_iter != LLCharacter::sInstances.end()) + + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* avatar = dynamic_cast(*char_iter); - if (avatar && !avatar->isDead() && !avatar->isControlAvatar()) + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (!avatar->isDead() && !avatar->isControlAvatar()) { - if ((dist_vec_squared(avatar->getPositionGlobal(), gAgent.getPositionGlobal()) > radius) && - (dist_vec_squared(avatar->getPositionGlobal(), gAgentCamera.getCameraPositionGlobal()) > radius)) + if ((dist_vec_squared(avatar->getPositionGlobal(), gAgent.getPositionGlobal()) <= radius) || + (dist_vec_squared(avatar->getPositionGlobal(), gAgentCamera.getCameraPositionGlobal()) <= radius)) { - char_iter++; - continue; - } - - if (!avatar->isTooSlow()) - { - gPipeline.profileAvatar(avatar); + if (!avatar->isTooSlow()) + { + gPipeline.profileAvatar(avatar); + } + nearby_max_complexity = llmax(nearby_max_complexity, avatar->getGPURenderTime()); + valid_nearby_avs.push_back(avatar); } - nearby_max_complexity = llmax(nearby_max_complexity, avatar->getGPURenderTime()); - valid_nearby_avs.push_back(*char_iter); } - char_iter++; } + return nearby_max_complexity; } diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h index 01f666d19a..dc95a4eff1 100644 --- a/indra/newview/llworld.h +++ b/indra/newview/llworld.h @@ -172,7 +172,7 @@ public: // profile nearby avatars using gPipeline.profileAvatar and update their render times // return max GPU time - F32 getNearbyAvatarsAndMaxGPUTime(std::vector &valid_nearby_avs); + F32 getNearbyAvatarsAndMaxGPUTime(std::vector &valid_nearby_avs); private: void clearHoleWaterObjects(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 056affb68e..2a461ca84b 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6438,16 +6438,14 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, } } - //check all avatar nametags (silly, isn't it?) - for (std::vector< LLCharacter* >::iterator iter = LLCharacter::sInstances.begin(); - iter != LLCharacter::sInstances.end(); - ++iter) + // check all avatar nametags (silly, isn't it?) + for (LLCharacter* character : LLCharacter::sInstances) { - LLVOAvatar* av = (LLVOAvatar*) *iter; - if (av->mNameText.notNull() - && av->mNameText->lineSegmentIntersect(start, local_end, position)) + LLVOAvatar* avatar = (LLVOAvatar*)character; + if (avatar->mNameText.notNull() && + avatar->mNameText->lineSegmentIntersect(start, local_end, position)) { - drawable = av->mDrawable; + drawable = avatar->mDrawable; local_end = position; } } -- cgit v1.2.3 From c4ff0b48898de86b9ee8e198395e16a8429c8aa4 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 19 Jul 2024 20:17:37 +0300 Subject: viewer#2071 Properly handle 'out of memory' for meshes --- indra/newview/llfloaterbvhpreview.cpp | 14 ++++++-- indra/newview/llmeshrepository.cpp | 60 +++++++++++++++++++++++++++++++---- indra/newview/llviewerassetupload.cpp | 7 +++- indra/newview/llviewerobject.cpp | 7 +++- 4 files changed, 78 insertions(+), 10 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterbvhpreview.cpp b/indra/newview/llfloaterbvhpreview.cpp index 2cb930922a..3d81d01e16 100644 --- a/indra/newview/llfloaterbvhpreview.cpp +++ b/indra/newview/llfloaterbvhpreview.cpp @@ -285,7 +285,12 @@ bool LLFloaterBvhPreview::postBuild() // create data buffer for keyframe initialization S32 buffer_size = loaderp->getOutputSize(); - U8* buffer = new U8[buffer_size]; + U8* buffer = new(std::nothrow) U8[buffer_size]; + if (!buffer) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Bad memory allocation for buffer, size: " << buffer_size << LL_ENDL; + } LLDataPackerBinaryBuffer dp(buffer, buffer_size); @@ -992,7 +997,12 @@ void LLFloaterBvhPreview::onBtnOK(void* userdata) LLKeyframeMotion* motionp = (LLKeyframeMotion*)floaterp->mAnimPreview->getDummyAvatar()->findMotion(floaterp->mMotionID); S32 file_size = motionp->getFileSize(); - U8* buffer = new U8[file_size]; + U8* buffer = new(std::nothrow) U8[file_size]; + if (!buffer) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Bad memory allocation for buffer, size: " << file_size << LL_ENDL; + } LLDataPackerBinaryBuffer dp(buffer, file_size); if (motionp->serialize(dp)) diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 1c64ed6822..a1b2d502af 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1360,7 +1360,19 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id, bool can_retry) U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { - LL_WARNS(LOG_MESH) << "Failed to allocate memory for skin info, size: " << size << LL_ENDL; + // Not sure what size is reasonable for skin info, + // but if 20MB allocation failed, we definetely have issues + const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + if (size < MAX_SIZE) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Bad memory allocation for skin info, size: " << size << LL_ENDL; + } + else + { + // Ignore failures for anomalously large data + LL_WARNS(LOG_MESH) << "Failed to allocate memory for skin info, size: " << size << LL_ENDL; + } return false; } LLMeshRepository::sCacheBytesRead += size; @@ -1473,7 +1485,19 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id) U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { - LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + // Not sure what size is reasonable for decomposition + // but if 20MB allocation failed, we definetely have issues + const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + if (size < MAX_SIZE) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + } + else + { + // Ignore failures for anomalously large decompositiions + LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + } return false; } LLMeshRepository::sCacheBytesRead += size; @@ -1575,7 +1599,19 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id) U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { - LL_WARNS(LOG_MESH) << "Failed to allocate memory for physics shape, size: " << size << LL_ENDL; + // Not sure what size is reasonable for physcis + // but if 20MB allocation failed, we definetely have issues + const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + if (size < MAX_SIZE) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + } + else + { + // Ignore failures for anomalously large meshes + LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + } return false; } file.read(buffer, size); @@ -1766,9 +1802,21 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod, U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { - LL_WARNS(LOG_MESH) << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL; - // todo: for now it will result in indefinite constant retries, should result in timeout - // or in retry-count and disabling mesh. (but usually viewer is beyond saving at this point) + // Not sure what size is reasonable for a mesh, + // but if 20MB allocation failed, we definetely have issues + const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + if (size < MAX_SIZE) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL; + } + else + { + // Ignore failures for anomalously large data + LL_WARNS(LOG_MESH) << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL; + // todo: for now it will result in indefinite constant retries, should result in timeout + // or in retry-count and disabling mesh. (but usually viewer is beyond saving at this point) + } return false; } LLMeshRepository::sCacheBytesRead += size; diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 50128d826a..b74b48b9f6 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -479,7 +479,12 @@ LLSD LLNewFileResourceUploadInfo::exportTempFile() else { S32 size = LLAPRFile::size(getFileName()); - U8* buffer = new U8[size]; + U8* buffer = new(std::nothrow) U8[size]; + if (!buffer) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Bad memory allocation for buffer, size: " << size << LL_ENDL; + } S32 size_read = infile.read(buffer,size); if (size_read != size) { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 094d866bc1..fd85d75d98 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -1521,7 +1521,12 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, S32 size = mesgsys->getSizeFast(_PREHASH_ObjectData, block_num, _PREHASH_ExtraParams); if (size > 0) { - U8 *buffer = new U8[size]; + U8 *buffer = new(std::nothrow) U8[size]; + if (!buffer) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Bad memory allocation for buffer, size: " << size << LL_ENDL; + } mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_ExtraParams, buffer, size, block_num); LLDataPackerBinaryBuffer dp(buffer, size); -- cgit v1.2.3 From c5d2e92089344b115d657eb23487144cb3d9842a Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 29 Jul 2024 11:00:05 +0300 Subject: viewer#2071 Soft quit on 'out of memory' for meshes #2 --- indra/newview/llappviewer.cpp | 35 +++++++++++++++++-- indra/newview/llappviewer.h | 7 ++++ indra/newview/llmeshrepository.cpp | 70 +++++++++++++++----------------------- 3 files changed, 67 insertions(+), 45 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index b380b09129..d25762f561 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -646,6 +646,7 @@ LLAppViewer::LLAppViewer() mSavedFinalSnapshot(false), mSavePerAccountSettings(false), // don't save settings on logout unless login succeeded. mQuitRequested(false), + mClosingFloaters(false), mLogoutRequestSent(false), mLastAgentControlFlags(0), mLastAgentForceUpdate(0), @@ -4028,6 +4029,7 @@ void LLAppViewer::requestQuit() { // application is quitting gFloaterView->closeAllChildren(true); + mClosingFloaters = true; } // Send preferences once, when exiting @@ -4091,6 +4093,7 @@ void LLAppViewer::abortQuit() { LL_INFOS() << "abortQuit()" << LL_ENDL; mQuitRequested = false; + mClosingFloaters = false; } void LLAppViewer::migrateCacheDirectory() @@ -5040,10 +5043,19 @@ void LLAppViewer::idleShutdown() } // Wait for all floaters to get resolved - if (gFloaterView - && !gFloaterView->allChildrenClosed()) + if (gFloaterView) { - return; + if (!mClosingFloaters) + { + // application is quitting + gFloaterView->closeAllChildren(true); + mClosingFloaters = true; + return; + } + if (!gFloaterView->allChildrenClosed()) + { + return; + } } // ProductEngine: Try moving this code to where we shut down sTextureCache in cleanup() @@ -5204,6 +5216,23 @@ void LLAppViewer::postToMainCoro(const LL::WorkQueue::Work& work) gMainloopWork.post(work); } +void LLAppViewer::outOfMemorySoftQuit() +{ + if (!mQuitRequested) + { + // Todo: + // Find a way to free at least some memory to make it safer + // Pause decoding and mesh repositorie + getTextureCache()->pause(); + getTextureFetch()->pause(); + LLLFSThread::sLocal->pause(); + gLogoutTimer.reset(); + mQuitRequested = true; + + LLError::LLUserWarningMsg::showOutOfMemory(); + } +} + void LLAppViewer::idleNameCache() { // Neither old nor new name cache can function before agent has a region diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 417ab0fa00..cf5f1ab1e3 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -230,6 +230,12 @@ public: // post given work to the "mainloop" work queue for handling on the main thread void postToMainCoro(const LL::WorkQueue::Work& work); + // Attempt a 'soft' quit with disconnect and saving of settings/cache. + // Intended to be thread safe. + // Good chance of viewer crashing either way, but better than alternatives. + // Note: mQuitRequested can be aborted by user. + void outOfMemorySoftQuit(); + protected: virtual bool initWindow(); // Initialize the viewer's window. virtual void initLoggingAndGetLastDuration(); // Initialize log files, logging system @@ -317,6 +323,7 @@ private: boost::optional mForceGraphicsLevel; bool mQuitRequested; // User wants to quit, may have modified documents open. + bool mClosingFloaters; bool mLogoutRequestSent; // Disconnect message sent to simulator, no longer safe to send messages to the sim. U32 mLastAgentControlFlags; F32 mLastAgentForceUpdate; diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index a1b2d502af..4c5cc37766 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1360,20 +1360,18 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id, bool can_retry) U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { + LL_WARNS(LOG_MESH) << "Failed to allocate memory for skin info, size: " << size << LL_ENDL; + // Not sure what size is reasonable for skin info, // but if 20MB allocation failed, we definetely have issues - const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + const S32 MAX_SIZE = 30 * 1024 * 1024; //30MB if (size < MAX_SIZE) { - LLError::LLUserWarningMsg::showOutOfMemory(); - LL_ERRS() << "Bad memory allocation for skin info, size: " << size << LL_ENDL; - } - else - { - // Ignore failures for anomalously large data - LL_WARNS(LOG_MESH) << "Failed to allocate memory for skin info, size: " << size << LL_ENDL; - } - return false; + LLAppViewer::instance()->outOfMemorySoftQuit(); + } // else ignore failures for anomalously large data + LLMutexLock locker(mMutex); + mSkinUnavailableQ.emplace_back(mesh_id); + return true; } LLMeshRepository::sCacheBytesRead += size; ++LLMeshRepository::sCacheReads; @@ -1485,20 +1483,16 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id) U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { + LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + // Not sure what size is reasonable for decomposition // but if 20MB allocation failed, we definetely have issues - const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + const S32 MAX_SIZE = 30 * 1024 * 1024; //30MB if (size < MAX_SIZE) { - LLError::LLUserWarningMsg::showOutOfMemory(); - LL_ERRS() << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; - } - else - { - // Ignore failures for anomalously large decompositiions - LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; - } - return false; + LLAppViewer::instance()->outOfMemorySoftQuit(); + } // else ignore failures for anomalously large decompositiions + return true; } LLMeshRepository::sCacheBytesRead += size; ++LLMeshRepository::sCacheReads; @@ -1599,20 +1593,16 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id) U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { + LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + // Not sure what size is reasonable for physcis // but if 20MB allocation failed, we definetely have issues - const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + const S32 MAX_SIZE = 30 * 1024 * 1024; //30MB if (size < MAX_SIZE) { - LLError::LLUserWarningMsg::showOutOfMemory(); - LL_ERRS() << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; - } - else - { - // Ignore failures for anomalously large meshes - LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; - } - return false; + LLAppViewer::instance()->outOfMemorySoftQuit(); + } // else ignore failures for anomalously large data + return true; } file.read(buffer, size); @@ -1802,22 +1792,18 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod, U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { + LL_WARNS(LOG_MESH) << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL; + // Not sure what size is reasonable for a mesh, // but if 20MB allocation failed, we definetely have issues - const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + const S32 MAX_SIZE = 30 * 1024 * 1024; //30MB if (size < MAX_SIZE) { - LLError::LLUserWarningMsg::showOutOfMemory(); - LL_ERRS() << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL; - } - else - { - // Ignore failures for anomalously large data - LL_WARNS(LOG_MESH) << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL; - // todo: for now it will result in indefinite constant retries, should result in timeout - // or in retry-count and disabling mesh. (but usually viewer is beyond saving at this point) - } - return false; + LLAppViewer::instance()->outOfMemorySoftQuit(); + } // else ignore failures for anomalously large data + LLMutexLock lock(mMutex); + mUnavailableQ.push_back(LODRequest(mesh_params, lod)); + return true; } LLMeshRepository::sCacheBytesRead += size; ++LLMeshRepository::sCacheReads; -- cgit v1.2.3 From b6e90adb5624558ebc04543042f053dc32e79ff3 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 29 Jul 2024 18:50:30 +0300 Subject: small adjustment to reduce confusion --- indra/newview/llappviewer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index d25762f561..f2023565fc 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2249,7 +2249,9 @@ void errorCallback(LLError::ELevel level, const std::string &error_string) if (level == LLError::LEVEL_ERROR) { #ifndef LL_RELEASE_FOR_DOWNLOAD - OSMessageBox(error_string, LLTrans::getString("MBFatalError"), OSMB_OK); + std::string message = error_string + + "\n\n\nThis is a developer-only notification!\nThis notification won't be present in Release for download build"; + OSMessageBox(message, LLTrans::getString("MBFatalError"), OSMB_OK); #endif gDebugInfo["FatalMessage"] = error_string; -- cgit v1.2.3 From 9e4cc30b298c32b0a90fa311560c2b43c9648bb1 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 29 Jul 2024 21:19:57 +0300 Subject: viewer#2142 Crash at LLOutfitGalleryItem::setDefaultImage --- indra/newview/llinventorygallery.cpp | 104 ++++++++++++++++++++--------------- indra/newview/llinventorygallery.h | 1 + indra/newview/lloutfitgallery.cpp | 44 ++++++++++++--- indra/newview/lloutfitgallery.h | 3 +- 4 files changed, 101 insertions(+), 51 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 98b3707457..2ca122c955 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -221,9 +221,10 @@ void LLInventoryGallery::setRootFolder(const LLUUID cat_id) for (const LLUUID& id : mSelectedItemIDs) { - if (mItemMap[id]) + LLInventoryGalleryItem* item = getItem(id); + if (item) { - mItemMap[id]->setSelected(false); + item->setSelected(false); } } @@ -348,7 +349,7 @@ void LLInventoryGallery::initGallery() mScrollPanel->addChild(mGalleryPanel); for (int i = 0; i < n; i++) { - addToGallery(mItemMap[cats[i]]); + addToGallery(getItem(cats[i])); } reArrangeRows(); mGalleryCreated = true; @@ -656,6 +657,16 @@ LLInventoryGalleryItem* LLInventoryGallery::buildGalleryItem(std::string name, L return gitem; } +LLInventoryGalleryItem* LLInventoryGallery::getItem(const LLUUID& id) const +{ + auto it = mItemMap.find(id); + if (it != mItemMap.end()) + { + return it->second; + } + return nullptr; +} + void LLInventoryGallery::buildGalleryPanel(int row_count) { LLPanel::Params params; @@ -1006,14 +1017,15 @@ void LLInventoryGallery::updateItemThumbnail(LLUUID item_id) thumbnail_id = getOutfitImageID(item_id); } - if (mItemMap[item_id]) + LLInventoryGalleryItem* item = getItem(item_id); + if (item) { - mItemMap[item_id]->setLoadImmediately(mLoadThumbnailsImmediately); - mItemMap[item_id]->setThumbnail(thumbnail_id); + item->setLoadImmediately(mLoadThumbnailsImmediately); + item->setThumbnail(thumbnail_id); - bool passes_filter = checkAgainstFilters(mItemMap[item_id], mFilterSubString); - if((mItemMap[item_id]->isHidden() && passes_filter) - || (!mItemMap[item_id]->isHidden() && !passes_filter)) + bool passes_filter = checkAgainstFilters(item, mFilterSubString); + if((item->isHidden() && passes_filter) + || (!item->isHidden() && !passes_filter)) { reArrangeRows(); } @@ -1169,7 +1181,7 @@ void LLInventoryGallery::moveUp(MASK mask) if (mInventoryGalleryMenu && mSelectedItemIDs.size() > 0 && mItemsAddedCount > 1) { - LLInventoryGalleryItem* item = mItemMap[mLastInteractedUUID]; + LLInventoryGalleryItem* item = getItem(mLastInteractedUUID); if (item) { if (mask == MASK_NONE || mask == MASK_CONTROL) @@ -1214,7 +1226,7 @@ void LLInventoryGallery::moveDown(MASK mask) if (mInventoryGalleryMenu && mSelectedItemIDs.size() > 0 && mItemsAddedCount > 1) { - LLInventoryGalleryItem* item = mItemMap[mLastInteractedUUID]; + LLInventoryGalleryItem* item = getItem(mLastInteractedUUID); if (item) { if (mask == MASK_NONE || mask == MASK_CONTROL) @@ -1259,11 +1271,7 @@ void LLInventoryGallery::moveLeft(MASK mask) if (mInventoryGalleryMenu && mSelectedItemIDs.size() > 0 && mItemsAddedCount > 1) { - LLInventoryGalleryItem* item = mItemMap[mLastInteractedUUID]; - if (mask == MASK_SHIFT) - { - item = mItemMap[mLastInteractedUUID]; - } + LLInventoryGalleryItem* item = getItem(mLastInteractedUUID); if (item) { // Might be better to get item from panel @@ -1307,7 +1315,7 @@ void LLInventoryGallery::moveRight(MASK mask) if (mInventoryGalleryMenu && mSelectedItemIDs.size() > 0 && mItemsAddedCount > 1) { - LLInventoryGalleryItem* item = mItemMap[mLastInteractedUUID]; + LLInventoryGalleryItem* item = getItem(mLastInteractedUUID); if (item) { S32 n = mItemIndexMap[item]; @@ -1373,8 +1381,8 @@ void LLInventoryGallery::toggleSelectionRangeFromLast(const LLUUID target) { return; } - LLInventoryGalleryItem* last_item = mItemMap[mLastInteractedUUID]; - LLInventoryGalleryItem* next_item = mItemMap[target]; + LLInventoryGalleryItem* last_item = getItem(mLastInteractedUUID); + LLInventoryGalleryItem* next_item = getItem(target); if (last_item && next_item) { S32 last_idx = mItemIndexMap[last_item]; @@ -1417,9 +1425,10 @@ void LLInventoryGallery::onFocusLost() for (const LLUUID& id : mSelectedItemIDs) { - if (mItemMap[id]) + LLInventoryGalleryItem* item = getItem(id); + if (item) { - mItemMap[id]->setSelected(false); + item->setSelected(false); } } } @@ -1435,9 +1444,10 @@ void LLInventoryGallery::onFocusReceived() LLInventoryGalleryItem* focus_item = NULL; for (const LLUUID& id : mSelectedItemIDs) { - if (mItemMap[id] && !mItemMap[id]->isHidden()) + LLInventoryGalleryItem* item = getItem(id); + if (item && !item->isHidden()) { - focus_item = mItemMap[id]; + focus_item = item; focus_item->setSelected(true); } } @@ -1478,9 +1488,10 @@ void LLInventoryGallery::changeItemSelection(const LLUUID& item_id, bool scroll_ { for (const LLUUID& id : mSelectedItemIDs) { - if (mItemMap[id]) + LLInventoryGalleryItem* item = getItem(id); + if (item) { - mItemMap[id]->setSelected(false); + item->setSelected(false); } } mSelectedItemIDs.clear(); @@ -1499,9 +1510,10 @@ void LLInventoryGallery::changeItemSelection(const LLUUID& item_id, bool scroll_ return; } - if (mItemMap[item_id]) + LLInventoryGalleryItem* item = getItem(item_id); + if (item) { - mItemMap[item_id]->setSelected(true); + item->setSelected(true); } mSelectedItemIDs.push_back(item_id); signalSelectionItemID(item_id); @@ -1527,9 +1539,10 @@ void LLInventoryGallery::addItemSelection(const LLUUID& item_id, bool scroll_to_ return; } - if (mItemMap[item_id]) + LLInventoryGalleryItem* item = getItem(item_id); + if (item) { - mItemMap[item_id]->setSelected(true); + item->setSelected(true); } mSelectedItemIDs.push_back(item_id); signalSelectionItemID(item_id); @@ -1552,18 +1565,20 @@ bool LLInventoryGallery::toggleItemSelection(const LLUUID& item_id, bool scroll_ selection_deque::iterator found = std::find(mSelectedItemIDs.begin(), mSelectedItemIDs.end(), item_id); if (found != mSelectedItemIDs.end()) { - if (mItemMap[item_id]) + LLInventoryGalleryItem* item = getItem(item_id); + if (item) { - mItemMap[item_id]->setSelected(false); + item->setSelected(false); } mSelectedItemIDs.erase(found); result = false; } else { - if (mItemMap[item_id]) + LLInventoryGalleryItem* item = getItem(item_id); + if (item) { - mItemMap[item_id]->setSelected(true); + item->setSelected(true); } mSelectedItemIDs.push_back(item_id); signalSelectionItemID(item_id); @@ -1580,7 +1595,7 @@ bool LLInventoryGallery::toggleItemSelection(const LLUUID& item_id, bool scroll_ void LLInventoryGallery::scrollToShowItem(const LLUUID& item_id) { - LLInventoryGalleryItem* item = mItemMap[item_id]; + LLInventoryGalleryItem* item = getItem(item_id); if(item) { const LLRect visible_content_rect = mScrollPanel->getVisibleContentRect(); @@ -1610,7 +1625,7 @@ LLInventoryGalleryItem* LLInventoryGallery::getFirstSelectedItem() if (mSelectedItemIDs.size() > 0) { selection_deque::iterator iter = mSelectedItemIDs.begin(); - return mItemMap[*iter]; + return getItem(*iter); } return NULL; } @@ -1768,9 +1783,10 @@ void LLInventoryGallery::paste() { for (const LLUUID& id : mSelectedItemIDs) { - if (mItemMap[id]) + LLInventoryGalleryItem* item = getItem(id); + if (item) { - mItemMap[id]->setSelected(false); + item->setSelected(false); } } mSelectedItemIDs.clear(); @@ -2108,9 +2124,10 @@ void LLInventoryGallery::pasteAsLink() { for (const LLUUID& id : mSelectedItemIDs) { - if (mItemMap[id]) + LLInventoryGalleryItem* item = getItem(id); + if (item) { - mItemMap[id]->setSelected(false); + item->setSelected(false); } } mSelectedItemIDs.clear(); @@ -2433,10 +2450,10 @@ void LLInventoryGallery::onGesturesChanged() void LLInventoryGallery::deselectItem(const LLUUID& category_id) { // Reset selection if the item is selected. - LLInventoryGalleryItem* item = mItemMap[category_id]; + LLInventoryGalleryItem* item = getItem(category_id); if (item && item->isSelected()) { - mItemMap[category_id]->setSelected(false); + item->setSelected(false); setFocus(true); // Todo: support multiselect // signalSelectionItemID(LLUUID::null); @@ -2453,9 +2470,10 @@ void LLInventoryGallery::clearSelection() { for (const LLUUID& id: mSelectedItemIDs) { - if (mItemMap[id]) + LLInventoryGalleryItem* item = getItem(id); + if (item) { - mItemMap[id]->setSelected(false); + item->setSelected(false); } } if (!mSelectedItemIDs.empty()) diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h index afc7bdc9f8..59d08d19ed 100644 --- a/indra/newview/llinventorygallery.h +++ b/indra/newview/llinventorygallery.h @@ -228,6 +228,7 @@ private: void updateGalleryWidth(); LLInventoryGalleryItem* buildGalleryItem(std::string name, LLUUID item_id, LLAssetType::EType type, LLUUID thumbnail_id, LLInventoryType::EType inventory_type, U32 flags, time_t creation_date, bool is_link, bool is_worn); + LLInventoryGalleryItem* getItem(const LLUUID& id) const; void buildGalleryPanel(int row_count); void reshapeGalleryPanel(int row_count); diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index 7482890d1e..f889a4439e 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -128,7 +128,7 @@ void LLOutfitGallery::onOpen(const LLSD& info) mScrollPanel->addChild(mGalleryPanel); for (int i = 0; i < n; i++) { - addToGallery(mOutfitMap[cats[i]]); + addToGallery(getItem(cats[i])); } reArrangeRows(); mGalleryCreated = true; @@ -377,7 +377,7 @@ void LLOutfitGallery::onOutfitsRemovalConfirmation(const LLSD& notification, con void LLOutfitGallery::scrollToShowItem(const LLUUID& item_id) { - LLOutfitGalleryItem* item = mOutfitMap[item_id]; + LLOutfitGalleryItem* item = getItem(item_id); if (item) { const LLRect visible_content_rect = mScrollPanel->getVisibleContentRect(); @@ -525,6 +525,10 @@ LLPanel* LLOutfitGallery::addToRow(LLPanel* row_stack, LLOutfitGalleryItem* item void LLOutfitGallery::addToGallery(LLOutfitGalleryItem* item) { + if (!item) + { + return; + } if(item->isHidden()) { mHiddenItems.push_back(item); @@ -632,9 +636,19 @@ LLOutfitGalleryItem* LLOutfitGallery::buildGalleryItem(std::string name, LLUUID return gitem; } -LLOutfitGalleryItem* LLOutfitGallery::getSelectedItem() +LLOutfitGalleryItem* LLOutfitGallery::getSelectedItem() const +{ + return getItem(mSelectedOutfitUUID); +} + +LLOutfitGalleryItem* LLOutfitGallery::getItem(const LLUUID& id) const { - return mOutfitMap[mSelectedOutfitUUID]; + auto it = mOutfitMap.find(id); + if (it != mOutfitMap.end()) + { + return it->second; + } + return nullptr; } void LLOutfitGallery::buildGalleryPanel(int row_count) @@ -1275,7 +1289,15 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) } if (asset_id.notNull()) { - photo_loaded |= mOutfitMap[category_id]->setImageAssetId(asset_id); + LLOutfitGalleryItem* item = getItem(category_id); + if (item) + { + photo_loaded |= item->setImageAssetId(asset_id); + } + else + { + photo_loaded = true; + } // Rename links if (!mOutfitRenamePending.isNull() && mOutfitRenamePending.asString() == item_name) { @@ -1301,13 +1323,21 @@ void LLOutfitGallery::refreshOutfit(const LLUUID& category_id) } if (!photo_loaded) { - mOutfitMap[category_id]->setDefaultImage(); + LLOutfitGalleryItem* item = getItem(category_id); + if (item) + { + item->setDefaultImage(); + } } } } else { - mOutfitMap[category_id]->setImageAssetId(asset_id); + LLOutfitGalleryItem* item = getItem(category_id); + if (item) + { + item->setImageAssetId(asset_id); + } } } diff --git a/indra/newview/lloutfitgallery.h b/indra/newview/lloutfitgallery.h index 5b2a33d0ca..fa441ff209 100644 --- a/indra/newview/lloutfitgallery.h +++ b/indra/newview/lloutfitgallery.h @@ -135,7 +135,8 @@ private: void updateGalleryWidth(); LLOutfitGalleryItem* buildGalleryItem(std::string name, LLUUID outfit_id); - LLOutfitGalleryItem* getSelectedItem(); + LLOutfitGalleryItem* getSelectedItem() const; + LLOutfitGalleryItem* getItem(const LLUUID& id) const; void onTextureSelectionChanged(LLInventoryItem* itemp); -- cgit v1.2.3 From 0c70d3c616320ae6e3f22935b0fd997133b0e0ec Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Tue, 30 Jul 2024 10:53:38 -0400 Subject: Cache LLVOAvatar::isBuddy check to reduce repeated calls to LLAvatarTracker::isBuddy during draw (#2149) --- indra/newview/llvoavatar.cpp | 26 ++++++++++++++++++++------ indra/newview/llvoavatar.h | 2 ++ 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 6e6ad485cf..0fd8f8a98b 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -3395,7 +3395,7 @@ void LLVOAvatar::idleUpdateNameTagText(bool new_name) { is_muted = isInMuteList(); } - bool is_friend = LLAvatarTracker::instance().isBuddy(getID()); + bool is_friend = isBuddy(); bool is_cloud = getIsCloud(); if (is_appearance != mNameAppearance) @@ -8452,7 +8452,7 @@ bool LLVOAvatar::isTooComplex() const { bool too_complex; static LLCachedControl compelxity_render_mode(gSavedSettings, "RenderAvatarComplexityMode"); - bool render_friend = (LLAvatarTracker::instance().isBuddy(getID()) && compelxity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY); + bool render_friend = (isBuddy() && compelxity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY); if (isSelf() || render_friend || mVisuallyMuteSetting == AV_ALWAYS_RENDER) { @@ -8488,7 +8488,7 @@ bool LLVOAvatar::isTooSlow() const static LLCachedControl compelxity_render_mode(gSavedSettings, "RenderAvatarComplexityMode"); static LLCachedControl friends_only(gSavedSettings, "RenderAvatarFriendsOnly", false); - bool is_friend = LLAvatarTracker::instance().isBuddy(getID()); + bool is_friend = isBuddy(); bool render_friend = is_friend && compelxity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY; if (render_friend || mVisuallyMuteSetting == AV_ALWAYS_RENDER) @@ -8545,7 +8545,7 @@ void LLVOAvatar::updateTooSlow() if(!mTooSlowWithoutShadows) // if we were not previously above the full impostor cap { bool always_render_friends = compelxity_render_mode > AV_RENDER_LIMIT_BY_COMPLEXITY; - bool render_friend_or_exception = (always_render_friends && LLAvatarTracker::instance().isBuddy( id ) ) || + bool render_friend_or_exception = (always_render_friends && isBuddy()) || ( getVisualMuteSettings() == LLVOAvatar::AV_ALWAYS_RENDER ); if( (!isSelf() || allowSelfImpostor) && !render_friend_or_exception) { @@ -11489,7 +11489,7 @@ void LLVOAvatar::calcMutedAVColor() new_color = LLColor4::grey4; change_msg = " not rendered: color is grey4"; } - else if (LLMuteList::getInstance()->isMuted(av_id)) // the user blocked them + else if (isInMuteList()) // the user blocked them { // blocked avatars are dark grey new_color = LLColor4::grey4; @@ -11738,6 +11738,20 @@ F32 LLVOAvatar::getAverageGPURenderTime() bool LLVOAvatar::isBuddy() const { - return LLAvatarTracker::instance().isBuddy(getID()); + bool is_friend = false; + F64 now = LLFrameTimer::getTotalSeconds(); + if (now < mCachedBuddyListUpdateTime) + { + is_friend = mCachedInBuddyList; + } + else + { + is_friend = LLAvatarTracker::instance().isBuddy(getID()); + + const F64 SECONDS_BETWEEN_BUDDY_UPDATES = 1; + mCachedBuddyListUpdateTime = now + SECONDS_BETWEEN_BUDDY_UPDATES; + mCachedInBuddyList = is_friend; + } + return is_friend; } diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 1ca8b81553..2144be1ba5 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -587,6 +587,8 @@ private: mutable bool mCachedInMuteList; mutable F64 mCachedMuteListUpdateTime; + mutable bool mCachedInBuddyList = false; + mutable F64 mCachedBuddyListUpdateTime = 0.0; VisualMuteSettings mVisuallyMuteSetting; // Always or never visually mute this AV -- cgit v1.2.3 From c3b678276dadb7aded8e8aeb3742524766f5ad8a Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 30 Jul 2024 18:57:46 +0300 Subject: viewer#2144 Correct unclear terminilogy in region's debug panel --- indra/newview/skins/default/xui/en/panel_region_debug.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/skins/default/xui/en/panel_region_debug.xml b/indra/newview/skins/default/xui/en/panel_region_debug.xml index 04a510d4e8..be8468a15c 100644 --- a/indra/newview/skins/default/xui/en/panel_region_debug.xml +++ b/indra/newview/skins/default/xui/en/panel_region_debug.xml @@ -140,7 +140,7 @@ layout="topleft" left_delta="0" name="return_other_land" - tool_tip="Return only objects which are on land belonging to someone else" + tool_tip="Return only objects which are on land that isn't owned by selected user" top_delta="20" width="80" /> Date: Wed, 31 Jul 2024 17:26:27 +0300 Subject: viewer#2153 Crash at LLViewerTextureList::updateImageDecodePriority Crash at getTextureEntry which calls getTE(mTEOffset) --- indra/newview/llviewertexturelist.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index d31c53d000..115934282f 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -948,7 +948,9 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag // shows one letter at a time // // Maximum usage examples: huge chunk of terrain repeats texture - const LLTextureEntry* te = face->getTextureEntry(); + S32 te_offset = face->getTEOffset(); // offset is -1 if not inited + LLViewerObject* objp = face->getViewerObject(); + const LLTextureEntry* te = (te_offset < 0 || te_offset >= objp->getNumTEs()) ? nullptr : objp->getTE(te_offset); F32 min_scale = te ? llmin(fabsf(te->getScaleS()), fabsf(te->getScaleT())) : 1.f; min_scale = llclamp(min_scale * min_scale, texture_scale_min(), texture_scale_max()); vsize /= min_scale; -- cgit v1.2.3 From 8f6e623a5fa7df3195da5ecd0ee32867185120c8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 1 Aug 2024 12:40:10 +0300 Subject: viewer#2163 Crash at getReflectionProbeIsDynamic --- indra/newview/llreflectionmap.cpp | 4 ++-- indra/newview/llviewerobject.h | 4 ++++ indra/newview/llvovolume.h | 8 ++++---- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 31fd6f3f07..8d164b6883 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -220,7 +220,7 @@ F32 LLReflectionMap::getNearClip() if (mViewerObject && mViewerObject->getVolume()) { - ret = ((LLVOVolume*)mViewerObject)->getReflectionProbeNearClip(); + ret = mViewerObject->getReflectionProbeNearClip(); } else if (mGroup) { @@ -240,7 +240,7 @@ bool LLReflectionMap::getIsDynamic() mViewerObject && mViewerObject->getVolume()) { - return ((LLVOVolume*)mViewerObject)->getReflectionProbeIsDynamic(); + return mViewerObject->getReflectionProbeIsDynamic(); } return false; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 09584d22a8..b6846c6716 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -266,7 +266,11 @@ public: virtual bool isRiggedMesh() const { return false; } virtual bool hasLightTexture() const { return false; } virtual bool isReflectionProbe() const { return false; } + virtual F32 getReflectionProbeAmbiance() const { return 0.f; } + virtual F32 getReflectionProbeNearClip() const { return 0.f; } virtual bool getReflectionProbeIsBox() const { return false; } + virtual bool getReflectionProbeIsDynamic() const { return false; }; + virtual bool getReflectionProbeIsMirror() const { return false; }; // This method returns true if the object is over land owned by // the agent, one of its groups, or it encroaches and diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 07e02e042c..6241bf42d6 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -304,11 +304,11 @@ public: bool setReflectionProbeIsMirror(bool is_mirror); bool isReflectionProbe() const override; - F32 getReflectionProbeAmbiance() const; - F32 getReflectionProbeNearClip() const; + F32 getReflectionProbeAmbiance() const override; + F32 getReflectionProbeNearClip() const override; bool getReflectionProbeIsBox() const override; - bool getReflectionProbeIsDynamic() const; - bool getReflectionProbeIsMirror() const; + bool getReflectionProbeIsDynamic() const override; + bool getReflectionProbeIsMirror() const override; // Flexible Objects U32 getVolumeInterfaceID() const; -- cgit v1.2.3 From 0723308c9c041533953b45fe62686e9f483ce360 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Wed, 31 Jul 2024 23:54:45 -0400 Subject: Fix emojipicker floater group buttons leaking and xui warning --- indra/newview/llfloateremojipicker.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/llfloateremojipicker.cpp b/indra/newview/llfloateremojipicker.cpp index 30f58aaeec..0830860633 100644 --- a/indra/newview/llfloateremojipicker.cpp +++ b/indra/newview/llfloateremojipicker.cpp @@ -429,6 +429,7 @@ void LLFloaterEmojiPicker::fillGroups() for (LLButton* button : mGroupButtons) { mGroups->removeChild(button); + button->die(); } mFilteredEmojiGroups.clear(); mFilteredEmojis.clear(); @@ -442,6 +443,7 @@ void LLFloaterEmojiPicker::fillGroups() rect.mBottom = mBadge->getRect().getHeight(); // Create button for "All categories" + params.name = "all_categories"; createGroupButton(params, rect, ALL_EMOJIS_IMAGE_INDEX); // Create group and button for "Recently used" and/or "Frequently used" @@ -455,6 +457,7 @@ void LLFloaterEmojiPicker::fillGroups() { mFilteredEmojiGroups.push_back(USED_EMOJIS_GROUP_INDEX); mFilteredEmojis.emplace_back(cats); + params.name = "used_categories"; createGroupButton(params, rect, USED_EMOJIS_IMAGE_INDEX); } } @@ -472,6 +475,7 @@ void LLFloaterEmojiPicker::fillGroups() { mFilteredEmojiGroups.push_back(i); mFilteredEmojis.emplace_back(cats); + params.name = "group_" + std::to_string(i); createGroupButton(params, rect, groups[i].Character); } } -- cgit v1.2.3 From 4217a778d68722735975f360c9be25655cf0e696 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Thu, 1 Aug 2024 00:38:58 -0400 Subject: Fix excessive wstring conversions during emojipicker draw --- indra/newview/llfloateremojipicker.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloateremojipicker.cpp b/indra/newview/llfloateremojipicker.cpp index 0830860633..50f71c9c0b 100644 --- a/indra/newview/llfloateremojipicker.cpp +++ b/indra/newview/llfloateremojipicker.cpp @@ -186,7 +186,7 @@ public: { mWStr = LLWString(1, emoji); mEmoji = emoji; - mTitle = title; + mTitle = utf8str_to_wstring(title); mBegin = begin; mEnd = end; } @@ -204,9 +204,9 @@ public: drawIcon(centerX, centerY - 1, iconWidth); static LLColor4 defaultColor(0.75f, 0.75f, 0.75f, 1.0f); - LLColor4 textColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", defaultColor); + static LLUIColor textColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", defaultColor); S32 max_pixels = clientWidth - iconWidth; - drawName((F32)iconWidth, centerY, max_pixels, textColor); + drawName((F32)iconWidth, centerY, max_pixels, textColor.get()); } protected: @@ -226,16 +226,16 @@ protected: max_pixels); // max_pixels } - void drawName(F32 x, F32 y, S32 max_pixels, LLColor4& color) + void drawName(F32 x, F32 y, S32 max_pixels, const LLColor4& color) { F32 x0 = x; F32 x1 = (F32)max_pixels; LLFontGL* font = LLFontGL::getFontEmojiLarge(); if (mBegin) { - std::string text = mTitle.substr(0, mBegin); - font->renderUTF8( - text, // text + LLWString text = mTitle.substr(0, mBegin); + font->render( + text.c_str(), // text 0, // begin_offset x0, // x y, // y @@ -246,14 +246,14 @@ protected: LLFontGL::DROP_SHADOW_SOFT, // shadow static_cast(text.size()), // max_chars (S32)x1); // max_pixels - F32 dx = font->getWidthF32(text); + F32 dx = font->getWidthF32(text.c_str()); x0 += dx; x1 -= dx; } if (x1 > 0 && mEnd > mBegin) { - std::string text = mTitle.substr(mBegin, mEnd - mBegin); - font->renderUTF8( + LLWString text = mTitle.substr(mBegin, mEnd - mBegin); + font->render( text, // text 0, // begin_offset x0, // x @@ -265,14 +265,14 @@ protected: LLFontGL::DROP_SHADOW_SOFT, // shadow static_cast(text.size()), // max_chars (S32)x1); // max_pixels - F32 dx = font->getWidthF32(text); + F32 dx = font->getWidthF32(text.c_str()); x0 += dx; x1 -= dx; } if (x1 > 0 && mEnd < mTitle.size()) { - std::string text = mEnd ? mTitle.substr(mEnd) : mTitle; - font->renderUTF8( + LLWString text = mEnd ? mTitle.substr(mEnd) : mTitle; + font->render( text, // text 0, // begin_offset x0, // x @@ -290,7 +290,7 @@ protected: private: llwchar mEmoji; LLWString mWStr; - std::string mTitle; + LLWString mTitle; size_t mBegin; size_t mEnd; }; -- cgit v1.2.3 From 212b1edd2d4d8ce570331ec6e8e4f87e4f162e34 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Thu, 1 Aug 2024 15:50:23 -0400 Subject: Fix trying to bind to non-existent texunit sampler during water draw (#2128) --- indra/newview/lldrawpoolwater.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 0d4eaab488..53d6e528b6 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -241,8 +241,6 @@ void LLDrawPoolWater::renderPostDeferred(S32 pass) F32 screenRes[] = { 1.f / gGLViewport[2], 1.f / gGLViewport[3] }; - S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP); - shader->uniform2fv(LLShaderMgr::DEFERRED_SCREEN_RES, 1, screenRes); shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); @@ -316,8 +314,6 @@ void LLDrawPoolWater::renderPostDeferred(S32 pass) water = static_cast(face->getViewerObject()); if (!water) continue; - gGL.getTexUnit(diffTex)->bind(face->getTexture()); - if ((bool)edge == (bool)water->getIsEdgePatch()) { face->renderIndexed(); @@ -334,7 +330,6 @@ void LLDrawPoolWater::renderPostDeferred(S32 pass) shader->disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); shader->disableTexture(LLShaderMgr::WATER_SCREENTEX); shader->disableTexture(LLShaderMgr::BUMP_MAP); - shader->disableTexture(LLShaderMgr::DIFFUSE_MAP); shader->disableTexture(LLShaderMgr::WATER_REFTEX); // clean up -- cgit v1.2.3 From 793f5ac3411882a53a49916f031090d1b6c72335 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 1 Aug 2024 19:55:16 +0300 Subject: Crash at LLViewerTexture::updateClass() --- indra/newview/llviewertexture.cpp | 4 ++-- indra/newview/llviewertexturelist.cpp | 4 ++-- indra/newview/llviewertexturelist.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 9648a9af18..8faa86876f 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -539,9 +539,9 @@ void LLViewerTexture::updateClass() LL_WARNS() << "Low system memory detected, emergency downrezzing off screen textures" << LL_ENDL; sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.5f); - for (auto image : gTextureList) + for (auto& image : gTextureList) { - gTextureList.updateImageDecodePriority(image); + gTextureList.updateImageDecodePriority(image, false /*will modify gTextureList otherwise!*/); } } diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 115934282f..865805f9bf 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -904,7 +904,7 @@ void LLViewerTextureList::clearFetchingRequests() extern bool gCubeSnapshot; -void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imagep) +void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imagep, bool flush_images) { if (imagep->isInDebug() || imagep->isUnremovable()) { @@ -993,7 +993,7 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag // Flush formatted images using a lazy flush // S32 num_refs = imagep->getNumRefs(); - if (num_refs == min_refs) + if (num_refs == min_refs && flush_images) { if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > lazy_flush_timeout) { diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index 075f6ae915..b614753b4f 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -148,7 +148,7 @@ public: // - updates decode priority // - updates desired discard level // - cleans up textures that haven't been referenced in awhile - void updateImageDecodePriority(LLViewerFetchedTexture* imagep); + void updateImageDecodePriority(LLViewerFetchedTexture* imagep, bool flush_images = true); private: F32 updateImagesCreateTextures(F32 max_time); -- cgit v1.2.3 From f08b3f2046e9f72369c36fe39e71ced5d1943e8c Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Fri, 2 Aug 2024 06:31:11 -0400 Subject: Update to libhunspell 1.7.2-r1 (#2175) --- indra/newview/CMakeLists.txt | 1 - indra/newview/viewer_manifest.py | 5 ----- 2 files changed, 6 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index a34354d287..4c5deb4974 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1729,7 +1729,6 @@ if (WINDOWS) ${CMAKE_SOURCE_DIR}/../etc/message.xml ${CMAKE_SOURCE_DIR}/../scripts/messages/message_template.msg ${SHARED_LIB_STAGING_DIR}/openjp2.dll - ${SHARED_LIB_STAGING_DIR}/libhunspell.dll ${SHARED_LIB_STAGING_DIR}/llwebrtc.dll #${SHARED_LIB_STAGING_DIR}/${LL_INTDIR}/SLVoice.exe #${SHARED_LIB_STAGING_DIR}/${LL_INTDIR}/libsndfile-1.dll diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index a25efc5de4..09397a0989 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -587,9 +587,6 @@ class Windows_x86_64_Manifest(ViewerManifest): # HTTP/2 self.path("nghttp2.dll") - # Hunspell - self.path("libhunspell.dll") - # BugSplat if self.args.get('bugsplat'): self.path("BsSndRpt64.exe") @@ -930,7 +927,6 @@ class Darwin_x86_64_Manifest(ViewerManifest): with self.prefix(src=relpkgdir, dst=""): self.path("libndofdev.dylib") - self.path("libhunspell-*.dylib") with self.prefix(src_dst="cursors_mac"): self.path("*.tif") @@ -1336,7 +1332,6 @@ class Linux_i686_Manifest(LinuxManifest): self.path("libdirectfb-1.4.so.5") self.path("libfusion-1.4.so.5") self.path("libdirect-1.4.so.5*") - self.path("libhunspell-1.3.so*") self.path("libalut.so*") self.path("libopenal.so*") self.path("libopenal.so", "libvivoxoal.so.1") # vivox's sdk expects this soname -- cgit v1.2.3 From a37590b45220cc21f038e715527c35e2b74b5a15 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 2 Aug 2024 14:33:22 +0300 Subject: viewer#853 Fix upload losing face data. Multiple faces can share same mMaterial --- indra/newview/llmeshrepository.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 4c5cc37766..349df11f35 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -2363,10 +2363,11 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures) // We want to be able to allow more than 8 materials... // - S32 end = llmin((S32)instance.mMaterial.size(), instance.mModel->getNumVolumeFaces()) ; + S32 end = llmin((S32)data.mBaseModel->mMaterialList.size(), instance.mModel->getNumVolumeFaces()) ; for (S32 face_num = 0; face_num < end; face_num++) { + // multiple faces can reuse the same material LLImportMaterial& material = instance.mMaterial[data.mBaseModel->mMaterialList[face_num]]; LLSD face_entry = LLSD::emptyMap(); -- cgit v1.2.3 From 593479f33cecd81148a861c93c3f889e1ee5dc20 Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Sat, 3 Aug 2024 00:24:41 +0200 Subject: Display parcel name when clicking on a parcel on the world map (#2131) --- indra/newview/llfloaterworldmap.cpp | 135 +++++++++++++++++++-- indra/newview/llfloaterworldmap.h | 29 ++++- indra/newview/llworldmap.h | 8 +- .../skins/default/xui/en/floater_world_map.xml | 3 + 4 files changed, 161 insertions(+), 14 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index 8d74a99539..fc2cfbcf2b 100755 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -261,6 +261,48 @@ void LLMapFriendObserver::changed(U32 mask) } } +LLWorldMapParcelInfoObserver::LLWorldMapParcelInfoObserver(const LLVector3d& pos_global) + : LLRemoteParcelInfoObserver(), + mPosGlobal(pos_global), + mParcelID(LLUUID::null) +{ } + +LLWorldMapParcelInfoObserver::~LLWorldMapParcelInfoObserver() +{ + if (mParcelID.notNull()) + { + LLRemoteParcelInfoProcessor::getInstance()->removeObserver(mParcelID, this); + } +} + +void LLWorldMapParcelInfoObserver::processParcelInfo(const LLParcelData& parcel_data) +{ + if (parcel_data.parcel_id == mParcelID) + { + LLRemoteParcelInfoProcessor::getInstance()->removeObserver(mParcelID, this); + + if (gFloaterWorldMap) + { + gFloaterWorldMap->processParcelInfo(parcel_data, mPosGlobal); + } + } +} + +// virtual +void LLWorldMapParcelInfoObserver::setParcelID(const LLUUID& parcel_id) +{ + mParcelID = parcel_id; + auto instance = LLRemoteParcelInfoProcessor::getInstance(); + instance->addObserver(mParcelID, this); + instance->sendParcelInfoRequest(mParcelID); +} + +// virtual +void LLWorldMapParcelInfoObserver::setErrorStatus(S32 status, const std::string& reason) +{ + LL_WARNS("LLWorldMapParcelInfoObserver") << "Can't handle remote parcel request." << " Http Status: " << status << ". Reason : " << reason << LL_ENDL; +} + //--------------------------------------------------------------------------- // Statics //--------------------------------------------------------------------------- @@ -275,23 +317,25 @@ const LLUUID LLFloaterWorldMap::sHomeID( "10000000-0000-0000-0000-000000000001" LLFloaterWorldMap::LLFloaterWorldMap(const LLSD& key) : LLFloater(key), - mInventory(NULL), - mInventoryObserver(NULL), - mFriendObserver(NULL), + mInventory(nullptr), + mInventoryObserver(nullptr), + mFriendObserver(nullptr), mCompletingRegionName(), mCompletingRegionPos(), mWaitingForTracker(false), mIsClosing(false), mSetToUserPosition(true), - mTrackedLocation(0,0,0), + mTrackedLocation(0.0,0.0,0.0), mTrackedStatus(LLTracker::TRACKING_NOTHING), - mListFriendCombo(NULL), - mListLandmarkCombo(NULL), - mListSearchResults(NULL) + mListFriendCombo(nullptr), + mListLandmarkCombo(nullptr), + mListSearchResults(nullptr), + mParcelInfoObserver(nullptr), + mShowParcelInfo(false) { gFloaterWorldMap = this; - mFactoryMap["objects_mapview"] = LLCallbackMap(createWorldMapView, NULL); + mFactoryMap["objects_mapview"] = LLCallbackMap(createWorldMapView, nullptr); mCommitCallbackRegistrar.add("WMap.Coordinates", boost::bind(&LLFloaterWorldMap::onCoordinatesCommit, this)); mCommitCallbackRegistrar.add("WMap.Location", boost::bind(&LLFloaterWorldMap::onLocationCommit, this)); @@ -374,6 +418,11 @@ bool LLFloaterWorldMap::postBuild() // virtual LLFloaterWorldMap::~LLFloaterWorldMap() { + if (mParcelInfoObserver) + { + delete mParcelInfoObserver; + } + // All cleaned up by LLView destructor mMapView = NULL; @@ -584,9 +633,73 @@ void LLFloaterWorldMap::draw() // Internal utility functions //------------------------------------------------------------------------- +void LLFloaterWorldMap::processParcelInfo(const LLParcelData& parcel_data, const LLVector3d& pos_global) const +{ + LLVector3d tracker_pos = LLTracker::getTrackedPositionGlobal(); + if (!mShowParcelInfo || + (tracker_pos.mdV[VX] != pos_global.mdV[VX] && tracker_pos.mdV[VY] != pos_global.mdV[VY]) || + LLTracker::getTrackedLocationType() != LLTracker::LOCATION_NOTHING || + LLTracker::getTrackingStatus() != LLTracker::TRACKING_LOCATION) + { + return; + } + + LLSimInfo* sim_info = LLWorldMap::getInstance()->simInfoFromPosGlobal(pos_global); + if (!sim_info) + { + return; + } + + std::string sim_name = sim_info->getName(); + U32 locX, locY; + from_region_handle(sim_info->getHandle(), &locX, &locY); + F32 region_x = (F32)(pos_global.mdV[VX] - locX); + F32 region_y = (F32)(pos_global.mdV[VY] - locY); + std::string full_name = llformat("%s (%d, %d, %d)", + sim_name.c_str(), + ll_round(region_x), + ll_round(region_y), + ll_round((F32)pos_global.mdV[VZ])); + + LLTracker::trackLocation(pos_global, parcel_data.name.empty() ? getString("UnnamedParcel") : parcel_data.name, full_name); +} + +void LLFloaterWorldMap::requestParcelInfo(const LLVector3d& pos_global, const LLVector3d& region_origin) +{ + if (pos_global == mRequestedGlobalPos) + { + return; + } + + LLViewerRegion* region = gAgent.getRegion(); + if (!region) + { + return; + } + + if (std::string url = region->getCapability("RemoteParcelRequest"); !url.empty()) + { + mRequestedGlobalPos = pos_global; + if (mParcelInfoObserver) + { + delete mParcelInfoObserver; + } + mParcelInfoObserver = new LLWorldMapParcelInfoObserver(pos_global); + + auto pos_region = LLVector3(pos_global - region_origin); + LLRemoteParcelInfoProcessor::instance().requestRegionParcelInfo(url, + region->getRegionID(), pos_region, pos_global, + mParcelInfoObserver->getObserverHandle()); + } + else + { + LL_WARNS() << "Cannot request parcel details: Cap not found" << LL_ENDL; + } +} void LLFloaterWorldMap::trackAvatar( const LLUUID& avatar_id, const std::string& name ) { + mShowParcelInfo = false; LLCtrlSelectionInterface *iface = childGetSelectionInterface("friend combo"); if (!iface) return; @@ -617,6 +730,7 @@ void LLFloaterWorldMap::trackAvatar( const LLUUID& avatar_id, const std::string& void LLFloaterWorldMap::trackLandmark( const LLUUID& landmark_item_id ) { + mShowParcelInfo = false; LLCtrlSelectionInterface *iface = childGetSelectionInterface("landmark combo"); if (!iface) return; @@ -662,6 +776,7 @@ void LLFloaterWorldMap::trackLandmark( const LLUUID& landmark_item_id ) void LLFloaterWorldMap::trackEvent(const LLItemInfo &event_info) { + mShowParcelInfo = false; mTrackedStatus = LLTracker::TRACKING_LOCATION; LLTracker::trackLocation(event_info.getGlobalPosition(), event_info.getName(), event_info.getToolTip(), LLTracker::LOCATION_EVENT); setDefaultBtn("Teleport"); @@ -669,6 +784,7 @@ void LLFloaterWorldMap::trackEvent(const LLItemInfo &event_info) void LLFloaterWorldMap::trackGenericItem(const LLItemInfo &item) { + mShowParcelInfo = false; mTrackedStatus = LLTracker::TRACKING_LOCATION; LLTracker::trackLocation(item.getGlobalPosition(), item.getName(), item.getToolTip(), LLTracker::LOCATION_ITEM); setDefaultBtn("Teleport"); @@ -721,6 +837,9 @@ void LLFloaterWorldMap::trackLocation(const LLVector3d& pos_global) LLWorldMap::getInstance()->cancelTracking(); // The floater is taking over the tracking LLTracker::trackLocation(pos_global, full_name, tooltip); + mShowParcelInfo = true; + requestParcelInfo(pos_global, sim_info->getGlobalOrigin()); + LLVector3d coord_pos = LLTracker::getTrackedPositionGlobal(); updateTeleportCoordsDisplay( coord_pos ); diff --git a/indra/newview/llfloaterworldmap.h b/indra/newview/llfloaterworldmap.h index a99100f5bd..2f2b2b7a0d 100644 --- a/indra/newview/llfloaterworldmap.h +++ b/indra/newview/llfloaterworldmap.h @@ -34,8 +34,9 @@ #include "llfloater.h" #include "llmapimagetype.h" -#include "lltracker.h" +#include "llremoteparcelrequest.h" #include "llslurl.h" +#include "lltracker.h" class LLCtrlListInterface; class LLFriendObserver; @@ -51,6 +52,21 @@ class LLSliderCtrl; class LLSpinCtrl; class LLSearchEditor; +class LLWorldMapParcelInfoObserver : public LLRemoteParcelInfoObserver +{ +public: + LLWorldMapParcelInfoObserver(const LLVector3d& pos_global); + ~LLWorldMapParcelInfoObserver(); + + void processParcelInfo(const LLParcelData& parcel_data); + void setParcelID(const LLUUID& parcel_id); + void setErrorStatus(S32 status, const std::string& reason); + +protected: + LLVector3d mPosGlobal; + LLUUID mParcelID; +}; + class LLFloaterWorldMap : public LLFloater { public: @@ -119,6 +135,8 @@ public: //Slapp instigated avatar tracking void avatarTrackFromSlapp( const LLUUID& id ); + void processParcelInfo(const LLParcelData& parcel_data, const LLVector3d& pos_global) const; + protected: void onGoHome(); @@ -169,8 +187,13 @@ private: // enable/disable teleport destination coordinates void enableTeleportCoordsDisplay( bool enabled ); - std::vector mLandmarkAssetIDList; - std::vector mLandmarkItemIDList; + void requestParcelInfo(const LLVector3d& pos_global, const LLVector3d& region_origin); + LLVector3d mRequestedGlobalPos; + bool mShowParcelInfo; + LLWorldMapParcelInfoObserver* mParcelInfoObserver; + + uuid_vec_t mLandmarkAssetIDList; + uuid_vec_t mLandmarkItemIDList; static const LLUUID sHomeID; diff --git a/indra/newview/llworldmap.h b/indra/newview/llworldmap.h index fb9d140851..aab19a4d5f 100644 --- a/indra/newview/llworldmap.h +++ b/indra/newview/llworldmap.h @@ -128,9 +128,9 @@ public: LLPointer getLandForSaleImage(); // Get the overlay image, fetch it if necessary bool isName(const std::string& name) const; - bool isDown() { return (mAccess == SIM_ACCESS_DOWN); } - bool isPG() { return (mAccess <= SIM_ACCESS_PG); } - bool isAdult() { return (mAccess == SIM_ACCESS_ADULT); } + bool isDown() const { return (mAccess == SIM_ACCESS_DOWN); } + bool isPG() const { return (mAccess <= SIM_ACCESS_PG); } + bool isAdult() const { return (mAccess == SIM_ACCESS_ADULT); } // Debug only void dump() const; // Print the region info to the standard output @@ -157,6 +157,8 @@ public: const LLSimInfo::item_info_list_t& getLandForSaleAdult() const { return mLandForSaleAdult; } const LLSimInfo::item_info_list_t& getAgentLocation() const { return mAgentLocations; } + const U64& getHandle() const { return mHandle; } + private: U64 mHandle; // This is a hash of the X and Y world coordinates of the SW corner of the sim std::string mName; // Region name diff --git a/indra/newview/skins/default/xui/en/floater_world_map.xml b/indra/newview/skins/default/xui/en/floater_world_map.xml index 7efa81d263..b0b818cde5 100644 --- a/indra/newview/skins/default/xui/en/floater_world_map.xml +++ b/indra/newview/skins/default/xui/en/floater_world_map.xml @@ -14,6 +14,9 @@ single_instance="true" title="WORLD MAP" width="650"> + + (Unnamed Parcel) + -- cgit v1.2.3 From adf2d91fb9032ab70b61269d49bacec6aac22ab1 Mon Sep 17 00:00:00 2001 From: TommyTheTerrible <81168766+TommyTheTerrible@users.noreply.github.com> Date: Sun, 4 Aug 2024 19:58:54 -0400 Subject: Reduce Avatar Loading Checks (#2187) This simple trick stops checking if the avatar is loaded if the avatar is loaded, decreasing calculation times and increasing FPS. --- indra/newview/llvoavatar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 8581a96c06..83df39d606 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -3145,7 +3145,7 @@ void LLVOAvatar::idleUpdateLipSync(bool voice_enabled) void LLVOAvatar::idleUpdateLoadingEffect() { // update visibility when avatar is partially loaded - if (updateIsFullyLoaded()) // changed? + if (!mFullyLoaded && updateIsFullyLoaded()) // Avoid repeat calculations by checking if mFullyLoaded is true first. { if (isFullyLoaded()) { -- cgit v1.2.3 From 874794ea584588457dfde7ef17c447e2a0eb46bb Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sun, 4 Aug 2024 21:00:10 -0400 Subject: Add LLUIColorTable debug-settings-like floater for easing skin design --- indra/newview/CMakeLists.txt | 2 + indra/newview/app_settings/settings.xml | 11 + indra/newview/llfloatersettingscolor.cpp | 334 +++++++++++++++++++++ indra/newview/llfloatersettingscolor.h | 81 +++++ indra/newview/llmanip.cpp | 6 +- indra/newview/llselectmgr.cpp | 25 +- indra/newview/llselectmgr.h | 13 +- indra/newview/llviewerfloaterreg.cpp | 2 + .../default/xui/en/floater_settings_color.xml | 117 ++++++++ indra/newview/skins/default/xui/en/menu_login.xml | 7 + indra/newview/skins/default/xui/en/menu_viewer.xml | 7 + 11 files changed, 583 insertions(+), 22 deletions(-) create mode 100644 indra/newview/llfloatersettingscolor.cpp create mode 100644 indra/newview/llfloatersettingscolor.h create mode 100644 indra/newview/skins/default/xui/en/floater_settings_color.xml (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 4c5deb4974..8df9c41219 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -286,6 +286,7 @@ set(viewer_SOURCE_FILES llfloaterscriptlimits.cpp llfloatersearch.cpp llfloatersellland.cpp + llfloatersettingscolor.cpp llfloatersettingsdebug.cpp llfloatersidepanelcontainer.cpp llfloatersnapshot.cpp @@ -954,6 +955,7 @@ set(viewer_HEADER_FILES llfloaterscriptlimits.h llfloatersearch.h llfloatersellland.h + llfloatersettingscolor.h llfloatersettingsdebug.h llfloatersidepanelcontainer.h llfloatersnapshot.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 9e5d3f09bd..eb053ebaa0 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -15773,6 +15773,17 @@ Value 0 + ColorSettingsHideDefault + + Comment + Show non-default settings only in Color Settings list + Persist + 0 + Type + Boolean + Value + 0 + DebugSettingsHideDefault Comment diff --git a/indra/newview/llfloatersettingscolor.cpp b/indra/newview/llfloatersettingscolor.cpp new file mode 100644 index 0000000000..d9c382a1dc --- /dev/null +++ b/indra/newview/llfloatersettingscolor.cpp @@ -0,0 +1,334 @@ +/** +* @file llfloatersettingscolor.cpp +* @brief Implementation of LLFloaterSettingsColor +* @author Rye Cogtail +* +* $LicenseInfo:firstyear=2024&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2024, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "llfloatersettingscolor.h" + +#include "llfloater.h" +#include "llfiltereditor.h" +#include "lluictrlfactory.h" +#include "llcombobox.h" +#include "llspinctrl.h" +#include "llcolorswatch.h" +#include "llviewercontrol.h" +#include "lltexteditor.h" + + +LLFloaterSettingsColor::LLFloaterSettingsColor(const LLSD& key) +: LLFloater(key), + mSettingList(NULL) +{ + mCommitCallbackRegistrar.add("CommitSettings", boost::bind(&LLFloaterSettingsColor::onCommitSettings, this)); + mCommitCallbackRegistrar.add("ClickDefault", boost::bind(&LLFloaterSettingsColor::onClickDefault, this)); +} + +LLFloaterSettingsColor::~LLFloaterSettingsColor() +{} + +bool LLFloaterSettingsColor::postBuild() +{ + enableResizeCtrls(true, false, true); + + mAlphaSpinner = getChild("alpha_spinner"); + mColorSwatch = getChild("color_swatch"); + + mDefaultButton = getChild("default_btn"); + mSettingNameText = getChild("color_name_txt"); + + getChild("filter_input")->setCommitCallback(boost::bind(&LLFloaterSettingsColor::setSearchFilter, this, _2)); + + mSettingList = getChild("setting_list"); + mSettingList->setCommitOnSelectionChange(true); + mSettingList->setCommitCallback(boost::bind(&LLFloaterSettingsColor::onSettingSelect, this)); + + updateList(); + + gSavedSettings.getControl("ColorSettingsHideDefault")->getCommitSignal()->connect(boost::bind(&LLFloaterSettingsColor::updateList, this, false)); + + return LLFloater::postBuild(); +} + +void LLFloaterSettingsColor::draw() +{ + LLScrollListItem* first_selected = mSettingList->getFirstSelected(); + if (first_selected) + { + if(auto cell = first_selected->getColumn(1)) + { + updateControl(cell->getValue().asString()); + } + } + + LLFloater::draw(); +} + +void LLFloaterSettingsColor::onCommitSettings() +{ + LLScrollListItem* first_selected = mSettingList->getFirstSelected(); + if (!first_selected) + { + return; + } + auto cell = first_selected->getColumn(1); + + if (!cell) + { + return; + } + + auto color_name = cell->getValue().asString(); + if (color_name.empty()) + { + return; + } + + LLColor4 col4; + LLColor3 col3; + col3.setValue(mColorSwatch->getValue()); + col4 = LLColor4(col3, (F32)mAlphaSpinner->getValue().asReal()); + LLUIColorTable::instance().setColor(color_name, col4); + + updateDefaultColumn(color_name); +} + +// static +void LLFloaterSettingsColor::onClickDefault() +{ + LLScrollListItem* first_selected = mSettingList->getFirstSelected(); + if (first_selected) + { + auto cell = first_selected->getColumn(1); + if (cell) + { + auto name = cell->getValue().asString(); + LLUIColorTable::instance().resetToDefault(name); + updateDefaultColumn(name); + updateControl(name); + } + } +} + +// we've switched controls, or doing per-frame update, so update spinners, etc. +void LLFloaterSettingsColor::updateControl(const std::string& color_name) +{ + hideUIControls(); + + if (!isSettingHidden(color_name)) + { + mDefaultButton->setVisible(true); + mSettingNameText->setVisible(true); + mSettingNameText->setText(color_name); + mSettingNameText->setToolTip(color_name); + + LLColor4 clr = LLUIColorTable::instance().getColor(color_name); + mColorSwatch->setVisible(true); + // only set if changed so color picker doesn't update + if (clr != LLColor4(mColorSwatch->getValue())) + { + mColorSwatch->setOriginal(clr); + } + mAlphaSpinner->setVisible(true); + mAlphaSpinner->setLabel(std::string("Alpha")); + if (!mAlphaSpinner->hasFocus()) + { + mAlphaSpinner->setPrecision(3); + mAlphaSpinner->setMinValue(0.0); + mAlphaSpinner->setMaxValue(1.f); + mAlphaSpinner->setValue(clr.mV[VALPHA]); + } + } + +} + +void LLFloaterSettingsColor::updateList(bool skip_selection) +{ + std::string last_selected; + LLScrollListItem* item = mSettingList->getFirstSelected(); + if (item) + { + LLScrollListCell* cell = item->getColumn(1); + if (cell) + { + last_selected = cell->getValue().asString(); + } + } + + mSettingList->deleteAllItems(); + + const auto& base_colors = LLUIColorTable::instance().getLoadedColors(); + for (const auto& pair : base_colors) + { + const auto& name = pair.first; + if (matchesSearchFilter(name) && !isSettingHidden(name)) + { + LLSD row; + + row["columns"][0]["column"] = "changed_color"; + row["columns"][0]["value"] = LLUIColorTable::instance().isDefault(name) ? "" : "*"; + + row["columns"][1]["column"] = "color"; + row["columns"][1]["value"] = name; + + LLScrollListItem* item = mSettingList->addElement(row, ADD_BOTTOM, nullptr); + if (!mSearchFilter.empty() && (last_selected == name) && !skip_selection) + { + std::string lower_name(name); + LLStringUtil::toLower(lower_name); + if (LLStringUtil::startsWith(lower_name, mSearchFilter)) + { + item->setSelected(true); + } + } + } + } + + for (const auto& pair : LLUIColorTable::instance().getUserColors()) + { + const auto& name = pair.first; + if (base_colors.find(name) == base_colors.end() && matchesSearchFilter(name) && !isSettingHidden(name)) + { + LLSD row; + + row["columns"][0]["column"] = "changed_color"; + row["columns"][0]["value"] = LLUIColorTable::instance().isDefault(name) ? "" : "*"; + + row["columns"][1]["column"] = "color"; + row["columns"][1]["value"] = name; + + LLScrollListItem* item = mSettingList->addElement(row, ADD_BOTTOM, nullptr); + if (!mSearchFilter.empty() && (last_selected == name) && !skip_selection) + { + std::string lower_name(name); + LLStringUtil::toLower(lower_name); + if (LLStringUtil::startsWith(lower_name, mSearchFilter)) + { + item->setSelected(true); + } + } + } + } + + mSettingList->updateSort(); + + if (!mSettingList->isEmpty()) + { + if (mSettingList->hasSelectedItem()) + { + mSettingList->scrollToShowSelected(); + } + else if (!mSettingList->hasSelectedItem() && !mSearchFilter.empty() && !skip_selection) + { + if (!mSettingList->selectItemByPrefix(mSearchFilter, false, 1)) + { + mSettingList->selectFirstItem(); + } + mSettingList->scrollToShowSelected(); + } + } + else + { + LLSD row; + + row["columns"][0]["column"] = "changed_color"; + row["columns"][0]["value"] = ""; + row["columns"][1]["column"] = "color"; + row["columns"][1]["value"] = "No matching colors."; + + mSettingList->addElement(row); + hideUIControls(); + } +} + +void LLFloaterSettingsColor::onSettingSelect() +{ + LLScrollListItem* first_selected = mSettingList->getFirstSelected(); + if (first_selected) + { + auto cell = first_selected->getColumn(1); + if (cell) + { + updateControl(cell->getValue().asString()); + } + } +} + +void LLFloaterSettingsColor::setSearchFilter(const std::string& filter) +{ + if(mSearchFilter == filter) + return; + mSearchFilter = filter; + LLStringUtil::toLower(mSearchFilter); + updateList(); +} + +bool LLFloaterSettingsColor::matchesSearchFilter(std::string setting_name) +{ + // If the search filter is empty, everything passes. + if (mSearchFilter.empty()) return true; + + LLStringUtil::toLower(setting_name); + std::string::size_type match_name = setting_name.find(mSearchFilter); + + return (std::string::npos != match_name); +} + +bool LLFloaterSettingsColor::isSettingHidden(const std::string& color_name) +{ + static LLCachedControl hide_default(gSavedSettings, "ColorSettingsHideDefault", false); + return hide_default && LLUIColorTable::instance().isDefault(color_name); +} + +void LLFloaterSettingsColor::updateDefaultColumn(const std::string& color_name) +{ + if (isSettingHidden(color_name)) + { + hideUIControls(); + updateList(true); + return; + } + + LLScrollListItem* item = mSettingList->getFirstSelected(); + if (item) + { + LLScrollListCell* cell = item->getColumn(0); + if (cell) + { + std::string is_default = LLUIColorTable::instance().isDefault(color_name) ? "" : "*"; + cell->setValue(is_default); + } + } +} + +void LLFloaterSettingsColor::hideUIControls() +{ + mColorSwatch->setVisible(false); + mAlphaSpinner->setVisible(false); + mDefaultButton->setVisible(false); + mSettingNameText->setVisible(false); +} + diff --git a/indra/newview/llfloatersettingscolor.h b/indra/newview/llfloatersettingscolor.h new file mode 100644 index 0000000000..42eb85cd60 --- /dev/null +++ b/indra/newview/llfloatersettingscolor.h @@ -0,0 +1,81 @@ +/** +* @file llfloatersettingscolor.h +* @brief Header file for LLFloaterSettingsColor +* @author Rye Cogtail +* +* $LicenseInfo:firstyear=2024&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2024, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#ifndef LLFLOATERCOLORSETTINGS_H +#define LLFLOATERCOLORSETTINGS_H + +#include "llcontrol.h" +#include "llfloater.h" + +class LLColorSwatchCtrl; +class LLScrollListCtrl; +class LLSpinCtrl; +class LLTextBox; + +class LLFloaterSettingsColor final +: public LLFloater +{ + friend class LLFloaterReg; + +public: + + bool postBuild() override; + void draw() override; + + void updateControl(const std::string& color_name); + + void onCommitSettings(); + void onClickDefault(); + + bool matchesSearchFilter(std::string setting_name); + bool isSettingHidden(const std::string& color_name); + +private: + LLFloaterSettingsColor(const LLSD& key); + virtual ~LLFloaterSettingsColor(); + + void updateList(bool skip_selection = false); + void onSettingSelect(); + void setSearchFilter(const std::string& filter); + + void updateDefaultColumn(const std::string& color_name); + void hideUIControls(); + + LLScrollListCtrl* mSettingList; + +protected: + LLUICtrl* mDefaultButton = nullptr; + LLTextBox* mSettingNameText = nullptr; + + LLSpinCtrl* mAlphaSpinner = nullptr; + LLColorSwatchCtrl* mColorSwatch = nullptr; + + std::string mSearchFilter; +}; + +#endif //LLFLOATERCOLORSETTINGS_H + diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp index 0c82db1011..0d617753c8 100644 --- a/indra/newview/llmanip.cpp +++ b/indra/newview/llmanip.cpp @@ -594,9 +594,9 @@ void LLManip::renderTickValue(const LLVector3& pos, F32 value, const std::string LLColor4 LLManip::setupSnapGuideRenderPass(S32 pass) { - static LLColor4 grid_color_fg = LLUIColorTable::instance().getColor("GridlineColor"); - static LLColor4 grid_color_bg = LLUIColorTable::instance().getColor("GridlineBGColor"); - static LLColor4 grid_color_shadow = LLUIColorTable::instance().getColor("GridlineShadowColor"); + static LLUIColor grid_color_fg = LLUIColorTable::instance().getColor("GridlineColor"); + static LLUIColor grid_color_bg = LLUIColorTable::instance().getColor("GridlineBGColor"); + static LLUIColor grid_color_shadow = LLUIColorTable::instance().getColor("GridlineShadowColor"); LLColor4 line_color; F32 line_alpha = gSavedSettings.getF32("GridOpacity"); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index fcd1c84ba4..342048252f 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -128,12 +128,12 @@ F32 LLSelectMgr::sHighlightAlpha = 0.f; F32 LLSelectMgr::sHighlightAlphaTest = 0.f; F32 LLSelectMgr::sHighlightUAnim = 0.f; F32 LLSelectMgr::sHighlightVAnim = 0.f; -LLColor4 LLSelectMgr::sSilhouetteParentColor; -LLColor4 LLSelectMgr::sSilhouetteChildColor; -LLColor4 LLSelectMgr::sHighlightInspectColor; -LLColor4 LLSelectMgr::sHighlightParentColor; -LLColor4 LLSelectMgr::sHighlightChildColor; -LLColor4 LLSelectMgr::sContextSilhouetteColor; +LLUIColor LLSelectMgr::sSilhouetteParentColor; +LLUIColor LLSelectMgr::sSilhouetteChildColor; +LLUIColor LLSelectMgr::sHighlightInspectColor; +LLUIColor LLSelectMgr::sHighlightParentColor; +LLUIColor LLSelectMgr::sHighlightChildColor; +LLUIColor LLSelectMgr::sContextSilhouetteColor; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // struct LLDeRezInfo @@ -6437,8 +6437,10 @@ void LLSelectMgr::renderSilhouettes(bool for_hud) bool wireframe_selection = (gFloaterTools && gFloaterTools->getVisible()) || LLSelectMgr::sRenderHiddenSelections; F32 fogCfx = (F32)llclamp((LLSelectMgr::getInstance()->getSelectionCenterGlobal() - gAgentCamera.getCameraPositionGlobal()).magVec() / (LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal().magVec() * 4), 0.0, 1.0); - static LLColor4 sParentColor = LLColor4(sSilhouetteParentColor[VRED], sSilhouetteParentColor[VGREEN], sSilhouetteParentColor[VBLUE], LLSelectMgr::sHighlightAlpha); - static LLColor4 sChildColor = LLColor4(sSilhouetteChildColor[VRED], sSilhouetteChildColor[VGREEN], sSilhouetteChildColor[VBLUE], LLSelectMgr::sHighlightAlpha); + LLColor4 sParentColor = sSilhouetteParentColor; + sParentColor.mV[VALPHA] = LLSelectMgr::sHighlightAlpha; + LLColor4 sChildColor = sSilhouetteChildColor; + sChildColor.mV[VALPHA] = LLSelectMgr::sHighlightAlpha; auto renderMeshSelection_f = [fogCfx, wireframe_selection](LLSelectNode* node, LLViewerObject* objectp, LLColor4 hlColor) { @@ -8006,12 +8008,9 @@ S32 LLObjectSelection::getSelectedObjectRenderCost() cost += object->getRenderCost(textures); computed_objects.insert(object->getID()); - const_child_list_t children = object->getChildren(); - for (const_child_list_t::const_iterator child_iter = children.begin(); - child_iter != children.end(); - ++child_iter) + const const_child_list_t& children = object->getChildren(); + for (LLViewerObject* child_obj : children) { - LLViewerObject* child_obj = *child_iter; LLVOVolume *child = dynamic_cast( child_obj ); if (child) { diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 355e28595b..2764b0179c 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -44,6 +44,7 @@ #include "llcontrol.h" #include "llviewerobject.h" // LLObjectSelection::getSelectedTEValue template #include "llmaterial.h" +#include "lluicolor.h" #include #include @@ -450,12 +451,12 @@ public: static F32 sHighlightAlphaTest; static F32 sHighlightUAnim; static F32 sHighlightVAnim; - static LLColor4 sSilhouetteParentColor; - static LLColor4 sSilhouetteChildColor; - static LLColor4 sHighlightParentColor; - static LLColor4 sHighlightChildColor; - static LLColor4 sHighlightInspectColor; - static LLColor4 sContextSilhouetteColor; + static LLUIColor sSilhouetteParentColor; + static LLUIColor sSilhouetteChildColor; + static LLUIColor sHighlightParentColor; + static LLUIColor sHighlightChildColor; + static LLUIColor sHighlightInspectColor; + static LLUIColor sContextSilhouetteColor; LLCachedControl mHideSelectedObjects; LLCachedControl mRenderHighlightSelections; diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index c97a512a57..9bdd246129 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -134,6 +134,7 @@ #include "llfloaterscriptlimits.h" #include "llfloatersearch.h" #include "llfloatersellland.h" +#include "llfloatersettingscolor.h" #include "llfloatersettingsdebug.h" #include "llfloatersidepanelcontainer.h" #include "llfloatersnapshot.h" @@ -486,6 +487,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("script_limits", "floater_script_limits.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("my_scripts", "floater_my_scripts.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("sell_land", "floater_sell_land.xml", &LLFloaterSellLand::buildFloater); + LLFloaterReg::add("settings_color", "floater_settings_color.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("settings_debug", "floater_settings_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("sound_devices", "floater_sound_devices.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("stats", "floater_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/skins/default/xui/en/floater_settings_color.xml b/indra/newview/skins/default/xui/en/floater_settings_color.xml new file mode 100644 index 0000000000..0722677f1d --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_settings_color.xml @@ -0,0 +1,117 @@ + + + + + + + + + Color name + + + + + + + + + + + \ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/menu_login.xml b/indra/newview/skins/default/xui/en/menu_login.xml index a71cbde21b..1d1b81e31a 100644 --- a/indra/newview/skins/default/xui/en/menu_login.xml +++ b/indra/newview/skins/default/xui/en/menu_login.xml @@ -149,6 +149,13 @@ function="Advanced.ShowDebugSettings" parameter="all" /> + + + + + + -- cgit v1.2.3 From c4e921828a41c0e759ee103c6cfdb2cc40c1a581 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sat, 3 Aug 2024 10:10:17 -0400 Subject: Optimization and cleanup of various color finds during draw --- indra/newview/llchathistory.cpp | 14 +++++------ indra/newview/llconversationview.cpp | 11 +++++---- indra/newview/llfloateremojipicker.cpp | 6 ++--- indra/newview/llhudnametag.cpp | 9 ++++--- indra/newview/llhudtext.cpp | 6 +++-- indra/newview/llinventorygallery.cpp | 6 +++-- indra/newview/llscripteditor.cpp | 2 +- indra/newview/llspeakers.cpp | 4 +-- indra/newview/lltoolbarview.cpp | 2 +- indra/newview/llviewermenu.cpp | 6 ++--- indra/newview/llviewerobjectlist.cpp | 24 +++++++++--------- indra/newview/llviewerparceloverlay.cpp | 43 ++++++++++++++++++++++++--------- indra/newview/llviewerparceloverlay.h | 9 +++++++ indra/newview/llviewertexteditor.cpp | 12 +++------ indra/newview/llvoavatar.cpp | 4 ++- 15 files changed, 92 insertions(+), 66 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 2b02aabc31..8eba9aee37 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -693,7 +693,7 @@ public: mNeedsTimeBox = false; user_name->setValue(mFrom); updateMinUserNameWidth(); - LLColor4 sep_color = LLUIColorTable::instance().getColor("ChatTeleportSeparatorColor"); + LLUIColor sep_color = LLUIColorTable::instance().getColor("ChatTeleportSeparatorColor"); setTransparentColor(sep_color); mTimeBoxTextBox->setVisible(false); } @@ -739,7 +739,7 @@ public: std::string username = chat.mFromName.substr(username_start + 2); username = username.substr(0, username.length() - 1); LLStyle::Params style_params_name; - LLColor4 userNameColor = LLUIColorTable::instance().getColor("EmphasisColor"); + LLUIColor userNameColor = LLUIColorTable::instance().getColor("EmphasisColor"); style_params_name.color(userNameColor); style_params_name.font.name("SansSerifSmall"); style_params_name.font.style("NORMAL"); @@ -1037,7 +1037,7 @@ private: !av_name.isDisplayNameDefault()) { LLStyle::Params style_params_name; - LLColor4 userNameColor = LLUIColorTable::instance().getColor("EmphasisColor"); + LLUIColor userNameColor = LLUIColorTable::instance().getColor("EmphasisColor"); style_params_name.color(userNameColor); style_params_name.font.name("SansSerifSmall"); style_params_name.font.style("NORMAL"); @@ -1239,8 +1239,8 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL mMoreChatPanel->reshape(mMoreChatPanel->getRect().getWidth(), height); } - LLColor4 txt_color = LLUIColorTable::instance().getColor("White"); - LLColor4 name_color(txt_color); + LLUIColor txt_color = LLUIColorTable::instance().getColor("White"); + LLUIColor name_color(txt_color); LLViewerChat::getChatColor(chat,txt_color); LLFontGL* fontp = LLViewerChat::getChatFont(); @@ -1317,7 +1317,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL { if (!message_from_log) { - LLColor4 timestamp_color = LLUIColorTable::instance().getColor("ChatTimestampColor"); + LLUIColor timestamp_color = LLUIColorTable::instance().getColor("ChatTimestampColor"); timestamp_style.color(timestamp_color); timestamp_style.readonly_color(timestamp_color); } @@ -1344,7 +1344,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL // set the link for the object name to be the objectim SLapp // (don't let object names with hyperlinks override our objectim Url) LLStyle::Params link_params(body_message_params); - LLColor4 link_color = LLUIColorTable::instance().getColor("HTMLLinkColor"); + LLUIColor link_color = LLUIColorTable::instance().getColor("HTMLLinkColor"); link_params.color = link_color; link_params.readonly_color = link_color; link_params.is_link = true; diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp index eac1ee2a3c..72d08428d3 100644 --- a/indra/newview/llconversationview.cpp +++ b/indra/newview/llconversationview.cpp @@ -652,6 +652,7 @@ void LLConversationViewParticipant::draw() static LLUIColor sFlashBgColor = LLUIColorTable::instance().getColor("MenuItemFlashBgColor", DEFAULT_WHITE); static LLUIColor sFocusOutlineColor = LLUIColorTable::instance().getColor("InventoryFocusOutlineColor", DEFAULT_WHITE); static LLUIColor sMouseOverColor = LLUIColorTable::instance().getColor("InventoryMouseOverColor", DEFAULT_WHITE); + static LLUIColor sFriendColor = LLUIColorTable::instance().getColor("ConversationFriendColor");; const bool show_context = (getRoot() ? getRoot()->getShowSelectionContext() : false); @@ -661,23 +662,23 @@ void LLConversationViewParticipant::draw() F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)mTextPad; F32 text_left = (F32)getLabelXPos(); - LLColor4 color; + LLUIColor* color; LLLocalSpeakerMgr *speakerMgr = LLLocalSpeakerMgr::getInstance(); if (speakerMgr && speakerMgr->isSpeakerToBeRemoved(mUUID)) { - color = sFgDisabledColor; + color = &sFgDisabledColor; } else { if (LLAvatarActions::isFriend(mUUID)) { - color = LLUIColorTable::instance().getColor("ConversationFriendColor"); + color = &sFriendColor; } else { - color = mIsSelected ? sHighlightFgColor : sFgColor; + color = mIsSelected ? &sHighlightFgColor : &sFgColor; } } @@ -688,7 +689,7 @@ void LLConversationViewParticipant::draw() } drawHighlight(show_context, mIsSelected, sHighlightBgColor, sFlashBgColor, sFocusOutlineColor, sMouseOverColor); - drawLabel(font, text_left, y, color, right_x); + drawLabel(font, text_left, y, color->get(), right_x); LLView::draw(); } diff --git a/indra/newview/llfloateremojipicker.cpp b/indra/newview/llfloateremojipicker.cpp index 50f71c9c0b..cc13e5d059 100644 --- a/indra/newview/llfloateremojipicker.cpp +++ b/indra/newview/llfloateremojipicker.cpp @@ -203,8 +203,7 @@ public: F32 centerY = 0.5f * clientHeight; drawIcon(centerX, centerY - 1, iconWidth); - static LLColor4 defaultColor(0.75f, 0.75f, 0.75f, 1.0f); - static LLUIColor textColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", defaultColor); + static LLUIColor textColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", LLColor4(0.75f, 0.75f, 0.75f, 1.0f)); S32 max_pixels = clientWidth - iconWidth; drawName((F32)iconWidth, centerY, max_pixels, textColor.get()); } @@ -704,8 +703,7 @@ void LLFloaterEmojiPicker::fillEmojis(bool fromResize) LLPanel::Params icon_params; LLRect icon_rect(0, icon_size, icon_size, 0); - static LLColor4 default_color(0.75f, 0.75f, 0.75f, 1.0f); - LLColor4 bg_color = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", default_color); + static LLUIColor bg_color = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", LLColor4(0.75f, 0.75f, 0.75f, 1.0f)); if (!mSelectedGroupIndex) { diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp index 4011a857e5..205089c662 100644 --- a/indra/newview/llhudnametag.cpp +++ b/indra/newview/llhudnametag.cpp @@ -279,8 +279,10 @@ void LLHUDNameTag::renderText(bool for_select) mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f)); // *TODO: make this a per-text setting - LLColor4 bg_color = LLUIColorTable::instance().getColor("NameTagBackground"); - bg_color.setAlpha(gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor); + static LLCachedControl bubble_opacity(gSavedSettings, "ChatBubbleOpacity"); + static LLUIColor nametag_bg_color = LLUIColorTable::instance().getColor("NameTagBackground"); + LLColor4 bg_color = nametag_bg_color; + bg_color.setAlpha(bubble_opacity * alpha_factor); // scale screen size of borders down //RN: for now, text on hud objects is never occluded @@ -340,8 +342,7 @@ void LLHUDNameTag::renderText(bool for_select) x_offset = -0.5f * mWidth + (HORIZONTAL_PADDING / 2.f); } - LLColor4 label_color(0.f, 0.f, 0.f, 1.f); - label_color.mV[VALPHA] = alpha_factor; + LLColor4 label_color(0.f, 0.f, 0.f, alpha_factor); hud_render_text(segment_iter->getText(), render_position, *fontp, segment_iter->mStyle, LLFontGL::NO_SHADOW, x_offset, y_offset, label_color, false); } } diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp index 35bcf65db6..fd0d8b696f 100644 --- a/indra/newview/llhudtext.cpp +++ b/indra/newview/llhudtext.cpp @@ -138,8 +138,10 @@ void LLHUDText::renderText() mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f)); // *TODO: make this a per-text setting - LLColor4 bg_color = LLUIColorTable::instance().getColor("ObjectBubbleColor"); - bg_color.setAlpha(gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor); + static LLCachedControl bubble_opacity(gSavedSettings, "ChatBubbleOpacity"); + static LLUIColor nametag_bg_color = LLUIColorTable::instance().getColor("ObjectBubbleColor"); + LLColor4 bg_color = nametag_bg_color; + bg_color.setAlpha(bubble_opacity * alpha_factor); const S32 border_height = 16; const S32 border_width = 16; diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 2ca122c955..9e6cf7ac73 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -2881,11 +2881,13 @@ void LLInventoryGalleryItem::draw() LLPanel::draw(); // Draw border - LLUIColor border_color = LLUIColorTable::instance().getColor(mSelected ? "MenuItemHighlightBgColor" : "TextFgTentativeColor", LLColor4::white); + static LLUIColor menu_highlighted_color = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", LLColor4::white);; + static LLUIColor text_fg_tentative_color = LLUIColorTable::instance().getColor("TextFgTentativeColor", LLColor4::white);; + const LLColor4& border_color = mSelected ? menu_highlighted_color : text_fg_tentative_color; LLRect border = mThumbnailCtrl->getRect(); border.mRight = border.mRight + 1; border.mTop = border.mTop + 1; - gl_rect_2d(border, border_color.get(), false); + gl_rect_2d(border, border_color, false); } } diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp index 6f23477415..59cf3ac02b 100644 --- a/indra/newview/llscripteditor.cpp +++ b/indra/newview/llscripteditor.cpp @@ -122,7 +122,7 @@ void LLScriptEditor::drawLineNumbers() const LLWString ltext = utf8str_to_wstring(llformat("%d", line.mLineNum )); bool is_cur_line = cursor_line == line.mLineNum; const U8 style = is_cur_line ? LLFontGL::BOLD : LLFontGL::NORMAL; - const LLColor4 fg_color = is_cur_line ? mCursorColor : mReadOnlyFgColor; + const LLColor4& fg_color = is_cur_line ? mCursorColor : mReadOnlyFgColor; getScriptFont()->render( ltext, // string to draw 0, // begin offset diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp index 81002139be..7480a18d9f 100644 --- a/indra/newview/llspeakers.cpp +++ b/indra/newview/llspeakers.cpp @@ -368,8 +368,8 @@ void LLSpeakerMgr::update(bool resort_ok) return; } - LLColor4 speaking_color = LLUIColorTable::instance().getColor("SpeakingColor"); - LLColor4 overdriven_color = LLUIColorTable::instance().getColor("OverdrivenColor"); + static const LLUIColor speaking_color = LLUIColorTable::instance().getColor("SpeakingColor"); + static const LLUIColor overdriven_color = LLUIColorTable::instance().getColor("OverdrivenColor"); if(resort_ok) // only allow list changes when user is not interacting with it { diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp index 5180b1808c..0063e0b7fd 100644 --- a/indra/newview/lltoolbarview.cpp +++ b/indra/newview/lltoolbarview.cpp @@ -566,7 +566,7 @@ void LLToolBarView::draw() // Draw drop zones if drop of a tool is active if (isToolDragged()) { - LLColor4 drop_color = LLUIColorTable::instance().getColor( "ToolbarDropZoneColor" ); + static const LLUIColor drop_color = LLUIColorTable::instance().getColor( "ToolbarDropZoneColor" ); for (S32 i = LLToolBarEnums::TOOLBAR_FIRST; i <= LLToolBarEnums::TOOLBAR_LAST; i++) { diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 0c8dd6dff9..e3b92598f7 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -536,9 +536,7 @@ void init_menus() /// /// set up the colors /// - LLColor4 color; - - LLColor4 context_menu_color = LLUIColorTable::instance().getColor("MenuPopupBgColor"); + LLUIColor context_menu_color = LLUIColorTable::instance().getColor("MenuPopupBgColor"); gMenuAvatarSelf->setBackgroundColor( context_menu_color ); gMenuAvatarOther->setBackgroundColor( context_menu_color ); @@ -548,7 +546,7 @@ void init_menus() gMenuLand->setBackgroundColor( context_menu_color ); - color = LLUIColorTable::instance().getColor( "MenuPopupBgColor" ); + LLUIColor color = LLUIColorTable::instance().getColor( "MenuPopupBgColor" ); gPopupMenuView->setBackgroundColor( color ); // If we are not in production, use a different color to make it apparent. diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index cda8c99594..ae64ee7b92 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -1715,15 +1715,15 @@ void LLViewerObjectList::clearAllMapObjectsInRegion(LLViewerRegion* regionp) void LLViewerObjectList::renderObjectsForMap(LLNetMap &netmap) { - LLColor4 above_water_color = LLUIColorTable::instance().getColor( "NetMapOtherOwnAboveWater" ); - LLColor4 below_water_color = LLUIColorTable::instance().getColor( "NetMapOtherOwnBelowWater" ); - LLColor4 you_own_above_water_color = + static const LLUIColor above_water_color = LLUIColorTable::instance().getColor( "NetMapOtherOwnAboveWater" ); + static const LLUIColor below_water_color = LLUIColorTable::instance().getColor( "NetMapOtherOwnBelowWater" ); + static const LLUIColor you_own_above_water_color = LLUIColorTable::instance().getColor( "NetMapYouOwnAboveWater" ); - LLColor4 you_own_below_water_color = + static const LLUIColor you_own_below_water_color = LLUIColorTable::instance().getColor( "NetMapYouOwnBelowWater" ); - LLColor4 group_own_above_water_color = + static const LLUIColor group_own_above_water_color = LLUIColorTable::instance().getColor( "NetMapGroupOwnAboveWater" ); - LLColor4 group_own_below_water_color = + static const LLUIColor group_own_below_water_color = LLUIColorTable::instance().getColor( "NetMapGroupOwnBelowWater" ); F32 max_radius = gSavedSettings.getF32("MiniMapPrimMaxRadius"); @@ -1753,7 +1753,7 @@ void LLViewerObjectList::renderObjectsForMap(LLNetMap &netmap) // See DEV-17370 and DEV-29869/SNOW-79 for details. approx_radius = llmin(approx_radius, max_radius); - LLColor4U color = above_water_color; + LLColor4U color = above_water_color.get(); if( objectp->permYouOwner() ) { const F32 MIN_RADIUS_FOR_OWNED_OBJECTS = 2.f; @@ -1766,29 +1766,29 @@ void LLViewerObjectList::renderObjectsForMap(LLNetMap &netmap) { if ( objectp->permGroupOwner() ) { - color = group_own_above_water_color; + color = group_own_above_water_color.get(); } else { - color = you_own_above_water_color; + color = you_own_above_water_color.get(); } } else { if ( objectp->permGroupOwner() ) { - color = group_own_below_water_color; + color = group_own_below_water_color.get(); } else { - color = you_own_below_water_color; + color = you_own_below_water_color.get(); } } } else if( pos.mdV[VZ] < water_height ) { - color = below_water_color; + color = below_water_color.get(); } netmap.renderScaledPointGlobal( diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp index 58b8a5b677..2e9b5de72b 100755 --- a/indra/newview/llviewerparceloverlay.cpp +++ b/indra/newview/llviewerparceloverlay.cpp @@ -53,6 +53,14 @@ static const U8 OVERLAY_IMG_COMPONENTS = 4; static const F32 LINE_WIDTH = 0.0625f; +bool LLViewerParcelOverlay::sColorSetInitialized = false; +LLUIColor LLViewerParcelOverlay::sAvailColor; +LLUIColor LLViewerParcelOverlay::sOwnedColor; +LLUIColor LLViewerParcelOverlay::sGroupColor; +LLUIColor LLViewerParcelOverlay::sSelfColor; +LLUIColor LLViewerParcelOverlay::sForSaleColor; +LLUIColor LLViewerParcelOverlay::sAuctionColor; + LLViewerParcelOverlay::LLViewerParcelOverlay(LLViewerRegion* region, F32 region_width_meters) : mRegion( region ), mParcelGridsPerEdge( S32( region_width_meters / PARCEL_GRID_STEP_METERS ) ), @@ -60,6 +68,17 @@ LLViewerParcelOverlay::LLViewerParcelOverlay(LLViewerRegion* region, F32 region_ mTimeSinceLastUpdate(), mOverlayTextureIdx(-1) { + if (!sColorSetInitialized) + { + sColorSetInitialized = true; + sAvailColor = LLUIColorTable::instance().getColor("PropertyColorAvail").get(); + sOwnedColor = LLUIColorTable::instance().getColor("PropertyColorOther").get(); + sGroupColor = LLUIColorTable::instance().getColor("PropertyColorGroup").get(); + sSelfColor = LLUIColorTable::instance().getColor("PropertyColorSelf").get(); + sForSaleColor = LLUIColorTable::instance().getColor("PropertyColorForSale").get(); + sAuctionColor = LLUIColorTable::instance().getColor("PropertyColorAuction").get(); + } + // Create a texture to hold color information. // 4 components // Use mipmaps = false, clamped, NEAREST filter, for sharp edges @@ -321,12 +340,12 @@ void LLViewerParcelOverlay::updateOverlayTexture() mOverlayTextureIdx = 0; } - const LLColor4U avail = LLUIColorTable::instance().getColor("PropertyColorAvail").get(); - const LLColor4U owned = LLUIColorTable::instance().getColor("PropertyColorOther").get(); - const LLColor4U group = LLUIColorTable::instance().getColor("PropertyColorGroup").get(); - const LLColor4U self = LLUIColorTable::instance().getColor("PropertyColorSelf").get(); - const LLColor4U for_sale = LLUIColorTable::instance().getColor("PropertyColorForSale").get(); - const LLColor4U auction = LLUIColorTable::instance().getColor("PropertyColorAuction").get(); + const LLColor4U avail = sAvailColor.get(); + const LLColor4U owned = sOwnedColor.get(); + const LLColor4U group = sGroupColor.get(); + const LLColor4U self = sSelfColor.get(); + const LLColor4U for_sale = sForSaleColor.get(); + const LLColor4U auction = sAuctionColor.get(); // Create the base texture. U8 *raw = mImageRaw->getData(); @@ -339,7 +358,7 @@ void LLViewerParcelOverlay::updateOverlayTexture() { U8 ownership = mOwnership[i]; - F32 r,g,b,a; + U8 r,g,b,a; // Color stored in low three bits switch( ownership & 0x7 ) @@ -433,11 +452,11 @@ void LLViewerParcelOverlay::updatePropertyLines() return; LLColor4U colors[PARCEL_COLOR_MASK + 1]; - colors[PARCEL_SELF] = LLUIColorTable::instance().getColor("PropertyColorSelf").get(); - colors[PARCEL_OWNED] = LLUIColorTable::instance().getColor("PropertyColorOther").get(); - colors[PARCEL_GROUP] = LLUIColorTable::instance().getColor("PropertyColorGroup").get(); - colors[PARCEL_FOR_SALE] = LLUIColorTable::instance().getColor("PropertyColorForSale").get(); - colors[PARCEL_AUCTION] = LLUIColorTable::instance().getColor("PropertyColorAuction").get(); + colors[PARCEL_SELF] = sSelfColor.get(); + colors[PARCEL_OWNED] = sOwnedColor.get(); + colors[PARCEL_GROUP] = sGroupColor.get(); + colors[PARCEL_FOR_SALE] = sForSaleColor.get(); + colors[PARCEL_AUCTION] = sAuctionColor.get(); mEdges.clear(); diff --git a/indra/newview/llviewerparceloverlay.h b/indra/newview/llviewerparceloverlay.h index d78005e376..03ae464cb8 100644 --- a/indra/newview/llviewerparceloverlay.h +++ b/indra/newview/llviewerparceloverlay.h @@ -35,6 +35,7 @@ #include "lluuid.h" #include "llviewertexture.h" #include "llgl.h" +#include "lluicolor.h" class LLViewerRegion; class LLVector3; @@ -123,6 +124,14 @@ private: }; std::vector mEdges; + + static bool sColorSetInitialized; + static LLUIColor sAvailColor; + static LLUIColor sOwnedColor; + static LLUIColor sGroupColor; + static LLUIColor sSelfColor; + static LLUIColor sForSaleColor; + static LLUIColor sAuctionColor; }; #endif diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index 15902e8a87..14228b469f 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -222,15 +222,9 @@ public: image_rect.mTop = image_rect.mBottom + mImage->getHeight(); mImage->draw(LLRect((S32)image_rect.mLeft, (S32)image_rect.mTop, (S32)image_rect.mRight, (S32)image_rect.mBottom)); - LLColor4 color; - if (mEditor.getReadOnly()) - { - color = LLUIColorTable::instance().getColor("TextEmbeddedItemReadOnlyColor"); - } - else - { - color = LLUIColorTable::instance().getColor("TextEmbeddedItemColor"); - } + static const LLUIColor embedded_item_readonly_col = LLUIColorTable::instance().getColor("TextEmbeddedItemReadOnlyColor"); + static const LLUIColor embedded_item_col = LLUIColorTable::instance().getColor("TextEmbeddedItemColor"); + const LLColor4& color = mEditor.getReadOnly() ? embedded_item_readonly_col : embedded_item_col; F32 right_x; mStyle->getFont()->render(mLabel, 0, image_rect.mRight + EMBEDDED_ITEM_LABEL_PADDING, draw_rect.mTop, color, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::UNDERLINE, LLFontGL::NO_SHADOW, static_cast(mLabel.length()), S32_MAX, &right_x); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 83df39d606..d5a8ee6cf8 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -3531,7 +3531,9 @@ void LLVOAvatar::idleUpdateNameTagText(bool new_name) std::deque::iterator chat_iter = mChats.begin(); mNameText->clearString(); - LLColor4 new_chat = LLUIColorTable::instance().getColor( isSelf() ? "UserChatColor" : "AgentChatColor" ); + static const LLUIColor user_chat_color = LLUIColorTable::instance().getColor("UserChatColor"); + static const LLUIColor agent_chat_color = LLUIColorTable::instance().getColor("AgentChatColor"); + const LLColor4& new_chat = isSelf() ? user_chat_color : agent_chat_color; LLColor4 normal_chat = lerp(new_chat, LLColor4(0.8f, 0.8f, 0.8f, 1.f), 0.7f); LLColor4 old_chat = lerp(normal_chat, LLColor4(0.6f, 0.6f, 0.6f, 1.f), 0.7f); if (mTyping && mChats.size() >= MAX_BUBBLE_CHAT_UTTERANCES) -- cgit v1.2.3 From 456d013ba80566bd3c142f03b1754de47c940baf Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sun, 4 Aug 2024 15:51:21 -0400 Subject: Fix various issues with ui elements not updating colors dynamically --- indra/newview/lloutfitgallery.cpp | 4 ++-- indra/newview/llviewerwindow.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index f889a4439e..d7df9ceadc 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -1020,8 +1020,8 @@ void LLOutfitGalleryItem::setOutfitWorn(bool value) LLStringUtil::format_map_t worn_string_args; std::string worn_string = getString("worn_string", worn_string_args); LLUIColor text_color = LLUIColorTable::instance().getColor("White", LLColor4::white); - mOutfitWornText->setReadOnlyColor(text_color.get()); - mOutfitNameText->setReadOnlyColor(text_color.get()); + mOutfitWornText->setReadOnlyColor(text_color); + mOutfitNameText->setReadOnlyColor(text_color); mOutfitWornText->setFont(value ? LLFontGL::getFontSansSerifBold() : LLFontGL::getFontSansSerifSmall()); mOutfitNameText->setFont(value ? LLFontGL::getFontSansSerifBold() : LLFontGL::getFontSansSerifSmall()); mOutfitWornText->setValue(value ? worn_string : ""); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index f6de8377f3..f51850a644 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2190,7 +2190,7 @@ void LLViewerWindow::initWorldUI() gStatusBar->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP | FOLLOWS_RIGHT); gStatusBar->setShape(status_bar_container->getLocalRect()); // sync bg color with menu bar - gStatusBar->setBackgroundColor(gMenuBarView->getBackgroundColor().get()); + gStatusBar->setBackgroundColor(gMenuBarView->getBackgroundColor()); // add InBack so that gStatusBar won't be drawn over menu status_bar_container->addChildInBack(gStatusBar, 2/*tab order, after menu*/); status_bar_container->setVisible(true); @@ -2199,7 +2199,7 @@ void LLViewerWindow::initWorldUI() LLView* nav_bar_container = getRootView()->getChild("nav_bar_container"); navbar->setShape(nav_bar_container->getLocalRect()); - navbar->setBackgroundColor(gMenuBarView->getBackgroundColor().get()); + navbar->setBackgroundColor(gMenuBarView->getBackgroundColor()); nav_bar_container->addChild(navbar); nav_bar_container->setVisible(true); } -- cgit v1.2.3 From 9e777e1109035b40989ac13eb3a73323307ff151 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sun, 4 Aug 2024 15:55:50 -0400 Subject: Fix various issues with text segments not updating UI color --- indra/newview/llchatitemscontainerctrl.cpp | 11 +++-------- indra/newview/llpanelpermissions.cpp | 2 +- indra/newview/llsidepaneliteminfo.cpp | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index a5c26eff9c..f5519a8c88 100644 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -222,14 +222,9 @@ void LLFloaterIMNearbyChatToastPanel::init(LLSD& notification) if (mSourceType == CHAT_SOURCE_AGENT || mSourceType == CHAT_SOURCE_OBJECT) { LLStyle::Params style_params_name; - - LLColor4 user_name_color = LLUIColorTable::instance().getColor("HTMLLinkColor"); - style_params_name.color(user_name_color); - - std::string font_name = LLFontGL::nameFromFont(messageFont); - std::string font_style_size = LLFontGL::sizeFromFont(messageFont); - style_params_name.font.name(font_name); - style_params_name.font.size(font_style_size); + style_params_name.color = LLUIColorTable::instance().getColor("HTMLLinkColor"); + style_params_name.font.name = LLFontGL::nameFromFont(messageFont); + style_params_name.font.size = LLFontGL::sizeFromFont(messageFont); style_params_name.link_href = notification["sender_slurl"].asString(); style_params_name.is_link = true; diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp index aa35335ad9..0ce1f0f9d3 100644 --- a/indra/newview/llpanelpermissions.cpp +++ b/indra/newview/llpanelpermissions.cpp @@ -399,7 +399,7 @@ void LLPanelPermissions::refresh() // Style for creator and owner links (both group and agent) LLStyle::Params style_params; - LLColor4 link_color = LLUIColorTable::instance().getColor("HTMLLinkColor"); + LLUIColor link_color = LLUIColorTable::instance().getColor("HTMLLinkColor"); style_params.color = link_color; style_params.readonly_color = link_color; style_params.is_link = true; // link will be added later diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp index 7775e3d9f6..fccf745a74 100644 --- a/indra/newview/llsidepaneliteminfo.cpp +++ b/indra/newview/llsidepaneliteminfo.cpp @@ -351,7 +351,7 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item) // Style for creator and owner links LLStyle::Params style_params; - LLColor4 link_color = LLUIColorTable::instance().getColor("HTMLLinkColor"); + LLUIColor link_color = LLUIColorTable::instance().getColor("HTMLLinkColor"); style_params.color = link_color; style_params.readonly_color = link_color; style_params.is_link = true; // link will be added later -- cgit v1.2.3 From 409b9eebe12b864280ead8e3c537a73e40548b97 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sun, 4 Aug 2024 20:02:53 -0400 Subject: Fix chat text segments not dynamically updating when colors changed in preferences --- indra/newview/llchathistory.cpp | 4 +++- indra/newview/llchatitemscontainerctrl.cpp | 10 ++++++---- indra/newview/llconversationview.cpp | 2 +- indra/newview/llfloatercolorpicker.cpp | 12 ++++++------ indra/newview/llfloaterimnearbychathandler.cpp | 9 ++++----- indra/newview/llfloaterscriptedprefs.cpp | 2 -- indra/newview/llviewerchat.cpp | 10 +++++++--- indra/newview/llviewerchat.h | 5 ++--- indra/newview/llviewerwindow.cpp | 2 +- 9 files changed, 30 insertions(+), 26 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 8eba9aee37..a48e22bc73 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -1239,10 +1239,11 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL mMoreChatPanel->reshape(mMoreChatPanel->getRect().getWidth(), height); } + F32 alpha = 1.f; LLUIColor txt_color = LLUIColorTable::instance().getColor("White"); LLUIColor name_color(txt_color); + LLViewerChat::getChatColor(chat, txt_color, alpha); - LLViewerChat::getChatColor(chat,txt_color); LLFontGL* fontp = LLViewerChat::getChatFont(); std::string font_name = LLFontGL::nameFromFont(fontp); std::string font_size = LLFontGL::sizeFromFont(fontp); @@ -1250,6 +1251,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL LLStyle::Params body_message_params; body_message_params.color(txt_color); body_message_params.readonly_color(txt_color); + body_message_params.alpha(alpha); body_message_params.font.name(font_name); body_message_params.font.size(font_size); body_message_params.font.style(input_append_params.font.style); diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index f5519a8c88..550dfeb802 100644 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -134,8 +134,8 @@ void LLFloaterIMNearbyChatToastPanel::addMessage(LLSD& notification) std::string color_name = notification["text_color"].asString(); - LLColor4 textColor = LLUIColorTable::instance().getColor(color_name); - textColor.mV[VALPHA] = (F32)notification["color_alpha"].asReal(); + LLUIColor textColor = LLUIColorTable::instance().getColor(color_name); + F32 textAlpha = (F32)notification["color_alpha"].asReal(); S32 font_size = notification["font_size"].asInteger(); @@ -152,6 +152,7 @@ void LLFloaterIMNearbyChatToastPanel::addMessage(LLSD& notification) { LLStyle::Params style_params; style_params.color(textColor); + style_params.alpha(textAlpha); std::string font_name = LLFontGL::nameFromFont(messageFont); std::string font_style_size = LLFontGL::sizeFromFont(messageFont); style_params.font.name(font_name); @@ -190,8 +191,8 @@ void LLFloaterIMNearbyChatToastPanel::init(LLSD& notification) std::string color_name = notification["text_color"].asString(); - LLColor4 textColor = LLUIColorTable::instance().getColor(color_name); - textColor.mV[VALPHA] = (F32)notification["color_alpha"].asReal(); + LLUIColor textColor = LLUIColorTable::instance().getColor(color_name); + F32 textAlpha = (F32)notification["color_alpha"].asReal(); S32 font_size = notification["font_size"].asInteger(); @@ -269,6 +270,7 @@ void LLFloaterIMNearbyChatToastPanel::init(LLSD& notification) { LLStyle::Params style_params; style_params.color(textColor); + style_params.alpha(textAlpha); std::string font_name = LLFontGL::nameFromFont(messageFont); std::string font_style_size = LLFontGL::sizeFromFont(messageFont); style_params.font.name(font_name); diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp index 72d08428d3..cb2370f413 100644 --- a/indra/newview/llconversationview.cpp +++ b/indra/newview/llconversationview.cpp @@ -652,7 +652,7 @@ void LLConversationViewParticipant::draw() static LLUIColor sFlashBgColor = LLUIColorTable::instance().getColor("MenuItemFlashBgColor", DEFAULT_WHITE); static LLUIColor sFocusOutlineColor = LLUIColorTable::instance().getColor("InventoryFocusOutlineColor", DEFAULT_WHITE); static LLUIColor sMouseOverColor = LLUIColorTable::instance().getColor("InventoryMouseOverColor", DEFAULT_WHITE); - static LLUIColor sFriendColor = LLUIColorTable::instance().getColor("ConversationFriendColor");; + static LLUIColor sFriendColor = LLUIColorTable::instance().getColor("ConversationFriendColor"); const bool show_context = (getRoot() ? getRoot()->getShowSelectionContext() : false); diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp index 603f54fb49..cd45093856 100644 --- a/indra/newview/llfloatercolorpicker.cpp +++ b/indra/newview/llfloatercolorpicker.cpp @@ -110,12 +110,6 @@ LLFloaterColorPicker::LLFloaterColorPicker (LLColorSwatchCtrl* swatch, bool show // create user interface for this picker createUI (); - - if (!mCanApplyImmediately) - { - mApplyImmediateCheck->setEnabled(false); - mApplyImmediateCheck->set(false); - } } LLFloaterColorPicker::~LLFloaterColorPicker() @@ -226,6 +220,12 @@ bool LLFloaterColorPicker::postBuild() mApplyImmediateCheck->set(gSavedSettings.getBOOL("ApplyColorImmediately")); mApplyImmediateCheck->setCommitCallback(onImmediateCheck, this); + if (!mCanApplyImmediately) + { + mApplyImmediateCheck->setEnabled(false); + mApplyImmediateCheck->set(false); + } + childSetCommitCallback("rspin", onTextCommit, (void*)this ); childSetCommitCallback("gspin", onTextCommit, (void*)this ); childSetCommitCallback("bspin", onTextCommit, (void*)this ); diff --git a/indra/newview/llfloaterimnearbychathandler.cpp b/indra/newview/llfloaterimnearbychathandler.cpp index 5cf02d1ec0..a614299e03 100644 --- a/indra/newview/llfloaterimnearbychathandler.cpp +++ b/indra/newview/llfloaterimnearbychathandler.cpp @@ -535,14 +535,13 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg, if (gSavedSettings.getS32("ShowScriptErrorsLocation") == 1)// show error in window //("ScriptErrorsAsChat")) { - - LLColor4 txt_color; - - LLViewerChat::getChatColor(chat_msg,txt_color); + LLUIColor txt_color; + F32 alpha = 1.f; + LLViewerChat::getChatColor(chat_msg, txt_color, alpha); LLFloaterScriptDebug::addScriptLine(chat_msg.mText, chat_msg.mFromName, - txt_color, + txt_color % alpha, chat_msg.mFromID); return; } diff --git a/indra/newview/llfloaterscriptedprefs.cpp b/indra/newview/llfloaterscriptedprefs.cpp index a38c4b51f2..fa31cd72c1 100644 --- a/indra/newview/llfloaterscriptedprefs.cpp +++ b/indra/newview/llfloaterscriptedprefs.cpp @@ -54,8 +54,6 @@ bool LLFloaterScriptEdPrefs::postBuild() void LLFloaterScriptEdPrefs::applyUIColor(LLUICtrl* ctrl, const LLSD& param) { LLUIColorTable::instance().setColor(param.asString(), LLColor4(ctrl->getValue())); - mEditor->initKeywords(); - mEditor->loadKeywords(); } void LLFloaterScriptEdPrefs::getUIColor(LLUICtrl* ctrl, const LLSD& param) diff --git a/indra/newview/llviewerchat.cpp b/indra/newview/llviewerchat.cpp index 597cf3c98c..8b01c4ef88 100644 --- a/indra/newview/llviewerchat.cpp +++ b/indra/newview/llviewerchat.cpp @@ -41,7 +41,7 @@ LLViewerChat::font_change_signal_t LLViewerChat::sChatFontChangedSignal; //static -void LLViewerChat::getChatColor(const LLChat& chat, LLColor4& r_color) +void LLViewerChat::getChatColor(const LLChat& chat, LLUIColor& r_color, F32& r_color_alpha) { if(chat.mMuted) { @@ -90,7 +90,7 @@ void LLViewerChat::getChatColor(const LLChat& chat, LLColor4& r_color) } break; default: - r_color.setToWhite(); + r_color = LLUIColorTable::instance().getColor("White"); } if (!chat.mPosAgent.isExactlyZero()) @@ -101,7 +101,11 @@ void LLViewerChat::getChatColor(const LLChat& chat, LLColor4& r_color) if (distance_squared > dist_near_chat * dist_near_chat) { // diminish far-off chat - r_color.mV[VALPHA] = 0.8f; + r_color_alpha = 0.8f; + } + else + { + r_color_alpha = 1.0f; } } } diff --git a/indra/newview/llviewerchat.h b/indra/newview/llviewerchat.h index a84d7dbc5d..6138358caf 100644 --- a/indra/newview/llviewerchat.h +++ b/indra/newview/llviewerchat.h @@ -29,15 +29,14 @@ #include "llchat.h" #include "llfontgl.h" -#include "v4color.h" - +#include "lluicolor.h" class LLViewerChat { public: typedef boost::signals2::signal font_change_signal_t; - static void getChatColor(const LLChat& chat, LLColor4& r_color); + static void getChatColor(const LLChat& chat, LLUIColor& r_color, F32& r_color_alpha); static void getChatColor(const LLChat& chat, std::string& r_color_name, F32& r_color_alpha); static LLFontGL* getChatFont(); static S32 getChatFontSize(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index f51850a644..417cece8eb 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2583,7 +2583,7 @@ void LLViewerWindow::setNormalControlsVisible( bool visible ) void LLViewerWindow::setMenuBackgroundColor(bool god_mode, bool dev_grid) { LLSD args; - LLColor4 new_bg_color; + LLUIColor new_bg_color; // god more important than project, proj more important than grid if ( god_mode ) -- cgit v1.2.3 From 7144fb2359fa0ac64ca7dc8c61bceb0a52015a10 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 5 Aug 2024 09:26:04 +0300 Subject: Remove remainder of unused packet data code from LLTextureFetch Downloading packets from server was removed in favor of HTTP --- indra/newview/lltexturefetch.cpp | 77 ---------------------------------------- indra/newview/lltexturefetch.h | 2 -- indra/newview/lltextureview.cpp | 10 +----- 3 files changed, 1 insertion(+), 88 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 689c555998..69c40066b4 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -467,14 +467,6 @@ private: // Locks: Mw (ctor invokes without lock) void setDesiredDiscard(S32 discard, S32 size); - // Threads: T* - // Locks: Mw - bool insertPacket(S32 index, U8* data, S32 size); - - // Locks: Mw - void clearPackets(); - - // Locks: Mw void removeFromCache(); @@ -592,21 +584,6 @@ private: // Work Data LLMutex mWorkMutex; - struct PacketData - { - PacketData(U8* data, S32 size) - : mData(data), mSize(size) - {} - ~PacketData() { clearData(); } - void clearData() { delete[] mData; mData = NULL; } - - U8* mData; - U32 mSize; - }; - std::vector mPackets; - S32 mFirstPacket; - S32 mLastPacket; - U16 mTotalPackets; U8 mImageCodec; LLViewerAssetStats::duration_t mMetricsStartTime; @@ -922,9 +899,6 @@ LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher, mRetryAttempt(0), mActiveCount(0), mWorkMutex(), - mFirstPacket(0), - mLastPacket(-1), - mTotalPackets(0), mImageCodec(IMG_CODEC_INVALID), mMetricsStartTime(0), mHttpHandle(LLCORE_HTTP_HANDLE_INVALID), @@ -980,7 +954,6 @@ LLTextureFetchWorker::~LLTextureFetchWorker() mFetcher->mTextureCache->writeComplete(mCacheWriteHandle, true); } mFormattedImage = NULL; - clearPackets(); if (mHttpBufferArray) { mHttpBufferArray->release(); @@ -992,16 +965,6 @@ LLTextureFetchWorker::~LLTextureFetchWorker() mFetcher->updateStateStats(mCacheReadCount, mCacheWriteCount, mResourceWaitCount); } -// Locks: Mw -void LLTextureFetchWorker::clearPackets() -{ - for_each(mPackets.begin(), mPackets.end(), DeletePointer()); - mPackets.clear(); - mTotalPackets = 0; - mLastPacket = -1; - mFirstPacket = 0; -} - // Locks: Mw (ctor invokes without lock) void LLTextureFetchWorker::setDesiredDiscard(S32 discard, S32 size) { @@ -1164,7 +1127,6 @@ bool LLTextureFetchWorker::doWork(S32 param) mHttpReplySize = 0; mHttpReplyOffset = 0; mHaveAllData = false; - clearPackets(); // TODO: Shouldn't be necessary mCacheReadHandle = LLTextureCache::nullHandle(); mCacheWriteHandle = LLTextureCache::nullHandle(); setState(LOAD_FROM_TEXTURE_CACHE); @@ -2441,8 +2403,6 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, bool threaded, bool qa_mod : LLWorkerThread("TextureFetch", threaded, true), mDebugCount(0), mDebugPause(false), - mPacketCount(0), - mBadPacketCount(0), mQueueMutex(), mNetworkQueueMutex(), mTextureCache(cache), @@ -3066,43 +3026,6 @@ void LLTextureFetch::threadedUpdate() #endif } -////////////////////////////////////////////////////////////////////////////// - -// Threads: T* -// Locks: Mw -bool LLTextureFetchWorker::insertPacket(S32 index, U8* data, S32 size) -{ - LL_PROFILE_ZONE_SCOPED; - mRequestedDeltaTimer.reset(); - if (index >= mTotalPackets) - { -// LL_WARNS(LOG_TXT) << "Received Image Packet " << index << " > max: " << mTotalPackets << " for image: " << mID << LL_ENDL; - return false; - } - if (index > 0 && index < mTotalPackets-1 && size != MAX_IMG_PACKET_SIZE) - { -// LL_WARNS(LOG_TXT) << "Received bad sized packet: " << index << ", " << size << " != " << MAX_IMG_PACKET_SIZE << " for image: " << mID << LL_ENDL; - return false; - } - - if (index >= (S32)mPackets.size()) - { - mPackets.resize(index+1, (PacketData*)NULL); // initializes v to NULL pointers - } - else if (mPackets[index] != NULL) - { -// LL_WARNS(LOG_TXT) << "Received duplicate packet: " << index << " for image: " << mID << LL_ENDL; - return false; - } - - mPackets[index] = new PacketData(data, size); - while (mLastPacket+1 < (S32)mPackets.size() && mPackets[mLastPacket+1] != NULL) - { - ++mLastPacket; - } - return true; -} - void LLTextureFetchWorker::setState(e_state new_state) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index aebd2f8f95..3405f76e37 100644 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -293,8 +293,6 @@ public: LLUUID mDebugID; S32 mDebugCount; bool mDebugPause; - S32 mPacketCount; - S32 mBadPacketCount; static LLTrace::CountStatHandle sCacheHit; static LLTrace::CountStatHandle sCacheAttempt; diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index 92527fc3a9..e5a61b359d 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -323,13 +323,6 @@ void LLTextureBar::draw() { LLGLSUIDefault gls_ui; - // draw the packet data -// { -// std::string num_str = llformat("%3d/%3d", mImagep->mLastPacket+1, mImagep->mPackets); -// LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, bar_left + 100, getRect().getHeight(), color, -// LLFontGL::LEFT, LLFontGL::TOP); -// } - // draw the image size at the end { std::string num_str = llformat("%3dx%3d (%2d) %7d", mImagep->getWidth(), mImagep->getHeight(), @@ -620,10 +613,9 @@ void LLGLTexMemBar::draw() //---------------------------------------------------------------------------- - text = llformat("Textures: %d Fetch: %d(%d) Pkts:%d(%d) Cache R/W: %d/%d LFS:%d RAW:%d HTP:%d DEC:%d CRE:%d ", + text = llformat("Textures: %d Fetch: %d(%d) Cache R/W: %d/%d LFS:%d RAW:%d HTP:%d DEC:%d CRE:%d ", gTextureList.getNumImages(), LLAppViewer::getTextureFetch()->getNumRequests(), LLAppViewer::getTextureFetch()->getNumDeletes(), - LLAppViewer::getTextureFetch()->mPacketCount, LLAppViewer::getTextureFetch()->mBadPacketCount, LLAppViewer::getTextureCache()->getNumReads(), LLAppViewer::getTextureCache()->getNumWrites(), LLLFSThread::sLocal->getPending(), LLImageRaw::sRawImageCount, -- cgit v1.2.3 From db376f2ace28b199749796520966b6e9884985d6 Mon Sep 17 00:00:00 2001 From: TJ Date: Tue, 6 Aug 2024 00:05:10 +1000 Subject: Fixed unwanted implicit cast from U32 to U16 causing possible crash (#2193, #2194) --- indra/newview/llvosurfacepatch.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index 471174cf5d..d7fe17c3ce 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -987,7 +987,7 @@ LLTerrainPartition::LLTerrainPartition(LLViewerRegion* regionp) } // Do not add vertices; honor strict vertex count specified by strider_vertex_count -void gen_terrain_tangents(U16 strider_vertex_count, +void gen_terrain_tangents(U32 strider_vertex_count, U32 strider_index_count, LLStrider &verticesp, LLStrider &normalsp, @@ -1003,7 +1003,7 @@ void gen_terrain_tangents(U16 strider_vertex_count, std::vector texcoords(strider_vertex_count); std::vector indices(strider_index_count); - for (U16 v = 0; v < strider_vertex_count; ++v) + for (U32 v = 0; v < strider_vertex_count; ++v) { F32 *vert = verticesp[v].mV; vertices[v] = LLVector4a(vert[0], vert[1], vert[2], 1.f); @@ -1019,7 +1019,7 @@ void gen_terrain_tangents(U16 strider_vertex_count, LLCalculateTangentArray(strider_vertex_count, vertices, normals, texcoords.data(), strider_index_count / 3, indices.data(), tangents); - for (U16 v = 0; v < strider_vertex_count; ++v) + for (U32 v = 0; v < strider_vertex_count; ++v) { tangentsp[v] = tangents[v]; } -- cgit v1.2.3 From 75455d101c9535d0d45aa0f505f888f4ba3de64d Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Tue, 6 Aug 2024 09:21:19 -0400 Subject: Convert LLUI and LLRender2D to LLSimpleton to reduce overhead during ui draw (#2202) --- indra/newview/llappviewer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index f2023565fc..262ab439b4 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -802,7 +802,7 @@ bool LLAppViewer::init() settings_map["floater"] = &gSavedSettings; // *TODO: New settings file settings_map["account"] = &gSavedPerAccountSettings; - LLUI::initParamSingleton(settings_map, + LLUI::createInstance(settings_map, LLUIImageList::getInstance(), ui_audio_callback, deferred_ui_audio_callback); @@ -2155,6 +2155,7 @@ bool LLAppViewer::cleanup() LLViewerEventRecorder::deleteSingleton(); LLWorld::deleteSingleton(); LLVoiceClient::deleteSingleton(); + LLUI::deleteSingleton(); // It's not at first obvious where, in this long sequence, a generic cleanup // call OUGHT to go. So let's say this: as we migrate cleanup from -- cgit v1.2.3 From ae2ff22542a5882616778ffab50612f8ad41b71e Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 18 Jul 2024 15:24:11 -0700 Subject: NOISSUE: Prevent potential bad matrix state in HUD render --- indra/newview/llviewerwindow.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index f6de8377f3..4bd1b98569 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4185,15 +4185,17 @@ void LLViewerWindow::renderSelections( bool for_gl_pick, bool pick_parcel_walls, } } } - if (selection->getSelectType() == SELECT_TYPE_HUD && selection->getObjectCount()) - { - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); + } - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - stop_glerror(); - } + // un-setup HUD render + if (selection->getSelectType() == SELECT_TYPE_HUD && selection->getObjectCount()) + { + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + stop_glerror(); } } } -- cgit v1.2.3 From 6aa9110b2ae346da1a396500cae1b41e8e2d5b75 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 11 Jul 2024 15:54:24 -0700 Subject: secondlife/viewer#1883: Local-only PBR terrain paintmap with developer tools --- indra/newview/CMakeLists.txt | 2 + indra/newview/app_settings/settings.xml | 33 +++ .../shaders/class1/deferred/pbrterrainF.glsl | 31 ++- .../shaders/class1/deferred/pbrterrainUtilF.glsl | 46 ++++ .../shaders/class1/deferred/pbrterrainV.glsl | 38 ++- .../shaders/class1/interface/pbrTerrainBakeF.glsl | 62 +++++ .../shaders/class1/interface/pbrTerrainBakeV.glsl | 42 +++ indra/newview/lldrawpoolterrain.cpp | 58 ++++- indra/newview/lldrawpoolterrain.h | 3 +- indra/newview/llsurface.h | 3 +- indra/newview/llsurfacepatch.cpp | 10 +- indra/newview/llsurfacepatch.h | 4 +- indra/newview/llterrainpaintmap.cpp | 285 +++++++++++++++++++++ indra/newview/llterrainpaintmap.h | 42 +++ indra/newview/llviewercontrol.cpp | 4 + indra/newview/llviewermenu.cpp | 82 ++++-- indra/newview/llviewershadermgr.cpp | 74 ++++-- indra/newview/llviewershadermgr.h | 11 +- indra/newview/llviewertexture.cpp | 1 + indra/newview/llvlcomposition.cpp | 11 + indra/newview/llvlcomposition.h | 12 + indra/newview/llvosurfacepatch.cpp | 74 +++--- indra/newview/llvosurfacepatch.h | 12 - indra/newview/skins/default/xui/en/menu_viewer.xml | 38 ++- 24 files changed, 842 insertions(+), 136 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/interface/pbrTerrainBakeF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/interface/pbrTerrainBakeV.glsl create mode 100644 indra/newview/llterrainpaintmap.cpp create mode 100644 indra/newview/llterrainpaintmap.h (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index a34354d287..e7857ff09f 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -578,6 +578,7 @@ set(viewer_SOURCE_FILES llsyswellwindow.cpp llteleporthistory.cpp llteleporthistorystorage.cpp + llterrainpaintmap.cpp lltexturecache.cpp lltexturectrl.cpp lltexturefetch.cpp @@ -1235,6 +1236,7 @@ set(viewer_HEADER_FILES lltable.h llteleporthistory.h llteleporthistorystorage.h + llterrainpaintmap.h lltexturecache.h lltexturectrl.h lltexturefetch.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 9e5d3f09bd..5c3706bb6c 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -14965,6 +14965,39 @@ F32 Value 0.0 + + LocalTerrainPaintEnabled + + Comment + Enables local paintmap if LocalTerrainAsset1, etc are set + Persist + 0 + Type + Boolean + Value + 0 + + TerrainPaintBitDepth + + Comment + Bit depth for future terrain paint map operations. Min: 1. Max: 8. Takes effect when the paint map is created or modified. Modifications to an existing paintmap of different bit depth will have lower precision. + Persist + 1 + Type + U32 + Value + 5 + + TerrainPaintResolution + + Comment + Resolution of the terrain paint map in pixels. Rounded to a power of two. Min: 16. Max: RenderMaxTextureResolution. Takes effect when the paint map is created. + Persist + 1 + Type + U32 + Value + 2048 PathfindingRetrieveNeighboringRegion diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl index 6ca35419f2..410c447c64 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl @@ -30,6 +30,9 @@ #define TERRAIN_PBR_DETAIL_NORMAL -2 #define TERRAIN_PBR_DETAIL_METALLIC_ROUGHNESS -3 +#define TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE 0 +#define TERRAIN_PAINT_TYPE_PBR_PAINTMAP 1 + #if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 #define TerrainCoord vec4[3] #elif TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 1 @@ -48,6 +51,7 @@ struct TerrainMix }; TerrainMix get_terrain_mix_weights(float alpha1, float alpha2, float alphaFinal); +TerrainMix get_terrain_usage_from_weight3(vec3 weight3); struct PBRMix { @@ -97,7 +101,11 @@ PBRMix mix_pbr(PBRMix mix1, PBRMix mix2, float mix2_weight); out vec4 frag_data[4]; +#if TERRAIN_PAINT_TYPE == TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE uniform sampler2D alpha_ramp; +#elif TERRAIN_PAINT_TYPE == TERRAIN_PAINT_TYPE_PBR_PAINTMAP +uniform sampler2D paint_map; +#endif // https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#additional-textures uniform sampler2D detail_0_base_color; @@ -133,19 +141,25 @@ uniform vec3[4] emissiveColors; #endif uniform vec4 minimum_alphas; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff() -#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 -in vec4[10] vary_coords; -#elif TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 1 -in vec4[2] vary_coords; -#endif in vec3 vary_position; in vec3 vary_normal; #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) in vec3 vary_tangents[4]; flat in float vary_signs[4]; #endif + +// vary_texcoord* are used for terrain composition, vary_coords are used for terrain UVs +#if TERRAIN_PAINT_TYPE == TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE in vec4 vary_texcoord0; in vec4 vary_texcoord1; +#elif TERRAIN_PAINT_TYPE == TERRAIN_PAINT_TYPE_PBR_PAINTMAP +in vec2 vary_texcoord; +#endif +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 +in vec4[10] vary_coords; +#elif TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 1 +in vec4[2] vary_coords; +#endif void mirrorClip(vec3 position); @@ -171,11 +185,16 @@ void main() // Make sure we clip the terrain if we're in a mirror. mirrorClip(vary_position); + TerrainMix tm; +#if TERRAIN_PAINT_TYPE == TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE float alpha1 = texture(alpha_ramp, vary_texcoord0.zw).a; float alpha2 = texture(alpha_ramp,vary_texcoord1.xy).a; float alphaFinal = texture(alpha_ramp, vary_texcoord1.zw).a; - TerrainMix tm = get_terrain_mix_weights(alpha1, alpha2, alphaFinal); + tm = get_terrain_mix_weights(alpha1, alpha2, alphaFinal); +#elif TERRAIN_PAINT_TYPE == TERRAIN_PAINT_TYPE_PBR_PAINTMAP + tm = get_terrain_usage_from_weight3(texture(paint_map, vary_texcoord).xyz); +#endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_OCCLUSION) // RGB = Occlusion, Roughness, Metal diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl index 5098de717e..dc43007dca 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl @@ -51,7 +51,12 @@ #define TERRAIN_PBR_DETAIL_NORMAL -2 #define TERRAIN_PBR_DETAIL_METALLIC_ROUGHNESS -3 +#define TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE 0 +#define TERRAIN_PAINT_TYPE_PBR_PAINTMAP 1 + +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 in vec3 vary_vertex_normal; +#endif vec3 srgb_to_linear(vec3 c); @@ -202,6 +207,45 @@ TerrainMix get_terrain_mix_weights(float alpha1, float alpha2, float alphaFinal) return tm; } +// A paintmap weight applier for 4 swatches. The input saves a channel by not +// storing swatch 1, and assuming the weights of the 4 swatches add to 1. +// The components of weight3 should be between 0 and 1 +// The sum of the components of weight3 should be between 0 and 1 +TerrainMix get_terrain_usage_from_weight3(vec3 weight3) +{ + // These steps ensure the output weights add to between 0 and 1 + weight3.xyz = max(vec3(0.0), weight3.xyz); + weight3.xyz /= max(1.0, weight3.x + weight3.y + weight3.z); + + TerrainMix tm; + + // Extract the first weight from the other weights + tm.weight.x = 1.0 - (weight3.x + weight3.y + weight3.z); + tm.weight.yzw = weight3.xyz; + ivec4 usage = max(ivec4(0), ivec4(ceil(tm.weight))); + + tm.type = (usage.x * MIX_X) | + (usage.y * MIX_Y) | + (usage.z * MIX_Z) | + (usage.w * MIX_W); + return tm; +} + +// Inverse of get_terrain_usage_from_weight3, excluding usage flags +// The components of weight should be between 0 and 1 +// The sum of the components of weight should be 1 +vec3 get_weight3_from_terrain_weight(vec4 weight) +{ + // These steps ensure the input weights add to 1 + weight = max(vec4(0.0), weight); + weight.x += 1.0 - sign(weight.x + weight.y + weight.z + weight.w); + weight /= weight.x + weight.y + weight.z + weight.w; + + // Then return the input weights with the first weight truncated + return weight.yzw; +} + +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 TerrainTriplanar _t_triplanar() { float sharpness = TERRAIN_TRIPLANAR_BLEND_FACTOR; @@ -219,6 +263,8 @@ TerrainTriplanar _t_triplanar() ((usage.z) * SAMPLE_Z); return tw; } +#endif + // Assume weights add to 1 float terrain_mix(TerrainMix tm, vec4 tms4) diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl index c90b2b5926..6791a22a76 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl @@ -28,31 +28,47 @@ #define TERRAIN_PBR_DETAIL_NORMAL -2 #define TERRAIN_PBR_DETAIL_METALLIC_ROUGHNESS -3 +#define TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE 0 +#define TERRAIN_PAINT_TYPE_PBR_PAINTMAP 1 + uniform mat3 normal_matrix; uniform mat4 texture_matrix0; uniform mat4 modelview_matrix; uniform mat4 modelview_projection_matrix; +#if TERRAIN_PAINT_TYPE == TERRAIN_PAINT_TYPE_PBR_PAINTMAP +uniform float region_scale; +#endif in vec3 position; in vec3 normal; in vec4 tangent; in vec4 diffuse_color; +#if TERRAIN_PAINT_TYPE == TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE in vec2 texcoord1; +#endif -out vec3 vary_vertex_normal; // Used by pbrterrainUtilF.glsl +out vec3 vary_position; out vec3 vary_normal; +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 +out vec3 vary_vertex_normal; // Used by pbrterrainUtilF.glsl +#endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) out vec3 vary_tangents[4]; flat out float vary_signs[4]; #endif + +// vary_texcoord* are used for terrain composition, vary_coords are used for terrain UVs +#if TERRAIN_PAINT_TYPE == TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE out vec4 vary_texcoord0; out vec4 vary_texcoord1; +#elif TERRAIN_PAINT_TYPE == TERRAIN_PAINT_TYPE_PBR_PAINTMAP +out vec2 vary_texcoord; +#endif #if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 out vec4[10] vary_coords; #elif TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 1 out vec4[2] vary_coords; #endif -out vec3 vary_position; // *HACK: Each material uses only one texture transform, but the KHR texture // transform spec allows handling texture transforms separately for each @@ -69,7 +85,9 @@ void main() vary_position = (modelview_matrix*vec4(position.xyz, 1.0)).xyz; vec3 n = normal_matrix * normal; +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 vary_vertex_normal = normal; +#endif vec3 t = normal_matrix * tangent.xyz; #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) @@ -110,9 +128,9 @@ void main() // Transform and pass tex coords { vec4[2] ttt; +#define transform_xy() terrain_texture_transform(position.xy, ttt) #if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 // Don't care about upside-down (transform_xy_flipped()) -#define transform_xy() terrain_texture_transform(position.xy, ttt) #define transform_yz() terrain_texture_transform(position.yz, ttt) #define transform_negx_z() terrain_texture_transform(position.xz * vec2(-1, 1), ttt) #define transform_yz_flipped() terrain_texture_transform(position.yz * vec2(-1, 1), ttt) @@ -157,26 +175,30 @@ void main() ttt[0].xyz = terrain_texture_transforms[0].xyz; ttt[1].x = terrain_texture_transforms[0].w; ttt[1].y = terrain_texture_transforms[1].x; - vary_coords[0].xy = terrain_texture_transform(position.xy, ttt); + vary_coords[0].xy = transform_xy(); // material 2 ttt[0].xyz = terrain_texture_transforms[1].yzw; ttt[1].xy = terrain_texture_transforms[2].xy; - vary_coords[0].zw = terrain_texture_transform(position.xy, ttt); + vary_coords[0].zw = transform_xy(); // material 3 ttt[0].xy = terrain_texture_transforms[2].zw; ttt[0].z = terrain_texture_transforms[3].x; ttt[1].xy = terrain_texture_transforms[3].yz; - vary_coords[1].xy = terrain_texture_transform(position.xy, ttt); + vary_coords[1].xy = transform_xy(); // material 4 ttt[0].x = terrain_texture_transforms[3].w; ttt[0].yz = terrain_texture_transforms[4].xy; ttt[1].xy = terrain_texture_transforms[4].zw; - vary_coords[1].zw = terrain_texture_transform(position.xy, ttt); + vary_coords[1].zw = transform_xy(); #endif } - vec4 tc = vec4(texcoord1,0,1); +#if TERRAIN_PAINT_TYPE == TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE + vec2 tc = texcoord1.xy; vary_texcoord0.zw = tc.xy; vary_texcoord1.xy = tc.xy-vec2(2.0, 0.0); vary_texcoord1.zw = tc.xy-vec2(1.0, 0.0); +#elif TERRAIN_PAINT_TYPE == TERRAIN_PAINT_TYPE_PBR_PAINTMAP + vary_texcoord = position.xy / region_scale; +#endif } diff --git a/indra/newview/app_settings/shaders/class1/interface/pbrTerrainBakeF.glsl b/indra/newview/app_settings/shaders/class1/interface/pbrTerrainBakeF.glsl new file mode 100644 index 0000000000..cf20653a0f --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/pbrTerrainBakeF.glsl @@ -0,0 +1,62 @@ +/** + * @file terrainBakeF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +/*[EXTRA_CODE_HERE]*/ + +out vec4 frag_color; + +struct TerrainMix +{ + vec4 weight; + int type; +}; + +TerrainMix get_terrain_mix_weights(float alpha1, float alpha2, float alphaFinal); + +uniform sampler2D alpha_ramp; + +// vary_texcoord* are used for terrain composition +in vec4 vary_texcoord0; +in vec4 vary_texcoord1; + +void main() +{ + TerrainMix tm; + float alpha1 = texture(alpha_ramp, vary_texcoord0.zw).a; + float alpha2 = texture(alpha_ramp,vary_texcoord1.xy).a; + float alphaFinal = texture(alpha_ramp, vary_texcoord1.zw).a; + + tm = get_terrain_mix_weights(alpha1, alpha2, alphaFinal); + + // tm.weight.x can be ignored. The paintmap saves a channel by not storing + // swatch 1, and assuming the weights of the 4 swatches add to 1. + // TERRAIN_PAINT_PRECISION emulates loss of precision at lower bit depth + // when a corresponding low-bit image format is not available. Because + // integral values at one depth cannot be precisely represented at another + // bit depth, rounding is required. To maximize numerical stability for + // future conversions, bit depth conversions should round to the nearest + // integer, not floor or ceil. + frag_color = max(vec4(round(tm.weight.yzw * TERRAIN_PAINT_PRECISION) / TERRAIN_PAINT_PRECISION, 1.0), vec4(0)); +} diff --git a/indra/newview/app_settings/shaders/class1/interface/pbrTerrainBakeV.glsl b/indra/newview/app_settings/shaders/class1/interface/pbrTerrainBakeV.glsl new file mode 100644 index 0000000000..fd150b54ad --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/pbrTerrainBakeV.glsl @@ -0,0 +1,42 @@ +/** + * @file pbrTerrainBakeV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +uniform mat4 modelview_projection_matrix; + +in vec3 position; +in vec2 texcoord1; + +out vec4 vary_texcoord0; +out vec4 vary_texcoord1; + +void main() +{ + gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + vec2 tc = texcoord1.xy; + vary_texcoord0.zw = tc.xy; + vary_texcoord1.xy = tc.xy-vec2(2.0, 0.0); + vary_texcoord1.zw = tc.xy-vec2(1.0, 0.0); +} + diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index 7d2912d81f..5e676bc5b3 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -219,7 +219,9 @@ void LLDrawPoolTerrain::renderFullShader() else { // Use materials - sShader = &gDeferredPBRTerrainProgram; + U32 paint_type = use_local_materials ? gLocalTerrainMaterials.getPaintType() : compp->getPaintType(); + paint_type = llclamp(paint_type, 0, TERRAIN_PAINT_TYPE_COUNT); + sShader = &gDeferredPBRTerrainProgram[paint_type]; sShader->bind(); renderFullShaderPBR(use_local_materials); } @@ -326,7 +328,7 @@ void LLDrawPoolTerrain::renderFullShaderTextures() } // *TODO: Investigate use of bindFast for PBR terrain textures -void LLDrawPoolTerrain::renderFullShaderPBR(bool local_materials) +void LLDrawPoolTerrain::renderFullShaderPBR(bool use_local_materials) { // Hack! Get the region that this draw pool is rendering from! LLViewerRegion *regionp = mDrawFace[0]->getDrawable()->getVObj()->getRegion(); @@ -339,7 +341,7 @@ void LLDrawPoolTerrain::renderFullShaderPBR(bool local_materials) llassert(shader_material_count == terrain_material_count); #endif - if (local_materials) + if (use_local_materials) { // Override region terrain with the global local override terrain fetched_materials = &gLocalTerrainMaterials.mDetailRenderMaterials; @@ -351,6 +353,9 @@ void LLDrawPoolTerrain::renderFullShaderPBR(bool local_materials) if (!materials[i]) { materials[i] = &LLGLTFMaterial::sDefault; } } + U32 paint_type = use_local_materials ? gLocalTerrainMaterials.getPaintType() : compp->getPaintType(); + paint_type = llclamp(paint_type, 0, TERRAIN_PAINT_TYPE_COUNT); + S32 detail_basecolor[terrain_material_count]; S32 detail_normal[terrain_material_count]; S32 detail_metalrough[terrain_material_count]; @@ -481,11 +486,31 @@ void LLDrawPoolTerrain::renderFullShaderPBR(bool local_materials) LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); // - // Alpha Ramp + // Alpha Ramp or paint map // - S32 alpha_ramp = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_ALPHARAMP); - gGL.getTexUnit(alpha_ramp)->bind(m2DAlphaRampImagep); - gGL.getTexUnit(alpha_ramp)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + S32 alpha_ramp = -1; + S32 paint_map = -1; + if (paint_type == TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE) + { + alpha_ramp = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_ALPHARAMP); + gGL.getTexUnit(alpha_ramp)->bind(m2DAlphaRampImagep); + gGL.getTexUnit(alpha_ramp)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + } + else if (paint_type == TERRAIN_PAINT_TYPE_PBR_PAINTMAP) + { + paint_map = sShader->enableTexture(LLViewerShaderMgr::TERRAIN_PAINTMAP); + LLViewerTexture* tex_paint_map = use_local_materials ? gLocalTerrainMaterials.getPaintMap() : compp->getPaintMap(); + // If no paintmap is available, fall back to rendering just material slot 1 (by binding the appropriate image) + if (!tex_paint_map) { tex_paint_map = LLViewerTexture::sBlackImagep.get(); } + // This is a paint map for four materials, but we save a channel by + // storing the paintmap as the "difference" between slot 1 and the + // other 3 slots. + llassert(tex_paint_map->getComponents() == 3); + gGL.getTexUnit(paint_map)->bind(tex_paint_map); + gGL.getTexUnit(paint_map)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + + shader->uniform1f(LLShaderMgr::REGION_SCALE, regionp->getWidth()); + } // // GLTF uniforms @@ -534,11 +559,22 @@ void LLDrawPoolTerrain::renderFullShaderPBR(bool local_materials) // Disable multitexture - sShader->disableTexture(LLViewerShaderMgr::TERRAIN_ALPHARAMP); + if (paint_type == TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE) + { + sShader->disableTexture(LLViewerShaderMgr::TERRAIN_ALPHARAMP); - gGL.getTexUnit(alpha_ramp)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(alpha_ramp)->disable(); - gGL.getTexUnit(alpha_ramp)->activate(); + gGL.getTexUnit(alpha_ramp)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(alpha_ramp)->disable(); + gGL.getTexUnit(alpha_ramp)->activate(); + } + else if (paint_type == TERRAIN_PAINT_TYPE_PBR_PAINTMAP) + { + sShader->disableTexture(LLViewerShaderMgr::TERRAIN_PAINTMAP); + + gGL.getTexUnit(paint_map)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(paint_map)->disable(); + gGL.getTexUnit(paint_map)->activate(); + } for (U32 i = 0; i < terrain_material_count; ++i) { diff --git a/indra/newview/lldrawpoolterrain.h b/indra/newview/lldrawpoolterrain.h index a8097fb58b..5380463d01 100644 --- a/indra/newview/lldrawpoolterrain.h +++ b/indra/newview/lldrawpoolterrain.h @@ -38,7 +38,6 @@ public: VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TANGENT | // Only PBR terrain uses this currently - LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1 }; @@ -80,7 +79,7 @@ protected: void renderFull4TU(); void renderFullShader(); void renderFullShaderTextures(); - void renderFullShaderPBR(bool local_materials = false); + void renderFullShaderPBR(bool use_local_materials = false); void drawLoop(); private: diff --git a/indra/newview/llsurface.h b/indra/newview/llsurface.h index 68295225b6..10a104730b 100644 --- a/indra/newview/llsurface.h +++ b/indra/newview/llsurface.h @@ -110,6 +110,7 @@ public: LLSurfacePatch *resolvePatchRegion(const F32 x, const F32 y) const; LLSurfacePatch *resolvePatchRegion(const LLVector3 &position_region) const; LLSurfacePatch *resolvePatchGlobal(const LLVector3d &position_global) const; + LLSurfacePatch *getPatch(const S32 x, const S32 y) const; // Update methods (called during idle, normally) template @@ -176,8 +177,6 @@ protected: void createPatchData(); // Allocates memory for patches. void destroyPatchData(); // Deallocates memory for patches. - LLSurfacePatch *getPatch(const S32 x, const S32 y) const; - protected: LLVector3d mOriginGlobal; // In absolute frame LLSurfacePatch *mPatchList; // Array of all patches diff --git a/indra/newview/llsurfacepatch.cpp b/indra/newview/llsurfacepatch.cpp index 0550889a9b..4315c4c6b0 100644 --- a/indra/newview/llsurfacepatch.cpp +++ b/indra/newview/llsurfacepatch.cpp @@ -201,13 +201,13 @@ LLVector2 LLSurfacePatch::getTexCoords(const U32 x, const U32 y) const void LLSurfacePatch::eval(const U32 x, const U32 y, const U32 stride, LLVector3 *vertex, LLVector3 *normal, - LLVector2 *tex0, LLVector2 *tex1) + LLVector2 *tex1) const { if (!mSurfacep || !mSurfacep->getRegion() || !mSurfacep->getGridsPerEdge() || !mVObjp) { return; // failsafe } - llassert_always(vertex && normal && tex0 && tex1); + llassert_always(vertex && normal && tex1); U32 surface_stride = mSurfacep->getGridsPerEdge(); U32 point_offset = x + y*surface_stride; @@ -220,12 +220,6 @@ void LLSurfacePatch::eval(const U32 x, const U32 y, const U32 stride, LLVector3 pos_agent.mV[VZ] = *(mDataZ + point_offset); *vertex = pos_agent-mVObjp->getRegion()->getOriginAgent(); - LLVector3 rel_pos = pos_agent - mSurfacep->getOriginAgent(); - // *NOTE: Only PBR terrain uses the UVs right now. Texture terrain just ignores it. - // *NOTE: In the future, UVs and horizontal position will no longer have a 1:1 relationship for PBR terrain - LLVector3 tex_pos = rel_pos; - tex0->mV[0] = tex_pos.mV[0]; - tex0->mV[1] = tex_pos.mV[1]; tex1->mV[0] = mSurfacep->getRegion()->getCompositionXY(llfloor(mOriginRegion.mV[0])+x, llfloor(mOriginRegion.mV[1])+y); const F32 xyScale = 4.9215f*7.f; //0.93284f; diff --git a/indra/newview/llsurfacepatch.h b/indra/newview/llsurfacepatch.h index 195250d2c0..f4831487c1 100644 --- a/indra/newview/llsurfacepatch.h +++ b/indra/newview/llsurfacepatch.h @@ -116,7 +116,7 @@ public: void calcNormalFlat(LLVector3& normal_out, const U32 x, const U32 y, const U32 index /* 0 or 1 */); void eval(const U32 x, const U32 y, const U32 stride, - LLVector3 *vertex, LLVector3 *normal, LLVector2 *tex0, LLVector2 *tex1); + LLVector3 *vertex, LLVector3 *normal, LLVector2 *tex1) const; @@ -146,6 +146,8 @@ public: void dirty(); // Mark this surface patch as dirty... void clearDirty() { mDirty = false; } + bool isHeightsGenerated() const { return mHeightsGenerated; } + void clearVObj(); public: diff --git a/indra/newview/llterrainpaintmap.cpp b/indra/newview/llterrainpaintmap.cpp new file mode 100644 index 0000000000..4381d14546 --- /dev/null +++ b/indra/newview/llterrainpaintmap.cpp @@ -0,0 +1,285 @@ +/** + * @file llterrainpaintmap.cpp + * @brief Utilities for managing terrain paint maps + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llterrainpaintmap.h" + +#include "llviewerprecompiledheaders.h" + +// library includes +#include "llglslshader.h" +#include "llrendertarget.h" +#include "llvertexbuffer.h" + +// newview includes +#include "llrender.h" +#include "llsurface.h" +#include "llsurfacepatch.h" +#include "llviewercamera.h" +#include "llviewerregion.h" +#include "llviewershadermgr.h" +#include "llviewertexture.h" + +// static +bool LLTerrainPaintMap::bakeHeightNoiseIntoPBRPaintMapRGB(const LLViewerRegion& region, LLViewerTexture& tex) +{ + llassert(tex.getComponents() == 3); + llassert(tex.getWidth() > 0 && tex.getHeight() > 0); + llassert(tex.getWidth() == tex.getHeight()); + llassert(tex.getPrimaryFormat() == GL_RGB); + llassert(tex.getGLTexture()); + + const LLSurface& surface = region.getLand(); + const U32 patch_count = surface.getPatchesPerEdge(); + + // *TODO: mHeightsGenerated isn't guaranteed to be true. Assume terrain is + // loaded for now. Would be nice to fix the loading issue or find a better + // heuristic to determine that the terrain is sufficiently loaded. +#if 0 + // Don't proceed if the region heightmap isn't loaded + for (U32 rj = 0; rj < patch_count; ++rj) + { + for (U32 ri = 0; ri < patch_count; ++ri) + { + const LLSurfacePatch* patch = surface.getPatch(ri, rj); + if (!patch->isHeightsGenerated()) + { + LL_WARNS() << "Region heightmap not fully loaded" << LL_ENDL; + return false; + } + } + } +#endif + + // Bind the debug shader and render terrain to tex + // Use a scratch render target because its dimensions may exceed the standard bake target, and this is a one-off bake + LLRenderTarget scratch_target; + const S32 dim = llmin(tex.getWidth(), tex.getHeight()); + scratch_target.allocate(dim, dim, GL_RGB, false, LLTexUnit::eTextureType::TT_TEXTURE, + LLTexUnit::eTextureMipGeneration::TMG_NONE); + if (!scratch_target.isComplete()) + { + llassert(false); + LL_WARNS() << "Failed to allocate render target" << LL_ENDL; + return false; + } + gGL.getTexUnit(0)->disable(); + stop_glerror(); + + scratch_target.bindTarget(); + glClearColor(0, 0, 0, 0); + scratch_target.clear(); + + // Render terrain heightmap to paint map via shader + + // Set up viewport, camera, and orthographic projection matrix. Position + // the camera such that the camera points straight down, and the region + // completely covers the "screen". Since orthographic projection does not + // distort, we arbitrarily choose the near plane and far plane to cover the + // full span of region heights, plus a small amount of padding to account + // for rounding errors. + const F32 region_width = region.getWidth(); + const F32 region_half_width = region_width / 2.0f; + const F32 region_camera_height = surface.getMaxZ() + DEFAULT_NEAR_PLANE; + LLViewerCamera camera; + const LLVector3 region_center = LLVector3(region_half_width, region_half_width, 0.0) + region.getOriginAgent(); + const LLVector3 camera_origin = LLVector3(0.0f, 0.0f, region_camera_height) + region_center; + camera.lookAt(camera_origin, region_center, LLVector3::y_axis); + camera.setAspect(F32(scratch_target.getHeight()) / F32(scratch_target.getWidth())); + const LLRect texture_rect(0, scratch_target.getHeight(), scratch_target.getWidth(), 0); + glViewport(texture_rect.mLeft, texture_rect.mBottom, texture_rect.getWidth(), texture_rect.getHeight()); + // Manually get modelview matrix from camera orientation. + glh::matrix4f modelview((GLfloat *) OGL_TO_CFR_ROTATION); + GLfloat ogl_matrix[16]; + camera.getOpenGLTransform(ogl_matrix); + modelview *= glh::matrix4f(ogl_matrix); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.loadMatrix(modelview.m); + // Override the projection matrix from the camera + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + llassert(camera_origin.mV[VZ] >= surface.getMaxZ()); + const F32 region_high_near = camera_origin.mV[VZ] - surface.getMaxZ(); + constexpr F32 far_plane_delta = 0.25f; + const F32 region_low_far = camera_origin.mV[VZ] - surface.getMinZ() + far_plane_delta; + gGL.ortho(-region_half_width, region_half_width, -region_half_width, region_half_width, region_high_near, region_low_far); + // No need to call camera.setPerspective because we don't need the clip planes. It would be inaccurate due to the perspective rendering anyway. + + // Need to get the full resolution vertices in order to get an accurate + // paintmap. It's not sufficient to iterate over the surface patches, as + // they may be at lower LODs. + // The functionality here is a subset of + // LLVOSurfacePatch::getTerrainGeometry. Unlike said function, we don't + // care about stride length since we're always rendering at full + // resolution. We also don't care about normals/tangents because those + // don't contribute to the paintmap. + // *NOTE: The actual getTerrainGeometry fits the terrain vertices snugly + // under the 16-bit indices limit. For the sake of simplicity, that has not + // been replicated here. + std::vector> infos; + // Vertex and index counts adapted from LLVOSurfacePatch::getGeomSizesMain, + // with additional vertices added as we are including the north and east + // edges here. + const U32 patch_size = (U32)surface.getGridsPerPatchEdge(); + constexpr U32 stride = 1; + const U32 vert_size = (patch_size / stride) + 1; + const U32 n = vert_size * vert_size; + const U32 ni = 6 * (vert_size - 1) * (vert_size - 1); + const U32 region_vertices = n * patch_count * patch_count; + const U32 region_indices = ni * patch_count * patch_count; + if (LLGLSLShader::sCurBoundShaderPtr == nullptr) + { // make sure a shader is bound to satisfy mVertexBuffer->setBuffer + gDebugProgram.bind(); + } + LLPointer buf = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD1); + { + buf->allocateBuffer(region_vertices, region_indices*2); // hack double index count... TODO: find a better way to indicate 32-bit indices will be used + buf->setBuffer(); + U32 vertex_total = 0; + std::vector index_array(region_indices); + std::vector positions(region_vertices); + std::vector texcoords1(region_vertices); + auto idx = index_array.begin(); + auto pos = positions.begin(); + auto tex1 = texcoords1.begin(); + for (U32 rj = 0; rj < patch_count; ++rj) + { + for (U32 ri = 0; ri < patch_count; ++ri) + { + const U32 index_offset = vertex_total; + for (U32 j = 0; j < (vert_size - 1); ++j) + { + for (U32 i = 0; i < (vert_size - 1); ++i) + { + // y + // 2....3 + // ^ . . + // | 0....1 + // | + // -------> x + // + // triangle 1: 0,1,2 + // triangle 2: 1,3,2 + // 0: vert0 + // 1: vert0 + 1 + // 2: vert0 + vert_size + // 3: vert0 + vert_size + 1 + const U32 vert0 = index_offset + i + (j*vert_size); + *idx++ = vert0; + *idx++ = vert0 + 1; + *idx++ = vert0 + vert_size; + *idx++ = vert0 + 1; + *idx++ = vert0 + vert_size + 1; + *idx++ = vert0 + vert_size; + } + } + + const LLSurfacePatch* patch = surface.getPatch(ri, rj); + for (U32 j = 0; j < vert_size; ++j) + { + for (U32 i = 0; i < vert_size; ++i) + { + LLVector3 scratch3; + LLVector3 pos3; + LLVector2 tex1_temp; + patch->eval(i, j, stride, &pos3, &scratch3, &tex1_temp); + (*pos++).set(pos3.mV[VX], pos3.mV[VY], pos3.mV[VZ]); + *tex1++ = tex1_temp; + vertex_total++; + } + } + } + } + buf->setIndexData(index_array.data(), 0, (U32)index_array.size()); + buf->setPositionData(positions.data(), 0, (U32)positions.size()); + buf->setTexCoord1Data(texcoords1.data(), 0, (U32)texcoords1.size()); + buf->unmapBuffer(); + buf->unbind(); + } + + // Draw the region in agent space at full resolution + { + + LLGLSLShader::unbind(); + // *NOTE: A theoretical non-PBR terrain bake program would be + // *slightly* different, due the texture terrain shader not having an + // alpha ramp threshold (TERRAIN_RAMP_MIX_THRESHOLD) + LLGLSLShader& shader = gPBRTerrainBakeProgram; + shader.bind(); + + LLGLDisable stencil(GL_STENCIL_TEST); + LLGLDisable scissor(GL_SCISSOR_TEST); + LLGLEnable cull_face(GL_CULL_FACE); + LLGLDepthTest depth_test(GL_FALSE, GL_FALSE, GL_ALWAYS); + + S32 alpha_ramp = shader.enableTexture(LLViewerShaderMgr::TERRAIN_ALPHARAMP); + LLPointer alpha_ramp_texture = LLViewerTextureManager::getFetchedTexture(IMG_ALPHA_GRAD_2D); + gGL.getTexUnit(alpha_ramp)->bind(alpha_ramp_texture); + gGL.getTexUnit(alpha_ramp)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + + buf->setBuffer(); + for (U32 rj = 0; rj < patch_count; ++rj) + { + for (U32 ri = 0; ri < patch_count; ++ri) + { + const U32 patch_index = ri + (rj * patch_count); + const U32 index_offset = ni * patch_index; + const U32 vertex_offset = n * patch_index; + llassert(index_offset + ni <= region_indices); + llassert(vertex_offset + n <= region_vertices); + buf->drawRange(LLRender::TRIANGLES, vertex_offset, vertex_offset + n - 1, ni, index_offset); + } + } + + shader.disableTexture(LLViewerShaderMgr::TERRAIN_ALPHARAMP); + + gGL.getTexUnit(alpha_ramp)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(alpha_ramp)->disable(); + gGL.getTexUnit(alpha_ramp)->activate(); + + shader.unbind(); + } + + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + + gGL.flush(); + LLVertexBuffer::unbind(); + // Final step: Copy the output to the terrain paintmap + const bool success = tex.getGLTexture()->setSubImageFromFrameBuffer(0, 0, 0, 0, dim, dim); + if (!success) + { + LL_WARNS() << "Failed to copy framebuffer to paintmap" << LL_ENDL; + } + glGenerateMipmap(GL_TEXTURE_2D); + stop_glerror(); + + scratch_target.flush(); + + LLGLSLShader::unbind(); + + return success; +} diff --git a/indra/newview/llterrainpaintmap.h b/indra/newview/llterrainpaintmap.h new file mode 100644 index 0000000000..66827862c5 --- /dev/null +++ b/indra/newview/llterrainpaintmap.h @@ -0,0 +1,42 @@ +/** + * @file llterrainpaintmap.h + * @brief Utilities for managing terrain paint maps + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#pragma once + +class LLViewerRegion; +class LLViewerTexture; + +class LLTerrainPaintMap +{ +public: + + // Convert a region's heightmap and composition into a paint map texture which + // approximates how the terrain would be rendered with the heightmap. + // In effect, this allows converting terrain of type TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE + // to type TERRAIN_PAINT_TYPE_PBR_PAINTMAP. + // Returns true if successful + static bool bakeHeightNoiseIntoPBRPaintMapRGB(const LLViewerRegion& region, LLViewerTexture& tex); +}; diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 0e1f4c09c7..c1bf31ff9a 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -719,6 +719,8 @@ void handleLocalTerrainChanged(const LLSD& newValue) { gLocalTerrainMaterials.setMaterialOverride(i, mat_override); } + const bool paint_enabled = gSavedSettings.getBOOL("LocalTerrainPaintEnabled"); + gLocalTerrainMaterials.setPaintType(paint_enabled ? TERRAIN_PAINT_TYPE_PBR_PAINTMAP : TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE); } } //////////////////////////////////////////////////////////////////////////// @@ -909,6 +911,7 @@ void settings_setup_listeners() setting_setup_signal_listener(gSavedSettings, "AutoTuneImpostorByDistEnabled", handleUserImpostorByDistEnabledChanged); setting_setup_signal_listener(gSavedSettings, "TuningFPSStrategy", handleFPSTuningStrategyChanged); { + setting_setup_signal_listener(gSavedSettings, "LocalTerrainPaintEnabled", handleLocalTerrainChanged); const char* transform_suffixes[] = { "ScaleU", "ScaleV", @@ -927,6 +930,7 @@ void settings_setup_listeners() } } } + setting_setup_signal_listener(gSavedSettings, "TerrainPaintBitDepth", handleSetShaderChanged); setting_setup_signal_listener(gSavedPerAccountSettings, "AvatarHoverOffsetZ", handleAvatarHoverOffsetChanged); } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 0c8dd6dff9..aa14820d55 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -42,6 +42,7 @@ #include "llnotifications.h" #include "llnotificationsutil.h" #include "llviewereventrecorder.h" +#include "v4coloru.h" // newview includes #include "llagent.h" @@ -105,6 +106,7 @@ #include "llsidepanelappearance.h" #include "llspellcheckmenuhandler.h" #include "llstatusbar.h" +#include "llterrainpaintmap.h" #include "lltextureview.h" #include "lltoolbarview.h" #include "lltoolcomp.h" @@ -122,6 +124,7 @@ #include "llviewerparcelmgr.h" #include "llviewerstats.h" #include "llviewerstatsrecorder.h" +#include "llvlcomposition.h" #include "llvoavatarself.h" #include "llvoicevivox.h" #include "llworld.h" @@ -1387,6 +1390,65 @@ class LLAdvancedResetInterestLists : public view_listener_t }; +///////////// +// TERRAIN // +///////////// + +class LLAdvancedRebuildTerrain : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + gPipeline.rebuildTerrain(); + return true; + } +}; + +class LLAdvancedTerrainCreateLocalPaintMap : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + LLViewerRegion* region = gAgent.getRegion(); + if (!region) + { + LL_WARNS() << "Agent not in a region" << LL_ENDL; + return false; + } + + U16 dim = (U16)gSavedSettings.getU32("TerrainPaintResolution"); + // Ensure a reasonable image size of power two + const U32 max_resolution = gSavedSettings.getU32("RenderMaxTextureResolution"); + dim = llclamp(dim, 16, max_resolution); + dim = 1 << U32(std::ceil(std::log2(dim))); + LLPointer image_raw = new LLImageRaw(dim,dim,3); + LLPointer tex = LLViewerTextureManager::getLocalTexture(image_raw.get(), true); + const bool success = LLTerrainPaintMap::bakeHeightNoiseIntoPBRPaintMapRGB(*region, *tex); + // This calls gLocalTerrainMaterials.setPaintType + gSavedSettings.setBOOL("LocalTerrainPaintEnabled", true); + // If baking the paintmap failed, set the paintmap to nullptr. This + // causes LLDrawPoolTerrain to use a blank paintmap instead. + if (!success) { tex = nullptr; } + gLocalTerrainMaterials.setPaintMap(tex); + + return true; + } +}; + +class LLAdvancedTerrainDeleteLocalPaintMap : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + // This calls gLocalTerrainMaterials.setPaintType + gSavedSettings.setBOOL("LocalTerrainPaintEnabled", false); + gLocalTerrainMaterials.setPaintMap(nullptr); + + return true; + } +}; + + +///////////// + + class LLAdvancedBuyCurrencyTest : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -2242,20 +2304,6 @@ class LLAdvancedPurgeShaderCache : public view_listener_t } }; -///////////////////// -// REBUILD TERRAIN // -///////////////////// - - -class LLAdvancedRebuildTerrain : public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - gPipeline.rebuildTerrain(); - return true; - } -}; - //////////////////// // EVENT Recorder // /////////////////// @@ -9851,7 +9899,6 @@ void initialize_menus() view_listener_t::addMenu(new LLAdvancedClickGLTFEdit(), "Advanced.ClickGLTFEdit"); view_listener_t::addMenu(new LLAdvancedClickResizeWindow(), "Advanced.ClickResizeWindow"); view_listener_t::addMenu(new LLAdvancedPurgeShaderCache(), "Advanced.ClearShaderCache"); - view_listener_t::addMenu(new LLAdvancedRebuildTerrain(), "Advanced.RebuildTerrain"); #ifdef TOGGLE_HACKED_GODLIKE_VIEWER view_listener_t::addMenu(new LLAdvancedHandleToggleHackedGodmode(), "Advanced.HandleToggleHackedGodmode"); @@ -9868,6 +9915,11 @@ void initialize_menus() view_listener_t::addMenu(new LLAdvancedCheckInterestList360Mode(), "Advanced.CheckInterestList360Mode"); view_listener_t::addMenu(new LLAdvancedResetInterestLists(), "Advanced.ResetInterestLists"); + // Develop > Terrain + view_listener_t::addMenu(new LLAdvancedRebuildTerrain(), "Advanced.RebuildTerrain"); + view_listener_t::addMenu(new LLAdvancedTerrainCreateLocalPaintMap(), "Advanced.TerrainCreateLocalPaintMap"); + view_listener_t::addMenu(new LLAdvancedTerrainDeleteLocalPaintMap(), "Advanced.TerrainDeleteLocalPaintMap"); + // Advanced > UI commit.add("Advanced.WebBrowserTest", boost::bind(&handle_web_browser_test, _2)); // sigh! this one opens the MEDIA browser commit.add("Advanced.WebContentTest", boost::bind(&handle_web_content_test, _2)); // this one opens the Web Content floater diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 96354ea18f..073a1787d5 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -100,6 +100,7 @@ LLGLSLShader gBenchmarkProgram; LLGLSLShader gReflectionProbeDisplayProgram; LLGLSLShader gCopyProgram; LLGLSLShader gCopyDepthProgram; +LLGLSLShader gPBRTerrainBakeProgram; //object shaders LLGLSLShader gObjectPreviewProgram; @@ -226,7 +227,7 @@ LLGLSLShader gDeferredSkinnedPBROpaqueProgram; LLGLSLShader gHUDPBRAlphaProgram; LLGLSLShader gDeferredPBRAlphaProgram; LLGLSLShader gDeferredSkinnedPBRAlphaProgram; -LLGLSLShader gDeferredPBRTerrainProgram; +LLGLSLShader gDeferredPBRTerrainProgram[TERRAIN_PAINT_TYPE_COUNT]; LLGLSLShader gGLTFPBRMetallicRoughnessProgram; @@ -432,7 +433,10 @@ void LLViewerShaderMgr::finalizeShaderList() mShaderList.push_back(&gGLTFPBRMetallicRoughnessProgram); mShaderList.push_back(&gDeferredAvatarProgram); mShaderList.push_back(&gDeferredTerrainProgram); - mShaderList.push_back(&gDeferredPBRTerrainProgram); + for (U32 paint_type = 0; paint_type < TERRAIN_PAINT_TYPE_COUNT; ++paint_type) + { + mShaderList.push_back(&gDeferredPBRTerrainProgram[paint_type]); + } mShaderList.push_back(&gDeferredDiffuseAlphaMaskProgram); mShaderList.push_back(&gDeferredNonIndexedDiffuseAlphaMaskProgram); mShaderList.push_back(&gDeferredTreeProgram); @@ -1129,7 +1133,10 @@ bool LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedPBROpaqueProgram.unload(); gDeferredPBRAlphaProgram.unload(); gDeferredSkinnedPBRAlphaProgram.unload(); - gDeferredPBRTerrainProgram.unload(); + for (U32 paint_type = 0; paint_type < TERRAIN_PAINT_TYPE_COUNT; ++paint_type) + { + gDeferredPBRTerrainProgram[paint_type].unload(); + } return true; } @@ -1443,25 +1450,31 @@ bool LLViewerShaderMgr::loadShadersDeferred() S32 detail = gSavedSettings.getS32("RenderTerrainPBRDetail"); detail = llclamp(detail, TERRAIN_PBR_DETAIL_MIN, TERRAIN_PBR_DETAIL_MAX); const S32 mapping = clamp_terrain_mapping(gSavedSettings.getS32("RenderTerrainPBRPlanarSampleCount")); - gDeferredPBRTerrainProgram.mName = llformat("Deferred PBR Terrain Shader %d %s", - detail, - (mapping == 1 ? "flat" : "triplanar")); - gDeferredPBRTerrainProgram.mFeatures.hasSrgb = true; - gDeferredPBRTerrainProgram.mFeatures.isAlphaLighting = true; - gDeferredPBRTerrainProgram.mFeatures.calculatesAtmospherics = true; - gDeferredPBRTerrainProgram.mFeatures.hasAtmospherics = true; - gDeferredPBRTerrainProgram.mFeatures.hasGamma = true; - gDeferredPBRTerrainProgram.mFeatures.hasTransport = true; - gDeferredPBRTerrainProgram.mFeatures.isPBRTerrain = true; + for (U32 paint_type = 0; paint_type < TERRAIN_PAINT_TYPE_COUNT; ++paint_type) + { + LLGLSLShader* shader = &gDeferredPBRTerrainProgram[paint_type]; + shader->mName = llformat("Deferred PBR Terrain Shader %d %s %s", + detail, + (paint_type == TERRAIN_PAINT_TYPE_PBR_PAINTMAP ? "paintmap" : "heightmap-with-noise"), + (mapping == 1 ? "flat" : "triplanar")); + shader->mFeatures.hasSrgb = true; + shader->mFeatures.isAlphaLighting = true; + shader->mFeatures.calculatesAtmospherics = true; + shader->mFeatures.hasAtmospherics = true; + shader->mFeatures.hasGamma = true; + shader->mFeatures.hasTransport = true; + shader->mFeatures.isPBRTerrain = true; - gDeferredPBRTerrainProgram.mShaderFiles.clear(); - gDeferredPBRTerrainProgram.mShaderFiles.push_back(make_pair("deferred/pbrterrainV.glsl", GL_VERTEX_SHADER)); - gDeferredPBRTerrainProgram.mShaderFiles.push_back(make_pair("deferred/pbrterrainF.glsl", GL_FRAGMENT_SHADER)); - gDeferredPBRTerrainProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; - gDeferredPBRTerrainProgram.addPermutation("TERRAIN_PBR_DETAIL", llformat("%d", detail)); - gDeferredPBRTerrainProgram.addPermutation("TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT", llformat("%d", mapping)); - success = gDeferredPBRTerrainProgram.createShader(); - llassert(success); + shader->mShaderFiles.clear(); + shader->mShaderFiles.push_back(make_pair("deferred/pbrterrainV.glsl", GL_VERTEX_SHADER)); + shader->mShaderFiles.push_back(make_pair("deferred/pbrterrainF.glsl", GL_FRAGMENT_SHADER)); + shader->mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + shader->addPermutation("TERRAIN_PBR_DETAIL", llformat("%d", detail)); + shader->addPermutation("TERRAIN_PAINT_TYPE", llformat("%d", paint_type)); + shader->addPermutation("TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT", llformat("%d", mapping)); + success = success && shader->createShader(); + llassert(success); + } } if (success) @@ -2957,6 +2970,25 @@ bool LLViewerShaderMgr::loadShadersInterface() success = gCopyDepthProgram.createShader(); } + if (success) + { + LLGLSLShader* shader = &gPBRTerrainBakeProgram; + U32 bit_depth = gSavedSettings.getU32("TerrainPaintBitDepth"); + // LLTerrainPaintMap currently uses an RGB8 texture internally + bit_depth = llclamp(bit_depth, 1, 8); + shader->mName = llformat("Terrain Bake Shader RGB%o", bit_depth); + shader->mFeatures.isPBRTerrain = true; + + shader->mShaderFiles.clear(); + shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeV.glsl", GL_VERTEX_SHADER)); + shader->mShaderFiles.push_back(make_pair("interface/pbrTerrainBakeF.glsl", GL_FRAGMENT_SHADER)); + shader->mShaderLevel = mShaderLevel[SHADER_INTERFACE]; + const U32 value_range = (1 << bit_depth) - 1; + shader->addPermutation("TERRAIN_PAINT_PRECISION", llformat("%d", value_range)); + success = success && shader->createShader(); + llassert(success); + } + if (success) { gAlphaMaskProgram.mName = "Alpha Mask Shader"; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 60ce8c430b..af47014a43 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -174,6 +174,7 @@ extern LLGLSLShader gBenchmarkProgram; extern LLGLSLShader gReflectionProbeDisplayProgram; extern LLGLSLShader gCopyProgram; extern LLGLSLShader gCopyDepthProgram; +extern LLGLSLShader gPBRTerrainBakeProgram; //output tex0[tc0] - tex1[tc1] extern LLGLSLShader gTwoTextureCompareProgram; @@ -304,5 +305,13 @@ enum TerrainPBRDetail : S32 TERRAIN_PBR_DETAIL_BASE_COLOR = -4, TERRAIN_PBR_DETAIL_MIN = -4, }; -extern LLGLSLShader gDeferredPBRTerrainProgram; +enum TerrainPaintType : U32 +{ + // Use LLVLComposition::mDatap (heightmap) generated by generateHeights, plus noise from TERRAIN_ALPHARAMP + TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE = 0, + // Use paint map if PBR terrain, otherwise fall back to TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE + TERRAIN_PAINT_TYPE_PBR_PAINTMAP = 1, + TERRAIN_PAINT_TYPE_COUNT = 2, +}; +extern LLGLSLShader gDeferredPBRTerrainProgram[TERRAIN_PAINT_TYPE_COUNT]; #endif diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 9648a9af18..1369e3d306 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -42,6 +42,7 @@ #include "llstl.h" #include "message.h" #include "lltimer.h" +#include "v4coloru.h" // viewer includes #include "llimagegl.h" diff --git a/indra/newview/llvlcomposition.cpp b/indra/newview/llvlcomposition.cpp index f5f058a080..077e6e6cb1 100644 --- a/indra/newview/llvlcomposition.cpp +++ b/indra/newview/llvlcomposition.cpp @@ -312,6 +312,17 @@ bool LLTerrainMaterials::makeMaterialsReady(bool boost, bool strict) return one_ready; } +LLViewerTexture* LLTerrainMaterials::getPaintMap() +{ + return mPaintMap.get(); +} + +void LLTerrainMaterials::setPaintMap(LLViewerTexture* paint_map) +{ + llassert(!paint_map || mPaintType == TERRAIN_PAINT_TYPE_PBR_PAINTMAP); + mPaintMap = paint_map; +} + // Boost the texture loading priority // Return true when ready to use (i.e. texture is sufficiently loaded) // static diff --git a/indra/newview/llvlcomposition.h b/indra/newview/llvlcomposition.h index 2637d77183..f15f9bff6a 100644 --- a/indra/newview/llvlcomposition.h +++ b/indra/newview/llvlcomposition.h @@ -28,6 +28,8 @@ #define LL_LLVLCOMPOSITION_H #include "llviewerlayer.h" +#include "llviewershadermgr.h" +#include "llviewertexture.h" #include "llpointer.h" #include "llimage.h" @@ -44,6 +46,7 @@ public: virtual const LLGLTFMaterial* getMaterialOverride(S32 asset) const = 0; }; +// The subset of the composition used by local terrain debug materials (gLocalTerrainMaterials) class LLTerrainMaterials : public LLModifyRegion { public: @@ -79,6 +82,12 @@ public: // strict = false -> at least one material must be loaded bool makeMaterialsReady(bool boost, bool strict); + // See TerrainPaintType + U32 getPaintType() const { return mPaintType; } + void setPaintType(U32 paint_type) { mPaintType = paint_type; } + LLViewerTexture* getPaintMap(); + void setPaintMap(LLViewerTexture* paint_map); + protected: void unboost(); static bool makeTextureReady(LLPointer& tex, bool boost); @@ -93,6 +102,9 @@ protected: LLPointer mDetailMaterialOverrides[ASSET_COUNT]; LLPointer mDetailRenderMaterials[ASSET_COUNT]; bool mMaterialTexturesSet[ASSET_COUNT]; + + U32 mPaintType = TERRAIN_PAINT_TYPE_HEIGHTMAP_WITH_NOISE; + LLPointer mPaintMap; }; // Local materials to override all regions diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index 471174cf5d..b76717e660 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -245,7 +245,6 @@ bool LLVOSurfacePatch::updateLOD() void LLVOSurfacePatch::getTerrainGeometry(LLStrider &verticesp, LLStrider &normalsp, - LLStrider &texCoords0p, LLStrider &texCoords1p, LLStrider &indicesp) { @@ -260,21 +259,18 @@ void LLVOSurfacePatch::getTerrainGeometry(LLStrider &verticesp, updateMainGeometry(facep, verticesp, normalsp, - texCoords0p, texCoords1p, indicesp, index_offset); updateNorthGeometry(facep, verticesp, normalsp, - texCoords0p, texCoords1p, indicesp, index_offset); updateEastGeometry(facep, verticesp, normalsp, - texCoords0p, texCoords1p, indicesp, index_offset); @@ -283,7 +279,6 @@ void LLVOSurfacePatch::getTerrainGeometry(LLStrider &verticesp, void LLVOSurfacePatch::updateMainGeometry(LLFace *facep, LLStrider &verticesp, LLStrider &normalsp, - LLStrider &texCoords0p, LLStrider &texCoords1p, LLStrider &indicesp, U32 &index_offset) @@ -322,10 +317,9 @@ void LLVOSurfacePatch::updateMainGeometry(LLFace *facep, { x = i * render_stride; y = j * render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } } @@ -387,7 +381,6 @@ void LLVOSurfacePatch::updateMainGeometry(LLFace *facep, void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, LLStrider &verticesp, LLStrider &normalsp, - LLStrider &texCoords0p, LLStrider &texCoords1p, LLStrider &indicesp, U32 &index_offset) @@ -421,10 +414,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, x = i * render_stride; y = 16 - render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -433,10 +425,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, { x = i * render_stride; y = 16; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -469,10 +460,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, x = i * render_stride; y = 16 - render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -482,10 +472,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, x = i * render_stride; y = 16; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -525,10 +514,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, x = i * north_stride; y = 16 - render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -538,10 +526,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, x = i * north_stride; y = 16; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -577,7 +564,6 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, LLStrider &verticesp, LLStrider &normalsp, - LLStrider &texCoords0p, LLStrider &texCoords1p, LLStrider &indicesp, U32 &index_offset) @@ -606,10 +592,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, x = 16 - render_stride; y = i * render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -618,10 +603,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, { x = 16; y = i * render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -654,10 +638,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, x = 16 - render_stride; y = i * render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } // Iterate through the east patch's points @@ -666,10 +649,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, x = 16; y = i * render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -708,10 +690,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, x = 16 - render_stride; y = i * east_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } // Iterate through the east patch's points @@ -720,10 +701,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, x = 16; y = i * east_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -992,8 +972,8 @@ void gen_terrain_tangents(U16 strider_vertex_count, LLStrider &verticesp, LLStrider &normalsp, LLStrider &tangentsp, - LLStrider &texCoords0p, - LLStrider &indicesp) + LLStrider &indicesp, + F32 region_width) { LL_PROFILE_ZONE_SCOPED; @@ -1010,7 +990,10 @@ void gen_terrain_tangents(U16 strider_vertex_count, F32 *n = normalsp[v].mV; normals[v] = LLVector4a(n[0], n[1], n[2], 1.f); tangents[v] = tangentsp[v]; - texcoords[v] = texCoords0p[v]; + + // Calculate texcoords on-the-fly using the terrain positions + texcoords[v].mV[VX] = verticesp[v].mV[VX] / region_width; + texcoords[v].mV[VY] = verticesp[v].mV[VY] / region_width; } for (U32 i = 0; i < strider_index_count; ++i) { @@ -1039,14 +1022,12 @@ void LLTerrainPartition::getGeometry(LLSpatialGroup* group) LLStrider vertices_start; LLStrider normals_start; LLStrider tangents_start; - LLStrider texcoords_start; LLStrider texcoords2_start; LLStrider indices_start; llassert_always(buffer->getVertexStrider(vertices_start)); llassert_always(buffer->getNormalStrider(normals_start)); llassert_always(buffer->getTangentStrider(tangents_start)); - llassert_always(buffer->getTexCoord0Strider(texcoords_start)); llassert_always(buffer->getTexCoord1Strider(texcoords2_start)); llassert_always(buffer->getIndexStrider(indices_start)); @@ -1056,7 +1037,6 @@ void LLTerrainPartition::getGeometry(LLSpatialGroup* group) { LLStrider vertices = vertices_start; LLStrider normals = normals_start; - LLStrider texcoords = texcoords_start; LLStrider texcoords2 = texcoords2_start; LLStrider indices = indices_start; @@ -1069,7 +1049,7 @@ void LLTerrainPartition::getGeometry(LLSpatialGroup* group) facep->setVertexBuffer(buffer); LLVOSurfacePatch* patchp = (LLVOSurfacePatch*) facep->getViewerObject(); - patchp->getTerrainGeometry(vertices, normals, texcoords, texcoords2, indices); + patchp->getTerrainGeometry(vertices, normals, texcoords2, indices); indices_index += facep->getIndicesCount(); index_offset += facep->getGeomCount(); @@ -1082,10 +1062,20 @@ void LLTerrainPartition::getGeometry(LLSpatialGroup* group) LLStrider vertices = vertices_start; LLStrider normals = normals_start; LLStrider tangents = tangents_start; - LLStrider texcoords = texcoords_start; LLStrider indices = indices_start; - gen_terrain_tangents(index_offset, indices_index, vertices, normals, tangents, texcoords, indices); + F32 region_width = 256.0f; + if (mFaceList.empty()) + { + llassert(false); + } + else + { + const LLViewerRegion* regionp = mFaceList[0]->getViewerObject()->getRegion(); + llassert(regionp == mFaceList.back()->getViewerObject()->getRegion()); // Assume this spatial group is confined to one region + region_width = regionp->getWidth(); + } + gen_terrain_tangents(index_offset, indices_index, vertices, normals, tangents, indices, region_width); } buffer->unmapBuffer(); diff --git a/indra/newview/llvosurfacepatch.h b/indra/newview/llvosurfacepatch.h index 2780b97a97..af5f05774b 100644 --- a/indra/newview/llvosurfacepatch.h +++ b/indra/newview/llvosurfacepatch.h @@ -41,14 +41,6 @@ class LLVOSurfacePatch : public LLStaticViewerObject public: static F32 sLODFactor; - enum - { - VERTEX_DATA_MASK = (1 << LLVertexBuffer::TYPE_VERTEX) | - (1 << LLVertexBuffer::TYPE_NORMAL) | - (1 << LLVertexBuffer::TYPE_TEXCOORD0) | - (1 << LLVertexBuffer::TYPE_TEXCOORD1) - }; - LLVOSurfacePatch(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp); /*virtual*/ void markDead(); @@ -65,7 +57,6 @@ public: /*virtual*/ void updateFaceSize(S32 idx); void getTerrainGeometry(LLStrider &verticesp, LLStrider &normalsp, - LLStrider &texCoords0p, LLStrider &texCoords1p, LLStrider &indicesp); @@ -118,21 +109,18 @@ protected: void updateMainGeometry(LLFace *facep, LLStrider &verticesp, LLStrider &normalsp, - LLStrider &texCoords0p, LLStrider &texCoords1p, LLStrider &indicesp, U32 &index_offset); void updateNorthGeometry(LLFace *facep, LLStrider &verticesp, LLStrider &normalsp, - LLStrider &texCoords0p, LLStrider &texCoords1p, LLStrider &indicesp, U32 &index_offset); void updateEastGeometry(LLFace *facep, LLStrider &verticesp, LLStrider &normalsp, - LLStrider &texCoords0p, LLStrider &texCoords1p, LLStrider &indicesp, U32 &index_offset); diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 941f0c6bb7..98cf03b30e 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -3435,13 +3435,6 @@ function="World.EnvPreset" - - - + + + + + + + + + + + + + + + Date: Wed, 7 Aug 2024 08:23:47 +0200 Subject: #1922 Make PBR scale and offset crosshair work (fix callbacks in LLPanelFace) --- indra/newview/llpanelface.cpp | 944 +++++++++++++++++------------------------- indra/newview/llpanelface.h | 302 +++++++------- 2 files changed, 530 insertions(+), 716 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 0afe967839..f01d327fb4 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -240,10 +240,10 @@ LLUUID LLPanelFace::getCurrentNormalMap() { return mBumpyTextureCtrl-> LLUUID LLPanelFace::getCurrentSpecularMap() { return mShinyTextureCtrl->getImageAssetID(); } U32 LLPanelFace::getCurrentShininess() { return getChild("combobox shininess")->getCurrentIndex(); } U32 LLPanelFace::getCurrentBumpiness() { return getChild("combobox bumpiness")->getCurrentIndex(); } -U8 LLPanelFace::getCurrentDiffuseAlphaMode() { return (U8)getChild("combobox alphamode")->getCurrentIndex(); } -U8 LLPanelFace::getCurrentAlphaMaskCutoff() { return (U8)getChild("maskcutoff")->getValue().asInteger(); } -U8 LLPanelFace::getCurrentEnvIntensity() { return (U8)getChild("environment")->getValue().asInteger(); } -U8 LLPanelFace::getCurrentGlossiness() { return (U8)getChild("glossiness")->getValue().asInteger(); } +U8 LLPanelFace::getCurrentDiffuseAlphaMode() { return (U8)getChild("combobox alphamode")->getCurrentIndex(); } +U8 LLPanelFace::getCurrentAlphaMaskCutoff() { return (U8)getChild("maskcutoff")->getValue().asInteger(); } +U8 LLPanelFace::getCurrentEnvIntensity() { return (U8)getChild("environment")->getValue().asInteger(); } +U8 LLPanelFace::getCurrentGlossiness() { return (U8)getChild("glossiness")->getValue().asInteger(); } F32 LLPanelFace::getCurrentBumpyRot() { return (F32)getChild("bumpyRot")->getValue().asReal(); } F32 LLPanelFace::getCurrentBumpyScaleU() { return (F32)getChild("bumpyScaleU")->getValue().asReal(); } F32 LLPanelFace::getCurrentBumpyScaleV() { return (F32)getChild("bumpyScaleV")->getValue().asReal(); } @@ -259,49 +259,49 @@ F32 LLPanelFace::getCurrentShinyOffsetV() { return (F32)getChild("gltfTextureScaleU")->setCommitCallback(boost::bind(&LLPanelFace::onCommitGLTFTextureScaleU, this, _1), nullptr); - getChild("gltfTextureScaleV")->setCommitCallback(boost::bind(&LLPanelFace::onCommitGLTFTextureScaleV, this, _1), nullptr); - getChild("gltfTextureRotation")->setCommitCallback(boost::bind(&LLPanelFace::onCommitGLTFRotation, this, _1), nullptr); - getChild("gltfTextureOffsetU")->setCommitCallback(boost::bind(&LLPanelFace::onCommitGLTFTextureOffsetU, this, _1), nullptr); - getChild("gltfTextureOffsetV")->setCommitCallback(boost::bind(&LLPanelFace::onCommitGLTFTextureOffsetV, this, _1), nullptr); +bool LLPanelFace::postBuild() +{ + childSetCommitCallback("combobox shininess", [&](LLUICtrl*, const void*) { onCommitShiny(); }, 0); + childSetCommitCallback("combobox bumpiness", [&](LLUICtrl*, const void*) { onCommitBump(); }, 0); + childSetCommitCallback("combobox alphamode", [&](LLUICtrl*, const void*) { onCommitAlphaMode(); }, 0); + childSetCommitCallback("TexScaleU", [&](LLUICtrl*, const void*) { onCommitTextureScaleX(); }, 0); + childSetCommitCallback("TexScaleV", [&](LLUICtrl*, const void*) { onCommitTextureScaleY(); }, 0); + childSetCommitCallback("TexRot", [&](LLUICtrl*, const void*) { onCommitTextureRot(); }, 0); + childSetCommitCallback("rptctrl", [&](LLUICtrl*, const void*) { onCommitRepeatsPerMeter(); }, 0); + childSetCommitCallback("checkbox planar align", [&](LLUICtrl*, const void*) { onCommitPlanarAlign(); }, 0); + childSetCommitCallback("TexOffsetU", [&](LLUICtrl*, const void*) { onCommitTextureOffsetX(); }, 0); + childSetCommitCallback("TexOffsetV", [&](LLUICtrl*, const void*) { onCommitTextureOffsetY(); }, 0); + + childSetCommitCallback("bumpyScaleU", [&](LLUICtrl*, const void*) { onCommitMaterialBumpyScaleX(); }, 0); + childSetCommitCallback("bumpyScaleV", [&](LLUICtrl*, const void*) { onCommitMaterialBumpyScaleY(); }, 0); + childSetCommitCallback("bumpyRot", [&](LLUICtrl*, const void*) { onCommitMaterialBumpyRot(); }, 0); + childSetCommitCallback("bumpyOffsetU", [&](LLUICtrl*, const void*) { onCommitMaterialBumpyOffsetX(); }, 0); + childSetCommitCallback("bumpyOffsetV", [&](LLUICtrl*, const void*) { onCommitMaterialBumpyOffsetY(); }, 0); + childSetCommitCallback("shinyScaleU", [&](LLUICtrl*, const void*) { onCommitMaterialShinyScaleX(); }, 0); + childSetCommitCallback("shinyScaleV", [&](LLUICtrl*, const void*) { onCommitMaterialShinyScaleY(); }, 0); + childSetCommitCallback("shinyRot", [&](LLUICtrl*, const void*) { onCommitMaterialShinyRot(); }, 0); + childSetCommitCallback("shinyOffsetU", [&](LLUICtrl*, const void*) { onCommitMaterialShinyOffsetX(); }, 0); + childSetCommitCallback("shinyOffsetV", [&](LLUICtrl*, const void*) { onCommitMaterialShinyOffsetY(); }, 0); + childSetCommitCallback("glossiness", [&](LLUICtrl*, const void*) { onCommitMaterialGloss(); }, 0); + childSetCommitCallback("environment", [&](LLUICtrl*, const void*) { onCommitMaterialEnv(); }, 0); + childSetCommitCallback("maskcutoff", [&](LLUICtrl*, const void*) { onCommitMaterialMaskCutoff(); }, 0); + childSetCommitCallback("add_media", [&](LLUICtrl*, const void*) { onClickBtnAddMedia(); }, 0); + childSetCommitCallback("delete_media", [&](LLUICtrl*, const void*) { onClickBtnDeleteMedia(); }, 0); + + childSetCommitCallback("gltfTextureScaleU", [&](LLUICtrl*, const void*) { onCommitGLTFTextureScaleU(); }, 0); + childSetCommitCallback("gltfTextureScaleV", [&](LLUICtrl*, const void*) { onCommitGLTFTextureScaleV(); }, 0); + childSetCommitCallback("gltfTextureRotation", [&](LLUICtrl*, const void*) { onCommitGLTFRotation(); }, 0); + childSetCommitCallback("gltfTextureOffsetU", [&](LLUICtrl*, const void*) { onCommitGLTFTextureOffsetU(); }, 0); + childSetCommitCallback("gltfTextureOffsetV", [&](LLUICtrl*, const void*) { onCommitGLTFTextureOffsetV(); }, 0); LLGLTFMaterialList::addSelectionUpdateCallback(&LLPanelFace::onMaterialOverrideReceived); sMaterialOverrideSelection.connect(); - childSetAction("button align",&LLPanelFace::onClickAutoFix,this); - childSetAction("button align textures", &LLPanelFace::onAlignTexture, this); - childSetAction("pbr_from_inventory", &LLPanelFace::onClickBtnLoadInvPBR, this); - childSetAction("edit_selected_pbr", &LLPanelFace::onClickBtnEditPBR, this); - childSetAction("save_selected_pbr", &LLPanelFace::onClickBtnSavePBR, this); + childSetAction("button align", [&](LLUICtrl*, const LLSD&) { onClickAutoFix(); }); + childSetAction("button align textures", [&](LLUICtrl*, const LLSD&) { onAlignTexture(); }); + childSetAction("pbr_from_inventory", [&](LLUICtrl*, const LLSD&) { onClickBtnLoadInvPBR(); }); + childSetAction("edit_selected_pbr", [&](LLUICtrl*, const LLSD&) { onClickBtnEditPBR(); }); + childSetAction("save_selected_pbr", [&](LLUICtrl*, const LLSD&) { onClickBtnSavePBR(); }); setMouseOpaque(false); @@ -310,12 +310,12 @@ bool LLPanelFace::postBuild() { mPBRTextureCtrl->setDefaultImageAssetID(LLUUID::null); mPBRTextureCtrl->setBlankImageAssetID(BLANK_MATERIAL_ASSET_ID); - mPBRTextureCtrl->setCommitCallback(boost::bind(&LLPanelFace::onCommitPbr, this, _2)); - mPBRTextureCtrl->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelPbr, this, _2)); - mPBRTextureCtrl->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectPbr, this, _2)); - mPBRTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragPbr, this, _2)); - mPBRTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onPbrSelectionChanged, this, _1)); - mPBRTextureCtrl->setOnCloseCallback(boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2)); + mPBRTextureCtrl->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitPbr(); }); + mPBRTextureCtrl->setOnCancelCallback([&](LLUICtrl*, const LLSD&) { onCancelPbr(); }); + mPBRTextureCtrl->setOnSelectCallback([&](LLUICtrl*, const LLSD&) { onSelectPbr(); }); + mPBRTextureCtrl->setDragCallback([&](LLUICtrl*, LLInventoryItem* item) { return onDragPbr(item); }); + mPBRTextureCtrl->setOnTextureSelectedCallback([&](LLInventoryItem* item) { onPbrSelectionChanged(item); }); + mPBRTextureCtrl->setOnCloseCallback([&](LLUICtrl*, const LLSD& data) { onCloseTexturePicker(data); }); mPBRTextureCtrl->setFollowsTop(); mPBRTextureCtrl->setFollowsLeft(); @@ -326,15 +326,15 @@ bool LLPanelFace::postBuild() } mTextureCtrl = getChild("texture control"); - if(mTextureCtrl) + if (mTextureCtrl) { mTextureCtrl->setDefaultImageAssetID(DEFAULT_OBJECT_TEXTURE); - mTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitTexture, this, _2) ); - mTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelTexture, this, _2) ); - mTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectTexture, this, _2) ); - mTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2)); - mTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1)); - mTextureCtrl->setOnCloseCallback( boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2) ); + mTextureCtrl->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitTexture(); }); + mTextureCtrl->setOnCancelCallback([&](LLUICtrl*, const LLSD&) { onCancelTexture(); }); + mTextureCtrl->setOnSelectCallback([&](LLUICtrl*, const LLSD&) { onSelectTexture(); }); + mTextureCtrl->setDragCallback([&](LLUICtrl*, LLInventoryItem* item) { return onDragTexture(item); }); + mTextureCtrl->setOnTextureSelectedCallback([&](LLInventoryItem* item) { onTextureSelectionChanged(item); }); + mTextureCtrl->setOnCloseCallback([&](LLUICtrl*, const LLSD& data) { onCloseTexturePicker(data); }); mTextureCtrl->setFollowsTop(); mTextureCtrl->setFollowsLeft(); @@ -343,16 +343,16 @@ bool LLPanelFace::postBuild() } mShinyTextureCtrl = getChild("shinytexture control"); - if(mShinyTextureCtrl) + if (mShinyTextureCtrl) { mShinyTextureCtrl->setDefaultImageAssetID(DEFAULT_OBJECT_SPECULAR); - mShinyTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitSpecularTexture, this, _2) ); - mShinyTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelSpecularTexture, this, _2) ); - mShinyTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectSpecularTexture, this, _2) ); - mShinyTextureCtrl->setOnCloseCallback( boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2) ); + mShinyTextureCtrl->setCommitCallback([&](LLUICtrl*, const LLSD& data) { onCommitSpecularTexture(data); }); + mShinyTextureCtrl->setOnCancelCallback([&](LLUICtrl*, const LLSD& data) { onCancelSpecularTexture(data); }); + mShinyTextureCtrl->setOnSelectCallback([&](LLUICtrl*, const LLSD& data) { onSelectSpecularTexture(data); }); + mShinyTextureCtrl->setOnCloseCallback([&](LLUICtrl*, const LLSD& data) { onCloseTexturePicker(data); }); - mShinyTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2)); - mShinyTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1)); + mShinyTextureCtrl->setDragCallback([&](LLUICtrl*, LLInventoryItem* item) { return onDragTexture(item); }); + mShinyTextureCtrl->setOnTextureSelectedCallback([&](LLInventoryItem* item) { onTextureSelectionChanged(item); }); mShinyTextureCtrl->setFollowsTop(); mShinyTextureCtrl->setFollowsLeft(); mShinyTextureCtrl->setImmediateFilterPermMask(PERM_NONE); @@ -360,17 +360,17 @@ bool LLPanelFace::postBuild() } mBumpyTextureCtrl = getChild("bumpytexture control"); - if(mBumpyTextureCtrl) + if (mBumpyTextureCtrl) { mBumpyTextureCtrl->setDefaultImageAssetID(DEFAULT_OBJECT_NORMAL); mBumpyTextureCtrl->setBlankImageAssetID(BLANK_OBJECT_NORMAL); - mBumpyTextureCtrl->setCommitCallback( boost::bind(&LLPanelFace::onCommitNormalTexture, this, _2) ); - mBumpyTextureCtrl->setOnCancelCallback( boost::bind(&LLPanelFace::onCancelNormalTexture, this, _2) ); - mBumpyTextureCtrl->setOnSelectCallback( boost::bind(&LLPanelFace::onSelectNormalTexture, this, _2) ); - mBumpyTextureCtrl->setOnCloseCallback( boost::bind(&LLPanelFace::onCloseTexturePicker, this, _2) ); + mBumpyTextureCtrl->setCommitCallback([&](LLUICtrl*, const LLSD& data) { onCommitNormalTexture(data); }); + mBumpyTextureCtrl->setOnCancelCallback([&](LLUICtrl*, const LLSD& data) { onCancelNormalTexture(data); }); + mBumpyTextureCtrl->setOnSelectCallback([&](LLUICtrl*, const LLSD& data) { onSelectNormalTexture(data); }); + mBumpyTextureCtrl->setOnCloseCallback([&](LLUICtrl*, const LLSD& data) { onCloseTexturePicker(data); }); - mBumpyTextureCtrl->setDragCallback(boost::bind(&LLPanelFace::onDragTexture, this, _2)); - mBumpyTextureCtrl->setOnTextureSelectedCallback(boost::bind(&LLPanelFace::onTextureSelectionChanged, this, _1)); + mBumpyTextureCtrl->setDragCallback([&](LLUICtrl*, LLInventoryItem* item) { return onDragTexture(item); }); + mBumpyTextureCtrl->setOnTextureSelectedCallback([&](LLInventoryItem* item) { onTextureSelectionChanged(item); }); mBumpyTextureCtrl->setFollowsTop(); mBumpyTextureCtrl->setFollowsLeft(); mBumpyTextureCtrl->setImmediateFilterPermMask(PERM_NONE); @@ -378,38 +378,38 @@ bool LLPanelFace::postBuild() } mColorSwatch = getChild("colorswatch"); - if(mColorSwatch) + if (mColorSwatch) { - mColorSwatch->setCommitCallback(boost::bind(&LLPanelFace::onCommitColor, this, _2)); - mColorSwatch->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelColor, this, _2)); - mColorSwatch->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectColor, this, _2)); + mColorSwatch->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitColor(); }); + mColorSwatch->setOnCancelCallback([&](LLUICtrl*, const LLSD&) { onCancelColor(); }); + mColorSwatch->setOnSelectCallback([&](LLUICtrl*, const LLSD&) { onSelectColor(); }); mColorSwatch->setFollowsTop(); mColorSwatch->setFollowsLeft(); mColorSwatch->setCanApplyImmediately(true); } mShinyColorSwatch = getChild("shinycolorswatch"); - if(mShinyColorSwatch) + if (mShinyColorSwatch) { - mShinyColorSwatch->setCommitCallback(boost::bind(&LLPanelFace::onCommitShinyColor, this, _2)); - mShinyColorSwatch->setOnCancelCallback(boost::bind(&LLPanelFace::onCancelShinyColor, this, _2)); - mShinyColorSwatch->setOnSelectCallback(boost::bind(&LLPanelFace::onSelectShinyColor, this, _2)); + mShinyColorSwatch->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitShinyColor(); }); + mShinyColorSwatch->setOnCancelCallback([&](LLUICtrl*, const LLSD&) { onCancelShinyColor(); }); + mShinyColorSwatch->setOnSelectCallback([&](LLUICtrl*, const LLSD&) { onSelectShinyColor(); }); mShinyColorSwatch->setFollowsTop(); mShinyColorSwatch->setFollowsLeft(); mShinyColorSwatch->setCanApplyImmediately(true); } mLabelColorTransp = getChild("color trans"); - if(mLabelColorTransp) + if (mLabelColorTransp) { mLabelColorTransp->setFollowsTop(); mLabelColorTransp->setFollowsLeft(); } mCtrlColorTransp = getChild("ColorTrans"); - if(mCtrlColorTransp) + if (mCtrlColorTransp) { - mCtrlColorTransp->setCommitCallback(boost::bind(&LLPanelFace::onCommitAlpha, this, _2)); + mCtrlColorTransp->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitAlpha(); }); mCtrlColorTransp->setPrecision(0); mCtrlColorTransp->setFollowsTop(); mCtrlColorTransp->setFollowsLeft(); @@ -418,41 +418,41 @@ bool LLPanelFace::postBuild() mCheckFullbright = getChild("checkbox fullbright"); if (mCheckFullbright) { - mCheckFullbright->setCommitCallback(LLPanelFace::onCommitFullbright, this); + mCheckFullbright->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitFullbright(); }); } mComboTexGen = getChild("combobox texgen"); - if(mComboTexGen) + if (mComboTexGen) { - mComboTexGen->setCommitCallback(LLPanelFace::onCommitTexGen, this); + mComboTexGen->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitTexGen(); }); mComboTexGen->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP); } mComboMatMedia = getChild("combobox matmedia"); - if(mComboMatMedia) + if (mComboMatMedia) { - mComboMatMedia->setCommitCallback(LLPanelFace::onCommitMaterialsMedia,this); + mComboMatMedia->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitMaterialsMedia(); }); mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL); } mRadioMaterialType = getChild("radio_material_type"); - if(mRadioMaterialType) + if (mRadioMaterialType) { - mRadioMaterialType->setCommitCallback(LLPanelFace::onCommitMaterialType, this); + mRadioMaterialType->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitMaterialType(); }); mRadioMaterialType->selectNthItem(MATTYPE_DIFFUSE); } mRadioPbrType = getChild("radio_pbr_type"); if (mRadioPbrType) { - mRadioPbrType->setCommitCallback(LLPanelFace::onCommitPbrType, this); + mRadioPbrType->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitPbrType(); }); mRadioPbrType->selectNthItem(PBRTYPE_RENDER_MATERIAL_ID); } mCtrlGlow = getChild("glow"); - if(mCtrlGlow) + if (mCtrlGlow) { - mCtrlGlow->setCommitCallback(LLPanelFace::onCommitGlow, this); + mCtrlGlow->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitGlow(); }); } mMenuClipboardColor = getChild("clipboard_color_params_btn"); @@ -534,7 +534,7 @@ void LLPanelFace::sendTexture() void LLPanelFace::sendBump(U32 bumpiness) { if (bumpiness < BUMPY_TEXTURE) -{ + { LL_DEBUGS("Materials") << "clearing bumptexture control" << LL_ENDL; mBumpyTextureCtrl->clear(); mBumpyTextureCtrl->setImageAssetID(LLUUID()); @@ -544,12 +544,13 @@ void LLPanelFace::sendBump(U32 bumpiness) LLUUID current_normal_map = mBumpyTextureCtrl->getImageAssetID(); - U8 bump = (U8) bumpiness & TEM_BUMP_MASK; + U8 bump = (U8)bumpiness & TEM_BUMP_MASK; // Clear legacy bump to None when using an actual normal map - // if (!current_normal_map.isNull()) + { bump = 0; + } // Set the normal map or reset it to null as appropriate // @@ -560,14 +561,14 @@ void LLPanelFace::sendBump(U32 bumpiness) void LLPanelFace::sendTexGen() { - U8 tex_gen = (U8) mComboTexGen->getCurrentIndex() << TEM_TEX_GEN_SHIFT; - LLSelectMgr::getInstance()->selectionSetTexGen( tex_gen ); + U8 tex_gen = (U8)mComboTexGen->getCurrentIndex() << TEM_TEX_GEN_SHIFT; + LLSelectMgr::getInstance()->selectionSetTexGen(tex_gen); } void LLPanelFace::sendShiny(U32 shininess) { if (shininess < SHINY_TEXTURE) -{ + { mShinyTextureCtrl->clear(); mShinyTextureCtrl->setImageAssetID(LLUUID()); } @@ -576,40 +577,38 @@ void LLPanelFace::sendShiny(U32 shininess) U8 shiny = (U8) shininess & TEM_SHINY_MASK; if (!specmap.isNull()) + { shiny = 0; + } LLSelectedTEMaterial::setSpecularID(this, specmap); - LLSelectMgr::getInstance()->selectionSetShiny( shiny, mShinyTextureCtrl->getImageItemID() ); + LLSelectMgr::getInstance()->selectionSetShiny(shiny, mShinyTextureCtrl->getImageItemID()); updateShinyControls(!specmap.isNull(), true); - } void LLPanelFace::sendFullbright() { if(!mCheckFullbright)return; U8 fullbright = mCheckFullbright->get() ? TEM_FULLBRIGHT_MASK : 0; - LLSelectMgr::getInstance()->selectionSetFullbright( fullbright ); + LLSelectMgr::getInstance()->selectionSetFullbright(fullbright); } void LLPanelFace::sendColor() { if(!mColorSwatch)return; LLColor4 color = mColorSwatch->get(); - - LLSelectMgr::getInstance()->selectionSetColorOnly( color ); + LLSelectMgr::getInstance()->selectionSetColorOnly(color); } void LLPanelFace::sendAlpha() { if(!mCtrlColorTransp)return; F32 alpha = (100.f - mCtrlColorTransp->get()) / 100.f; - LLSelectMgr::getInstance()->selectionSetAlphaOnly( alpha ); } - void LLPanelFace::sendGlow() { if (mCtrlGlow) @@ -750,6 +749,7 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor } } } + return true; } private: @@ -906,7 +906,7 @@ struct LLPanelFaceGetIsAlignedTEFunctor : public LLSelectedTEFunctor LLVector2 aligned_st_offset, aligned_st_scale; F32 aligned_st_rot; - if ( facep->calcAlignedPlanarTE(mCenterFace, &aligned_st_offset, &aligned_st_scale, &aligned_st_rot) ) + if (facep->calcAlignedPlanarTE(mCenterFace, &aligned_st_offset, &aligned_st_scale, &aligned_st_rot)) { const LLTextureEntry* tep = facep->getTextureEntry(); LLVector2 st_offset, st_scale; @@ -947,7 +947,7 @@ struct LLPanelFaceSendFunctor : public LLSelectedObjectFunctor void LLPanelFace::sendTextureInfo() { - if ((bool)childGetValue("checkbox planar align").asBoolean()) + if (childGetValue("checkbox planar align").asBoolean()) { LLFace* last_face = NULL; bool identical_face =false; @@ -1322,9 +1322,9 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) if (mShinyTextureCtrl) { - mShinyTextureCtrl->setTentative( !identical_spec ); - mShinyTextureCtrl->setEnabled( editable && !has_pbr_material); - mShinyTextureCtrl->setImageAssetID( specmap_id ); + mShinyTextureCtrl->setTentative(!identical_spec); + mShinyTextureCtrl->setEnabled(editable && !has_pbr_material); + mShinyTextureCtrl->setImageAssetID(specmap_id); if (attachment) { @@ -1338,9 +1338,9 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) if (mBumpyTextureCtrl) { - mBumpyTextureCtrl->setTentative( !identical_norm ); - mBumpyTextureCtrl->setEnabled( editable && !has_pbr_material); - mBumpyTextureCtrl->setImageAssetID( normmap_id ); + mBumpyTextureCtrl->setTentative(!identical_norm); + mBumpyTextureCtrl->setEnabled(editable && !has_pbr_material); + mBumpyTextureCtrl->setImageAssetID(normmap_id); if (attachment) { @@ -1386,10 +1386,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) bool identical_texgen = true; bool identical_planar_texgen = false; - { - LLSelectedTE::getTexGen(selected_texgen, identical_texgen); - identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); - } + LLSelectedTE::getTexGen(selected_texgen, identical_texgen); + identical_planar_texgen = (identical_texgen && (selected_texgen == LLTextureEntry::TEX_GEN_PLANAR)); // Texture scale { @@ -1428,7 +1426,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) bool norm_scale_tentative = !(identical && identical_norm_scale_s); bool spec_scale_tentative = !(identical && identical_spec_scale_s); - getChild("TexScaleU")->setTentative( LLSD(diff_scale_tentative)); + getChild("TexScaleU")->setTentative(LLSD(diff_scale_tentative)); getChild("shinyScaleU")->setTentative(LLSD(spec_scale_tentative)); getChild("bumpyScaleU")->setTentative(LLSD(norm_scale_tentative)); } @@ -1550,9 +1548,9 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) F32 norm_rotation = 0.f; F32 spec_rotation = 0.f; - LLSelectedTE::getRotation(diff_rotation,identical_diff_rotation); - LLSelectedTEMaterial::getSpecularRotation(spec_rotation,identical_spec_rotation); - LLSelectedTEMaterial::getNormalRotation(norm_rotation,identical_norm_rotation); + LLSelectedTE::getRotation(diff_rotation, identical_diff_rotation); + LLSelectedTEMaterial::getSpecularRotation(spec_rotation, identical_spec_rotation); + LLSelectedTEMaterial::getNormalRotation(norm_rotation, identical_norm_rotation); bool diff_rot_tentative = !(align_planar ? identical_planar_aligned : identical_diff_rotation); bool norm_rot_tentative = !(align_planar ? identical_planar_aligned : identical_norm_rotation); @@ -1566,11 +1564,11 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) getChildView("shinyRot")->setEnabled(editable && has_material && specmap_id.notNull()); getChildView("bumpyRot")->setEnabled(editable && has_material && normmap_id.notNull()); - getChild("TexRot")->setTentative(diff_rot_tentative); - getChild("shinyRot")->setTentative(LLSD(norm_rot_tentative)); - getChild("bumpyRot")->setTentative(LLSD(spec_rot_tentative)); + getChild("TexRot")->setTentative(LLSD(diff_rot_tentative)); + getChild("shinyRot")->setTentative(LLSD(spec_rot_tentative)); + getChild("bumpyRot")->setTentative(LLSD(norm_rot_tentative)); - getChild("TexRot")->setValue( editable ? diff_rot_deg : 0.0f); + getChild("TexRot")->setValue(editable ? diff_rot_deg : 0.0f); getChild("shinyRot")->setValue(editable ? spec_rot_deg : 0.0f); getChild("bumpyRot")->setValue(editable ? norm_rot_deg : 0.0f); } @@ -1578,7 +1576,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) { F32 glow = 0.f; bool identical_glow = false; - LLSelectedTE::getGlow(glow,identical_glow); + LLSelectedTE::getGlow(glow, identical_glow); mCtrlGlow->setValue(glow); mCtrlGlow->setTentative(!identical_glow); mCtrlGlow->setEnabled(editable); @@ -1598,7 +1596,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) U8 fullbright_flag = 0; bool identical_fullbright = false; - LLSelectedTE::getFullbright(fullbright_flag,identical_fullbright); + LLSelectedTE::getFullbright(fullbright_flag, identical_fullbright); mCheckFullbright->setValue((S32)(fullbright_flag != 0)); mCheckFullbright->setEnabled(editable && !has_pbr_material); @@ -1625,7 +1623,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) bool enabled = editable && (index != 1); bool identical_repeats = true; S32 material_selection = mComboMatMedia->getCurrentIndex(); - F32 repeats = 1.0f; + F32 repeats = 1.0f; U32 material_type = MATTYPE_DIFFUSE; if (material_selection == MATMEDIA_MATERIAL) @@ -1642,37 +1640,29 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) { default: case MATTYPE_DIFFUSE: - { if (material_selection != MATMEDIA_PBR) { enabled = editable && !id.isNull(); } identical_repeats = identical_diff_repeats; repeats = repeats_diff; - } - break; - + break; case MATTYPE_SPECULAR: - { if (material_selection != MATMEDIA_PBR) { enabled = (editable && ((shiny == SHINY_TEXTURE) && !specmap_id.isNull())); } identical_repeats = identical_spec_repeats; repeats = repeats_spec; - } - break; - + break; case MATTYPE_NORMAL: - { if (material_selection != MATMEDIA_PBR) { enabled = (editable && ((bumpy == BUMPY_TEXTURE) && !normmap_id.isNull())); } identical_repeats = identical_norm_repeats; repeats = repeats_norm; - } - break; + break; } bool repeats_tentative = !identical_repeats; @@ -1724,6 +1714,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) { LL_WARNS() << "failed childGetSelectionInterface for 'combobox alphamode'" << LL_ENDL; } + getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); updateAlphaControls(); @@ -1735,8 +1726,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) if (!material->getSpecularID().isNull() && (shiny == SHINY_TEXTURE)) { - material->getSpecularOffset(offset_x,offset_y); - material->getSpecularRepeat(repeat_x,repeat_y); + material->getSpecularOffset(offset_x, offset_y); + material->getSpecularRepeat(repeat_x, repeat_y); if (identical_planar_texgen) { @@ -1747,7 +1738,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) rot = material->getSpecularRotation(); getChild("shinyScaleU")->setValue(repeat_x); getChild("shinyScaleV")->setValue(repeat_y); - getChild("shinyRot")->setValue(rot*RAD_TO_DEG); + getChild("shinyRot")->setValue(rot * RAD_TO_DEG); getChild("shinyOffsetU")->setValue(offset_x); getChild("shinyOffsetV")->setValue(offset_y); getChild("glossiness")->setValue(material->getSpecularLightExponent()); @@ -1785,7 +1776,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) rot = material->getNormalRotation(); getChild("bumpyScaleU")->setValue(repeat_x); getChild("bumpyScaleV")->setValue(repeat_y); - getChild("bumpyRot")->setValue(rot*RAD_TO_DEG); + getChild("bumpyRot")->setValue(rot * RAD_TO_DEG); getChild("bumpyOffsetU")->setValue(offset_x); getChild("bumpyOffsetV")->setValue(offset_y); @@ -1793,6 +1784,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) } } } + S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); bool single_volume = (selected_count == 1); mMenuClipboardColor->setEnabled(editable && single_volume); @@ -2814,65 +2806,58 @@ void LLPanelFace::updateMediaTitle() }; } -// -// Static functions -// - // static F32 LLPanelFace::valueGlow(LLViewerObject* object, S32 face) { return (F32)(object->getTE(face)->getGlow()); } - -void LLPanelFace::onCommitColor(const LLSD& data) +void LLPanelFace::onCommitColor() { sendColor(); } -void LLPanelFace::onCommitShinyColor(const LLSD& data) +void LLPanelFace::onCommitShinyColor() { LLSelectedTEMaterial::setSpecularLightColor(this, mShinyColorSwatch->get()); } -void LLPanelFace::onCommitAlpha(const LLSD& data) +void LLPanelFace::onCommitAlpha() { sendAlpha(); } -void LLPanelFace::onCancelColor(const LLSD& data) +void LLPanelFace::onCancelColor() { LLSelectMgr::getInstance()->selectionRevertColors(); } -void LLPanelFace::onCancelShinyColor(const LLSD& data) +void LLPanelFace::onCancelShinyColor() { LLSelectMgr::getInstance()->selectionRevertShinyColors(); } -void LLPanelFace::onSelectColor(const LLSD& data) +void LLPanelFace::onSelectColor() { LLSelectMgr::getInstance()->saveSelectedObjectColors(); sendColor(); } -void LLPanelFace::onSelectShinyColor(const LLSD& data) +void LLPanelFace::onSelectShinyColor() { LLSelectedTEMaterial::setSpecularLightColor(this, mShinyColorSwatch->get()); LLSelectMgr::getInstance()->saveSelectedShinyColors(); } -// static -void LLPanelFace::onCommitMaterialsMedia(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialsMedia() { - LLPanelFace* self = (LLPanelFace*) userdata; // Force to default states to side-step problems with menu contents // and generally reflecting old state when switching tabs or objects // - self->updateShinyControls(false,true); - self->updateBumpyControls(false,true); - self->updateUI(); - self->refreshMedia(); + updateShinyControls(false, true); + updateBumpyControls(false, true); + updateUI(); + refreshMedia(); } void LLPanelFace::updateVisibility(LLViewerObject* objectp /* = nullptr */) @@ -2967,62 +2952,42 @@ void LLPanelFace::updateVisibility(LLViewerObject* objectp /* = nullptr */) updateVisibilityGLTF(objectp); } -// static -void LLPanelFace::onCommitMaterialType(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialType() { - LLPanelFace* self = (LLPanelFace*) userdata; // Force to default states to side-step problems with menu contents // and generally reflecting old state when switching tabs or objects // - self->updateShinyControls(false,true); - self->updateBumpyControls(false,true); - self->updateUI(); + updateShinyControls(false, true); + updateBumpyControls(false, true); + updateUI(); } -// static -void LLPanelFace::onCommitPbrType(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitPbrType() { - LLPanelFace* self = (LLPanelFace*)userdata; // Force to default states to side-step problems with menu contents // and generally reflecting old state when switching tabs or objects // - self->updateUI(); + updateUI(); } -// static -void LLPanelFace::onCommitBump(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitBump() { - LLPanelFace* self = (LLPanelFace*) userdata; - - LLComboBox* mComboBumpiness = self->getChild("combobox bumpiness"); - if(!mComboBumpiness) - return; - - U32 bumpiness = mComboBumpiness->getCurrentIndex(); - - self->sendBump(bumpiness); + sendBump(getChild("combobox bumpiness")->getCurrentIndex()); } -// static -void LLPanelFace::onCommitTexGen(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitTexGen() { - LLPanelFace* self = (LLPanelFace*) userdata; - self->sendTexGen(); + sendTexGen(); } -// static void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_shiny_combobox) { LLUUID shiny_texture_ID = mShinyTextureCtrl->getImageAssetID(); LL_DEBUGS("Materials") << "Shiny texture selected: " << shiny_texture_ID << LL_ENDL; LLComboBox* comboShiny = getChild("combobox shininess"); - if(mess_with_shiny_combobox) + if (mess_with_shiny_combobox) { - if (!comboShiny) - { - return; - } if (!shiny_texture_ID.isNull() && is_setting_texture) { if (!comboShiny->itemExists(USE_TEXTURE)) @@ -3042,7 +3007,7 @@ void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_sh } else { - if (shiny_texture_ID.isNull() && comboShiny && comboShiny->itemExists(USE_TEXTURE)) + if (shiny_texture_ID.isNull() && comboShiny->itemExists(USE_TEXTURE)) { comboShiny->remove(SHINY_TEXTURE); comboShiny->selectFirstItem(); @@ -3063,16 +3028,11 @@ void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_sh mShinyColorSwatch->setVisible(show_shinyctrls); } -// static void LLPanelFace::updateBumpyControls(bool is_setting_texture, bool mess_with_combobox) { LLUUID bumpy_texture_ID = mBumpyTextureCtrl->getImageAssetID(); LL_DEBUGS("Materials") << "texture: " << bumpy_texture_ID << (mess_with_combobox ? "" : " do not") << " update combobox" << LL_ENDL; LLComboBox* comboBumpy = getChild("combobox bumpiness"); - if (!comboBumpy) - { - return; - } if (mess_with_combobox) { @@ -3095,43 +3055,18 @@ void LLPanelFace::updateBumpyControls(bool is_setting_texture, bool mess_with_co } } -// static -void LLPanelFace::onCommitShiny(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitShiny() { - LLPanelFace* self = (LLPanelFace*) userdata; - - - LLComboBox* mComboShininess = self->getChild("combobox shininess"); - if(!mComboShininess) - return; - - U32 shininess = mComboShininess->getCurrentIndex(); - - self->sendShiny(shininess); + sendShiny(getChild("combobox shininess")->getCurrentIndex()); } -// static void LLPanelFace::updateAlphaControls() { - LLComboBox* comboAlphaMode = getChild("combobox alphamode"); - if (!comboAlphaMode) - { - return; - } - U32 alpha_value = comboAlphaMode->getCurrentIndex(); + U32 alpha_value = getChild("combobox alphamode")->getCurrentIndex(); bool show_alphactrls = (alpha_value == ALPHAMODE_MASK); // Alpha masking - U32 mat_media = MATMEDIA_MATERIAL; - if (mComboMatMedia) - { - mat_media = mComboMatMedia->getCurrentIndex(); - } - - U32 mat_type = MATTYPE_DIFFUSE; - if(mRadioMaterialType) - { - mat_type = mRadioMaterialType->getSelectedIndex(); - } + U32 mat_media = mComboMatMedia->getCurrentIndex(); + U32 mat_type = mRadioMaterialType->getSelectedIndex(); show_alphactrls = show_alphactrls && (mat_media == MATMEDIA_MATERIAL); show_alphactrls = show_alphactrls && (mat_type == MATTYPE_DIFFUSE); @@ -3140,30 +3075,23 @@ void LLPanelFace::updateAlphaControls() getChildView("maskcutoff")->setVisible(show_alphactrls); } -// static -void LLPanelFace::onCommitAlphaMode(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitAlphaMode() { - LLPanelFace* self = (LLPanelFace*) userdata; - self->updateAlphaControls(); - LLSelectedTEMaterial::setDiffuseAlphaMode(self,self->getCurrentDiffuseAlphaMode()); + updateAlphaControls(); + LLSelectedTEMaterial::setDiffuseAlphaMode(this, getCurrentDiffuseAlphaMode()); } -// static -void LLPanelFace::onCommitFullbright(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitFullbright() { - LLPanelFace* self = (LLPanelFace*) userdata; - self->sendFullbright(); + sendFullbright(); } -// static -void LLPanelFace::onCommitGlow(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitGlow() { - LLPanelFace* self = (LLPanelFace*) userdata; - self->sendGlow(); + sendGlow(); } -// static -bool LLPanelFace::onDragPbr(LLUICtrl*, LLInventoryItem* item) +bool LLPanelFace::onDragPbr(LLInventoryItem* item) { bool accept = true; for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); @@ -3180,9 +3108,8 @@ bool LLPanelFace::onDragPbr(LLUICtrl*, LLInventoryItem* item) return accept; } -void LLPanelFace::onCommitPbr(const LLSD& data) +void LLPanelFace::onCommitPbr() { - if (!mPBRTextureCtrl) return; if (!mPBRTextureCtrl->getTentative()) { // we grab the item id first, because we want to do a @@ -3200,16 +3127,15 @@ void LLPanelFace::onCommitPbr(const LLSD& data) } } -void LLPanelFace::onCancelPbr(const LLSD& data) +void LLPanelFace::onCancelPbr() { LLSelectMgr::getInstance()->selectionRevertGLTFMaterials(); } -void LLPanelFace::onSelectPbr(const LLSD& data) +void LLPanelFace::onSelectPbr() { LLSelectMgr::getInstance()->saveSelectedObjectTextures(); - if (!mPBRTextureCtrl) return; if (!mPBRTextureCtrl->getTentative()) { // we grab the item id first, because we want to do a @@ -3226,8 +3152,7 @@ void LLPanelFace::onSelectPbr(const LLSD& data) } } -// static -bool LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item) +bool LLPanelFace::onDragTexture(LLInventoryItem* item) { bool accept = true; for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin(); @@ -3244,18 +3169,18 @@ bool LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item) return accept; } -void LLPanelFace::onCommitTexture( const LLSD& data ) +void LLPanelFace::onCommitTexture() { add(LLStatViewer::EDIT_TEXTURE, 1); sendTexture(); } -void LLPanelFace::onCancelTexture(const LLSD& data) +void LLPanelFace::onCancelTexture() { LLSelectMgr::getInstance()->selectionRevertTextures(); } -void LLPanelFace::onSelectTexture(const LLSD& data) +void LLPanelFace::onSelectTexture() { LLSelectMgr::getInstance()->saveSelectedObjectTextures(); sendTexture(); @@ -3265,31 +3190,25 @@ void LLPanelFace::onSelectTexture(const LLSD& data) bool missing_asset = false; LLSelectedTE::getImageFormat(image_format, identical_image_format, missing_asset); - LLCtrlSelectionInterface* combobox_alphamode = - childGetSelectionInterface("combobox alphamode"); - U32 alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE; - if (combobox_alphamode && !missing_asset) + if (!missing_asset) { switch (image_format) { case GL_RGBA: case GL_ALPHA: - { - alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_BLEND; - } + alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_BLEND; + break; + case GL_RGB: break; - - case GL_RGB: break; default: - { - LL_WARNS() << "Unexpected tex format in LLPanelFace...resorting to no alpha" << LL_ENDL; - } + LL_WARNS() << "Unexpected tex format in LLPanelFace...resorting to no alpha" << LL_ENDL; break; } - combobox_alphamode->selectNthItem(alpha_mode); + childGetSelectionInterface("combobox alphamode")->selectNthItem(alpha_mode); } + LLSelectedTEMaterial::setDiffuseAlphaMode(this, getCurrentDiffuseAlphaMode()); } @@ -3299,13 +3218,13 @@ void LLPanelFace::onCloseTexturePicker(const LLSD& data) updateUI(); } -void LLPanelFace::onCommitSpecularTexture( const LLSD& data ) +void LLPanelFace::onCommitSpecularTexture(const LLSD& data) { LL_DEBUGS("Materials") << data << LL_ENDL; sendShiny(SHINY_TEXTURE); } -void LLPanelFace::onCommitNormalTexture( const LLSD& data ) +void LLPanelFace::onCommitNormalTexture(const LLSD& data) { LL_DEBUGS("Materials") << data << LL_ENDL; LLUUID nmap_id = getCurrentNormalMap(); @@ -3348,34 +3267,32 @@ void LLPanelFace::onSelectNormalTexture(const LLSD& data) ////////////////////////////////////////////////////////////////////////////// // called when a user wants to edit existing media settings on a prim or prim face // TODO: test if there is media on the item and only allow editing if present -void LLPanelFace::onClickBtnEditMedia(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onClickBtnEditMedia() { - LLPanelFace* self = (LLPanelFace*)userdata; - self->refreshMedia(); + refreshMedia(); LLFloaterReg::showInstance("media_settings"); } ////////////////////////////////////////////////////////////////////////////// // called when a user wants to delete media from a prim or prim face -void LLPanelFace::onClickBtnDeleteMedia(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onClickBtnDeleteMedia() { LLNotificationsUtil::add("DeleteMedia", LLSD(), LLSD(), deleteMediaConfirm); } ////////////////////////////////////////////////////////////////////////////// // called when a user wants to add media to a prim or prim face -void LLPanelFace::onClickBtnAddMedia(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onClickBtnAddMedia() { // check if multiple faces are selected if (LLSelectMgr::getInstance()->getSelection()->isMultipleTESelected()) { - LLPanelFace* self = (LLPanelFace*)userdata; - self->refreshMedia(); + refreshMedia(); LLNotificationsUtil::add("MultipleFacesSelected", LLSD(), LLSD(), multipleFacesSelectedConfirm); } else { - onClickBtnEditMedia(ctrl, userdata); + onClickBtnEditMedia(); } } @@ -3416,396 +3333,316 @@ bool LLPanelFace::multipleFacesSelectedConfirm(const LLSD& notification, const L return false; } -//static -void LLPanelFace::syncOffsetX(LLPanelFace* self, F32 offsetU) +void LLPanelFace::syncOffsetX(F32 offsetU) { - LLSelectedTEMaterial::setNormalOffsetX(self,offsetU); - LLSelectedTEMaterial::setSpecularOffsetX(self,offsetU); - self->getChild("TexOffsetU")->forceSetValue(offsetU); - self->sendTextureInfo(); + LLSelectedTEMaterial::setNormalOffsetX(this, offsetU); + LLSelectedTEMaterial::setSpecularOffsetX(this, offsetU); + getChild("TexOffsetU")->forceSetValue(LLSD(offsetU)); + sendTextureInfo(); } -//static -void LLPanelFace::syncOffsetY(LLPanelFace* self, F32 offsetV) +void LLPanelFace::syncOffsetY(F32 offsetV) { - LLSelectedTEMaterial::setNormalOffsetY(self,offsetV); - LLSelectedTEMaterial::setSpecularOffsetY(self,offsetV); - self->getChild("TexOffsetV")->forceSetValue(offsetV); - self->sendTextureInfo(); + LLSelectedTEMaterial::setNormalOffsetY(this, offsetV); + LLSelectedTEMaterial::setSpecularOffsetY(this, offsetV); + getChild("TexOffsetV")->forceSetValue(LLSD(offsetV)); + sendTextureInfo(); } -//static -void LLPanelFace::onCommitMaterialBumpyOffsetX(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialBumpyOffsetX() { - LLPanelFace* self = (LLPanelFace*) userdata; - llassert_always(self); - if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - syncOffsetX(self,self->getCurrentBumpyOffsetU()); + syncOffsetX(getCurrentBumpyOffsetU()); } else { - LLSelectedTEMaterial::setNormalOffsetX(self,self->getCurrentBumpyOffsetU()); + LLSelectedTEMaterial::setNormalOffsetX(this, getCurrentBumpyOffsetU()); } - } -//static -void LLPanelFace::onCommitMaterialBumpyOffsetY(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialBumpyOffsetY() { - LLPanelFace* self = (LLPanelFace*) userdata; - llassert_always(self); - if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - syncOffsetY(self,self->getCurrentBumpyOffsetV()); + syncOffsetY(getCurrentBumpyOffsetV()); } else { - LLSelectedTEMaterial::setNormalOffsetY(self,self->getCurrentBumpyOffsetV()); + LLSelectedTEMaterial::setNormalOffsetY(this, getCurrentBumpyOffsetV()); } } -//static -void LLPanelFace::onCommitMaterialShinyOffsetX(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialShinyOffsetX() { - LLPanelFace* self = (LLPanelFace*) userdata; - llassert_always(self); - if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - syncOffsetX(self, self->getCurrentShinyOffsetU()); + syncOffsetX(getCurrentShinyOffsetU()); } else { - LLSelectedTEMaterial::setSpecularOffsetX(self,self->getCurrentShinyOffsetU()); + LLSelectedTEMaterial::setSpecularOffsetX(this, getCurrentShinyOffsetU()); } } -//static -void LLPanelFace::onCommitMaterialShinyOffsetY(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialShinyOffsetY() { - LLPanelFace* self = (LLPanelFace*) userdata; - llassert_always(self); - if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - syncOffsetY(self,self->getCurrentShinyOffsetV()); + syncOffsetY(getCurrentShinyOffsetV()); } else { - LLSelectedTEMaterial::setSpecularOffsetY(self,self->getCurrentShinyOffsetV()); + LLSelectedTEMaterial::setSpecularOffsetY(this, getCurrentShinyOffsetV()); } } -//static -void LLPanelFace::syncRepeatX(LLPanelFace* self, F32 scaleU) +void LLPanelFace::syncRepeatX(F32 scaleU) { - LLSelectedTEMaterial::setNormalRepeatX(self,scaleU); - LLSelectedTEMaterial::setSpecularRepeatX(self,scaleU); - self->sendTextureInfo(); + LLSelectedTEMaterial::setNormalRepeatX(this, scaleU); + LLSelectedTEMaterial::setSpecularRepeatX(this, scaleU); + sendTextureInfo(); } -//static -void LLPanelFace::syncRepeatY(LLPanelFace* self, F32 scaleV) +void LLPanelFace::syncRepeatY(F32 scaleV) { - LLSelectedTEMaterial::setNormalRepeatY(self,scaleV); - LLSelectedTEMaterial::setSpecularRepeatY(self,scaleV); - self->sendTextureInfo(); + LLSelectedTEMaterial::setNormalRepeatY(this, scaleV); + LLSelectedTEMaterial::setSpecularRepeatY(this, scaleV); + sendTextureInfo(); } -//static -void LLPanelFace::onCommitMaterialBumpyScaleX(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialBumpyScaleX() { - LLPanelFace* self = (LLPanelFace*) userdata; - llassert_always(self); - F32 bumpy_scale_u = self->getCurrentBumpyScaleU(); - if (self->isIdenticalPlanarTexgen()) + F32 bumpy_scale_u = getCurrentBumpyScaleU(); + if (isIdenticalPlanarTexgen()) { bumpy_scale_u *= 0.5f; } if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - self->getChild("TexScaleU")->forceSetValue(self->getCurrentBumpyScaleU()); - syncRepeatX(self, bumpy_scale_u); + getChild("TexScaleU")->forceSetValue(getCurrentBumpyScaleU()); + syncRepeatX(bumpy_scale_u); } else { - LLSelectedTEMaterial::setNormalRepeatX(self,bumpy_scale_u); + LLSelectedTEMaterial::setNormalRepeatX(this, bumpy_scale_u); } } -//static -void LLPanelFace::onCommitMaterialBumpyScaleY(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialBumpyScaleY() { - LLPanelFace* self = (LLPanelFace*) userdata; - llassert_always(self); - F32 bumpy_scale_v = self->getCurrentBumpyScaleV(); - if (self->isIdenticalPlanarTexgen()) + F32 bumpy_scale_v = getCurrentBumpyScaleV(); + if (isIdenticalPlanarTexgen()) { bumpy_scale_v *= 0.5f; } - if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - self->getChild("TexScaleV")->forceSetValue(self->getCurrentBumpyScaleV()); - syncRepeatY(self, bumpy_scale_v); + getChild("TexScaleV")->forceSetValue(getCurrentBumpyScaleV()); + syncRepeatY(bumpy_scale_v); } else { - LLSelectedTEMaterial::setNormalRepeatY(self,bumpy_scale_v); + LLSelectedTEMaterial::setNormalRepeatY(this, bumpy_scale_v); } } -//static -void LLPanelFace::onCommitMaterialShinyScaleX(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialShinyScaleX() { - LLPanelFace* self = (LLPanelFace*) userdata; - llassert_always(self); - F32 shiny_scale_u = self->getCurrentShinyScaleU(); - if (self->isIdenticalPlanarTexgen()) + F32 shiny_scale_u = getCurrentShinyScaleU(); + if (isIdenticalPlanarTexgen()) { shiny_scale_u *= 0.5f; } if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - self->getChild("TexScaleU")->forceSetValue(self->getCurrentShinyScaleU()); - syncRepeatX(self, shiny_scale_u); + getChild("TexScaleU")->forceSetValue(LLSD(getCurrentShinyScaleU())); + syncRepeatX(shiny_scale_u); } else { - LLSelectedTEMaterial::setSpecularRepeatX(self,shiny_scale_u); + LLSelectedTEMaterial::setSpecularRepeatX(this, shiny_scale_u); } } -//static -void LLPanelFace::onCommitMaterialShinyScaleY(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialShinyScaleY() { - LLPanelFace* self = (LLPanelFace*) userdata; - llassert_always(self); - F32 shiny_scale_v = self->getCurrentShinyScaleV(); - if (self->isIdenticalPlanarTexgen()) + F32 shiny_scale_v = getCurrentShinyScaleV(); + if (isIdenticalPlanarTexgen()) { shiny_scale_v *= 0.5f; } if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - self->getChild("TexScaleV")->forceSetValue(self->getCurrentShinyScaleV()); - syncRepeatY(self, shiny_scale_v); + getChild("TexScaleV")->forceSetValue(LLSD(getCurrentShinyScaleV())); + syncRepeatY(shiny_scale_v); } else { - LLSelectedTEMaterial::setSpecularRepeatY(self,shiny_scale_v); + LLSelectedTEMaterial::setSpecularRepeatY(this, shiny_scale_v); } } -//static -void LLPanelFace::syncMaterialRot(LLPanelFace* self, F32 rot, int te) +void LLPanelFace::syncMaterialRot(F32 rot, int te) { - LLSelectedTEMaterial::setNormalRotation(self,rot * DEG_TO_RAD, te); - LLSelectedTEMaterial::setSpecularRotation(self,rot * DEG_TO_RAD, te); - self->sendTextureInfo(); + LLSelectedTEMaterial::setNormalRotation(this, rot * DEG_TO_RAD, te); + LLSelectedTEMaterial::setSpecularRotation(this, rot * DEG_TO_RAD, te); + sendTextureInfo(); } -//static -void LLPanelFace::onCommitMaterialBumpyRot(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialBumpyRot() { - LLPanelFace* self = (LLPanelFace*) userdata; - llassert_always(self); - if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - self->getChild("TexRot")->forceSetValue(self->getCurrentBumpyRot()); - syncMaterialRot(self, self->getCurrentBumpyRot()); + getChild("TexRot")->forceSetValue(LLSD(getCurrentBumpyRot())); + syncMaterialRot(getCurrentBumpyRot()); } else { - if ((bool)self->childGetValue("checkbox planar align").asBoolean()) + if (childGetValue("checkbox planar align").asBoolean()) { LLFace* last_face = NULL; bool identical_face = false; LLSelectedTE::getFace(last_face, identical_face); - LLPanelFaceSetAlignedTEFunctor setfunc(self, last_face); + LLPanelFaceSetAlignedTEFunctor setfunc(this, last_face); LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc); } else { - LLSelectedTEMaterial::setNormalRotation(self, self->getCurrentBumpyRot() * DEG_TO_RAD); + LLSelectedTEMaterial::setNormalRotation(this, getCurrentBumpyRot() * DEG_TO_RAD); } } } -//static -void LLPanelFace::onCommitMaterialShinyRot(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialShinyRot() { - LLPanelFace* self = (LLPanelFace*) userdata; - llassert_always(self); - if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - self->getChild("TexRot")->forceSetValue(self->getCurrentShinyRot()); - syncMaterialRot(self, self->getCurrentShinyRot()); + getChild("TexRot")->forceSetValue(LLSD(getCurrentShinyRot())); + syncMaterialRot(getCurrentShinyRot()); } else { - if ((bool)self->childGetValue("checkbox planar align").asBoolean()) + if (childGetValue("checkbox planar align").asBoolean()) { LLFace* last_face = NULL; bool identical_face = false; LLSelectedTE::getFace(last_face, identical_face); - LLPanelFaceSetAlignedTEFunctor setfunc(self, last_face); + LLPanelFaceSetAlignedTEFunctor setfunc(this, last_face); LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc); } else { - LLSelectedTEMaterial::setSpecularRotation(self, self->getCurrentShinyRot() * DEG_TO_RAD); + LLSelectedTEMaterial::setSpecularRotation(this, getCurrentShinyRot() * DEG_TO_RAD); } } } -//static -void LLPanelFace::onCommitMaterialGloss(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialGloss() { - LLPanelFace* self = (LLPanelFace*) userdata; - llassert_always(self); - LLSelectedTEMaterial::setSpecularLightExponent(self,self->getCurrentGlossiness()); + LLSelectedTEMaterial::setSpecularLightExponent(this, getCurrentGlossiness()); } -//static -void LLPanelFace::onCommitMaterialEnv(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialEnv() { - LLPanelFace* self = (LLPanelFace*) userdata; - llassert_always(self); - LLSelectedTEMaterial::setEnvironmentIntensity(self,self->getCurrentEnvIntensity()); + LLSelectedTEMaterial::setEnvironmentIntensity(this, getCurrentEnvIntensity()); } -//static -void LLPanelFace::onCommitMaterialMaskCutoff(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitMaterialMaskCutoff() { - LLPanelFace* self = (LLPanelFace*) userdata; - LLSelectedTEMaterial::setAlphaMaskCutoff(self,self->getCurrentAlphaMaskCutoff()); + LLSelectedTEMaterial::setAlphaMaskCutoff(this, getCurrentAlphaMaskCutoff()); } -// static -void LLPanelFace::onCommitTextureInfo( LLUICtrl* ctrl, void* userdata ) +void LLPanelFace::onCommitTextureInfo() { - LLPanelFace* self = (LLPanelFace*) userdata; - self->sendTextureInfo(); + sendTextureInfo(); // vertical scale and repeats per meter depends on each other, so force set on changes - self->updateUI(true); + updateUI(true); } -// static -void LLPanelFace::onCommitTextureScaleX( LLUICtrl* ctrl, void* userdata ) +void LLPanelFace::onCommitTextureScaleX() { - LLPanelFace* self = (LLPanelFace*) userdata; if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - F32 bumpy_scale_u = (F32)self->getChild("TexScaleU")->getValue().asReal(); - if (self->isIdenticalPlanarTexgen()) + F32 bumpy_scale_u = (F32)getChild("TexScaleU")->getValue().asReal(); + if (isIdenticalPlanarTexgen()) { bumpy_scale_u *= 0.5f; } - syncRepeatX(self, bumpy_scale_u); + syncRepeatX(bumpy_scale_u); } else { - self->sendTextureInfo(); + sendTextureInfo(); } - self->updateUI(true); + updateUI(true); } -// static -void LLPanelFace::onCommitTextureScaleY( LLUICtrl* ctrl, void* userdata ) +void LLPanelFace::onCommitTextureScaleY() { - LLPanelFace* self = (LLPanelFace*) userdata; if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - F32 bumpy_scale_v = (F32)self->getChild("TexScaleV")->getValue().asReal(); - if (self->isIdenticalPlanarTexgen()) + F32 bumpy_scale_v = (F32)getChild("TexScaleV")->getValue().asReal(); + if (isIdenticalPlanarTexgen()) { bumpy_scale_v *= 0.5f; } - syncRepeatY(self, bumpy_scale_v); + syncRepeatY(bumpy_scale_v); } else { - self->sendTextureInfo(); + sendTextureInfo(); } - self->updateUI(true); + updateUI(true); } -// static -void LLPanelFace::onCommitTextureRot( LLUICtrl* ctrl, void* userdata ) +void LLPanelFace::onCommitTextureRot() { - LLPanelFace* self = (LLPanelFace*) userdata; - if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - syncMaterialRot(self, (F32)self->getChild("TexRot")->getValue().asReal()); + syncMaterialRot((F32)getChild("TexRot")->getValue().asReal()); } else { - self->sendTextureInfo(); + sendTextureInfo(); } - self->updateUI(true); + updateUI(true); } -// static -void LLPanelFace::onCommitTextureOffsetX( LLUICtrl* ctrl, void* userdata ) +void LLPanelFace::onCommitTextureOffsetX() { - LLPanelFace* self = (LLPanelFace*) userdata; if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - syncOffsetX(self, (F32)self->getChild("TexOffsetU")->getValue().asReal()); + syncOffsetX((F32)getChild("TexOffsetU")->getValue().asReal()); } else { - self->sendTextureInfo(); + sendTextureInfo(); } - self->updateUI(true); + updateUI(true); } -// static -void LLPanelFace::onCommitTextureOffsetY( LLUICtrl* ctrl, void* userdata ) +void LLPanelFace::onCommitTextureOffsetY() { - LLPanelFace* self = (LLPanelFace*) userdata; if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - syncOffsetY(self, (F32)self->getChild("TexOffsetV")->getValue().asReal()); + syncOffsetY((F32)getChild("TexOffsetV")->getValue().asReal()); } else { - self->sendTextureInfo(); + sendTextureInfo(); } - self->updateUI(true); + updateUI(true); } // Commit the number of repeats per meter -// static -void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitRepeatsPerMeter() { - LLPanelFace *self = (LLPanelFace *) userdata; - - LLUICtrl *repeats_ctrl = self->getChild("rptctrl"); - - U32 materials_media = self->mComboMatMedia->getCurrentIndex(); - U32 material_type = 0; - if (materials_media == MATMEDIA_PBR) - { - material_type = self->mRadioPbrType->getSelectedIndex(); - } - if (materials_media == MATMEDIA_MATERIAL) - { - material_type = self->mRadioMaterialType->getSelectedIndex(); - } - - F32 repeats_per_meter = (F32) repeats_ctrl->getValue().asReal(); + F32 repeats_per_meter = (F32)getChild("rptctrl")->getValue().asReal(); F32 obj_scale_s = 1.0f; F32 obj_scale_t = 1.0f; @@ -3816,64 +3653,57 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) LLSelectedTE::getObjectScaleS(obj_scale_s, identical_scale_s); LLSelectedTE::getObjectScaleS(obj_scale_t, identical_scale_t); - LLUICtrl *bumpy_scale_u = self->getChild("bumpyScaleU"); - LLUICtrl *bumpy_scale_v = self->getChild("bumpyScaleV"); - LLUICtrl *shiny_scale_u = self->getChild("shinyScaleU"); - LLUICtrl *shiny_scale_v = self->getChild("shinyScaleV"); + LLUICtrl* bumpy_scale_u = getChild("bumpyScaleU"); + LLUICtrl* bumpy_scale_v = getChild("bumpyScaleV"); + LLUICtrl* shiny_scale_u = getChild("shinyScaleU"); + LLUICtrl* shiny_scale_v = getChild("shinyScaleV"); if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - LLSelectMgr::getInstance()->selectionTexScaleAutofit( repeats_per_meter ); + LLSelectMgr::getInstance()->selectionTexScaleAutofit(repeats_per_meter); bumpy_scale_u->setValue(obj_scale_s * repeats_per_meter); bumpy_scale_v->setValue(obj_scale_t * repeats_per_meter); - LLSelectedTEMaterial::setNormalRepeatX(self,obj_scale_s * repeats_per_meter); - LLSelectedTEMaterial::setNormalRepeatY(self,obj_scale_t * repeats_per_meter); + LLSelectedTEMaterial::setNormalRepeatX(this, obj_scale_s * repeats_per_meter); + LLSelectedTEMaterial::setNormalRepeatY(this, obj_scale_t * repeats_per_meter); shiny_scale_u->setValue(obj_scale_s * repeats_per_meter); shiny_scale_v->setValue(obj_scale_t * repeats_per_meter); - LLSelectedTEMaterial::setSpecularRepeatX(self,obj_scale_s * repeats_per_meter); - LLSelectedTEMaterial::setSpecularRepeatY(self,obj_scale_t * repeats_per_meter); + LLSelectedTEMaterial::setSpecularRepeatX(this, obj_scale_s * repeats_per_meter); + LLSelectedTEMaterial::setSpecularRepeatY(this, obj_scale_t * repeats_per_meter); } else { + U32 material_type = mRadioMaterialType->getSelectedIndex(); switch (material_type) { - case MATTYPE_DIFFUSE: - { - LLSelectMgr::getInstance()->selectionTexScaleAutofit( repeats_per_meter ); - } + case MATTYPE_DIFFUSE: + LLSelectMgr::getInstance()->selectionTexScaleAutofit(repeats_per_meter); break; + case MATTYPE_NORMAL: + bumpy_scale_u->setValue(obj_scale_s * repeats_per_meter); + bumpy_scale_v->setValue(obj_scale_t * repeats_per_meter); - case MATTYPE_NORMAL: - { - bumpy_scale_u->setValue(obj_scale_s * repeats_per_meter); - bumpy_scale_v->setValue(obj_scale_t * repeats_per_meter); - - LLSelectedTEMaterial::setNormalRepeatX(self,obj_scale_s * repeats_per_meter); - LLSelectedTEMaterial::setNormalRepeatY(self,obj_scale_t * repeats_per_meter); - } + LLSelectedTEMaterial::setNormalRepeatX(this, obj_scale_s * repeats_per_meter); + LLSelectedTEMaterial::setNormalRepeatY(this, obj_scale_t * repeats_per_meter); break; + case MATTYPE_SPECULAR: + bumpy_scale_u->setValue(obj_scale_s * repeats_per_meter); + bumpy_scale_v->setValue(obj_scale_t * repeats_per_meter); - case MATTYPE_SPECULAR: - { - shiny_scale_u->setValue(obj_scale_s * repeats_per_meter); - shiny_scale_v->setValue(obj_scale_t * repeats_per_meter); - - LLSelectedTEMaterial::setSpecularRepeatX(self,obj_scale_s * repeats_per_meter); - LLSelectedTEMaterial::setSpecularRepeatY(self,obj_scale_t * repeats_per_meter); - } + LLSelectedTEMaterial::setSpecularRepeatX(this, obj_scale_s * repeats_per_meter); + LLSelectedTEMaterial::setSpecularRepeatY(this, obj_scale_t * repeats_per_meter); + break; + default: + llassert(false); break; - - default: - llassert(false); - break; } } + // vertical scale and repeats per meter depends on each other, so force set on changes - self->updateUI(true); + updateUI(true); } struct LLPanelFaceSetMediaFunctor : public LLSelectedTEFunctor @@ -3883,22 +3713,20 @@ struct LLPanelFaceSetMediaFunctor : public LLSelectedTEFunctor viewer_media_t pMediaImpl; const LLTextureEntry* tep = object->getTE(te); - const LLMediaEntry* mep = tep->hasMedia() ? tep->getMediaData() : NULL; - if ( mep ) + if (const LLMediaEntry* mep = tep->hasMedia() ? tep->getMediaData() : NULL) { pMediaImpl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mep->getMediaID()); } - if ( pMediaImpl.isNull()) + if (pMediaImpl.isNull()) { // If we didn't find face media for this face, check whether this face is showing parcel media. pMediaImpl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(tep->getID()); } - if ( pMediaImpl.notNull()) + if (pMediaImpl.notNull()) { - LLPluginClassMedia *media = pMediaImpl->getMediaPlugin(); - if(media) + if (LLPluginClassMedia* media = pMediaImpl->getMediaPlugin()) { S32 media_width = media->getWidth(); S32 media_height = media->getHeight(); @@ -3908,17 +3736,17 @@ struct LLPanelFaceSetMediaFunctor : public LLSelectedTEFunctor F32 scale_t = (F32)media_height / (F32)texture_height; // set scale and adjust offset - object->setTEScaleS( te, scale_s ); - object->setTEScaleT( te, scale_t ); // don't need to flip Y anymore since QT does this for us now. - object->setTEOffsetS( te, -( 1.0f - scale_s ) / 2.0f ); - object->setTEOffsetT( te, -( 1.0f - scale_t ) / 2.0f ); + object->setTEScaleS(te, scale_s); + object->setTEScaleT(te, scale_t); // don't need to flip Y anymore since QT does this for us now. + object->setTEOffsetS(te, -( 1.0f - scale_s ) / 2.0f); + object->setTEOffsetT(te, -( 1.0f - scale_t ) / 2.0f); } } return true; }; }; -void LLPanelFace::onClickAutoFix(void* userdata) +void LLPanelFace::onClickAutoFix() { LLPanelFaceSetMediaFunctor setfunc; LLSelectMgr::getInstance()->getSelection()->applyToTEs(&setfunc); @@ -3927,25 +3755,23 @@ void LLPanelFace::onClickAutoFix(void* userdata) LLSelectMgr::getInstance()->getSelection()->applyToObjects(&sendfunc); } -void LLPanelFace::onAlignTexture(void* userdata) +void LLPanelFace::onAlignTexture() { - LLPanelFace* self = (LLPanelFace*)userdata; - self->alignTextureLayer(); + alignTextureLayer(); } -void LLPanelFace::onClickBtnLoadInvPBR(void* userdata) +void LLPanelFace::onClickBtnLoadInvPBR() { // Shouldn't this be "save to inventory?" - LLPanelFace* self = (LLPanelFace*)userdata; - self->mPBRTextureCtrl->showPicker(true); + mPBRTextureCtrl->showPicker(true); } -void LLPanelFace::onClickBtnEditPBR(void* userdata) +void LLPanelFace::onClickBtnEditPBR() { LLMaterialEditor::loadLive(); } -void LLPanelFace::onClickBtnSavePBR(void* userdata) +void LLPanelFace::onClickBtnSavePBR() { LLMaterialEditor::saveObjectsMaterialAs(); } @@ -4806,44 +4632,39 @@ bool LLPanelFace::menuEnableItem(const LLSD& userdata) return false; } - -// static -void LLPanelFace::onCommitPlanarAlign(LLUICtrl* ctrl, void* userdata) +void LLPanelFace::onCommitPlanarAlign() { - LLPanelFace* self = (LLPanelFace*) userdata; - self->getState(); - self->sendTextureInfo(); + getState(); + sendTextureInfo(); } -void LLPanelFace::updateGLTFTextureTransform(float value, U32 pbr_type, std::function edit) +void LLPanelFace::updateGLTFTextureTransform(std::function edit) { - U32 texture_info_start; - U32 texture_info_end; - const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); + const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(mRadioPbrType->getSelectedIndex()); if (texture_info == LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT) { - texture_info_start = 0; - texture_info_end = LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; + updateSelectedGLTFMaterials([&](LLGLTFMaterial* new_override) + { + for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i) + { + LLGLTFMaterial::TextureTransform& new_transform = new_override->mTextureTransform[(LLGLTFMaterial::TextureInfo)i]; + edit(&new_transform); + } + }); } else { - texture_info_start = texture_info_from_pbrtype(pbr_type); - texture_info_end = texture_info_start + 1; + updateSelectedGLTFMaterials([&](LLGLTFMaterial* new_override) + { + LLGLTFMaterial::TextureTransform& new_transform = new_override->mTextureTransform[texture_info]; + edit(&new_transform); + }); } - updateSelectedGLTFMaterials([&](LLGLTFMaterial* new_override) - { - for (U32 ti = texture_info_start; ti < texture_info_end; ++ti) - { - LLGLTFMaterial::TextureTransform& new_transform = new_override->mTextureTransform[(LLGLTFMaterial::TextureInfo)ti]; - edit(&new_transform); - } - }); } void LLPanelFace::setMaterialOverridesFromSelection() { - const U32 pbr_type = mRadioPbrType->getSelectedIndex(); - const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); + const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(mRadioPbrType->getSelectedIndex()); U32 texture_info_start; U32 texture_info_end; if (texture_info == LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_COUNT) @@ -5009,51 +4830,46 @@ bool LLPanelFace::Selection::compareSelection() return selection_changed; } -void LLPanelFace::onCommitGLTFTextureScaleU(LLUICtrl* ctrl) +void LLPanelFace::onCommitGLTFTextureScaleU() { - const float value = (F32)ctrl->getValue().asReal(); - const U32 pbr_type = mRadioPbrType->getSelectedIndex(); - updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) + F32 value = (F32)getChild("gltfTextureScaleU")->getValue().asReal(); + updateGLTFTextureTransform([&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mScale.mV[VX] = value; }); } -void LLPanelFace::onCommitGLTFTextureScaleV(LLUICtrl* ctrl) +void LLPanelFace::onCommitGLTFTextureScaleV() { - const float value = (F32)ctrl->getValue().asReal(); - const U32 pbr_type = mRadioPbrType->getSelectedIndex(); - updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) + F32 value = (F32)getChild("gltfTextureScaleV")->getValue().asReal(); + updateGLTFTextureTransform([&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mScale.mV[VY] = value; }); } -void LLPanelFace::onCommitGLTFRotation(LLUICtrl* ctrl) +void LLPanelFace::onCommitGLTFRotation() { - const float value = (F32)ctrl->getValue().asReal() * DEG_TO_RAD; - const U32 pbr_type = mRadioPbrType->getSelectedIndex(); - updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) + F32 value = (F32)getChild("gltfTextureRotation")->getValue().asReal() * DEG_TO_RAD; + updateGLTFTextureTransform([&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mRotation = value; }); } -void LLPanelFace::onCommitGLTFTextureOffsetU(LLUICtrl* ctrl) +void LLPanelFace::onCommitGLTFTextureOffsetU() { - const float value = (F32)ctrl->getValue().asReal(); - const U32 pbr_type = mRadioPbrType->getSelectedIndex(); - updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) + F32 value = (F32)getChild("gltfTextureOffsetU")->getValue().asReal(); + updateGLTFTextureTransform([&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mOffset.mV[VX] = value; }); } -void LLPanelFace::onCommitGLTFTextureOffsetV(LLUICtrl* ctrl) +void LLPanelFace::onCommitGLTFTextureOffsetV() { - const float value = (F32)ctrl->getValue().asReal(); - const U32 pbr_type = mRadioPbrType->getSelectedIndex(); - updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) + F32 value = (F32)getChild("gltfTextureOffsetV")->getValue().asReal(); + updateGLTFTextureTransform([&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mOffset.mV[VY] = value; }); @@ -5063,20 +4879,20 @@ void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp) { LL_DEBUGS("Materials") << "item asset " << itemp->getAssetUUID() << LL_ENDL; + LLTextureCtrl* texture_ctrl; U32 mattype = mRadioMaterialType->getSelectedIndex(); - std::string which_control="texture control"; switch (mattype) { case MATTYPE_SPECULAR: - which_control = "shinytexture control"; + texture_ctrl = getChild("shinytexture control"); break; case MATTYPE_NORMAL: - which_control = "bumpytexture control"; + texture_ctrl = getChild("bumpytexture control"); break; - // no default needed + default: + texture_ctrl = getChild("texture control"); } - LL_DEBUGS("Materials") << "control " << which_control << LL_ENDL; - LLTextureCtrl* texture_ctrl = getChild(which_control); + if (texture_ctrl) { LLUUID obj_owner_id; diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 6e88116a2d..ede2ef9339 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -130,54 +130,54 @@ public: LLGLTFMaterial::TextureInfo getPBRDropChannel(); protected: - void navigateToTitleMedia(const std::string url); - bool selectedMediaEditable(); - void clearMediaSettings(); - void updateMediaSettings(); - void updateMediaTitle(); - - void getState(); - - void sendTexture(); // applies and sends texture - void sendTextureInfo(); // applies and sends texture scale, offset, etc. - void sendColor(); // applies and sends color - void sendAlpha(); // applies and sends transparency - void sendBump(U32 bumpiness); // applies and sends bump map - void sendTexGen(); // applies and sends bump map - void sendShiny(U32 shininess); // applies and sends shininess - void sendFullbright(); // applies and sends full bright - - void sendGlow(); - void alignTextureLayer(); - - void updateCopyTexButton(); - - void onCommitPbr(const LLSD& data); - void onCancelPbr(const LLSD& data); - void onSelectPbr(const LLSD& data); - static bool onDragPbr(LLUICtrl* ctrl, LLInventoryItem* item); - - // this function is to return true if the drag should succeed. - static bool onDragTexture(LLUICtrl* ctrl, LLInventoryItem* item); - - void onCommitTexture(const LLSD& data); - void onCancelTexture(const LLSD& data); - void onSelectTexture(const LLSD& data); - void onCommitSpecularTexture(const LLSD& data); - void onCancelSpecularTexture(const LLSD& data); - void onSelectSpecularTexture(const LLSD& data); - void onCommitNormalTexture(const LLSD& data); - void onCancelNormalTexture(const LLSD& data); - void onSelectNormalTexture(const LLSD& data); - void onCommitColor(const LLSD& data); - void onCommitShinyColor(const LLSD& data); - void onCommitAlpha(const LLSD& data); - void onCancelColor(const LLSD& data); - void onCancelShinyColor(const LLSD& data); - void onSelectColor(const LLSD& data); - void onSelectShinyColor(const LLSD& data); - - void onCloseTexturePicker(const LLSD& data); + void navigateToTitleMedia(const std::string url); + bool selectedMediaEditable(); + void clearMediaSettings(); + void updateMediaSettings(); + void updateMediaTitle(); + + void getState(); + + void sendTexture(); // applies and sends texture + void sendTextureInfo(); // applies and sends texture scale, offset, etc. + void sendColor(); // applies and sends color + void sendAlpha(); // applies and sends transparency + void sendBump(U32 bumpiness); // applies and sends bump map + void sendTexGen(); // applies and sends bump map + void sendShiny(U32 shininess); // applies and sends shininess + void sendFullbright(); // applies and sends full bright + + void sendGlow(); + void alignTextureLayer(); + + void updateCopyTexButton(); + + void onCommitPbr(); + void onCancelPbr(); + void onSelectPbr(); + + // These functions are to return true if the drag should succeed + bool onDragPbr(LLInventoryItem* item); + bool onDragTexture(LLInventoryItem* item); + + void onCommitTexture(); + void onCancelTexture(); + void onSelectTexture(); + void onCommitSpecularTexture(const LLSD& data); + void onCancelSpecularTexture(const LLSD& data); + void onSelectSpecularTexture(const LLSD& data); + void onCommitNormalTexture(const LLSD& data); + void onCancelNormalTexture(const LLSD& data); + void onSelectNormalTexture(const LLSD& data); + void onCommitColor(); + void onCommitShinyColor(); + void onCommitAlpha(); + void onCancelColor(); + void onCancelShinyColor(); + void onSelectColor(); + void onSelectShinyColor(); + + void onCloseTexturePicker(const LLSD& data); static bool deleteMediaConfirm(const LLSD& notification, const LLSD& response); static bool multipleFacesSelectedConfirm(const LLSD& notification, const LLSD& response); @@ -195,81 +195,79 @@ protected: // Callback funcs for individual controls // - static void onCommitTextureInfo(LLUICtrl* ctrl, void* userdata); - static void onCommitTextureScaleX(LLUICtrl* ctrl, void* userdata); - static void onCommitTextureScaleY(LLUICtrl* ctrl, void* userdata); - static void onCommitTextureRot(LLUICtrl* ctrl, void* userdata); - static void onCommitTextureOffsetX(LLUICtrl* ctrl, void* userdata); - static void onCommitTextureOffsetY(LLUICtrl* ctrl, void* userdata); - - static void onCommitMaterialBumpyScaleX( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialBumpyScaleY( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialBumpyRot( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialBumpyOffsetX( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialBumpyOffsetY( LLUICtrl* ctrl, void* userdata); - - static void syncRepeatX(LLPanelFace* self, F32 scaleU); - static void syncRepeatY(LLPanelFace* self, F32 scaleV); - static void syncOffsetX(LLPanelFace* self, F32 offsetU); - static void syncOffsetY(LLPanelFace* self, F32 offsetV); - static void syncMaterialRot(LLPanelFace* self, F32 rot, int te = -1); - - static void onCommitMaterialShinyScaleX( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialShinyScaleY( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialShinyRot( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialShinyOffsetX( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialShinyOffsetY( LLUICtrl* ctrl, void* userdata); - - static void onCommitMaterialGloss( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialEnv( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialMaskCutoff( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialID( LLUICtrl* ctrl, void* userdata); - - static void onCommitMaterialsMedia( LLUICtrl* ctrl, void* userdata); - static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); - static void onCommitPbrType(LLUICtrl* ctrl, void* userdata); - static void onClickBtnEditMedia(LLUICtrl* ctrl, void* userdata); - static void onClickBtnDeleteMedia(LLUICtrl* ctrl, void* userdata); - static void onClickBtnAddMedia(LLUICtrl* ctrl, void* userdata); - static void onCommitBump( LLUICtrl* ctrl, void* userdata); - static void onCommitTexGen( LLUICtrl* ctrl, void* userdata); - static void onCommitShiny( LLUICtrl* ctrl, void* userdata); - static void onCommitAlphaMode( LLUICtrl* ctrl, void* userdata); - static void onCommitFullbright( LLUICtrl* ctrl, void* userdata); - static void onCommitGlow( LLUICtrl* ctrl, void *userdata); - static void onCommitPlanarAlign( LLUICtrl* ctrl, void* userdata); - static void onCommitRepeatsPerMeter( LLUICtrl* ctrl, void* userinfo); - - void onCommitGLTFTextureScaleU(LLUICtrl* ctrl); - void onCommitGLTFTextureScaleV(LLUICtrl* ctrl); - void onCommitGLTFRotation(LLUICtrl* ctrl); - void onCommitGLTFTextureOffsetU(LLUICtrl* ctrl); - void onCommitGLTFTextureOffsetV(LLUICtrl* ctrl); - - static void onClickAutoFix(void*); - static void onAlignTexture(void*); - static void onClickBtnLoadInvPBR(void* userdata); - static void onClickBtnEditPBR(void* userdata); - static void onClickBtnSavePBR(void* userdata); + void onCommitTextureInfo(); + void onCommitTextureScaleX(); + void onCommitTextureScaleY(); + void onCommitTextureRot(); + void onCommitTextureOffsetX(); + void onCommitTextureOffsetY(); + + void onCommitMaterialBumpyScaleX(); + void onCommitMaterialBumpyScaleY(); + void onCommitMaterialBumpyRot(); + void onCommitMaterialBumpyOffsetX(); + void onCommitMaterialBumpyOffsetY(); + + void syncRepeatX(F32 scaleU); + void syncRepeatY(F32 scaleV); + void syncOffsetX(F32 offsetU); + void syncOffsetY(F32 offsetV); + void syncMaterialRot(F32 rot, int te = -1); + + void onCommitMaterialShinyScaleX(); + void onCommitMaterialShinyScaleY(); + void onCommitMaterialShinyRot(); + void onCommitMaterialShinyOffsetX(); + void onCommitMaterialShinyOffsetY(); + + void onCommitMaterialGloss(); + void onCommitMaterialEnv(); + void onCommitMaterialMaskCutoff(); + void onCommitMaterialID(); + + void onCommitMaterialsMedia(); + void onCommitMaterialType(); + void onCommitPbrType(); + void onClickBtnEditMedia(); + void onClickBtnDeleteMedia(); + void onClickBtnAddMedia(); + void onCommitBump(); + void onCommitTexGen(); + void onCommitShiny(); + void onCommitAlphaMode(); + void onCommitFullbright(); + void onCommitGlow(); + void onCommitPlanarAlign(); + void onCommitRepeatsPerMeter(); + + void onCommitGLTFTextureScaleU(); + void onCommitGLTFTextureScaleV(); + void onCommitGLTFRotation(); + void onCommitGLTFTextureOffsetU(); + void onCommitGLTFTextureOffsetV(); + + void onClickAutoFix(); + void onAlignTexture(); + void onClickBtnLoadInvPBR(); + void onClickBtnEditPBR(); + void onClickBtnSavePBR(); public: // needs to be accessible to selection manager - void onCopyColor(); // records all selected faces - void onPasteColor(); // to specific face - void onPasteColor(LLViewerObject* objectp, S32 te); // to specific face - void onCopyTexture(); - void onPasteTexture(); - void onPasteTexture(LLViewerObject* objectp, S32 te); + void onCopyColor(); // records all selected faces + void onPasteColor(); // to specific face + void onPasteColor(LLViewerObject* objectp, S32 te); // to specific face + void onCopyTexture(); + void onPasteTexture(); + void onPasteTexture(LLViewerObject* objectp, S32 te); protected: - void menuDoToSelected(const LLSD& userdata); - bool menuEnableItem(const LLSD& userdata); - - static F32 valueGlow(LLViewerObject* object, S32 face); - + void menuDoToSelected(const LLSD& userdata); + bool menuEnableItem(const LLSD& userdata); + static F32 valueGlow(LLViewerObject* object, S32 face); private: - bool isAlpha() { return mIsAlpha; } + bool isAlpha() { return mIsAlpha; } // Convenience funcs to keep the visual flack to a minimum // @@ -483,7 +481,7 @@ private: void updateVisibilityGLTF(LLViewerObject* objectp = nullptr); void updateSelectedGLTFMaterials(std::function func); - void updateGLTFTextureTransform(float value, U32 pbr_type, std::function edit); + void updateGLTFTextureTransform(std::function edit); void setMaterialOverridesFromSelection(); @@ -578,41 +576,41 @@ public: static void getMaxNormalRepeats(F32& repeats, bool& identical); static void getCurrentDiffuseAlphaMode(U8& diffuse_alpha_mode, bool& identical, bool diffuse_texture_has_alpha); - DEF_GET_MAT_STATE(LLUUID,const LLUUID&,getNormalID,LLUUID::null, false, LLUUID::null) - DEF_GET_MAT_STATE(LLUUID,const LLUUID&,getSpecularID,LLUUID::null, false, LLUUID::null) - DEF_GET_MAT_STATE(F32,F32,getSpecularRepeatX,1.0f, true, 0.001f) - DEF_GET_MAT_STATE(F32,F32,getSpecularRepeatY,1.0f, true, 0.001f) - DEF_GET_MAT_STATE(F32,F32,getSpecularOffsetX,0.0f, true, 0.001f) - DEF_GET_MAT_STATE(F32,F32,getSpecularOffsetY,0.0f, true, 0.001f) - DEF_GET_MAT_STATE(F32,F32,getSpecularRotation,0.0f, true, 0.001f) - - DEF_GET_MAT_STATE(F32,F32,getNormalRepeatX,1.0f, true, 0.001f) - DEF_GET_MAT_STATE(F32,F32,getNormalRepeatY,1.0f, true, 0.001f) - DEF_GET_MAT_STATE(F32,F32,getNormalOffsetX,0.0f, true, 0.001f) - DEF_GET_MAT_STATE(F32,F32,getNormalOffsetY,0.0f, true, 0.001f) - DEF_GET_MAT_STATE(F32,F32,getNormalRotation,0.0f, true, 0.001f) - - DEF_EDIT_MAT_STATE(U8,U8,setDiffuseAlphaMode); - DEF_EDIT_MAT_STATE(U8,U8,setAlphaMaskCutoff); - - DEF_EDIT_MAT_STATE(F32,F32,setNormalOffsetX); - DEF_EDIT_MAT_STATE(F32,F32,setNormalOffsetY); - DEF_EDIT_MAT_STATE(F32,F32,setNormalRepeatX); - DEF_EDIT_MAT_STATE(F32,F32,setNormalRepeatY); - DEF_EDIT_MAT_STATE(F32,F32,setNormalRotation); - - DEF_EDIT_MAT_STATE(F32,F32,setSpecularOffsetX); - DEF_EDIT_MAT_STATE(F32,F32,setSpecularOffsetY); - DEF_EDIT_MAT_STATE(F32,F32,setSpecularRepeatX); - DEF_EDIT_MAT_STATE(F32,F32,setSpecularRepeatY); - DEF_EDIT_MAT_STATE(F32,F32,setSpecularRotation); - - DEF_EDIT_MAT_STATE(U8,U8,setEnvironmentIntensity); - DEF_EDIT_MAT_STATE(U8,U8,setSpecularLightExponent); - - DEF_EDIT_MAT_STATE(LLUUID,const LLUUID&,setNormalID); - DEF_EDIT_MAT_STATE(LLUUID,const LLUUID&,setSpecularID); - DEF_EDIT_MAT_STATE(LLColor4U, const LLColor4U&,setSpecularLightColor); + DEF_GET_MAT_STATE(LLUUID, const LLUUID&, getNormalID, LLUUID::null, false, LLUUID::null); + DEF_GET_MAT_STATE(LLUUID, const LLUUID&, getSpecularID, LLUUID::null, false, LLUUID::null); + DEF_GET_MAT_STATE(F32, F32, getSpecularRepeatX, 1.0f, true, 0.001f); + DEF_GET_MAT_STATE(F32, F32, getSpecularRepeatY, 1.0f, true, 0.001f); + DEF_GET_MAT_STATE(F32, F32, getSpecularOffsetX, 0.0f, true, 0.001f); + DEF_GET_MAT_STATE(F32, F32, getSpecularOffsetY, 0.0f, true, 0.001f); + DEF_GET_MAT_STATE(F32, F32, getSpecularRotation, 0.0f, true, 0.001f); + + DEF_GET_MAT_STATE(F32, F32, getNormalRepeatX, 1.0f, true, 0.001f); + DEF_GET_MAT_STATE(F32, F32, getNormalRepeatY, 1.0f, true, 0.001f); + DEF_GET_MAT_STATE(F32, F32, getNormalOffsetX, 0.0f, true, 0.001f); + DEF_GET_MAT_STATE(F32, F32, getNormalOffsetY, 0.0f, true, 0.001f); + DEF_GET_MAT_STATE(F32, F32, getNormalRotation, 0.0f, true, 0.001f); + + DEF_EDIT_MAT_STATE(U8, U8, setDiffuseAlphaMode); + DEF_EDIT_MAT_STATE(U8, U8, setAlphaMaskCutoff); + + DEF_EDIT_MAT_STATE(F32, F32, setNormalOffsetX); + DEF_EDIT_MAT_STATE(F32, F32, setNormalOffsetY); + DEF_EDIT_MAT_STATE(F32, F32, setNormalRepeatX); + DEF_EDIT_MAT_STATE(F32, F32, setNormalRepeatY); + DEF_EDIT_MAT_STATE(F32, F32, setNormalRotation); + + DEF_EDIT_MAT_STATE(F32, F32, setSpecularOffsetX); + DEF_EDIT_MAT_STATE(F32, F32, setSpecularOffsetY); + DEF_EDIT_MAT_STATE(F32, F32, setSpecularRepeatX); + DEF_EDIT_MAT_STATE(F32, F32, setSpecularRepeatY); + DEF_EDIT_MAT_STATE(F32, F32, setSpecularRotation); + + DEF_EDIT_MAT_STATE(U8, U8, setEnvironmentIntensity); + DEF_EDIT_MAT_STATE(U8, U8, setSpecularLightExponent); + + DEF_EDIT_MAT_STATE(LLUUID, const LLUUID&,setNormalID); + DEF_EDIT_MAT_STATE(LLUUID, const LLUUID&,setSpecularID); + DEF_EDIT_MAT_STATE(LLColor4U, const LLColor4U&, setSpecularLightColor); }; class LLSelectedTE -- cgit v1.2.3 From 8754ce088fd0e901ad2d9dfd7bfc70266340bc39 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 7 Aug 2024 16:06:26 +0300 Subject: viewer#2212 Bulk upload makes an incorrect cost estimate --- indra/newview/llviewermenufile.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index c4fecf8dff..83f8e96f9a 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -547,9 +547,11 @@ void do_bulk_upload(std::vector filenames, bool allow_2k) if (asset_type == LLAssetType::AT_TEXTURE && allow_2k) { LLPointer image_frmted = LLImageFormatted::createFromType(codec); - if (gDirUtilp->fileExists(filename) && image_frmted->load(filename)) + if (gDirUtilp->fileExists(filename) && image_frmted && image_frmted->load(filename)) { - expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(image_frmted); + S32 biased_width = LLImageRaw::biasedDimToPowerOfTwo(image_frmted->getWidth(), LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); + S32 biased_height = LLImageRaw::biasedDimToPowerOfTwo(image_frmted->getHeight(), LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); + expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(biased_width, biased_height); resource_upload = true; } } @@ -643,16 +645,15 @@ bool get_bulk_upload_expected_cost( if (asset_type == LLAssetType::AT_TEXTURE && allow_2k) { LLPointer image_frmted = LLImageFormatted::createFromType(codec); - if (gDirUtilp->fileExists(filename) && image_frmted->load(filename)) + if (gDirUtilp->fileExists(filename) && image_frmted && image_frmted->load(filename)) { - total_cost += LLAgentBenefitsMgr::current().getTextureUploadCost(image_frmted); - if (image_frmted) + S32 biased_width = LLImageRaw::biasedDimToPowerOfTwo(image_frmted->getWidth(), LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); + S32 biased_height = LLImageRaw::biasedDimToPowerOfTwo(image_frmted->getHeight(), LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); + total_cost += LLAgentBenefitsMgr::current().getTextureUploadCost(biased_width, biased_height); + S32 area = biased_width * biased_height; + if (area >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) { - S32 area = image_frmted->getHeight() * image_frmted->getWidth(); - if (area >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) - { - textures_2k_count++; - } + textures_2k_count++; } file_count++; } -- cgit v1.2.3 From 413ece6c481e430ad380697934a20ecd95aaa7fb Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Wed, 7 Aug 2024 18:08:21 +0200 Subject: #1922 Make PBR scale and offset crosshair work (store control pointers in LLPanelFace) --- indra/newview/llpanelface.cpp | 1074 +++++++++++++++++++---------------------- indra/newview/llpanelface.h | 108 ++++- 2 files changed, 573 insertions(+), 609 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index f01d327fb4..936ca273c3 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -226,7 +226,7 @@ LLRender::eTexIndex LLPanelFace::getTextureDropChannel() LLGLTFMaterial::TextureInfo LLPanelFace::getPBRDropChannel() { - if (mComboMatMedia && mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR) + if (mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR) { return texture_info_from_pbrtype(mRadioPbrType->getSelectedIndex()); } @@ -236,24 +236,24 @@ LLGLTFMaterial::TextureInfo LLPanelFace::getPBRDropChannel() // Things the UI provides... // -LLUUID LLPanelFace::getCurrentNormalMap() { return mBumpyTextureCtrl->getImageAssetID(); } -LLUUID LLPanelFace::getCurrentSpecularMap() { return mShinyTextureCtrl->getImageAssetID(); } -U32 LLPanelFace::getCurrentShininess() { return getChild("combobox shininess")->getCurrentIndex(); } -U32 LLPanelFace::getCurrentBumpiness() { return getChild("combobox bumpiness")->getCurrentIndex(); } -U8 LLPanelFace::getCurrentDiffuseAlphaMode() { return (U8)getChild("combobox alphamode")->getCurrentIndex(); } -U8 LLPanelFace::getCurrentAlphaMaskCutoff() { return (U8)getChild("maskcutoff")->getValue().asInteger(); } -U8 LLPanelFace::getCurrentEnvIntensity() { return (U8)getChild("environment")->getValue().asInteger(); } -U8 LLPanelFace::getCurrentGlossiness() { return (U8)getChild("glossiness")->getValue().asInteger(); } -F32 LLPanelFace::getCurrentBumpyRot() { return (F32)getChild("bumpyRot")->getValue().asReal(); } -F32 LLPanelFace::getCurrentBumpyScaleU() { return (F32)getChild("bumpyScaleU")->getValue().asReal(); } -F32 LLPanelFace::getCurrentBumpyScaleV() { return (F32)getChild("bumpyScaleV")->getValue().asReal(); } -F32 LLPanelFace::getCurrentBumpyOffsetU() { return (F32)getChild("bumpyOffsetU")->getValue().asReal(); } -F32 LLPanelFace::getCurrentBumpyOffsetV() { return (F32)getChild("bumpyOffsetV")->getValue().asReal(); } -F32 LLPanelFace::getCurrentShinyRot() { return (F32)getChild("shinyRot")->getValue().asReal(); } -F32 LLPanelFace::getCurrentShinyScaleU() { return (F32)getChild("shinyScaleU")->getValue().asReal(); } -F32 LLPanelFace::getCurrentShinyScaleV() { return (F32)getChild("shinyScaleV")->getValue().asReal(); } -F32 LLPanelFace::getCurrentShinyOffsetU() { return (F32)getChild("shinyOffsetU")->getValue().asReal(); } -F32 LLPanelFace::getCurrentShinyOffsetV() { return (F32)getChild("shinyOffsetV")->getValue().asReal(); } +LLUUID LLPanelFace::getCurrentNormalMap() { return mBumpyTextureCtrl->getImageAssetID(); } +LLUUID LLPanelFace::getCurrentSpecularMap() { return mShinyTextureCtrl->getImageAssetID(); } +U32 LLPanelFace::getCurrentShininess() { return mComboShininess->getCurrentIndex(); } +U32 LLPanelFace::getCurrentBumpiness() { return mComboBumpiness->getCurrentIndex(); } +U8 LLPanelFace::getCurrentDiffuseAlphaMode() { return (U8)mComboAlphaMode->getCurrentIndex(); } +U8 LLPanelFace::getCurrentAlphaMaskCutoff() { return (U8)mMaskCutoff->getValue().asInteger(); } +U8 LLPanelFace::getCurrentEnvIntensity() { return (U8)mEnvironment->getValue().asInteger(); } +U8 LLPanelFace::getCurrentGlossiness() { return (U8)mGlossiness->getValue().asInteger(); } +F32 LLPanelFace::getCurrentBumpyRot() { return (F32)mBumpyRotate->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyScaleU() { return (F32)mBumpyScaleU->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyScaleV() { return (F32)mBumpyScaleV->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyOffsetU() { return (F32)mBumpyOffsetU->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyOffsetV() { return (F32)mBumpyOffsetV->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyRot() { return (F32)mShinyRotate->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyScaleU() { return (F32)mShinyScaleU->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyScaleV() { return (F32)mShinyScaleV->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyOffsetU() { return (F32)mShinyOffsetU->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyOffsetV() { return (F32)mShinyOffsetV->getValue().asReal(); } // // Methods @@ -261,199 +261,156 @@ F32 LLPanelFace::getCurrentShinyOffsetV() { return (F32)getChild("pbr_control"); - if (mPBRTextureCtrl) - { - mPBRTextureCtrl->setDefaultImageAssetID(LLUUID::null); - mPBRTextureCtrl->setBlankImageAssetID(BLANK_MATERIAL_ASSET_ID); - mPBRTextureCtrl->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitPbr(); }); - mPBRTextureCtrl->setOnCancelCallback([&](LLUICtrl*, const LLSD&) { onCancelPbr(); }); - mPBRTextureCtrl->setOnSelectCallback([&](LLUICtrl*, const LLSD&) { onSelectPbr(); }); - mPBRTextureCtrl->setDragCallback([&](LLUICtrl*, LLInventoryItem* item) { return onDragPbr(item); }); - mPBRTextureCtrl->setOnTextureSelectedCallback([&](LLInventoryItem* item) { onPbrSelectionChanged(item); }); - mPBRTextureCtrl->setOnCloseCallback([&](LLUICtrl*, const LLSD& data) { onCloseTexturePicker(data); }); - - mPBRTextureCtrl->setFollowsTop(); - mPBRTextureCtrl->setFollowsLeft(); - mPBRTextureCtrl->setImmediateFilterPermMask(PERM_NONE); - mPBRTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); - mPBRTextureCtrl->setBakeTextureEnabled(false); - mPBRTextureCtrl->setInventoryPickType(PICK_MATERIAL); - } + mPBRTextureCtrl->setDefaultImageAssetID(LLUUID::null); + mPBRTextureCtrl->setBlankImageAssetID(BLANK_MATERIAL_ASSET_ID); + mPBRTextureCtrl->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitPbr(); }); + mPBRTextureCtrl->setOnCancelCallback([&](LLUICtrl*, const LLSD&) { onCancelPbr(); }); + mPBRTextureCtrl->setOnSelectCallback([&](LLUICtrl*, const LLSD&) { onSelectPbr(); }); + mPBRTextureCtrl->setDragCallback([&](LLUICtrl*, LLInventoryItem* item) { return onDragPbr(item); }); + mPBRTextureCtrl->setOnTextureSelectedCallback([&](LLInventoryItem* item) { onPbrSelectionChanged(item); }); + mPBRTextureCtrl->setOnCloseCallback([&](LLUICtrl*, const LLSD& data) { onCloseTexturePicker(data); }); + mPBRTextureCtrl->setFollowsTop(); + mPBRTextureCtrl->setFollowsLeft(); + mPBRTextureCtrl->setImmediateFilterPermMask(PERM_NONE); + mPBRTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); + mPBRTextureCtrl->setBakeTextureEnabled(false); + mPBRTextureCtrl->setInventoryPickType(PICK_MATERIAL); mTextureCtrl = getChild("texture control"); - if (mTextureCtrl) - { - mTextureCtrl->setDefaultImageAssetID(DEFAULT_OBJECT_TEXTURE); - mTextureCtrl->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitTexture(); }); - mTextureCtrl->setOnCancelCallback([&](LLUICtrl*, const LLSD&) { onCancelTexture(); }); - mTextureCtrl->setOnSelectCallback([&](LLUICtrl*, const LLSD&) { onSelectTexture(); }); - mTextureCtrl->setDragCallback([&](LLUICtrl*, LLInventoryItem* item) { return onDragTexture(item); }); - mTextureCtrl->setOnTextureSelectedCallback([&](LLInventoryItem* item) { onTextureSelectionChanged(item); }); - mTextureCtrl->setOnCloseCallback([&](LLUICtrl*, const LLSD& data) { onCloseTexturePicker(data); }); - - mTextureCtrl->setFollowsTop(); - mTextureCtrl->setFollowsLeft(); - mTextureCtrl->setImmediateFilterPermMask(PERM_NONE); - mTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); - } + mTextureCtrl->setDefaultImageAssetID(DEFAULT_OBJECT_TEXTURE); + mTextureCtrl->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitTexture(); }); + mTextureCtrl->setOnCancelCallback([&](LLUICtrl*, const LLSD&) { onCancelTexture(); }); + mTextureCtrl->setOnSelectCallback([&](LLUICtrl*, const LLSD&) { onSelectTexture(); }); + mTextureCtrl->setDragCallback([&](LLUICtrl*, LLInventoryItem* item) { return onDragTexture(item); }); + mTextureCtrl->setOnTextureSelectedCallback([&](LLInventoryItem* item) { onTextureSelectionChanged(item); }); + mTextureCtrl->setOnCloseCallback([&](LLUICtrl*, const LLSD& data) { onCloseTexturePicker(data); }); + mTextureCtrl->setFollowsTop(); + mTextureCtrl->setFollowsLeft(); + mTextureCtrl->setImmediateFilterPermMask(PERM_NONE); + mTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); mShinyTextureCtrl = getChild("shinytexture control"); - if (mShinyTextureCtrl) - { - mShinyTextureCtrl->setDefaultImageAssetID(DEFAULT_OBJECT_SPECULAR); - mShinyTextureCtrl->setCommitCallback([&](LLUICtrl*, const LLSD& data) { onCommitSpecularTexture(data); }); - mShinyTextureCtrl->setOnCancelCallback([&](LLUICtrl*, const LLSD& data) { onCancelSpecularTexture(data); }); - mShinyTextureCtrl->setOnSelectCallback([&](LLUICtrl*, const LLSD& data) { onSelectSpecularTexture(data); }); - mShinyTextureCtrl->setOnCloseCallback([&](LLUICtrl*, const LLSD& data) { onCloseTexturePicker(data); }); - - mShinyTextureCtrl->setDragCallback([&](LLUICtrl*, LLInventoryItem* item) { return onDragTexture(item); }); - mShinyTextureCtrl->setOnTextureSelectedCallback([&](LLInventoryItem* item) { onTextureSelectionChanged(item); }); - mShinyTextureCtrl->setFollowsTop(); - mShinyTextureCtrl->setFollowsLeft(); - mShinyTextureCtrl->setImmediateFilterPermMask(PERM_NONE); - mShinyTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); - } + mShinyTextureCtrl->setDefaultImageAssetID(DEFAULT_OBJECT_SPECULAR); + mShinyTextureCtrl->setCommitCallback([&](LLUICtrl*, const LLSD& data) { onCommitSpecularTexture(data); }); + mShinyTextureCtrl->setOnCancelCallback([&](LLUICtrl*, const LLSD& data) { onCancelSpecularTexture(data); }); + mShinyTextureCtrl->setOnSelectCallback([&](LLUICtrl*, const LLSD& data) { onSelectSpecularTexture(data); }); + mShinyTextureCtrl->setDragCallback([&](LLUICtrl*, LLInventoryItem* item) { return onDragTexture(item); }); + mShinyTextureCtrl->setOnTextureSelectedCallback([&](LLInventoryItem* item) { onTextureSelectionChanged(item); }); + mShinyTextureCtrl->setOnCloseCallback([&](LLUICtrl*, const LLSD& data) { onCloseTexturePicker(data); }); + mShinyTextureCtrl->setFollowsTop(); + mShinyTextureCtrl->setFollowsLeft(); + mShinyTextureCtrl->setImmediateFilterPermMask(PERM_NONE); + mShinyTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); mBumpyTextureCtrl = getChild("bumpytexture control"); - if (mBumpyTextureCtrl) - { - mBumpyTextureCtrl->setDefaultImageAssetID(DEFAULT_OBJECT_NORMAL); - mBumpyTextureCtrl->setBlankImageAssetID(BLANK_OBJECT_NORMAL); - mBumpyTextureCtrl->setCommitCallback([&](LLUICtrl*, const LLSD& data) { onCommitNormalTexture(data); }); - mBumpyTextureCtrl->setOnCancelCallback([&](LLUICtrl*, const LLSD& data) { onCancelNormalTexture(data); }); - mBumpyTextureCtrl->setOnSelectCallback([&](LLUICtrl*, const LLSD& data) { onSelectNormalTexture(data); }); - mBumpyTextureCtrl->setOnCloseCallback([&](LLUICtrl*, const LLSD& data) { onCloseTexturePicker(data); }); - - mBumpyTextureCtrl->setDragCallback([&](LLUICtrl*, LLInventoryItem* item) { return onDragTexture(item); }); - mBumpyTextureCtrl->setOnTextureSelectedCallback([&](LLInventoryItem* item) { onTextureSelectionChanged(item); }); - mBumpyTextureCtrl->setFollowsTop(); - mBumpyTextureCtrl->setFollowsLeft(); - mBumpyTextureCtrl->setImmediateFilterPermMask(PERM_NONE); - mBumpyTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); - } + mBumpyTextureCtrl->setDefaultImageAssetID(DEFAULT_OBJECT_NORMAL); + mBumpyTextureCtrl->setBlankImageAssetID(BLANK_OBJECT_NORMAL); + mBumpyTextureCtrl->setCommitCallback([&](LLUICtrl*, const LLSD& data) { onCommitNormalTexture(data); }); + mBumpyTextureCtrl->setOnCancelCallback([&](LLUICtrl*, const LLSD& data) { onCancelNormalTexture(data); }); + mBumpyTextureCtrl->setOnSelectCallback([&](LLUICtrl*, const LLSD& data) { onSelectNormalTexture(data); }); + mBumpyTextureCtrl->setDragCallback([&](LLUICtrl*, LLInventoryItem* item) { return onDragTexture(item); }); + mBumpyTextureCtrl->setOnTextureSelectedCallback([&](LLInventoryItem* item) { onTextureSelectionChanged(item); }); + mBumpyTextureCtrl->setOnCloseCallback([&](LLUICtrl*, const LLSD& data) { onCloseTexturePicker(data); }); + mBumpyTextureCtrl->setFollowsTop(); + mBumpyTextureCtrl->setFollowsLeft(); + mBumpyTextureCtrl->setImmediateFilterPermMask(PERM_NONE); + mBumpyTextureCtrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER); mColorSwatch = getChild("colorswatch"); - if (mColorSwatch) - { - mColorSwatch->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitColor(); }); - mColorSwatch->setOnCancelCallback([&](LLUICtrl*, const LLSD&) { onCancelColor(); }); - mColorSwatch->setOnSelectCallback([&](LLUICtrl*, const LLSD&) { onSelectColor(); }); - mColorSwatch->setFollowsTop(); - mColorSwatch->setFollowsLeft(); - mColorSwatch->setCanApplyImmediately(true); - } + mColorSwatch->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitColor(); }); + mColorSwatch->setOnCancelCallback([&](LLUICtrl*, const LLSD&) { onCancelColor(); }); + mColorSwatch->setOnSelectCallback([&](LLUICtrl*, const LLSD&) { onSelectColor(); }); + mColorSwatch->setFollowsTop(); + mColorSwatch->setFollowsLeft(); + mColorSwatch->setCanApplyImmediately(true); mShinyColorSwatch = getChild("shinycolorswatch"); - if (mShinyColorSwatch) - { - mShinyColorSwatch->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitShinyColor(); }); - mShinyColorSwatch->setOnCancelCallback([&](LLUICtrl*, const LLSD&) { onCancelShinyColor(); }); - mShinyColorSwatch->setOnSelectCallback([&](LLUICtrl*, const LLSD&) { onSelectShinyColor(); }); - mShinyColorSwatch->setFollowsTop(); - mShinyColorSwatch->setFollowsLeft(); - mShinyColorSwatch->setCanApplyImmediately(true); - } + mShinyColorSwatch->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitShinyColor(); }); + mShinyColorSwatch->setOnCancelCallback([&](LLUICtrl*, const LLSD&) { onCancelShinyColor(); }); + mShinyColorSwatch->setOnSelectCallback([&](LLUICtrl*, const LLSD&) { onSelectShinyColor(); }); + mShinyColorSwatch->setFollowsTop(); + mShinyColorSwatch->setFollowsLeft(); + mShinyColorSwatch->setCanApplyImmediately(true); mLabelColorTransp = getChild("color trans"); - if (mLabelColorTransp) - { - mLabelColorTransp->setFollowsTop(); - mLabelColorTransp->setFollowsLeft(); - } + mLabelColorTransp->setFollowsTop(); + mLabelColorTransp->setFollowsLeft(); mCtrlColorTransp = getChild("ColorTrans"); - if (mCtrlColorTransp) - { - mCtrlColorTransp->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitAlpha(); }); - mCtrlColorTransp->setPrecision(0); - mCtrlColorTransp->setFollowsTop(); - mCtrlColorTransp->setFollowsLeft(); - } + mCtrlColorTransp->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitAlpha(); }); + mCtrlColorTransp->setPrecision(0); + mCtrlColorTransp->setFollowsTop(); + mCtrlColorTransp->setFollowsLeft(); mCheckFullbright = getChild("checkbox fullbright"); - if (mCheckFullbright) - { - mCheckFullbright->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitFullbright(); }); - } + mCheckFullbright->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitFullbright(); }); + mLabelTexGen = getChild("tex gen"); mComboTexGen = getChild("combobox texgen"); - if (mComboTexGen) - { - mComboTexGen->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitTexGen(); }); - mComboTexGen->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP); - } + mComboTexGen->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitTexGen(); }); + mComboTexGen->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP); mComboMatMedia = getChild("combobox matmedia"); - if (mComboMatMedia) - { - mComboMatMedia->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitMaterialsMedia(); }); - mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL); - } + mComboMatMedia->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitMaterialsMedia(); }); + mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL); mRadioMaterialType = getChild("radio_material_type"); - if (mRadioMaterialType) - { - mRadioMaterialType->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitMaterialType(); }); - mRadioMaterialType->selectNthItem(MATTYPE_DIFFUSE); - } + mRadioMaterialType->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitMaterialType(); }); + mRadioMaterialType->selectNthItem(MATTYPE_DIFFUSE); mRadioPbrType = getChild("radio_pbr_type"); - if (mRadioPbrType) - { - mRadioPbrType->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitPbrType(); }); - mRadioPbrType->selectNthItem(PBRTYPE_RENDER_MATERIAL_ID); - } + mRadioPbrType->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitPbrType(); }); + mRadioPbrType->selectNthItem(PBRTYPE_RENDER_MATERIAL_ID); + mLabelGlow = getChild("glow label"); mCtrlGlow = getChild("glow"); - if (mCtrlGlow) - { - mCtrlGlow->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitGlow(); }); - } + mCtrlGlow->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitGlow(); }); mMenuClipboardColor = getChild("clipboard_color_params_btn"); mMenuClipboardTexture = getChild("clipboard_texture_params_btn"); @@ -461,6 +418,19 @@ bool LLPanelFace::postBuild() mTitleMedia = getChild("title_media"); mTitleMediaText = getChild("media_info"); + mLabelBumpiness = getChild("label bumpiness"); + mLabelShininess = getChild("label shininess"); + mLabelAlphaMode = getChild("label alphamode"); + mLabelGlossiness = getChild("label glossiness"); + mLabelEnvironment = getChild("label environment"); + mLabelMaskCutoff = getChild("label maskcutoff"); + mLabelShiniColor = getChild("label shinycolor"); + mLabelColor = getChild("color label"); + + mLabelMatPermLoading = getChild("material_permissions_loading_label"); + + mCheckSyncSettings = getChild("checkbox_sync_settings"); + clearCtrls(); return true; @@ -513,8 +483,7 @@ void LLPanelFace::draw() void LLPanelFace::sendTexture() { - if(!mTextureCtrl) return; - if( !mTextureCtrl->getTentative() ) + if (!mTextureCtrl->getTentative()) { // we grab the item id first, because we want to do a // permissions check in the selection manager. ARGH! @@ -590,32 +559,26 @@ void LLPanelFace::sendShiny(U32 shininess) void LLPanelFace::sendFullbright() { - if(!mCheckFullbright)return; U8 fullbright = mCheckFullbright->get() ? TEM_FULLBRIGHT_MASK : 0; LLSelectMgr::getInstance()->selectionSetFullbright(fullbright); } void LLPanelFace::sendColor() { - if(!mColorSwatch)return; LLColor4 color = mColorSwatch->get(); LLSelectMgr::getInstance()->selectionSetColorOnly(color); } void LLPanelFace::sendAlpha() { - if(!mCtrlColorTransp)return; F32 alpha = (100.f - mCtrlColorTransp->get()) / 100.f; LLSelectMgr::getInstance()->selectionSetAlphaOnly( alpha ); } void LLPanelFace::sendGlow() { - if (mCtrlGlow) - { - F32 glow = mCtrlGlow->get(); - LLSelectMgr::getInstance()->selectionSetGlow( glow ); - } + F32 glow = mCtrlGlow->get(); + LLSelectMgr::getInstance()->selectionSetGlow(glow); } struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor @@ -623,47 +586,49 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor LLPanelFaceSetTEFunctor(LLPanelFace* panel) : mPanel(panel) {} virtual bool apply(LLViewerObject* object, S32 te) { - bool valid; - F32 value; - std::string prefix; + LLSpinCtrl *ctrlTexScaleS, *ctrlTexScaleT, *ctrlTexOffsetS, *ctrlTexOffsetT, *ctrlTexRotation; // Effectively the same as MATMEDIA_PBR sans using different radio, // separate for the sake of clarity - LLRadioGroup * radio_mat_type = mPanel->getChild("radio_material_type"); - switch (radio_mat_type->getSelectedIndex()) + switch (mPanel->mRadioMaterialType->getSelectedIndex()) { case MATTYPE_DIFFUSE: - prefix = "Tex"; + ctrlTexScaleS = mPanel->mTexScaleU; + ctrlTexScaleT = mPanel->mTexScaleV; + ctrlTexOffsetS = mPanel->mTexOffsetU; + ctrlTexOffsetT = mPanel->mTexOffsetV; + ctrlTexRotation = mPanel->mTexRotate; break; case MATTYPE_NORMAL: - prefix = "bumpy"; + ctrlTexScaleS = mPanel->mBumpyScaleU; + ctrlTexScaleT = mPanel->mBumpyScaleV; + ctrlTexOffsetS = mPanel->mBumpyOffsetU; + ctrlTexOffsetT = mPanel->mBumpyOffsetV; + ctrlTexRotation = mPanel->mBumpyRotate; break; case MATTYPE_SPECULAR: - prefix = "shiny"; + ctrlTexScaleS = mPanel->mShinyScaleU; + ctrlTexScaleT = mPanel->mShinyScaleV; + ctrlTexOffsetS = mPanel->mShinyOffsetU; + ctrlTexOffsetT = mPanel->mShinyOffsetV; + ctrlTexRotation = mPanel->mShinyRotate; break; + default: + llassert(false); + return false; } - LLSpinCtrl * ctrlTexScaleS = mPanel->getChild(prefix + "ScaleU"); - LLSpinCtrl * ctrlTexScaleT = mPanel->getChild(prefix + "ScaleV"); - LLSpinCtrl * ctrlTexOffsetS = mPanel->getChild(prefix + "OffsetU"); - LLSpinCtrl * ctrlTexOffsetT = mPanel->getChild(prefix + "OffsetV"); - LLSpinCtrl * ctrlTexRotation = mPanel->getChild(prefix + "Rot"); - - LLComboBox* comboTexGen = mPanel->getChild("combobox texgen"); - LLCheckBoxCtrl* cb_planar_align = mPanel->getChild("checkbox planar align"); - bool align_planar = (cb_planar_align && cb_planar_align->get()); + bool align_planar = mPanel->mPlanarAlign->get(); - llassert(comboTexGen); llassert(object); if (ctrlTexScaleS) { - valid = !ctrlTexScaleS->getTentative(); // || !checkFlipScaleS->getTentative(); + bool valid = !ctrlTexScaleS->getTentative(); // || !checkFlipScaleS->getTentative(); if (valid || align_planar) { - value = ctrlTexScaleS->get(); - if (comboTexGen && - comboTexGen->getCurrentIndex() == 1) + F32 value = ctrlTexScaleS->get(); + if (mPanel->mComboTexGen->getCurrentIndex() == 1) { value *= 0.5f; } @@ -679,20 +644,19 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor if (ctrlTexScaleT) { - valid = !ctrlTexScaleT->getTentative(); // || !checkFlipScaleT->getTentative(); + bool valid = !ctrlTexScaleT->getTentative(); // || !checkFlipScaleT->getTentative(); if (valid || align_planar) { - value = ctrlTexScaleT->get(); - //if( checkFlipScaleT->get() ) + F32 value = ctrlTexScaleT->get(); + //if (checkFlipScaleT->get()) //{ // value = -value; //} - if (comboTexGen && - comboTexGen->getCurrentIndex() == 1) + if (mPanel->mComboTexGen->getCurrentIndex() == 1) { value *= 0.5f; } - object->setTEScaleT( te, value ); + object->setTEScaleT(te, value); if (align_planar) { @@ -704,11 +668,11 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor if (ctrlTexOffsetS) { - valid = !ctrlTexOffsetS->getTentative(); + bool valid = !ctrlTexOffsetS->getTentative(); if (valid || align_planar) { - value = ctrlTexOffsetS->get(); - object->setTEOffsetS( te, value ); + F32 value = ctrlTexOffsetS->get(); + object->setTEOffsetS(te, value); if (align_planar) { @@ -720,11 +684,11 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor if (ctrlTexOffsetT) { - valid = !ctrlTexOffsetT->getTentative(); + bool valid = !ctrlTexOffsetT->getTentative(); if (valid || align_planar) { - value = ctrlTexOffsetT->get(); - object->setTEOffsetT( te, value ); + F32 value = ctrlTexOffsetT->get(); + object->setTEOffsetT(te, value); if (align_planar) { @@ -736,11 +700,11 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor if (ctrlTexRotation) { - valid = !ctrlTexRotation->getTentative(); + bool valid = !ctrlTexRotation->getTentative(); if (valid || align_planar) { - value = ctrlTexRotation->get() * DEG_TO_RAD; - object->setTERotation( te, value ); + F32 value = ctrlTexRotation->get() * DEG_TO_RAD; + object->setTERotation(te, value); if (align_planar) { @@ -947,7 +911,7 @@ struct LLPanelFaceSendFunctor : public LLSelectedObjectFunctor void LLPanelFace::sendTextureInfo() { - if (childGetValue("checkbox planar align").asBoolean()) + if (mPlanarAlign->getValue().asBoolean()) { LLFace* last_face = NULL; bool identical_face =false; @@ -999,7 +963,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) const bool has_material = !has_pbr_material; // only turn on auto-adjust button if there is a media renderer and the media is loaded - childSetEnabled("button align", editable); + mBtnAlign->setEnabled(editable); if (mComboMatMedia->getCurrentIndex() < MATMEDIA_MATERIAL) { @@ -1100,30 +1064,23 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) const bool pbr_selected = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR; const bool texture_info_selected = pbr_selected && mRadioPbrType->getSelectedIndex() != PBRTYPE_RENDER_MATERIAL_ID; - getChildView("checkbox_sync_settings")->setEnabled(editable); - childSetValue("checkbox_sync_settings", gSavedSettings.getBOOL("SyncMaterialSettings")); + mCheckSyncSettings->setEnabled(editable); + mCheckSyncSettings->setValue(gSavedSettings.getBOOL("SyncMaterialSettings")); updateVisibility(objectp); // Color swatch - { - getChildView("color label")->setEnabled(editable); - } - + mLabelColor->setEnabled(editable); LLColor4 color = LLColor4::white; bool identical_color = false; - { - LLSelectedTE::getColor(color, identical_color); - LLColor4 prev_color = mColorSwatch->get(); - - mColorSwatch->setOriginal(color); - mColorSwatch->set(color, force_set_values || (prev_color != color) || !editable); - - mColorSwatch->setValid(editable && !has_pbr_material); - mColorSwatch->setEnabled( editable && !has_pbr_material); - mColorSwatch->setCanApplyImmediately( editable && !has_pbr_material); - } + LLSelectedTE::getColor(color, identical_color); + LLColor4 prev_color = mColorSwatch->get(); + mColorSwatch->setOriginal(color); + mColorSwatch->set(color, force_set_values || (prev_color != color) || !editable); + mColorSwatch->setValid(editable && !has_pbr_material); + mColorSwatch->setEnabled( editable && !has_pbr_material); + mColorSwatch->setCanApplyImmediately( editable && !has_pbr_material); // Color transparency mLabelColorTransp->setEnabled(editable); @@ -1132,65 +1089,51 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) mCtrlColorTransp->setValue(editable ? transparency : 0); mCtrlColorTransp->setEnabled(editable && has_material); + // Shiny U8 shiny = 0; - bool identical_shiny = false; + { + bool identical_shiny = false; - // Shiny - LLSelectedTE::getShiny(shiny, identical_shiny); - identical = identical && identical_shiny; + LLSelectedTE::getShiny(shiny, identical_shiny); + identical = identical && identical_shiny; - shiny = specmap_id.isNull() ? shiny : SHINY_TEXTURE; + shiny = specmap_id.isNull() ? shiny : SHINY_TEXTURE; - LLCtrlSelectionInterface* combobox_shininess = childGetSelectionInterface("combobox shininess"); - if (combobox_shininess) - { - combobox_shininess->selectNthItem((S32)shiny); - } + mComboShininess->getSelectionInterface()->selectNthItem((S32)shiny); - getChildView("label shininess")->setEnabled(editable); - getChildView("combobox shininess")->setEnabled(editable); + mLabelShininess->setEnabled(editable); + mComboShininess->setEnabled(editable); - getChildView("label glossiness")->setEnabled(editable); - getChildView("glossiness")->setEnabled(editable); + mLabelGlossiness->setEnabled(editable); + mGlossiness->setEnabled(editable); - getChildView("label environment")->setEnabled(editable); - getChildView("environment")->setEnabled(editable); - getChildView("label shinycolor")->setEnabled(editable); + mLabelEnvironment->setEnabled(editable); + mEnvironment->setEnabled(editable); + mLabelShiniColor->setEnabled(editable); - getChild("combobox shininess")->setTentative(!identical_spec); - getChild("glossiness")->setTentative(!identical_spec); - getChild("environment")->setTentative(!identical_spec); - mShinyColorSwatch->setTentative(!identical_spec); + mComboShininess->setTentative(!identical_spec); + mGlossiness->setTentative(!identical_spec); + mEnvironment->setTentative(!identical_spec); + mShinyColorSwatch->setTentative(!identical_spec); - { mShinyColorSwatch->setValid(editable); - mShinyColorSwatch->setEnabled( editable ); - mShinyColorSwatch->setCanApplyImmediately( editable ); + mShinyColorSwatch->setEnabled(editable); + mShinyColorSwatch->setCanApplyImmediately(editable); } - U8 bumpy = 0; // Bumpy + U8 bumpy = 0; { bool identical_bumpy = false; - LLSelectedTE::getBumpmap(bumpy,identical_bumpy); + LLSelectedTE::getBumpmap(bumpy, identical_bumpy); LLUUID norm_map_id = getCurrentNormalMap(); - LLCtrlSelectionInterface* combobox_bumpiness = childGetSelectionInterface("combobox bumpiness"); - bumpy = norm_map_id.isNull() ? bumpy : BUMPY_TEXTURE; + mComboBumpiness->getSelectionInterface()->selectNthItem((S32)bumpy); - if (combobox_bumpiness) - { - combobox_bumpiness->selectNthItem((S32)bumpy); - } - else - { - LL_WARNS() << "failed childGetSelectionInterface for 'combobox bumpiness'" << LL_ENDL; - } - - getChildView("combobox bumpiness")->setEnabled(editable); - getChild("combobox bumpiness")->setTentative(!identical_bumpy); - getChildView("label bumpiness")->setEnabled(editable); + mComboBumpiness->setEnabled(editable); + mComboBumpiness->setTentative(!identical_bumpy); + mLabelBumpiness->setEnabled(editable); } // Texture @@ -1228,7 +1171,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) if (LLViewerMedia::getInstance()->textureHasMedia(id)) { - getChildView("button align")->setEnabled(editable); + mBtnAlign->setEnabled(editable); } // Diffuse Alpha Mode @@ -1243,22 +1186,14 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) // LLSelectedTEMaterial::getCurrentDiffuseAlphaMode(alpha_mode, identical_alpha_mode, mIsAlpha); - LLCtrlSelectionInterface* combobox_alphamode = childGetSelectionInterface("combobox alphamode"); - if (combobox_alphamode) - { - //it is invalid to have any alpha mode other than blend if transparency is greater than zero ... - // Want masking? Want emissive? Tough! You get BLEND! - alpha_mode = (transparency > 0.f) ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : alpha_mode; + // it is invalid to have any alpha mode other than blend if transparency is greater than zero ... + // Want masking? Want emissive? Tough! You get BLEND! + alpha_mode = (transparency > 0.f) ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : alpha_mode; - // ... unless there is no alpha channel in the texture, in which case alpha mode MUST be none - alpha_mode = mIsAlpha ? alpha_mode : LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + // ... unless there is no alpha channel in the texture, in which case alpha mode MUST be none + alpha_mode = mIsAlpha ? alpha_mode : LLMaterial::DIFFUSE_ALPHA_MODE_NONE; - combobox_alphamode->selectNthItem(alpha_mode); - } - else - { - LL_WARNS() << "failed childGetSelectionInterface for 'combobox alphamode'" << LL_ENDL; - } + mComboAlphaMode->getSelectionInterface()->selectNthItem(alpha_mode); updateAlphaControls(); @@ -1271,10 +1206,10 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) mTextureCtrl->setImageAssetID(id); bool can_change_alpha = editable && mIsAlpha && !missing_asset && !has_pbr_material; - getChildView("combobox alphamode")->setEnabled(can_change_alpha && transparency <= 0.f); - getChildView("label alphamode")->setEnabled(can_change_alpha); - getChildView("maskcutoff")->setEnabled(can_change_alpha); - getChildView("label maskcutoff")->setEnabled(can_change_alpha); + mComboAlphaMode->setEnabled(can_change_alpha && transparency <= 0.f); + mLabelAlphaMode->setEnabled(can_change_alpha); + mMaskCutoff->setEnabled(can_change_alpha); + mLabelMaskCutoff->setEnabled(can_change_alpha); mTextureCtrl->setBakeTextureEnabled(true); } @@ -1284,10 +1219,10 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) mTextureCtrl->setTentative(false); mTextureCtrl->setEnabled(false); mTextureCtrl->setImageAssetID(LLUUID::null); - getChildView("combobox alphamode")->setEnabled(false); - getChildView("label alphamode")->setEnabled(false); - getChildView("maskcutoff")->setEnabled(false); - getChildView("label maskcutoff")->setEnabled(false); + mComboAlphaMode->setEnabled(false); + mLabelAlphaMode->setEnabled(false); + mMaskCutoff->setEnabled(false); + mLabelMaskCutoff->setEnabled(false); mTextureCtrl->setBakeTextureEnabled(false); } @@ -1299,10 +1234,10 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) mTextureCtrl->setImageAssetID(id); bool can_change_alpha = editable && mIsAlpha && !missing_asset && !has_pbr_material; - getChildView("combobox alphamode")->setEnabled(can_change_alpha && transparency <= 0.f); - getChildView("label alphamode")->setEnabled(can_change_alpha); - getChildView("maskcutoff")->setEnabled(can_change_alpha); - getChildView("label maskcutoff")->setEnabled(can_change_alpha); + mComboAlphaMode->setEnabled(can_change_alpha && transparency <= 0.f); + mLabelAlphaMode->setEnabled(can_change_alpha); + mMaskCutoff->setEnabled(can_change_alpha); + mLabelMaskCutoff->setEnabled(can_change_alpha); mTextureCtrl->setBakeTextureEnabled(true); } @@ -1354,28 +1289,24 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) } // planar align - bool align_planar = false; + bool align_planar = mPlanarAlign->get(); bool identical_planar_aligned = false; - { - LLCheckBoxCtrl* cb_planar_align = getChild("checkbox planar align"); - align_planar = (cb_planar_align && cb_planar_align->get()); - bool enabled = (editable && isIdenticalPlanarTexgen() && !texture_info_selected); - childSetValue("checkbox planar align", align_planar && enabled); - childSetVisible("checkbox planar align", enabled); - childSetEnabled("checkbox planar align", enabled); - childSetEnabled("button align textures", enabled && LLSelectMgr::getInstance()->getSelection()->getObjectCount() > 1); + bool enabled = (editable && isIdenticalPlanarTexgen() && !texture_info_selected); + mPlanarAlign->setValue(align_planar && enabled); + mPlanarAlign->setVisible(enabled); + mPlanarAlign->setEnabled(enabled); + mBtnAlignTex->setEnabled(enabled && LLSelectMgr::getInstance()->getSelection()->getObjectCount() > 1); - if (align_planar && enabled) - { - LLFace* last_face = NULL; - bool identical_face = false; - LLSelectedTE::getFace(last_face, identical_face); + if (align_planar && enabled) + { + LLFace* last_face = NULL; + bool identical_face = false; + LLSelectedTE::getFace(last_face, identical_face); - LLPanelFaceGetIsAlignedTEFunctor get_is_aligend_func(last_face); - // this will determine if the texture param controls are tentative: - identical_planar_aligned = LLSelectMgr::getInstance()->getSelection()->applyToTEs(&get_is_aligend_func); - } + LLPanelFaceGetIsAlignedTEFunctor get_is_aligend_func(last_face); + // this will determine if the texture param controls are tentative: + identical_planar_aligned = LLSelectMgr::getInstance()->getSelection()->applyToTEs(&get_is_aligend_func); } // Needs to be public and before tex scale settings below to properly reflect @@ -1414,21 +1345,21 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) spec_scale_s = editable ? spec_scale_s : 1.0f; spec_scale_s *= identical_planar_texgen ? 2.0f : 1.0f; - getChild("TexScaleU")->setValue(diff_scale_s); - getChild("shinyScaleU")->setValue(spec_scale_s); - getChild("bumpyScaleU")->setValue(norm_scale_s); + mTexScaleU->setValue(diff_scale_s); + mShinyScaleU->setValue(spec_scale_s); + mBumpyScaleU->setValue(norm_scale_s); - getChildView("TexScaleU")->setEnabled(editable && has_material); - getChildView("shinyScaleU")->setEnabled(editable && has_material && specmap_id.notNull()); - getChildView("bumpyScaleU")->setEnabled(editable && has_material && normmap_id.notNull()); + mTexScaleU->setEnabled(editable && has_material); + mShinyScaleU->setEnabled(editable && has_material && specmap_id.notNull()); + mBumpyScaleU->setEnabled(editable && has_material && normmap_id.notNull()); bool diff_scale_tentative = !(identical && identical_diff_scale_s); bool norm_scale_tentative = !(identical && identical_norm_scale_s); bool spec_scale_tentative = !(identical && identical_spec_scale_s); - getChild("TexScaleU")->setTentative(LLSD(diff_scale_tentative)); - getChild("shinyScaleU")->setTentative(LLSD(spec_scale_tentative)); - getChild("bumpyScaleU")->setTentative(LLSD(norm_scale_tentative)); + mTexScaleU->setTentative(LLSD(diff_scale_tentative)); + mShinyScaleU->setTentative(LLSD(spec_scale_tentative)); + mBumpyScaleU->setTentative(LLSD(norm_scale_tentative)); } { @@ -1457,24 +1388,24 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) bool norm_scale_tentative = !identical_norm_scale_t; bool spec_scale_tentative = !identical_spec_scale_t; - getChildView("TexScaleV")->setEnabled(editable && has_material); - getChildView("shinyScaleV")->setEnabled(editable && has_material && specmap_id.notNull()); - getChildView("bumpyScaleV")->setEnabled(editable && has_material && normmap_id.notNull()); + mTexScaleV->setEnabled(editable && has_material); + mShinyScaleV->setEnabled(editable && has_material && specmap_id.notNull()); + mBumpyScaleV->setEnabled(editable && has_material && normmap_id.notNull()); if (force_set_values) { - getChild("TexScaleV")->forceSetValue(diff_scale_t); + mTexScaleV->forceSetValue(diff_scale_t); } else { - getChild("TexScaleV")->setValue(diff_scale_t); + mTexScaleV->setValue(diff_scale_t); } - getChild("shinyScaleV")->setValue(norm_scale_t); - getChild("bumpyScaleV")->setValue(spec_scale_t); + mShinyScaleV->setValue(norm_scale_t); + mBumpyScaleV->setValue(spec_scale_t); - getChild("TexScaleV")->setTentative(LLSD(diff_scale_tentative)); - getChild("shinyScaleV")->setTentative(LLSD(norm_scale_tentative)); - getChild("bumpyScaleV")->setTentative(LLSD(spec_scale_tentative)); + mTexScaleV->setTentative(LLSD(diff_scale_tentative)); + mShinyScaleV->setTentative(LLSD(spec_scale_tentative)); + mBumpyScaleV->setTentative(LLSD(norm_scale_tentative)); } // Texture offset @@ -1495,17 +1426,17 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) bool norm_offset_u_tentative = !(align_planar ? identical_planar_aligned : identical_norm_offset_s); bool spec_offset_u_tentative = !(align_planar ? identical_planar_aligned : identical_spec_offset_s); - getChild("TexOffsetU")->setValue( editable ? diff_offset_s : 0.0f); - getChild("bumpyOffsetU")->setValue(editable ? norm_offset_s : 0.0f); - getChild("shinyOffsetU")->setValue(editable ? spec_offset_s : 0.0f); + mTexOffsetU->setValue(editable ? diff_offset_s : 0.0f); + mBumpyOffsetU->setValue(editable ? norm_offset_s : 0.0f); + mShinyOffsetU->setValue(editable ? spec_offset_s : 0.0f); - getChild("TexOffsetU")->setTentative(LLSD(diff_offset_u_tentative)); - getChild("shinyOffsetU")->setTentative(LLSD(norm_offset_u_tentative)); - getChild("bumpyOffsetU")->setTentative(LLSD(spec_offset_u_tentative)); + mTexOffsetU->setTentative(LLSD(diff_offset_u_tentative)); + mShinyOffsetU->setTentative(LLSD(spec_offset_u_tentative)); + mBumpyOffsetU->setTentative(LLSD(norm_offset_u_tentative)); - getChildView("TexOffsetU")->setEnabled(editable && has_material); - getChildView("shinyOffsetU")->setEnabled(editable && has_material && specmap_id.notNull()); - getChildView("bumpyOffsetU")->setEnabled(editable && has_material && normmap_id.notNull()); + mTexOffsetU->setEnabled(editable && has_material); + mShinyOffsetU->setEnabled(editable && has_material && specmap_id.notNull()); + mBumpyOffsetU->setEnabled(editable && has_material && normmap_id.notNull()); } { @@ -1525,17 +1456,17 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) bool norm_offset_v_tentative = !(align_planar ? identical_planar_aligned : identical_norm_offset_t); bool spec_offset_v_tentative = !(align_planar ? identical_planar_aligned : identical_spec_offset_t); - getChild("TexOffsetV")->setValue( editable ? diff_offset_t : 0.0f); - getChild("bumpyOffsetV")->setValue(editable ? norm_offset_t : 0.0f); - getChild("shinyOffsetV")->setValue(editable ? spec_offset_t : 0.0f); + mTexOffsetV->setValue( editable ? diff_offset_t : 0.0f); + mBumpyOffsetV->setValue(editable ? norm_offset_t : 0.0f); + mShinyOffsetV->setValue(editable ? spec_offset_t : 0.0f); - getChild("TexOffsetV")->setTentative(LLSD(diff_offset_v_tentative)); - getChild("shinyOffsetV")->setTentative(LLSD(norm_offset_v_tentative)); - getChild("bumpyOffsetV")->setTentative(LLSD(spec_offset_v_tentative)); + mTexOffsetV->setTentative(LLSD(diff_offset_v_tentative)); + mBumpyOffsetV->setTentative(LLSD(norm_offset_v_tentative)); + mShinyOffsetV->setTentative(LLSD(spec_offset_v_tentative)); - getChildView("TexOffsetV")->setEnabled(editable && has_material); - getChildView("shinyOffsetV")->setEnabled(editable && has_material && specmap_id.notNull()); - getChildView("bumpyOffsetV")->setEnabled(editable && has_material && normmap_id.notNull()); + mTexOffsetV->setEnabled(editable && has_material); + mShinyOffsetV->setEnabled(editable && has_material && specmap_id.notNull()); + mBumpyOffsetV->setEnabled(editable && has_material && normmap_id.notNull()); } // Texture rotation @@ -1560,17 +1491,17 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) F32 norm_rot_deg = norm_rotation * RAD_TO_DEG; F32 spec_rot_deg = spec_rotation * RAD_TO_DEG; - getChildView("TexRot")->setEnabled(editable && has_material); - getChildView("shinyRot")->setEnabled(editable && has_material && specmap_id.notNull()); - getChildView("bumpyRot")->setEnabled(editable && has_material && normmap_id.notNull()); + mTexRotate->setEnabled(editable && has_material); + mShinyRotate->setEnabled(editable && has_material && specmap_id.notNull()); + mBumpyRotate->setEnabled(editable && has_material && normmap_id.notNull()); - getChild("TexRot")->setTentative(LLSD(diff_rot_tentative)); - getChild("shinyRot")->setTentative(LLSD(spec_rot_tentative)); - getChild("bumpyRot")->setTentative(LLSD(norm_rot_tentative)); + mTexRotate->setTentative(LLSD(diff_rot_tentative)); + mShinyRotate->setTentative(LLSD(spec_rot_tentative)); + mBumpyRotate->setTentative(LLSD(norm_rot_tentative)); - getChild("TexRot")->setValue(editable ? diff_rot_deg : 0.0f); - getChild("shinyRot")->setValue(editable ? spec_rot_deg : 0.0f); - getChild("bumpyRot")->setValue(editable ? norm_rot_deg : 0.0f); + mTexRotate->setValue(editable ? diff_rot_deg : 0.0f); + mShinyRotate->setValue(editable ? spec_rot_deg : 0.0f); + mBumpyRotate->setValue(editable ? norm_rot_deg : 0.0f); } { @@ -1580,7 +1511,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) mCtrlGlow->setValue(glow); mCtrlGlow->setTentative(!identical_glow); mCtrlGlow->setEnabled(editable); - getChildView("glow label")->setEnabled(editable); + mLabelGlow->setEnabled(editable); } { @@ -1589,7 +1520,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) mComboTexGen->setEnabled(editable); mComboTexGen->setTentative(!identical); - getChildView("tex gen")->setEnabled(editable); + mLabelTexGen->setEnabled(editable); } { @@ -1667,18 +1598,17 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) bool repeats_tentative = !identical_repeats; - LLSpinCtrl* rpt_ctrl = getChild("rptctrl"); if (force_set_values) { - //onCommit, previosly edited element updates related ones - rpt_ctrl->forceSetValue(editable ? repeats : 1.0f); + // onCommit, previosly edited element updates related ones + mTexRepeat->forceSetValue(editable ? repeats : 1.0f); } else { - rpt_ctrl->setValue(editable ? repeats : 1.0f); + mTexRepeat->setValue(editable ? repeats : 1.0f); } - rpt_ctrl->setTentative(LLSD(repeats_tentative)); - rpt_ctrl->setEnabled(has_material && !identical_planar_texgen && enabled); + mTexRepeat->setTentative(LLSD(repeats_tentative)); + mTexRepeat->setEnabled(has_material && !identical_planar_texgen && enabled); } } @@ -1692,9 +1622,6 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LL_DEBUGS("Materials") << material->asLLSD() << LL_ENDL; // Alpha - LLCtrlSelectionInterface* combobox_alphamode = - childGetSelectionInterface("combobox alphamode"); - if (combobox_alphamode) { U32 alpha_mode = material->getDiffuseAlphaMode(); @@ -1708,14 +1635,10 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE; } - combobox_alphamode->selectNthItem(alpha_mode); - } - else - { - LL_WARNS() << "failed childGetSelectionInterface for 'combobox alphamode'" << LL_ENDL; + mComboAlphaMode->getSelectionInterface()->selectNthItem(alpha_mode); } - getChild("maskcutoff")->setValue(material->getAlphaMaskCutoff()); + mMaskCutoff->setValue(material->getAlphaMaskCutoff()); updateAlphaControls(); identical_planar_texgen = isIdenticalPlanarTexgen(); @@ -1736,13 +1659,13 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) } rot = material->getSpecularRotation(); - getChild("shinyScaleU")->setValue(repeat_x); - getChild("shinyScaleV")->setValue(repeat_y); - getChild("shinyRot")->setValue(rot * RAD_TO_DEG); - getChild("shinyOffsetU")->setValue(offset_x); - getChild("shinyOffsetV")->setValue(offset_y); - getChild("glossiness")->setValue(material->getSpecularLightExponent()); - getChild("environment")->setValue(material->getEnvironmentIntensity()); + mShinyScaleU->setValue(repeat_x); + mShinyScaleV->setValue(repeat_y); + mShinyRotate->setValue(rot * RAD_TO_DEG); + mShinyOffsetU->setValue(offset_x); + mShinyOffsetV->setValue(offset_y); + mGlossiness->setValue(material->getSpecularLightExponent()); + mEnvironment->setValue(material->getEnvironmentIntensity()); updateShinyControls(!material->getSpecularID().isNull(), true); } @@ -1774,11 +1697,11 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) } rot = material->getNormalRotation(); - getChild("bumpyScaleU")->setValue(repeat_x); - getChild("bumpyScaleV")->setValue(repeat_y); - getChild("bumpyRot")->setValue(rot * RAD_TO_DEG); - getChild("bumpyOffsetU")->setValue(offset_x); - getChild("bumpyOffsetV")->setValue(offset_y); + mBumpyScaleU->setValue(repeat_x); + mBumpyScaleV->setValue(repeat_y); + mBumpyRotate->setValue(rot*RAD_TO_DEG); + mBumpyOffsetU->setValue(offset_x); + mBumpyOffsetV->setValue(offset_y); updateBumpyControls(!material->getNormalID().isNull(), true); } @@ -1791,11 +1714,11 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) // Set variable values for numeric expressions LLCalc* calcp = LLCalc::getInstance(); - calcp->setVar(LLCalc::TEX_U_SCALE, (F32)childGetValue("TexScaleU").asReal()); - calcp->setVar(LLCalc::TEX_V_SCALE, (F32)childGetValue("TexScaleV").asReal()); - calcp->setVar(LLCalc::TEX_U_OFFSET, (F32)childGetValue("TexOffsetU").asReal()); - calcp->setVar(LLCalc::TEX_V_OFFSET, (F32)childGetValue("TexOffsetV").asReal()); - calcp->setVar(LLCalc::TEX_ROTATION, (F32)childGetValue("TexRot").asReal()); + calcp->setVar(LLCalc::TEX_U_SCALE, (F32)mTexScaleU->getValue().asReal()); + calcp->setVar(LLCalc::TEX_V_SCALE, (F32)mTexScaleV->getValue().asReal()); + calcp->setVar(LLCalc::TEX_U_OFFSET, (F32)mTexOffsetU->getValue().asReal()); + calcp->setVar(LLCalc::TEX_V_OFFSET, (F32)mTexOffsetV->getValue().asReal()); + calcp->setVar(LLCalc::TEX_ROTATION, (F32)mTexRotate->getValue().asReal()); calcp->setVar(LLCalc::TEX_TRANSPARENCY, (F32)mCtrlColorTransp->getValue().asReal()); calcp->setVar(LLCalc::TEX_GLOW, (F32)mCtrlGlow->getValue().asReal()); } @@ -1830,14 +1753,14 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) mRadioMaterialType->setSelectedIndex(0); } mLabelColorTransp->setEnabled(false); - getChildView("rptctrl")->setEnabled(false); - getChildView("tex gen")->setEnabled(false); - getChildView("label shininess")->setEnabled(false); - getChildView("label bumpiness")->setEnabled(false); - getChildView("button align")->setEnabled(false); - getChildView("pbr_from_inventory")->setEnabled(false); - getChildView("edit_selected_pbr")->setEnabled(false); - getChildView("save_selected_pbr")->setEnabled(false); + mTexRepeat->setEnabled(false); + mLabelTexGen->setEnabled(false); + mLabelShininess->setEnabled(false); + mLabelBumpiness->setEnabled(false); + mBtnAlign->setEnabled(false); + mBtnPbrFromInv->setEnabled(false); + mBtnEditBbr->setEnabled(false); + mBtnSaveBbr->setEnabled(false); updateVisibility(); @@ -1960,9 +1883,9 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material, } } - getChildView("pbr_from_inventory")->setEnabled(settable); - getChildView("edit_selected_pbr")->setEnabled(editable && !has_faces_without_pbr); - getChildView("save_selected_pbr")->setEnabled(saveable && identical_pbr); + mBtnPbrFromInv->setEnabled(settable); + mBtnEditBbr->setEnabled(editable && !has_faces_without_pbr); + mBtnSaveBbr->setEnabled(saveable && identical_pbr); if (objectp->isInventoryPending()) { // Reuse the same listener when possible @@ -1992,17 +1915,11 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material, { const bool new_state = has_pbr_capabilities && has_pbr_material && !has_faces_without_pbr; - LLUICtrl* gltfCtrlTextureScaleU = getChild("gltfTextureScaleU"); - LLUICtrl* gltfCtrlTextureScaleV = getChild("gltfTextureScaleV"); - LLUICtrl* gltfCtrlTextureRotation = getChild("gltfTextureRotation"); - LLUICtrl* gltfCtrlTextureOffsetU = getChild("gltfTextureOffsetU"); - LLUICtrl* gltfCtrlTextureOffsetV = getChild("gltfTextureOffsetV"); - - gltfCtrlTextureScaleU->setEnabled(new_state); - gltfCtrlTextureScaleV->setEnabled(new_state); - gltfCtrlTextureRotation->setEnabled(new_state); - gltfCtrlTextureOffsetU->setEnabled(new_state); - gltfCtrlTextureOffsetV->setEnabled(new_state); + mPBRScaleU->setEnabled(new_state); + mPBRScaleV->setEnabled(new_state); + mPBRRotate->setEnabled(new_state); + mPBROffsetU->setEnabled(new_state); + mPBROffsetV->setEnabled(new_state); // Control values will be set once per frame in // setMaterialOverridesFromSelection @@ -2022,16 +1939,16 @@ void LLPanelFace::updateVisibilityGLTF(LLViewerObject* objectp /*= nullptr */) mPBRTextureCtrl->setVisible(show_pbr_render_material_id); - getChildView("pbr_from_inventory")->setVisible(show_pbr_render_material_id); - getChildView("edit_selected_pbr")->setVisible(show_pbr_render_material_id && !inventory_pending); - getChildView("save_selected_pbr")->setVisible(show_pbr_render_material_id && !inventory_pending); - getChildView("material_permissions_loading_label")->setVisible(show_pbr_render_material_id && inventory_pending); + mBtnPbrFromInv->setVisible(show_pbr_render_material_id); + mBtnEditBbr->setVisible(show_pbr_render_material_id && !inventory_pending); + mBtnSaveBbr->setVisible(show_pbr_render_material_id && !inventory_pending); + mLabelMatPermLoading->setVisible(show_pbr_render_material_id && inventory_pending); - getChildView("gltfTextureScaleU")->setVisible(show_pbr); - getChildView("gltfTextureScaleV")->setVisible(show_pbr); - getChildView("gltfTextureRotation")->setVisible(show_pbr); - getChildView("gltfTextureOffsetU")->setVisible(show_pbr); - getChildView("gltfTextureOffsetV")->setVisible(show_pbr); + mPBRScaleU->setVisible(show_pbr); + mPBRScaleV->setVisible(show_pbr); + mPBRRotate->setVisible(show_pbr); + mPBROffsetU->setVisible(show_pbr); + mPBROffsetV->setVisible(show_pbr); } void LLPanelFace::updateCopyTexButton() @@ -2061,7 +1978,7 @@ void LLPanelFace::refreshMedia() && first_object->permModify() )) { - getChildView("add_media")->setEnabled(false); + mAddMedia->setEnabled(false); mTitleMediaText->clear(); clearMediaSettings(); return; @@ -2072,7 +1989,7 @@ void LLPanelFace::refreshMedia() if (!has_media_capability) { - getChildView("add_media")->setEnabled(false); + mAddMedia->setEnabled(false); LL_WARNS("LLFloaterToolsMedia") << "Media not enabled (no capability) in this region!" << LL_ENDL; clearMediaSettings(); return; @@ -2154,7 +2071,7 @@ void LLPanelFace::refreshMedia() // update UI depending on whether "object" (prim or face) has media // and whether or not you are allowed to edit it. - getChildView("add_media")->setEnabled(editable); + mAddMedia->setEnabled(editable); // IF all the faces have media (or all dont have media) if (LLFloaterMediaSettings::getInstance()->mIdenticalHasMediaInfo) { @@ -2176,7 +2093,7 @@ void LLPanelFace::refreshMedia() media_title = multi_media_info_str; } - getChildView("delete_media")->setEnabled(bool_has_media && editable); + mDelMedia->setEnabled(bool_has_media && editable); // TODO: display a list of all media on the face - use 'identical' flag } else // not all face has media but at least one does. @@ -2198,7 +2115,7 @@ void LLPanelFace::refreshMedia() } } - getChildView("delete_media")->setEnabled(true); + mDelMedia->setEnabled(true); } U32 materials_media = mComboMatMedia->getCurrentIndex(); @@ -2862,9 +2779,7 @@ void LLPanelFace::onCommitMaterialsMedia() void LLPanelFace::updateVisibility(LLViewerObject* objectp /* = nullptr */) { - LLComboBox* combo_shininess = findChild("combobox shininess"); - LLComboBox* combo_bumpiness = findChild("combobox bumpiness"); - if (!mRadioMaterialType || !mRadioPbrType || !mComboMatMedia || !combo_shininess || !combo_bumpiness) + if (!mRadioMaterialType || !mRadioPbrType) { LL_WARNS("Materials") << "Combo box not found...exiting." << LL_ENDL; return; @@ -2884,53 +2799,53 @@ void LLPanelFace::updateVisibility(LLViewerObject* objectp /* = nullptr */) mRadioMaterialType->setVisible(show_material); // Shared material controls - getChildView("checkbox_sync_settings")->setVisible(show_material || show_media); - getChildView("tex gen")->setVisible(show_material || show_media || show_pbr_asset); + mCheckSyncSettings->setVisible(show_material || show_media); + mLabelTexGen->setVisible(show_material || show_media || show_pbr_asset); mComboTexGen->setVisible(show_material || show_media || show_pbr_asset); - getChildView("button align textures")->setVisible(show_material || show_media); + mBtnAlignTex->setVisible(show_material || show_media); // Media controls mTitleMediaText->setVisible(show_media); - getChildView("add_media")->setVisible(show_media); - getChildView("delete_media")->setVisible(show_media); - getChildView("button align")->setVisible(show_media); + mAddMedia->setVisible(show_media); + mDelMedia->setVisible(show_media); + mBtnAlign->setVisible(show_media); // Diffuse texture controls mTextureCtrl->setVisible(show_texture && show_material); - getChildView("label alphamode")->setVisible(show_texture && show_material); - getChildView("combobox alphamode")->setVisible(show_texture && show_material); - getChildView("label maskcutoff")->setVisible(false); - getChildView("maskcutoff")->setVisible(false); + mLabelAlphaMode->setVisible(show_texture && show_material); + mComboAlphaMode->setVisible(show_texture && show_material); + mLabelMaskCutoff->setVisible(false); + mMaskCutoff->setVisible(false); if (show_texture && show_material) { updateAlphaControls(); } // texture scale and position controls - getChildView("TexScaleU")->setVisible(show_texture); - getChildView("TexScaleV")->setVisible(show_texture); - getChildView("TexRot")->setVisible(show_texture); - getChildView("TexOffsetU")->setVisible(show_texture); - getChildView("TexOffsetV")->setVisible(show_texture); + mTexScaleU->setVisible(show_texture); + mTexScaleV->setVisible(show_texture); + mTexRotate->setVisible(show_texture); + mTexOffsetU->setVisible(show_texture); + mTexOffsetV->setVisible(show_texture); // Specular map controls mShinyTextureCtrl->setVisible(show_shininess); - getChildView("combobox shininess")->setVisible(show_shininess); - getChildView("label shininess")->setVisible(show_shininess); - getChildView("label glossiness")->setVisible(false); - getChildView("glossiness")->setVisible(false); - getChildView("label environment")->setVisible(false); - getChildView("environment")->setVisible(false); - getChildView("label shinycolor")->setVisible(false); + mComboShininess->setVisible(show_shininess); + mLabelShininess->setVisible(show_shininess); + mLabelGlossiness->setVisible(false); + mGlossiness->setVisible(false); + mLabelEnvironment->setVisible(false); + mEnvironment->setVisible(false); + mLabelShiniColor->setVisible(false); mShinyColorSwatch->setVisible(false); if (show_shininess) { updateShinyControls(); } - getChildView("shinyScaleU")->setVisible(show_shininess); - getChildView("shinyScaleV")->setVisible(show_shininess); - getChildView("shinyRot")->setVisible(show_shininess); - getChildView("shinyOffsetU")->setVisible(show_shininess); - getChildView("shinyOffsetV")->setVisible(show_shininess); + mShinyScaleU->setVisible(show_shininess); + mShinyScaleV->setVisible(show_shininess); + mShinyRotate->setVisible(show_shininess); + mShinyOffsetU->setVisible(show_shininess); + mShinyOffsetV->setVisible(show_shininess); // Normal map controls if (show_bumpiness) @@ -2938,15 +2853,15 @@ void LLPanelFace::updateVisibility(LLViewerObject* objectp /* = nullptr */) updateBumpyControls(); } mBumpyTextureCtrl->setVisible(show_bumpiness); - getChildView("combobox bumpiness")->setVisible(show_bumpiness); - getChildView("label bumpiness")->setVisible(show_bumpiness); - getChildView("bumpyScaleU")->setVisible(show_bumpiness); - getChildView("bumpyScaleV")->setVisible(show_bumpiness); - getChildView("bumpyRot")->setVisible(show_bumpiness); - getChildView("bumpyOffsetU")->setVisible(show_bumpiness); - getChildView("bumpyOffsetV")->setVisible(show_bumpiness); + mComboBumpiness->setVisible(show_bumpiness); + mLabelBumpiness->setVisible(show_bumpiness); + mBumpyScaleU->setVisible(show_bumpiness); + mBumpyScaleV->setVisible(show_bumpiness); + mBumpyRotate->setVisible(show_bumpiness); + mBumpyOffsetU->setVisible(show_bumpiness); + mBumpyOffsetV->setVisible(show_bumpiness); - getChild("rptctrl")->setVisible(show_material || show_media); + mTexRepeat->setVisible(show_material || show_media); // PBR controls updateVisibilityGLTF(objectp); @@ -2972,7 +2887,7 @@ void LLPanelFace::onCommitPbrType() void LLPanelFace::onCommitBump() { - sendBump(getChild("combobox bumpiness")->getCurrentIndex()); + sendBump(mComboBumpiness->getCurrentIndex()); } void LLPanelFace::onCommitTexGen() @@ -2984,33 +2899,32 @@ void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_sh { LLUUID shiny_texture_ID = mShinyTextureCtrl->getImageAssetID(); LL_DEBUGS("Materials") << "Shiny texture selected: " << shiny_texture_ID << LL_ENDL; - LLComboBox* comboShiny = getChild("combobox shininess"); if (mess_with_shiny_combobox) { if (!shiny_texture_ID.isNull() && is_setting_texture) { - if (!comboShiny->itemExists(USE_TEXTURE)) + if (!mComboShininess->itemExists(USE_TEXTURE)) { - comboShiny->add(USE_TEXTURE); + mComboShininess->add(USE_TEXTURE); } - comboShiny->setSimple(USE_TEXTURE); + mComboShininess->setSimple(USE_TEXTURE); } else { - if (comboShiny->itemExists(USE_TEXTURE)) + if (mComboShininess->itemExists(USE_TEXTURE)) { - comboShiny->remove(SHINY_TEXTURE); - comboShiny->selectFirstItem(); + mComboShininess->remove(SHINY_TEXTURE); + mComboShininess->selectFirstItem(); } } } else { - if (shiny_texture_ID.isNull() && comboShiny->itemExists(USE_TEXTURE)) + if (shiny_texture_ID.isNull() && mComboShininess->itemExists(USE_TEXTURE)) { - comboShiny->remove(SHINY_TEXTURE); - comboShiny->selectFirstItem(); + mComboShininess->remove(SHINY_TEXTURE); + mComboShininess->selectFirstItem(); } } @@ -3018,13 +2932,13 @@ void LLPanelFace::updateShinyControls(bool is_setting_texture, bool mess_with_sh U32 material_type = mRadioMaterialType->getSelectedIndex(); bool show_material = (materials_media == MATMEDIA_MATERIAL); bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && mComboMatMedia->getEnabled(); - U32 shiny_value = comboShiny->getCurrentIndex(); + U32 shiny_value = mComboShininess->getCurrentIndex(); bool show_shinyctrls = (shiny_value == SHINY_TEXTURE) && show_shininess; // Use texture - getChildView("label glossiness")->setVisible(show_shinyctrls); - getChildView("glossiness")->setVisible(show_shinyctrls); - getChildView("label environment")->setVisible(show_shinyctrls); - getChildView("environment")->setVisible(show_shinyctrls); - getChildView("label shinycolor")->setVisible(show_shinyctrls); + mLabelGlossiness->setVisible(show_shinyctrls); + mGlossiness->setVisible(show_shinyctrls); + mLabelEnvironment->setVisible(show_shinyctrls); + mEnvironment->setVisible(show_shinyctrls); + mLabelShiniColor->setVisible(show_shinyctrls); mShinyColorSwatch->setVisible(show_shinyctrls); } @@ -3032,24 +2946,23 @@ void LLPanelFace::updateBumpyControls(bool is_setting_texture, bool mess_with_co { LLUUID bumpy_texture_ID = mBumpyTextureCtrl->getImageAssetID(); LL_DEBUGS("Materials") << "texture: " << bumpy_texture_ID << (mess_with_combobox ? "" : " do not") << " update combobox" << LL_ENDL; - LLComboBox* comboBumpy = getChild("combobox bumpiness"); if (mess_with_combobox) { if (!bumpy_texture_ID.isNull() && is_setting_texture) { - if (!comboBumpy->itemExists(USE_TEXTURE)) + if (!mComboBumpiness->itemExists(USE_TEXTURE)) { - comboBumpy->add(USE_TEXTURE); + mComboBumpiness->add(USE_TEXTURE); } - comboBumpy->setSimple(USE_TEXTURE); + mComboBumpiness->setSimple(USE_TEXTURE); } else { - if (comboBumpy->itemExists(USE_TEXTURE)) + if (mComboBumpiness->itemExists(USE_TEXTURE)) { - comboBumpy->remove(BUMPY_TEXTURE); - comboBumpy->selectFirstItem(); + mComboBumpiness->remove(BUMPY_TEXTURE); + mComboBumpiness->selectFirstItem(); } } } @@ -3057,12 +2970,12 @@ void LLPanelFace::updateBumpyControls(bool is_setting_texture, bool mess_with_co void LLPanelFace::onCommitShiny() { - sendShiny(getChild("combobox shininess")->getCurrentIndex()); + sendShiny(mComboShininess->getCurrentIndex()); } void LLPanelFace::updateAlphaControls() { - U32 alpha_value = getChild("combobox alphamode")->getCurrentIndex(); + U32 alpha_value = mComboAlphaMode->getCurrentIndex(); bool show_alphactrls = (alpha_value == ALPHAMODE_MASK); // Alpha masking U32 mat_media = mComboMatMedia->getCurrentIndex(); @@ -3071,8 +2984,8 @@ void LLPanelFace::updateAlphaControls() show_alphactrls = show_alphactrls && (mat_media == MATMEDIA_MATERIAL); show_alphactrls = show_alphactrls && (mat_type == MATTYPE_DIFFUSE); - getChildView("label maskcutoff")->setVisible(show_alphactrls); - getChildView("maskcutoff")->setVisible(show_alphactrls); + mLabelMaskCutoff->setVisible(show_alphactrls); + mMaskCutoff->setVisible(show_alphactrls); } void LLPanelFace::onCommitAlphaMode() @@ -3206,7 +3119,7 @@ void LLPanelFace::onSelectTexture() break; } - childGetSelectionInterface("combobox alphamode")->selectNthItem(alpha_mode); + mComboAlphaMode->getSelectionInterface()->selectNthItem(alpha_mode); } LLSelectedTEMaterial::setDiffuseAlphaMode(this, getCurrentDiffuseAlphaMode()); @@ -3337,7 +3250,7 @@ void LLPanelFace::syncOffsetX(F32 offsetU) { LLSelectedTEMaterial::setNormalOffsetX(this, offsetU); LLSelectedTEMaterial::setSpecularOffsetX(this, offsetU); - getChild("TexOffsetU")->forceSetValue(LLSD(offsetU)); + mTexOffsetU->forceSetValue(LLSD(offsetU)); sendTextureInfo(); } @@ -3345,7 +3258,7 @@ void LLPanelFace::syncOffsetY(F32 offsetV) { LLSelectedTEMaterial::setNormalOffsetY(this, offsetV); LLSelectedTEMaterial::setSpecularOffsetY(this, offsetV); - getChild("TexOffsetV")->forceSetValue(LLSD(offsetV)); + mTexOffsetV->forceSetValue(LLSD(offsetV)); sendTextureInfo(); } @@ -3421,7 +3334,7 @@ void LLPanelFace::onCommitMaterialBumpyScaleX() if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - getChild("TexScaleU")->forceSetValue(getCurrentBumpyScaleU()); + mTexScaleU->forceSetValue(LLSD(getCurrentBumpyScaleU())); syncRepeatX(bumpy_scale_u); } else @@ -3440,7 +3353,7 @@ void LLPanelFace::onCommitMaterialBumpyScaleY() if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - getChild("TexScaleV")->forceSetValue(getCurrentBumpyScaleV()); + mTexScaleV->forceSetValue(LLSD(getCurrentBumpyScaleV())); syncRepeatY(bumpy_scale_v); } else @@ -3459,7 +3372,7 @@ void LLPanelFace::onCommitMaterialShinyScaleX() if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - getChild("TexScaleU")->forceSetValue(LLSD(getCurrentShinyScaleU())); + mTexScaleU->forceSetValue(LLSD(getCurrentShinyScaleU())); syncRepeatX(shiny_scale_u); } else @@ -3478,7 +3391,7 @@ void LLPanelFace::onCommitMaterialShinyScaleY() if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - getChild("TexScaleV")->forceSetValue(LLSD(getCurrentShinyScaleV())); + mTexScaleV->forceSetValue(LLSD(getCurrentShinyScaleV())); syncRepeatY(shiny_scale_v); } else @@ -3498,12 +3411,12 @@ void LLPanelFace::onCommitMaterialBumpyRot() { if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - getChild("TexRot")->forceSetValue(LLSD(getCurrentBumpyRot())); + mTexRotate->forceSetValue(LLSD(getCurrentBumpyRot())); syncMaterialRot(getCurrentBumpyRot()); } else { - if (childGetValue("checkbox planar align").asBoolean()) + if (mPlanarAlign->getValue().asBoolean()) { LLFace* last_face = NULL; bool identical_face = false; @@ -3522,12 +3435,12 @@ void LLPanelFace::onCommitMaterialShinyRot() { if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - getChild("TexRot")->forceSetValue(LLSD(getCurrentShinyRot())); + mTexRotate->forceSetValue(LLSD(getCurrentShinyRot())); syncMaterialRot(getCurrentShinyRot()); } else { - if (childGetValue("checkbox planar align").asBoolean()) + if (mPlanarAlign->getValue().asBoolean()) { LLFace* last_face = NULL; bool identical_face = false; @@ -3568,7 +3481,7 @@ void LLPanelFace::onCommitTextureScaleX() { if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - F32 bumpy_scale_u = (F32)getChild("TexScaleU")->getValue().asReal(); + F32 bumpy_scale_u = (F32)mTexScaleU->getValue().asReal(); if (isIdenticalPlanarTexgen()) { bumpy_scale_u *= 0.5f; @@ -3586,7 +3499,7 @@ void LLPanelFace::onCommitTextureScaleY() { if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - F32 bumpy_scale_v = (F32)getChild("TexScaleV")->getValue().asReal(); + F32 bumpy_scale_v = (F32)mTexScaleV->getValue().asReal(); if (isIdenticalPlanarTexgen()) { bumpy_scale_v *= 0.5f; @@ -3604,7 +3517,7 @@ void LLPanelFace::onCommitTextureRot() { if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - syncMaterialRot((F32)getChild("TexRot")->getValue().asReal()); + syncMaterialRot((F32)mTexRotate->getValue().asReal()); } else { @@ -3617,7 +3530,7 @@ void LLPanelFace::onCommitTextureOffsetX() { if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - syncOffsetX((F32)getChild("TexOffsetU")->getValue().asReal()); + syncOffsetX((F32)mTexOffsetU->getValue().asReal()); } else { @@ -3630,7 +3543,7 @@ void LLPanelFace::onCommitTextureOffsetY() { if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - syncOffsetY((F32)getChild("TexOffsetV")->getValue().asReal()); + syncOffsetY((F32)mTexOffsetV->getValue().asReal()); } else { @@ -3642,7 +3555,7 @@ void LLPanelFace::onCommitTextureOffsetY() // Commit the number of repeats per meter void LLPanelFace::onCommitRepeatsPerMeter() { - F32 repeats_per_meter = (F32)getChild("rptctrl")->getValue().asReal(); + F32 repeats_per_meter = (F32)mTexRepeat->getValue().asReal(); F32 obj_scale_s = 1.0f; F32 obj_scale_t = 1.0f; @@ -3653,23 +3566,18 @@ void LLPanelFace::onCommitRepeatsPerMeter() LLSelectedTE::getObjectScaleS(obj_scale_s, identical_scale_s); LLSelectedTE::getObjectScaleS(obj_scale_t, identical_scale_t); - LLUICtrl* bumpy_scale_u = getChild("bumpyScaleU"); - LLUICtrl* bumpy_scale_v = getChild("bumpyScaleV"); - LLUICtrl* shiny_scale_u = getChild("shinyScaleU"); - LLUICtrl* shiny_scale_v = getChild("shinyScaleV"); - if (gSavedSettings.getBOOL("SyncMaterialSettings")) { LLSelectMgr::getInstance()->selectionTexScaleAutofit(repeats_per_meter); - bumpy_scale_u->setValue(obj_scale_s * repeats_per_meter); - bumpy_scale_v->setValue(obj_scale_t * repeats_per_meter); + mBumpyScaleU->setValue(obj_scale_s * repeats_per_meter); + mBumpyScaleV->setValue(obj_scale_t * repeats_per_meter); LLSelectedTEMaterial::setNormalRepeatX(this, obj_scale_s * repeats_per_meter); LLSelectedTEMaterial::setNormalRepeatY(this, obj_scale_t * repeats_per_meter); - shiny_scale_u->setValue(obj_scale_s * repeats_per_meter); - shiny_scale_v->setValue(obj_scale_t * repeats_per_meter); + mShinyScaleU->setValue(obj_scale_s * repeats_per_meter); + mShinyScaleV->setValue(obj_scale_t * repeats_per_meter); LLSelectedTEMaterial::setSpecularRepeatX(this, obj_scale_s * repeats_per_meter); LLSelectedTEMaterial::setSpecularRepeatY(this, obj_scale_t * repeats_per_meter); @@ -3683,15 +3591,15 @@ void LLPanelFace::onCommitRepeatsPerMeter() LLSelectMgr::getInstance()->selectionTexScaleAutofit(repeats_per_meter); break; case MATTYPE_NORMAL: - bumpy_scale_u->setValue(obj_scale_s * repeats_per_meter); - bumpy_scale_v->setValue(obj_scale_t * repeats_per_meter); + mBumpyScaleU->setValue(obj_scale_s * repeats_per_meter); + mBumpyScaleV->setValue(obj_scale_t * repeats_per_meter); LLSelectedTEMaterial::setNormalRepeatX(this, obj_scale_s * repeats_per_meter); LLSelectedTEMaterial::setNormalRepeatY(this, obj_scale_t * repeats_per_meter); break; case MATTYPE_SPECULAR: - bumpy_scale_u->setValue(obj_scale_s * repeats_per_meter); - bumpy_scale_v->setValue(obj_scale_t * repeats_per_meter); + mBumpyScaleU->setValue(obj_scale_s * repeats_per_meter); + mBumpyScaleV->setValue(obj_scale_t * repeats_per_meter); LLSelectedTEMaterial::setSpecularRepeatX(this, obj_scale_s * repeats_per_meter); LLSelectedTEMaterial::setSpecularRepeatY(this, obj_scale_t * repeats_per_meter); @@ -3701,7 +3609,6 @@ void LLPanelFace::onCommitRepeatsPerMeter() break; } } - // vertical scale and repeats per meter depends on each other, so force set on changes updateUI(true); } @@ -4737,23 +4644,17 @@ void LLPanelFace::setMaterialOverridesFromSelection() } } - LLUICtrl* gltfCtrlTextureScaleU = getChild("gltfTextureScaleU"); - LLUICtrl* gltfCtrlTextureScaleV = getChild("gltfTextureScaleV"); - LLUICtrl* gltfCtrlTextureRotation = getChild("gltfTextureRotation"); - LLUICtrl* gltfCtrlTextureOffsetU = getChild("gltfTextureOffsetU"); - LLUICtrl* gltfCtrlTextureOffsetV = getChild("gltfTextureOffsetV"); - - gltfCtrlTextureScaleU->setValue(transform.mScale[VX]); - gltfCtrlTextureScaleV->setValue(transform.mScale[VY]); - gltfCtrlTextureRotation->setValue(transform.mRotation * RAD_TO_DEG); - gltfCtrlTextureOffsetU->setValue(transform.mOffset[VX]); - gltfCtrlTextureOffsetV->setValue(transform.mOffset[VY]); + mPBRScaleU->setValue(transform.mScale[VX]); + mPBRScaleV->setValue(transform.mScale[VY]); + mPBRRotate->setValue(transform.mRotation * RAD_TO_DEG); + mPBROffsetU->setValue(transform.mOffset[VX]); + mPBROffsetV->setValue(transform.mOffset[VY]); - gltfCtrlTextureScaleU->setTentative(!scale_u_same); - gltfCtrlTextureScaleV->setTentative(!scale_v_same); - gltfCtrlTextureRotation->setTentative(!rotation_same); - gltfCtrlTextureOffsetU->setTentative(!offset_u_same); - gltfCtrlTextureOffsetV->setTentative(!offset_v_same); + mPBRScaleU->setTentative(!scale_u_same); + mPBRScaleV->setTentative(!scale_v_same); + mPBRRotate->setTentative(!rotation_same); + mPBROffsetU->setTentative(!offset_u_same); + mPBROffsetV->setTentative(!offset_v_same); } void LLPanelFace::Selection::connect() @@ -4832,7 +4733,7 @@ bool LLPanelFace::Selection::compareSelection() void LLPanelFace::onCommitGLTFTextureScaleU() { - F32 value = (F32)getChild("gltfTextureScaleU")->getValue().asReal(); + F32 value = (F32)mPBRScaleU->getValue().asReal(); updateGLTFTextureTransform([&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mScale.mV[VX] = value; @@ -4841,7 +4742,7 @@ void LLPanelFace::onCommitGLTFTextureScaleU() void LLPanelFace::onCommitGLTFTextureScaleV() { - F32 value = (F32)getChild("gltfTextureScaleV")->getValue().asReal(); + F32 value = (F32)mPBRScaleV->getValue().asReal(); updateGLTFTextureTransform([&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mScale.mV[VY] = value; @@ -4850,7 +4751,7 @@ void LLPanelFace::onCommitGLTFTextureScaleV() void LLPanelFace::onCommitGLTFRotation() { - F32 value = (F32)getChild("gltfTextureRotation")->getValue().asReal() * DEG_TO_RAD; + F32 value = (F32)mPBRRotate->getValue().asReal() * DEG_TO_RAD; updateGLTFTextureTransform([&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mRotation = value; @@ -4859,7 +4760,7 @@ void LLPanelFace::onCommitGLTFRotation() void LLPanelFace::onCommitGLTFTextureOffsetU() { - F32 value = (F32)getChild("gltfTextureOffsetU")->getValue().asReal(); + F32 value = (F32)mPBROffsetU->getValue().asReal(); updateGLTFTextureTransform([&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mOffset.mV[VX] = value; @@ -4868,7 +4769,7 @@ void LLPanelFace::onCommitGLTFTextureOffsetU() void LLPanelFace::onCommitGLTFTextureOffsetV() { - F32 value = (F32)getChild("gltfTextureOffsetV")->getValue().asReal(); + F32 value = (F32)mPBROffsetV->getValue().asReal(); updateGLTFTextureTransform([&](LLGLTFMaterial::TextureTransform* new_transform) { new_transform->mOffset.mV[VY] = value; @@ -4884,42 +4785,39 @@ void LLPanelFace::onTextureSelectionChanged(LLInventoryItem* itemp) switch (mattype) { case MATTYPE_SPECULAR: - texture_ctrl = getChild("shinytexture control"); + texture_ctrl = mShinyTextureCtrl; break; case MATTYPE_NORMAL: - texture_ctrl = getChild("bumpytexture control"); + texture_ctrl = mBumpyTextureCtrl; break; default: - texture_ctrl = getChild("texture control"); + texture_ctrl = mTextureCtrl; } - if (texture_ctrl) - { - LLUUID obj_owner_id; - std::string obj_owner_name; - LLSelectMgr::instance().selectGetOwner(obj_owner_id, obj_owner_name); + LLUUID obj_owner_id; + std::string obj_owner_name; + LLSelectMgr::instance().selectGetOwner(obj_owner_id, obj_owner_name); - LLSaleInfo sale_info; - LLSelectMgr::instance().selectGetSaleInfo(sale_info); + LLSaleInfo sale_info; + LLSelectMgr::instance().selectGetSaleInfo(sale_info); - bool can_copy = itemp->getPermissions().allowCopyBy(gAgentID); // do we have perm to copy this texture? - bool can_transfer = itemp->getPermissions().allowOperationBy(PERM_TRANSFER, gAgentID); // do we have perm to transfer this texture? - bool is_object_owner = gAgentID == obj_owner_id; // does object for which we are going to apply texture belong to the agent? - bool not_for_sale = !sale_info.isForSale(); // is object for which we are going to apply texture not for sale? + bool can_copy = itemp->getPermissions().allowCopyBy(gAgentID); // do we have perm to copy this texture? + bool can_transfer = itemp->getPermissions().allowOperationBy(PERM_TRANSFER, gAgentID); // do we have perm to transfer this texture? + bool is_object_owner = gAgentID == obj_owner_id; // does object for which we are going to apply texture belong to the agent? + bool not_for_sale = !sale_info.isForSale(); // is object for which we are going to apply texture not for sale? - if (can_copy && can_transfer) - { - texture_ctrl->setCanApply(true, true); - return; - } + if (can_copy && can_transfer) + { + texture_ctrl->setCanApply(true, true); + return; + } - // if texture has (no-transfer) attribute it can be applied only for object which we own and is not for sale - texture_ctrl->setCanApply(false, can_transfer ? true : is_object_owner && not_for_sale); + // if texture has (no-transfer) attribute it can be applied only for object which we own and is not for sale + texture_ctrl->setCanApply(false, can_transfer ? true : is_object_owner && not_for_sale); - if (gSavedSettings.getBOOL("TextureLivePreview")) - { - LLNotificationsUtil::add("LivePreviewUnavailable"); - } + if (gSavedSettings.getBOOL("TextureLivePreview")) + { + LLNotificationsUtil::add("LivePreviewUnavailable"); } } diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index ede2ef9339..e90453c564 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -290,27 +290,77 @@ private: F32 getCurrentShinyOffsetU(); F32 getCurrentShinyOffsetV(); - LLTextureCtrl* mPBRTextureCtrl = nullptr; - LLTextureCtrl* mTextureCtrl = nullptr; - LLTextureCtrl* mShinyTextureCtrl = nullptr; - LLTextureCtrl* mBumpyTextureCtrl = nullptr; - LLColorSwatchCtrl* mColorSwatch = nullptr; - LLColorSwatchCtrl* mShinyColorSwatch = nullptr; - - LLComboBox* mComboTexGen = nullptr; - - LLRadioGroup* mRadioMaterialType = nullptr; - LLRadioGroup* mRadioPbrType = nullptr; - - LLCheckBoxCtrl* mCheckFullbright = nullptr; - - LLTextBox* mLabelColorTransp = nullptr; - LLSpinCtrl* mCtrlColorTransp = nullptr; // transparency = 1 - alpha - - LLSpinCtrl* mCtrlGlow = nullptr; - LLComboBox *mComboMatMedia = nullptr; - LLMediaCtrl *mTitleMedia = nullptr; - LLTextBox *mTitleMediaText = nullptr; + LLTextureCtrl* mPBRTextureCtrl { nullptr }; + LLTextureCtrl* mTextureCtrl { nullptr }; + LLTextureCtrl* mShinyTextureCtrl { nullptr }; + LLTextureCtrl* mBumpyTextureCtrl { nullptr }; + LLTextBox* mLabelColor { nullptr }; + LLColorSwatchCtrl* mColorSwatch { nullptr }; + LLTextBox* mLabelShiniColor { nullptr }; + LLColorSwatchCtrl* mShinyColorSwatch { nullptr }; + + LLTextBox* mLabelTexGen { nullptr }; + LLComboBox* mComboTexGen { nullptr }; + + LLRadioGroup* mRadioMaterialType { nullptr }; + LLRadioGroup* mRadioPbrType { nullptr }; + + LLCheckBoxCtrl* mCheckFullbright { nullptr }; + + LLTextBox* mLabelColorTransp { nullptr }; + LLSpinCtrl* mCtrlColorTransp { nullptr }; // transparency = 1 - alpha + + LLTextBox* mLabelGlow { nullptr }; + LLSpinCtrl* mCtrlGlow { nullptr }; + LLComboBox* mComboMatMedia { nullptr }; + LLMediaCtrl* mTitleMedia { nullptr }; + LLTextBox* mTitleMediaText { nullptr }; + + LLTextBox* mLabelMatPermLoading { nullptr }; + LLCheckBoxCtrl* mCheckSyncSettings { nullptr }; + + LLTextBox* mLabelBumpiness { nullptr }; + LLComboBox* mComboBumpiness { nullptr }; + LLTextBox* mLabelShininess { nullptr }; + LLComboBox* mComboShininess { nullptr }; + LLTextBox* mLabelAlphaMode { nullptr }; + LLComboBox* mComboAlphaMode { nullptr }; + LLSpinCtrl* mTexScaleU { nullptr }; + LLSpinCtrl* mTexScaleV { nullptr }; + LLSpinCtrl* mTexRotate { nullptr }; + LLSpinCtrl* mTexRepeat { nullptr }; + LLSpinCtrl* mTexOffsetU { nullptr }; + LLSpinCtrl* mTexOffsetV { nullptr }; + LLCheckBoxCtrl* mPlanarAlign{ nullptr }; + LLSpinCtrl* mBumpyScaleU { nullptr }; + LLSpinCtrl* mBumpyScaleV { nullptr }; + LLSpinCtrl* mBumpyRotate { nullptr }; + LLSpinCtrl* mBumpyOffsetU { nullptr }; + LLSpinCtrl* mBumpyOffsetV { nullptr }; + LLSpinCtrl* mShinyScaleU { nullptr }; + LLSpinCtrl* mShinyScaleV { nullptr }; + LLSpinCtrl* mShinyRotate { nullptr }; + LLSpinCtrl* mShinyOffsetU { nullptr }; + LLSpinCtrl* mShinyOffsetV { nullptr }; + LLTextBox* mLabelGlossiness { nullptr }; + LLSpinCtrl* mGlossiness { nullptr }; + LLTextBox* mLabelEnvironment { nullptr }; + LLSpinCtrl* mEnvironment { nullptr }; + LLTextBox* mLabelMaskCutoff { nullptr }; + LLSpinCtrl* mMaskCutoff { nullptr }; + LLButton* mAddMedia { nullptr }; + LLButton* mDelMedia { nullptr }; + LLSpinCtrl* mPBRScaleU { nullptr }; + LLSpinCtrl* mPBRScaleV { nullptr }; + LLSpinCtrl* mPBRRotate { nullptr }; + LLSpinCtrl* mPBROffsetU { nullptr }; + LLSpinCtrl* mPBROffsetV { nullptr }; + + LLButton* mBtnAlign { nullptr }; + LLButton* mBtnAlignTex { nullptr }; + LLButton* mBtnPbrFromInv { nullptr }; + LLButton* mBtnEditBbr { nullptr }; + LLButton* mBtnSaveBbr { nullptr }; // Update visibility of controls to match current UI mode // (e.g. materials vs media editing) @@ -322,6 +372,20 @@ private: // Hey look everyone, a type-safe alternative to copy and paste! :) // + template + void getChildSetCommitCallback(T*& ctrl, std::string_view name, std::function cb) + { + ctrl = this->getChild(name); + ctrl->setCommitCallback(cb); + } + + template + void getChildSetClickedCallback(T*& ctrl, std::string_view name, std::function cb) + { + ctrl = this->getChild(name); + ctrl->setClickedCallback(cb); + } + // Update material parameters by applying 'edit_func' to selected TEs // template< @@ -636,6 +700,8 @@ public: DEF_GET_TE_STATE(LLTextureEntry::e_texgen,LLTextureEntry::e_texgen,getTexGen,LLTextureEntry::TEX_GEN_DEFAULT, false, LLTextureEntry::TEX_GEN_DEFAULT) DEF_GET_TE_STATE(LLColor4,const LLColor4&,getColor,LLColor4::white, false, LLColor4::black); }; + + friend struct LLPanelFaceSetTEFunctor; }; #endif -- cgit v1.2.3 From e20e387d481513e4e7eed570d224da19aa532fb8 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Wed, 7 Aug 2024 19:13:40 +0200 Subject: #1922 Make PBR scale and offset crosshair work (fix PBR channels in LLPanelFace) --- indra/newview/llpanelface.cpp | 112 +++++++++++++++++++++++++----------------- indra/newview/llpanelface.h | 3 ++ 2 files changed, 71 insertions(+), 44 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 936ca273c3..94674dc557 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -117,26 +117,23 @@ const S32 PBRTYPE_METALLIC_ROUGHNESS = 2; // PBR Metallic const S32 PBRTYPE_EMISSIVE = 3; // PBR Emissive const S32 PBRTYPE_NORMAL = 4; // PBR Normal -LLGLTFMaterial::TextureInfo texture_info_from_pbrtype(S32 pbr_type) +LLGLTFMaterial::TextureInfo LLPanelFace::getPBRTextureInfo() { - switch (pbr_type) + // Radiogroup [ "Complete material", "Base color", "Metallic/roughness", "Emissive", "Normal" ] + S32 radio_group_index = mRadioPbrType->getSelectedIndex(); + switch (radio_group_index) { case PBRTYPE_BASE_COLOR: return LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR; - break; case PBRTYPE_NORMAL: return LLGLTFMaterial::GLTF_TEXTURE_INFO_NORMAL; - break; case PBRTYPE_METALLIC_ROUGHNESS: return LLGLTFMaterial::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS; - break; case PBRTYPE_EMISSIVE: return LLGLTFMaterial::GLTF_TEXTURE_INFO_EMISSIVE; - break; - default: - return LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; - break; } + // The default value is used as a fallback + return LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; } void LLPanelFace::updateSelectedGLTFMaterials(std::function func) @@ -195,43 +192,77 @@ std::string USE_TEXTURE; LLRender::eTexIndex LLPanelFace::getTextureChannelToEdit() { - LLRender::eTexIndex channel_to_edit = LLRender::DIFFUSE_MAP; - if (mComboMatMedia) + S32 matmedia_selection = mComboMatMedia->getCurrentIndex(); + switch (matmedia_selection) { - U32 matmedia_selection = mComboMatMedia->getCurrentIndex(); - if (matmedia_selection == MATMEDIA_MATERIAL) - { - channel_to_edit = (LLRender::eTexIndex)mRadioMaterialType->getSelectedIndex(); - } - if (matmedia_selection == MATMEDIA_PBR) - { - channel_to_edit = (LLRender::eTexIndex)mRadioPbrType->getSelectedIndex(); - } + case MATMEDIA_MATERIAL: + return getMatTextureChannel(); + case MATMEDIA_PBR: + return getPBRTextureChannel(); + } + return (LLRender::eTexIndex)0; +} + +LLRender::eTexIndex LLPanelFace::getMatTextureChannel() +{ + // Radiogroup [ "Texture (diffuse)", "Bumpiness (normal)", "Shininess (specular)" ] + S32 radio_group_index = mRadioMaterialType->getSelectedIndex(); + switch (radio_group_index) + { + case MATTYPE_DIFFUSE: // "Texture (diffuse)" + return LLRender::DIFFUSE_MAP; + case MATTYPE_NORMAL: // "Bumpiness (normal)" + if (getCurrentNormalMap().notNull()) + return LLRender::NORMAL_MAP; + break; + case MATTYPE_SPECULAR: // "Shininess (specular)" + if (getCurrentNormalMap().notNull()) + return LLRender::SPECULAR_MAP; + break; } + // The default value is used as a fallback if no required texture is chosen + return (LLRender::eTexIndex)0; +} - channel_to_edit = (channel_to_edit == LLRender::NORMAL_MAP) ? (getCurrentNormalMap().isNull() ? LLRender::DIFFUSE_MAP : channel_to_edit) : channel_to_edit; - channel_to_edit = (channel_to_edit == LLRender::SPECULAR_MAP) ? (getCurrentSpecularMap().isNull() ? LLRender::DIFFUSE_MAP : channel_to_edit) : channel_to_edit; - return channel_to_edit; +LLRender::eTexIndex LLPanelFace::getPBRTextureChannel() +{ + // Radiogroup [ "Complete material", "Base color", "Metallic/roughness", "Emissive", "Normal" ] + S32 radio_group_index = mRadioPbrType->getSelectedIndex(); + switch (radio_group_index) + { + case PBRTYPE_RENDER_MATERIAL_ID: // "Complete material" + return LLRender::NUM_TEXTURE_CHANNELS; + case PBRTYPE_BASE_COLOR: // "Base color" + return LLRender::BASECOLOR_MAP; + case PBRTYPE_METALLIC_ROUGHNESS: // "Metallic/roughness" + return LLRender::METALLIC_ROUGHNESS_MAP; + case PBRTYPE_EMISSIVE: // "Emissive" + return LLRender::EMISSIVE_MAP; + case PBRTYPE_NORMAL: // "Normal" + return LLRender::GLTF_NORMAL_MAP; + } + // The default value is used as a fallback + return LLRender::NUM_TEXTURE_CHANNELS; } LLRender::eTexIndex LLPanelFace::getTextureDropChannel() { - if (mComboMatMedia && mComboMatMedia->getCurrentIndex() == MATMEDIA_MATERIAL) + if (mComboMatMedia->getCurrentIndex() == MATMEDIA_MATERIAL) { - return LLRender::eTexIndex(mRadioMaterialType->getSelectedIndex()); + return getMatTextureChannel(); } - return LLRender::eTexIndex(MATTYPE_DIFFUSE); + return (LLRender::eTexIndex)0; } LLGLTFMaterial::TextureInfo LLPanelFace::getPBRDropChannel() { if (mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR) { - return texture_info_from_pbrtype(mRadioPbrType->getSelectedIndex()); + return getPBRTextureInfo(); } - return texture_info_from_pbrtype(PBRTYPE_BASE_COLOR); + return (LLGLTFMaterial::TextureInfo)0; } // Things the UI provides... @@ -388,29 +419,23 @@ bool LLPanelFace::postBuild() mCtrlColorTransp->setFollowsTop(); mCtrlColorTransp->setFollowsLeft(); - mCheckFullbright = getChild("checkbox fullbright"); - mCheckFullbright->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitFullbright(); }); + getChildSetCommitCallback(mCheckFullbright, "checkbox fullbright", [&](LLUICtrl*, const LLSD&) { onCommitFullbright(); }); mLabelTexGen = getChild("tex gen"); - mComboTexGen = getChild("combobox texgen"); - mComboTexGen->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitTexGen(); }); + getChildSetCommitCallback(mComboTexGen, "combobox texgen", [&](LLUICtrl*, const LLSD&) { onCommitTexGen(); }); mComboTexGen->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP); - mComboMatMedia = getChild("combobox matmedia"); - mComboMatMedia->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitMaterialsMedia(); }); + getChildSetCommitCallback(mComboMatMedia, "combobox matmedia", [&](LLUICtrl*, const LLSD&) { onCommitMaterialsMedia(); }); mComboMatMedia->selectNthItem(MATMEDIA_MATERIAL); - mRadioMaterialType = getChild("radio_material_type"); - mRadioMaterialType->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitMaterialType(); }); + getChildSetCommitCallback(mRadioMaterialType, "radio_material_type", [&](LLUICtrl*, const LLSD&) { onCommitMaterialType(); }); mRadioMaterialType->selectNthItem(MATTYPE_DIFFUSE); - mRadioPbrType = getChild("radio_pbr_type"); - mRadioPbrType->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitPbrType(); }); + getChildSetCommitCallback(mRadioPbrType, "radio_pbr_type", [&](LLUICtrl*, const LLSD&) { onCommitPbrType(); }); mRadioPbrType->selectNthItem(PBRTYPE_RENDER_MATERIAL_ID); mLabelGlow = getChild("glow label"); - mCtrlGlow = getChild("glow"); - mCtrlGlow->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCommitGlow(); }); + getChildSetCommitCallback(mCtrlGlow, "glow", [&](LLUICtrl*, const LLSD&) { onCommitGlow(); }); mMenuClipboardColor = getChild("clipboard_color_params_btn"); mMenuClipboardTexture = getChild("clipboard_texture_params_btn"); @@ -2792,8 +2817,7 @@ void LLPanelFace::updateVisibility(LLViewerObject* objectp /* = nullptr */) bool show_bumpiness = show_material && (material_type == MATTYPE_NORMAL) && mComboMatMedia->getEnabled(); bool show_shininess = show_material && (material_type == MATTYPE_SPECULAR) && mComboMatMedia->getEnabled(); const bool show_pbr = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR && mComboMatMedia->getEnabled(); - const U32 pbr_type = mRadioPbrType->getSelectedIndex(); - const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); + const LLGLTFMaterial::TextureInfo texture_info = getPBRTextureInfo(); const bool show_pbr_asset = show_pbr && texture_info == LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; mRadioMaterialType->setVisible(show_material); @@ -4547,7 +4571,7 @@ void LLPanelFace::onCommitPlanarAlign() void LLPanelFace::updateGLTFTextureTransform(std::function edit) { - const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(mRadioPbrType->getSelectedIndex()); + const LLGLTFMaterial::TextureInfo texture_info = getPBRTextureInfo(); if (texture_info == LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT) { updateSelectedGLTFMaterials([&](LLGLTFMaterial* new_override) @@ -4571,7 +4595,7 @@ void LLPanelFace::updateGLTFTextureTransform(std::functiongetSelectedIndex()); + const LLGLTFMaterial::TextureInfo texture_info = getPBRTextureInfo(); U32 texture_info_start; U32 texture_info_end; if (texture_info == LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_COUNT) diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index e90453c564..1caca0cf64 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -125,7 +125,10 @@ public: return new_material; } + LLGLTFMaterial::TextureInfo getPBRTextureInfo(); LLRender::eTexIndex getTextureChannelToEdit(); + LLRender::eTexIndex getMatTextureChannel(); + LLRender::eTexIndex getPBRTextureChannel(); LLRender::eTexIndex getTextureDropChannel(); LLGLTFMaterial::TextureInfo getPBRDropChannel(); -- cgit v1.2.3 From 17f7b439d617bfdf4c865f1478ade662e86b61d2 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Wed, 7 Aug 2024 20:56:10 +0200 Subject: #1922 Make PBR scale and offset crosshair work like Texture crosshair do --- indra/newview/llface.cpp | 116 +++++++++++++++++++++++++++------ indra/newview/llface.h | 4 +- indra/newview/pipeline.cpp | 159 +++++++++++++++++++++++---------------------- indra/newview/pipeline.h | 1 + 4 files changed, 182 insertions(+), 98 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index f73c530ff9..d14a7ffddc 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -514,7 +514,7 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) mDrawablep->getSpatialGroup()->rebuildGeom(); mDrawablep->getSpatialGroup()->rebuildMesh(); - if(mVertexBuffer.isNull()) + if (mVertexBuffer.isNull()) { return; } @@ -567,8 +567,20 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) { // cheaters sometimes prosper... // - mVertexBuffer->setBuffer(); - mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); + LLVertexBuffer* vertex_buffer = mVertexBuffer.get(); + // To display selection markers (white squares with the rounded cross at the center) + // on faces with GLTF textures we use a spectal vertex buffer with other transforms + if (const LLTextureEntry* te = getTextureEntry()) + { + if (LLGLTFMaterial* gltf_mat = te->getGLTFRenderMaterial()) + { + vertex_buffer = mVertexBufferGLTF.get(); + vertex_buffer->unmapBuffer(); + } + } + // Draw the selection marker using the correctly chosen vertex buffer + vertex_buffer->setBuffer(); + vertex_buffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); } gGL.popMatrix(); @@ -1144,7 +1156,8 @@ bool LLFace::getGeometryVolume(const LLVolume& volume, const LLMatrix3& mat_norm_in, U16 index_offset, bool force_rebuild, - bool no_debug_assert) + bool no_debug_assert, + bool rebuild_for_gltf) { LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE; llassert(verify()); @@ -1202,6 +1215,58 @@ bool LLFace::getGeometryVolume(const LLVolume& volume, } } + const LLTextureEntry* tep = mVObjp->getTE(face_index); + llassert(tep); + if (!tep) + return false; + + LLGLTFMaterial* gltf_mat = tep->getGLTFRenderMaterial(); + // To display selection markers (white squares with the rounded cross at the center) + // on faces with GLTF textures we use a special vertex buffer with other transforms + if (gltf_mat && !rebuild_for_gltf && tep->isSelected() && mVertexBuffer.notNull()) + { + // Create a temporary vertex buffer to provide transforms for GLTF textures + if (mVertexBufferGLTF.isNull()) + { + mVertexBufferGLTF = new LLVertexBuffer(mVertexBuffer->getTypeMask()); + } + + // Clone the existing vertex buffer into the temporary one + mVertexBuffer->clone(*mVertexBufferGLTF); + + // Recursive call the same function with the argument rebuild_for_gltf set to true + // This call will make geometry in mVertexBuffer but in fact for mVertexBufferGLTF + mVertexBufferGLTF.swap(mVertexBufferGLTF, mVertexBuffer); + getGeometryVolume(volume, face_index, mat_vert_in, mat_norm_in, index_offset, force_rebuild, no_debug_assert, true); + mVertexBufferGLTF.swap(mVertexBufferGLTF, mVertexBuffer); + } + else if (!tep->isSelected() && mVertexBufferGLTF.notNull()) + { + // Free the temporary vertex buffer when it is not needed anymore + mVertexBufferGLTF = nullptr; + } + + LLGLTFMaterial::TextureInfo gltf_info_index = (LLGLTFMaterial::TextureInfo)0; + if (gltf_mat && rebuild_for_gltf) + { + switch (LLPipeline::sRenderHighlightTextureChannel) + { + case LLRender::BASECOLOR_MAP: + gltf_info_index = LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR; + break; + case LLRender::METALLIC_ROUGHNESS_MAP: + gltf_info_index = LLGLTFMaterial::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS; + break; + case LLRender::GLTF_NORMAL_MAP: + gltf_info_index = LLGLTFMaterial::GLTF_TEXTURE_INFO_NORMAL; + break; + case LLRender::EMISSIVE_MAP: + gltf_info_index = LLGLTFMaterial::GLTF_TEXTURE_INFO_EMISSIVE; + break; + default:; // just to make clang happy + } + } + LLStrider vert; LLStrider tex_coords0; LLStrider tex_coords1; @@ -1218,7 +1283,7 @@ bool LLFace::getGeometryVolume(const LLVolume& volume, LLVector3 scale; if (global_volume) { - scale.setVec(1,1,1); + scale.setVec(1, 1, 1); } else { @@ -1233,7 +1298,6 @@ bool LLFace::getGeometryVolume(const LLVolume& volume, bool rebuild_tangent = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TANGENT); bool rebuild_weights = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_WEIGHT4); - const LLTextureEntry *tep = mVObjp->getTE(face_index); const U8 bump_code = tep ? tep->getBumpmap() : 0; bool is_static = mDrawablep->isStatic(); @@ -1323,7 +1387,6 @@ bool LLFace::getGeometryVolume(const LLVolume& volume, LLMaterial* mat = tep->getMaterialParams().get(); - LLGLTFMaterial* gltf_mat = tep->getGLTFRenderMaterial(); F32 r = 0, os = 0, ot = 0, ms = 0, mt = 0, cos_ang = 0, sin_ang = 0; @@ -1334,13 +1397,27 @@ bool LLFace::getGeometryVolume(const LLVolume& volume, S32 xforms = XFORM_NONE; // For GLTF, transforms will be applied later - if (rebuild_tcoord && tep && !gltf_mat) + if (rebuild_tcoord && tep && (!gltf_mat || rebuild_for_gltf)) { - r = tep->getRotation(); - os = tep->mOffsetS; - ot = tep->mOffsetT; - ms = tep->mScaleS; - mt = tep->mScaleT; + if (gltf_mat && rebuild_for_gltf) + { + // Apply special transformations for mVertexBufferGLTF + // They are used only to display a face selection marker + // (white square with a rounded cross at the center) + const auto& tt = gltf_mat->mTextureTransform[gltf_info_index]; + r = -tt.mRotation * 2; + ms = tt.mScale[VX]; + mt = tt.mScale[VY]; + os += tt.mOffset[VX] + (ms - 1) / 2; + ot -= tt.mOffset[VY] + (mt - 1) / 2; + } + else + { + r = tep->getRotation(); + tep->getOffset(&os, &ot); + tep->getScale(&ms, &mt); + } + cos_ang = cos(r); sin_ang = sin(r); @@ -1481,12 +1558,9 @@ bool LLFace::getGeometryVolume(const LLVolume& volume, break; } - F32 s_scale = 1.f; - F32 t_scale = 1.f; - if( tep ) - { - tep->getScale( &s_scale, &t_scale ); - } + F32 s_scale = tep->getScaleS(); + F32 t_scale = tep->getScaleT(); + // Use the nudged south when coming from above sun angle, such // that emboss mapping always shows up on the upward faces of cubes when // it's noon (since a lot of builders build with the sun forced to noon). @@ -1508,8 +1582,8 @@ bool LLFace::getGeometryVolume(const LLVolume& volume, bool tex_anim = false; - LLVOVolume* vobj = (LLVOVolume*) (LLViewerObject*) mVObjp; - tex_mode = vobj->mTexAnimMode; + LLVOVolume* vobj = (LLVOVolume*)mVObjp.get(); + tex_mode = vobj->mTexAnimMode; if (vobj->mTextureAnimp) { //texture animation is in play, override specular and normal map tex coords with diffuse texcoords diff --git a/indra/newview/llface.h b/indra/newview/llface.h index 917f3aa0b2..7cf256f731 100644 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -161,7 +161,8 @@ public: const LLMatrix3& mat_normal, U16 index_offset, bool force_rebuild = false, - bool no_debug_assert = false); + bool no_debug_assert = false, + bool rebuild_for_gltf = false); // For avatar U16 getGeometryAvatar( @@ -266,6 +267,7 @@ public: private: LLPointer mVertexBuffer; + LLPointer mVertexBufferGLTF; U32 mState; LLFacePool* mDrawPoolp; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2a461ca84b..1b2cffa6c9 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3580,9 +3580,12 @@ void LLPipeline::postSort(LLCamera &camera) { mSelectedFaces.clear(); + bool tex_index_changed = false; if (!gNonInteractive) { - LLPipeline::setRenderHighlightTextureChannel(gFloaterTools->getPanelFace()->getTextureChannelToEdit()); + LLRender::eTexIndex tex_index = sRenderHighlightTextureChannel; + setRenderHighlightTextureChannel(gFloaterTools->getPanelFace()->getTextureChannelToEdit()); + tex_index_changed = sRenderHighlightTextureChannel != tex_index; } // Draw face highlights for selected faces. @@ -3604,6 +3607,24 @@ void LLPipeline::postSort(LLCamera &camera) } } func; LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func); + + if (tex_index_changed) + { + // Rebuild geometry for all selected faces with PBR textures + for (const LLFace* face : gPipeline.mSelectedFaces) + { + if (const LLViewerObject* vobj = face->getViewerObject()) + { + if (const LLTextureEntry* tep = vobj->getTE(face->getTEOffset())) + { + if (tep->getGLTFRenderMaterial()) + { + gPipeline.markRebuild(face->getDrawable(), LLDrawable::REBUILD_VOLUME); + } + } + } + } + } } } @@ -3656,28 +3677,31 @@ void render_hud_elements() gUIProgram.unbind(); } -void LLPipeline::renderHighlights() +static inline void bindHighlightProgram(LLGLSLShader& program) { - assertInitialized(); - - // Draw 3D UI elements here (before we clear the Z buffer in POOL_HUD) - // Render highlighted faces. - LLGLSPipelineAlpha gls_pipeline_alpha; - LLColor4 color(1.f, 1.f, 1.f, 0.5f); - disableLights(); - if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) { - gHighlightProgram.bind(); - gGL.diffuseColor4f(1,1,1,0.5f); + program.bind(); + gGL.diffuseColor4f(1, 1, 1, 0.5f); } +} - if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && !mFaceSelectImagep) - { - mFaceSelectImagep = LLViewerTextureManager::getFetchedTexture(IMG_FACE_SELECT); - } +static inline void unbindHighlightProgram(LLGLSLShader& program) +{ + if (LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0) + { + program.unbind(); + } +} - if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && (sRenderHighlightTextureChannel == LLRender::DIFFUSE_MAP)) +void LLPipeline::renderSelectedFaces(const LLColor4& color) +{ + if (!mFaceSelectImagep) + { + mFaceSelectImagep = LLViewerTextureManager::getFetchedTexture(IMG_FACE_SELECT); + } + + if (mFaceSelectImagep) { // Make sure the selection image gets downloaded and decoded mFaceSelectImagep->addTextureStats((F32)MAX_IMAGE_AREA); @@ -3693,81 +3717,61 @@ void LLPipeline::renderHighlights() facep->renderSelected(mFaceSelectImagep, color); } } +} - if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED)) - { - // Paint 'em red! - color.setVec(1.f, 0.f, 0.f, 0.5f); - - for (auto facep : mHighlightFaces) - { - facep->renderSelected(LLViewerTexture::sNullImagep, color); - } - } +void LLPipeline::renderHighlights() +{ + assertInitialized(); - // Contains a list of the faces of objects that are physical or - // have touch-handlers. - mHighlightFaces.clear(); + // Draw 3D UI elements here (before we clear the Z buffer in POOL_HUD) + // Render highlighted faces. + LLGLSPipelineAlpha gls_pipeline_alpha; + disableLights(); - if (LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0) + if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED)) { - gHighlightProgram.unbind(); - } - + bindHighlightProgram(gHighlightProgram); - if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && (sRenderHighlightTextureChannel == LLRender::NORMAL_MAP)) - { - color.setVec(1.0f, 0.5f, 0.5f, 0.5f); - if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) + if (sRenderHighlightTextureChannel == LLRender::DIFFUSE_MAP || + sRenderHighlightTextureChannel == LLRender::BASECOLOR_MAP || + sRenderHighlightTextureChannel == LLRender::METALLIC_ROUGHNESS_MAP || + sRenderHighlightTextureChannel == LLRender::GLTF_NORMAL_MAP || + sRenderHighlightTextureChannel == LLRender::EMISSIVE_MAP || + sRenderHighlightTextureChannel == LLRender::NUM_TEXTURE_CHANNELS) { - gHighlightNormalProgram.bind(); - gGL.diffuseColor4f(1,1,1,0.5f); + static const LLColor4 highlight_selected_color(1.f, 1.f, 1.f, 0.5f); + renderSelectedFaces(highlight_selected_color); } - mFaceSelectImagep->addTextureStats((F32)MAX_IMAGE_AREA); - - for (auto facep : mSelectedFaces) + // Paint 'em red! + static const LLColor4 highlight_face_color(1.f, 0.f, 0.f, 0.5f); + for (auto facep : mHighlightFaces) { - if (!facep || facep->getDrawable()->isDead()) - { - LL_ERRS() << "Bad face on selection" << LL_ENDL; - return; - } - - facep->renderSelected(mFaceSelectImagep, color); + facep->renderSelected(LLViewerTexture::sNullImagep, highlight_face_color); } - if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) - { - gHighlightNormalProgram.unbind(); - } + unbindHighlightProgram(gHighlightProgram); } - if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED) && (sRenderHighlightTextureChannel == LLRender::SPECULAR_MAP)) - { - color.setVec(0.0f, 0.3f, 1.0f, 0.8f); - if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) - { - gHighlightSpecularProgram.bind(); - gGL.diffuseColor4f(1,1,1,0.5f); - } - - mFaceSelectImagep->addTextureStats((F32)MAX_IMAGE_AREA); + // Contains a list of the faces of objects that are physical or + // have touch-handlers. + mHighlightFaces.clear(); - for (auto facep : mSelectedFaces) + if (hasRenderDebugFeatureMask(RENDER_DEBUG_FEATURE_SELECTED)) + { + if (sRenderHighlightTextureChannel == LLRender::NORMAL_MAP) { - if (!facep || facep->getDrawable()->isDead()) - { - LL_ERRS() << "Bad face on selection" << LL_ENDL; - return; - } - - facep->renderSelected(mFaceSelectImagep, color); + static const LLColor4 highlight_normal_color(1.0f, 0.5f, 0.5f, 0.5f); + bindHighlightProgram(gHighlightNormalProgram); + renderSelectedFaces(highlight_normal_color); + unbindHighlightProgram(gHighlightNormalProgram); } - - if ((LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE) > 0)) + else if (sRenderHighlightTextureChannel == LLRender::SPECULAR_MAP) { - gHighlightSpecularProgram.unbind(); + static const LLColor4 highlight_specular_color(0.0f, 0.3f, 1.0f, 0.8f); + bindHighlightProgram(gHighlightSpecularProgram); + renderSelectedFaces(highlight_specular_color); + unbindHighlightProgram(gHighlightSpecularProgram); } } } @@ -6256,7 +6260,10 @@ bool LLPipeline::getRenderHighlights() // static void LLPipeline::setRenderHighlightTextureChannel(LLRender::eTexIndex channel) { - sRenderHighlightTextureChannel = channel; + if (channel != sRenderHighlightTextureChannel) + { + sRenderHighlightTextureChannel = channel; + } } LLVOPartGroup* LLPipeline::lineSegmentIntersectParticle(const LLVector4a& start, const LLVector4a& end, LLVector4a* intersection, diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 6c79d20149..4164474238 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -342,6 +342,7 @@ public: void renderHighlight(const LLViewerObject* obj, F32 fade); void renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& camera, LLCullResult& result, bool depth_clamp); + void renderSelectedFaces(const LLColor4& color); void renderHighlights(); void renderDebug(); void renderPhysicsDisplay(); -- cgit v1.2.3 From 12cb787f314b690e018d4b12ac54e08570b3b677 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Thu, 8 Aug 2024 11:57:26 -0400 Subject: Update libexpat to 2.6.2 and libapr 1.7.4 (#2214) --- indra/newview/viewer_manifest.py | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index 09397a0989..ea4b2ff4f4 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -1008,9 +1008,6 @@ class Darwin_x86_64_Manifest(ViewerManifest): libfile_parent = self.get_dst_prefix() dylibs=[] for libfile in ( - "libapr-1.0.dylib", - "libaprutil-1.0.dylib", - "libexpat.1.dylib", # libnghttp2.dylib is a symlink to # libnghttp2.major.dylib, which is a symlink to # libnghttp2.version.dylib. Get all of them. @@ -1315,14 +1312,7 @@ class Linux_i686_Manifest(LinuxManifest): debpkgdir = os.path.join(pkgdir, "lib", "debug") with self.prefix(src=relpkgdir, dst="lib"): - self.path("libapr-1.so") - self.path("libapr-1.so.0") - self.path("libapr-1.so.0.4.5") - self.path("libaprutil-1.so") - self.path("libaprutil-1.so.0") - self.path("libaprutil-1.so.0.4.1") self.path("libdb*.so") - self.path("libexpat.so.*") self.path("libuuid.so*") self.path("libSDL-1.2.so.*") self.path("libdirectfb-1.*.so.*") -- cgit v1.2.3 From 77d50cad495511a91ca1461d9e6f43a7e8656965 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 8 Aug 2024 14:59:41 +0300 Subject: viewer#2225 Fix Joystick Floater's FPS drops --- indra/newview/llfloaterjoystick.cpp | 33 ++++++++++++++++++++++++++------- indra/newview/llfloaterjoystick.h | 2 ++ 2 files changed, 28 insertions(+), 7 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp index 7db3621a4b..68b11ec92b 100644 --- a/indra/newview/llfloaterjoystick.cpp +++ b/indra/newview/llfloaterjoystick.cpp @@ -93,8 +93,9 @@ BOOL CALLBACK di8_list_devices_callback(LPCDIDEVICEINSTANCE device_instance_ptr, #endif LLFloaterJoystick::LLFloaterJoystick(const LLSD& data) - : LLFloater(data), - mHasDeviceList(false) + : LLFloater(data) + , mHasDeviceList(false) + , mJoystickInitialized(false) { if (!LLViewerJoystick::getInstance()->isJoystickInitialized()) { @@ -108,7 +109,10 @@ void LLFloaterJoystick::draw() { LLViewerJoystick* joystick(LLViewerJoystick::getInstance()); bool joystick_inited = joystick->isJoystickInitialized(); - if (joystick_inited != mHasDeviceList) + if (!mHasDeviceList + || mJoystickInitialized != joystick_inited + || (joystick->isDeviceUUIDSet() && joystick->getDeviceUUID().asUUID() != mCurrentDeviceId) + || (!joystick->isDeviceUUIDSet() && mCurrentDeviceId.notNull())) { refreshListOfDevices(); } @@ -290,15 +294,16 @@ void LLFloaterJoystick::refreshListOfDevices() mHasDeviceList = true; } - bool is_device_id_set = LLViewerJoystick::getInstance()->isDeviceUUIDSet(); + LLViewerJoystick* joystick = LLViewerJoystick::getInstance(); + bool is_device_id_set = joystick->isDeviceUUIDSet(); - if (LLViewerJoystick::getInstance()->isJoystickInitialized() && + if (joystick->isJoystickInitialized() && (!mHasDeviceList || !is_device_id_set)) { #if LL_WINDOWS && !LL_MESA_HEADLESS LL_WARNS() << "NDOF connected to device without using SL provided handle" << LL_ENDL; #endif - std::string desc = LLViewerJoystick::getInstance()->getDescription(); + std::string desc = joystick->getDescription(); if (!desc.empty()) { LLSD value = LLSD::Integer(1); // value for selection @@ -311,11 +316,13 @@ void LLFloaterJoystick::refreshListOfDevices() { if (is_device_id_set) { - LLSD guid = LLViewerJoystick::getInstance()->getDeviceUUID(); + LLSD guid = joystick->getDeviceUUID(); + mCurrentDeviceId = guid.asUUID(); mJoysticksCombo->selectByValue(guid); } else { + mCurrentDeviceId.setNull(); mJoysticksCombo->selectByValue(LLSD::Integer(1)); } } @@ -323,6 +330,18 @@ void LLFloaterJoystick::refreshListOfDevices() { mJoysticksCombo->selectByValue(LLSD::Integer(0)); } + + // Update tracking + if (is_device_id_set) + { + LLSD guid = joystick->getDeviceUUID(); + mCurrentDeviceId = guid.asUUID(); + } + else + { + mCurrentDeviceId.setNull(); + } + mJoystickInitialized = joystick->isJoystickInitialized(); } void LLFloaterJoystick::cancel() diff --git a/indra/newview/llfloaterjoystick.h b/indra/newview/llfloaterjoystick.h index b94223a738..c7e727635d 100644 --- a/indra/newview/llfloaterjoystick.h +++ b/indra/newview/llfloaterjoystick.h @@ -95,6 +95,8 @@ private: LLComboBox *mJoysticksCombo; bool mHasDeviceList; + bool mJoystickInitialized; + LLUUID mCurrentDeviceId; // stats view LLStatBar* mAxisStatsBar[6]; -- cgit v1.2.3 From fe0f1be17bfd83323f2fcda124f3327cc14b0cad Mon Sep 17 00:00:00 2001 From: Beq Janus Date: Thu, 8 Aug 2024 17:10:03 +0100 Subject: Auto-scaling amortisation of dynamic BB calcs (#2226) * Auto-scaling amortisation of dynamic BB calcs This fix limits the overhead of the dynamic BB calcs to AvatarExtentRefreshMaxPerBatch per AvatarExtentRefreshPeriodBatch frames default is 5 avatar per 4 frames. Thus a standard busy region 25 avatars would take 20 frames to refresh the BBs. * Add comments to give context to the amortised BB recalcs explain the frequency of updates given the number of avatars present as to how that limits the impact on frame rate in busy scenes --- indra/newview/app_settings/settings.xml | 22 ++++++++++++++++++++ indra/newview/llviewerobjectlist.cpp | 5 +++++ indra/newview/llviewerobjectlist.h | 2 ++ indra/newview/llvoavatar.cpp | 37 +++++++++++++++++++++++++++------ 4 files changed, 60 insertions(+), 6 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index eb053ebaa0..887a8584d8 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1874,6 +1874,28 @@ Value 64.0 + AvatarExtentRefreshPeriodBatch + + Comment + how many frames do we spread over by default when refreshing extents (default is 4) + Persist + 1 + Type + S32 + Value + 4 + + AvatarExtentRefreshMaxPerBatch + + Comment + how many avatars do we want to handle in total per batch (default is 5) + Persist + 1 + Type + S32 + Value + 5 + DebugAvatarAppearanceMessage Comment diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index ae64ee7b92..435bd60917 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -889,6 +889,7 @@ void LLViewerObjectList::update(LLAgent &agent) static std::vector idle_list; U32 idle_count = 0; + mNumAvatars = 0; { for (std::vector >::iterator active_iter = mActiveObjects.begin(); @@ -906,6 +907,10 @@ void LLViewerObjectList::update(LLAgent &agent) idle_list[idle_count] = objectp; } ++idle_count; + if (objectp->isAvatar()) + { + mNumAvatars++; + } } else { // There shouldn't be any NULL pointers in the list, but they have caused diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index ebdfd0d369..7dfa94b99f 100644 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -145,6 +145,7 @@ public: S32 getOrphanParentCount() const { return (S32) mOrphanParents.size(); } S32 getOrphanCount() const { return mNumOrphans; } + S32 getAvatarCount() const { return mNumAvatars; } void orphanize(LLViewerObject *childp, U32 parent_id, U32 ip, U32 port); void findOrphans(LLViewerObject* objectp, U32 ip, U32 port); @@ -191,6 +192,7 @@ protected: std::vector mOrphanParents; // LocalID/ip,port of orphaned objects std::vector mOrphanChildren; // UUID's of orphaned objects S32 mNumOrphans; + S32 mNumAvatars; typedef std::vector > vobj_list_t; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index d5a8ee6cf8..b3b8969faa 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -2631,6 +2631,29 @@ void LLVOAvatar::idleUpdate(LLAgent &agent, const F64 &time) } // Update should be happening max once per frame. + static LLCachedControl refreshPeriod(gSavedSettings, "AvatarExtentRefreshPeriodBatch"); + static LLCachedControl refreshMaxPerPeriod(gSavedSettings, "AvatarExtentRefreshMaxPerBatch"); + static S32 upd_freq = refreshPeriod; // initialise to a reasonable default of 1 batch + static S32 lastRecalibrationFrame{ 0 }; + + const S32 thisFrame = LLDrawable::getCurrentFrame(); + if (thisFrame - lastRecalibrationFrame >= upd_freq) + { + // Only update at the start of a cycle. . + // update frequency = ((Num_Avatars -1 / NumberPerPeriod) + 1 ) * Periodicity + // Given NumberPerPeriod = 5 and Periodicity = 4 + // | NumAvatars | frequency | + // +-------------+-----------+ + // | 1 | 4 | + // | 2 | 4 | + // | 5 | 4 | + // | 10 | 8 | + // | 25 | 20 | + + upd_freq = (((gObjectList.getAvatarCount() - 1) / refreshMaxPerPeriod) + 1)*refreshPeriod; + lastRecalibrationFrame = thisFrame; + } + if ((mLastAnimExtents[0]==LLVector3())|| (mLastAnimExtents[1])==LLVector3()) { @@ -2638,8 +2661,9 @@ void LLVOAvatar::idleUpdate(LLAgent &agent, const F64 &time) } else { - const S32 upd_freq = 4; // force update every upd_freq frames. - mNeedsExtentUpdate = ((LLDrawable::getCurrentFrame()+mID.mData[0])%upd_freq==0); + // Update extent if necessary. + // if the frame counnter + the first byte of the UUID % upd_freq = 0 then update the extent. + mNeedsExtentUpdate = ((thisFrame + mID.mData[0]) % upd_freq == 0); } LLScopedContextString str("avatar_idle_update " + getFullname()); @@ -10725,10 +10749,11 @@ void LLVOAvatar::updateRiggingInfo() } //LL_INFOS() << "done update rig count is " << countRigInfoTab(mJointRiggingInfoTab) << LL_ENDL; - LL_DEBUGS("RigSpammish") << getFullname() << " after update rig tab:" << LL_ENDL; - S32 joint_count, box_count; - showRigInfoTabExtents(this, mJointRiggingInfoTab, joint_count, box_count); - LL_DEBUGS("RigSpammish") << "uses " << joint_count << " joints " << " nonzero boxes: " << box_count << LL_ENDL; + // Remove debug only stuff on hot path + // LL_DEBUGS("RigSpammish") << getFullname() << " after update rig tab:" << LL_ENDL; + // S32 joint_count, box_count; + // showRigInfoTabExtents(this, mJointRiggingInfoTab, joint_count, box_count); + // LL_DEBUGS("RigSpammish") << "uses " << joint_count << " joints " << " nonzero boxes: " << box_count << LL_ENDL; } // virtual -- cgit v1.2.3 From f782f5f5345e68e0c579e5fe78be94f749723dee Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Thu, 8 Aug 2024 23:21:28 +0200 Subject: Fix copy&paste error in LLPanelFace (#2233) --- indra/newview/llpanelface.cpp | 10 +++++----- indra/newview/llpanelface.h | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 94674dc557..544b6fbc9c 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1425,8 +1425,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) { mTexScaleV->setValue(diff_scale_t); } - mShinyScaleV->setValue(norm_scale_t); - mBumpyScaleV->setValue(spec_scale_t); + mShinyScaleV->setValue(spec_scale_t); + mBumpyScaleV->setValue(norm_scale_t); mTexScaleV->setTentative(LLSD(diff_scale_tentative)); mShinyScaleV->setTentative(LLSD(spec_scale_tentative)); @@ -2181,7 +2181,7 @@ void LLPanelFace::onMaterialOverrideReceived(const LLUUID& object_id, S32 side) ////////////////////////////////////////////////////////////////////////////// // -void LLPanelFace::navigateToTitleMedia( const std::string url ) +void LLPanelFace::navigateToTitleMedia(const std::string& url) { std::string multi_media_info_str = LLTrans::getString("Multiple Media"); if (url.empty() || multi_media_info_str == url) @@ -2193,9 +2193,9 @@ void LLPanelFace::navigateToTitleMedia( const std::string url ) { LLPluginClassMedia* media_plugin = mTitleMedia->getMediaPlugin(); // check if url changed or if we need a new media source - if (mTitleMedia->getCurrentNavUrl() != url || media_plugin == NULL) + if (mTitleMedia->getCurrentNavUrl() != url || media_plugin == nullptr) { - mTitleMedia->navigateTo( url ); + mTitleMedia->navigateTo(url); LLViewerMediaImpl* impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mTitleMedia->getTextureID()); if (impl) diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 1caca0cf64..dfd3201533 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -133,7 +133,7 @@ public: LLGLTFMaterial::TextureInfo getPBRDropChannel(); protected: - void navigateToTitleMedia(const std::string url); + void navigateToTitleMedia(const std::string& url); bool selectedMediaEditable(); void clearMediaSettings(); void updateMediaSettings(); @@ -226,7 +226,6 @@ protected: void onCommitMaterialGloss(); void onCommitMaterialEnv(); void onCommitMaterialMaskCutoff(); - void onCommitMaterialID(); void onCommitMaterialsMedia(); void onCommitMaterialType(); @@ -270,7 +269,7 @@ protected: static F32 valueGlow(LLViewerObject* object, S32 face); private: - bool isAlpha() { return mIsAlpha; } + bool isAlpha() const { return mIsAlpha; } // Convenience funcs to keep the visual flack to a minimum // -- cgit v1.2.3 From a6131b5652124d40e782dd6bc653a9020061cf33 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Thu, 8 Aug 2024 22:13:57 +0200 Subject: #2229 BugSplat Crash #1502471: SecondLifeViewer!LLPolySkeletalDistortion::apply(196) --- indra/newview/llvoavatar.cpp | 23 ++++------------------- indra/newview/llvoavatar.h | 2 +- 2 files changed, 5 insertions(+), 20 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index b3b8969faa..f813df3fb5 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -3081,30 +3081,15 @@ void LLVOAvatar::idleUpdateAppearanceAnimation() } else { - F32 morph_amt = calcMorphAmount(); - LLVisualParam *param; - if (!isSelf()) { + F32 morph_amt = calcMorphAmount(); // animate only top level params for non-self avatars - for (param = getFirstVisualParam(); - param; - param = getNextVisualParam()) - { - if (param->isTweakable()) - { - param->animate(morph_amt); - } - } + animateTweakableVisualParams(morph_amt); } // apply all params - for (param = getFirstVisualParam(); - param; - param = getNextVisualParam()) - { - param->apply(avatar_sex); - } + applyAllVisualParams(avatar_sex); mLastAppearanceBlendTime = appearance_anim_time; } @@ -3112,7 +3097,7 @@ void LLVOAvatar::idleUpdateAppearanceAnimation() } } -F32 LLVOAvatar::calcMorphAmount() +F32 LLVOAvatar::calcMorphAmount() const { F32 appearance_anim_time = mAppearanceMorphTimer.getElapsedTimeF32(); F32 blend_frac = calc_bouncy_animation(appearance_anim_time / APPEARANCE_MORPH_TIME); diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 2144be1ba5..aa6aee0de5 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -422,7 +422,7 @@ protected: bool updateIsFullyLoaded(); bool processFullyLoadedChange(bool loading); void updateRuthTimer(bool loading); - F32 calcMorphAmount(); + F32 calcMorphAmount() const; private: bool mFirstFullyVisible; -- cgit v1.2.3 From 5a1ce7974b0c58d32c047a814fa94d4072a70de7 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Fri, 9 Aug 2024 16:32:11 +0200 Subject: #2230 BugSplat Crash #1502376: SecondLifeViewer!LLPrimitive::isAvatar(606) --- indra/newview/lldrawable.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 60e7171004..3b531c41d9 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -1600,18 +1600,10 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update) mDrawable->updateDistance(camera, force_update); - LLViewerObject::const_child_list_t& child_list = mDrawable->getVObj()->getChildren(); - for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); - iter != child_list.end(); iter++) + for (LLViewerObject* child : mDrawable->getVObj()->getChildren()) { - LLViewerObject* child = *iter; LLDrawable* drawable = child->mDrawable; - if (!drawable) - { - continue; - } - - if (!drawable->isAvatar()) + if (drawable && !drawable->isDead() && drawable->isAvatar()) { drawable->updateDistance(camera, force_update); } -- cgit v1.2.3 From ecfa05711ecf5e331c6b5eb6e404ecf940ad014e Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Fri, 9 Aug 2024 16:41:37 +0200 Subject: #2231 BugSplat Crash #1502347: SecondLifeViewer!LLViewerObject::getBoundingBoxAgent(5858) --- indra/newview/llviewerobject.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index fd85d75d98..a2abd1d930 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -5753,7 +5753,8 @@ LLBBox LLViewerObject::getBoundingBoxAgent() const } if (avatar_parent && avatar_parent->isAvatar() && - root_edit && root_edit->mDrawable.notNull() && root_edit->mDrawable->getXform()->getParent()) + root_edit && root_edit->mDrawable.notNull() && !root_edit->mDrawable->isDead() && + root_edit->mDrawable->getXform()->getParent()) { LLXform* parent_xform = root_edit->mDrawable->getXform()->getParent(); position_agent = (getPositionEdit() * parent_xform->getWorldRotation()) + parent_xform->getWorldPosition(); -- cgit v1.2.3 From 501e92250ef61abcbbdb26f2e6f882d864113ac4 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sun, 11 Aug 2024 17:54:38 -0400 Subject: Fix avatar lod corruption from commit 5a1ce79 (#2247) --- indra/newview/lldrawable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 3b531c41d9..ae48db24bc 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -1603,7 +1603,7 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update) for (LLViewerObject* child : mDrawable->getVObj()->getChildren()) { LLDrawable* drawable = child->mDrawable; - if (drawable && !drawable->isDead() && drawable->isAvatar()) + if (drawable && !drawable->isDead() && !drawable->isAvatar()) { drawable->updateDistance(camera, force_update); } -- cgit v1.2.3 From dff3fdbfd7d0b29b51d4d6b7ecfd84177e114eb8 Mon Sep 17 00:00:00 2001 From: Signal Linden Date: Sun, 11 Aug 2024 16:44:39 -0700 Subject: Adopt NSIS 3.0 (#2248) --- indra/newview/installers/windows/installer_template.nsi | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview') diff --git a/indra/newview/installers/windows/installer_template.nsi b/indra/newview/installers/windows/installer_template.nsi index d1dab94a76..77f24ac6a6 100644 --- a/indra/newview/installers/windows/installer_template.nsi +++ b/indra/newview/installers/windows/installer_template.nsi @@ -32,6 +32,7 @@ SetCompressor /solid lzma # Compress whole installer as one block SetDatablockOptimize off # Only saves us 0.1%, not worth it XPStyle on # Add an XP manifest to the installer RequestExecutionLevel admin # For when we write to Program Files +Unicode true # Enable unicode support ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Project flags -- cgit v1.2.3 From af2b5a3c58999c12f7c5e091cd4703e358fe844c Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Mon, 12 Aug 2024 00:15:21 -0400 Subject: Fix sculpt discard level being discarded due to shadowing outer scope discard_level (#2249) --- indra/newview/llvovolume.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 9ebe648680..7a7d88327b 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1250,7 +1250,7 @@ void LLVOVolume::sculpt() if (!raw_image) { raw_image = mSculptTexture->getSavedRawImage(); - S32 discard_level = mSculptTexture->getSavedRawImageLevel(); + discard_level = mSculptTexture->getSavedRawImageLevel(); } if (!raw_image) -- cgit v1.2.3 From f982463488a35b58b86d5d76309055416eb9eaec Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Mon, 12 Aug 2024 00:30:42 -0400 Subject: Update zlib-ng libxml2 libpng freetype minizip-ng boost collada-dom tinygltf packages (#2250) Rebuild expat, apr, meshoptimizer, ogg_vorbis, libjpeg-turbo for symbol fixes --- indra/newview/CMakeLists.txt | 4 ---- indra/newview/viewer_manifest.py | 15 --------------- 2 files changed, 19 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index f7c5010e72..87823d5e9c 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1749,15 +1749,11 @@ if (WINDOWS) list(APPEND COPY_INPUT_DEPENDENCIES ${SHARED_LIB_STAGING_DIR}/vivoxsdk_x64.dll ${SHARED_LIB_STAGING_DIR}/ortp_x64.dll - ${ARCH_PREBUILT_DIRS_RELEASE}/libcrypto-1_1-x64.dll - ${ARCH_PREBUILT_DIRS_RELEASE}/libssl-1_1-x64.dll ) else (ADDRESS_SIZE EQUAL 64) list(APPEND COPY_INPUT_DEPENDENCIES ${SHARED_LIB_STAGING_DIR}/vivoxsdk.dll ${SHARED_LIB_STAGING_DIR}/ortp.dll - ${ARCH_PREBUILT_DIRS_RELEASE}/libcrypto-1_1.dll - ${ARCH_PREBUILT_DIRS_RELEASE}/libssl-1_1.dll ) endif (ADDRESS_SIZE EQUAL 64) diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index ea4b2ff4f4..91a9347449 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -580,13 +580,6 @@ class Windows_x86_64_Manifest(ViewerManifest): self.path("vivoxsdk_x64.dll") self.path("ortp_x64.dll") - # OpenSSL - self.path("libcrypto-1_1-x64.dll") - self.path("libssl-1_1-x64.dll") - - # HTTP/2 - self.path("nghttp2.dll") - # BugSplat if self.args.get('bugsplat'): self.path("BsSndRpt64.exe") @@ -1007,14 +1000,6 @@ class Darwin_x86_64_Manifest(ViewerManifest): # Need to get the llcommon dll from any of the build directories as well. libfile_parent = self.get_dst_prefix() dylibs=[] - for libfile in ( - # libnghttp2.dylib is a symlink to - # libnghttp2.major.dylib, which is a symlink to - # libnghttp2.version.dylib. Get all of them. - "libnghttp2.*dylib", - ): - dylibs += path_optional(os.path.join(relpkgdir, libfile), libfile) - # SLVoice executable with self.prefix(src=os.path.join(pkgdir, 'bin', 'release')): self.path("SLVoice") -- cgit v1.2.3 From 3f9a38bb4bf7514e575315c3c304e04e9b828c8b Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Mon, 12 Aug 2024 15:20:46 +0200 Subject: #2255 BugSplat Crash #1503774: SecondLifeViewer!LLViewerOctreeGroup::hasState(227) --- indra/newview/llspatialpartition.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index ffe5fa394f..b1f80e48af 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -1051,7 +1051,8 @@ public: LLSpatialGroup* group = (LLSpatialGroup*)base_group; group->checkOcclusion(); - if (group->getOctreeNode()->getParent() && //never occlusion cull the root node + if (group->getOctreeNode() && + group->getOctreeNode()->getParent() && //never occlusion cull the root node LLPipeline::sUseOcclusion && //ignore occlusion if disabled group->isOcclusionState(LLSpatialGroup::OCCLUDED)) { -- cgit v1.2.3 From c1bc32ad42413342dfff396c7b37372619a03f72 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Mon, 12 Aug 2024 14:40:40 +0200 Subject: #2253 BugSplat Crash #1504389: SecondLifeViewer!LLVOAvatar::updateRiggingInfo(10561) --- indra/newview/llvoavatar.cpp | 57 ++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 31 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index f813df3fb5..09375a6930 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -10634,18 +10634,19 @@ void showRigInfoTabExtents(LLVOAvatar *avatar, LLJointRiggingInfoTab& tab, S32& void LLVOAvatar::getAssociatedVolumes(std::vector& volumes) { LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; - for ( LLVOAvatar::attachment_map_t::iterator iter = mAttachmentPoints.begin(); iter != mAttachmentPoints.end(); ++iter ) + for (const auto& iter : mAttachmentPoints) { - LLViewerJointAttachment* attachment = iter->second; + LLViewerJointAttachment* attachment = iter.second; LLViewerJointAttachment::attachedobjs_vec_t::iterator attach_end = attachment->mAttachedObjects.end(); - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attach_iter = attachment->mAttachedObjects.begin(); - attach_iter != attach_end; ++attach_iter) + for (LLViewerObject* attached_object : attachment->mAttachedObjects) { - LLViewerObject* attached_object = attach_iter->get(); - LLVOVolume *volume = dynamic_cast(attached_object); - if (volume) + if (attached_object->isDead()) + continue; + + if (attached_object->getPCode() == LL_PCODE_VOLUME) { + LLVOVolume* volume = (LLVOVolume*)attached_object; volumes.push_back(volume); if (volume->isAnimatedObject()) { @@ -10655,15 +10656,12 @@ void LLVOAvatar::getAssociatedVolumes(std::vector& volumes) continue; } } - LLViewerObject::const_child_list_t& children = attached_object->getChildren(); - for (LLViewerObject::const_child_list_t::const_iterator it = children.begin(); - it != children.end(); ++it) + + for (LLViewerObject* childp : attached_object->getChildren()) { - LLViewerObject *childp = *it; - LLVOVolume *volume = dynamic_cast(childp); - if (volume) + if (!childp->isDead() && childp->getPCode() == LL_PCODE_VOLUME) { - volumes.push_back(volume); + volumes.push_back((LLVOVolume*)childp); } } } @@ -10702,33 +10700,30 @@ void LLVOAvatar::updateRiggingInfo() getAssociatedVolumes(volumes); - std::map curr_rigging_info_key; + std::map curr_rigging_info_key; + + // Get current rigging info key + for (LLVOVolume* vol : volumes) { - // Get current rigging info key - for (std::vector::iterator it = volumes.begin(); it != volumes.end(); ++it) + if (vol->isMesh() && vol->getVolume()) { - LLVOVolume *vol = *it; - if (vol->isMesh() && vol->getVolume()) - { - const LLUUID& mesh_id = vol->getVolume()->getParams().getSculptID(); - S32 max_lod = llmax(vol->getLOD(), vol->mLastRiggingInfoLOD); - curr_rigging_info_key[mesh_id] = max_lod; - } + const LLUUID& mesh_id = vol->getVolume()->getParams().getSculptID(); + S32 max_lod = llmax(vol->getLOD(), vol->mLastRiggingInfoLOD); + curr_rigging_info_key[mesh_id] = max_lod; } + } - // Check for key change, which indicates some change in volume composition or LOD. - if (curr_rigging_info_key == mLastRiggingInfoKey) - { - return; - } + // Check for key change, which indicates some change in volume composition or LOD. + if (curr_rigging_info_key == mLastRiggingInfoKey) + { + return; } // Something changed. Update. mLastRiggingInfoKey = curr_rigging_info_key; mJointRiggingInfoTab.clear(); - for (std::vector::iterator it = volumes.begin(); it != volumes.end(); ++it) + for (LLVOVolume* vol : volumes) { - LLVOVolume *vol = *it; vol->updateRiggingInfo(); mJointRiggingInfoTab.merge(vol->mJointRiggingInfoTab); } -- cgit v1.2.3 From 50e05c70d38c0e9da654cbc0f1758809e7159744 Mon Sep 17 00:00:00 2001 From: Beq Janus Date: Mon, 12 Aug 2024 19:01:34 +0100 Subject: Interim fix for particles no longer rezzing properly. (#2227) In a previous PR, I noted: Note this change moves the calcPixelArea() call to the top BEFORE we user getPixelArea(). Either that call is entirely redundant (i.e. if calc was called earlier in the frame) or we were using the stale pixelArea (one frame behind). If the former is true then it might be faster to just do an AABB frustum check. It turns out that by moving the calcPixelArea to the "correct place", we break the rezzing of particles which are then being downsampled as a result. Moving this back to the "incorrect" location undoes the immediate effect but this whole scenario may need to be re-examined. --- indra/newview/llviewertexturelist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 865805f9bf..7047ce7d29 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -938,9 +938,9 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag onFace = true; F32 radius; F32 cos_angle_to_view_dir; - bool in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius); static LLCachedControl bias_unimportant_threshold(gSavedSettings, "TextureBiasUnimportantFactor", 0.25f); F32 vsize = face->getPixelArea(); + bool in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius); // Scale desired texture resolution higher or lower depending on texture scale // -- cgit v1.2.3 From 2cc21e982668750b237edf2c54979f58d1c52203 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 13 Aug 2024 13:14:17 -0500 Subject: Fix for coroutine assert rooted in coroRequestEnvironment (#2276) --- indra/newview/llenvironment.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 5dfaf176fd..6e31760e9e 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -2123,8 +2123,11 @@ void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environ LLSD environment = result[KEY_ENVIRONMENT]; if (environment.isDefined() && apply) { - EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); - apply(parcel_id, envinfo); + LLAppViewer::instance()->postToMainCoro([=]() + { + EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment); + apply(parcel_id, envinfo); + }); } } -- cgit v1.2.3 From 183b097072015fe83c751904d8133fa105717a5b Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Tue, 13 Aug 2024 16:28:23 -0400 Subject: Update tracy integration to 0.11 and rework client library to be configurable at build time Also copy tracy profiler client next to windows binary when enabled --- indra/newview/CMakeLists.txt | 6 ++++++ indra/newview/viewer_manifest.py | 5 +++++ 2 files changed, 11 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index fbaf4e559f..7a9f3a46b5 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1776,6 +1776,7 @@ if (WINDOWS) --artwork=${ARTWORK_DIR} "--bugsplat=${BUGSPLAT_DB}" "--openal=${USE_OPENAL}" + "--tracy=${USE_TRACY}" --build=${CMAKE_CURRENT_BINARY_DIR} --buildtype=$ "--channel=${VIEWER_CHANNEL}" @@ -1836,6 +1837,7 @@ if (WINDOWS) --artwork=${ARTWORK_DIR} "--bugsplat=${BUGSPLAT_DB}" "--openal=${USE_OPENAL}" + "--tracy=${USE_TRACY}" --build=${CMAKE_CURRENT_BINARY_DIR} --buildtype=$ "--channel=${VIEWER_CHANNEL}" @@ -1985,6 +1987,7 @@ if (LINUX) --artwork=${ARTWORK_DIR} "--bugsplat=${BUGSPLAT_DB}" "--openal=${USE_OPENAL}" + "--tracy=${USE_TRACY}" --build=${CMAKE_CURRENT_BINARY_DIR} --buildtype=${CMAKE_BUILD_TYPE} "--channel=${VIEWER_CHANNEL}" @@ -2012,6 +2015,7 @@ if (LINUX) --artwork=${ARTWORK_DIR} "--bugsplat=${BUGSPLAT_DB}" "--openal=${USE_OPENAL}" + "--tracy=${USE_TRACY}" --build=${CMAKE_CURRENT_BINARY_DIR} --buildtype=${CMAKE_BUILD_TYPE} "--channel=${VIEWER_CHANNEL}" @@ -2087,6 +2091,7 @@ if (DARWIN) --artwork=${ARTWORK_DIR} "--bugsplat=${BUGSPLAT_DB}" "--openal=${USE_OPENAL}" + "--tracy=${USE_TRACY}" --build=${CMAKE_CURRENT_BINARY_DIR} --buildtype=$ --bundleid=${MACOSX_BUNDLE_GUI_IDENTIFIER} @@ -2121,6 +2126,7 @@ if (DARWIN) --artwork=${ARTWORK_DIR} "--bugsplat=${BUGSPLAT_DB}" "--openal=${USE_OPENAL}" + "--tracy=${USE_TRACY}" --build=${CMAKE_CURRENT_BINARY_DIR} --buildtype=$ "--channel=${VIEWER_CHANNEL}" diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index 91a9347449..b2f9654eb3 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -586,6 +586,10 @@ class Windows_x86_64_Manifest(ViewerManifest): self.path("BugSplat64.dll") self.path("BugSplatRc64.dll") + if self.args['tracy'] == 'ON': + with self.prefix(src=os.path.join(pkgdir, 'bin')): + self.path("tracy-profiler.exe") + self.path(src="licenses-win32.txt", dst="licenses.txt") self.path("featuretable.txt") self.path("cube.dae") @@ -1372,6 +1376,7 @@ if __name__ == "__main__": dict(name='bugsplat', description="""BugSplat database to which to post crashes, if BugSplat crash reporting is desired""", default=''), dict(name='openal', description="""Indication openal libraries are needed""", default='OFF'), + dict(name='tracy', description="""Indication tracy profiler is enabled""", default='OFF'), ] try: main(extra=extra_arguments) -- cgit v1.2.3 From 2cff1e217ba0df94fc50a30c8d49dc848c294ac6 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Tue, 13 Aug 2024 18:39:57 -0400 Subject: Reduce UI draw stalls from LLSpellChecker singleton via simpleton --- indra/newview/llappviewer.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 262ab439b4..36fe5a953f 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -806,6 +806,20 @@ bool LLAppViewer::init() LLUIImageList::getInstance(), ui_audio_callback, deferred_ui_audio_callback); + + if (gSavedSettings.getBOOL("SpellCheck")) + { + std::list dict_list; + std::string dict_setting = gSavedSettings.getString("SpellCheckDictionary"); + boost::split(dict_list, dict_setting, boost::is_any_of(std::string(","))); + if (!dict_list.empty()) + { + LLSpellChecker::setUseSpellCheck(dict_list.front()); + dict_list.pop_front(); + LLSpellChecker::instance().setSecondaryDictionaries(dict_list); + } + } + LL_INFOS("InitInfo") << "UI initialized." << LL_ENDL ; // NOW LLUI::getLanguage() should work. gDirUtilp must know the language @@ -1611,7 +1625,7 @@ bool LLAppViewer::doFrame() { LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df gMeshRepo"); - gMeshRepo.update() ; + gMeshRepo.update() ; } if(!total_work_pending) //pause texture fetching threads if nothing to process. @@ -2799,19 +2813,6 @@ bool LLAppViewer::initConfiguration() gSavedSettings.getString("Language")); } - if (gSavedSettings.getBOOL("SpellCheck")) - { - std::list dict_list; - std::string dict_setting = gSavedSettings.getString("SpellCheckDictionary"); - boost::split(dict_list, dict_setting, boost::is_any_of(std::string(","))); - if (!dict_list.empty()) - { - LLSpellChecker::setUseSpellCheck(dict_list.front()); - dict_list.pop_front(); - LLSpellChecker::instance().setSecondaryDictionaries(dict_list); - } - } - if (gNonInteractive) { tempSetControl("AllowMultipleViewers", "true"); -- cgit v1.2.3 From 6dbf1cafb20557722f30618e744e5ab61e9365fa Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Tue, 13 Aug 2024 18:45:50 -0400 Subject: Reduce texture fetch and main thread contention from LLViewerStatsRecorder via simpleton. --- indra/newview/llappviewer.cpp | 2 ++ indra/newview/llstartup.cpp | 1 - indra/newview/llviewerstatsrecorder.cpp | 10 +--------- indra/newview/llviewerstatsrecorder.h | 9 +++------ 4 files changed, 6 insertions(+), 16 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 36fe5a953f..ca7a300403 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1284,6 +1284,7 @@ bool LLAppViewer::init() //LLSimpleton creations LLEnvironment::createInstance(); LLWorld::createInstance(); + LLViewerStatsRecorder::createInstance(); LLSelectMgr::createInstance(); LLViewerCamera::createInstance(); LL::GLTFSceneManager::createInstance(); @@ -2166,6 +2167,7 @@ bool LLAppViewer::cleanup() LL::GLTFSceneManager::deleteSingleton(); LLEnvironment::deleteSingleton(); LLSelectMgr::deleteSingleton(); + LLViewerStatsRecorder::deleteSingleton(); LLViewerEventRecorder::deleteSingleton(); LLWorld::deleteSingleton(); LLVoiceClient::deleteSingleton(); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index b993ba16d5..7cefa21125 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1285,7 +1285,6 @@ bool idle_startup() // // Initialize classes w/graphics stuff. // - LLViewerStatsRecorder::instance(); // Since textures work in threads LLSurface::initClasses(); display_startup(); diff --git a/indra/newview/llviewerstatsrecorder.cpp b/indra/newview/llviewerstatsrecorder.cpp index 88edb96fbb..58065ecce5 100644 --- a/indra/newview/llviewerstatsrecorder.cpp +++ b/indra/newview/llviewerstatsrecorder.cpp @@ -27,16 +27,13 @@ #include "llviewerprecompiledheaders.h" #include "llviewerstatsrecorder.h" - #include "llcontrol.h" #include "llfile.h" +#include "llviewercontrol.h" #include "llviewerregion.h" #include "llviewerobject.h" #include "llworld.h" -extern LLControlGroup gSavedSettings; - -LLViewerStatsRecorder* LLViewerStatsRecorder::sInstance = NULL; LLViewerStatsRecorder::LLViewerStatsRecorder() : mStatsFile(NULL), mTimer(), @@ -48,11 +45,6 @@ LLViewerStatsRecorder::LLViewerStatsRecorder() : mMaxDuration(300.f), mSkipSaveIfZeros(false) { - if (NULL != sInstance) - { - LL_ERRS() << "Attempted to create multiple instances of LLViewerStatsRecorder!" << LL_ENDL; - } - sInstance = this; clearStats(); } diff --git a/indra/newview/llviewerstatsrecorder.h b/indra/newview/llviewerstatsrecorder.h index ecc321c0a8..2108f49dc3 100644 --- a/indra/newview/llviewerstatsrecorder.h +++ b/indra/newview/llviewerstatsrecorder.h @@ -38,13 +38,12 @@ class LLMutex; class LLViewerObject; -class LLViewerStatsRecorder : public LLSingleton +class LLViewerStatsRecorder : public LLSimpleton { - LLSINGLETON(LLViewerStatsRecorder); +public: + LLViewerStatsRecorder(); LOG_CLASS(LLViewerStatsRecorder); ~LLViewerStatsRecorder(); - - public: // Enable/disable stats recording. This is broken down into two // flags so we can record stats without writing them to the log // file. This is useful to analyzing updates for scene loading. @@ -140,8 +139,6 @@ private: void closeStatsFile(); void makeStatsFileName(); - static LLViewerStatsRecorder* sInstance; - LLFILE * mStatsFile; // File to write data into std::string mStatsFileName; -- cgit v1.2.3 From b5e306f7d89e82984a37824a3640bd67a5c45d61 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Wed, 14 Aug 2024 11:01:02 -0400 Subject: Enable /permissive- on MSVC for better standards conformance (#2251) * Enable /permissive- on MSVC for better C++ conformance and fix related errors * Clean up left over warning suppressions from old library or msvc versions --- indra/newview/llappearancemgr.cpp | 5 ----- indra/newview/llappviewer.cpp | 5 ----- indra/newview/llcommandlineparser.cpp | 14 -------------- indra/newview/llgroupmgr.cpp | 11 ----------- indra/newview/llimprocessing.cpp | 4 ---- indra/newview/lllogchat.cpp | 12 ------------ indra/newview/llmediadataclient.cpp | 5 ----- indra/newview/llsecapi.h | 4 ++++ indra/newview/llsechandler_basic.h | 9 +++++++++ indra/newview/llviewerjoystick.cpp | 2 +- indra/newview/llviewerjoystick.h | 2 +- indra/newview/llviewerprecompiledheaders.h | 5 ----- indra/newview/llvoavatarself.cpp | 11 ----------- indra/newview/llwindebug.h | 3 --- 14 files changed, 15 insertions(+), 77 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 66082d317a..946d674e8b 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -66,11 +66,6 @@ #include "llavatarpropertiesprocessor.h" -#if LL_MSVC -// disable boost::lexical_cast warning -#pragma warning (disable:4702) -#endif - namespace { const S32 BAKE_RETRY_MAX_COUNT = 5; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 262ab439b4..e39d9e7e20 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -269,11 +269,6 @@ using namespace LL; #include "glib.h" #endif // (LL_LINUX) && LL_GTK -#if LL_MSVC -// disable boost::lexical_cast warning -#pragma warning (disable:4702) -#endif - static LLAppViewerListener sAppViewerListener(LLAppViewer::instance); ////// Windows-specific includes to the bottom - nasty defines in these pollute the preprocessor diff --git a/indra/newview/llcommandlineparser.cpp b/indra/newview/llcommandlineparser.cpp index f301af9511..f21bae9805 100644 --- a/indra/newview/llcommandlineparser.cpp +++ b/indra/newview/llcommandlineparser.cpp @@ -28,26 +28,12 @@ #include "llcommandlineparser.h" #include "llexception.h" -// *NOTE: The boost::lexical_cast generates -// the warning C4701(local used with out assignment) in VC7.1. -// Disable the warning for the boost includes. -#if _MSC_VER -# pragma warning(push) -# pragma warning( disable : 4701 ) -#else -// NOTE: For the other platforms? -#endif - #include #include #include #include #include -#if _MSC_VER -# pragma warning(pop) -#endif - #include "llsdserialize.h" #include "llerror.h" #include "stringize.h" diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 76d3e3e049..d53b36e59f 100644 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -55,19 +55,8 @@ #include "llcorehttputil.h" #include "lluiusage.h" - -#if LL_MSVC -#pragma warning(push) -// disable boost::lexical_cast warning -#pragma warning (disable:4702) -#endif - #include -#if LL_MSVC -#pragma warning(pop) // Restore all warnings to the previous state -#endif - const U32 MAX_CACHED_GROUPS = 20; // diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp index e24274650d..c1e68e0288 100644 --- a/indra/newview/llimprocessing.cpp +++ b/indra/newview/llimprocessing.cpp @@ -58,10 +58,6 @@ #include "llworld.h" #include "boost/lexical_cast.hpp" -#if LL_MSVC -// disable boost::lexical_cast warning -#pragma warning (disable:4702) -#endif extern void on_new_message(const LLSD& msg); diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index 329fb881e3..bf49f33049 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -42,19 +42,7 @@ #include #include #include - -#if LL_MSVC -#pragma warning(push) -// disable warning about boost::lexical_cast unreachable code -// when it fails to parse the string -#pragma warning (disable:4702) -#endif - #include -#if LL_MSVC -#pragma warning(pop) // Restore all warnings to the previous state -#endif - #include #include diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index 0f3e0306af..83a6e66019 100644 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -29,11 +29,6 @@ #include "llmediadataclient.h" #include "llviewercontrol.h" -#if LL_MSVC -// disable boost::lexical_cast warning -#pragma warning (disable:4702) -#endif - #include #include diff --git a/indra/newview/llsecapi.h b/indra/newview/llsecapi.h index 5cc78d09dc..ceea11cc34 100644 --- a/indra/newview/llsecapi.h +++ b/indra/newview/llsecapi.h @@ -35,6 +35,7 @@ #include "llexception.h" #ifdef LL_WINDOWS +#pragma warning (push) #pragma warning(disable:4250) #endif // LL_WINDOWS @@ -549,5 +550,8 @@ void registerSecHandler(const std::string& handler_type, extern LLPointer gSecAPIHandler; +#ifdef LL_WINDOWS +#pragma warning (pop) +#endif // LL_WINDOWS #endif // LL_SECAPI_H diff --git a/indra/newview/llsechandler_basic.h b/indra/newview/llsechandler_basic.h index 1484c6d0e1..2dffe84775 100644 --- a/indra/newview/llsechandler_basic.h +++ b/indra/newview/llsechandler_basic.h @@ -28,6 +28,11 @@ #ifndef LLSECHANDLER_BASIC #define LLSECHANDLER_BASIC +#ifdef LL_WINDOWS +#pragma warning (push) +#pragma warning(disable:4250) +#endif // LL_WINDOWS + #include "llsecapi.h" #include #include @@ -346,6 +351,10 @@ protected: bool valueCompareLLSD(const LLSD& lhs, const LLSD& rhs); +#ifdef LL_WINDOWS +#pragma warning (pop) +#endif // LL_WINDOWS + #endif // LLSECHANDLER_BASIC diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp index 787ea02e4c..7543fb3743 100644 --- a/indra/newview/llviewerjoystick.cpp +++ b/indra/newview/llviewerjoystick.cpp @@ -524,7 +524,7 @@ void LLViewerJoystick::initDevice(LLSD &guid) #endif } -bool LLViewerJoystick::initDevice(void * preffered_device /*LPDIRECTINPUTDEVICE8*/, std::string &name, LLSD &guid) +bool LLViewerJoystick::initDevice(void * preffered_device /*LPDIRECTINPUTDEVICE8*/, const std::string &name, const LLSD &guid) { #if LIB_NDOF mLastDeviceUUID = guid; diff --git a/indra/newview/llviewerjoystick.h b/indra/newview/llviewerjoystick.h index b459987c68..c989615653 100644 --- a/indra/newview/llviewerjoystick.h +++ b/indra/newview/llviewerjoystick.h @@ -56,7 +56,7 @@ public: void init(bool autoenable); void initDevice(LLSD &guid); bool initDevice(void * preffered_device /*LPDIRECTINPUTDEVICE8*/); - bool initDevice(void * preffered_device /*LPDIRECTINPUTDEVICE8*/, std::string &name, LLSD &guid); + bool initDevice(void * preffered_device /*LPDIRECTINPUTDEVICE8*/, const std::string &name, const LLSD &guid); void terminate(); void updateStatus(); diff --git a/indra/newview/llviewerprecompiledheaders.h b/indra/newview/llviewerprecompiledheaders.h index 8398cd8a54..6561f0d644 100644 --- a/indra/newview/llviewerprecompiledheaders.h +++ b/indra/newview/llviewerprecompiledheaders.h @@ -37,11 +37,6 @@ #include "linden_common.h" -// Work around stupid Microsoft STL warning -#ifdef LL_WINDOWS -#pragma warning (disable : 4702) // warning C4702: unreachable code -#endif - #include #include #include diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 57f7734fea..00a7325db2 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -24,12 +24,6 @@ * $/LicenseInfo$ */ -#if LL_MSVC -// disable warning about boost::lexical_cast returning uninitialized data -// when it fails to parse the string -#pragma warning (disable:4701) -#endif - #include "llviewerprecompiledheaders.h" #include "llvoavatarself.h" @@ -69,11 +63,6 @@ #include "llcorehttputil.h" #include "lluiusage.h" -#if LL_MSVC -// disable boost::lexical_cast warning -#pragma warning (disable:4702) -#endif - #include LLPointer gAgentAvatarp = NULL; diff --git a/indra/newview/llwindebug.h b/indra/newview/llwindebug.h index d2801c86e1..770584c88d 100644 --- a/indra/newview/llwindebug.h +++ b/indra/newview/llwindebug.h @@ -30,10 +30,7 @@ #include "stdtypes.h" #include "llwin32headerslean.h" -#pragma warning (push) -#pragma warning (disable:4091) // a microsoft header has warnings. Very nice. #include -#pragma warning (pop) class LLWinDebug: public LLSingleton -- cgit v1.2.3 From 714c6983f4cad754661654c09e9629b9d7a0db11 Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Thu, 15 Aug 2024 04:49:23 +0200 Subject: Add missing va_end (#2301) --- indra/newview/pipeline.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1b2cffa6c9..a5c7350fd8 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -10668,6 +10668,7 @@ bool LLPipeline::hasAnyRenderType(U32 type, ...) const { if (mRenderTypeEnabled[type]) { + va_end(args); return true; } type = va_arg(args, U32); -- cgit v1.2.3 From 9daa5b000cd61c77c9bec8f837920937e4e4b0f8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 15 Aug 2024 18:17:39 +0300 Subject: viewer-private#268 When deleting worn items, move them to trash --- indra/newview/llinventoryfunctions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 8471b2cea1..57c0d57190 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -3637,11 +3637,11 @@ void LLInventoryAction::onItemsRemovalConfirmation(const LLSD& notification, con { for (const LLUUID& id : item_deletion_list) { - remove_inventory_item(id, NULL); + gInventory.removeItem(id); } for (const LLUUID& id : cat_deletion_list) { - remove_inventory_category(id, NULL); + gInventory.removeCategory(id); } }); } -- cgit v1.2.3 From ae0433f4ebba799c16d6498f8a78ccb101db9706 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 15 Aug 2024 21:02:04 +0300 Subject: Fix loose mGalleryPanel in LLInventoryGallery LLInventoryGallery::buildGalleryPanel does the creation, not postBuild() same for LLOutfitGallery. Either don't create mGalleryPanel or remove it before creating again. --- indra/newview/llfloaterimnearbychathandler.cpp | 1 - indra/newview/llinventorygallery.cpp | 2 -- indra/newview/lloutfitgallery.cpp | 2 -- 3 files changed, 5 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterimnearbychathandler.cpp b/indra/newview/llfloaterimnearbychathandler.cpp index a614299e03..e9cd912ca9 100644 --- a/indra/newview/llfloaterimnearbychathandler.cpp +++ b/indra/newview/llfloaterimnearbychathandler.cpp @@ -152,7 +152,6 @@ protected: toast_list_t m_toast_pool; bool mStopProcessing; - bool mChannelRect; }; diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index 9e6cf7ac73..46d1e822de 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -147,8 +147,6 @@ const LLInventoryGallery::Params& LLInventoryGallery::getDefaultParams() bool LLInventoryGallery::postBuild() { mScrollPanel = getChild("gallery_scroll_panel"); - LLPanel::Params params = LLPanel::getDefaultParams(); - mGalleryPanel = LLUICtrlFactory::create(params); mMessageTextBox = getChild("empty_txt"); mInventoryGalleryMenu = new LLInventoryGalleryContextMenu(this); mRootGalleryMenu = new LLInventoryGalleryContextMenu(this); diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp index d7df9ceadc..72fb9464d8 100644 --- a/indra/newview/lloutfitgallery.cpp +++ b/indra/newview/lloutfitgallery.cpp @@ -109,8 +109,6 @@ bool LLOutfitGallery::postBuild() { bool rv = LLOutfitListBase::postBuild(); mScrollPanel = getChild("gallery_scroll_panel"); - LLPanel::Params params = LLPanel::getDefaultParams(); // Don't parse XML when creating dummy LLPanel - mGalleryPanel = LLUICtrlFactory::create(params); mMessageTextBox = getChild("no_outfits_txt"); mOutfitGalleryMenu = new LLOutfitGalleryContextMenu(this); return rv; -- cgit v1.2.3 From d79ff40ee2bac1ddb9d721aa8a408a0f104d5a4d Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sat, 17 Aug 2024 18:23:58 -0400 Subject: Fix hero probes not releasing resources when disabled --- indra/newview/llheroprobemanager.cpp | 4 ---- indra/newview/llheroprobemanager.h | 7 ------- indra/newview/pipeline.cpp | 4 +++- 3 files changed, 3 insertions(+), 12 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index 91051f8235..ce419498cf 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -586,7 +586,6 @@ void LLHeroProbeManager::cleanup() { mVertexBuffer = nullptr; mRenderTarget.release(); - mHeroRenderTarget.release(); mMipChain.clear(); @@ -594,10 +593,7 @@ void LLHeroProbeManager::cleanup() mProbes.clear(); - mReflectionMaps.clear(); - mDefaultProbe = nullptr; - mUpdatingProbe = nullptr; } void LLHeroProbeManager::doOcclusion() diff --git a/indra/newview/llheroprobemanager.h b/indra/newview/llheroprobemanager.h index 28852770c3..58a94a3de8 100644 --- a/indra/newview/llheroprobemanager.h +++ b/indra/newview/llheroprobemanager.h @@ -104,8 +104,6 @@ private: // used to generate mipmaps without doing a copy-to-texture LLRenderTarget mRenderTarget; - LLRenderTarget mHeroRenderTarget; - std::vector mMipChain; // storage for reflection probe radiance maps (plus two scratch space cubemaps) @@ -124,11 +122,6 @@ private: // list of active reflection maps std::vector> mProbes; - // list of maps being used for rendering - std::vector mReflectionMaps; - - LLReflectionMap* mUpdatingProbe = nullptr; - LLPointer mDefaultProbe; // default reflection probe to fall back to for pixels with no probe influences (should always be at cube index 0) // number of reflection probes to use for rendering diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a5c7350fd8..857af40601 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -777,7 +777,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (mRT == &mMainRT) { // hacky -- allocate auxillary buffer - gCubeSnapshot = TRUE; + gCubeSnapshot = true; if (sReflectionProbesEnabled) { @@ -1117,6 +1117,8 @@ void LLPipeline::releaseGLBuffers() mGlow[i].release(); } + mHeroProbeManager.cleanup(); // release hero probes + releaseScreenBuffers(); gBumpImageList.destroyGL(); -- cgit v1.2.3 From 0d9ddae0c6734f8ce76a5cdb40947f6da105c0b2 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sat, 17 Aug 2024 19:14:40 -0400 Subject: Reduce number of full screen render targets --- indra/newview/llviewerdisplay.cpp | 6 +-- indra/newview/pipeline.cpp | 92 ++++++++++++++++++++++----------------- indra/newview/pipeline.h | 9 ++-- 3 files changed, 60 insertions(+), 47 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index fbbcf9bd84..8c6a38876a 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1603,7 +1603,7 @@ void render_ui_2d() LLView::sIsRectDirty = false; LLRect t_rect; - gPipeline.mRT->uiScreen.bindTarget(); + gPipeline.mUIScreen.bindTarget(); gGL.setColorMask(true, true); { static const S32 pad = 8; @@ -1635,7 +1635,7 @@ void render_ui_2d() gViewerWindow->draw(); } - gPipeline.mRT->uiScreen.flush(); + gPipeline.mUIScreen.flush(); gGL.setColorMask(true, false); LLView::sDirtyRect = t_rect; @@ -1645,7 +1645,7 @@ void render_ui_2d() LLGLDisable blend(GL_BLEND); S32 width = gViewerWindow->getWindowWidthScaled(); S32 height = gViewerWindow->getWindowHeightScaled(); - gGL.getTexUnit(0)->bind(&gPipeline.mRT->uiScreen); + gGL.getTexUnit(0)->bind(&gPipeline.mUIScreen); gGL.begin(LLRender::TRIANGLE_STRIP); gGL.color4f(1.f,1.f,1.f,1.f); gGL.texCoord2f(0.f, 0.f); gGL.vertex2i(0, 0); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 857af40601..2bafa6e3af 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -812,17 +812,6 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) resY /= res_mod; } - //water reflection texture (always needed as scratch space whether or not transparent water is enabled) - mWaterDis.allocate(resX, resY, GL_RGBA16F, true); - - if (RenderUIBuffer) - { - if (!mRT->uiScreen.allocate(resX,resY, GL_RGBA)) - { - return false; - } - } - S32 shadow_detail = RenderShadowDetail; bool ssao = RenderDeferredSSAO; @@ -836,15 +825,6 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) mRT->deferredScreen.shareDepthBuffer(mRT->screen); - if (samples > 0) - { - if (!mRT->fxaaBuffer.allocate(resX, resY, GL_RGBA)) return false; - } - else - { - mRT->fxaaBuffer.release(); - } - if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0) { //only need mRT->deferredLight for shadows OR ssao OR dof OR fxaa if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA16F)) return false; @@ -856,19 +836,45 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) allocateShadowBuffer(resX, resY); - if (!gCubeSnapshot && RenderScreenSpaceReflections) // hack to not allocate mSceneMap for cube snapshots + if (!gCubeSnapshot) // hack to not re-allocate various targets for cube snapshots { - mSceneMap.allocate(resX, resY, GL_RGB, true); - } + if (RenderUIBuffer) + { + if (!mUIScreen.allocate(resX, resY, GL_RGBA)) + { + return false; + } + } - const bool post_hdr = gSavedSettings.getBOOL("RenderPostProcessingHDR"); - const U32 post_color_fmt = post_hdr ? GL_RGBA16F : GL_RGBA; - mPostMap.allocate(resX, resY, post_color_fmt); + if (samples > 0) + { + if (!mFXAAMap.allocate(resX, resY, GL_RGBA)) return false; + } + else + { + mFXAAMap.release(); + } - // used to scale down textures - // See LLViwerTextureList::updateImagesCreateTextures and LLImageGL::scaleDown - mDownResMap.allocate(4, 4, GL_RGBA); + //water reflection texture (always needed as scratch space whether or not transparent water is enabled) + mWaterDis.allocate(resX, resY, GL_RGBA16F, true); + if(RenderScreenSpaceReflections) + { + mSceneMap.allocate(resX, resY, GL_RGB, true); + } + else + { + mSceneMap.release(); + } + + const bool post_hdr = gSavedSettings.getBOOL("RenderPostProcessingHDR"); + const U32 post_color_fmt = post_hdr ? GL_RGBA16F : GL_RGBA; + mPostMap.allocate(resX, resY, post_color_fmt); + + // used to scale down textures + // See LLViwerTextureList::updateImagesCreateTextures and LLImageGL::scaleDown + mDownResMap.allocate(4, 4, GL_RGBA); + } //HACK make screenbuffer allocations start failing after 30 seconds if (gSavedSettings.getBOOL("SimulateFBOFailure")) { @@ -1110,6 +1116,10 @@ void LLPipeline::releaseGLBuffers() mPostMap.release(); + mFXAAMap.release(); + + mUIScreen.release(); + mDownResMap.release(); for (U32 i = 0; i < 3; i++) @@ -1149,15 +1159,15 @@ void LLPipeline::releaseShadowBuffers() void LLPipeline::releaseScreenBuffers() { - mRT->uiScreen.release(); mRT->screen.release(); - mRT->fxaaBuffer.release(); mRT->deferredScreen.release(); mRT->deferredLight.release(); - mHeroProbeRT.uiScreen.release(); + mAuxillaryRT.screen.release(); + mAuxillaryRT.deferredScreen.release(); + mAuxillaryRT.deferredLight.release(); + mHeroProbeRT.screen.release(); - mHeroProbeRT.fxaaBuffer.release(); mHeroProbeRT.deferredScreen.release(); mHeroProbeRT.deferredLight.release(); } @@ -7125,7 +7135,7 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { { llassert(!gCubeSnapshot); - bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete(); + bool multisample = RenderFSAASamples > 1 && mFXAAMap.isComplete(); LLGLSLShader* shader = &gGlowCombineProgram; S32 width = dst->getWidth(); @@ -7136,7 +7146,7 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) { LL_PROFILE_GPU_ZONE("aa"); // bake out texture2D with RGBL for FXAA shader - mRT->fxaaBuffer.bindTarget(); + mFXAAMap.bindTarget(); shader = &gGlowCombineFXAAProgram; shader->bind(); @@ -7156,16 +7166,16 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, src->getUsage()); shader->unbind(); - mRT->fxaaBuffer.flush(); + mFXAAMap.flush(); dst->bindTarget(); shader = &gFXAAProgram; shader->bind(); - channel = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP, mRT->fxaaBuffer.getUsage()); + channel = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP, mFXAAMap.getUsage()); if (channel > -1) { - mRT->fxaaBuffer.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + mFXAAMap.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; @@ -7175,8 +7185,8 @@ void LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst) glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - F32 scale_x = (F32)width / mRT->fxaaBuffer.getWidth(); - F32 scale_y = (F32)height / mRT->fxaaBuffer.getHeight(); + F32 scale_x = (F32)width / mFXAAMap.getWidth(); + F32 scale_y = (F32)height / mFXAAMap.getHeight(); shader->uniform2f(LLShaderMgr::FXAA_TC_SCALE, scale_x, scale_y); shader->uniform2f(LLShaderMgr::FXAA_RCP_SCREEN_RES, 1.f / width * scale_x, 1.f / height * scale_y); shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT, -0.5f / width * scale_x, -0.5f / height * scale_y, @@ -7410,7 +7420,7 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) { // combine result based on alpha dst->bindTarget(); - if (RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete()) + if (RenderFSAASamples > 1 && mFXAAMap.isComplete()) { glViewport(0, 0, dst->getWidth(), dst->getHeight()); } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 4164474238..024303d5f0 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -687,10 +687,7 @@ public: //screen texture LLRenderTarget screen; - LLRenderTarget uiScreen; LLRenderTarget deferredScreen; - LLRenderTarget fxaaBuffer; - LLRenderTarget edgeMap; LLRenderTarget deferredLight; //sun shadow map @@ -726,6 +723,12 @@ public: // tonemapped and gamma corrected render ready for post LLRenderTarget mPostMap; + // FXAA helper target + LLRenderTarget mFXAAMap; + + // render ui to buffer target + LLRenderTarget mUIScreen; + // downres scratch space for GPU downscaling of textures LLRenderTarget mDownResMap; -- cgit v1.2.3 From 94aec3d1e619372b0652d298ded4d2a7ac96d131 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sat, 17 Aug 2024 19:23:05 -0400 Subject: Avoid scaling probe shadow maps by RenderShadowResolutionScale --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2bafa6e3af..979d0eba7e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -896,7 +896,7 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; S32 shadow_detail = RenderShadowDetail; - F32 scale = llmax(0.f, RenderShadowResolutionScale); + F32 scale = gCubeSnapshot ? 1.0 : llmax(0.f, RenderShadowResolutionScale); // Don't scale probe shadow maps U32 sun_shadow_map_width = BlurHappySize(resX, scale); U32 sun_shadow_map_height = BlurHappySize(resY, scale); -- cgit v1.2.3 From 4e19b2ae34a0cd5e19068bedb8612ba4ea89e8c1 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sat, 17 Aug 2024 19:19:18 -0400 Subject: Fix RenderReflectionProbeResolution debug setting not updating during runtime --- indra/newview/llreflectionmapmanager.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 1efe51c1aa..3526004071 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -1371,13 +1371,21 @@ void LLReflectionMapManager::initReflectionMaps() { U32 count = LL_MAX_REFLECTION_PROBE_COUNT; - if (mTexture.isNull() || mReflectionProbeCount != count || mReset) + static LLCachedControl ref_probe_res(gSavedSettings, "RenderReflectionProbeResolution", 128U); + U32 probe_resolution = nhpo2(llclamp(ref_probe_res(), (U32)64, (U32)512)); + if (mTexture.isNull() || mReflectionProbeCount != count || mProbeResolution != probe_resolution || mReset) { + if(mProbeResolution != probe_resolution) + { + mRenderTarget.release(); + mMipChain.clear(); + } + gEXRImage = nullptr; mReset = false; mReflectionProbeCount = count; - mProbeResolution = nhpo2(llclamp(gSavedSettings.getU32("RenderReflectionProbeResolution"), (U32)64, (U32)512)); + mProbeResolution = probe_resolution; mMaxProbeLOD = log2f((F32)mProbeResolution) - 1.f; // number of mips - 1 if (mTexture.isNull() || -- cgit v1.2.3 From ba2b77d0882f8ca3ef0ae95ca9d388aa217f9a7a Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sun, 18 Aug 2024 15:35:33 -0400 Subject: Fix findChild during draw in preference floater --- indra/newview/llfloaterpreference.cpp | 49 ++++++++++------------ indra/newview/llfloaterpreference.h | 7 +++- .../default/xui/en/panel_preferences_alerts.xml | 2 - 3 files changed, 28 insertions(+), 30 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 5e5cfcecbf..3441fff7e8 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -430,6 +430,13 @@ void LLFloaterPreference::saveAvatarPropertiesCoro(const std::string cap_url, bo bool LLFloaterPreference::postBuild() { + mDeleteTranscriptsBtn = getChild("delete_transcripts"); + + mEnabledPopups = getChild("enabled_popups"); + mDisabledPopups = getChild("disabled_popups"); + mEnablePopupBtn = getChild("enable_this_popup"); + mDisablePopupBtn = getChild("disable_this_popup"); + gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLFloaterIMSessionTab::processChatHistoryStyleUpdate, false)); gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLViewerChat::signalChatFontChanged)); @@ -519,7 +526,7 @@ bool LLFloaterPreference::postBuild() void LLFloaterPreference::updateDeleteTranscriptsButton() { - getChild("delete_transcripts")->setEnabled(LLLogChat::transcriptFilesExist()); + mDeleteTranscriptsBtn->setEnabled(LLLogChat::transcriptFilesExist()); } void LLFloaterPreference::onDoNotDisturbResponseChanged() @@ -540,11 +547,11 @@ LLFloaterPreference::~LLFloaterPreference() void LLFloaterPreference::draw() { - bool has_first_selected = (getChildRef("disabled_popups").getFirstSelected()!=NULL); - gSavedSettings.setBOOL("FirstSelectedDisabledPopups", has_first_selected); + bool has_first_selected = (mDisabledPopups->getFirstSelected()!=NULL); + mEnablePopupBtn->setEnabled(has_first_selected); - has_first_selected = (getChildRef("enabled_popups").getFirstSelected()!=NULL); - gSavedSettings.setBOOL("FirstSelectedEnabledPopups", has_first_selected); + has_first_selected = (mEnabledPopups->getFirstSelected()!=NULL); + mDisablePopupBtn->setEnabled(has_first_selected); LLFloater::draw(); } @@ -1171,13 +1178,8 @@ void LLFloaterPreference::refreshSkin(void* data) void LLFloaterPreference::buildPopupLists() { - LLScrollListCtrl& disabled_popups = - getChildRef("disabled_popups"); - LLScrollListCtrl& enabled_popups = - getChildRef("enabled_popups"); - - disabled_popups.deleteAllItems(); - enabled_popups.deleteAllItems(); + mDisabledPopups->deleteAllItems(); + mEnabledPopups->deleteAllItems(); for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin(); iter != LLNotifications::instance().templatesEnd(); @@ -1219,11 +1221,11 @@ void LLFloaterPreference::buildPopupLists() } } } - item = disabled_popups.addElement(row); + item = mDisabledPopups->addElement(row); } else { - item = enabled_popups.addElement(row); + item = mEnabledPopups->addElement(row); } if (item) @@ -1324,9 +1326,7 @@ void LLFloaterPreference::onClickSetSounds() void LLFloaterPreference::onClickEnablePopup() { - LLScrollListCtrl& disabled_popups = getChildRef("disabled_popups"); - - std::vector items = disabled_popups.getAllSelected(); + std::vector items = mDisabledPopups->getAllSelected(); std::vector::iterator itor; for (itor = items.begin(); itor != items.end(); ++itor) { @@ -1345,9 +1345,7 @@ void LLFloaterPreference::onClickEnablePopup() void LLFloaterPreference::onClickDisablePopup() { - LLScrollListCtrl& enabled_popups = getChildRef("enabled_popups"); - - std::vector items = enabled_popups.getAllSelected(); + std::vector items = mEnabledPopups->getAllSelected(); std::vector::iterator itor; for (itor = items.begin(); itor != items.end(); ++itor) { @@ -1796,11 +1794,9 @@ void LLFloaterPreference::onDeleteTranscriptsResponse(const LLSD& notification, void LLFloaterPreference::onLogChatHistorySaved() { - LLButton * delete_transcripts_buttonp = getChild("delete_transcripts"); - - if (!delete_transcripts_buttonp->getEnabled()) + if (!mDeleteTranscriptsBtn->getEnabled()) { - delete_transcripts_buttonp->setEnabled(true); + mDeleteTranscriptsBtn->setEnabled(true); } } @@ -2334,7 +2330,6 @@ bool LLPanelPreferenceGraphics::postBuild() void LLPanelPreferenceGraphics::draw() { - setPresetText(); LLPanelPreference::draw(); } @@ -3315,8 +3310,8 @@ void LLFloaterPreference::onUpdateFilterTerm(bool force) void LLFloaterPreference::filterIgnorableNotifications() { - bool visible = getChildRef("enabled_popups").highlightMatchingItems(mFilterEdit->getValue()); - visible |= getChildRef("disabled_popups").highlightMatchingItems(mFilterEdit->getValue()); + bool visible = mEnabledPopups->highlightMatchingItems(mFilterEdit->getValue()); + visible |= mDisabledPopups->highlightMatchingItems(mFilterEdit->getValue()); if (visible) { diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index c8b98d8e1b..51ed3d8179 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -225,7 +225,12 @@ private: std::string mSavedGraphicsPreset; LOG_CLASS(LLFloaterPreference); - LLSearchEditor *mFilterEdit; + LLSearchEditor* mFilterEdit = nullptr; + LLScrollListCtrl* mEnabledPopups = nullptr; + LLScrollListCtrl* mDisabledPopups = nullptr; + LLButton* mDeleteTranscriptsBtn = nullptr; + LLButton* mEnablePopupBtn = nullptr; + LLButton* mDisablePopupBtn = nullptr; std::unique_ptr< ll::prefs::SearchData > mSearchData; bool mSearchDataDirty; diff --git a/indra/newview/skins/default/xui/en/panel_preferences_alerts.xml b/indra/newview/skins/default/xui/en/panel_preferences_alerts.xml index fb528bf98f..425cbb6f44 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_alerts.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_alerts.xml @@ -69,7 +69,6 @@ sort_ascending="true" width="495" />