diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llprimitive/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/llprimitive/llmaterial.cpp | 155 | ||||
-rw-r--r-- | indra/llprimitive/llmaterial.h | 101 | ||||
-rwxr-xr-x | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llfloaterdebugmaterials.cpp | 1344 | ||||
-rw-r--r-- | indra/newview/llfloaterdebugmaterials.h | 60 | ||||
-rw-r--r-- | indra/newview/llmaterialmgr.cpp | 634 | ||||
-rw-r--r-- | indra/newview/llmaterialmgr.h | 93 | ||||
-rw-r--r-- | indra/newview/llworld.cpp | 22 | ||||
-rw-r--r-- | indra/newview/llworld.h | 6 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_debug_materials.xml | 334 |
11 files changed, 1462 insertions, 1291 deletions
diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index 82d0f892f2..4eef1673f4 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -21,6 +21,7 @@ include_directories( set(llprimitive_SOURCE_FILES llmaterialid.cpp + llmaterial.cpp llmaterialtable.cpp llmediaentry.cpp llmodel.cpp @@ -38,6 +39,7 @@ set(llprimitive_HEADER_FILES CMakeLists.txt legacy_object_types.h + llmaterial.h llmaterialid.h llmaterialtable.h llmediaentry.h diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp new file mode 100644 index 0000000000..982136128e --- /dev/null +++ b/indra/llprimitive/llmaterial.cpp @@ -0,0 +1,155 @@ +/** + * @file llmaterial.cpp + * @brief Material definition + * + * $LicenseInfo:firstyear=2006&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, 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$ + */ + +#include "linden_common.h" + +#include "llmaterial.h" + +/** + * Materials cap parameters + */ +#define MATERIALS_CAP_NORMAL_MAP_FIELD "NormMap" +#define MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD "NormOffsetX" +#define MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD "NormOffsetY" +#define MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD "NormRepeatX" +#define MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD "NormRepeatY" +#define MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD "NormRotation" + +#define MATERIALS_CAP_SPECULAR_MAP_FIELD "SpecMap" +#define MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD "SpecOffsetX" +#define MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD "SpecOffsetY" +#define MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD "SpecRepeatX" +#define MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD "SpecRepeatY" +#define MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD "SpecRotation" + +#define MATERIALS_CAP_SPECULAR_COLOR_FIELD "SpecColor" +#define MATERIALS_CAP_SPECULAR_EXP_FIELD "SpecExp" +#define MATERIALS_CAP_ENV_INTENSITY_FIELD "EnvIntensity" +#define MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD "AlphaMaskCutoff" +#define MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD "DiffuseAlphaMode" + +/** + * Materials constants + */ + +const LLColor4U MATERIALS_DEFAULT_SPECULAR_COLOR = LLColor4U(255, 255, 255, 255); +const U8 MATERIALS_DEFAULT_SPECULAR_EXP = 128; +const U8 MATERIALS_DEFAULT_ENV_INTENSITY = 128; +const U8 MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE = 0; +const U8 MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF = 128; +const F32 MATERIALS_MULTIPLIER = 10000.f; + +/** + * Helper functions + */ + +template<typename T> T getMaterialField(const LLSD& data, const std::string& field, const LLSD::Type field_type) +{ + if ( (data.has(field)) && (field_type == data[field].type()) ) + { + return (T)data[field]; + } + llerrs << "Missing or mistyped field '" << field << "' in material definition" << llendl; + return (T)LLSD(); +} + +/** + * LLMaterial class + */ + +const LLMaterial LLMaterial::null; + +LLMaterial::LLMaterial() + : mSpecularLightColor(MATERIALS_DEFAULT_SPECULAR_COLOR) + , mSpecularLightExponent(MATERIALS_DEFAULT_SPECULAR_EXP) + , mEnvironmentIntensity(MATERIALS_DEFAULT_ENV_INTENSITY) + , mDiffuseAlphaMode(MATERIALS_DEFAULT_DIFFUSE_ALPHA_MODE) + , mAlphaMaskCutoff(MATERIALS_DEFAULT_ALPHA_MASK_CUTOFF) +{ +} + +LLMaterial::LLMaterial(const LLSD& material_data) +{ + fromLLSD(material_data); +} + +LLSD LLMaterial::asLLSD() const +{ + LLSD material_data; + + material_data[MATERIALS_CAP_NORMAL_MAP_FIELD] = mNormalID; + material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = llround(mNormalOffsetX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = llround(mNormalOffsetY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = llround(mNormalRepeatX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = llround(mNormalRepeatY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = llround(mNormalRotation * MATERIALS_MULTIPLIER); + + material_data[MATERIALS_CAP_SPECULAR_MAP_FIELD] = mSpecularID; + material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = llround(mSpecularOffsetX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = llround(mSpecularOffsetY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = llround(mSpecularRepeatX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = llround(mSpecularRepeatY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = llround(mSpecularRotation * MATERIALS_MULTIPLIER); + + material_data[MATERIALS_CAP_SPECULAR_COLOR_FIELD] = mSpecularLightColor.getValue(); + material_data[MATERIALS_CAP_SPECULAR_EXP_FIELD] = mSpecularLightExponent; + material_data[MATERIALS_CAP_ENV_INTENSITY_FIELD] = mEnvironmentIntensity; + material_data[MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD] = mDiffuseAlphaMode; + material_data[MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD] = mAlphaMaskCutoff; + + return material_data; +} + +void LLMaterial::fromLLSD(const LLSD& material_data) +{ + mNormalID = getMaterialField<LLSD::UUID>(material_data, MATERIALS_CAP_NORMAL_MAP_FIELD, LLSD::TypeUUID); + mNormalOffsetX = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mNormalOffsetY = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mNormalRepeatX = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mNormalRepeatY = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mNormalRotation = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + + mSpecularID = getMaterialField<LLSD::UUID>(material_data, MATERIALS_CAP_SPECULAR_MAP_FIELD, LLSD::TypeUUID); + mSpecularOffsetX = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mSpecularOffsetY = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mSpecularRepeatX = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mSpecularRepeatY = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + mSpecularRotation = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULTIPLIER; + + mSpecularLightColor.setValue(getMaterialField<LLSD>(material_data, MATERIALS_CAP_SPECULAR_COLOR_FIELD, LLSD::TypeArray)); + mSpecularLightExponent = (U8)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_SPECULAR_EXP_FIELD, LLSD::TypeInteger); + mEnvironmentIntensity = (U8)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_ENV_INTENSITY_FIELD, LLSD::TypeInteger); + mDiffuseAlphaMode = (U8)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD, LLSD::TypeInteger); + mAlphaMaskCutoff = (U8)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD, LLSD::TypeInteger); +} + +bool LLMaterial::isNull() const +{ + // *TODO: find a better way of defining a 'null' material? + return + (mNormalID.isNull()) && (.0f == mNormalOffsetX) && (.0f == mNormalOffsetY) && (.0f == mNormalRepeatX) && (.0f == mNormalRepeatY) && + (mSpecularID.isNull()) && (.0f == mSpecularOffsetX) && (.0f == mSpecularOffsetY) && (.0f == mSpecularRepeatX) && (.0f == mSpecularRepeatY); +} diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h new file mode 100644 index 0000000000..da364e548c --- /dev/null +++ b/indra/llprimitive/llmaterial.h @@ -0,0 +1,101 @@ +/** + * @file llmaterial.h + * @brief Material definition + * + * $LicenseInfo:firstyear=2006&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, 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_LLMATERIAL_H +#define LL_LLMATERIAL_H + +#include <boost/shared_ptr.hpp> + +#include "llmaterialid.h" +#include "llsd.h" +#include "v4coloru.h" + +class LLMaterial +{ +public: + LLMaterial(); + LLMaterial(const LLSD& material_data); + + LLSD asLLSD() const; + void fromLLSD(const LLSD& material_data); + + const LLUUID& getNormalID() const { return mNormalID; } + void setNormalID(const LLUUID& normal_id) { mNormalID = normal_id; } + void getNormalOffset(F32& offset_x, F32& offset_y) const { offset_x = mNormalOffsetX; offset_y = mNormalOffsetY; } + void setNormalOffset(F32 offset_x, F32 offset_y) { mNormalOffsetX = offset_x; mNormalOffsetY = offset_y; } + void getNormalRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mNormalRepeatX; repeat_y = mNormalRepeatY; } + void setNormalRepeat(F32 repeat_x, F32 repeat_y) { mNormalRepeatX = repeat_x; mNormalRepeatY = repeat_y; } + F32 getNormalRotation() const { return mNormalRotation; } + void setNormalRotation(F32 rot) { mNormalRotation = rot; } + + const LLUUID& getSpecularID() const { return mSpecularID; } + void setSpecularID(const LLUUID& specular_id) { mSpecularID = specular_id; } + void getSpecularOffset(F32& offset_x, F32& offset_y) const { offset_x = mSpecularOffsetX; offset_y = mSpecularOffsetY; } + void setSpecularOffset(F32 offset_x, F32 offset_y) { mSpecularOffsetX = offset_x; mSpecularOffsetY = offset_y; } + void getSpecularRepeat(F32& repeat_x, F32& repeat_y) const { repeat_x = mSpecularRepeatX; repeat_y = mSpecularRepeatY; } + void setSpecularRepeat(F32 repeat_x, F32 repeat_y) { mSpecularRepeatX = repeat_x; mSpecularRepeatY = repeat_y; } + F32 getSpecularRotation() const { return mSpecularRotation; } + void setSpecularRotation(F32 rot) { mSpecularRotation = rot; } + + const LLColor4U& getSpecularLightColor() const { return mSpecularLightColor; } + void setSpecularLightColor(const LLColor4U& color) { mSpecularLightColor = color; } + U8 getSpecularLightExponent() const { return mSpecularLightExponent; } + void setSpecularLightExponent(U8 exponent) { mSpecularLightExponent = exponent; } + U8 getEnvironmentIntensity() const { return mEnvironmentIntensity; } + void setEnvironmentIntensity(U8 intensity) { mEnvironmentIntensity = intensity; } + U8 getDiffuseAlphaMode() const { return mDiffuseAlphaMode; } + void setDiffuseAlphaMode(U8 alpha_mode) { mDiffuseAlphaMode = alpha_mode; } + U8 getAlphaMaskCutoff() const { return mAlphaMaskCutoff; } + void setAlphaMaskCutoff(U8 cutoff) { mAlphaMaskCutoff = cutoff; } + + bool isNull() const; + static const LLMaterial null; + +protected: + LLUUID mNormalID; + F32 mNormalOffsetX; + F32 mNormalOffsetY; + F32 mNormalRepeatX; + F32 mNormalRepeatY; + F32 mNormalRotation; + + LLUUID mSpecularID; + F32 mSpecularOffsetX; + F32 mSpecularOffsetY; + F32 mSpecularRepeatX; + F32 mSpecularRepeatY; + F32 mSpecularRotation; + + LLColor4U mSpecularLightColor; + U8 mSpecularLightExponent; + U8 mEnvironmentIntensity; + U8 mDiffuseAlphaMode; + U8 mAlphaMaskCutoff; +}; + +typedef boost::shared_ptr<LLMaterial> LLMaterialPtr; + +#endif // LL_LLMATERIAL_H diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 746703db66..3e99bd2551 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -335,6 +335,7 @@ set(viewer_SOURCE_FILES llmaniptranslate.cpp llmarketplacefunctions.cpp llmarketplacenotifications.cpp + llmaterialmgr.cpp llmediactrl.cpp llmediadataclient.cpp llmemoryview.cpp @@ -913,6 +914,7 @@ set(viewer_HEADER_FILES llmaniptranslate.h llmarketplacefunctions.h llmarketplacenotifications.h + llmaterialmgr.h llmediactrl.h llmediadataclient.h llmemoryview.h diff --git a/indra/newview/llfloaterdebugmaterials.cpp b/indra/newview/llfloaterdebugmaterials.cpp index d5ed667c4d..c9f15a9c35 100644 --- a/indra/newview/llfloaterdebugmaterials.cpp +++ b/indra/newview/llfloaterdebugmaterials.cpp @@ -43,6 +43,7 @@ #include "llcolorswatch.h" #include "llenvmanager.h" #include "llfloater.h" +#include "llfloaterreg.h" #include "llfontgl.h" #include "llhttpclient.h" #include "lllineeditor.h" @@ -73,84 +74,10 @@ #define MATERIALS_CAPABILITY_NAME "RenderMaterials" -#define MATERIALS_CAP_ZIP_FIELD "Zipped" - -#define MATERIALS_CAP_FULL_PER_FACE_FIELD "FullMaterialsPerFace" -#define MATERIALS_CAP_FACE_FIELD "Face" -#define MATERIALS_CAP_MATERIAL_FIELD "Material" -#define MATERIALS_CAP_OBJECT_ID_FIELD "ID" -#define MATERIALS_CAP_MATERIAL_ID_FIELD "MaterialID" - -#define MATERIALS_CAP_NORMAL_MAP_FIELD "NormMap" -#define MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD "NormOffsetX" -#define MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD "NormOffsetY" -#define MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD "NormRepeatX" -#define MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD "NormRepeatY" -#define MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD "NormRotation" - -#define MATERIALS_CAP_SPECULAR_MAP_FIELD "SpecMap" -#define MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD "SpecOffsetX" -#define MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD "SpecOffsetY" -#define MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD "SpecRepeatX" -#define MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD "SpecRepeatY" -#define MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD "SpecRotation" - -#define MATERIALS_CAP_SPECULAR_COLOR_FIELD "SpecColor" -#define MATERIALS_CAP_SPECULAR_EXP_FIELD "SpecExp" -#define MATERIALS_CAP_ENV_INTENSITY_FIELD "EnvIntensity" -#define MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD "AlphaMaskCutoff" -#define MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD "DiffuseAlphaMode" - -#define MULTI_MATERIALS_STATUS_FIELD "status" -#define MULTI_MATERIALS_DATA_FIELD "data" - #define VIEWABLE_OBJECTS_REGION_ID_FIELD "regionId" #define VIEWABLE_OBJECTS_OBJECT_ID_FIELD "objectId" #define VIEWABLE_OBJECTS_MATERIAL_ID_FIELD "materialId" -class MaterialsResponder : public LLHTTPClient::Responder -{ -public: - typedef boost::function<void (bool, const LLSD&)> CallbackFunction; - - MaterialsResponder(const std::string& pMethod, const std::string& pCapabilityURL, CallbackFunction pCallback); - virtual ~MaterialsResponder(); - - virtual void result(const LLSD& pContent); - virtual void error(U32 pStatus, const std::string& pReason); - -protected: - -private: - std::string mMethod; - std::string mCapabilityURL; - CallbackFunction mCallback; -}; - -class MultiMaterialsResponder -{ -public: - typedef boost::function<void (bool, const LLSD&)> CallbackFunction; - - MultiMaterialsResponder(CallbackFunction pCallback, unsigned int pNumRequests); - virtual ~MultiMaterialsResponder(); - - void onMaterialsResponse(bool pRequestStatus, const LLSD& pContent); - -protected: - -private: - bool appendRequestResults(bool pRequestStatus, const LLSD& pResults); - void fireResponse(); - - CallbackFunction mCallback; - unsigned int mNumRequests; - - bool mRequestStatus; - LLSD mContent; - LLMutex* mMutex; -}; - BOOL LLFloaterDebugMaterials::postBuild() { mStatusText = findChild<LLTextBase>("material_status"); @@ -178,58 +105,38 @@ BOOL LLFloaterDebugMaterials::postBuild() mNormalMap = findChild<LLTextureCtrl>("normal_map"); llassert(mNormalMap != NULL); - mNormalMapOffsetX = findChild<LLLineEditor>("normal_map_offset_x"); + mNormalMapOffsetX = findChild<LLSpinCtrl>("normal_map_offset_x"); llassert(mNormalMapOffsetX != NULL); - mNormalMapOffsetX->setPrevalidate(LLTextValidate::validateInt); - mNormalMapOffsetX->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onValueEntered, this, _1)); - mNormalMapOffsetY = findChild<LLLineEditor>("normal_map_offset_y"); + mNormalMapOffsetY = findChild<LLSpinCtrl>("normal_map_offset_y"); llassert(mNormalMapOffsetY != NULL); - mNormalMapOffsetY->setPrevalidate(LLTextValidate::validateInt); - mNormalMapOffsetY->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onValueEntered, this, _1)); - mNormalMapRepeatX = findChild<LLLineEditor>("normal_map_repeat_x"); + mNormalMapRepeatX = findChild<LLSpinCtrl>("normal_map_repeat_x"); llassert(mNormalMapRepeatX != NULL); - mNormalMapRepeatX->setPrevalidate(LLTextValidate::validateInt); - mNormalMapRepeatX->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onValueEntered, this, _1)); - mNormalMapRepeatY = findChild<LLLineEditor>("normal_map_repeat_y"); + mNormalMapRepeatY = findChild<LLSpinCtrl>("normal_map_repeat_y"); llassert(mNormalMapRepeatY != NULL); - mNormalMapRepeatY->setPrevalidate(LLTextValidate::validateInt); - mNormalMapRepeatY->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onValueEntered, this, _1)); - mNormalMapRotation = findChild<LLLineEditor>("normal_map_rotation"); + mNormalMapRotation = findChild<LLSpinCtrl>("normal_map_rotation"); llassert(mNormalMapRotation != NULL); - mNormalMapRotation->setPrevalidate(LLTextValidate::validateInt); - mNormalMapRotation->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onValueEntered, this, _1)); mSpecularMap = findChild<LLTextureCtrl>("specular_map"); llassert(mSpecularMap != NULL); - mSpecularMapOffsetX = findChild<LLLineEditor>("specular_map_offset_x"); + mSpecularMapOffsetX = findChild<LLSpinCtrl>("specular_map_offset_x"); llassert(mSpecularMapOffsetX != NULL); - mSpecularMapOffsetX->setPrevalidate(LLTextValidate::validateInt); - mSpecularMapOffsetX->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onValueEntered, this, _1)); - mSpecularMapOffsetY = findChild<LLLineEditor>("specular_map_offset_y"); + mSpecularMapOffsetY = findChild<LLSpinCtrl>("specular_map_offset_y"); llassert(mSpecularMapOffsetY != NULL); - mSpecularMapOffsetY->setPrevalidate(LLTextValidate::validateInt); - mSpecularMapOffsetY->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onValueEntered, this, _1)); - mSpecularMapRepeatX = findChild<LLLineEditor>("specular_map_repeat_x"); + mSpecularMapRepeatX = findChild<LLSpinCtrl>("specular_map_repeat_x"); llassert(mSpecularMapRepeatX != NULL); - mSpecularMapRepeatX->setPrevalidate(LLTextValidate::validateInt); - mSpecularMapRepeatX->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onValueEntered, this, _1)); - mSpecularMapRepeatY = findChild<LLLineEditor>("specular_map_repeat_y"); + mSpecularMapRepeatY = findChild<LLSpinCtrl>("specular_map_repeat_y"); llassert(mSpecularMapRepeatY != NULL); - mSpecularMapRepeatY->setPrevalidate(LLTextValidate::validateInt); - mSpecularMapRepeatY->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onValueEntered, this, _1)); - mSpecularMapRotation = findChild<LLLineEditor>("specular_map_rotation"); + mSpecularMapRotation = findChild<LLSpinCtrl>("specular_map_rotation"); llassert(mSpecularMapRotation != NULL); - mSpecularMapRotation->setPrevalidate(LLTextValidate::validateInt); - mSpecularMapRotation->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onValueEntered, this, _1)); mSpecularColor = findChild<LLColorSwatchCtrl>("specular_color"); llassert(mSpecularColor != NULL); @@ -331,7 +238,6 @@ void LLFloaterDebugMaterials::onOpen(const LLSD& pKey) checkRegionMaterialStatus(); resetObjectEditInputs(); clearGetResults(); - clearPutResults(); clearViewableObjectsResults(); clearPostResults(); } @@ -340,7 +246,6 @@ void LLFloaterDebugMaterials::onClose(bool pIsAppQuitting) { resetObjectEditInputs(); clearGetResults(); - clearPutResults(); clearViewableObjectsResults(); clearPostResults(); @@ -364,14 +269,14 @@ void LLFloaterDebugMaterials::onClose(bool pIsAppQuitting) void LLFloaterDebugMaterials::draw() { - if (mUnparsedGetData.isDefined()) - { - parseGetResponse(); - } if (mNextUnparsedQueryDataIndex >= 0) { parseQueryViewableObjects(); } + if (LLSelectMgr::instance().getSelection().notNull()) + { + refreshObjectEdit(); + } LLFloater::draw(); } @@ -417,19 +322,12 @@ LLFloaterDebugMaterials::LLFloaterDebugMaterials(const LLSD& pParams) mRegionCrossConnection(), mTeleportFailedConnection(), mSelectionUpdateConnection(), - mUnparsedGetData(), - mNextUnparsedGetDataIndex(-1), - mNextUnparsedQueryDataIndex(-1), - mMultiMaterialsResponder() + mNextUnparsedQueryDataIndex(-1) { } LLFloaterDebugMaterials::~LLFloaterDebugMaterials() { - if (!mMultiMaterialsResponder) - { - mMultiMaterialsResponder.reset(); - } } void LLFloaterDebugMaterials::onGetClicked() @@ -478,14 +376,35 @@ void LLFloaterDebugMaterials::onQueryVisibleObjectsClicked() void LLFloaterDebugMaterials::onPostClicked() { - requestPostMaterials(); + clearPostResults(); + + std::vector<LLScrollListItem*> selectedItems = mViewableObjectsScrollList->getAllSelected(); + if (!selectedItems.empty()) + { + for (std::vector<LLScrollListItem*>::const_iterator selectedItemIter = selectedItems.begin(); + selectedItemIter != selectedItems.end(); ++selectedItemIter) + { + const LLScrollListItem* selectedItem = *selectedItemIter; + const LLSD& selectedItemValue = selectedItem->getValue(); + llassert(selectedItemValue.isMap()); + + llassert(selectedItemValue.has(VIEWABLE_OBJECTS_REGION_ID_FIELD)); + llassert(selectedItemValue.get(VIEWABLE_OBJECTS_REGION_ID_FIELD).isUUID()); + const LLUUID& region_id = selectedItemValue.get(VIEWABLE_OBJECTS_REGION_ID_FIELD).asUUID(); + + llassert(selectedItemValue.has(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD)); + llassert(selectedItemValue.get(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD).isBinary()); + const LLMaterialID material_id(selectedItemValue.get(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD).asBinary()); + + LLMaterialMgr::instance().get(region_id, material_id, boost::bind(&LLFloaterDebugMaterials::onPostMaterial, _1, _2)); + } + } } void LLFloaterDebugMaterials::onRegionCross() { checkRegionMaterialStatus(); clearGetResults(); - clearPutResults(); clearViewableObjectsResults(); clearPostResults(); } @@ -605,47 +524,6 @@ void LLFloaterDebugMaterials::onDeferredRequestPutMaterials(LLUUID regionId, boo requestPutMaterials(regionId, pIsDoSet); } -void LLFloaterDebugMaterials::onGetResponse(bool pRequestStatus, const LLSD& pContent) -{ - clearGetResults(); - if (pRequestStatus) - { - setState(kRequestCompleted); - setUnparsedGetData(pContent); - } - else - { - setState(kError); - } -} - -void LLFloaterDebugMaterials::onPutResponse(bool pRequestStatus, const LLSD& pContent) -{ - if (pRequestStatus) - { - setState(kRequestCompleted); - parsePutResponse(pContent); - } - else - { - setState(kError); - } -} - -void LLFloaterDebugMaterials::onPostResponse(bool pRequestStatus, const LLSD& pContent) -{ - if (pRequestStatus) - { - setState(kRequestCompleted); - parsePostResponse(pContent); - } - else - { - setState(kError); - } - mMultiMaterialsResponder.reset(); -} - void LLFloaterDebugMaterials::checkRegionMaterialStatus() { LLViewerRegion *region = gAgent.getRegion(); @@ -713,9 +591,8 @@ void LLFloaterDebugMaterials::requestGetMaterials() } else { - setState(kRequestStarted); - LLHTTPClient::ResponderPtr materialsResponder = new MaterialsResponder("GET", capURL, boost::bind(&LLFloaterDebugMaterials::onGetResponse, this, _1, _2)); - LLHTTPClient::get(capURL, materialsResponder); + setState(kReady); + LLMaterialMgr::instance().getAll(region->getRegionID(), boost::bind(&LLFloaterDebugMaterials::onGetMaterials, _1, _2)); } } } @@ -756,34 +633,9 @@ void LLFloaterDebugMaterials::requestPutMaterials(bool pIsDoSet) } else { - setState(kRequestStarted); - - LLSD facesData = LLSD::emptyArray(); + setState(kReady); - LLSD materialData = LLSD::emptyMap(); - if (pIsDoSet) - { - materialData[MATERIALS_CAP_NORMAL_MAP_FIELD] = mNormalMap->getImageAssetID(); - materialData[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = static_cast<LLSD::Integer>(getNormalMapOffsetX()); - materialData[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = static_cast<LLSD::Integer>(getNormalMapOffsetY()); - materialData[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = static_cast<LLSD::Integer>(getNormalMapRepeatX()); - materialData[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = static_cast<LLSD::Integer>(getNormalMapRepeatY()); - materialData[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = static_cast<LLSD::Integer>(getNormalMapRotation()); - - materialData[MATERIALS_CAP_SPECULAR_MAP_FIELD] = mSpecularMap->getImageAssetID(); - materialData[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = static_cast<LLSD::Integer>(getSpecularMapOffsetX()); - materialData[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = static_cast<LLSD::Integer>(getSpecularMapOffsetY()); - materialData[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = static_cast<LLSD::Integer>(getSpecularMapRepeatX()); - materialData[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = static_cast<LLSD::Integer>(getSpecularMapRepeatY()); - materialData[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = static_cast<LLSD::Integer>(getSpecularMapRotation()); - - LLColor4U specularColor = getSpecularColor(); - materialData[MATERIALS_CAP_SPECULAR_COLOR_FIELD] = specularColor.getValue(); - materialData[MATERIALS_CAP_SPECULAR_EXP_FIELD] = static_cast<LLSD::Integer>(getSpecularExponent()); - materialData[MATERIALS_CAP_ENV_INTENSITY_FIELD] = static_cast<LLSD::Integer>(getEnvironmentExponent()); - materialData[MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD] = static_cast<LLSD::Integer>(getAlphMaskCutoff()); - materialData[MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD] = static_cast<LLSD::Integer>(getDiffuseAlphaMode()); - } + LLMaterial material = (pIsDoSet) ? getMaterial() : LLMaterial::null; LLObjectSelectionHandle selectionHandle = LLSelectMgr::getInstance()->getEditSelection(); for (LLObjectSelection::valid_iterator objectIter = selectionHandle->valid_begin(); @@ -804,41 +656,11 @@ void LLFloaterDebugMaterials::requestPutMaterials(bool pIsDoSet) { if (objectNode->isTESelected(curTEIndex)) { - LLSD faceData = LLSD::emptyMap(); - faceData[MATERIALS_CAP_FACE_FIELD] = static_cast<LLSD::Integer>(curTEIndex); - faceData[MATERIALS_CAP_OBJECT_ID_FIELD] = static_cast<LLSD::Integer>(viewerObject->getLocalID()); - if (pIsDoSet) - { - faceData[MATERIALS_CAP_MATERIAL_FIELD] = materialData; - } - facesData.append(faceData); + LLMaterialMgr::instance().put(viewerObject->getID(), curTEIndex, material); } } } } - - LLSD materialsData = LLSD::emptyMap(); - materialsData[MATERIALS_CAP_FULL_PER_FACE_FIELD] = facesData; - - std::string materialString = zip_llsd(materialsData); - S32 materialSize = materialString.size(); - - if (materialSize <= 0) - { - LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; - } - else - { - LLSD::Binary materialBinary; - materialBinary.resize(materialSize); - memcpy(materialBinary.data(), materialString.data(), materialSize); - - LLSD putData = LLSD::emptyMap(); - putData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; - - LLHTTPClient::ResponderPtr materialsResponder = new MaterialsResponder("PUT", capURL, boost::bind(&LLFloaterDebugMaterials::onPutResponse, this, _1, _2)); - LLHTTPClient::put(capURL, putData, materialsResponder); - } } } } @@ -853,128 +675,6 @@ void LLFloaterDebugMaterials::requestPutMaterials(const LLUUID& regionId, bool p } } -void LLFloaterDebugMaterials::requestPostMaterials() -{ - llassert(!mMultiMaterialsResponder); - - std::vector<LLScrollListItem*> selectedItems = mViewableObjectsScrollList->getAllSelected(); - std::map<LLUUID, std::string> uniqueRegions; - - if (!selectedItems.empty()) - { - for (std::vector<LLScrollListItem*>::const_iterator selectedItemIter = selectedItems.begin(); - selectedItemIter != selectedItems.end(); ++selectedItemIter) - { - const LLScrollListItem* selectedItem = *selectedItemIter; - const LLSD& selectedItemValue = selectedItem->getValue(); - llassert(selectedItemValue.isMap()); - - llassert(selectedItemValue.has(VIEWABLE_OBJECTS_REGION_ID_FIELD)); - llassert(selectedItemValue.get(VIEWABLE_OBJECTS_REGION_ID_FIELD).isUUID()); - const LLUUID& regionId = selectedItemValue.get(VIEWABLE_OBJECTS_REGION_ID_FIELD).asUUID(); - if (uniqueRegions.find(regionId) == uniqueRegions.end()) - { - llassert(selectedItemValue.has(VIEWABLE_OBJECTS_OBJECT_ID_FIELD)); - llassert(selectedItemValue.get(VIEWABLE_OBJECTS_OBJECT_ID_FIELD).isUUID()); - const LLUUID& objectId = selectedItemValue.get(VIEWABLE_OBJECTS_OBJECT_ID_FIELD).asUUID(); - LLViewerObject* viewerObject = gObjectList.findObject(objectId); - if (viewerObject != NULL) - { - LLViewerRegion* region = viewerObject->getRegion(); - if (region != NULL) - { - if (!region->capabilitiesReceived()) - { - LL_WARNS("debugMaterials") << "region '" << region->getName() << "' (id:" - << region->getRegionID().asString() << ") has not received capabilities" - << LL_ENDL; - } - else - { - std::string capURL = region->getCapability(MATERIALS_CAPABILITY_NAME); - - if (capURL.empty()) - { - LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME - << "' is not defined on the current region '" << region->getName() << "'" << LL_ENDL; - } - else - { - uniqueRegions.insert(std::make_pair<LLUUID, std::string>(regionId, capURL)); - } - } - } - } - } - } - - unsigned int numRegions = static_cast<unsigned int>(uniqueRegions.size()); - - if (numRegions > 0U) - { - setState(kRequestStarted); - mMultiMaterialsResponder = MultiMaterialsResponderPtr(new MultiMaterialsResponder(boost::bind(&LLFloaterDebugMaterials::onPostResponse, this, _1, _2), numRegions)); - - for (std::map<LLUUID, std::string>::const_iterator regionIdIter = uniqueRegions.begin(); - regionIdIter != uniqueRegions.end(); ++regionIdIter) - { - const LLUUID& regionId = regionIdIter->first; - std::string capURL = regionIdIter->second; - - LLSD materialIdsData = LLSD::emptyArray(); - - for (std::vector<LLScrollListItem*>::const_iterator selectedItemIter = selectedItems.begin(); - selectedItemIter != selectedItems.end(); ++selectedItemIter) - { - const LLScrollListItem* selectedItem = *selectedItemIter; - const LLSD& selectedItemValue = selectedItem->getValue(); - - llassert(selectedItemValue.has(VIEWABLE_OBJECTS_REGION_ID_FIELD)); - llassert(selectedItemValue.get(VIEWABLE_OBJECTS_REGION_ID_FIELD).isUUID()); - const LLUUID& selectedItemRegionId = selectedItemValue.get(VIEWABLE_OBJECTS_REGION_ID_FIELD).asUUID(); - if (selectedItemRegionId == regionId) - { - llassert(selectedItemValue.has(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD)); - llassert(selectedItemValue.get(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD).isBinary()); - const LLSD& materidIdLLSD = selectedItemValue.get(VIEWABLE_OBJECTS_MATERIAL_ID_FIELD); - - materialIdsData.append(materidIdLLSD); - } - } - - if (materialIdsData.size() <= 0) - { - LL_ERRS("debugMaterials") << "no material IDs to POST to region id " << regionId.asString() - << LL_ENDL; - } - else - { - std::string materialsString = zip_llsd(materialIdsData); - S32 materialsSize = materialsString.size(); - - if (materialsSize <= 0) - { - LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; - } - else - { - LLSD::Binary materialsBinary; - materialsBinary.resize(materialsSize); - memcpy(materialsBinary.data(), materialsString.data(), materialsSize); - - LLSD postData = LLSD::emptyMap(); - postData[MATERIALS_CAP_ZIP_FIELD] = materialsBinary; - - LLHTTPClient::ResponderPtr materialsResponder = new MaterialsResponder("POST", - capURL, boost::bind(&MultiMaterialsResponder::onMaterialsResponse, mMultiMaterialsResponder.get(), _1, _2)); - LLHTTPClient::post(capURL, postData, materialsResponder); - } - } - } - } - } -} - void LLFloaterDebugMaterials::parseQueryViewableObjects() { llassert(mNextUnparsedQueryDataIndex >= 0); @@ -1029,9 +729,8 @@ void LLFloaterDebugMaterials::parseQueryViewableObjects() rowParams.columns.add(cellParams); cellParams.font = LLFontGL::getFontMonospace(); - std::string materialIDString = objectMaterialID.asString(); cellParams.column = "material_id"; - cellParams.value = materialIDString; + cellParams.value = objectMaterialID.asString(); rowParams.columns.add(cellParams); LLSD rowValue = LLSD::emptyMap(); @@ -1060,508 +759,288 @@ void LLFloaterDebugMaterials::parseQueryViewableObjects() } } -void LLFloaterDebugMaterials::parseGetResponse() +void LLFloaterDebugMaterials::onGetMaterials(const LLUUID& region_id, const LLMaterialMgr::material_map_t& materials) { - llassert(mUnparsedGetData.isDefined()); - llassert(mNextUnparsedGetDataIndex >= 0); - - if (mUnparsedGetData.isDefined()) + LLFloaterDebugMaterials* instancep = LLFloaterReg::findTypedInstance<LLFloaterDebugMaterials>("floater_debug_materials"); + if (!instancep) { - LLScrollListCell::Params cellParams; - LLScrollListItem::Params normalMapRowParams; - LLScrollListItem::Params specularMapRowParams; - LLScrollListItem::Params otherDataRowParams; - - llassert(mUnparsedGetData.isArray()); - LLSD::array_const_iterator materialIter = mUnparsedGetData.beginArray(); - S32 materialIndex; - - for (materialIndex = 0; - (materialIndex < mNextUnparsedGetDataIndex) && (materialIter != mUnparsedGetData.endArray()); - ++materialIndex, ++materialIter) - { - } - - for (S32 currentParseCount = 0; - (currentParseCount < 10) && (materialIter != mUnparsedGetData.endArray()); - ++currentParseCount, ++materialIndex, ++materialIter) - { - const LLSD &material = *materialIter; - llassert(material.isMap()); - llassert(material.has(MATERIALS_CAP_OBJECT_ID_FIELD)); - llassert(material.get(MATERIALS_CAP_OBJECT_ID_FIELD).isBinary()); - const LLSD &materialIdLLSD = material.get(MATERIALS_CAP_OBJECT_ID_FIELD); - LLMaterialID materialID(materialIdLLSD); - std::string materialIDString = materialID.asString(); - - llassert(material.has(MATERIALS_CAP_MATERIAL_FIELD)); - const LLSD &materialData = material.get(MATERIALS_CAP_MATERIAL_FIELD); - llassert(materialData.isMap()); - - llassert(materialData.has(MATERIALS_CAP_NORMAL_MAP_FIELD)); - llassert(materialData.get(MATERIALS_CAP_NORMAL_MAP_FIELD).isUUID()); - const LLUUID &normalMapID = materialData.get(MATERIALS_CAP_NORMAL_MAP_FIELD).asUUID(); - - llassert(materialData.has(MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD)); - llassert(materialData.get(MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD).isInteger()); - S32 normalMapOffsetX = materialData.get(MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD)); - llassert(materialData.get(MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD).isInteger()); - S32 normalMapOffsetY = materialData.get(MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD)); - llassert(materialData.get(MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD).isInteger()); - S32 normalMapRepeatX = materialData.get(MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD)); - llassert(materialData.get(MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD).isInteger()); - S32 normalMapRepeatY = materialData.get(MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD)); - llassert(materialData.get(MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD).isInteger()); - S32 normalMapRotation = materialData.get(MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_MAP_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_MAP_FIELD).isUUID()); - const LLUUID &specularMapID = materialData.get(MATERIALS_CAP_SPECULAR_MAP_FIELD).asUUID(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD).isInteger()); - S32 specularMapOffsetX = materialData.get(MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD).isInteger()); - S32 specularMapOffsetY = materialData.get(MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD).isInteger()); - S32 specularMapRepeatX = materialData.get(MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD).isInteger()); - S32 specularMapRepeatY = materialData.get(MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD).isInteger()); - S32 specularMapRotation = materialData.get(MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_COLOR_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_COLOR_FIELD).isArray()); - LLColor4U specularColor; - specularColor.setValue(materialData.get(MATERIALS_CAP_SPECULAR_COLOR_FIELD)); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_EXP_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_EXP_FIELD).isInteger()); - S32 specularExp = materialData.get(MATERIALS_CAP_SPECULAR_EXP_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_ENV_INTENSITY_FIELD)); - llassert(materialData.get(MATERIALS_CAP_ENV_INTENSITY_FIELD).isInteger()); - S32 envIntensity = materialData.get(MATERIALS_CAP_ENV_INTENSITY_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD)); - llassert(materialData.get(MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD).isInteger()); - S32 alphaMaskCutoff = materialData.get(MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD)); - llassert(materialData.get(MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD).isInteger()); - S32 diffuseAlphaMode = materialData.get(MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD).asInteger(); - - cellParams.font = LLFontGL::getFontMonospace(); - - cellParams.column = "id"; - cellParams.value = materialIDString; - normalMapRowParams.columns.add(cellParams); - specularMapRowParams.columns.add(cellParams); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_map"; - cellParams.value = normalMapID.asString(); - normalMapRowParams.columns.add(cellParams); - - cellParams.font = LLFontGL::getFontSansSerif(); - - cellParams.column = "normal_map_list_offset_x"; - cellParams.value = llformat("%d", normalMapOffsetX); - normalMapRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_offset_y"; - cellParams.value = llformat("%d", normalMapOffsetY); - normalMapRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_repeat_x"; - cellParams.value = llformat("%d", normalMapRepeatX); - normalMapRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_repeat_y"; - cellParams.value = llformat("%d", normalMapRepeatY); - normalMapRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_rotation"; - cellParams.value = llformat("%d", normalMapRotation); - normalMapRowParams.columns.add(cellParams); - - cellParams.font = LLFontGL::getFontMonospace(); - - cellParams.column = "specular_map_list_map"; - cellParams.value = specularMapID.asString(); - specularMapRowParams.columns.add(cellParams); - - cellParams.font = LLFontGL::getFontSansSerif(); - - cellParams.column = "specular_map_list_offset_x"; - cellParams.value = llformat("%d", specularMapOffsetX); - specularMapRowParams.columns.add(cellParams); - - cellParams.column = "specular_map_list_offset_y"; - cellParams.value = llformat("%d", specularMapOffsetY); - specularMapRowParams.columns.add(cellParams); - - cellParams.column = "specular_map_list_repeat_x"; - cellParams.value = llformat("%d", specularMapRepeatX); - specularMapRowParams.columns.add(cellParams); - - cellParams.column = "specular_map_list_repeat_y"; - cellParams.value = llformat("%d", specularMapRepeatY); - specularMapRowParams.columns.add(cellParams); - - cellParams.column = "specular_map_list_rotation"; - cellParams.value = llformat("%d", specularMapRotation); - specularMapRowParams.columns.add(cellParams); - - cellParams.column = "specular_color"; - cellParams.value = llformat("(%d, %d, %d, %d)", specularColor.mV[0], - specularColor.mV[1], specularColor.mV[2], specularColor.mV[3]); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "specular_exponent"; - cellParams.value = llformat("%d", specularExp); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "env_intensity"; - cellParams.value = llformat("%d", envIntensity); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "alpha_mask_cutoff"; - cellParams.value = llformat("%d", alphaMaskCutoff); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "diffuse_alpha_mode"; - cellParams.value = llformat("%d", diffuseAlphaMode); - otherDataRowParams.columns.add(cellParams); + return; + } - normalMapRowParams.value = materialIDString; - specularMapRowParams.value = materialIDString; - otherDataRowParams.value = materialIDString; + LLViewerRegion* regionp = gAgent.getRegion(); + if ( (!regionp) || (regionp->getRegionID() != region_id) ) + { + return; + } - mGetNormalMapScrollList->addRow(normalMapRowParams); - mGetSpecularMapScrollList->addRow(specularMapRowParams); - mGetOtherDataScrollList->addRow(otherDataRowParams); - } + LLScrollListCell::Params cellParams; + LLScrollListItem::Params normalMapRowParams; + LLScrollListItem::Params specularMapRowParams; + LLScrollListItem::Params otherDataRowParams; - if (materialIter != mUnparsedGetData.endArray()) - { - mNextUnparsedGetDataIndex = materialIndex; - updateGetParsingStatus(); - } - else - { - clearUnparsedGetData(); - } + instancep->clearGetResults(); + for (LLMaterialMgr::material_map_t::const_iterator itMaterial = materials.begin(); itMaterial != materials.end(); ++itMaterial) + { + const LLMaterialID& material_id = itMaterial->first; + const LLMaterialPtr material = itMaterial->second; + + F32 x, y; + + cellParams.font = LLFontGL::getFontMonospace(); + + cellParams.column = "id"; + cellParams.value = material_id.asString(); + normalMapRowParams.columns.add(cellParams); + specularMapRowParams.columns.add(cellParams); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "normal_map_list_map"; + cellParams.value = material->getNormalID().asString(); + normalMapRowParams.columns.add(cellParams); + + cellParams.font = LLFontGL::getFontSansSerif(); + + material->getNormalOffset(x, y); + cellParams.column = "normal_map_list_offset_x"; + cellParams.value = llformat("%f", x); + normalMapRowParams.columns.add(cellParams); + cellParams.column = "normal_map_list_offset_y"; + cellParams.value = llformat("%f", y); + normalMapRowParams.columns.add(cellParams); + + material->getNormalRepeat(x, y); + cellParams.column = "normal_map_list_repeat_x"; + cellParams.value = llformat("%f", x); + normalMapRowParams.columns.add(cellParams); + cellParams.column = "normal_map_list_repeat_y"; + cellParams.value = llformat("%f", y); + normalMapRowParams.columns.add(cellParams); + + cellParams.column = "normal_map_list_rotation"; + cellParams.value = llformat("%f", material->getNormalRotation()); + normalMapRowParams.columns.add(cellParams); + + cellParams.font = LLFontGL::getFontMonospace(); + + cellParams.column = "specular_map_list_map"; + cellParams.value = material->getSpecularID().asString(); + specularMapRowParams.columns.add(cellParams); + + cellParams.font = LLFontGL::getFontSansSerif(); + + material->getSpecularOffset(x, y); + cellParams.column = "specular_map_list_offset_x"; + cellParams.value = llformat("%f", x); + specularMapRowParams.columns.add(cellParams); + cellParams.column = "specular_map_list_offset_y"; + cellParams.value = llformat("%f", y); + specularMapRowParams.columns.add(cellParams); + + material->getSpecularRepeat(x, y); + cellParams.column = "specular_map_list_repeat_x"; + cellParams.value = llformat("%f", x); + specularMapRowParams.columns.add(cellParams); + + cellParams.column = "specular_map_list_repeat_y"; + cellParams.value = llformat("%f", y); + specularMapRowParams.columns.add(cellParams); + + cellParams.column = "specular_map_list_rotation"; + cellParams.value = llformat("%f", material->getSpecularRotation()); + specularMapRowParams.columns.add(cellParams); + + const LLColor4U& specularColor = material->getSpecularLightColor(); + cellParams.column = "specular_color"; + cellParams.value = llformat("(%d, %d, %d, %d)", specularColor.mV[0], + specularColor.mV[1], specularColor.mV[2], specularColor.mV[3]); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "specular_exponent"; + cellParams.value = llformat("%d", material->getSpecularLightExponent()); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "env_intensity"; + cellParams.value = llformat("%d", material->getEnvironmentIntensity()); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "alpha_mask_cutoff"; + cellParams.value = llformat("%d", material->getAlphaMaskCutoff()); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "diffuse_alpha_mode"; + cellParams.value = llformat("%d", material->getDiffuseAlphaMode()); + otherDataRowParams.columns.add(cellParams); + + normalMapRowParams.value = cellParams.value; + specularMapRowParams.value = cellParams.value; + otherDataRowParams.value = cellParams.value; + + instancep->mGetNormalMapScrollList->addRow(normalMapRowParams); + instancep->mGetSpecularMapScrollList->addRow(specularMapRowParams); + instancep->mGetOtherDataScrollList->addRow(otherDataRowParams); } } -void LLFloaterDebugMaterials::parsePutResponse(const LLSD& pContent) +void LLFloaterDebugMaterials::onPostMaterial(const LLMaterialID& material_id, const LLMaterialPtr materialp) { - clearPutResults(); - - LLScrollListCell::Params cellParams; - LLScrollListItem::Params rowParams; - - llassert(pContent.isMap()); - llassert(pContent.has(MATERIALS_CAP_ZIP_FIELD)); - llassert(pContent.get(MATERIALS_CAP_ZIP_FIELD).isBinary()); - - LLSD::Binary responseBinary = pContent.get(MATERIALS_CAP_ZIP_FIELD).asBinary(); - S32 responseSize = static_cast<S32>(responseBinary.size()); - std::string responseString(reinterpret_cast<const char*>(responseBinary.data()), responseSize); - - std::istringstream responseStream(responseString); - - LLSD responseContent; - if (!unzip_llsd(responseContent, responseStream, responseSize)) + LLFloaterDebugMaterials* instancep = LLFloaterReg::findTypedInstance<LLFloaterDebugMaterials>("floater_debug_materials"); + if ( (!instancep) || (!materialp.get()) ) { - LL_ERRS("debugMaterials") << "cannot unzip LLSD binary content" << LL_ENDL; + return; } - else - { - llassert(responseContent.isArray()); - for (LLSD::array_const_iterator faceIter = responseContent.beginArray(); faceIter != responseContent.endArray(); - ++faceIter) - { - const LLSD &face = *faceIter; - llassert(face.isMap()); - - llassert(face.has(MATERIALS_CAP_FACE_FIELD)); - llassert(face.get(MATERIALS_CAP_FACE_FIELD).isInteger()); - S32 faceId = face.get(MATERIALS_CAP_FACE_FIELD).asInteger(); - - llassert(face.has(MATERIALS_CAP_OBJECT_ID_FIELD)); - llassert(face.get(MATERIALS_CAP_OBJECT_ID_FIELD).isInteger()); - S32 objectId = face.get(MATERIALS_CAP_OBJECT_ID_FIELD).asInteger(); - - llassert(face.has(MATERIALS_CAP_MATERIAL_ID_FIELD)); - llassert(face.get(MATERIALS_CAP_MATERIAL_ID_FIELD).isBinary()); - LLMaterialID materialID(face.get(MATERIALS_CAP_MATERIAL_ID_FIELD)); - std::string materialIDString = materialID.asString(); - cellParams.font = LLFontGL::getFontMonospace(); - - cellParams.column = "material_id"; - cellParams.value = materialIDString; - rowParams.columns.add(cellParams); - - cellParams.font = LLFontGL::getFontSansSerif(); - - cellParams.column = "object_id"; - cellParams.value = llformat("%d", objectId); - rowParams.columns.add(cellParams); - - cellParams.column = "face_index"; - cellParams.value = llformat("%d", faceId); - rowParams.columns.add(cellParams); + LLScrollListCell::Params cellParams; + LLScrollListItem::Params normalMapRowParams; + LLScrollListItem::Params specularMapRowParams; + LLScrollListItem::Params otherDataRowParams; + + cellParams.font = LLFontGL::getFontMonospace(); + + cellParams.column = "id"; + cellParams.value = material_id.asString(); + normalMapRowParams.columns.add(cellParams); + specularMapRowParams.columns.add(cellParams); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "normal_map_list_map"; + cellParams.value = materialp->getNormalID().asString(); + normalMapRowParams.columns.add(cellParams); + + cellParams.font = LLFontGL::getFontSansSerif(); + + F32 x, y; + materialp->getNormalOffset(x, y); + cellParams.column = "normal_map_list_offset_x"; + cellParams.value = llformat("%f", x); + normalMapRowParams.columns.add(cellParams); + cellParams.column = "normal_map_list_offset_y"; + cellParams.value = llformat("%f", y); + normalMapRowParams.columns.add(cellParams); + + materialp->getNormalRepeat(x, y); + cellParams.column = "normal_map_list_repeat_x"; + cellParams.value = llformat("%f", x); + normalMapRowParams.columns.add(cellParams); + cellParams.column = "normal_map_list_repeat_y"; + cellParams.value = llformat("%f", y); + normalMapRowParams.columns.add(cellParams); + + cellParams.column = "normal_map_list_rotation"; + cellParams.value = llformat("%f", materialp->getNormalRotation()); + normalMapRowParams.columns.add(cellParams); + + cellParams.font = LLFontGL::getFontMonospace(); + + cellParams.column = "specular_map_list_map"; + cellParams.value = materialp->getSpecularID().asString(); + specularMapRowParams.columns.add(cellParams); + + cellParams.font = LLFontGL::getFontSansSerif(); + + materialp->getSpecularOffset(x, y); + cellParams.column = "specular_map_list_offset_x"; + cellParams.value = llformat("%f", x); + specularMapRowParams.columns.add(cellParams); + cellParams.column = "specular_map_list_offset_y"; + cellParams.value = llformat("%f", y); + specularMapRowParams.columns.add(cellParams); + + materialp->getSpecularRepeat(x, y); + cellParams.column = "specular_map_list_repeat_x"; + cellParams.value = llformat("%f", x); + specularMapRowParams.columns.add(cellParams); + cellParams.column = "specular_map_list_repeat_y"; + cellParams.value = llformat("%f", y); + specularMapRowParams.columns.add(cellParams); + + cellParams.column = "specular_map_list_rotation"; + cellParams.value = llformat("%d", materialp->getSpecularRotation()); + specularMapRowParams.columns.add(cellParams); + + const LLColor4U& specularColor =materialp->getSpecularLightColor(); + cellParams.column = "specular_color"; + cellParams.value = llformat("(%d, %d, %d, %d)", specularColor.mV[0], + specularColor.mV[1], specularColor.mV[2], specularColor.mV[3]); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "specular_exponent"; + cellParams.value = llformat("%d", materialp->getSpecularLightExponent()); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "env_intensity"; + cellParams.value = llformat("%d", materialp->getEnvironmentIntensity()); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "alpha_mask_cutoff"; + cellParams.value = llformat("%d", materialp->getAlphaMaskCutoff()); + otherDataRowParams.columns.add(cellParams); + + cellParams.column = "diffuse_alpha_mode"; + cellParams.value = llformat("%d", materialp->getDiffuseAlphaMode()); + otherDataRowParams.columns.add(cellParams); + + normalMapRowParams.value = cellParams.value; + specularMapRowParams.value = cellParams.value; + otherDataRowParams.value = cellParams.value; + + instancep->mPostNormalMapScrollList->addRow(normalMapRowParams); + instancep->mPostSpecularMapScrollList->addRow(specularMapRowParams); + instancep->mPostOtherDataScrollList->addRow(otherDataRowParams); +} - mPutScrollList->addRow(rowParams); - } - } +void LLFloaterDebugMaterials::setState(EState pState) +{ + mState = pState; + updateStatusMessage(); + updateControls(); } -void LLFloaterDebugMaterials::parsePostResponse(const LLSD& pMultiContent) +void LLFloaterDebugMaterials::refreshObjectEdit() { - clearPostResults(); + mPutScrollList->deleteAllItems(); + + LLScrollListCell::Params cellParams; + LLScrollListItem::Params rowParams; - llassert(pMultiContent.isArray()); - for (LLSD::array_const_iterator contentIter = pMultiContent.beginArray(); - contentIter != pMultiContent.endArray(); ++contentIter) + LLObjectSelectionHandle selectionHandle = LLSelectMgr::getInstance()->getEditSelection(); + for (LLObjectSelection::valid_iterator objectIter = selectionHandle->valid_begin(); + objectIter != selectionHandle->valid_end(); ++objectIter) { - const LLSD& content = *contentIter; + LLSelectNode* nodep = *objectIter; - llassert(content.isMap()); - llassert(content.has(MULTI_MATERIALS_STATUS_FIELD)); - llassert(content.get(MULTI_MATERIALS_STATUS_FIELD).isBoolean()); - if (content.get(MULTI_MATERIALS_STATUS_FIELD).asBoolean()) + LLViewerObject* objectp = nodep->getObject(); + if (objectp != NULL) { - llassert(content.has(MULTI_MATERIALS_DATA_FIELD)); - llassert(content.get(MULTI_MATERIALS_DATA_FIELD).isMap()); - const LLSD& postData = content.get(MULTI_MATERIALS_DATA_FIELD); - - llassert(postData.has(MATERIALS_CAP_ZIP_FIELD)); - llassert(postData.get(MATERIALS_CAP_ZIP_FIELD).isBinary()); - - LLSD::Binary postDataBinary = postData.get(MATERIALS_CAP_ZIP_FIELD).asBinary(); - S32 postDataSize = static_cast<S32>(postDataBinary.size()); - std::string postDataString(reinterpret_cast<const char*>(postDataBinary.data()), postDataSize); - - std::istringstream postDataStream(postDataString); - - LLSD unzippedPostData; - if (!unzip_llsd(unzippedPostData, postDataStream, postDataSize)) - { - LL_ERRS("debugMaterials") << "cannot unzip LLSD binary content" << LL_ENDL; - } - - LLScrollListCell::Params cellParams; - LLScrollListItem::Params normalMapRowParams; - LLScrollListItem::Params specularMapRowParams; - LLScrollListItem::Params otherDataRowParams; - - llassert(unzippedPostData.isArray()); - for (LLSD::array_const_iterator materialIter = unzippedPostData.beginArray(); - materialIter != unzippedPostData.endArray(); ++materialIter) + S32 numTEs = llmin(static_cast<S32>(objectp->getNumTEs()), objectp->getNumFaces()); + for (S32 curTEIndex = 0; curTEIndex < numTEs; ++curTEIndex) { - const LLSD &material = *materialIter; - llassert(material.isMap()); - llassert(material.has(MATERIALS_CAP_OBJECT_ID_FIELD)); - llassert(material.get(MATERIALS_CAP_OBJECT_ID_FIELD).isBinary()); - const LLSD &materialIdLLSD = material.get(MATERIALS_CAP_OBJECT_ID_FIELD); - LLMaterialID materialID(materialIdLLSD); - std::string materialIDString = materialID.asString(); - - llassert(material.has(MATERIALS_CAP_MATERIAL_FIELD)); - const LLSD &materialData = material.get(MATERIALS_CAP_MATERIAL_FIELD); - llassert(materialData.isMap()); - - llassert(materialData.has(MATERIALS_CAP_NORMAL_MAP_FIELD)); - llassert(materialData.get(MATERIALS_CAP_NORMAL_MAP_FIELD).isUUID()); - const LLUUID &normalMapID = materialData.get(MATERIALS_CAP_NORMAL_MAP_FIELD).asUUID(); - - llassert(materialData.has(MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD)); - llassert(materialData.get(MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD).isInteger()); - S32 normalMapOffsetX = materialData.get(MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD)); - llassert(materialData.get(MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD).isInteger()); - S32 normalMapOffsetY = materialData.get(MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD)); - llassert(materialData.get(MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD).isInteger()); - S32 normalMapRepeatX = materialData.get(MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD)); - llassert(materialData.get(MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD).isInteger()); - S32 normalMapRepeatY = materialData.get(MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD)); - llassert(materialData.get(MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD).isInteger()); - S32 normalMapRotation = materialData.get(MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_MAP_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_MAP_FIELD).isUUID()); - const LLUUID &specularMapID = materialData.get(MATERIALS_CAP_SPECULAR_MAP_FIELD).asUUID(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD).isInteger()); - S32 specularMapOffsetX = materialData.get(MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD).isInteger()); - S32 specularMapOffsetY = materialData.get(MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD).isInteger()); - S32 specularMapRepeatX = materialData.get(MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD).isInteger()); - S32 specularMapRepeatY = materialData.get(MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD).isInteger()); - S32 specularMapRotation = materialData.get(MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_COLOR_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_COLOR_FIELD).isArray()); - LLColor4U specularColor; - specularColor.setValue(materialData.get(MATERIALS_CAP_SPECULAR_COLOR_FIELD)); - - llassert(materialData.has(MATERIALS_CAP_SPECULAR_EXP_FIELD)); - llassert(materialData.get(MATERIALS_CAP_SPECULAR_EXP_FIELD).isInteger()); - S32 specularExp = materialData.get(MATERIALS_CAP_SPECULAR_EXP_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_ENV_INTENSITY_FIELD)); - llassert(materialData.get(MATERIALS_CAP_ENV_INTENSITY_FIELD).isInteger()); - S32 envIntensity = materialData.get(MATERIALS_CAP_ENV_INTENSITY_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD)); - llassert(materialData.get(MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD).isInteger()); - S32 alphaMaskCutoff = materialData.get(MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD).asInteger(); - - llassert(materialData.has(MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD)); - llassert(materialData.get(MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD).isInteger()); - S32 diffuseAlphaMode = materialData.get(MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD).asInteger(); - - cellParams.font = LLFontGL::getFontMonospace(); - - cellParams.column = "id"; - cellParams.value = materialIDString; - normalMapRowParams.columns.add(cellParams); - specularMapRowParams.columns.add(cellParams); - otherDataRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_map"; - cellParams.value = normalMapID.asString(); - normalMapRowParams.columns.add(cellParams); - - cellParams.font = LLFontGL::getFontSansSerif(); - - cellParams.column = "normal_map_list_offset_x"; - cellParams.value = llformat("%d", normalMapOffsetX); - normalMapRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_offset_y"; - cellParams.value = llformat("%d", normalMapOffsetY); - normalMapRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_repeat_x"; - cellParams.value = llformat("%d", normalMapRepeatX); - normalMapRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_repeat_y"; - cellParams.value = llformat("%d", normalMapRepeatY); - normalMapRowParams.columns.add(cellParams); - - cellParams.column = "normal_map_list_rotation"; - cellParams.value = llformat("%d", normalMapRotation); - normalMapRowParams.columns.add(cellParams); - - cellParams.font = LLFontGL::getFontMonospace(); - - cellParams.column = "specular_map_list_map"; - cellParams.value = specularMapID.asString(); - specularMapRowParams.columns.add(cellParams); - - cellParams.font = LLFontGL::getFontSansSerif(); - - cellParams.column = "specular_map_list_offset_x"; - cellParams.value = llformat("%d", specularMapOffsetX); - specularMapRowParams.columns.add(cellParams); - - cellParams.column = "specular_map_list_offset_y"; - cellParams.value = llformat("%d", specularMapOffsetY); - specularMapRowParams.columns.add(cellParams); - - cellParams.column = "specular_map_list_repeat_x"; - cellParams.value = llformat("%d", specularMapRepeatX); - specularMapRowParams.columns.add(cellParams); - - cellParams.column = "specular_map_list_repeat_y"; - cellParams.value = llformat("%d", specularMapRepeatY); - specularMapRowParams.columns.add(cellParams); - - cellParams.column = "specular_map_list_rotation"; - cellParams.value = llformat("%d", specularMapRotation); - specularMapRowParams.columns.add(cellParams); - - cellParams.column = "specular_color"; - cellParams.value = llformat("(%d, %d, %d, %d)", specularColor.mV[0], - specularColor.mV[1], specularColor.mV[2], specularColor.mV[3]); - otherDataRowParams.columns.add(cellParams); + if (nodep->isTESelected(curTEIndex)) + { + const LLTextureEntry* tep = objectp->getTE(curTEIndex); - cellParams.column = "specular_exponent"; - cellParams.value = llformat("%d", specularExp); - otherDataRowParams.columns.add(cellParams); + cellParams.font = LLFontGL::getFontMonospace(); - cellParams.column = "env_intensity"; - cellParams.value = llformat("%d", envIntensity); - otherDataRowParams.columns.add(cellParams); + cellParams.column = "material_id"; + cellParams.value = tep->getMaterialID().asString(); + rowParams.columns.add(cellParams); - cellParams.column = "alpha_mask_cutoff"; - cellParams.value = llformat("%d", alphaMaskCutoff); - otherDataRowParams.columns.add(cellParams); + cellParams.font = LLFontGL::getFontSansSerif(); - cellParams.column = "diffuse_alpha_mode"; - cellParams.value = llformat("%d", diffuseAlphaMode); - otherDataRowParams.columns.add(cellParams); + cellParams.column = "object_id"; + cellParams.value = objectp->getID().asString(); + rowParams.columns.add(cellParams); - normalMapRowParams.value = materialIDString; - specularMapRowParams.value = materialIDString; - otherDataRowParams.value = materialIDString; + cellParams.column = "face_index"; + cellParams.value = llformat("%d", curTEIndex); + rowParams.columns.add(cellParams); - mPostNormalMapScrollList->addRow(normalMapRowParams); - mPostSpecularMapScrollList->addRow(specularMapRowParams); - mPostOtherDataScrollList->addRow(otherDataRowParams); + mPutScrollList->addRow(rowParams); + } } } } } -void LLFloaterDebugMaterials::setState(EState pState) -{ - mState = pState; - updateStatusMessage(); - updateControls(); -} - void LLFloaterDebugMaterials::resetObjectEditInputs() { const LLSD zeroValue = static_cast<LLSD::Integer>(0); @@ -1594,12 +1073,6 @@ void LLFloaterDebugMaterials::clearGetResults() mGetNormalMapScrollList->deleteAllItems(); mGetSpecularMapScrollList->deleteAllItems(); mGetOtherDataScrollList->deleteAllItems(); - clearUnparsedGetData(); -} - -void LLFloaterDebugMaterials::clearPutResults() -{ - mPutScrollList->deleteAllItems(); } void LLFloaterDebugMaterials::clearPostResults() @@ -1615,63 +1088,6 @@ void LLFloaterDebugMaterials::clearViewableObjectsResults() clearUnparsedQueryData(); } -void LLFloaterDebugMaterials::setUnparsedGetData(const LLSD& pGetData) -{ - llassert(pGetData.isMap()); - llassert(pGetData.has(MATERIALS_CAP_ZIP_FIELD)); - llassert(pGetData.get(MATERIALS_CAP_ZIP_FIELD).isBinary()); - - LLSD::Binary getDataBinary = pGetData.get(MATERIALS_CAP_ZIP_FIELD).asBinary(); - S32 getDataSize = static_cast<S32>(getDataBinary.size()); - std::string getDataString(reinterpret_cast<const char*>(getDataBinary.data()), getDataSize); - - std::istringstream getDataStream(getDataString); - - llassert(!mUnparsedGetData.isDefined()); - if (!unzip_llsd(mUnparsedGetData, getDataStream, getDataSize)) - { - LL_ERRS("debugMaterials") << "cannot unzip LLSD binary content" << LL_ENDL; - } - mNextUnparsedGetDataIndex = 0; - - updateGetParsingStatus(); -} - -void LLFloaterDebugMaterials::clearUnparsedGetData() -{ - mUnparsedGetData.clear(); - mNextUnparsedGetDataIndex = -1; - - updateGetParsingStatus(); -} - -void LLFloaterDebugMaterials::updateGetParsingStatus() -{ - std::string parsingStatus; - - if (mUnparsedGetData.isDefined()) - { - LLLocale locale(LLStringUtil::getLocale()); - std::string numProcessedString; - LLResMgr::getInstance()->getIntegerString(numProcessedString, mNextUnparsedGetDataIndex); - - std::string numTotalString; - LLResMgr::getInstance()->getIntegerString(numTotalString, mUnparsedGetData.size()); - - LLStringUtil::format_map_t stringArgs; - stringArgs["[NUM_PROCESSED]"] = numProcessedString; - stringArgs["[NUM_TOTAL]"] = numTotalString; - - parsingStatus = getString("loading_status_in_progress", stringArgs); - } - else - { - parsingStatus = getString("loading_status_done"); - } - - mParsingStatusText->setText(static_cast<const LLStringExplicit>(parsingStatus)); -} - void LLFloaterDebugMaterials::setUnparsedQueryData() { mNextUnparsedQueryDataIndex = 0; @@ -1790,168 +1206,40 @@ void LLFloaterDebugMaterials::updateControls() } } -S32 LLFloaterDebugMaterials::getNormalMapOffsetX() const -{ - return getLineEditorValue(mNormalMapOffsetX); -} - -S32 LLFloaterDebugMaterials::getNormalMapOffsetY() const -{ - return getLineEditorValue(mNormalMapOffsetY); -} - -S32 LLFloaterDebugMaterials::getNormalMapRepeatX() const -{ - return getLineEditorValue(mNormalMapRepeatX); -} - -S32 LLFloaterDebugMaterials::getNormalMapRepeatY() const -{ - return getLineEditorValue(mNormalMapRepeatY); -} +template<typename T> T getLineEditorValue(const LLLineEditor *pLineEditor); -S32 LLFloaterDebugMaterials::getNormalMapRotation() const +template<> U8 getLineEditorValue(const LLLineEditor *pLineEditor) { - return getLineEditorValue(mNormalMapRotation); -} + U8 value = 0; -S32 LLFloaterDebugMaterials::getSpecularMapOffsetX() const -{ - return getLineEditorValue(mSpecularMapOffsetX); -} + LLStringUtil::convertToU8(pLineEditor->getText(), value); -S32 LLFloaterDebugMaterials::getSpecularMapOffsetY() const -{ - return getLineEditorValue(mSpecularMapOffsetY); + return value; } -S32 LLFloaterDebugMaterials::getSpecularMapRepeatX() const +LLMaterial LLFloaterDebugMaterials::getMaterial() const { - return getLineEditorValue(mSpecularMapRepeatX); -} + LLMaterial material; -S32 LLFloaterDebugMaterials::getSpecularMapRepeatY() const -{ - return getLineEditorValue(mSpecularMapRepeatY); -} + material.setNormalID(mNormalMap->getImageAssetID()); + material.setNormalOffset(mNormalMapOffsetX->get(), mNormalMapOffsetY->get()); + material.setNormalRepeat(mNormalMapRepeatX->get(), mNormalMapRepeatY->get()); + material.setNormalRotation(mNormalMapRotation->get()); -S32 LLFloaterDebugMaterials::getSpecularMapRotation() const -{ - return getLineEditorValue(mSpecularMapRotation); -} + material.setSpecularID(mSpecularMap->getImageAssetID()); + material.setSpecularOffset(mSpecularMapOffsetX->get(), mSpecularMapOffsetY->get()); + material.setSpecularRepeat(mSpecularMapRepeatX->get(), mSpecularMapRepeatY->get()); + material.setSpecularRotation(mSpecularMapRotation->get()); -LLColor4U LLFloaterDebugMaterials::getSpecularColor() const -{ const LLColor4& specularColor = mSpecularColor->get(); LLColor4U specularColor4U = specularColor; - specularColor4U.setAlpha(static_cast<U8>(llclamp(llround(mSpecularColorAlpha->get()), 0, 255))); + material.setSpecularLightColor(specularColor4U); - return specularColor4U; -} - -S32 LLFloaterDebugMaterials::getSpecularExponent() const -{ - return getLineEditorValue(mSpecularExponent); -} + material.setSpecularLightExponent(getLineEditorValue<U8>(mSpecularExponent)); + material.setEnvironmentIntensity(getLineEditorValue<U8>(mEnvironmentExponent)); + material.setDiffuseAlphaMode(getLineEditorValue<U8>(mDiffuseAlphaMode)); + material.setAlphaMaskCutoff(getLineEditorValue<U8>(mAlphaMaskCutoff)); -S32 LLFloaterDebugMaterials::getEnvironmentExponent() const -{ - return getLineEditorValue(mEnvironmentExponent); -} - -S32 LLFloaterDebugMaterials::getAlphMaskCutoff() const -{ - return getLineEditorValue(mAlphaMaskCutoff); -} - -S32 LLFloaterDebugMaterials::getDiffuseAlphaMode() const -{ - return getLineEditorValue(mDiffuseAlphaMode); -} - -S32 LLFloaterDebugMaterials::getLineEditorValue(const LLLineEditor *pLineEditor) const -{ - S32 value = 0; - - LLStringUtil::convertToS32(pLineEditor->getText(), value); - - return value; -} - -MaterialsResponder::MaterialsResponder(const std::string& pMethod, const std::string& pCapabilityURL, CallbackFunction pCallback) - : LLHTTPClient::Responder(), - mMethod(pMethod), - mCapabilityURL(pCapabilityURL), - mCallback(pCallback) -{ -} - -MaterialsResponder::~MaterialsResponder() -{ -} - -void MaterialsResponder::result(const LLSD& pContent) -{ - mCallback(true, pContent); -} - -void MaterialsResponder::error(U32 pStatus, const std::string& pReason) -{ - LL_WARNS("debugMaterials") << "--------------------------------------------------------------------------" << LL_ENDL; - LL_WARNS("debugMaterials") << mMethod << " Error[" << pStatus << "] cannot access cap '" << MATERIALS_CAPABILITY_NAME - << "' with url '" << mCapabilityURL << "' because " << pReason << LL_ENDL; - LL_WARNS("debugMaterials") << "--------------------------------------------------------------------------" << LL_ENDL; - - LLSD emptyResult; - mCallback(false, emptyResult); -} - -MultiMaterialsResponder::MultiMaterialsResponder(CallbackFunction pCallback, unsigned int pNumRequests) - : mCallback(pCallback), - mNumRequests(pNumRequests), - mRequestStatus(true), - mContent(LLSD::emptyArray()), - mMutex(NULL) -{ - mMutex = new LLMutex(NULL); - llassert(mMutex); -} - -MultiMaterialsResponder::~MultiMaterialsResponder() -{ - llassert(mMutex); - if (mMutex) - { - delete mMutex; - } -} - -void MultiMaterialsResponder::onMaterialsResponse(bool pRequestStatus, const LLSD& pContent) -{ - LLSD result = LLSD::emptyMap(); - - result[MULTI_MATERIALS_STATUS_FIELD] = static_cast<LLSD::Boolean>(pRequestStatus); - result[MULTI_MATERIALS_DATA_FIELD] = pContent; - - if (appendRequestResults(pRequestStatus, result)) - { - fireResponse(); - } -} - -bool MultiMaterialsResponder::appendRequestResults(bool pRequestStatus, const LLSD& pResults) -{ - llassert(mMutex); - LLMutexLock mutexLock(mMutex); - - mRequestStatus = mRequestStatus && pRequestStatus; - mContent.append(pResults); - llassert(mNumRequests > 0U); - return (--mNumRequests == 0U); -} - -void MultiMaterialsResponder::fireResponse() -{ - mCallback(mRequestStatus, mContent); + return material; } diff --git a/indra/newview/llfloaterdebugmaterials.h b/indra/newview/llfloaterdebugmaterials.h index c5179ef6b0..0bd33d7cd0 100644 --- a/indra/newview/llfloaterdebugmaterials.h +++ b/indra/newview/llfloaterdebugmaterials.h @@ -33,6 +33,8 @@ #include <boost/signals2.hpp> #include "llfloater.h" +#include "llmaterial.h" +#include "llmaterialmgr.h" #include "lluuid.h" #include "v4color.h" @@ -94,9 +96,6 @@ private: void onDeferredCheckRegionMaterialStatus(LLUUID regionId); void onDeferredRequestGetMaterials(LLUUID regionId); void onDeferredRequestPutMaterials(LLUUID regionId, bool pIsDoSet); - void onGetResponse(bool pRequestStatus, const LLSD& pContent); - void onPutResponse(bool pRequestStatus, const LLSD& pContent); - void onPostResponse(bool pRequestStatus, const LLSD& pContent); void checkRegionMaterialStatus(); void checkRegionMaterialStatus(const LLUUID& regionId); @@ -107,26 +106,20 @@ private: void requestPutMaterials(bool pIsDoSet); void requestPutMaterials(const LLUUID& regionId, bool pIsDoSet); - void requestPostMaterials(); + static void onGetMaterials(const LLUUID& region_id, const LLMaterialMgr::material_map_t& materials); + static void onPostMaterial(const LLMaterialID& material_id, const LLMaterialPtr materialp); - void parseGetResponse(); - void parsePutResponse(const LLSD& pContent); void parseQueryViewableObjects(); - void parsePostResponse(const LLSD& pMultiContent); void setState(EState pState); inline EState getState() const; + void refreshObjectEdit(); void resetObjectEditInputs(); void clearGetResults(); - void clearPutResults(); void clearPostResults(); void clearViewableObjectsResults(); - void setUnparsedGetData(const LLSD& pGetData); - void clearUnparsedGetData(); - void updateGetParsingStatus(); - void setUnparsedQueryData(); void clearUnparsedQueryData(); void updateQueryParsingStatus(); @@ -134,24 +127,7 @@ private: void updateStatusMessage(); void updateControls(); - S32 getNormalMapOffsetX() const; - S32 getNormalMapOffsetY() const; - S32 getNormalMapRepeatX() const; - S32 getNormalMapRepeatY() const; - S32 getNormalMapRotation() const; - - S32 getSpecularMapOffsetX() const; - S32 getSpecularMapOffsetY() const; - S32 getSpecularMapRepeatX() const; - S32 getSpecularMapRepeatY() const; - S32 getSpecularMapRotation() const; - - LLColor4U getSpecularColor() const; - S32 getSpecularExponent() const; - S32 getEnvironmentExponent() const; - S32 getAlphMaskCutoff() const; - S32 getDiffuseAlphaMode() const; - S32 getLineEditorValue(const LLLineEditor *pLineEditor) const; + LLMaterial getMaterial() const; LLTextBase* mStatusText; LLButton* mGetButton; @@ -160,17 +136,17 @@ private: LLScrollListCtrl* mGetSpecularMapScrollList; LLScrollListCtrl* mGetOtherDataScrollList; LLTextureCtrl* mNormalMap; - LLLineEditor* mNormalMapOffsetX; - LLLineEditor* mNormalMapOffsetY; - LLLineEditor* mNormalMapRepeatX; - LLLineEditor* mNormalMapRepeatY; - LLLineEditor* mNormalMapRotation; + LLSpinCtrl* mNormalMapOffsetX; + LLSpinCtrl* mNormalMapOffsetY; + LLSpinCtrl* mNormalMapRepeatX; + LLSpinCtrl* mNormalMapRepeatY; + LLSpinCtrl* mNormalMapRotation; LLTextureCtrl* mSpecularMap; - LLLineEditor* mSpecularMapOffsetX; - LLLineEditor* mSpecularMapOffsetY; - LLLineEditor* mSpecularMapRepeatX; - LLLineEditor* mSpecularMapRepeatY; - LLLineEditor* mSpecularMapRotation; + LLSpinCtrl* mSpecularMapOffsetX; + LLSpinCtrl* mSpecularMapOffsetY; + LLSpinCtrl* mSpecularMapRepeatX; + LLSpinCtrl* mSpecularMapRepeatY; + LLSpinCtrl* mSpecularMapRotation; LLColorSwatchCtrl* mSpecularColor; LLSpinCtrl* mSpecularColorAlpha; LLLineEditor* mSpecularExponent; @@ -198,11 +174,7 @@ private: boost::signals2::connection mTeleportFailedConnection; boost::signals2::connection mSelectionUpdateConnection; - LLSD mUnparsedGetData; - S32 mNextUnparsedGetDataIndex; - S32 mNextUnparsedQueryDataIndex; - MultiMaterialsResponderPtr mMultiMaterialsResponder; }; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp new file mode 100644 index 0000000000..1daeedb8b0 --- /dev/null +++ b/indra/newview/llmaterialmgr.cpp @@ -0,0 +1,634 @@ +/** + * @file llmaterialmgr.cpp + * @brief Material manager + * + * $LicenseInfo:firstyear=2006&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, 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$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llsdserialize.h" +#include "llsdutil.h" + +#include "llagent.h" +#include "llcallbacklist.h" +#include "llmaterialmgr.h" +#include "llviewerobject.h" +#include "llviewerobjectlist.h" +#include "llviewerregion.h" +#include "llworld.h" + +/** + * Materials cap parameters + */ + +#define MATERIALS_CAPABILITY_NAME "RenderMaterials" + +#define MATERIALS_CAP_ZIP_FIELD "Zipped" + +#define MATERIALS_CAP_FULL_PER_FACE_FIELD "FullMaterialsPerFace" +#define MATERIALS_CAP_FACE_FIELD "Face" +#define MATERIALS_CAP_MATERIAL_FIELD "Material" +#define MATERIALS_CAP_OBJECT_ID_FIELD "ID" +#define MATERIALS_CAP_MATERIAL_ID_FIELD "MaterialID" + +#define MATERIALS_GET_MAX_ENTRIES 50 +#define MATERIALS_GET_TIMEOUT (60.f * 20) +#define MATERIALS_POST_MAX_ENTRIES 50 +#define MATERIALS_POST_TIMEOUT (60.f * 5) + +/** + * LLMaterialsResponder helper class + */ + +class LLMaterialsResponder : public LLHTTPClient::Responder +{ +public: + typedef boost::function<void (bool, const LLSD&)> CallbackFunction; + + LLMaterialsResponder(const std::string& pMethod, const std::string& pCapabilityURL, CallbackFunction pCallback); + virtual ~LLMaterialsResponder(); + + virtual void result(const LLSD& pContent); + virtual void error(U32 pStatus, const std::string& pReason); + +private: + std::string mMethod; + std::string mCapabilityURL; + CallbackFunction mCallback; +}; + +LLMaterialsResponder::LLMaterialsResponder(const std::string& pMethod, const std::string& pCapabilityURL, CallbackFunction pCallback) + : LLHTTPClient::Responder() + , mMethod(pMethod) + , mCapabilityURL(pCapabilityURL) + , mCallback(pCallback) +{ +} + +LLMaterialsResponder::~LLMaterialsResponder() +{ +} + +void LLMaterialsResponder::result(const LLSD& pContent) +{ + mCallback(true, pContent); +} + +void LLMaterialsResponder::error(U32 pStatus, const std::string& pReason) +{ + LL_WARNS("debugMaterials") << "--------------------------------------------------------------------------" << LL_ENDL; + LL_WARNS("debugMaterials") << mMethod << " Error[" << pStatus << "] cannot access cap '" << MATERIALS_CAPABILITY_NAME + << "' with url '" << mCapabilityURL << "' because " << pReason << LL_ENDL; + LL_WARNS("debugMaterials") << "--------------------------------------------------------------------------" << LL_ENDL; + + LLSD emptyResult; + mCallback(false, emptyResult); +} + +/** + * LLMaterialMgr class + */ + +LLMaterialMgr::LLMaterialMgr() +{ + gIdleCallbacks.addFunction(&LLMaterialMgr::onIdle, NULL); + LLWorld::instance().setRegionRemovedCallback(boost::bind(&LLMaterialMgr::onRegionRemoved, this, _1)); +} + +LLMaterialMgr::~LLMaterialMgr() +{ + gIdleCallbacks.deleteFunction(&LLMaterialMgr::onIdle, NULL); +} + +bool LLMaterialMgr::isGetPending(const LLUUID& region_id, const LLMaterialID& material_id) +{ + get_pending_map_t::const_iterator itPending = mGetPending.find(pending_material_t(region_id, material_id)); + return (mGetPending.end() != itPending) && (LLFrameTimer::getTotalSeconds() < itPending->second + MATERIALS_POST_TIMEOUT); +} + +const LLMaterialPtr LLMaterialMgr::get(const LLUUID& region_id, const LLMaterialID& material_id) +{ + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (mMaterials.end() != itMaterial) + { + return itMaterial->second; + } + + if (!isGetPending(region_id, material_id)) + { + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + std::pair<get_queue_t::iterator, bool> ret = mGetQueue.insert(std::pair<LLUUID, material_queue_t>(region_id, material_queue_t())); + itQueue = ret.first; + } + itQueue->second.insert(material_id); + } + return LLMaterialPtr(); +} + +boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LLMaterialID& material_id, LLMaterialMgr::get_callback_t::slot_type cb) +{ + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (itMaterial != mMaterials.end()) + { + get_callback_t signal; + signal.connect(cb); + signal(material_id, itMaterial->second); + return boost::signals2::connection(); + } + + if (!isGetPending(region_id, material_id)) + { + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + if (mGetQueue.end() == itQueue) + { + std::pair<get_queue_t::iterator, bool> ret = mGetQueue.insert(std::pair<LLUUID, material_queue_t>(region_id, material_queue_t())); + itQueue = ret.first; + } + itQueue->second.insert(material_id); + } + + get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); + if (itCallback == mGetCallbacks.end()) + { + std::pair<get_callback_map_t::iterator, bool> ret = mGetCallbacks.insert(std::pair<LLMaterialID, get_callback_t*>(material_id, new get_callback_t())); + itCallback = ret.first; + } + return itCallback->second->connect(cb);; +} + +bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) +{ + getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id); + return (mGetAllPending.end() != itPending) && (LLFrameTimer::getTotalSeconds() < itPending->second + MATERIALS_GET_TIMEOUT); +} + +void LLMaterialMgr::getAll(const LLUUID& region_id) +{ + if (!isGetAllPending(region_id)) + { + mGetAllQueue.insert(region_id); + } +} + +boost::signals2::connection LLMaterialMgr::getAll(const LLUUID& region_id, LLMaterialMgr::getall_callback_t::slot_type cb) +{ + if (!isGetAllPending(region_id)) + { + mGetAllQueue.insert(region_id); + } + + getall_callback_map_t::iterator itCallback = mGetAllCallbacks.find(region_id); + if (mGetAllCallbacks.end() == itCallback) + { + std::pair<getall_callback_map_t::iterator, bool> ret = mGetAllCallbacks.insert(std::pair<LLUUID, getall_callback_t*>(region_id, new getall_callback_t())); + itCallback = ret.first; + } + return itCallback->second->connect(cb);; +} + +void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial& material) +{ + put_queue_t::iterator itQueue = mPutQueue.find(object_id); + if (mPutQueue.end() == itQueue) + { + mPutQueue.insert(std::pair<LLUUID, facematerial_map_t>(object_id, facematerial_map_t())); + itQueue = mPutQueue.find(object_id); + } + + facematerial_map_t::iterator itFace = itQueue->second.find(te); + if (itQueue->second.end() == itFace) + { + itQueue->second.insert(std::pair<U8, LLMaterial>(te, material)); + } + else + { + itFace->second = material; + } +} + +const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LLMaterialID& material_id, const LLSD& material_data) +{ + material_map_t::const_iterator itMaterial = mMaterials.find(material_id); + if (mMaterials.end() == itMaterial) + { + std::pair<material_map_t::const_iterator, bool> ret = mMaterials.insert(std::pair<LLMaterialID, LLMaterialPtr>(material_id, new LLMaterial(material_data))); + itMaterial = ret.first; + } + + mGetPending.erase(pending_material_t(region_id, material_id)); + + get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id); + if (itCallback != mGetCallbacks.end()) + { + (*itCallback->second)(material_id, itMaterial->second); + + delete itCallback->second; + mGetCallbacks.erase(itCallback); + } + + return itMaterial->second; +} + +void LLMaterialMgr::onGetResponse(bool success, const LLSD& content, const LLUUID& region_id) +{ + if (!success) + { + // *TODO: is there any kind of error handling we can do here? + return; + } + + llassert(content.isMap()); + llassert(content.has(MATERIALS_CAP_ZIP_FIELD)); + llassert(content[MATERIALS_CAP_ZIP_FIELD].isBinary()); + + LLSD::Binary content_binary = content[MATERIALS_CAP_ZIP_FIELD].asBinary(); + std::string content_string(reinterpret_cast<const char*>(content_binary.data()), content_binary.size()); + std::istringstream content_stream(content_string); + + LLSD response_data; + if (!unzip_llsd(response_data, content_stream, content_binary.size())) + { + LL_ERRS("debugMaterials") << "Cannot unzip LLSD binary content" << LL_ENDL; + return; + } + + llassert(response_data.isArray()); + for (LLSD::array_const_iterator itMaterial = response_data.beginArray(); itMaterial != response_data.endArray(); ++itMaterial) + { + const LLSD& material_data = *itMaterial; + llassert(material_data.isMap()); + + llassert(material_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); + llassert(material_data[MATERIALS_CAP_OBJECT_ID_FIELD].isBinary()); + LLMaterialID material_id(material_data[MATERIALS_CAP_OBJECT_ID_FIELD].asBinary()); + + llassert(material_data.has(MATERIALS_CAP_MATERIAL_FIELD)); + llassert(material_data[MATERIALS_CAP_MATERIAL_FIELD].isMap()); + + setMaterial(region_id, material_id, material_data[MATERIALS_CAP_MATERIAL_FIELD]); + } +} + +void LLMaterialMgr::onGetAllResponse(bool success, const LLSD& content, const LLUUID& region_id) +{ + if (!success) + { + // *TODO: is there any kind of error handling we can do here? + return; + } + + llassert(content.isMap()); + llassert(content.has(MATERIALS_CAP_ZIP_FIELD)); + llassert(content[MATERIALS_CAP_ZIP_FIELD].isBinary()); + + LLSD::Binary content_binary = content[MATERIALS_CAP_ZIP_FIELD].asBinary(); + std::string content_string(reinterpret_cast<const char*>(content_binary.data()), content_binary.size()); + std::istringstream content_stream(content_string); + + LLSD response_data; + if (!unzip_llsd(response_data, content_stream, content_binary.size())) + { + LL_ERRS("debugMaterials") << "Cannot unzip LLSD binary content" << LL_ENDL; + return; + } + + get_queue_t::iterator itQueue = mGetQueue.find(region_id); + material_map_t materials; + + llassert(response_data.isArray()); + for (LLSD::array_const_iterator itMaterial = response_data.beginArray(); itMaterial != response_data.endArray(); ++itMaterial) + { + const LLSD& material_data = *itMaterial; + llassert(material_data.isMap()); + + llassert(material_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); + llassert(material_data[MATERIALS_CAP_OBJECT_ID_FIELD].isBinary()); + LLMaterialID material_id(material_data[MATERIALS_CAP_OBJECT_ID_FIELD].asBinary()); + if (mGetQueue.end() != itQueue) + { + itQueue->second.erase(material_id); + } + + llassert(material_data.has(MATERIALS_CAP_MATERIAL_FIELD)); + llassert(material_data[MATERIALS_CAP_MATERIAL_FIELD].isMap()); + LLMaterialPtr material = setMaterial(region_id, material_id, material_data[MATERIALS_CAP_MATERIAL_FIELD]); + + materials[material_id] = material; + } + + getall_callback_map_t::iterator itCallback = mGetAllCallbacks.find(region_id); + if (itCallback != mGetAllCallbacks.end()) + { + (*itCallback->second)(region_id, materials); + + delete itCallback->second; + mGetAllCallbacks.erase(itCallback); + } + + if ( (mGetQueue.end() != itQueue) && (itQueue->second.empty()) ) + { + mGetQueue.erase(itQueue); + } + mGetAllRequested.insert(region_id); + mGetAllPending.erase(region_id); // Invalidates region_id +} + +void LLMaterialMgr::onPutResponse(bool success, const LLSD& content) +{ + if (!success) + { + // *TODO: is there any kind of error handling we can do here? + return; + } + + llassert(content.isMap()); + llassert(content.has(MATERIALS_CAP_ZIP_FIELD)); + llassert(content[MATERIALS_CAP_ZIP_FIELD].isBinary()); + + LLSD::Binary content_binary = content[MATERIALS_CAP_ZIP_FIELD].asBinary(); + std::string content_string(reinterpret_cast<const char*>(content_binary.data()), content_binary.size()); + std::istringstream content_stream(content_string); + + LLSD response_data; + if (!unzip_llsd(response_data, content_stream, content_binary.size())) + { + LL_ERRS("debugMaterials") << "Cannot unzip LLSD binary content" << LL_ENDL; + return; + } + else + { + llassert(response_data.isArray()); + + for (LLSD::array_const_iterator faceIter = response_data.beginArray(); faceIter != response_data.endArray(); ++faceIter) + { + const LLSD& face_data = *faceIter; + llassert(face_data.isMap()); + + llassert(face_data.has(MATERIALS_CAP_OBJECT_ID_FIELD)); + llassert(face_data[MATERIALS_CAP_OBJECT_ID_FIELD].isInteger()); +// U32 local_id = face_data[MATERIALS_CAP_OBJECT_ID_FIELD].asInteger(); + + llassert(face_data.has(MATERIALS_CAP_FACE_FIELD)); + llassert(face_data[MATERIALS_CAP_FACE_FIELD].isInteger()); +// S32 te = face_data[MATERIALS_CAP_FACE_FIELD].asInteger(); + + llassert(face_data.has(MATERIALS_CAP_MATERIAL_ID_FIELD)); + llassert(face_data[MATERIALS_CAP_MATERIAL_ID_FIELD].isBinary()); +// LLMaterialID material_id(face_data[MATERIALS_CAP_MATERIAL_ID_FIELD].asBinary()); + + // *TODO: do we really still need to process this? + } + } +} + +static LLFastTimer::DeclareTimer FTM_MATERIALS_IDLE("Materials"); + +void LLMaterialMgr::onIdle(void*) +{ + LLFastTimer t(FTM_MATERIALS_IDLE); + + LLMaterialMgr* instancep = LLMaterialMgr::getInstance(); + + if (!instancep->mGetQueue.empty()) + { + instancep->processGetQueue(); + } + + if (!instancep->mGetAllQueue.empty()) + { + instancep->processGetAllQueue(); + } + + if (!instancep->mPutQueue.empty()) + { + instancep->processPutQueue(); + } +} + +void LLMaterialMgr::processGetQueue() +{ + get_queue_t::iterator loopRegionQueue = mGetQueue.begin(); + while (mGetQueue.end() != loopRegionQueue) + { + get_queue_t::iterator itRegionQueue = loopRegionQueue++; + + const LLUUID& region_id = itRegionQueue->first; + if (isGetAllPending(region_id)) + { + continue; + } + + const LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); + if (!regionp) + { + LL_WARNS("debugMaterials") << "Unknown region with id " << region_id.asString() << LL_ENDL; + mGetQueue.erase(itRegionQueue); + continue; + } + else if (!regionp->capabilitiesReceived()) + { + continue; + } + else if (mGetAllRequested.end() == mGetAllRequested.find(region_id)) + { + getAll(region_id); + continue; + } + + const std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); + if (capURL.empty()) + { + LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME + << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; + mGetQueue.erase(itRegionQueue); + continue; + } + + LLSD materialsData = LLSD::emptyArray(); + + material_queue_t& materials = itRegionQueue->second; + material_queue_t::iterator loopMaterial = materials.begin(); + while ( (materials.end() != loopMaterial) && (materialsData.size() <= MATERIALS_GET_MAX_ENTRIES) ) + { + material_queue_t::iterator itMaterial = loopMaterial++; + materialsData.append((*itMaterial).asLLSD()); + materials.erase(itMaterial); + mGetPending.insert(std::pair<pending_material_t, F64>(pending_material_t(region_id, *itMaterial), LLFrameTimer::getTotalSeconds())); + } + + std::string materialString = zip_llsd(materialsData); + + S32 materialSize = materialString.size(); + if (materialSize <= 0) + { + LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; + return; + } + + LLSD::Binary materialBinary; + materialBinary.resize(materialSize); + memcpy(materialBinary.data(), materialString.data(), materialSize); + + LLSD postData = LLSD::emptyMap(); + postData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; + + LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("POST", capURL, boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2, region_id)); + LLHTTPClient::post(capURL, postData, materialsResponder); + } +} + +void LLMaterialMgr::processGetAllQueue() +{ + getall_queue_t::iterator loopRegion = mGetAllQueue.begin(); + while (mGetAllQueue.end() != loopRegion) + { + getall_queue_t::iterator itRegion = loopRegion++; + + const LLUUID& region_id = *itRegion; + LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); + if (regionp == NULL) + { + LL_WARNS("debugMaterials") << "Unknown region with id " << region_id.asString() << LL_ENDL; + mGetAllQueue.erase(itRegion); + continue; + } + else if (!regionp->capabilitiesReceived()) + { + continue; + } + + std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); + if (capURL.empty()) + { + LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME + << "' is not defined on the current region '" << regionp->getName() << "'" << LL_ENDL; + mGetAllQueue.erase(itRegion); + continue; + } + + LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("GET", capURL, boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *itRegion)); + LLHTTPClient::get(capURL, materialsResponder); + mGetAllPending.insert(std::pair<LLUUID, F64>(region_id, LLFrameTimer::getTotalSeconds())); + mGetAllQueue.erase(itRegion); // Invalidates region_id + } +} + +void LLMaterialMgr::processPutQueue() +{ + put_queue_t::iterator loopQueue = mPutQueue.begin(); + while (mPutQueue.end() != loopQueue) + { + put_queue_t::iterator itQueue = loopQueue++; + + const LLUUID& object_id = itQueue->first; + const LLViewerObject* objectp = gObjectList.findObject(object_id); + if ( (!objectp) || (!objectp->getRegion()) ) + { + LL_WARNS("debugMaterials") << "Object or object region is NULL" << LL_ENDL; + + mPutQueue.erase(itQueue); + continue; + } + + const LLViewerRegion* regionp = objectp->getRegion(); + if (!regionp->capabilitiesReceived()) + { + continue; + } + + std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); + if (capURL.empty()) + { + LL_WARNS("debugMaterials") << "Capability '" << MATERIALS_CAPABILITY_NAME + << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; + + mPutQueue.erase(itQueue); + continue; + } + + LLSD facesData = LLSD::emptyArray(); + for (facematerial_map_t::const_iterator itFace = itQueue->second.begin(); itFace != itQueue->second.end(); ++itFace) + { + LLSD faceData = LLSD::emptyMap(); + faceData[MATERIALS_CAP_FACE_FIELD] = static_cast<LLSD::Integer>(itFace->first); + faceData[MATERIALS_CAP_OBJECT_ID_FIELD] = static_cast<LLSD::Integer>(objectp->getLocalID()); + if (!itFace->second.isNull()) + { + faceData[MATERIALS_CAP_MATERIAL_FIELD] = itFace->second.asLLSD(); + } + facesData.append(faceData); + } + + LLSD materialsData = LLSD::emptyMap(); + materialsData[MATERIALS_CAP_FULL_PER_FACE_FIELD] = facesData; + + std::string materialString = zip_llsd(materialsData); + + S32 materialSize = materialString.size(); + if (materialSize <= 0) + { + LL_ERRS("debugMaterials") << "cannot zip LLSD binary content" << LL_ENDL; + + mPutQueue.erase(itQueue); + continue; + } + else + { + LLSD::Binary materialBinary; + materialBinary.resize(materialSize); + memcpy(materialBinary.data(), materialString.data(), materialSize); + + LLSD putData = LLSD::emptyMap(); + putData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; + + LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("PUT", capURL, boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2)); + LLHTTPClient::put(capURL, putData, materialsResponder); + } + } +} + +void LLMaterialMgr::onRegionRemoved(LLViewerRegion* regionp) +{ + const LLUUID& region_id = regionp->getRegionID(); + + // Get + mGetQueue.erase(region_id); + for (get_pending_map_t::const_iterator itPending = mGetPending.begin(); itPending != mGetPending.end();) + { + if (region_id == itPending->first.first) + mGetPending.erase(itPending++); + else + ++itPending; + } + + // Get all + mGetAllQueue.erase(region_id); + mGetAllRequested.erase(region_id); + mGetAllPending.erase(region_id); + mGetAllCallbacks.erase(region_id); + + // Put +// mPutQueue.erase(region_id); +} diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h new file mode 100644 index 0000000000..5a0064ae27 --- /dev/null +++ b/indra/newview/llmaterialmgr.h @@ -0,0 +1,93 @@ +/** + * @file llmaterialmgr.h + * @brief Material manager + * + * $LicenseInfo:firstyear=2006&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, 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_LLMATERIALMGR_H +#define LL_LLMATERIALMGR_H + +#include "llmaterial.h" +#include "llmaterialid.h" +#include "llsingleton.h" + +class LLViewerRegion; + +class LLMaterialMgr : public LLSingleton<LLMaterialMgr> +{ + friend LLSingleton<LLMaterialMgr>; +protected: + LLMaterialMgr(); + virtual ~LLMaterialMgr(); + +public: + typedef std::map<LLMaterialID, LLMaterialPtr> material_map_t; + + typedef boost::signals2::signal<void (const LLMaterialID&, const LLMaterialPtr)> get_callback_t; + const LLMaterialPtr get(const LLUUID& region_id, const LLMaterialID& material_id); + boost::signals2::connection get(const LLUUID& region_id, const LLMaterialID& material_id, get_callback_t::slot_type cb); + typedef boost::signals2::signal<void (const LLUUID&, const material_map_t&)> getall_callback_t; + void getAll(const LLUUID& region_id); + boost::signals2::connection getAll(const LLUUID& region_id, getall_callback_t::slot_type cb); + void put(const LLUUID& object_id, const U8 te, const LLMaterial& material); + +protected: + bool isGetPending(const LLUUID& region_id, const LLMaterialID& material_id); + bool isGetAllPending(const LLUUID& region_id); + const LLMaterialPtr setMaterial(const LLUUID& region_id, const LLMaterialID& material_id, const LLSD& material_data); + + static void onIdle(void*); + void processGetQueue(); + void onGetResponse(bool success, const LLSD& content, const LLUUID& region_id); + void processGetAllQueue(); + void onGetAllResponse(bool success, const LLSD& content, const LLUUID& region_id); + void processPutQueue(); + void onPutResponse(bool success, const LLSD& content); + void onRegionRemoved(LLViewerRegion* regionp); + +protected: + typedef std::set<LLMaterialID> material_queue_t; + typedef std::map<LLUUID, material_queue_t> get_queue_t; + get_queue_t mGetQueue; + typedef std::pair<LLUUID, LLMaterialID> pending_material_t; + typedef std::map<pending_material_t, F64> get_pending_map_t; + get_pending_map_t mGetPending; + typedef std::map<LLMaterialID, get_callback_t*> get_callback_map_t; + get_callback_map_t mGetCallbacks; + + typedef std::set<LLUUID> getall_queue_t; + getall_queue_t mGetAllQueue; + getall_queue_t mGetAllRequested; + typedef std::map<LLUUID, F64> getall_pending_map_t; + getall_pending_map_t mGetAllPending; + typedef std::map<LLUUID, getall_callback_t*> getall_callback_map_t; + getall_callback_map_t mGetAllCallbacks; + + typedef std::map<U8, LLMaterial> facematerial_map_t; + typedef std::map<LLUUID, facematerial_map_t> put_queue_t; + put_queue_t mPutQueue; + + material_map_t mMaterials; +}; + +#endif // LL_LLMATERIALMGR_H diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 78ee3e4fd9..604f7f2b56 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -275,7 +275,9 @@ void LLWorld::removeRegion(const LLHost &host) mActiveRegionList.remove(regionp); mCulledRegionList.remove(regionp); mVisibleRegionList.remove(regionp); - + + mRegionRemovedSignal(regionp); + delete regionp; updateWaterObjects(); @@ -403,6 +405,19 @@ LLViewerRegion* LLWorld::getRegionFromHandle(const U64 &handle) return NULL; } +LLViewerRegion* LLWorld::getRegionFromID(const LLUUID& region_id) +{ + for (region_list_t::iterator iter = mRegionList.begin(); + iter != mRegionList.end(); ++iter) + { + LLViewerRegion* regionp = *iter; + if (regionp->getRegionID() == region_id) + { + return regionp; + } + } + return NULL; +} void LLWorld::updateAgentOffset(const LLVector3d &offset_global) { @@ -1246,6 +1261,11 @@ bool LLWorld::isRegionListed(const LLViewerRegion* region) const return it != mRegionList.end(); } +boost::signals2::connection LLWorld::setRegionRemovedCallback(const region_remove_signal_t::slot_type& cb) +{ + return mRegionRemovedSignal.connect(cb); +} + LLHTTPRegistration<LLEstablishAgentCommunication> gHTTPRegistrationEstablishAgentCommunication( "/message/EstablishAgentCommunication"); diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h index f350009d10..d0b001ba44 100644 --- a/indra/newview/llworld.h +++ b/indra/newview/llworld.h @@ -76,6 +76,7 @@ public: LLViewerRegion* getRegionFromPosGlobal(const LLVector3d &pos); LLViewerRegion* getRegionFromPosAgent(const LLVector3 &pos); LLViewerRegion* getRegionFromHandle(const U64 &handle); + LLViewerRegion* getRegionFromID(const LLUUID& region_id); BOOL positionRegionValidGlobal(const LLVector3d& pos); // true if position is in valid region LLVector3d clipToVisibleRegions(const LLVector3d &start_pos, const LLVector3d &end_pos); @@ -149,6 +150,9 @@ public: typedef std::list<LLViewerRegion*> region_list_t; const region_list_t& getRegionList() const { return mActiveRegionList; } + typedef boost::signals2::signal<void(LLViewerRegion*)> region_remove_signal_t; + boost::signals2::connection setRegionRemovedCallback(const region_remove_signal_t::slot_type& cb); + // Returns lists of avatar IDs and their world-space positions within a given distance of a point. // All arguments are optional. Given containers will be emptied and then filled. // Not supplying origin or radius input returns data on all avatars in the known regions. @@ -168,6 +172,8 @@ private: region_list_t mVisibleRegionList; region_list_t mCulledRegionList; + region_remove_signal_t mRegionRemovedSignal; + // Number of points on edge static const U32 mWidth; diff --git a/indra/newview/skins/default/xui/en/floater_debug_materials.xml b/indra/newview/skins/default/xui/en/floater_debug_materials.xml index afa93c3618..3a450fdeff 100644 --- a/indra/newview/skins/default/xui/en/floater_debug_materials.xml +++ b/indra/newview/skins/default/xui/en/floater_debug_materials.xml @@ -302,136 +302,85 @@ mouse_opaque="true" name="normal_map" tool_tip="Click to open texture picker" /> - <text - height="13" - word_wrap="false" - use_ellipses="false" - type="string" - text_color="LabelTextColor" - length="1" - follows="left|top" - layout="topleft" - left_pad="-260" - top_pad="10" - width="160"> - Normal Map Offset X - </text> - <line_editor - border_style="line" - border_thickness="1" - default_text="0" + <spinner + allow_text_entry="true" follows="left|top" height="20" + initial_value="0" + increment="0.1" + decimal_digits="4" + label_width="160" layout="topleft" - left_pad="0" - top_pad="-18" - max_length_chars="255" + left_pad="-260" + label="Normal Map Offset X" + max_val="1.0" + min_val="-1.0" name="normal_map_offset_x" - width="80" /> - <text - height="13" - word_wrap="false" - use_ellipses="false" - type="string" - text_color="LabelTextColor" - length="1" - follows="left|top" - layout="topleft" - left_pad="-240" - top_pad="10" - width="160"> - Normal Map Offset Y - </text> - <line_editor - border_style="line" - border_thickness="1" - default_text="0" + width="240" /> + <spinner + allow_text_entry="true" follows="left|top" height="20" - layout="topleft" - left_pad="0" - top_pad="-18" - max_length_chars="255" - name="normal_map_offset_y" - width="80" /> - <text - height="13" - word_wrap="false" - use_ellipses="false" - type="string" - text_color="LabelTextColor" - length="1" - follows="left|top" + initial_value="0" + increment="0.1" + decimal_digits="4" + label_width="160" layout="topleft" left_pad="-240" + label="Normal Map Offset Y" + max_val="1.0" + min_val="-1.0" + name="normal_map_offset_y" top_pad="10" - width="160"> - Normal Map Repeat X - </text> - <line_editor - border_style="line" - border_thickness="1" - default_text="0" + width="240" /> + <spinner + allow_text_entry="true" follows="left|top" height="20" - layout="topleft" - left_pad="0" - top_pad="-18" - max_length_chars="255" - name="normal_map_repeat_x" - width="80" /> - <text - height="13" - word_wrap="false" - use_ellipses="false" - type="string" - text_color="LabelTextColor" - length="1" - follows="left|top" + initial_value="0" + increment="0.1" + decimal_digits="4" + label_width="160" layout="topleft" left_pad="-240" + label="Normal Map Repeat X" + max_val="64" + min_val="0.0" + name="normal_map_repeat_x" top_pad="10" - width="160"> - Normal Map Repeat Y - </text> - <line_editor - border_style="line" - border_thickness="1" - default_text="0" + width="240" /> + <spinner + allow_text_entry="true" follows="left|top" height="20" - layout="topleft" - left_pad="0" - top_pad="-18" - max_length_chars="255" - name="normal_map_repeat_y" - width="80" /> - <text - height="13" - word_wrap="false" - use_ellipses="false" - type="string" - text_color="LabelTextColor" - length="1" - follows="left|top" + initial_value="0" + increment="0.1" + decimal_digits="4" + label_width="160" layout="topleft" left_pad="-240" + max_val="64" + min_val="0.0" + label="Normal Map Repeat Y" + name="normal_map_repeat_y" top_pad="10" - width="160"> - Normal Map Rotation - </text> - <line_editor - border_style="line" - border_thickness="1" - default_text="0" + width="240" /> + <spinner + allow_text_entry="true" follows="left|top" height="20" + initial_value="0" + increment="1" + decimal_digits="4" + label_width="160" layout="topleft" - left_pad="0" - top_pad="-18" - max_length_chars="255" + left_pad="-240" + label="Normal Map Rotation" + max_val="9999" + min_val="-9999" name="normal_map_rotation" - width="80" /> + top_pad="10" + width="240" /> </panel> <panel border="false" @@ -469,136 +418,85 @@ mouse_opaque="true" name="specular_map" tool_tip="Click to open texture picker" /> - <text - height="13" - word_wrap="false" - use_ellipses="false" - type="string" - text_color="LabelTextColor" - length="1" - follows="left|top" - layout="topleft" - left_pad="-260" - top_pad="10" - width="160"> - Specular Map Offset X - </text> - <line_editor - border_style="line" - border_thickness="1" - default_text="0" + <spinner + allow_text_entry="true" follows="left|top" height="20" + initial_value="0" + increment="0.1" + decimal_digits="4" + label_width="160" layout="topleft" - left_pad="0" - top_pad="-18" - max_length_chars="255" + left_pad="-260" + label="Specular Map Offset X" + max_val="1.0" + min_val="-1.0" name="specular_map_offset_x" - width="80" /> - <text - height="13" - word_wrap="false" - use_ellipses="false" - type="string" - text_color="LabelTextColor" - length="1" - follows="left|top" - layout="topleft" - left_pad="-240" - top_pad="10" - width="160"> - Specular Map Offset Y - </text> - <line_editor - border_style="line" - border_thickness="1" - default_text="0" + width="240" /> + <spinner + allow_text_entry="true" follows="left|top" height="20" - layout="topleft" - left_pad="0" - top_pad="-18" - max_length_chars="255" - name="specular_map_offset_y" - width="80" /> - <text - height="13" - word_wrap="false" - use_ellipses="false" - type="string" - text_color="LabelTextColor" - length="1" - follows="left|top" + initial_value="0" + increment="0.1" + decimal_digits="4" + label_width="160" layout="topleft" left_pad="-240" + label="Specular Map Offset Y" + max_val="1.0" + min_val="-1.0" + name="specular_map_offset_y" top_pad="10" - width="160"> - Specular Map Repeat X - </text> - <line_editor - border_style="line" - border_thickness="1" - default_text="0" + width="240" /> + <spinner + allow_text_entry="true" follows="left|top" height="20" - layout="topleft" - left_pad="0" - top_pad="-18" - max_length_chars="255" - name="specular_map_repeat_x" - width="80" /> - <text - height="13" - word_wrap="false" - use_ellipses="false" - type="string" - text_color="LabelTextColor" - length="1" - follows="left|top" + initial_value="0" + increment="0.1" + decimal_digits="4" + label_width="160" layout="topleft" left_pad="-240" + label="Specular Map Repeat X" + max_val="64" + min_val="0.0" + name="specular_map_repeat_x" top_pad="10" - width="160"> - Specular Map Repeat Y - </text> - <line_editor - border_style="line" - border_thickness="1" - default_text="0" + width="240" /> + <spinner + allow_text_entry="true" follows="left|top" height="20" - layout="topleft" - left_pad="0" - top_pad="-18" - max_length_chars="255" - name="specular_map_repeat_y" - width="80" /> - <text - height="13" - word_wrap="false" - use_ellipses="false" - type="string" - text_color="LabelTextColor" - length="1" - follows="left|top" + initial_value="0" + increment="0.1" + decimal_digits="4" + label_width="160" layout="topleft" left_pad="-240" + label="Specular Map Repeat Y" + max_val="64" + min_val="0.0" + name="specular_map_repeat_y" top_pad="10" - width="160"> - Specular Map Rotation - </text> - <line_editor - border_style="line" - border_thickness="1" - default_text="0" + width="240" /> + <spinner + allow_text_entry="true" follows="left|top" height="20" + initial_value="0" + increment="1" + decimal_digits="4" + label_width="160" layout="topleft" - left_pad="0" - top_pad="-18" - max_length_chars="255" + left_pad="-240" + label="Specular Map Rotation" + max_val="9999" + min_val="-9999" name="specular_map_rotation" - width="80" /> + top_pad="10" + width="240" /> </panel> <panel border="false" @@ -822,24 +720,24 @@ left="0" top_pad="0" width="160"> - Results + Active selection </text> <scroll_list column_padding="0" draw_heading="true" follows="left|top|right" - height="100" + height="300" layout="topleft" left="0" top_pad="10" tab_stop="false" multi_select="true" name="put_scroll_list" - width="400"> + width="600"> <scroll_list.columns label="Object ID" name="object_id" - width="80" /> + width="225" /> <scroll_list.columns label="Face Index" name="face_index" |