diff options
Diffstat (limited to 'indra/newview/llselectmgr.cpp')
-rw-r--r-- | indra/newview/llselectmgr.cpp | 92 |
1 files changed, 89 insertions, 3 deletions
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index b3420f9c57..fcd1c84ba4 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -56,6 +56,7 @@ #include "llattachmentsmgr.h" #include "llviewerwindow.h" #include "lldrawable.h" +#include "llfloatergltfasseteditor.h" #include "llfloaterinspect.h" #include "llfloaterreporter.h" #include "llfloaterreg.h" @@ -467,6 +468,11 @@ LLObjectSelectionHandle LLSelectMgr::selectObjectOnly(LLViewerObject* object, S3 if (object->isSelected() ) { // make sure point at position is updated updatePointAt(); + LLSelectNode* nodep = mSelectedObjects->findNode(object); + if (nodep) + { + nodep->selectGLTFNode(gltf_node, gltf_primitive, true); + } gEditMenuHandler = this; return NULL; } @@ -3052,7 +3058,7 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch) for (U8 te_num = 0; te_num < object->getNumTEs(); te_num++) { - const LLTextureEntry* tep = object->getTE(te_num); + LLTextureEntry* tep = object->getTE(te_num); bool planar = tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR; if (planar == stretch) @@ -3086,8 +3092,6 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch) object->setTEScale(te_num, diffuse_scale_s, diffuse_scale_t); - LLTextureEntry* tep = object->getTE(te_num); - if (tep && !tep->getMaterialParams().isNull()) { LLMaterialPtr orig = tep->getMaterialParams(); @@ -3125,6 +3129,47 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch) LLMaterialMgr::getInstance()->put(object->getID(), te_num, *p); } } + + if (tep->getGLTFMaterial()) + { + LLPointer<LLGLTFMaterial> material = tep->getGLTFMaterialOverride(); + if (!material) + { + material = new LLGLTFMaterial(); + tep->setGLTFMaterialOverride(material); + } + + F32 scale_x = 1; + F32 scale_y = 1; + + for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i) + { + 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); + } + + LLFetchedGLTFMaterial* render_mat = (LLFetchedGLTFMaterial*)tep->getGLTFRenderMaterial(); + if (render_mat) + { + render_mat->applyOverride(*material); + } + + if (send_to_sim) + { + LLGLTFMaterialList::queueModify(object, te_num, material); + } + } send = send_to_sim; } } @@ -6848,6 +6893,7 @@ void LLSelectNode::saveGLTFMaterials(const uuid_vec_t& materials, const gltf_mat void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) { mTextureScaleRatios.clear(); + mGLTFScaleRatios.clear(); if (mObject.notNull()) { @@ -6882,6 +6928,40 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) v.mV[t_axis] = diffuse_t/scale.mV[t_axis]; mTextureScaleRatios.push_back(v); } + + LLGLTFMaterial* material = tep->getGLTFMaterialOverride(); + LLVector3 material_v; + F32 scale_x = 1; + F32 scale_y = 1; + std::vector<LLVector3> material_v_vec; + for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i) + { + if (material) + { + LLGLTFMaterial::TextureTransform& transform = material->mTextureTransform[i]; + scale_x = transform.mScale[VX]; + scale_y = transform.mScale[VY]; + } + else + { + // Not having an override doesn't mean that there is no material + scale_x = 1; + scale_y = 1; + } + + if (tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR) + { + material_v.mV[s_axis] = scale_x * scale.mV[s_axis]; + material_v.mV[t_axis] = scale_y * scale.mV[t_axis]; + } + else + { + material_v.mV[s_axis] = scale_x / scale.mV[s_axis]; + material_v.mV[t_axis] = scale_y / scale.mV[t_axis]; + } + material_v_vec.push_back(material_v); + } + mGLTFScaleRatios.push_back(material_v_vec); } } } @@ -7187,6 +7267,12 @@ void dialog_refresh_all() { panel_task_info->dirty(); } + + LLFloaterGLTFAssetEditor * gltf_editor = LLFloaterReg::findTypedInstance<LLFloaterGLTFAssetEditor>("gltf_asset_editor"); + if (gltf_editor) + { + gltf_editor->dirty(); + } } S32 get_family_count(LLViewerObject *parent) |