diff options
author | Graham Madarasz <graham@lindenlab.com> | 2013-06-08 06:28:48 -0700 |
---|---|---|
committer | Graham Madarasz <graham@lindenlab.com> | 2013-06-08 06:28:48 -0700 |
commit | eba7eb2d062c43cd83cb6972e4e05dc54d409582 (patch) | |
tree | 61b5da4999e2164d765830f5916c20ff7ea6b2bd | |
parent | c78cd1aae63a7c7c0bf6a9c21380818aa9cd47b7 (diff) |
NORSPEC-233 fix default value and material apply logic errors
-rw-r--r-- | indra/llprimitive/llmaterial.cpp | 20 | ||||
-rwxr-xr-x | indra/newview/llface.cpp | 6 | ||||
-rwxr-xr-x | indra/newview/llpanelface.h | 111 |
3 files changed, 78 insertions, 59 deletions
diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index ce443dea1d..cf4c645cfd 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -91,16 +91,16 @@ template<> LLUUID getMaterialField(const LLSD& data, const std::string& field, c const LLMaterial LLMaterial::null; LLMaterial::LLMaterial() - : mNormalOffsetX(.0f) - , mNormalOffsetY(.0f) - , mNormalRepeatX(.0f) - , mNormalRepeatY(.0f) - , mNormalRotation(.0f) - , mSpecularOffsetX(.0f) - , mSpecularOffsetY(.0f) - , mSpecularRepeatX(.0f) - , mSpecularRepeatY(.0f) - , mSpecularRotation(.0f) + : mNormalOffsetX(0.0f) + , mNormalOffsetY(0.0f) + , mNormalRepeatX(1.0f) + , mNormalRepeatY(1.0f) + , mNormalRotation(0.0f) + , mSpecularOffsetX(0.0f) + , mSpecularOffsetY(0.0f) + , mSpecularRepeatX(1.0f) + , mSpecularRepeatY(1.0f) + , mSpecularRotation(0.0f) , mSpecularLightColor(LLMaterial::DEFAULT_SPECULAR_LIGHT_COLOR) , mSpecularLightExponent(LLMaterial::DEFAULT_SPECULAR_LIGHT_EXPONENT) , mEnvironmentIntensity(LLMaterial::DEFAULT_ENV_INTENSITY) diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 46d6a1a97f..3e503cb750 100755 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1655,8 +1655,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (mat && !do_bump) { - do_bump = mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1) || - mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD2); + do_bump = mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1) + || mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD2); } bool do_tex_mat = tex_mode && mTextureMatrix; @@ -1780,7 +1780,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, std::vector<LLVector2> bump_tc; - if (mat) + if (mat && !mat->getNormalID().isNull()) { //writing out normal and specular texture coordinates, not bump offsets do_bump = false; } diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 8d267fe723..b6a8df19fe 100755 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -235,6 +235,15 @@ private: LLMaterialPtr new_material(!current_material.isNull() ? new LLMaterial(current_material->asLLSD()) : new LLMaterial()); llassert_always(new_material); + // Determine correct alpha mode for current diffuse texture + // (i.e. does it have an alpha channel that makes alpha mode useful) + // + U8 default_alpha_mode = (_panel->isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE); + + // Default to matching expected state of UI + // + new_material->setDiffuseAlphaMode(default_alpha_mode); + // Do "It"! // _edit->apply(new_material); @@ -243,10 +252,10 @@ private: LLUUID new_normal_map_id = new_material->getNormalID(); LLUUID new_spec_map_id = new_material->getSpecularID(); - bool is_default_blend_mode = (new_alpha_mode == (_panel->isAlpha() ? LLMaterial::DIFFUSE_ALPHA_MODE_BLEND : LLMaterial::DIFFUSE_ALPHA_MODE_NONE)); + bool is_default_blend_mode = (new_alpha_mode == default_alpha_mode); bool is_need_material = !is_default_blend_mode || !new_normal_map_id.isNull() || !new_spec_map_id.isNull(); - if (!current_material.isNull() && !is_need_material) + if (!is_need_material) { LL_DEBUGS("Materials") << "Removing material from object " << object->getID() << " face " << face << LL_ENDL; LLMaterialMgr::getInstance()->remove(object->getID(),face); @@ -259,7 +268,6 @@ private: { U8 current_alpha_mode = _panel->getCurrentDiffuseAlphaMode(); U8 current_alpha_mask_cutoff = _panel->getCurrentAlphaMaskCutoff(); - new_material->setDiffuseAlphaMode(current_alpha_mode); new_material->setAlphaMaskCutoff(current_alpha_mask_cutoff); } @@ -283,13 +291,16 @@ private: typename DataType, typename ReturnType, ReturnType (LLMaterial::* const MaterialGetFunc)() const > - static void getTEMaterialValue(DataType& data_to_return, bool& identical) + static void getTEMaterialValue(DataType& data_to_return, bool& identical,DataType default_value) { struct GetTEMaterialVal : public LLSelectedTEGetFunctor<DataType> { + GetTEMaterialVal(DataType default_value) : _default(default_value) {} + virtual ~GetTEMaterialVal() {} + DataType get(LLViewerObject* object, S32 face) { - DataType ret = DataType(); + DataType ret = _default; LLMaterialPtr material_ptr; LLTextureEntry* tep = object ? object->getTE(face) : NULL; if (tep) @@ -302,7 +313,8 @@ private: } return ret; } - } GetFunc; + DataType _default; + } GetFunc(default_value); identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &GetFunc, data_to_return); } @@ -310,15 +322,19 @@ private: typename DataType, typename ReturnType, // some kids just have to different... ReturnType (LLTextureEntry::* const TEGetFunc)() const > - static void getTEValue(DataType& data_to_return, bool& identical) + static void getTEValue(DataType& data_to_return, bool& identical, DataType default_value) { struct GetTEVal : public LLSelectedTEGetFunctor<DataType> { + GetTEVal(DataType default_value) : _default(default_value) {} + virtual ~GetTEVal() {} + DataType get(LLViewerObject* object, S32 face) { LLTextureEntry* tep = object ? object->getTE(face) : NULL; - return tep ? ((tep->*(TEGetFunc))()) : DataType(); + return tep ? ((tep->*(TEGetFunc))()) : _default; } - } GetTEValFunc; + DataType _default; + } GetTEValFunc(default_value); identical = LLSelectMgr::getInstance()->getSelection()->getSelectedTEValue( &GetTEValFunc, data_to_return ); } @@ -359,29 +375,32 @@ private: #undef DEF_GET_TE_STATE #endif + #if defined(DEF_EDIT_MAT_STATE) + DEF_EDIT_MAT_STATE + #endif + // Accessors for selected TE material state // - #define DEF_GET_MAT_STATE(DataType,ReturnType,MaterialMemberFunc) \ - static void MaterialMemberFunc(DataType& data, bool& identical) \ - { \ - getTEMaterialValue< DataType, ReturnType, &LLMaterial::MaterialMemberFunc >(data, identical); \ + #define DEF_GET_MAT_STATE(DataType,ReturnType,MaterialMemberFunc,DefaultValue) \ + static void MaterialMemberFunc(DataType& data, bool& identical) \ + { \ + getTEMaterialValue< DataType, ReturnType, &LLMaterial::MaterialMemberFunc >(data, identical,DefaultValue); \ } // Mutators for selected TE material // - #define DEF_EDIT_MAT_STATE(DataType,ReturnType,MaterialMemberFunc) \ - static void MaterialMemberFunc(LLPanelFace* p,DataType data) \ - { \ - edit< DataType, ReturnType, &LLMaterial::MaterialMemberFunc >(p,data); \ + #define DEF_EDIT_MAT_STATE(DataType,ReturnType,MaterialMemberFunc) \ + static void MaterialMemberFunc(LLPanelFace* p,DataType data) \ + { \ + edit< DataType, ReturnType, &LLMaterial::MaterialMemberFunc >(p,data); \ } - // Accessors for selected TE state proper (legacy settings etc) // - #define DEF_GET_TE_STATE(DataType,ReturnType,TexEntryMemberFunc) \ - static void TexEntryMemberFunc(DataType& data, bool& identical) \ - { \ - getTEValue< DataType, ReturnType, &LLTextureEntry::TexEntryMemberFunc >(data, identical); \ + #define DEF_GET_TE_STATE(DataType,ReturnType,TexEntryMemberFunc,DefaultValue) \ + static void TexEntryMemberFunc(DataType& data, bool& identical) \ + { \ + getTEValue< DataType, ReturnType, &LLTextureEntry::TexEntryMemberFunc >(data, identical,DefaultValue); \ } class LLSelectedTEMaterial @@ -391,21 +410,21 @@ private: static void getMaxSpecularRepeats(F32& repeats, bool& identical); static void getMaxNormalRepeats(F32& repeats, bool& identical); - DEF_GET_MAT_STATE(LLUUID,const LLUUID&,getNormalID) - DEF_GET_MAT_STATE(LLUUID,const LLUUID&,getSpecularID) - DEF_GET_MAT_STATE(U8,U8,getDiffuseAlphaMode) + DEF_GET_MAT_STATE(LLUUID,const LLUUID&,getNormalID,LLUUID::null) + DEF_GET_MAT_STATE(LLUUID,const LLUUID&,getSpecularID,LLUUID::null) + DEF_GET_MAT_STATE(U8,U8,getDiffuseAlphaMode,LLMaterial::DIFFUSE_ALPHA_MODE_NONE) - DEF_GET_MAT_STATE(F32,F32,getSpecularRepeatX) - DEF_GET_MAT_STATE(F32,F32,getSpecularRepeatY) - DEF_GET_MAT_STATE(F32,F32,getSpecularOffsetX) - DEF_GET_MAT_STATE(F32,F32,getSpecularOffsetY) - DEF_GET_MAT_STATE(F32,F32,getSpecularRotation) + DEF_GET_MAT_STATE(F32,F32,getSpecularRepeatX,1.0f) + DEF_GET_MAT_STATE(F32,F32,getSpecularRepeatY,1.0f) + DEF_GET_MAT_STATE(F32,F32,getSpecularOffsetX,0.0f) + DEF_GET_MAT_STATE(F32,F32,getSpecularOffsetY,0.0f) + DEF_GET_MAT_STATE(F32,F32,getSpecularRotation,0.0f) - DEF_GET_MAT_STATE(F32,F32,getNormalRepeatX) - DEF_GET_MAT_STATE(F32,F32,getNormalRepeatY) - DEF_GET_MAT_STATE(F32,F32,getNormalOffsetX) - DEF_GET_MAT_STATE(F32,F32,getNormalOffsetY) - DEF_GET_MAT_STATE(F32,F32,getNormalRotation) + DEF_GET_MAT_STATE(F32,F32,getNormalRepeatX,1.0f) + DEF_GET_MAT_STATE(F32,F32,getNormalRepeatY,1.0f) + DEF_GET_MAT_STATE(F32,F32,getNormalOffsetX,0.0f) + DEF_GET_MAT_STATE(F32,F32,getNormalOffsetY,0.0f) + DEF_GET_MAT_STATE(F32,F32,getNormalRotation,0.0f) DEF_EDIT_MAT_STATE(U8,U8,setDiffuseAlphaMode); DEF_EDIT_MAT_STATE(U8,U8,setAlphaMaskCutoff); @@ -441,17 +460,17 @@ private: static void getObjectScaleT(F32& scale_t, bool& identical); static void getMaxDiffuseRepeats(F32& repeats, bool& identical); - DEF_GET_TE_STATE(U8,U8,getBumpmap) - DEF_GET_TE_STATE(U8,U8,getShiny) - DEF_GET_TE_STATE(U8,U8,getFullbright) - DEF_GET_TE_STATE(F32,F32,getRotation) - DEF_GET_TE_STATE(F32,F32,getOffsetS) - DEF_GET_TE_STATE(F32,F32,getOffsetT) - DEF_GET_TE_STATE(F32,F32,getScaleS) - DEF_GET_TE_STATE(F32,F32,getScaleT) - DEF_GET_TE_STATE(F32,F32,getGlow) - DEF_GET_TE_STATE(LLTextureEntry::e_texgen,LLTextureEntry::e_texgen,getTexGen) - DEF_GET_TE_STATE(LLColor4,const LLColor4&,getColor) + DEF_GET_TE_STATE(U8,U8,getBumpmap,0) + DEF_GET_TE_STATE(U8,U8,getShiny,0) + DEF_GET_TE_STATE(U8,U8,getFullbright,0) + DEF_GET_TE_STATE(F32,F32,getRotation,0.0f) + DEF_GET_TE_STATE(F32,F32,getOffsetS,0.0f) + DEF_GET_TE_STATE(F32,F32,getOffsetT,0.0f) + DEF_GET_TE_STATE(F32,F32,getScaleS,1.0f) + DEF_GET_TE_STATE(F32,F32,getScaleT,1.0f) + DEF_GET_TE_STATE(F32,F32,getGlow,0.0f) + DEF_GET_TE_STATE(LLTextureEntry::e_texgen,LLTextureEntry::e_texgen,getTexGen,LLTextureEntry::TEX_GEN_DEFAULT) + DEF_GET_TE_STATE(LLColor4,const LLColor4&,getColor,LLColor4::white) }; }; |