From f84f821df7a0edf472420995ae3e5140bbf05996 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Tue, 9 Oct 2012 17:59:46 -0700 Subject: Adding ability to edit materials per face. --- indra/newview/llfloaterdebugmaterials.cpp | 73 +++++++++++++++++-------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/indra/newview/llfloaterdebugmaterials.cpp b/indra/newview/llfloaterdebugmaterials.cpp index 8e37736394..da1068d879 100644 --- a/indra/newview/llfloaterdebugmaterials.cpp +++ b/indra/newview/llfloaterdebugmaterials.cpp @@ -600,6 +600,32 @@ void LLFloaterDebugMaterials::requestPutMaterials(bool pIsDoSet) LLSD facesData = LLSD::emptyArray(); + LLSD materialData = LLSD::emptyMap(); + if (pIsDoSet) + { + materialData[MATERIALS_CAP_NORMAL_MAP_FIELD] = mNormalMap->getImageAssetID(); + materialData[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = static_cast(getNormalMapOffsetX()); + materialData[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = static_cast(getNormalMapOffsetY()); + materialData[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = static_cast(getNormalMapRepeatX()); + materialData[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = static_cast(getNormalMapRepeatY()); + materialData[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = static_cast(getNormalMapRotation()); + + materialData[MATERIALS_CAP_SPECULAR_MAP_FIELD] = mSpecularMap->getImageAssetID(); + materialData[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = static_cast(getSpecularMapOffsetX()); + materialData[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = static_cast(getSpecularMapOffsetY()); + materialData[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = static_cast(getSpecularMapRepeatX()); + materialData[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = static_cast(getSpecularMapRepeatY()); + materialData[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = static_cast(getSpecularMapRotation()); + + const LLColor4& specularColor = mSpecularColor->get(); + LLColor4U specularColor4U = specularColor; + materialData[MATERIALS_CAP_SPECULAR_COLOR_FIELD] = specularColor4U.getValue(); + + materialData[MATERIALS_CAP_SPECULAR_EXP_FIELD] = static_cast(getSpecularExponent()); + materialData[MATERIALS_CAP_ENV_INTENSITY_FIELD] = static_cast(getEnvironmentExponent()); + materialData[MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD] = static_cast(getAlphMaskCutoff()); + materialData[MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD] = static_cast(getDiffuseAlphaMode()); + } LLObjectSelectionHandle selectionHandle = LLSelectMgr::getInstance()->getEditSelection(); for (LLObjectSelection::valid_iterator objectIter = selectionHandle->valid_begin(); @@ -608,42 +634,23 @@ void LLFloaterDebugMaterials::requestPutMaterials(bool pIsDoSet) LLSelectNode* objectNode = *objectIter; LLViewerObject* viewerObject = objectNode->getObject(); - S32 numFaces = viewerObject->getNumFaces(); - for (S32 curFaceIndex = 0; curFaceIndex < numFaces; ++curFaceIndex) + if (viewerObject != NULL) { - LLSD materialData = LLSD::emptyMap(); - - materialData[MATERIALS_CAP_NORMAL_MAP_FIELD] = mNormalMap->getImageAssetID(); - materialData[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = static_cast(getNormalMapOffsetX()); - materialData[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = static_cast(getNormalMapOffsetY()); - materialData[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = static_cast(getNormalMapRepeatX()); - materialData[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = static_cast(getNormalMapRepeatY()); - materialData[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = static_cast(getNormalMapRotation()); - - materialData[MATERIALS_CAP_SPECULAR_MAP_FIELD] = mSpecularMap->getImageAssetID(); - materialData[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = static_cast(getSpecularMapOffsetX()); - materialData[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = static_cast(getSpecularMapOffsetY()); - materialData[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = static_cast(getSpecularMapRepeatX()); - materialData[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = static_cast(getSpecularMapRepeatY()); - materialData[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = static_cast(getSpecularMapRotation()); - - const LLColor4& specularColor = mSpecularColor->get(); - LLColor4U specularColor4U = specularColor; - materialData[MATERIALS_CAP_SPECULAR_COLOR_FIELD] = specularColor4U.getValue(); - - materialData[MATERIALS_CAP_SPECULAR_EXP_FIELD] = static_cast(getSpecularExponent()); - materialData[MATERIALS_CAP_ENV_INTENSITY_FIELD] = static_cast(getEnvironmentExponent()); - materialData[MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD] = static_cast(getAlphMaskCutoff()); - materialData[MATERIALS_CAP_DIFFUSE_ALPHA_MODE_FIELD] = static_cast(getDiffuseAlphaMode()); - - LLSD faceData = LLSD::emptyMap(); - faceData[MATERIALS_CAP_FACE_FIELD] = static_cast(curFaceIndex); - faceData[MATERIALS_CAP_OBJECT_ID_FIELD] = static_cast(viewerObject->getLocalID()); - if (pIsDoSet) + S32 numTEs = llmin(static_cast(viewerObject->getNumTEs()), viewerObject->getNumFaces()); + for (S32 curTEIndex = 0; curTEIndex < numTEs; ++curTEIndex) { - faceData[MATERIALS_CAP_MATERIAL_FIELD] = materialData; + if (objectNode->isTESelected(curTEIndex)) + { + LLSD faceData = LLSD::emptyMap(); + faceData[MATERIALS_CAP_FACE_FIELD] = static_cast(curTEIndex); + faceData[MATERIALS_CAP_OBJECT_ID_FIELD] = static_cast(viewerObject->getLocalID()); + if (pIsDoSet) + { + faceData[MATERIALS_CAP_MATERIAL_FIELD] = materialData; + } + facesData.append(faceData); + } } - facesData.append(faceData); } } -- cgit v1.2.3