From c9fbd9e2e820ce4d5e62468f757ee0502fa93af1 Mon Sep 17 00:00:00 2001 From: Brad Kittenbrink Date: Wed, 27 Apr 2022 14:48:25 -0700 Subject: SL-17116 work on implementing MaterialID in ExtraParams of ObjectUpdate and related messages --- indra/llprimitive/CMakeLists.txt | 1 + indra/llprimitive/llmaterial.h | 4 -- indra/llprimitive/llprimitive.cpp | 69 ++++++++++++++++++++++++ indra/llprimitive/llprimitive.h | 20 +++++++ indra/llprimitive/tests/llmessagesystem_stub.cpp | 2 +- indra/llprimitive/tests/llprimitive_test.cpp | 40 ++++++++++++++ indra/newview/llviewerobject.cpp | 5 ++ 7 files changed, 136 insertions(+), 5 deletions(-) diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index 7b6d04b096..fff4d8ef0a 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -90,6 +90,7 @@ if (LL_TESTS) INCLUDE(LLAddBuildTest) SET(llprimitive_TEST_SOURCE_FILES llmediaentry.cpp + llprimitive.cpp ) LL_ADD_PROJECT_UNIT_TESTS(llprimitive "${llprimitive_TEST_SOURCE_FILES}") endif (LL_TESTS) diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h index d58b7ee812..1e068c2be3 100644 --- a/indra/llprimitive/llmaterial.h +++ b/indra/llprimitive/llmaterial.h @@ -27,8 +27,6 @@ #ifndef LL_LLMATERIAL_H #define LL_LLMATERIAL_H -#include - #include "llmaterialid.h" #include "llsd.h" #include "v4coloru.h" @@ -54,8 +52,6 @@ public: ALPHA_SHADER_COUNT = 4 } eShaderCount; - - static const U8 DEFAULT_SPECULAR_LIGHT_EXPONENT = ((U8)(0.2f * 255)); static const LLColor4U DEFAULT_SPECULAR_LIGHT_COLOR; static const U8 DEFAULT_ENV_INTENSITY = 0; diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 67c225d25d..c46e5fb3c5 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -39,6 +39,7 @@ #include "llsdutil_math.h" #include "llprimtexturelist.h" #include "llmaterialid.h" +#include "llsdutil.h" /** * exported constants @@ -1690,6 +1691,8 @@ BOOL LLNetworkData::isValid(U16 param_type, U32 size) return (size == 28); case PARAMS_EXTENDED_MESH: return (size == 4); + case PARAMS_RENDER_MATERIAL: + return (size == 16); } return FALSE; @@ -2181,3 +2184,69 @@ bool LLExtendedMeshParams::fromLLSD(LLSD& sd) return false; } + +//============================================================================ + +LLRenderMaterialParams::LLRenderMaterialParams() +{ + mType = PARAMS_RENDER_MATERIAL; +} + +BOOL LLRenderMaterialParams::pack(LLDataPacker &dp) const +{ + return dp.packUUID(mMaterial, "material"); + +// return TRUE; +} + +BOOL LLRenderMaterialParams::unpack(LLDataPacker &dp) +{ + return dp.unpackUUID(mMaterial, "material"); + +// return TRUE; +} + +bool LLRenderMaterialParams::operator==(const LLNetworkData& data) const +{ + if (data.mType != PARAMS_RENDER_MATERIAL) + { + return false; + } + + const LLRenderMaterialParams ¶m = static_cast(data); + + return param.mMaterial == mMaterial; +} + +void LLRenderMaterialParams::copy(const LLNetworkData& data) +{ + llassert_always(data.mType == PARAMS_RENDER_MATERIAL); + const LLRenderMaterialParams ¶m = static_cast(data); + mMaterial = param.mMaterial; +} + +LLSD LLRenderMaterialParams::asLLSD() const +{ + return llsd::map("material", mMaterial); +} + +bool LLRenderMaterialParams::fromLLSD(LLSD& sd) +{ + if (sd.has("material")) + { + setMaterial(sd["material"]); + return true; + } + + return false; +} + +void LLRenderMaterialParams::setMaterial(const LLUUID & id) +{ + mMaterial = id; +} + +LLUUID LLRenderMaterialParams::getMaterial() const +{ + return mMaterial; +} diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 309b18faa9..e23ddd2916 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -107,6 +107,7 @@ public: PARAMS_RESERVED = 0x50, // Used on server-side PARAMS_MESH = 0x60, PARAMS_EXTENDED_MESH = 0x70, + PARAMS_RENDER_MATERIAL = 0x80, }; public: @@ -320,6 +321,25 @@ public: }; +class LLRenderMaterialParams : public LLNetworkData +{ +private: + LLUUID mMaterial; + +public: + LLRenderMaterialParams(); + BOOL pack(LLDataPacker &dp) const override; + BOOL unpack(LLDataPacker &dp) override; + bool operator==(const LLNetworkData& data) const override; + void copy(const LLNetworkData& data) override; + LLSD asLLSD() const; + operator LLSD() const { return asLLSD(); } + bool fromLLSD(LLSD& sd); + + void setMaterial(const LLUUID & id); + LLUUID getMaterial() const; +}; + // This code is not naming-standards compliant. Leaving it like this for // now to make the connection to code in // BOOL packTEMessage(LLDataPacker &dp) const; diff --git a/indra/llprimitive/tests/llmessagesystem_stub.cpp b/indra/llprimitive/tests/llmessagesystem_stub.cpp index 04e70945c4..9006833054 100644 --- a/indra/llprimitive/tests/llmessagesystem_stub.cpp +++ b/indra/llprimitive/tests/llmessagesystem_stub.cpp @@ -25,7 +25,7 @@ #include "linden_common.h" -char * _PREHASH_TextureEntry; +const char * const _PREHASH_TextureEntry = "TextureEntry"; S32 LLMessageSystem::getSizeFast(char const*, char const*) const { diff --git a/indra/llprimitive/tests/llprimitive_test.cpp b/indra/llprimitive/tests/llprimitive_test.cpp index 0d60c7cd15..0ff0795fdc 100644 --- a/indra/llprimitive/tests/llprimitive_test.cpp +++ b/indra/llprimitive/tests/llprimitive_test.cpp @@ -71,6 +71,46 @@ private: S32 mCurrDetailTest; }; +LLMaterialID::LLMaterialID() {} +LLMaterialID::LLMaterialID(LLMaterialID const &m) = default; +LLMaterialID::~LLMaterialID() {} +void LLMaterialID::set(void const*) { } +U8 const * LLMaterialID::get() const { return mID; } + +LLPrimTextureList::LLPrimTextureList() { } +LLPrimTextureList::~LLPrimTextureList() { } +S32 LLPrimTextureList::setBumpMap(const U8 index, const U8 bump) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setOffsetS(const U8 index, const F32 s) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setOffsetT(const U8 index, const F32 t) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::copyTexture(const U8 index, const LLTextureEntry &te) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setRotation(const U8 index, const F32 r) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setBumpShiny(const U8 index, const U8 bump_shiny) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setFullbright(const U8 index, const U8 t) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setMaterialID(const U8 index, const LLMaterialID& pMaterialID) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setMediaFlags(const U8 index, const U8 media_flags) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setMediaTexGen(const U8 index, const U8 media) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setMaterialParams(const U8 index, const LLMaterialPtr pMaterialParams) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setBumpShinyFullbright(const U8 index, const U8 bump) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setID(const U8 index, const LLUUID& id) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setGlow(const U8 index, const F32 glow) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setAlpha(const U8 index, const F32 alpha) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setColor(const U8 index, const LLColor3& color) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setColor(const U8 index, const LLColor4& color) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setScale(const U8 index, const F32 s, const F32 t) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setScaleS(const U8 index, const F32 s) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setScaleT(const U8 index, const F32 t) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setShiny(const U8 index, const U8 shiny) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setOffset(const U8 index, const F32 s, const F32 t) { return TEM_CHANGE_NONE; } +S32 LLPrimTextureList::setTexGen(const U8 index, const U8 texgen) { return TEM_CHANGE_NONE; } + +LLMaterialPtr LLPrimTextureList::getMaterialParams(const U8 index) { return LLMaterialPtr(); } +void LLPrimTextureList::copy(LLPrimTextureList const & ptl) { mEntryList = ptl.mEntryList; } // do we need to call getTexture()->newCopy()? +void LLPrimTextureList::take(LLPrimTextureList &other_list) { } +void LLPrimTextureList::setSize(S32 new_size) { mEntryList.resize(new_size); } +void LLPrimTextureList::setAllIDs(const LLUUID &id) { } +LLTextureEntry * LLPrimTextureList::getTexture(const U8 index) const { return nullptr; } +S32 LLPrimTextureList::size() const { return mEntryList.size(); } + class PRIMITIVE_TEST_SETUP { public: diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 4c476e89ce..4b1edc8288 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -6005,6 +6005,11 @@ LLViewerObject::ExtraParameter* LLViewerObject::createNewParameterEntry(U16 para { new_block = new LLExtendedMeshParams(); break; + } + case LLNetworkData::PARAMS_RENDER_MATERIAL: + { + new_block = new LLRenderMaterialParams(); + break; } default: { -- cgit v1.2.3 From 3f43553ea096ce27da11ff797708ef7d6a391389 Mon Sep 17 00:00:00 2001 From: Brad Kittenbrink Date: Wed, 27 Apr 2022 14:55:06 -0700 Subject: Test UI for SL-17116. provide a debug interface to set a MaterialID for a face --- indra/newview/llpanelface.cpp | 11 ++++++++++- indra/newview/llpanelface.h | 1 + indra/newview/skins/default/xui/en/floater_tools.xml | 4 ++-- .../skins/default/xui/en/panel_tools_texture.xml | 17 +++++++++++++++-- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 71657239a6..094add423f 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -154,6 +154,7 @@ BOOL LLPanelFace::postBuild() childSetCommitCallback("glossiness",&LLPanelFace::onCommitMaterialGloss, this); childSetCommitCallback("environment",&LLPanelFace::onCommitMaterialEnv, this); childSetCommitCallback("maskcutoff",&LLPanelFace::onCommitMaterialMaskCutoff, this); + childSetCommitCallback("materialID", &LLPanelFace::onCommitMaterialID, this); childSetAction("button align",&LLPanelFace::onClickAutoFix,this); childSetAction("button align textures", &LLPanelFace::onAlignTexture, this); @@ -298,7 +299,7 @@ BOOL LLPanelFace::postBuild() { mCtrlGlow->setCommitCallback(LLPanelFace::onCommitGlow, this); } - + clearCtrls(); @@ -1518,6 +1519,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) calcp->setVar(LLCalc::TEX_ROTATION, childGetValue("TexRot").asReal()); calcp->setVar(LLCalc::TEX_TRANSPARENCY, childGetValue("ColorTrans").asReal()); calcp->setVar(LLCalc::TEX_GLOW, childGetValue("glow").asReal()); + + getChildView("materialID")->setEnabled(editable); } else { @@ -2302,6 +2305,12 @@ void LLPanelFace::onCommitMaterialMaskCutoff(LLUICtrl* ctrl, void* userdata) LLSelectedTEMaterial::setAlphaMaskCutoff(self,self->getCurrentAlphaMaskCutoff()); } +//static +void LLPanelFace::onCommitMaterialID(LLUICtrl* ctrl, void* userdata) +{ + LLPanelFace* self [[maybe_unused]] = (LLPanelFace*) userdata; +} + // static void LLPanelFace::onCommitTextureInfo( LLUICtrl* ctrl, void* userdata ) { diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 2d57d89a44..f7fa70a144 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -191,6 +191,7 @@ protected: static void onCommitMaterialGloss( LLUICtrl* ctrl, void* userdata); static void onCommitMaterialEnv( LLUICtrl* ctrl, void* userdata); static void onCommitMaterialMaskCutoff( LLUICtrl* ctrl, void* userdata); + static void onCommitMaterialID( LLUICtrl* ctrl, void* userdata); static void onCommitMaterialsMedia( LLUICtrl* ctrl, void* userdata); static void onCommitMaterialType( LLUICtrl* ctrl, void* userdata); diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index 0abee2ff80..44bdcd86f9 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -2,7 +2,7 @@