summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorKitty Barnett <develop@catznip.com>2012-12-02 00:31:17 +0100
committerKitty Barnett <develop@catznip.com>2012-12-02 00:31:17 +0100
commitfd3af97a01ef5ed6c07fb0eef9e705f01725a95a (patch)
treeaad64317d75a148821001bbaa1adc8c15b3a57c6 /indra
parent1bfeddc0039c7a18cdd878c4fcc3a51529eb1019 (diff)
parent6618cff96c75bd0183b173c30ec818404038c2dd (diff)
Pull and merge from https://bitbucket.org/lindenlab/viewer-development
Diffstat (limited to 'indra')
-rw-r--r--indra/llprimitive/CMakeLists.txt2
-rw-r--r--indra/llprimitive/llmaterial.cpp147
-rw-r--r--indra/llprimitive/llmaterial.h94
-rw-r--r--indra/newview/llfloaterdebugmaterials.cpp382
-rw-r--r--indra/newview/llfloaterdebugmaterials.h20
5 files changed, 333 insertions, 312 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..36d958ede5
--- /dev/null
+++ b/indra/llprimitive/llmaterial.cpp
@@ -0,0 +1,147 @@
+/**
+ * @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_MULT_OFFSETREPEAT = 10000.f;
+const F32 MATERIALS_MULT_ROTATION = 1000.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
+ */
+
+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_MULT_OFFSETREPEAT);
+ material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = llround(mNormalOffsetY * MATERIALS_MULT_OFFSETREPEAT);
+ material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = llround(mNormalRepeatX * MATERIALS_MULT_OFFSETREPEAT);
+ material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = llround(mNormalRepeatY * MATERIALS_MULT_OFFSETREPEAT);
+ material_data[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = llround(mNormalRotation * MATERIALS_MULT_ROTATION);
+
+ material_data[MATERIALS_CAP_SPECULAR_MAP_FIELD] = mSpecularID;
+ material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = llround(mSpecularOffsetX * MATERIALS_MULT_OFFSETREPEAT);
+ material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = llround(mSpecularOffsetY * MATERIALS_MULT_OFFSETREPEAT);
+ material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = llround(mSpecularRepeatX * MATERIALS_MULT_OFFSETREPEAT);
+ material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = llround(mSpecularRepeatY * MATERIALS_MULT_OFFSETREPEAT);
+ material_data[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = llround(mSpecularRotation * MATERIALS_MULT_ROTATION);
+
+ 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_ALPHA_MASK_CUTOFF_FIELD] = mDiffuseAlphaMode;
+ material_data[MATERIALS_CAP_DIFFUSE_ALPHA_MODE_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_MULT_OFFSETREPEAT;
+ mNormalOffsetY = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT;
+ mNormalRepeatX = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT;
+ mNormalRepeatY = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT;
+ mNormalRotation = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_ROTATION;
+
+ 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_MULT_OFFSETREPEAT;
+ mSpecularOffsetY = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT;
+ mSpecularRepeatX = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT;
+ mSpecularRepeatY = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_OFFSETREPEAT;
+ mSpecularRotation = (F32)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD, LLSD::TypeInteger) / MATERIALS_MULT_ROTATION;
+
+ 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_ALPHA_MASK_CUTOFF_FIELD, LLSD::TypeInteger);
+ mAlphaMaskCutoff = (U8)getMaterialField<LLSD::Integer>(material_data, MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD, LLSD::TypeInteger);
+}
diff --git a/indra/llprimitive/llmaterial.h b/indra/llprimitive/llmaterial.h
new file mode 100644
index 0000000000..d50ab30195
--- /dev/null
+++ b/indra/llprimitive/llmaterial.h
@@ -0,0 +1,94 @@
+/**
+ * @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 "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; }
+
+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;
+};
+
+#endif // LL_LLMATERIAL_H
diff --git a/indra/newview/llfloaterdebugmaterials.cpp b/indra/newview/llfloaterdebugmaterials.cpp
index 3420665883..c23a5a6426 100644
--- a/indra/newview/llfloaterdebugmaterials.cpp
+++ b/indra/newview/llfloaterdebugmaterials.cpp
@@ -46,6 +46,7 @@
#include "llfontgl.h"
#include "llhttpclient.h"
#include "lllineeditor.h"
+#include "llmaterial.h"
#include "llmaterialid.h"
#include "llresmgr.h"
#include "llscrolllistcell.h"
@@ -81,26 +82,6 @@
#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"
@@ -763,26 +744,8 @@ void LLFloaterDebugMaterials::requestPutMaterials(bool pIsDoSet)
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 = getMaterial();
+ materialData = material.asLLSD();
}
LLObjectSelectionHandle selectionHandle = LLSelectMgr::getInstance()->getEditSelection();
@@ -1086,85 +1049,20 @@ void LLFloaterDebugMaterials::parseGetResponse()
(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 &materialID = material.get(MATERIALS_CAP_OBJECT_ID_FIELD);
+ const LLSD &material_entry = *materialIter;
+ llassert(material_entry.isMap());
+ llassert(material_entry.has(MATERIALS_CAP_OBJECT_ID_FIELD));
+ llassert(material_entry.get(MATERIALS_CAP_OBJECT_ID_FIELD).isBinary());
+ const LLSD &materialID = material_entry.get(MATERIALS_CAP_OBJECT_ID_FIELD);
std::string materialIDString = convertToPrintableMaterialID(materialID);
- llassert(material.has(MATERIALS_CAP_MATERIAL_FIELD));
- const LLSD &materialData = material.get(MATERIALS_CAP_MATERIAL_FIELD);
+ llassert(material_entry.has(MATERIALS_CAP_MATERIAL_FIELD));
+ const LLSD &materialData = material_entry.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();
+ LLMaterial material(materialData);
- 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();
+ F32 x, y;
cellParams.font = LLFontGL::getFontMonospace();
@@ -1175,78 +1073,80 @@ void LLFloaterDebugMaterials::parseGetResponse()
otherDataRowParams.columns.add(cellParams);
cellParams.column = "normal_map_list_map";
- cellParams.value = normalMapID.asString();
+ 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("%d", normalMapOffsetX);
+ cellParams.value = llformat("%f", x);
normalMapRowParams.columns.add(cellParams);
-
cellParams.column = "normal_map_list_offset_y";
- cellParams.value = llformat("%d", normalMapOffsetY);
+ cellParams.value = llformat("%f", y);
normalMapRowParams.columns.add(cellParams);
+ material.getNormalRepeat(x, y);
cellParams.column = "normal_map_list_repeat_x";
- cellParams.value = llformat("%d", normalMapRepeatX);
+ cellParams.value = llformat("%f", x);
normalMapRowParams.columns.add(cellParams);
-
cellParams.column = "normal_map_list_repeat_y";
- cellParams.value = llformat("%d", normalMapRepeatY);
+ cellParams.value = llformat("%f", y);
normalMapRowParams.columns.add(cellParams);
cellParams.column = "normal_map_list_rotation";
- cellParams.value = llformat("%d", normalMapRotation);
+ cellParams.value = llformat("%f", material.getNormalRotation());
normalMapRowParams.columns.add(cellParams);
cellParams.font = LLFontGL::getFontMonospace();
cellParams.column = "specular_map_list_map";
- cellParams.value = specularMapID.asString();
+ 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("%d", specularMapOffsetX);
+ cellParams.value = llformat("%f", x);
specularMapRowParams.columns.add(cellParams);
-
cellParams.column = "specular_map_list_offset_y";
- cellParams.value = llformat("%d", specularMapOffsetY);
+ cellParams.value = llformat("%f", y);
specularMapRowParams.columns.add(cellParams);
+ material.getSpecularRepeat(x, y);
cellParams.column = "specular_map_list_repeat_x";
- cellParams.value = llformat("%d", specularMapRepeatX);
+ cellParams.value = llformat("%f", x);
specularMapRowParams.columns.add(cellParams);
cellParams.column = "specular_map_list_repeat_y";
- cellParams.value = llformat("%d", specularMapRepeatY);
+ cellParams.value = llformat("%f", y);
specularMapRowParams.columns.add(cellParams);
cellParams.column = "specular_map_list_rotation";
- cellParams.value = llformat("%d", specularMapRotation);
+ cellParams.value = llformat("%d", 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", specularExp);
+ cellParams.value = llformat("%d", material.getSpecularLightExponent());
otherDataRowParams.columns.add(cellParams);
cellParams.column = "env_intensity";
- cellParams.value = llformat("%d", envIntensity);
+ cellParams.value = llformat("%d", material.getEnvironmentIntensity());
otherDataRowParams.columns.add(cellParams);
cellParams.column = "alpha_mask_cutoff";
- cellParams.value = llformat("%d", alphaMaskCutoff);
+ cellParams.value = llformat("%d", material.getAlphaMaskCutoff());
otherDataRowParams.columns.add(cellParams);
cellParams.column = "diffuse_alpha_mode";
- cellParams.value = llformat("%d", diffuseAlphaMode);
+ cellParams.value = llformat("%d", material.getDiffuseAlphaMode());
otherDataRowParams.columns.add(cellParams);
normalMapRowParams.value = materialIDString;
@@ -1377,85 +1277,20 @@ void LLFloaterDebugMaterials::parsePostResponse(const LLSD& pMultiContent)
for (LLSD::array_const_iterator materialIter = unzippedPostData.beginArray();
materialIter != unzippedPostData.endArray(); ++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 &materialID = material.get(MATERIALS_CAP_OBJECT_ID_FIELD);
+ const LLSD &material_entry = *materialIter;
+ llassert(material_entry.isMap());
+ llassert(material_entry.has(MATERIALS_CAP_OBJECT_ID_FIELD));
+ llassert(material_entry.get(MATERIALS_CAP_OBJECT_ID_FIELD).isBinary());
+ const LLSD &materialID = material_entry.get(MATERIALS_CAP_OBJECT_ID_FIELD);
std::string materialIDString = convertToPrintableMaterialID(materialID);
- llassert(material.has(MATERIALS_CAP_MATERIAL_FIELD));
- const LLSD &materialData = material.get(MATERIALS_CAP_MATERIAL_FIELD);
+ llassert(material_entry.has(MATERIALS_CAP_MATERIAL_FIELD));
+ const LLSD &materialData = material_entry.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();
+ LLMaterial material(materialData);
- 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();
+ F32 x, y;
cellParams.font = LLFontGL::getFontMonospace();
@@ -1466,78 +1301,79 @@ void LLFloaterDebugMaterials::parsePostResponse(const LLSD& pMultiContent)
otherDataRowParams.columns.add(cellParams);
cellParams.column = "normal_map_list_map";
- cellParams.value = normalMapID.asString();
+ 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("%d", normalMapOffsetX);
+ cellParams.value = llformat("%f", x);
normalMapRowParams.columns.add(cellParams);
-
cellParams.column = "normal_map_list_offset_y";
- cellParams.value = llformat("%d", normalMapOffsetY);
+ cellParams.value = llformat("%f", y);
normalMapRowParams.columns.add(cellParams);
+ material.getNormalRepeat(x, y);
cellParams.column = "normal_map_list_repeat_x";
- cellParams.value = llformat("%d", normalMapRepeatX);
+ cellParams.value = llformat("%f", x);
normalMapRowParams.columns.add(cellParams);
-
cellParams.column = "normal_map_list_repeat_y";
- cellParams.value = llformat("%d", normalMapRepeatY);
+ cellParams.value = llformat("%f", y);
normalMapRowParams.columns.add(cellParams);
cellParams.column = "normal_map_list_rotation";
- cellParams.value = llformat("%d", normalMapRotation);
+ cellParams.value = llformat("%f", material.getNormalRotation());
normalMapRowParams.columns.add(cellParams);
cellParams.font = LLFontGL::getFontMonospace();
cellParams.column = "specular_map_list_map";
- cellParams.value = specularMapID.asString();
+ 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("%d", specularMapOffsetX);
+ cellParams.value = llformat("%f", x);
specularMapRowParams.columns.add(cellParams);
-
cellParams.column = "specular_map_list_offset_y";
- cellParams.value = llformat("%d", specularMapOffsetY);
+ cellParams.value = llformat("%f", y);
specularMapRowParams.columns.add(cellParams);
+ material.getSpecularRepeat(x, y);
cellParams.column = "specular_map_list_repeat_x";
- cellParams.value = llformat("%d", specularMapRepeatX);
+ cellParams.value = llformat("%f", x);
specularMapRowParams.columns.add(cellParams);
-
cellParams.column = "specular_map_list_repeat_y";
- cellParams.value = llformat("%d", specularMapRepeatY);
+ cellParams.value = llformat("%f", y);
specularMapRowParams.columns.add(cellParams);
cellParams.column = "specular_map_list_rotation";
- cellParams.value = llformat("%d", specularMapRotation);
+ cellParams.value = llformat("%d", 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", specularExp);
+ cellParams.value = llformat("%d", material.getSpecularLightExponent());
otherDataRowParams.columns.add(cellParams);
cellParams.column = "env_intensity";
- cellParams.value = llformat("%d", envIntensity);
+ cellParams.value = llformat("%d", material.getEnvironmentIntensity());
otherDataRowParams.columns.add(cellParams);
cellParams.column = "alpha_mask_cutoff";
- cellParams.value = llformat("%d", alphaMaskCutoff);
+ cellParams.value = llformat("%d", material.getAlphaMaskCutoff());
otherDataRowParams.columns.add(cellParams);
cellParams.column = "diffuse_alpha_mode";
- cellParams.value = llformat("%d", diffuseAlphaMode);
+ cellParams.value = llformat("%d", material.getDiffuseAlphaMode());
otherDataRowParams.columns.add(cellParams);
normalMapRowParams.value = materialIDString;
@@ -1824,93 +1660,51 @@ std::string LLFloaterDebugMaterials::convertToPrintableMaterialID(const LLMateri
return materialIDString;
}
-S32 LLFloaterDebugMaterials::getNormalMapOffsetX() const
-{
- return getLineEditorValue(mNormalMapOffsetX);
-}
+template<typename T> T getLineEditorValue(const LLLineEditor *pLineEditor);
-S32 LLFloaterDebugMaterials::getNormalMapOffsetY() const
+template<> F32 getLineEditorValue(const LLLineEditor *pLineEditor)
{
- return getLineEditorValue(mNormalMapOffsetY);
-}
+ F32 value = 0;
-S32 LLFloaterDebugMaterials::getNormalMapRepeatX() const
-{
- return getLineEditorValue(mNormalMapRepeatX);
-}
+ LLStringUtil::convertToF32(pLineEditor->getText(), value);
-S32 LLFloaterDebugMaterials::getNormalMapRepeatY() const
-{
- return getLineEditorValue(mNormalMapRepeatY);
+ return value;
}
-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(getLineEditorValue<F32>(mNormalMapOffsetX), getLineEditorValue<F32>(mNormalMapOffsetY));
+ material.setNormalRepeat(getLineEditorValue<F32>(mNormalMapRepeatX), getLineEditorValue<F32>(mNormalMapRepeatY));
+ material.setNormalRotation(getLineEditorValue<F32>(mNormalMapRotation));
-S32 LLFloaterDebugMaterials::getSpecularMapRotation() const
-{
- return getLineEditorValue(mSpecularMapRotation);
-}
+ material.setSpecularID(mSpecularMap->getImageAssetID());
+ material.setSpecularOffset(getLineEditorValue<F32>(mSpecularMapOffsetX), getLineEditorValue<F32>(mSpecularMapOffsetY));
+ material.setSpecularRepeat(getLineEditorValue<F32>(mSpecularMapRepeatX), getLineEditorValue<F32>(mSpecularMapRepeatY));
+ material.setSpecularRotation(getLineEditorValue<F32>(mSpecularMapRotation));
-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);
-}
-
-S32 LLFloaterDebugMaterials::getEnvironmentExponent() const
-{
- return getLineEditorValue(mEnvironmentExponent);
-}
-
-S32 LLFloaterDebugMaterials::getAlphMaskCutoff() const
-{
- return getLineEditorValue(mAlphaMaskCutoff);
-}
-
-S32 LLFloaterDebugMaterials::getDiffuseAlphaMode() const
-{
- return getLineEditorValue(mDiffuseAlphaMode);
-}
+ material.setSpecularLightExponent(getLineEditorValue<U8>(mSpecularExponent));
+ material.setEnvironmentIntensity(getLineEditorValue<U8>(mEnvironmentExponent));
+ material.setDiffuseAlphaMode(getLineEditorValue<U8>(mDiffuseAlphaMode));
+ material.setAlphaMaskCutoff(getLineEditorValue<U8>(mAlphaMaskCutoff));
-S32 LLFloaterDebugMaterials::getLineEditorValue(const LLLineEditor *pLineEditor) const
-{
- S32 value = 0;
-
- LLStringUtil::convertToS32(pLineEditor->getText(), value);
-
- return value;
+ return material;
}
MaterialsResponder::MaterialsResponder(const std::string& pMethod, const std::string& pCapabilityURL, CallbackFunction pCallback)
diff --git a/indra/newview/llfloaterdebugmaterials.h b/indra/newview/llfloaterdebugmaterials.h
index 565e440187..7fc077dd34 100644
--- a/indra/newview/llfloaterdebugmaterials.h
+++ b/indra/newview/llfloaterdebugmaterials.h
@@ -40,6 +40,7 @@ class LLButton;
class LLColorSwatchCtrl;
class LLColor4U;
class LLLineEditor;
+class LLMaterial;
class LLMaterialID;
class LLScrollListCtrl;
class LLSD;
@@ -136,24 +137,7 @@ private:
std::string convertToPrintableMaterialID(const LLSD& pBinaryHash) const;
std::string convertToPrintableMaterialID(const LLMaterialID& pMaterialID) const;
- 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;