diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfloatergltfasseteditor.cpp | 108 | ||||
-rw-r--r-- | indra/newview/llfloatergltfasseteditor.h | 8 | ||||
-rw-r--r-- | indra/newview/llselectmgr.cpp | 12 |
3 files changed, 119 insertions, 9 deletions
diff --git a/indra/newview/llfloatergltfasseteditor.cpp b/indra/newview/llfloatergltfasseteditor.cpp index f21b8032d0..c1946e9f96 100644 --- a/indra/newview/llfloatergltfasseteditor.cpp +++ b/indra/newview/llfloatergltfasseteditor.cpp @@ -52,8 +52,6 @@ LLFloaterGLTFAssetEditor::LLFloaterGLTFAssetEditor(const LLSD& key) LLFloaterGLTFAssetEditor::~LLFloaterGLTFAssetEditor() { - gIdleCallbacks.deleteFunction(idle, this); - if (mScroller) { removeChild(mScroller); @@ -120,7 +118,7 @@ void LLFloaterGLTFAssetEditor::initFolderRoot() // Insert that scroller into the panel widgets hierarchy mItemListPanel->addChild(mScroller); - // Create the root model and view for all conversation sessions + // Create the root model LLGLTFFolderItem* base_item = new LLGLTFFolderItem(mGLTFViewModel); LLFolderView::Params p(LLUICtrlFactory::getDefaultParams<LLFolderView>()); @@ -144,15 +142,33 @@ void LLFloaterGLTFAssetEditor::initFolderRoot() mFolderRoot->setOpen(true); mFolderRoot->setSelectCallback([this](const std::deque<LLFolderViewItem*>& items, bool user_action) { onFolderSelectionChanged(items, user_action); }); mScroller->setVisible(true); - - gIdleCallbacks.addFunction(idle, this); } void LLFloaterGLTFAssetEditor::onOpen(const LLSD& key) { + gIdleCallbacks.addFunction(idle, this); loadFromSelection(); } +void LLFloaterGLTFAssetEditor::onClose(bool app_quitting) +{ + gIdleCallbacks.deleteFunction(idle, this); + mAsset = nullptr; + mObject = nullptr; + +} + +void LLFloaterGLTFAssetEditor::clearRoot() +{ + LLFolderViewFolder::folders_t::iterator folders_it = mFolderRoot->getFoldersBegin(); + while (folders_it != mFolderRoot->getFoldersEnd()) + { + (*folders_it)->destroyView(); + folders_it = mFolderRoot->getFoldersBegin(); + } + mNodeToItemMap.clear(); +} + void LLFloaterGLTFAssetEditor::idle(void* user_data) { LLFloaterGLTFAssetEditor* floater = (LLFloaterGLTFAssetEditor*)user_data; @@ -216,6 +232,8 @@ void LLFloaterGLTFAssetEditor::loadFromNode(S32 node_id, LLFolderViewFolder* par view->setVisible(true); view->setOpen(true); + mNodeToItemMap[node_id] = view; + for (S32& node_id : node.mChildren) { loadFromNode(node_id, view); @@ -246,8 +264,12 @@ void LLFloaterGLTFAssetEditor::loadFromNode(S32 node_id, LLFolderViewFolder* par void LLFloaterGLTFAssetEditor::loadFromSelection() { - if (!mFolderRoot || LLSelectMgr::getInstance()->getSelection()->getObjectCount() != 1) + clearRoot(); + + if (LLSelectMgr::getInstance()->getSelection()->getObjectCount() != 1) { + mAsset = nullptr; + mObject = nullptr; return; } @@ -255,14 +277,19 @@ void LLFloaterGLTFAssetEditor::loadFromSelection() LLViewerObject* objectp = node->getObject(); if (!objectp) { + mAsset = nullptr; + mObject = nullptr; return; } - mAsset = objectp->mGLTFAsset; - if (!mAsset) + if (!objectp->mGLTFAsset) { + mAsset = nullptr; + mObject = nullptr; return; } + mAsset = objectp->mGLTFAsset; + mObject = objectp; if (node->mName.empty()) { @@ -289,7 +316,6 @@ void LLFloaterGLTFAssetEditor::loadFromSelection() LLGLTFFolderItem* listener = new LLGLTFFolderItem(i, name, LLGLTFFolderItem::TYPE_SCENE, mGLTFViewModel); - LLFolderViewFolder::Params p; p.name = name; p.root = mFolderRoot; @@ -316,6 +342,50 @@ void LLFloaterGLTFAssetEditor::loadFromSelection() mFolderRoot->update(); } +void LLFloaterGLTFAssetEditor::dirty() +{ + if (!mObject || !mAsset || !mFolderRoot) + { + closeFloater(); + return; + } + + if (LLSelectMgr::getInstance()->getSelection()->getObjectCount() > 1) + { + closeFloater(); + return; + } + + LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(NULL); + if (!node) + { + // not yet updated? + // Todo: Subscribe to deletion in some way + return; + } + + LLViewerObject* objectp = node->getObject(); + if (mObject != objectp || !objectp->mGLTFAsset) + { + closeFloater(); + return; + } + + if (mAsset != objectp->mGLTFAsset) + { + loadFromSelection(); + return; + } + + auto found = mNodeToItemMap.find(node->mSelectedGLTFNode); + if (found != mNodeToItemMap.end()) + { + LLFolderViewItem* itemp = found->second; + itemp->arrangeAndSet(true, false); + loadNodeTransforms(node->mSelectedGLTFNode); + } +} + void LLFloaterGLTFAssetEditor::onFolderSelectionChanged(const std::deque<LLFolderViewItem*>& items, bool user_action) { if (items.empty()) @@ -329,10 +399,30 @@ void LLFloaterGLTFAssetEditor::onFolderSelectionChanged(const std::deque<LLFolde switch (vmi->getType()) { + case LLGLTFFolderItem::TYPE_SCENE: + { + setTransformsEnabled(false); + LLSelectMgr::getInstance()->selectObjectOnly(mObject, SELECT_ALL_TES, -1, -1); + break; + } case LLGLTFFolderItem::TYPE_NODE: { setTransformsEnabled(true); loadNodeTransforms(vmi->getItemId()); + LLSelectMgr::getInstance()->selectObjectOnly(mObject, SELECT_ALL_TES, vmi->getItemId(), 0); + break; + } + case LLGLTFFolderItem::TYPE_MESH: + case LLGLTFFolderItem::TYPE_SKIN: + { + if (item->getParent()) // should be a node + { + LLFolderViewFolder* parent = item->getParentFolder(); + LLGLTFFolderItem* parent_vmi = static_cast<LLGLTFFolderItem*>(parent->getViewModelItem()); + LLSelectMgr::getInstance()->selectObjectOnly(mObject, SELECT_ALL_TES, parent_vmi->getItemId(), 0); + } + + setTransformsEnabled(false); break; } default: diff --git a/indra/newview/llfloatergltfasseteditor.h b/indra/newview/llfloatergltfasseteditor.h index e35ed30ed0..b0ba8941b9 100644 --- a/indra/newview/llfloatergltfasseteditor.h +++ b/indra/newview/llfloatergltfasseteditor.h @@ -42,6 +42,7 @@ namespace LL class LLSpinCtrl; class LLMenuButton; +class LLViewerObject; class LLFloaterGLTFAssetEditor : public LLFloater { @@ -51,6 +52,7 @@ public: bool postBuild() override; void onOpen(const LLSD& key) override; + void onClose(bool app_quitting) override; void initFolderRoot(); LLGLTFViewModel& getRootViewModel() { return mGLTFViewModel; } @@ -60,6 +62,8 @@ public: void loadFromNode(S32 node, LLFolderViewFolder* parent); void loadFromSelection(); + void dirty(); + protected: void onFolderSelectionChanged(const std::deque<LLFolderViewItem*>& items, bool user_action); void onCommitTransform(); @@ -69,8 +73,11 @@ protected: void setTransformsEnabled(bool val); void loadNodeTransforms(S32 id); + void clearRoot(); + private: + LLPointer<LLViewerObject> mObject; std::shared_ptr<LL::GLTF::Asset> mAsset; // Folder view related @@ -79,6 +86,7 @@ private: LLPanel* mItemListPanel = nullptr; LLFolderView* mFolderRoot = nullptr; LLScrollContainer* mScroller = nullptr; + std::map<S32, LLFolderViewItem*> mNodeToItemMap; // Transforms panel LLVector3 mLastEulerDegrees; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index b3420f9c57..17f968b921 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; } @@ -7187,6 +7193,12 @@ void dialog_refresh_all() { panel_task_info->dirty(); } + + LLFloaterGLTFAssetEditor * gltf_editor = LLFloaterReg::getTypedInstance<LLFloaterGLTFAssetEditor>("gltf_asset_editor"); + if (gltf_editor) + { + gltf_editor->dirty(); + } } S32 get_family_count(LLViewerObject *parent) |