diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2020-02-07 18:43:31 +0200 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2020-02-07 21:17:34 +0200 |
commit | 67b908cd2020231f30386294e4d0c5f199a007a0 (patch) | |
tree | a8f8209b0eae50a3d8e125fb446a7741e402cf0e /indra/newview/llfloatermodelpreview.cpp | |
parent | f249365f23e5ed3509a7f665ead53d4e781ff6d2 (diff) |
SL-379 WIP Joint overrides tab
Diffstat (limited to 'indra/newview/llfloatermodelpreview.cpp')
-rw-r--r-- | indra/newview/llfloatermodelpreview.cpp | 191 |
1 files changed, 121 insertions, 70 deletions
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<LLVector3> &vector_set, const LLVector3 &active) +void populate_list_with_map(LLScrollListCtrl *list, const std::map<std::string, LLVector3> &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<LLVector3 // Start out right justifying numeric displays cell_params.font_halign = LLFontGL::HCENTER; - std::set<LLVector3>::const_iterator iter = vector_set.begin(); - std::set<LLVector3>::const_iterator end = vector_set.end(); + std::map<std::string, LLVector3>::const_iterator iter = vector_map.begin(); + std::map<std::string, LLVector3>::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::set<LLVector3 void LLFloaterModelPreview::onJointListSelection() { + S32 display_lod = mModelPreview->mPreviewLOD; LLPanel *panel = mTabContainer->getPanelByName("overrides_panel"); LLScrollListCtrl *joints_list = panel->getChild<LLScrollListCtrl>("joints_list"); LLScrollListCtrl *joints_pos = panel->getChild<LLScrollListCtrl>("pos_overrides_list"); LLScrollListCtrl *joints_scale = panel->getChild<LLScrollListCtrl>("scale_overrides_list"); LLTextBox *joint_pos_descr = panel->getChild<LLTextBox>("pos_overrides_descr"); - LLTextBox *joint_scale_descr = panel->getChild<LLTextBox>("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<LLScrollListCtrl>("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<LLScrollListCtrl>("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<LLScrollListCtrl>("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; |