From bf0767b0d781202064c58ff7c9f44dfeec6959ac Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 29 Oct 2024 00:54:13 +0200 Subject: viewer#2894 Make PBR scale like Blinn Phong does --- indra/newview/llselectmgr.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index b307de787c..b2f30dd966 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -3138,6 +3138,8 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch) F32 scale_x = 1; F32 scale_y = 1; + F32 offset_x = 0; + F32 offset_y = 0; for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i) { @@ -3154,6 +3156,21 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch) scale_y = scale_ratio.mV[t_axis] * object_scale.mV[t_axis]; } material->mTextureTransform[i].mScale.set(scale_x, scale_y); + + LLVector2 scales = selectNode->mGLTFScales[te_num][i]; + LLVector2 offsets = selectNode->mGLTFOffsets[te_num][i]; + F64 int_part = 0; + offset_x = (F32)modf((offsets[VX] + (scales[VX] - scale_x)) / 2, &int_part); + if (offset_x < 0) + { + offset_x++; + } + offset_y = (F32)modf((offsets[VY] + (scales[VY] - scale_y)) / 2, &int_part); + if (offset_y < 0) + { + offset_y++; + } + material->mTextureTransform[i].mOffset.set(offset_x, offset_y); } const LLGLTFMaterial* base_material = tep->getGLTFMaterial(); @@ -6904,6 +6921,8 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) { mTextureScaleRatios.clear(); mGLTFScaleRatios.clear(); + mGLTFScales.clear(); + mGLTFOffsets.clear(); if (mObject.notNull()) { @@ -6944,6 +6963,8 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) F32 scale_x = 1; F32 scale_y = 1; std::vector material_v_vec; + std::vector material_scales_vec; + std::vector material_offset_vec; for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i) { if (material) @@ -6951,12 +6972,16 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) LLGLTFMaterial::TextureTransform& transform = material->mTextureTransform[i]; scale_x = transform.mScale[VX]; scale_y = transform.mScale[VY]; + material_scales_vec.push_back(transform.mScale); + material_offset_vec.push_back(transform.mOffset); } else { // Not having an override doesn't mean that there is no material scale_x = 1; scale_y = 1; + material_scales_vec.emplace_back(scale_x, scale_y); + material_offset_vec.emplace_back(0.f, 0.f); } if (tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR) @@ -6972,6 +6997,8 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) material_v_vec.push_back(material_v); } mGLTFScaleRatios.push_back(material_v_vec); + mGLTFScales.push_back(material_scales_vec); + mGLTFOffsets.push_back(material_offset_vec); } } } -- cgit v1.2.3 From 939817d560434cdc2888ef478b965f5625a381b7 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 1 Apr 2025 21:16:38 +0300 Subject: #3849 Crash at LLSelectMgr::updatePointAt --- indra/newview/llselectmgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 3d17446186..be1e64ce54 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -7513,7 +7513,7 @@ void LLSelectMgr::updatePointAt() LLVector3 select_offset; const LLPickInfo& pick = gViewerWindow->getLastPick(); LLViewerObject *click_object = pick.getObject(); - bool was_hud = pick.mPickHUD && !click_object->isHUDAttachment(); + bool was_hud = pick.mPickHUD && click_object && !click_object->isHUDAttachment(); if (click_object && click_object->isSelected() && !was_hud) { // clicked on another object in our selection group, use that as target -- cgit v1.2.3 From fe0a4f44cf172953fa44f26acb56e0be50ec8bb4 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 5 May 2025 19:38:07 +0300 Subject: #4027 Crash at adjustTexturesByScale --- indra/newview/llselectmgr.cpp | 62 ++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 28 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index be1e64ce54..8aa3693d60 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -3142,36 +3142,43 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch) F32 offset_x = 0; F32 offset_y = 0; - for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i) + if (te_num < selectNode->mGLTFScaleRatios.size()) { - LLVector3 scale_ratio = selectNode->mGLTFScaleRatios[te_num][i]; - - if (planar) - { - scale_x = scale_ratio.mV[s_axis] / object_scale.mV[s_axis]; - scale_y = scale_ratio.mV[t_axis] / object_scale.mV[t_axis]; - } - else - { - scale_x = scale_ratio.mV[s_axis] * object_scale.mV[s_axis]; - scale_y = scale_ratio.mV[t_axis] * object_scale.mV[t_axis]; - } - material->mTextureTransform[i].mScale.set(scale_x, scale_y); - - LLVector2 scales = selectNode->mGLTFScales[te_num][i]; - LLVector2 offsets = selectNode->mGLTFOffsets[te_num][i]; - F64 int_part = 0; - offset_x = (F32)modf((offsets[VX] + (scales[VX] - scale_x)) / 2, &int_part); - if (offset_x < 0) + for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i) { - offset_x++; + LLVector3 scale_ratio = selectNode->mGLTFScaleRatios[te_num][i]; + + if (planar) + { + scale_x = scale_ratio.mV[s_axis] / object_scale.mV[s_axis]; + scale_y = scale_ratio.mV[t_axis] / object_scale.mV[t_axis]; + } + else + { + scale_x = scale_ratio.mV[s_axis] * object_scale.mV[s_axis]; + scale_y = scale_ratio.mV[t_axis] * object_scale.mV[t_axis]; + } + material->mTextureTransform[i].mScale.set(scale_x, scale_y); + + LLVector2 scales = selectNode->mGLTFScales[te_num][i]; + LLVector2 offsets = selectNode->mGLTFOffsets[te_num][i]; + F64 int_part = 0; + offset_x = (F32)modf((offsets[VX] + (scales[VX] - scale_x)) / 2, &int_part); + if (offset_x < 0) + { + offset_x++; + } + offset_y = (F32)modf((offsets[VY] + (scales[VY] - scale_y)) / 2, &int_part); + if (offset_y < 0) + { + offset_y++; + } + material->mTextureTransform[i].mOffset.set(offset_x, offset_y); } - offset_y = (F32)modf((offsets[VY] + (scales[VY] - scale_y)) / 2, &int_part); - if (offset_y < 0) - { - offset_y++; - } - material->mTextureTransform[i].mOffset.set(offset_x, offset_y); + } + else + { + llassert(false); // make sure mGLTFScaleRatios is filled } const LLGLTFMaterial* base_material = tep->getGLTFMaterial(); @@ -6927,7 +6934,6 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) if (mObject.notNull()) { - LLVector3 scale = mObject->getScale(); for (U8 i = 0; i < mObject->getNumTEs(); i++) -- cgit v1.2.3