diff options
| -rw-r--r-- | autobuild.xml | 32 | ||||
| -rw-r--r-- | indra/newview/llgltfmateriallist.cpp | 28 | ||||
| -rw-r--r-- | indra/newview/llgltfmateriallist.h | 2 | ||||
| -rw-r--r-- | indra/newview/llmaterialeditor.cpp | 54 | ||||
| -rw-r--r-- | indra/newview/llmaterialeditor.h | 7 | ||||
| -rw-r--r-- | indra/newview/llpanelface.cpp | 33 | ||||
| -rw-r--r-- | indra/newview/llpanelface.h | 1 | ||||
| -rw-r--r-- | indra/newview/llstartup.cpp | 4 | ||||
| -rw-r--r-- | indra/newview/llviewerregion.cpp | 1 | 
9 files changed, 133 insertions, 29 deletions
| diff --git a/autobuild.xml b/autobuild.xml index 4abdd41528..64e1b87d16 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -2528,41 +2528,17 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>          <string>tinygltf</string>          <key>platforms</key>          <map> -          <key>darwin64</key> -          <map> -            <key>archive</key> -            <map> -              <key>hash</key> -              <string>7fd9a99cea31809c89759905fbba30c9</string> -              <key>url</key> -              <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/100928/888701/tinygltf-v2.5.0-windows64-572493.tar.bz2</string> -            </map> -            <key>name</key> -            <string>darwin64</string> -          </map> -          <key>windows</key> -          <map> -            <key>archive</key> -            <map> -              <key>hash</key> -              <string>7fd9a99cea31809c89759905fbba30c9</string> -              <key>url</key> -              <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/100928/888701/tinygltf-v2.5.0-windows64-572493.tar.bz2</string> -            </map> -            <key>name</key> -            <string>windows</string> -          </map> -          <key>windows64</key> +          <key>common</key>            <map>              <key>archive</key>              <map>                <key>hash</key> -              <string>7fd9a99cea31809c89759905fbba30c9</string> +              <string>4dad1c0948141e1667c01a3ee755e4dc</string>                <key>url</key> -              <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/100928/888701/tinygltf-v2.5.0-windows64-572493.tar.bz2</string> +              <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/105849/926137/tinygltf-v2.5.0-common-575729.tar.bz2</string>              </map>              <key>name</key> -            <string>windows64</string> +            <string>common</string>            </map>          </map>          <key>source</key> diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index a5d2be2d4e..24fd623231 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -28,13 +28,36 @@  #include "llgltfmateriallist.h"  #include "llassetstorage.h" +#include "lldispatcher.h"  #include "llfilesystem.h"  #include "llsdserialize.h"  #include "lltinygltfhelper.h" +#include "llviewergenericmessage.h"  #include "tinygltf/tiny_gltf.h"  #include <strstream> +namespace +{ +    class LLGLTFOverrideDispatchHandler : public LLDispatchHandler +    { +    public: +        LLGLTFOverrideDispatchHandler() = default; +        ~LLGLTFOverrideDispatchHandler() override = default; + +        bool operator()(const LLDispatcher* dispatcher, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override +        { +            LL_DEBUGS() << "strings: "; +            for (std::string const & s : strings) { +                LL_CONT << " " << s; +            } +            LL_CONT << LL_ENDL; +            return true; +        } +    }; +    LLGLTFOverrideDispatchHandler handle_gltf_override_message; +} +  LLGLTFMaterialList gGLTFMaterialList;  LLGLTFMaterial* LLGLTFMaterialList::getMaterial(const LLUUID& id) @@ -119,3 +142,8 @@ void LLGLTFMaterialList::removeMaterial(const LLUUID& id)      mList.erase(id);  } +// static +void LLGLTFMaterialList::registerCallbacks() +{ +    gGenericDispatcher.addHandler("GLTF", &handle_gltf_override_message); +} diff --git a/indra/newview/llgltfmateriallist.h b/indra/newview/llgltfmateriallist.h index 49760504e6..4aed4b009d 100644 --- a/indra/newview/llgltfmateriallist.h +++ b/indra/newview/llgltfmateriallist.h @@ -44,6 +44,8 @@ public:      void addMaterial(const LLUUID& id, LLGLTFMaterial* material);      void removeMaterial(const LLUUID& id); +    static void registerCallbacks(); +  };  extern LLGLTFMaterialList gGLTFMaterialList; diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 4a75426265..c23f9ec4e7 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -200,6 +200,8 @@ LLMaterialEditor::LLMaterialEditor(const LLSD& key)      , mHasUnsavedChanges(false)      , mExpectedUploadCost(0)      , mUploadingTexturesCount(0) +    , mOverrideLocalId(0) +    , mOverrideFace(0)  {      const LLInventoryItem* item = getItem();      if (item) @@ -1832,6 +1834,7 @@ private:  void LLMaterialEditor::applyToSelection()  { +#if 0 // local preview placeholder hack      // Placehodler. Will be removed once override systems gets finished.      LLPointer<LLGLTFMaterial> mat = new LLGLTFMaterial();      getGLTFMaterial(mat); @@ -1839,7 +1842,19 @@ void LLMaterialEditor::applyToSelection()      gGLTFMaterialList.addMaterial(placeholder, mat);      LLRemderMaterialFunctor mat_func(placeholder);      LLObjectSelectionHandle selected_objects = LLSelectMgr::getInstance()->getSelection(); -    selected_objects->applyToTEs(&mat_func); +    //selected_objects->applyToTEs(&mat_func); +#else  +    std::string url = gAgent.getRegionCapability("ModifyMaterialParams"); +    if (!url.empty()) +    { +        LLSDMap overrides; +        LLCoros::instance().launch("modifyMaterialCoro", std::bind(&LLMaterialEditor::modifyMaterialCoro, this, url, overrides)); +    } +    else +    { +        LL_WARNS() << "not connected to materials capable region, missing ModifyMaterialParams cap" << LL_ENDL; +    } +#endif  }  void LLMaterialEditor::getGLTFMaterial(LLGLTFMaterial* mat) @@ -2232,3 +2247,40 @@ void LLMaterialEditor::loadDefaults()      model_in.materials.resize(1);      setFromGltfModel(model_in, 0, true);  } + +void LLMaterialEditor::modifyMaterialCoro(std::string cap_url, LLSD overrides) +{ +    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); +    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t +        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("modifyMaterialCoro", httpPolicy)); +    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); +    LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); +    LLCore::HttpHeaders::ptr_t httpHeaders; + +    httpOpts->setFollowRedirects(true); +    LLSD body = llsd::map( +        "local_id", S32(mOverrideLocalId), +        "face", mOverrideFace, +        "overrides", overrides +    ); + +    LLSD result = httpAdapter->postAndSuspend(httpRequest, cap_url, body, httpOpts, httpHeaders); + +    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; +    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + +    if (!status) +    { +        LL_WARNS() << "Failed to modify material." << LL_ENDL; +    } +    else if (!result["success"].asBoolean()) +    { +        LL_WARNS() << "Failed to modify material: " << result["message"] << LL_ENDL; +    } +} + +void LLMaterialEditor::setOverrideTarget(U32 local_id, S32 face) +{ +    mOverrideLocalId = local_id; +    mOverrideFace = face; +} diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index d329222648..96bf8cc7a2 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -215,6 +215,10 @@ public:      // initialize the UI from a default GLTF material      void loadDefaults(); + +    void modifyMaterialCoro(std::string cap_url, LLSD overrides); +    void setOverrideTarget(U32 local_id, S32 face_id); +  private:      void loadMaterial(const tinygltf::Model &model, const std::string &filename_lc, S32 index); @@ -264,5 +268,8 @@ private:      S32 mExpectedUploadCost;      std::string mMaterialNameShort;      std::string mMaterialName; + +    U32 mOverrideLocalId; +    S32 mOverrideFace;  }; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index aaee64485a..f93a0e7142 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -46,6 +46,7 @@  #include "llcombobox.h"  #include "lldrawpoolbump.h"  #include "llface.h" +#include "llgltfmateriallist.h"  #include "llinventoryfunctions.h"  #include "llinventorymodel.h" // gInventory  #include "llinventorymodelbackgroundfetch.h" @@ -53,6 +54,7 @@  #include "llfloaterreg.h"  #include "lllineeditor.h"  #include "llmaterialmgr.h" +#include "llmaterialeditor.h"  #include "llmediactrl.h"  #include "llmediaentry.h"  #include "llmenubutton.h" @@ -91,6 +93,7 @@  #include "llsdserialize.h"  #include "llinventorymodel.h" +using namespace std::literals;  //  // Constant definitions for comboboxes @@ -234,6 +237,9 @@ BOOL	LLPanelFace::postBuild()          pbr_ctrl->setDnDFilterPermMask(PERM_COPY | PERM_TRANSFER);          pbr_ctrl->setBakeTextureEnabled(false);          pbr_ctrl->setInventoryPickType(LLTextureCtrl::PICK_MATERIAL); + +        // TODO - design real UI for activating live editing +        pbr_ctrl->setRightMouseUpCallback(boost::bind(&LLPanelFace::onPbrStartEditing, this));      }  	mTextureCtrl = getChild<LLTextureCtrl>("texture control"); @@ -4574,6 +4580,33 @@ void LLPanelFace::onPbrSelectionChanged(LLInventoryItem* itemp)      }  } +void LLPanelFace::onPbrStartEditing() { +    LL_DEBUGS() << "begin live editing material" << LL_ENDL; + +    LLMaterialEditor *editor = +        dynamic_cast<LLMaterialEditor *>(LLFloaterReg::showInstance("material_editor", LLSD(LLUUID::null), TAKE_FOCUS_YES)); +    if (editor) +    { +        LLObjectSelection *select = LLSelectMgr::getInstance()->getSelection(); +        LLViewerObject * objectp = select->getFirstObject(); +        LLUUID object_id = objectp->getID(); + +        bool   identical; +        LLUUID material_id; +        LLSelectedTE::getPbrMaterialId(material_id, identical); + +        S32 face = 0; + +        LL_DEBUGS() << "loading material live editor with asset " << material_id << " on object " << object_id << LL_ENDL; + +        LLGLTFMaterial* material = gGLTFMaterialList.getMaterial(material_id); +        editor->setTitle("Editing material on "s + object_id.asString()); +        editor->setAssetId(material_id); +        editor->setFromGLTFMaterial(material); +        editor->setOverrideTarget(objectp->getLocalID(), face); +    } +} +  bool LLPanelFace::isIdenticalPlanarTexgen()  {  	LLTextureEntry::e_texgen selected_texgen = LLTextureEntry::TEX_GEN_DEFAULT; diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 725cfb0f5f..cc46116545 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -438,6 +438,7 @@ private:  	 */      void onTextureSelectionChanged(LLInventoryItem* itemp);      void onPbrSelectionChanged(LLInventoryItem* itemp); +    void onPbrStartEditing();      LLMenuButton*   mMenuClipboardColor;      LLMenuButton*   mMenuClipboardTexture; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 6aca701fe2..64dd3af223 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -60,6 +60,7 @@  #include "llfloatergridstatus.h"  #include "llfloaterimsession.h"  #include "lllocationhistory.h" +#include "llgltfmateriallist.h"  #include "llimageworker.h"  #include "llloginflags.h" @@ -1473,6 +1474,9 @@ bool idle_startup()  		gXferManager->registerCallbacks(gMessageSystem);  		display_startup(); +		LLGLTFMaterialList::registerCallbacks(); +		display_startup(); +  		LLStartUp::initNameCache();  		display_startup(); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 3167d1161c..31752a5a8b 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -3082,6 +3082,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames)  	capabilityNames.append("MapLayer");  	capabilityNames.append("MapLayerGod");  	capabilityNames.append("MeshUploadFlag");	 +	capabilityNames.append("ModifyMaterialParams");  	capabilityNames.append("NavMeshGenerationStatus");  	capabilityNames.append("NewFileAgentInventory");  	capabilityNames.append("ObjectAnimation"); | 
