From 371b4d4e46baa29a7b352a08efd25f3dc0499b72 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sat, 24 Aug 2024 13:22:19 +0200 Subject: [PATCH] Main: MaterialSerializer - further reduce TextureEffect usage --- OgreMain/include/OgreMaterialSerializer.h | 4 ++-- OgreMain/src/OgreMaterialSerializer.cpp | 25 +++++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/OgreMain/include/OgreMaterialSerializer.h b/OgreMain/include/OgreMaterialSerializer.h index 1deb2c6e906..13316b5644d 100644 --- a/OgreMain/include/OgreMaterialSerializer.h +++ b/OgreMain/include/OgreMaterialSerializer.h @@ -187,10 +187,10 @@ namespace Ogre { void writeLayerBlendOperationEx(const LayerBlendOperationEx op); void writeLayerBlendSource(const LayerBlendSource lbs); - void writeRotationEffect(const TextureUnitState::TextureEffect& effect, const TextureUnitState *pTex); + void writeRotationEffect(float speed); void writeTransformEffect(const TextureUnitState::TextureEffect& effect, const TextureUnitState *pTex); void writeScrollEffect(float scrollAnimU, float scrollAnimV); - void writeEnvironmentMapEffect(const TextureUnitState::TextureEffect& effect, const TextureUnitState *pTex); + void writeEnvironmentMapEffect(int type); String convertFiltering(FilterOptions fo); diff --git a/OgreMain/src/OgreMaterialSerializer.cpp b/OgreMain/src/OgreMaterialSerializer.cpp index 29992758d45..1b7e59d3b15 100644 --- a/OgreMain/src/OgreMaterialSerializer.cpp +++ b/OgreMain/src/OgreMaterialSerializer.cpp @@ -1065,10 +1065,10 @@ namespace Ogre switch (ef.type) { case TextureUnitState::ET_ENVIRONMENT_MAP : - writeEnvironmentMapEffect(ef, pTex); + writeEnvironmentMapEffect(ef.subtype); break; case TextureUnitState::ET_ROTATE : - writeRotationEffect(ef, pTex); + writeRotationEffect(ef.arg1); break; case TextureUnitState::ET_UVSCROLL : scrollAnimU = scrollAnimV = ef.arg1; @@ -1124,32 +1124,35 @@ namespace Ogre } //----------------------------------------------------------------------- - void MaterialSerializer::writeEnvironmentMapEffect(const TextureUnitState::TextureEffect& effect, const TextureUnitState *pTex) + void MaterialSerializer::writeEnvironmentMapEffect(int type) { writeAttribute(4, "env_map"); - switch (effect.subtype) + switch (type) { - case TextureUnitState::ENV_PLANAR: + case TEXCALC_ENVIRONMENT_MAP_PLANAR: writeValue("planar"); break; - case TextureUnitState::ENV_CURVED: + case TEXCALC_ENVIRONMENT_MAP: writeValue("spherical"); break; - case TextureUnitState::ENV_NORMAL: + case TEXCALC_ENVIRONMENT_MAP_NORMAL: writeValue("cubic_normal"); break; - case TextureUnitState::ENV_REFLECTION: + case TEXCALC_ENVIRONMENT_MAP_REFLECTION: writeValue("cubic_reflection"); break; + default: + OgreAssert(false, "Unknown environment map type"); + break; } } //----------------------------------------------------------------------- - void MaterialSerializer::writeRotationEffect(const TextureUnitState::TextureEffect& effect, const TextureUnitState *pTex) + void MaterialSerializer::writeRotationEffect(float speed) { - if (effect.arg1) + if (speed) { writeAttribute(4, "rotate_anim"); - writeValue(StringConverter::toString(effect.arg1)); + writeValue(StringConverter::toString(speed)); } } //-----------------------------------------------------------------------