From 5ee9c177325240b4b1b88d6faaf89f305e689e72 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sat, 24 Aug 2024 13:17:35 +0200 Subject: [PATCH] Main: TextureUnitState - alias EnvMapType to TexCoordCalcMethod --- OgreMain/include/Ogre.i | 1 + OgreMain/include/OgreRenderSystem.h | 11 ++++++--- OgreMain/include/OgreTextureUnitState.h | 23 ++++++++++--------- OgreMain/src/OgreTextureUnitState.cpp | 19 ++------------- .../Tiny/include/OgreTinyRenderSystem.h | 1 + .../include/OgreShaderExTextureAtlasSampler.h | 1 + 6 files changed, 25 insertions(+), 31 deletions(-) diff --git a/OgreMain/include/Ogre.i b/OgreMain/include/Ogre.i index 06822c8e73e..753dbecef21 100644 --- a/OgreMain/include/Ogre.i +++ b/OgreMain/include/Ogre.i @@ -194,6 +194,7 @@ typedef uint8_t uint8; %ignore Ogre::GpuConstantType; %ignore Ogre::GpuProgramParameters::ElementType; %ignore Ogre::Capabilities; +%ignore Ogre::TextureUnitState::EnvMapType; %typemap(csbase) Ogre::SceneManager::QueryTypeMask "uint"; %csmethodmodifiers *::ToString "public override"; // wrong "override" because of multiple inheritance diff --git a/OgreMain/include/OgreRenderSystem.h b/OgreMain/include/OgreRenderSystem.h index f5fc1b25cdc..f3cabd85fed 100644 --- a/OgreMain/include/OgreRenderSystem.h +++ b/OgreMain/include/OgreRenderSystem.h @@ -31,8 +31,8 @@ THE SOFTWARE. // Precompiler options #include "OgrePrerequisites.h" -#include "OgreTextureUnitState.h" #include "OgreCommon.h" +#include "OgreBlendMode.h" #include "OgreRenderSystemCapabilities.h" #include "OgreConfigOptionMap.h" @@ -43,6 +43,9 @@ THE SOFTWARE. namespace Ogre { + class Sampler; + class TextureUnitState; + /** \addtogroup Core * @{ */ @@ -61,11 +64,13 @@ namespace Ogre { /// No calculated texture coordinates TEXCALC_NONE, - /// Environment map based on vertex normals + /// 2D texture coordinates using spherical reflection mapping based on vertex normals TEXCALC_ENVIRONMENT_MAP, - /// Environment map based on vertex positions + /// 2D texture coordinates using view space position. Same as #TEXCALC_ENVIRONMENT_MAP on all backends. TEXCALC_ENVIRONMENT_MAP_PLANAR, + /// 3D texture coordinates using the reflection vector TEXCALC_ENVIRONMENT_MAP_REFLECTION, + /// 3D texture coordinates using the normal vector TEXCALC_ENVIRONMENT_MAP_NORMAL, /// Projective texture TEXCALC_PROJECTIVE_TEXTURE diff --git a/OgreMain/include/OgreTextureUnitState.h b/OgreMain/include/OgreTextureUnitState.h index 90f147040eb..d68cddc85c4 100644 --- a/OgreMain/include/OgreTextureUnitState.h +++ b/OgreMain/include/OgreTextureUnitState.h @@ -34,6 +34,7 @@ THE SOFTWARE. #include "OgreMatrix4.h" #include "OgreTexture.h" #include "OgreHeaderPrefix.h" +#include "OgreRenderSystem.h" namespace Ogre { enum TexCoordCalcMethod : uint8; @@ -264,17 +265,17 @@ namespace Ogre { }; - /// %Texture coordinate generation method for environment mapping. - enum EnvMapType + /// rather use @ref TexCoordCalcMethod + enum EnvMapType : uint8 { - /// 2D texture coordinates using view space position. Same as ENV_CURVED on all backends. - ENV_PLANAR, - /// 2D texture coordinates using spherical reflection mapping - ENV_CURVED, - /// Cubic texture coordinates using the reflection vector - ENV_REFLECTION, - /// Cubic texture coordinates using the normal vector - ENV_NORMAL + /// same as #TEXCALC_ENVIRONMENT_MAP_PLANAR + ENV_PLANAR = TEXCALC_ENVIRONMENT_MAP_PLANAR, + /// same as #TEXCALC_ENVIRONMENT_MAP + ENV_CURVED = TEXCALC_ENVIRONMENT_MAP, + /// same as #TEXCALC_ENVIRONMENT_MAP_REFLECTION + ENV_REFLECTION = TEXCALC_ENVIRONMENT_MAP_REFLECTION, + /// same as #TEXCALC_ENVIRONMENT_MAP_NORMAL + ENV_NORMAL = TEXCALC_ENVIRONMENT_MAP_NORMAL }; /** Useful enumeration when dealing with procedural transforms. @@ -884,7 +885,7 @@ namespace Ogre { True to enable, false to disable @param texGenType texture coordinate generation type */ - void setEnvironmentMap(bool enable, EnvMapType texGenType = ENV_CURVED); + void setEnvironmentMap(bool enable, int texGenType = TEXCALC_ENVIRONMENT_MAP); /** Sets up an animated scroll for the texture layer. diff --git a/OgreMain/src/OgreTextureUnitState.cpp b/OgreMain/src/OgreTextureUnitState.cpp index c7981e552e7..d7f7613a49a 100644 --- a/OgreMain/src/OgreTextureUnitState.cpp +++ b/OgreMain/src/OgreTextureUnitState.cpp @@ -669,7 +669,7 @@ namespace Ogre { return mAlphaBlendMode; } //----------------------------------------------------------------------- - void TextureUnitState::setEnvironmentMap(bool enable, EnvMapType envMapType) + void TextureUnitState::setEnvironmentMap(bool enable, int envMapType) { if (enable) { @@ -1226,22 +1226,7 @@ namespace Ogre { switch (effi.second.type) { case ET_ENVIRONMENT_MAP: - if (effi.second.subtype == ENV_CURVED) - { - texCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP; - } - else if (effi.second.subtype == ENV_PLANAR) - { - texCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP_PLANAR; - } - else if (effi.second.subtype == ENV_REFLECTION) - { - texCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP_REFLECTION; - } - else if (effi.second.subtype == ENV_NORMAL) - { - texCoordCalcMethod = TEXCALC_ENVIRONMENT_MAP_NORMAL; - } + texCoordCalcMethod = (TexCoordCalcMethod)effi.second.subtype; break; case ET_UVSCROLL: case ET_USCROLL: diff --git a/RenderSystems/Tiny/include/OgreTinyRenderSystem.h b/RenderSystems/Tiny/include/OgreTinyRenderSystem.h index ee37a3eb11a..25645b9fd1b 100644 --- a/RenderSystems/Tiny/include/OgreTinyRenderSystem.h +++ b/RenderSystems/Tiny/include/OgreTinyRenderSystem.h @@ -8,6 +8,7 @@ #include "OgreRenderWindow.h" #include "OgreRenderSystem.h" +#include "OgreImage.h" namespace Ogre { /** \addtogroup RenderSystems RenderSystems diff --git a/Samples/ShaderSystem/include/OgreShaderExTextureAtlasSampler.h b/Samples/ShaderSystem/include/OgreShaderExTextureAtlasSampler.h index 0c6fd73c1e3..0089761a11c 100644 --- a/Samples/ShaderSystem/include/OgreShaderExTextureAtlasSampler.h +++ b/Samples/ShaderSystem/include/OgreShaderExTextureAtlasSampler.h @@ -30,6 +30,7 @@ THE SOFTWARE. #include "OgreShaderPrerequisites.h" #ifdef RTSHADER_SYSTEM_BUILD_EXT_SHADERS #include "OgreShaderSubRenderState.h" +#include "OgreTextureUnitState.h" #define TAS_MAX_TEXTURES 4 namespace Ogre {