From 5fddc374566a0111375df2191b9c38cd8752881e Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 5 Feb 2020 21:06:35 +0200 Subject: [PATCH 1/8] SL-12673 Make mesh uploader fit into 980px --- .../default/xui/en/floater_model_preview.xml | 152 +++++++++--------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/indra/newview/skins/default/xui/en/floater_model_preview.xml b/indra/newview/skins/default/xui/en/floater_model_preview.xml index b675a3e3be..bd8b764fde 100644 --- a/indra/newview/skins/default/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml @@ -6,8 +6,8 @@ can_resize="true" height="600" min_height="600" - width="1024" - min_width="1024" + width="980" + min_width="980" name="Model Preview" title="UPLOAD MODEL" help_topic="upload_model" > @@ -1656,121 +1656,121 @@ Analysed: width="462" visible="false"> You dont have rights to upload mesh models. [[VURL] Find out how] to get certified. - + [STATUS] + + + Preview: + + - + - Preview: - - + High + Medium + Low + Lowest + + - - High - Medium - Low - Lowest - - - - - - - + Display... + + + top_pad="8"> + + layout="topleft" + name="show_physics" + top_pad="8"> + + top_pad="8"> + + top_pad="8"> + + top_pad="8"> + Preview Spread: + width="150"/> From f851ce08d27c983423176e3508cebd9ac9f9cdd4 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 6 Feb 2020 20:00:21 +0200 Subject: [PATCH 2/8] SL-548 Add control for joint positions in model upload preview --- indra/newview/llfloatermodelpreview.cpp | 56 +++++++++++++++++-- .../default/xui/en/floater_model_preview.xml | 12 +++- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 2a8638e340..b846853755 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -337,6 +337,7 @@ BOOL LLFloaterModelPreview::postBuild() getChild("show_physics")->setCommitCallback(boost::bind(&LLFloaterModelPreview::onViewOptionChecked, this, _1)); getChild("show_textures")->setCommitCallback(boost::bind(&LLFloaterModelPreview::onViewOptionChecked, this, _1)); getChild("show_skin_weight")->setCommitCallback(boost::bind(&LLFloaterModelPreview::onShowSkinWeightChecked, this, _1)); + getChild("show_joint_overrides")->setCommitCallback(boost::bind(&LLFloaterModelPreview::onViewOptionChecked, this, _1)); getChild("show_joint_positions")->setCommitCallback(boost::bind(&LLFloaterModelPreview::onViewOptionChecked, this, _1)); childDisable("upload_skin"); @@ -2295,7 +2296,7 @@ void LLModelPreview::loadModelCallback(S32 loaded_lod) mBaseScene.clear(); bool skin_weights = false; - bool joint_positions = false; + bool joint_overrides = false; bool lock_scale_if_joint_position = false; for (S32 lod = 0; lod < LLModel::NUM_LODS; ++lod) @@ -2342,7 +2343,7 @@ void LLModelPreview::loadModelCallback(S32 loaded_lod) if (!list_iter->mModel->mSkinInfo.mAlternateBindMatrix.empty()) { - joint_positions = true; + joint_overrides = true; } if (list_iter->mModel->mSkinInfo.mLockScaleIfJointPosition) { @@ -2365,8 +2366,10 @@ void LLModelPreview::loadModelCallback(S32 loaded_lod) fmp->childSetValue("upload_skin", true); } - if (joint_positions) - { + if (joint_overrides) + { + fmp->enableViewOption("show_joint_overrides"); + mViewOption["show_joint_overrides"] = true; fmp->enableViewOption("show_joint_positions"); mViewOption["show_joint_positions"] = true; fmp->childSetValue("upload_joints", true); @@ -3977,6 +3980,7 @@ BOOL LLModelPreview::render() bool use_shaders = LLGLSLShader::sNoFixedFunction; bool edges = mViewOption["show_edges"]; + bool joints = mViewOption["show_joint_overrides"]; bool joint_positions = mViewOption["show_joint_positions"]; bool skin_weight = mViewOption["show_skin_weight"]; bool textures = mViewOption["show_textures"]; @@ -4068,6 +4072,7 @@ BOOL LLModelPreview::render() if (flags == LEGACY_RIG_OK) { fmp->enableViewOption("show_skin_weight"); + fmp->setViewOptionEnabled("show_joint_overrides", skin_weight); fmp->setViewOptionEnabled("show_joint_positions", skin_weight); mFMP->childEnable("upload_skin"); mFMP->childSetValue("show_skin_weight", skin_weight); @@ -4089,6 +4094,7 @@ BOOL LLModelPreview::render() { mViewOption["show_skin_weight"] = false; fmp->disableViewOption("show_skin_weight"); + fmp->disableViewOption("show_joint_overrides"); fmp->disableViewOption("show_joint_positions"); skin_weight = false; @@ -4496,6 +4502,7 @@ BOOL LLModelPreview::render() else { target_pos = getPreviewAvatar()->getPositionAgent(); + bool pelvis_recalc = false; LLViewerCamera::getInstance()->setOriginAndLookAt( target_pos + ((LLVector3(camera_distance, 0.f, 0.f) + offset) * av_rot), // camera @@ -4532,6 +4539,41 @@ BOOL LLModelPreview::render() U32 count = LLSkinningUtil::getMeshJointCount(skin); LLSkinningUtil::initSkinningMatrixPalette((LLMatrix4*)mat, count, skin, getPreviewAvatar()); + getPreviewAvatar()->clearAttachmentOverrides(); + if (joints) + { + LLUUID fake_mesh_id; + fake_mesh_id.generate(); + for (U32 j = 0; j < count; ++j) + { + LLJoint *joint = getPreviewAvatar()->getJoint(skin->mJointNums[j]); + if (joint && skin->mAlternateBindMatrix.size() > 0) + { + const LLVector3& jointPos = skin->mAlternateBindMatrix[j].getTranslation(); + if (joint->aboveJointPosThreshold(jointPos)) + { + bool override_changed; + joint->addAttachmentPosOverride(jointPos, fake_mesh_id, "model", override_changed); + + if (override_changed) + { + //If joint is a pelvis then handle old/new pelvis to foot values + if (joint->getName() == "mPelvis") + { + pelvis_recalc = true; + } + } + if (skin->mLockScaleIfJointPosition) + { + // Note that unlike positions, there's no threshold check here, + // just a lock at the default value. + joint->addAttachmentScaleOverride(joint->getDefaultScale(), fake_mesh_id, "model"); + } + } + } + } + } + LLMatrix4a bind_shape_matrix; bind_shape_matrix.loadu(skin->mBindShapeMatrix); U32 max_joints = LLSkinningUtil::getMaxJointCount(); @@ -4601,6 +4643,11 @@ BOOL LLModelPreview::render() } } + if (pelvis_recalc) + { + // size/scale recalculation + getPreviewAvatar()->postPelvisSetRecalc(); + } } } @@ -4918,6 +4965,7 @@ void LLFloaterModelPreview::populateOverridesTab() { mJointOverrides.clear(); attach_override_data_map_t attach_not_in_use; + // Todo: use mAlternateBindMatrix mModelPreview->getPreviewAvatar()->getAttachmentOverrides(mJointOverrides, attach_not_in_use); if (mJointOverrides.empty()) diff --git a/indra/newview/skins/default/xui/en/floater_model_preview.xml b/indra/newview/skins/default/xui/en/floater_model_preview.xml index bd8b764fde..699ea7b9db 100644 --- a/indra/newview/skins/default/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml @@ -1746,13 +1746,23 @@ Analysed: name="show_skin_weight" top_pad="8"> + + + top_pad="17"> Date: Thu, 6 Feb 2020 20:33:09 +0200 Subject: [PATCH 3/8] SL-12673 Fixed resize --- .../newview/skins/default/xui/en/floater_model_preview.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/indra/newview/skins/default/xui/en/floater_model_preview.xml b/indra/newview/skins/default/xui/en/floater_model_preview.xml index 699ea7b9db..9009eeeb04 100644 --- a/indra/newview/skins/default/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml @@ -1675,16 +1675,17 @@ Analysed: Preview: Date: Fri, 7 Feb 2020 15:41:45 +0200 Subject: [PATCH 4/8] SL-548 Fixed pelvis position and optimized --- indra/newview/llfloatermodelpreview.cpp | 80 +++++++++++++------------ 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index b846853755..82b3fa200c 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -3875,6 +3875,7 @@ void LLModelPreview::loadedCallback( LLModelPreview* pPreview = static_cast< LLModelPreview* >(opaque); if (pPreview && !LLModelPreview::sIgnoreLoadedCallback) { + // Load loader's warnings into floater's log tab const LLSD out = pPreview->mModelLoader->logOut(); LLSD::array_const_iterator iter_out = out.beginArray(); LLSD::array_const_iterator end_out = out.endArray(); @@ -3980,7 +3981,7 @@ BOOL LLModelPreview::render() bool use_shaders = LLGLSLShader::sNoFixedFunction; bool edges = mViewOption["show_edges"]; - bool joints = mViewOption["show_joint_overrides"]; + bool joint_overrides = mViewOption["show_joint_overrides"]; bool joint_positions = mViewOption["show_joint_positions"]; bool skin_weight = mViewOption["show_skin_weight"]; bool textures = mViewOption["show_textures"]; @@ -4502,6 +4503,10 @@ BOOL LLModelPreview::render() else { target_pos = getPreviewAvatar()->getPositionAgent(); + getPreviewAvatar()->clearAttachmentOverrides(); // removes pelvis fixup + LLUUID fake_mesh_id; + fake_mesh_id.generate(); + getPreviewAvatar()->addPelvisFixup(mPelvisZOffset, fake_mesh_id); bool pelvis_recalc = false; LLViewerCamera::getInstance()->setOriginAndLookAt( @@ -4518,6 +4523,43 @@ BOOL LLModelPreview::render() if (!model->mSkinWeights.empty()) { + const LLMeshSkinInfo *skin = &model->mSkinInfo; + U32 count = LLSkinningUtil::getMeshJointCount(skin); + + if (joint_overrides) + { + LLUUID fake_mesh_id; + fake_mesh_id.generate(); + for (U32 j = 0; j < count; ++j) + { + LLJoint *joint = getPreviewAvatar()->getJoint(skin->mJointNums[j]); + if (joint && skin->mAlternateBindMatrix.size() > 0) + { + const LLVector3& jointPos = skin->mAlternateBindMatrix[j].getTranslation(); + if (joint->aboveJointPosThreshold(jointPos)) + { + bool override_changed; + joint->addAttachmentPosOverride(jointPos, fake_mesh_id, "model", override_changed); + + if (override_changed) + { + //If joint is a pelvis then handle old/new pelvis to foot values + if (joint->getName() == "mPelvis") + { + pelvis_recalc = true; + } + } + if (skin->mLockScaleIfJointPosition) + { + // Note that unlike positions, there's no threshold check here, + // just a lock at the default value. + joint->addAttachmentScaleOverride(joint->getDefaultScale(), fake_mesh_id, "model"); + } + } + } + } + } + for (U32 i = 0, e = mVertexBuffer[mPreviewLOD][model].size(); i < e; ++i) { LLVertexBuffer* buffer = mVertexBuffer[mPreviewLOD][model][i]; @@ -4535,44 +4577,8 @@ BOOL LLModelPreview::render() //build matrix palette LLMatrix4a mat[LL_MAX_JOINTS_PER_MESH_OBJECT]; - const LLMeshSkinInfo *skin = &model->mSkinInfo; - U32 count = LLSkinningUtil::getMeshJointCount(skin); LLSkinningUtil::initSkinningMatrixPalette((LLMatrix4*)mat, count, skin, getPreviewAvatar()); - getPreviewAvatar()->clearAttachmentOverrides(); - if (joints) - { - LLUUID fake_mesh_id; - fake_mesh_id.generate(); - for (U32 j = 0; j < count; ++j) - { - LLJoint *joint = getPreviewAvatar()->getJoint(skin->mJointNums[j]); - if (joint && skin->mAlternateBindMatrix.size() > 0) - { - const LLVector3& jointPos = skin->mAlternateBindMatrix[j].getTranslation(); - if (joint->aboveJointPosThreshold(jointPos)) - { - bool override_changed; - joint->addAttachmentPosOverride(jointPos, fake_mesh_id, "model", override_changed); - - if (override_changed) - { - //If joint is a pelvis then handle old/new pelvis to foot values - if (joint->getName() == "mPelvis") - { - pelvis_recalc = true; - } - } - if (skin->mLockScaleIfJointPosition) - { - // Note that unlike positions, there's no threshold check here, - // just a lock at the default value. - joint->addAttachmentScaleOverride(joint->getDefaultScale(), fake_mesh_id, "model"); - } - } - } - } - } LLMatrix4a bind_shape_matrix; bind_shape_matrix.loadu(skin->mBindShapeMatrix); From f249365f23e5ed3509a7f665ead53d4e781ff6d2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 7 Feb 2020 16:59:50 +0200 Subject: [PATCH 5/8] SL-548 Fixed potential case where mJointNums will not be initialized --- indra/newview/llfloatermodelpreview.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 82b3fa200c..4e9e4754b3 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -4524,16 +4524,24 @@ BOOL LLModelPreview::render() if (!model->mSkinWeights.empty()) { const LLMeshSkinInfo *skin = &model->mSkinInfo; + LLSkinningUtil::initJointNums(&model->mSkinInfo, getPreviewAvatar());// inits skin->mJointNums if nessesary U32 count = LLSkinningUtil::getMeshJointCount(skin); - if (joint_overrides) + if (joint_overrides && skin->mAlternateBindMatrix.size() > 0) { + // mesh_id is used to determine which mesh gets to + // set the joint offset, in the event of a conflict. Since + // we don't know the mesh id yet, we can't guarantee that + // joint offsets will be applied with the same priority as + // in the uploaded model. If the file contains multiple + // meshes with conflicting joint offsets, preview may be + // incorrect. LLUUID fake_mesh_id; fake_mesh_id.generate(); for (U32 j = 0; j < count; ++j) { LLJoint *joint = getPreviewAvatar()->getJoint(skin->mJointNums[j]); - if (joint && skin->mAlternateBindMatrix.size() > 0) + if (joint) { const LLVector3& jointPos = skin->mAlternateBindMatrix[j].getTranslation(); if (joint->aboveJointPosThreshold(jointPos)) @@ -4544,7 +4552,7 @@ BOOL LLModelPreview::render() if (override_changed) { //If joint is a pelvis then handle old/new pelvis to foot values - if (joint->getName() == "mPelvis") + if (joint->getName() == "mPelvis")// or skin->mJointNames[j] { pelvis_recalc = true; } From 67b908cd2020231f30386294e4d0c5f199a007a0 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 7 Feb 2020 18:43:31 +0200 Subject: [PATCH 6/8] SL-379 WIP Joint overrides tab --- indra/newview/CMakeLists.txt | 1 - indra/newview/llfloatermodelpreview.cpp | 191 +++++++++++------- indra/newview/llfloatermodelpreview.h | 24 ++- indra/newview/lljointoverridedata.h | 53 ----- indra/newview/llvoavatar.cpp | 50 ----- indra/newview/llvoavatar.h | 26 +-- .../default/xui/en/floater_model_preview.xml | 53 +---- 7 files changed, 156 insertions(+), 242 deletions(-) delete mode 100644 indra/newview/lljointoverridedata.h diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index caa636cc83..cf8f99ed25 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -996,7 +996,6 @@ set(viewer_HEADER_FILES llinventorymodelbackgroundfetch.h llinventoryobserver.h llinventorypanel.h - lljointoverridedata.h lljoystickbutton.h lllandmarkactions.h lllandmarklist.h diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 4e9e4754b3..c791ca8e77 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -568,16 +568,6 @@ void LLFloaterModelPreview::onClickCalculateBtn() bool upload_joint_positions = childGetValue("upload_joints").asBoolean(); bool lock_scale_if_joint_position = childGetValue("lock_scale_if_joint_position").asBoolean(); - if (upload_joint_positions) - { - // Todo: this probably should be enabled when checkbox enables, not on calculate - populateOverridesTab(); - } - else - { - disableOverridesTab(); - } - mUploadModelUrl.clear(); gMeshRepo.uploadModel(mModelPreview->mUploadData, mModelPreview->mPreviewScale, @@ -590,9 +580,9 @@ void LLFloaterModelPreview::onClickCalculateBtn() mUploadBtn->setEnabled(false); } -void populate_list_with_vectors(LLScrollListCtrl *list, const std::set &vector_set, const LLVector3 &active) +void populate_list_with_map(LLScrollListCtrl *list, const std::map &vector_map) { - if (vector_set.empty()) + if (vector_map.empty()) { return; } @@ -602,35 +592,28 @@ void populate_list_with_vectors(LLScrollListCtrl *list, const std::set::const_iterator iter = vector_set.begin(); - std::set::const_iterator end = vector_set.end(); + std::map::const_iterator iter = vector_map.begin(); + std::map::const_iterator end = vector_map.end(); while (iter != end) { LLScrollListItem::Params item_params; item_params.value = LLSD::Integer(count); - cell_params.column = "override"; - if (*iter != active) - { - cell_params.value = ""; - } - else - { - cell_params.value = "active"; //todo: localize - } + cell_params.column = "model_name"; + cell_params.value = iter->first; item_params.columns.add(cell_params); cell_params.column = "axis_x"; - cell_params.value = iter->mV[VX]; + cell_params.value = iter->second.mV[VX]; item_params.columns.add(cell_params); cell_params.column = "axis_y"; - cell_params.value = iter->mV[VY]; + cell_params.value = iter->second.mV[VY]; item_params.columns.add(cell_params); cell_params.column = "axis_z"; - cell_params.value = iter->mV[VZ]; + cell_params.value = iter->second.mV[VZ]; item_params.columns.add(cell_params); @@ -642,12 +625,12 @@ void populate_list_with_vectors(LLScrollListCtrl *list, const std::setmPreviewLOD; LLPanel *panel = mTabContainer->getPanelByName("overrides_panel"); LLScrollListCtrl *joints_list = panel->getChild("joints_list"); LLScrollListCtrl *joints_pos = panel->getChild("pos_overrides_list"); LLScrollListCtrl *joints_scale = panel->getChild("scale_overrides_list"); LLTextBox *joint_pos_descr = panel->getChild("pos_overrides_descr"); - LLTextBox *joint_scale_descr = panel->getChild("scale_overrides_descr"); joints_pos->deleteAllItems(); joints_scale->deleteAllItems(); @@ -656,19 +639,19 @@ void LLFloaterModelPreview::onJointListSelection() if (selected) { std::string label = selected->getValue().asString(); - LLJointOverrideData *data = &mJointOverrides[label]; - populate_list_with_vectors(joints_pos, data->mPosOverrides, data->mActivePosOverride); - populate_list_with_vectors(joints_scale, data->mScaleOverrides, data->mActiveScaleOverride); + LLJointOverrideData &data = mJointOverrides[display_lod][label]; + populate_list_with_map(joints_pos, data.mPosOverrides); + //populate_list_with_vectors(joints_scale, data.mScaleOverrides, data.mActiveScaleOverride); joint_pos_descr->setTextArg("[JOINT]", label); - joint_scale_descr->setTextArg("[JOINT]", label); + //joint_scale_descr->setTextArg("[JOINT]", label); } else { // temporary value (shouldn't happen) std::string label = "mPelvis"; joint_pos_descr->setTextArg("[JOINT]", label); - joint_scale_descr->setTextArg("[JOINT]", label); + //joint_scale_descr->setTextArg("[JOINT]", label); } } @@ -1450,6 +1433,98 @@ void LLFloaterModelPreview::addStringToLog(const std::ostringstream& strm, bool } } + +void LLFloaterModelPreview::clearOverridesTab() +{ + LLPanel *panel = mTabContainer->getPanelByName("overrides_panel"); + LLScrollListCtrl *joints_list = panel->getChild("joints_list"); + joints_list->deleteAllItems(); + + for (U32 i = 0; i < LLModel::NUM_LODS; ++i) + { + mJointOverrides[i].clear(); + } +} + +void LLFloaterModelPreview::showOverridesTab() +{ + S32 display_lod = mModelPreview->mPreviewLOD; + if (mModelPreview->mModel[display_lod].empty()) + { + return; + } + + // Todo: Are overrides identical for all lods? + if (mJointOverrides[display_lod].empty()) + { + // populate list + for (LLModelLoader::scene::iterator iter = mModelPreview->mScene[display_lod].begin(); iter != mModelPreview->mScene[display_lod].end(); ++iter) + { + for (LLModelLoader::model_instance_list::iterator model_iter = iter->second.begin(); model_iter != iter->second.end(); ++model_iter) + { + LLModelInstance& instance = *model_iter; + LLModel* model = instance.mModel; + const LLMeshSkinInfo *skin = &model->mSkinInfo; + if (skin->mAlternateBindMatrix.size() > 0) + { + U32 count = LLSkinningUtil::getMeshJointCount(skin); + for (U32 j = 0; j < count; ++j) + { + const LLVector3& jointPos = skin->mAlternateBindMatrix[j].getTranslation(); + LLJointOverrideData &data = mJointOverrides[display_lod][skin->mJointNames[j]]; + if (data.mPosOverrides.size() > 0 + && (data.mPosOverrides.begin()->second - jointPos).inRange(-F_APPROXIMATELY_ZERO, F_APPROXIMATELY_ZERO)) + { + // File contains multiple meshes with conflicting joint offsets + // preview may be incorrect, upload result might wary (depends onto mesh_id). + data.mHasConflicts = true; + } + data.mPosOverrides[model->getName()] = jointPos; + + } + } + } + } + } + + LLPanel *panel = mTabContainer->getPanelByName("overrides_panel"); + S32 index = mTabContainer->getIndexForPanel(panel); + mTabContainer->enableTabButton(index, true); + + LLScrollListCtrl *joints_list = panel->getChild("joints_list"); + + joint_override_data_map_t::iterator joint_iter = mJointOverrides[display_lod].begin(); + joint_override_data_map_t::iterator joint_end = mJointOverrides[display_lod].end(); + while (joint_iter != joint_end) + { + const std::string& listName = joint_iter->first; + + LLScrollListItem::Params item_params; + item_params.value(listName); + + LLScrollListCell::Params cell_params; + cell_params.font = LLFontGL::getFontSansSerif(); + cell_params.value = listName; + if (joint_iter->second.mHasConflicts) + { + cell_params.color = LLColor4::orange; + } + + item_params.columns.add(cell_params); + + joints_list->addRow(item_params, ADD_BOTTOM); + joint_iter++; + } + joints_list->selectFirstItem(); +} + +void LLFloaterModelPreview::hideOverridesTab() +{ + LLPanel *panel = mTabContainer->getPanelByName("overrides_panel"); + S32 index = mTabContainer->getIndexForPanel(panel); + mTabContainer->enableTabButton(index, false); +} + //----------------------------------------------------------------------------- // addStringToLogTab() //----------------------------------------------------------------------------- @@ -2374,6 +2449,11 @@ void LLModelPreview::loadModelCallback(S32 loaded_lod) mViewOption["show_joint_positions"] = true; fmp->childSetValue("upload_joints", true); } + else + { + fmp->clearOverridesTab(); + fmp->hideOverridesTab(); + } if (lock_scale_if_joint_position) { @@ -4119,11 +4199,19 @@ BOOL LLModelPreview::render() if (upload_skin && upload_joints) { mFMP->childEnable("lock_scale_if_joint_position"); + if (fmp) + { + fmp->showOverridesTab(); + } } else { mFMP->childDisable("lock_scale_if_joint_position"); mFMP->childSetValue("lock_scale_if_joint_position", false); + if (fmp) + { + fmp->hideOverridesTab(); + } } //Only enable joint offsets if it passed the earlier critiquing @@ -4757,6 +4845,7 @@ void LLFloaterModelPreview::onReset(void* user_data) LLFloaterModelPreview* fmp = (LLFloaterModelPreview*) user_data; fmp->childDisable("reset_btn"); fmp->clearLogTab(); + fmp->clearOverridesTab(); LLModelPreview* mp = fmp->mModelPreview; std::string filename = mp->mLODFile[LLModel::LOD_HIGH]; @@ -4975,44 +5064,6 @@ void LLFloaterModelPreview::clearLogTab() mTabContainer->setTabPanelFlashing(panel, false); } -void LLFloaterModelPreview::populateOverridesTab() -{ - mJointOverrides.clear(); - attach_override_data_map_t attach_not_in_use; - // Todo: use mAlternateBindMatrix - mModelPreview->getPreviewAvatar()->getAttachmentOverrides(mJointOverrides, attach_not_in_use); - - if (mJointOverrides.empty()) - { - disableOverridesTab(); - return; - } - - LLPanel *panel = mTabContainer->getPanelByName("overrides_panel"); - S32 index = mTabContainer->getIndexForPanel(panel); - mTabContainer->enableTabButton(index, true); - - LLScrollListCtrl *joints_list = panel->getChild("joints_list"); - joints_list->deleteAllItems(); - - joint_override_data_map_t::iterator joint_iter = mJointOverrides.begin(); - joint_override_data_map_t::iterator joint_end = mJointOverrides.end(); - while (joint_iter != joint_end) - { - const std::string& listName = joint_iter->first; - joints_list->addSimpleElement(listName); - joint_iter++; - } - joints_list->selectFirstItem(); -} - -void LLFloaterModelPreview::disableOverridesTab() -{ - LLPanel *panel = mTabContainer->getPanelByName("overrides_panel"); - S32 index = mTabContainer->getIndexForPanel(panel); - mTabContainer->enableTabButton(index, false); -} - void LLFloaterModelPreview::onModelPhysicsFeeReceived(const LLSD& result, std::string upload_url) { mModelPhysicsFee = result; diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h index 8988dd2565..f53478f31b 100644 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -30,7 +30,6 @@ #include "llfloaternamedesc.h" #include "lldynamictexture.h" -#include "lljointoverridedata.h" #include "llquaternion.h" #include "llmeshrepository.h" #include "llmodel.h" @@ -62,6 +61,16 @@ class LLTabContainer; class LLToggleableMenu; class LLViewerTextEditor; + +class LLJointOverrideData +{ +public: + LLJointOverrideData() : mHasConflicts(false) {}; + std::map mPosOverrides; + bool mHasConflicts; +}; +typedef std::map joint_override_data_map_t; + class LLFloaterModelPreview : public LLFloaterModelUploadBase { public: @@ -95,10 +104,13 @@ public: /*virtual*/ void onClose(bool app_quitting); static void onMouseCaptureLostModelPreview(LLMouseHandler*); - static void setUploadAmount(S32 amount) { sUploadAmount = amount; } - static void addStringToLog(const std::string& message, const LLSD& args, bool flash, S32 lod = -1); + static void setUploadAmount(S32 amount) { sUploadAmount = amount; } + static void addStringToLog(const std::string& message, const LLSD& args, bool flash, S32 lod = -1); static void addStringToLog(const std::string& str, bool flash); - static void addStringToLog(const std::ostringstream& strm, bool flash); + static void addStringToLog(const std::ostringstream& strm, bool flash); + void clearOverridesTab(); + void showOverridesTab(); + void hideOverridesTab(); void setDetails(F32 x, F32 y, F32 z, F32 streaming_cost, F32 physics_cost); void setPreviewLOD(S32 lod); @@ -227,8 +239,6 @@ private: void resetUploadOptions(); void clearLogTab(); - void populateOverridesTab(); - void disableOverridesTab(); void createSmoothComboBox(LLComboBox* combo_box, float min, float max); @@ -237,7 +247,7 @@ private: LLViewerTextEditor* mUploadLogText; LLTabContainer* mTabContainer; - joint_override_data_map_t mJointOverrides; + joint_override_data_map_t mJointOverrides[LLModel::NUM_LODS]; }; class LLMeshFilePicker : public LLFilePickerThread diff --git a/indra/newview/lljointoverridedata.h b/indra/newview/lljointoverridedata.h deleted file mode 100644 index 99baa5f334..0000000000 --- a/indra/newview/lljointoverridedata.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file lljointoverridedata.h - * @brief Declaration of LLJointOverrideData and LLAttachmentOverrideData - * - * $LicenseInfo:firstyear=2020&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2020, 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_JOINTOVERRIDEDATA_H -#define LL_JOINTOVERRIDEDATA_H - -//#include -//#include -//#include - - -struct LLJointOverrideData -{ - std::set mPosOverrides; - LLVector3 mActivePosOverride; - std::set mScaleOverrides; - LLVector3 mActiveScaleOverride; -}; - -struct LLAttachmentOverrideData -{ - std::set mPosOverrides; - LLVector3 mActivePosOverride; -}; - -typedef std::map joint_override_data_map_t; -typedef std::map attach_override_data_map_t; - -#endif // LL_JOINTOVERRIDEDATA_H - diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index dac516d15c..3b51d07f96 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -6375,56 +6375,6 @@ void LLVOAvatar::showAttachmentOverrides(bool verbose) const } } -//----------------------------------------------------------------------------- -// getAttachmentOverrides -//----------------------------------------------------------------------------- -void LLVOAvatar::getAttachmentOverrides(joint_override_data_map_t &joint_overrides, attach_override_data_map_t &attach_overrides) const -{ - LLVector3 pos, scale; - LLUUID mesh_id; - S32 count = 0; - - // Bones - for (avatar_joint_list_t::const_iterator iter = mSkeleton.begin(); - iter != mSkeleton.end(); ++iter) - { - const LLJoint* pJoint = (*iter); - LLJointOverrideData data; - bool joint_override = false; - if (pJoint && pJoint->hasAttachmentPosOverride(pos, mesh_id)) - { - pJoint->getAllAttachmentPosOverrides(count, data.mPosOverrides); - data.mActivePosOverride = pos; - joint_override = true; - } - if (pJoint && pJoint->hasAttachmentScaleOverride(scale, mesh_id)) - { - pJoint->getAllAttachmentScaleOverrides(count, data.mPosOverrides); - data.mActiveScaleOverride = scale; - joint_override = true; - } - if (joint_override) - { - joint_overrides[pJoint->getName()] = data; - } - } - - // Attachment points - for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin(); - iter != mAttachmentPoints.end(); - ++iter) - { - const LLViewerJointAttachment *attachment_pt = (*iter).second; - if (attachment_pt && attachment_pt->hasAttachmentPosOverride(pos, mesh_id)) - { - LLAttachmentOverrideData data; - attachment_pt->getAllAttachmentPosOverrides(count, data.mPosOverrides); - data.mActivePosOverride = pos; - attach_overrides[attachment_pt->getName()] = data; - } - } -} - //----------------------------------------------------------------------------- // removeAttachmentOverridesForObject //----------------------------------------------------------------------------- diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 53a1d48d72..00dccc5d12 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -36,25 +36,23 @@ #include #include "llavatarappearance.h" -#include "llavatarappearancedefines.h" -#include "llavatarrendernotifier.h" -#include "llcontrol.h" -#include "llcharacter.h" #include "llchat.h" #include "lldrawpoolalpha.h" -#include "lldriverparam.h" -#include "lljointoverridedata.h" -#include "llrendertarget.h" -#include "llrigginginfo.h" -#include "lltexglobalcolor.h" +#include "llviewerobject.h" +#include "llcharacter.h" +#include "llcontrol.h" #include "llviewerjointmesh.h" #include "llviewerjointattachment.h" -#include "llviewerobject.h" -#include "llviewerstats.h" +#include "llrendertarget.h" +#include "llavatarappearancedefines.h" +#include "lltexglobalcolor.h" +#include "lldriverparam.h" #include "llviewertexlayer.h" -#include "llvovolume.h" - #include "material_codes.h" // LL_MCODE_END +#include "llrigginginfo.h" +#include "llviewerstats.h" +#include "llvovolume.h" +#include "llavatarrendernotifier.h" extern const LLUUID ANIM_AGENT_BODY_NOISE; extern const LLUUID ANIM_AGENT_BREATHE_ROT; @@ -217,8 +215,6 @@ public: void rebuildAttachmentOverrides(); void updateAttachmentOverrides(); void showAttachmentOverrides(bool verbose = false) const; - void getAttachmentOverrides(joint_override_data_map_t& joint_overrides, - attach_override_data_map_t& attach_overrides) const; void getAttachmentOverrideNames(std::set& pos_names, std::set& scale_names) const; diff --git a/indra/newview/skins/default/xui/en/floater_model_preview.xml b/indra/newview/skins/default/xui/en/floater_model_preview.xml index 9009eeeb04..a69fa8c57c 100644 --- a/indra/newview/skins/default/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml @@ -1304,62 +1304,23 @@ height="100" left_delta="0" top_pad="0" - width="310"> + width="330"> + label="Model" + name="model_name" + relative_width="0.40" /> + relative_width="0.20" /> + relative_width="0.20" /> - - - Scale overrides for joint '[JOINT]': - - - - - - + relative_width="0.20" /> Date: Mon, 10 Feb 2020 18:29:52 +0200 Subject: [PATCH 7/8] SL-379 Joint overrides tab --- indra/llcharacter/lljoint.cpp | 2 +- indra/llcharacter/lljoint.h | 2 + indra/newview/llfloatermodelpreview.cpp | 89 ++++++++++++------- indra/newview/llfloatermodelpreview.h | 7 +- .../default/xui/en/floater_model_preview.xml | 14 ++- 5 files changed, 77 insertions(+), 37 deletions(-) diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index 441ef1a352..bf99db2ce4 100644 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -407,7 +407,7 @@ void showJointScaleOverrides( const LLJoint& joint, const std::string& note, con bool LLJoint::aboveJointPosThreshold(const LLVector3& pos) const { LLVector3 diff = pos - getDefaultPosition(); - const F32 max_joint_pos_offset = 0.0001f; // 0.1 mm + const F32 max_joint_pos_offset = LL_JOINT_TRESHOLD_POS_OFFSET; // 0.1 mm return diff.lengthSquared() > max_joint_pos_offset * max_joint_pos_offset; } diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index 6f69786f53..79d9637f21 100644 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -53,6 +53,8 @@ const U32 LL_FACE_JOINT_NUM = (LL_CHARACTER_MAX_ANIMATED_JOINTS-2); const S32 LL_CHARACTER_MAX_PRIORITY = 7; const F32 LL_MAX_PELVIS_OFFSET = 5.f; +const F32 LL_JOINT_TRESHOLD_POS_OFFSET = 0.0001f; //0.1 mm + class LLVector3OverrideMap { public: diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index c791ca8e77..b30054c818 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -641,17 +641,14 @@ void LLFloaterModelPreview::onJointListSelection() std::string label = selected->getValue().asString(); LLJointOverrideData &data = mJointOverrides[display_lod][label]; populate_list_with_map(joints_pos, data.mPosOverrides); - //populate_list_with_vectors(joints_scale, data.mScaleOverrides, data.mActiveScaleOverride); joint_pos_descr->setTextArg("[JOINT]", label); - //joint_scale_descr->setTextArg("[JOINT]", label); } else { // temporary value (shouldn't happen) std::string label = "mPelvis"; joint_pos_descr->setTextArg("[JOINT]", label); - //joint_scale_descr->setTextArg("[JOINT]", label); } } @@ -1433,7 +1430,6 @@ void LLFloaterModelPreview::addStringToLog(const std::ostringstream& strm, bool } } - void LLFloaterModelPreview::clearOverridesTab() { LLPanel *panel = mTabContainer->getPanelByName("overrides_panel"); @@ -1446,6 +1442,16 @@ void LLFloaterModelPreview::clearOverridesTab() } } +void LLFloaterModelPreview::resetOverridesTab() +{ + clearOverridesTab(); + + for (U32 i = 0; i < LLModel::NUM_LODS; ++i) + { + mJointOverrides[i].clear(); + } +} + void LLFloaterModelPreview::showOverridesTab() { S32 display_lod = mModelPreview->mPreviewLOD; @@ -1453,11 +1459,13 @@ void LLFloaterModelPreview::showOverridesTab() { return; } - - // Todo: Are overrides identical for all lods? + + // Joints will be listed as long as they are listed in mAlternateBindMatrix + // even if they are for some reason identical to defaults. + // Todo: Are overrides always identical for all lods? They normally are, but there might be situations where they aren't. if (mJointOverrides[display_lod].empty()) { - // populate list + // populate map for (LLModelLoader::scene::iterator iter = mModelPreview->mScene[display_lod].begin(); iter != mModelPreview->mScene[display_lod].end(); ++iter) { for (LLModelLoader::model_instance_list::iterator model_iter = iter->second.begin(); model_iter != iter->second.end(); ++model_iter) @@ -1473,10 +1481,11 @@ void LLFloaterModelPreview::showOverridesTab() const LLVector3& jointPos = skin->mAlternateBindMatrix[j].getTranslation(); LLJointOverrideData &data = mJointOverrides[display_lod][skin->mJointNames[j]]; if (data.mPosOverrides.size() > 0 - && (data.mPosOverrides.begin()->second - jointPos).inRange(-F_APPROXIMATELY_ZERO, F_APPROXIMATELY_ZERO)) + && (data.mPosOverrides.begin()->second - jointPos).lengthSquared() > (LL_JOINT_TRESHOLD_POS_OFFSET * LL_JOINT_TRESHOLD_POS_OFFSET)) { // File contains multiple meshes with conflicting joint offsets - // preview may be incorrect, upload result might wary (depends onto mesh_id). + // preview may be incorrect, upload result might wary (depends onto + // mesh_id that hasn't been generated yet). data.mHasConflicts = true; } data.mPosOverrides[model->getName()] = jointPos; @@ -1486,36 +1495,45 @@ void LLFloaterModelPreview::showOverridesTab() } } } - + LLPanel *panel = mTabContainer->getPanelByName("overrides_panel"); S32 index = mTabContainer->getIndexForPanel(panel); mTabContainer->enableTabButton(index, true); - LLScrollListCtrl *joints_list = panel->getChild("joints_list"); - joint_override_data_map_t::iterator joint_iter = mJointOverrides[display_lod].begin(); - joint_override_data_map_t::iterator joint_end = mJointOverrides[display_lod].end(); - while (joint_iter != joint_end) + if (joints_list->isEmpty()) { - const std::string& listName = joint_iter->first; - - LLScrollListItem::Params item_params; - item_params.value(listName); - - LLScrollListCell::Params cell_params; - cell_params.font = LLFontGL::getFontSansSerif(); - cell_params.value = listName; - if (joint_iter->second.mHasConflicts) + // Populate table + S32 conflicts = 0; + joint_override_data_map_t::iterator joint_iter = mJointOverrides[display_lod].begin(); + joint_override_data_map_t::iterator joint_end = mJointOverrides[display_lod].end(); + while (joint_iter != joint_end) { - cell_params.color = LLColor4::orange; + const std::string& listName = joint_iter->first; + + LLScrollListItem::Params item_params; + item_params.value(listName); + + LLScrollListCell::Params cell_params; + cell_params.font = LLFontGL::getFontSansSerif(); + cell_params.value = listName; + if (joint_iter->second.mHasConflicts) + { + cell_params.color = LLColor4::orange; + conflicts++; + } + + item_params.columns.add(cell_params); + + joints_list->addRow(item_params, ADD_BOTTOM); + joint_iter++; } + joints_list->selectFirstItem(); - item_params.columns.add(cell_params); - - joints_list->addRow(item_params, ADD_BOTTOM); - joint_iter++; + LLTextBox *joint_pos_descr = panel->getChild("conflicts_description"); + joint_pos_descr->setTextArg("[CONFLICTS]", llformat("%d", conflicts)); + joint_pos_descr->setTextArg("[JOINTS_COUNT]", llformat("%d", mJointOverrides[display_lod].size())); } - joints_list->selectFirstItem(); } void LLFloaterModelPreview::hideOverridesTab() @@ -2451,7 +2469,7 @@ void LLModelPreview::loadModelCallback(S32 loaded_lod) } else { - fmp->clearOverridesTab(); + fmp->resetOverridesTab(); fmp->hideOverridesTab(); } @@ -4051,6 +4069,8 @@ void LLModelPreview::addEmptyFace( LLModel* pTarget ) //----------------------------------------------------------------------------- // render() //----------------------------------------------------------------------------- +// Todo: we shouldn't be setting all those UI elements on render. +// Note: Render happens each frame with skinned avatars BOOL LLModelPreview::render() { assert_main_thread(); @@ -4824,6 +4844,13 @@ void LLModelPreview::setPreviewLOD(S32 lod) mFMP->childSetColor(lod_triangles_name[i], color); mFMP->childSetColor(lod_vertices_name[i], color); } + + LLFloaterModelPreview* fmp = (LLFloaterModelPreview*)mFMP; + if (fmp) + { + // make preview repopulate tab + fmp->clearOverridesTab(); + } } refresh(); updateStatusMessages(); @@ -4845,7 +4872,7 @@ void LLFloaterModelPreview::onReset(void* user_data) LLFloaterModelPreview* fmp = (LLFloaterModelPreview*) user_data; fmp->childDisable("reset_btn"); fmp->clearLogTab(); - fmp->clearOverridesTab(); + fmp->resetOverridesTab(); LLModelPreview* mp = fmp->mModelPreview; std::string filename = mp->mLODFile[LLModel::LOD_HIGH]; diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h index f53478f31b..2adbfc1e79 100644 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -107,9 +107,10 @@ public: static void setUploadAmount(S32 amount) { sUploadAmount = amount; } static void addStringToLog(const std::string& message, const LLSD& args, bool flash, S32 lod = -1); static void addStringToLog(const std::string& str, bool flash); - static void addStringToLog(const std::ostringstream& strm, bool flash); - void clearOverridesTab(); - void showOverridesTab(); + static void addStringToLog(const std::ostringstream& strm, bool flash); + void clearOverridesTab(); // clears table + void resetOverridesTab(); // clears table and cleans all data + void showOverridesTab(); // populates table and data as nessesary void hideOverridesTab(); void setDetails(F32 x, F32 y, F32 z, F32 streaming_cost, F32 physics_cost); diff --git a/indra/newview/skins/default/xui/en/floater_model_preview.xml b/indra/newview/skins/default/xui/en/floater_model_preview.xml index a69fa8c57c..9ebcb0c09d 100644 --- a/indra/newview/skins/default/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml @@ -1279,10 +1279,20 @@ draw_stripes="false" commit_on_selection_change="true" heading_height="23" - height="253" + height="238" left="6" top_pad="0" - width="150"/> + width="200"/> + + [CONFLICTS] conflicts in [JOINTS_COUNT] joints + Date: Sat, 22 Feb 2020 19:24:13 +0200 Subject: [PATCH 8/8] post-merge buildfix --- indra/newview/llfloatermodelpreview.h | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h index d7fea67e60..c359722431 100644 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -235,6 +235,7 @@ private: void modelUpdated(bool calculate_visible); // Toggles between "Calculate weights & fee" and "Upload" buttons. + void toggleCalculateButton(); void toggleCalculateButton(bool visible); // resets display options of model preview to their defaults.