diff --git a/src/Common/Common.pro b/src/Common/Common.pro index 52d2ad74..48e23264 100644 --- a/src/Common/Common.pro +++ b/src/Common/Common.pro @@ -65,8 +65,8 @@ HEADERS += \ CUniqueID.h \ EKeyInputs.h \ EMouseInputs.h \ - EnumUtil.h \ ETransformSpace.h \ + Flags.h \ TString.h \ types.h diff --git a/src/Common/EKeyInputs.h b/src/Common/EKeyInputs.h index dae53081..787df2c7 100644 --- a/src/Common/EKeyInputs.h +++ b/src/Common/EKeyInputs.h @@ -1,11 +1,10 @@ #ifndef EKEYINPUTS #define EKEYINPUTS -#include "EnumUtil.h" +#include "Flags.h" -enum EKeyInputs +enum EKeyInput { - eNoKeys = 0, eCtrlKey = 0x1, eAltKey = 0x2, eQKey = 0x4, @@ -15,7 +14,7 @@ enum EKeyInputs eSKey = 0x40, eDKey = 0x80 }; -DEFINE_ENUM_FLAGS(EKeyInputs) +DECLARE_FLAGS(EKeyInput, FKeyInputs) #endif // EKEYINPUTS diff --git a/src/Common/EMouseInputs.h b/src/Common/EMouseInputs.h index d865b553..5d458668 100644 --- a/src/Common/EMouseInputs.h +++ b/src/Common/EMouseInputs.h @@ -1,15 +1,15 @@ #ifndef EMOUSEINPUTS #define EMOUSEINPUTS -#include "EnumUtil.h" +#include "Flags.h" -enum EMouseInputs +enum EMouseInput { eLeftButton = 0x1, eMiddleButton = 0x2, eRightButton = 0x4 }; -DEFINE_ENUM_FLAGS(EMouseInputs) +DECLARE_FLAGS(EMouseInput, FMouseInputs) #endif // EMOUSEINPUTS diff --git a/src/Common/EnumUtil.h b/src/Common/EnumUtil.h deleted file mode 100644 index a3811981..00000000 --- a/src/Common/EnumUtil.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef ENUMUTIL -#define ENUMUTIL - -#define DEFINE_ENUM_FLAGS(X) \ -inline X operator|(const X& A, const X& B) { \ - return (X) ((int) A | (int) B); \ -} \ -inline void operator|= (X& A, X& B) { \ - A = A | B; \ -} \ -inline X operator|(const X& A, const int B) { \ - return (X) ((int) A | B); \ -} \ -inline void operator|= (X& A, int B) { \ - A = A | B; \ -} \ -inline X operator|(const X& A, const unsigned int B) { \ - return (X) ((int) A | B); \ -} \ -inline void operator|= (X& A, unsigned int B) { \ - A = A | B; \ -} \ -inline X operator&(const X& A, const X& B) { \ - return (X) ((int) A & (int) B); \ -} \ -inline void operator&= (X& A, X& B) { \ - A = A & B; \ -} \ -inline X operator&(const X& A, const int B) { \ - return (X) ((int) A & B); \ -} \ -inline void operator&= (X& A, int B) { \ - A = A & B; \ -} \ -inline X operator&(const X& A, const unsigned int B) { \ - return (X) ((int) A & B); \ -} \ -inline void operator&= (X& A, unsigned int B) { \ - A = A & B; \ -} - -#endif // ENUMUTIL - diff --git a/src/Common/Flags.h b/src/Common/Flags.h new file mode 100644 index 00000000..38e6591b --- /dev/null +++ b/src/Common/Flags.h @@ -0,0 +1,35 @@ +#ifndef FLAGS_H +#define FLAGS_H + +#include + +template +class TFlags +{ + int mValue; + +public: + TFlags() : mValue(0) {} + TFlags(int v) : mValue(v) {} + TFlags(u32 v) : mValue(v) {} + TFlags(FlagEnum v) : mValue(v) {} + + inline operator int() const { return mValue; } + inline bool operator!() const { return !mValue; } + inline TFlags operator~() const { return TFlags(FlagEnum(~mValue)); } + + inline void operator&=(int Mask) { mValue &= Mask; } + inline void operator&=(u32 Mask) { mValue &= Mask; } + inline void operator|=(TFlags Flags) { mValue |= Flags.mValue; } + inline void operator|=(FlagEnum Flag) { mValue |= Flag; } + + inline TFlags operator|(TFlags Flags) const { return TFlags(FlagEnum(mValue | Flags.mValue)); } + inline TFlags operator|(FlagEnum Flag) const { return TFlags(FlagEnum(mValue | Flag)); } + inline TFlags operator&(int Mask) const { return TFlags(FlagEnum(mValue & Mask)); } + inline TFlags operator&(u32 Mask) const { return TFlags(FlagEnum(mValue & Mask)); } + inline TFlags operator&(FlagEnum Flag) const { return TFlags(FlagEnum(mValue & Flag)); } +}; +#define DECLARE_FLAGS(Enum, FlagTypeName) typedef TFlags FlagTypeName; + +#endif // FLAGS_H + diff --git a/src/Core/Core.pro b/src/Core/Core.pro index 47c0321f..8fe9fa2d 100644 --- a/src/Core/Core.pro +++ b/src/Core/Core.pro @@ -83,7 +83,6 @@ HEADERS += \ Render/CRenderBucket.h \ Render/CRenderer.h \ Render/ERenderCommand.h \ - Render/ERenderOptions.h \ Render/IRenderable.h \ Render/SRenderablePtr.h \ Render/SViewInfo.h \ @@ -110,13 +109,11 @@ HEADERS += \ Resource/Model/CModel.h \ Resource/Model/CStaticModel.h \ Resource/Model/CVertex.h \ - Resource/Model/EVertexDescription.h \ Resource/Model/SSurface.h \ Resource/Script/CMasterTemplate.h \ Resource/Script/CScriptLayer.h \ Resource/Script/CScriptObject.h \ Resource/Script/CScriptTemplate.h \ - Resource/Script/EObjectType.h \ Resource/Script/EPropertyType.h \ Resource/Script/EVolumeShape.h \ Resource/Script/SConnection.h \ @@ -180,7 +177,9 @@ HEADERS += \ Resource/Cooker/CAreaCooker.h \ Resource/Script/IPropertyValue.h \ Resource/Script/IPropertyTemplate.h \ - Resource/Script/IProperty.h + Resource/Script/IProperty.h \ + Resource/Model/EVertexAttribute.h \ + Render/FRenderOptions.h # Source Files SOURCES += \ diff --git a/src/Core/OpenGL/CDynamicVertexBuffer.cpp b/src/Core/OpenGL/CDynamicVertexBuffer.cpp index 116a88aa..cec0ee40 100644 --- a/src/Core/OpenGL/CDynamicVertexBuffer.cpp +++ b/src/Core/OpenGL/CDynamicVertexBuffer.cpp @@ -35,14 +35,14 @@ void CDynamicVertexBuffer::Unbind() glBindVertexArray(0); } -void CDynamicVertexBuffer::SetActiveAttribs(u32 AttribFlags) +void CDynamicVertexBuffer::SetActiveAttribs(FVertexDescription AttribFlags) { ClearBuffers(); - mAttribFlags = (EVertexDescription) AttribFlags; + mAttribFlags = AttribFlags; InitBuffers(); } -void CDynamicVertexBuffer::BufferAttrib(EVertexDescription Attrib, const void *pData) +void CDynamicVertexBuffer::BufferAttrib(EVertexAttribute Attrib, const void *pData) { u32 Index; diff --git a/src/Core/OpenGL/CDynamicVertexBuffer.h b/src/Core/OpenGL/CDynamicVertexBuffer.h index 0bb280b0..bbbf5e37 100644 --- a/src/Core/OpenGL/CDynamicVertexBuffer.h +++ b/src/Core/OpenGL/CDynamicVertexBuffer.h @@ -1,7 +1,7 @@ #ifndef CDYNAMICVERTEXBUFFER_H #define CDYNAMICVERTEXBUFFER_H -#include "Core/Resource/Model/EVertexDescription.h" +#include "Core/Resource/Model/EVertexAttribute.h" #include #include #include @@ -11,8 +11,8 @@ class CDynamicVertexBuffer { - EVertexDescription mAttribFlags; - EVertexDescription mBufferedFlags; + FVertexDescription mAttribFlags; + FVertexDescription mBufferedFlags; u32 mNumVertices; GLuint mAttribBuffers[12]; @@ -22,8 +22,8 @@ public: void SetVertexCount(u32 NumVerts); void Bind(); void Unbind(); - void SetActiveAttribs(u32 AttribFlags); - void BufferAttrib(EVertexDescription Attrib, const void *pData); + void SetActiveAttribs(FVertexDescription AttribFlags); + void BufferAttrib(EVertexAttribute Attrib, const void *pData); void ClearBuffers(); GLuint CreateVAO(); private: diff --git a/src/Core/OpenGL/CShaderGenerator.cpp b/src/Core/OpenGL/CShaderGenerator.cpp index 01921b18..67842d12 100644 --- a/src/Core/OpenGL/CShaderGenerator.cpp +++ b/src/Core/OpenGL/CShaderGenerator.cpp @@ -153,7 +153,7 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& Mat) // Input ShaderCode << "// Input\n"; - EVertexDescription VtxDesc = Mat.VtxDesc(); + FVertexDescription VtxDesc = Mat.VtxDesc(); if (VtxDesc & ePosition) ShaderCode << "layout(location = 0) in vec3 RawPosition;\n"; if (VtxDesc & eNormal) ShaderCode << "layout(location = 1) in vec3 RawNormal;\n"; if (VtxDesc & eColor0) ShaderCode << "layout(location = 2) in vec4 RawColor0;\n"; @@ -308,7 +308,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& Mat) ShaderCode << "#version 330 core\n" << "\n"; - EVertexDescription VtxDesc = Mat.VtxDesc(); + FVertexDescription VtxDesc = Mat.VtxDesc(); if (VtxDesc & ePosition) ShaderCode << "in vec3 Position;\n"; if (VtxDesc & eNormal) ShaderCode << "in vec3 Normal;\n"; if (VtxDesc & eColor0) ShaderCode << "in vec4 Color0;\n"; diff --git a/src/Core/OpenGL/CVertexBuffer.cpp b/src/Core/OpenGL/CVertexBuffer.cpp index b3b7b34a..3c3da81d 100644 --- a/src/Core/OpenGL/CVertexBuffer.cpp +++ b/src/Core/OpenGL/CVertexBuffer.cpp @@ -7,7 +7,7 @@ CVertexBuffer::CVertexBuffer() SetVertexDesc(ePosition | eNormal | eTex0 | eTex1 | eTex2 | eTex3 | eTex4 | eTex5 | eTex6 | eTex7); } -CVertexBuffer::CVertexBuffer(EVertexDescription Desc) +CVertexBuffer::CVertexBuffer(FVertexDescription Desc) { mBuffered = false; SetVertexDesc(Desc); @@ -174,12 +174,12 @@ bool CVertexBuffer::IsBuffered() return mBuffered; } -EVertexDescription CVertexBuffer::VertexDesc() +FVertexDescription CVertexBuffer::VertexDesc() { return mVtxDesc; } -void CVertexBuffer::SetVertexDesc(EVertexDescription Desc) +void CVertexBuffer::SetVertexDesc(FVertexDescription Desc) { Clear(); mVtxDesc = Desc; diff --git a/src/Core/OpenGL/CVertexBuffer.h b/src/Core/OpenGL/CVertexBuffer.h index f2e8f2c1..428706fd 100644 --- a/src/Core/OpenGL/CVertexBuffer.h +++ b/src/Core/OpenGL/CVertexBuffer.h @@ -2,13 +2,13 @@ #define CVERTEXBUFFER_H #include "Core/Resource/Model/CVertex.h" -#include "Core/Resource/Model/EVertexDescription.h" +#include "Core/Resource/Model/EVertexAttribute.h" #include #include class CVertexBuffer { - EVertexDescription mVtxDesc; // Flags that indicate what vertex attributes are enabled on this vertex buffer + FVertexDescription mVtxDesc; // Flags that indicate what vertex attributes are enabled on this vertex buffer GLuint mAttribBuffers[12]; // Separate GL buffer for each attribute to allow not tracking unused attribs. No support for matrix indices currently. std::vector mPositions; // Vector of vertex positions std::vector mNormals; // Vector of vertex normals @@ -18,7 +18,7 @@ class CVertexBuffer public: CVertexBuffer(); - CVertexBuffer(EVertexDescription Desc); + CVertexBuffer(FVertexDescription Desc); ~CVertexBuffer(); u16 AddVertex(const CVertex& vtx); u16 AddIfUnique(const CVertex& vtx, u16 start); @@ -28,8 +28,8 @@ public: void Bind(); void Unbind(); bool IsBuffered(); - EVertexDescription VertexDesc(); - void SetVertexDesc(EVertexDescription Desc); + FVertexDescription VertexDesc(); + void SetVertexDesc(FVertexDescription Desc); u32 Size(); GLuint CreateVAO(); }; diff --git a/src/Core/Render/CCamera.cpp b/src/Core/Render/CCamera.cpp index 880010ec..344b6d18 100644 --- a/src/Core/Render/CCamera.cpp +++ b/src/Core/Render/CCamera.cpp @@ -85,7 +85,7 @@ void CCamera::Snap(CVector3f Position) mFrustumPlanesDirty = true; } -void CCamera::ProcessKeyInput(EKeyInputs KeyFlags, double DeltaTime) +void CCamera::ProcessKeyInput(FKeyInputs KeyFlags, double DeltaTime) { float FDeltaTime = (float) DeltaTime; @@ -97,7 +97,7 @@ void CCamera::ProcessKeyInput(EKeyInputs KeyFlags, double DeltaTime) if (KeyFlags & eDKey) Pan(FDeltaTime * 25.f, 0); } -void CCamera::ProcessMouseInput(EKeyInputs KeyFlags, EMouseInputs MouseFlags, float XMovement, float YMovement) +void CCamera::ProcessMouseInput(FKeyInputs KeyFlags, FMouseInputs MouseFlags, float XMovement, float YMovement) { // Free Camera if (mMode == eFreeCamera) diff --git a/src/Core/Render/CCamera.h b/src/Core/Render/CCamera.h index 6e918d03..c7cc43e2 100644 --- a/src/Core/Render/CCamera.h +++ b/src/Core/Render/CCamera.h @@ -57,8 +57,8 @@ public: void Rotate(float XAmount, float YAmount); void Zoom(float Amount); void Snap(CVector3f Position); - void ProcessKeyInput(EKeyInputs KeyFlags, double DeltaTime); - void ProcessMouseInput(EKeyInputs KeyFlags, EMouseInputs MouseFlags, float XMovement, float YMovement); + void ProcessKeyInput(FKeyInputs KeyFlags, double DeltaTime); + void ProcessMouseInput(FKeyInputs KeyFlags, FMouseInputs MouseFlags, float XMovement, float YMovement); CRay CastRay(CVector2f DeviceCoords) const; void LoadMatrices() const; diff --git a/src/Core/Render/CDrawUtil.cpp b/src/Core/Render/CDrawUtil.cpp index 1ca2afb3..843f1c72 100644 --- a/src/Core/Render/CDrawUtil.cpp +++ b/src/Core/Render/CDrawUtil.cpp @@ -85,7 +85,7 @@ void CDrawUtil::DrawSquare(const float *pTexCoords) // Set tex coords for (u32 iTex = 0; iTex < 8; iTex++) { - EVertexDescription TexAttrib = (EVertexDescription) (eTex0 << (iTex *2)); + EVertexAttribute TexAttrib = (EVertexAttribute) (eTex0 << (iTex *2)); mSquareVertices.BufferAttrib(TexAttrib, pTexCoords); } @@ -453,7 +453,7 @@ void CDrawUtil::InitSquare() for (u32 iTex = 0; iTex < 8; iTex++) { - EVertexDescription Attrib = (EVertexDescription) (eTex0 << (iTex *2)); + EVertexAttribute Attrib = (EVertexAttribute) (eTex0 << (iTex *2)); mSquareVertices.BufferAttrib(Attrib, SquareTexCoords); } diff --git a/src/Core/Render/CRenderBucket.cpp b/src/Core/Render/CRenderBucket.cpp index aae4b26b..3f25f3bc 100644 --- a/src/Core/Render/CRenderBucket.cpp +++ b/src/Core/Render/CRenderBucket.cpp @@ -74,7 +74,7 @@ void CRenderBucket::Clear() void CRenderBucket::Draw(const SViewInfo& ViewInfo) { - ERenderOptions Options = ViewInfo.pRenderer->RenderOptions(); + FRenderOptions Options = ViewInfo.pRenderer->RenderOptions(); for (u32 n = 0; n < mSize; n++) { diff --git a/src/Core/Render/CRenderBucket.h b/src/Core/Render/CRenderBucket.h index 92026e56..5b104f84 100644 --- a/src/Core/Render/CRenderBucket.h +++ b/src/Core/Render/CRenderBucket.h @@ -2,7 +2,7 @@ #define CRENDERBUCKET_H #include "CCamera.h" -#include "ERenderOptions.h" +#include "FRenderOptions.h" #include "SRenderablePtr.h" #include #include diff --git a/src/Core/Render/CRenderer.cpp b/src/Core/Render/CRenderer.cpp index 666faf86..136c2665 100644 --- a/src/Core/Render/CRenderer.cpp +++ b/src/Core/Render/CRenderer.cpp @@ -53,7 +53,7 @@ void CRenderer::Init() } // ************ GETTERS/SETTERS ************ -ERenderOptions CRenderer::RenderOptions() const +FRenderOptions CRenderer::RenderOptions() const { return mOptions; } diff --git a/src/Core/Render/CRenderer.h b/src/Core/Render/CRenderer.h index 57c59289..7bdf4082 100644 --- a/src/Core/Render/CRenderer.h +++ b/src/Core/Render/CRenderer.h @@ -4,7 +4,7 @@ #include "CCamera.h" #include "CGraphics.h" #include "CRenderBucket.h" -#include "ERenderOptions.h" +#include "FRenderOptions.h" #include "ERenderCommand.h" #include "SRenderablePtr.h" #include "SViewInfo.h" @@ -28,7 +28,7 @@ public: }; private: - ERenderOptions mOptions; + FRenderOptions mOptions; EBloomMode mBloomMode; bool mDrawGrid; CColor mClearColor; @@ -54,7 +54,7 @@ public: void Init(); // Getters/Setters - ERenderOptions RenderOptions() const; + FRenderOptions RenderOptions() const; void ToggleWorld(bool b); void ToggleWorldCollision(bool b); void ToggleObjects(bool b); diff --git a/src/Core/Render/ERenderOptions.h b/src/Core/Render/FRenderOptions.h similarity index 72% rename from src/Core/Render/ERenderOptions.h rename to src/Core/Render/FRenderOptions.h index 571e03e4..2345ffc2 100644 --- a/src/Core/Render/ERenderOptions.h +++ b/src/Core/Render/FRenderOptions.h @@ -1,9 +1,9 @@ -#ifndef ERENDEROPTIONS -#define ERENDEROPTIONS +#ifndef FRENDEROPTIONS_H +#define FRENDEROPTIONS_H -#include +#include -enum ERenderOptions +enum ERenderOption { eNoRenderOptions = 0x0, eDrawWorld = 0x1, @@ -19,7 +19,7 @@ enum ERenderOptions eEnableBloom = 0x400, eNoAlpha = 0x800 }; -DEFINE_ENUM_FLAGS(ERenderOptions) +DECLARE_FLAGS(ERenderOption, FRenderOptions) -#endif // ERENDEROPTIONS +#endif // FRENDEROPTIONS_H diff --git a/src/Core/Render/IRenderable.h b/src/Core/Render/IRenderable.h index 8f7161f2..fdbea22c 100644 --- a/src/Core/Render/IRenderable.h +++ b/src/Core/Render/IRenderable.h @@ -1,7 +1,7 @@ #ifndef IRENDERABLE_H #define IRENDERABLE_H -#include "ERenderOptions.h" +#include "FRenderOptions.h" #include "SViewInfo.h" #include @@ -13,7 +13,7 @@ public: IRenderable() {} virtual ~IRenderable() {} virtual void AddToRenderer(CRenderer* pRenderer, const SViewInfo& ViewInfo) = 0; - virtual void Draw(ERenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& /*ViewInfo*/) {} + virtual void Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& /*ViewInfo*/) {} virtual void DrawSelection() {} }; diff --git a/src/Core/Resource/CMaterial.cpp b/src/Core/Resource/CMaterial.cpp index 092f90f9..f80ab1e0 100644 --- a/src/Core/Resource/CMaterial.cpp +++ b/src/Core/Resource/CMaterial.cpp @@ -29,7 +29,7 @@ CMaterial::CMaterial() mpIndirectTexture = nullptr; } -CMaterial::CMaterial(EGame version, EVertexDescription vtxDesc) +CMaterial::CMaterial(EGame version, FVertexDescription vtxDesc) { mpShader = nullptr; mShaderStatus = eNoShader; @@ -87,7 +87,7 @@ void CMaterial::GenerateShader() else mShaderStatus = eShaderExists; } -bool CMaterial::SetCurrent(ERenderOptions Options) +bool CMaterial::SetCurrent(FRenderOptions Options) { // Bind textures const char *skpSamplers[8] = { @@ -226,12 +226,12 @@ EGame CMaterial::Version() const return mVersion; } -CMaterial::EMaterialOptions CMaterial::Options() const +CMaterial::FMaterialOptions CMaterial::Options() const { return mOptions; } -EVertexDescription CMaterial::VtxDesc() const +FVertexDescription CMaterial::VtxDesc() const { return mVtxDesc; } @@ -287,13 +287,13 @@ void CMaterial::SetName(const TString& name) mName = name; } -void CMaterial::SetOptions(EMaterialOptions Options) +void CMaterial::SetOptions(FMaterialOptions Options) { mOptions = Options; mRecalcHash = true; } -void CMaterial::SetVertexDescription(EVertexDescription desc) +void CMaterial::SetVertexDescription(FVertexDescription desc) { mVtxDesc = desc; mRecalcHash = true; diff --git a/src/Core/Resource/CMaterial.h b/src/Core/Resource/CMaterial.h index 5a1e7bc7..5875a685 100644 --- a/src/Core/Resource/CMaterial.h +++ b/src/Core/Resource/CMaterial.h @@ -5,12 +5,12 @@ #include "CTexture.h" #include "EGame.h" #include "TResPtr.h" -#include "Core/Resource/Model/EVertexDescription.h" -#include "Core/Render/ERenderOptions.h" +#include "Core/Resource/Model/EVertexAttribute.h" +#include "Core/Render/FRenderOptions.h" #include "Core/OpenGL/CShader.h" #include -#include +#include #include #include @@ -23,7 +23,7 @@ public: friend class CMaterialCooker; // Enums - enum EMaterialOptions + enum EMaterialOption { eNoSettings = 0, eKonst = 0x8, @@ -38,6 +38,7 @@ public: eShortTexCoord = 0x2000, eAllSettings = 0x2FF8 }; + DECLARE_FLAGS(EMaterialOption, FMaterialOptions) private: enum EShaderStatus @@ -58,8 +59,8 @@ private: bool mEnableBloom; // Bool that toggles bloom on or off. On by default on MP3 materials, off by default on MP1 materials. EGame mVersion; - EMaterialOptions mOptions; // See the EMaterialOptions enum above - EVertexDescription mVtxDesc; // Descriptor of vertex attributes used by this material + FMaterialOptions mOptions; // See the EMaterialOptions enum above + FVertexDescription mVtxDesc; // Descriptor of vertex attributes used by this material CColor mKonstColors[4]; // Konst color values for TEV GLenum mBlendSrcFac; // Source blend factor GLenum mBlendDstFac; // Dest blend factor @@ -72,19 +73,19 @@ private: public: CMaterial(); - CMaterial(EGame version, EVertexDescription vtxDesc); + CMaterial(EGame version, FVertexDescription vtxDesc); ~CMaterial(); CMaterial* Clone(); void GenerateShader(); - bool SetCurrent(ERenderOptions Options); + bool SetCurrent(FRenderOptions Options); u64 HashParameters(); void Update(); // Getters TString Name() const; EGame Version() const; - EMaterialOptions Options() const; - EVertexDescription VtxDesc() const; + FMaterialOptions Options() const; + FVertexDescription VtxDesc() const; GLenum BlendSrcFac() const; GLenum BlendDstFac() const; CColor Konst(u32 KIndex) const; @@ -97,8 +98,8 @@ public: // Setters void SetName(const TString& name); - void SetOptions(EMaterialOptions Options); - void SetVertexDescription(EVertexDescription desc); + void SetOptions(FMaterialOptions Options); + void SetVertexDescription(FVertexDescription desc); void SetBlendMode(GLenum SrcFac, GLenum DstFac); void SetKonst(CColor& Konst, u32 KIndex); void SetIndTexture(CTexture *pTex); @@ -108,6 +109,5 @@ public: // Static static void KillCachedMaterial(); }; -DEFINE_ENUM_FLAGS(CMaterial::EMaterialOptions) #endif // MATERIAL_H diff --git a/src/Core/Resource/CMaterialPass.cpp b/src/Core/Resource/CMaterialPass.cpp index 3d2f9b07..1649bb19 100644 --- a/src/Core/Resource/CMaterialPass.cpp +++ b/src/Core/Resource/CMaterialPass.cpp @@ -81,7 +81,7 @@ void CMaterialPass::LoadTexture(u32 PassIndex) mpTexture->Bind(PassIndex); } -void CMaterialPass::SetAnimCurrent(ERenderOptions Options, u32 PassIndex) +void CMaterialPass::SetAnimCurrent(FRenderOptions Options, u32 PassIndex) { if (mAnimMode == eNoUVAnim) return; diff --git a/src/Core/Resource/CMaterialPass.h b/src/Core/Resource/CMaterialPass.h index d5036f1a..f60497c5 100644 --- a/src/Core/Resource/CMaterialPass.h +++ b/src/Core/Resource/CMaterialPass.h @@ -4,7 +4,7 @@ #include "TResPtr.h" #include "CTexture.h" #include "ETevEnums.h" -#include "Core/Render/ERenderOptions.h" +#include "Core/Render/FRenderOptions.h" #include #include @@ -47,7 +47,7 @@ public: CMaterialPass* Clone(CMaterial *pParent); void HashParameters(CHashFNV1A& Hash); void LoadTexture(u32 PassIndex); - void SetAnimCurrent(ERenderOptions Options, u32 PassIndex); + void SetAnimCurrent(FRenderOptions Options, u32 PassIndex); // Setters void SetType(CFourCC Type); diff --git a/src/Core/Resource/Cooker/CMaterialCooker.cpp b/src/Core/Resource/Cooker/CMaterialCooker.cpp index 2c3f24b0..2de4a5f9 100644 --- a/src/Core/Resource/Cooker/CMaterialCooker.cpp +++ b/src/Core/Resource/Cooker/CMaterialCooker.cpp @@ -141,7 +141,7 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out) else Flags = 0x4002; - Flags |= (HasKonst << 3) | mpMat->Options() | (TexFlags << 16); + Flags |= (HasKonst ? 0x8 : 0x0) | mpMat->Options() | (TexFlags << 16); Out.WriteLong(Flags); @@ -151,10 +151,10 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out) Out.WriteLong(TexIndices[iTex]); // Vertex description - EVertexDescription Desc = mpMat->VtxDesc(); + FVertexDescription Desc = mpMat->VtxDesc(); if (mVersion < eEchoes) - Desc = (EVertexDescription) (Desc & 0x00FFFFFF); + Desc &= 0x00FFFFFF; Out.WriteLong(Desc); diff --git a/src/Core/Resource/Cooker/CModelCooker.cpp b/src/Core/Resource/Cooker/CModelCooker.cpp index a7531890..b858067a 100644 --- a/src/Core/Resource/Cooker/CModelCooker.cpp +++ b/src/Core/Resource/Cooker/CModelCooker.cpp @@ -164,7 +164,7 @@ void CModelCooker::WriteModelPrime(IOutputStream& Out) Out.WriteToBoundary(32, 0); u32 PrimTableStart = Out.Tell(); - EVertexDescription MatAttribs = mpModel->GetMaterialBySurface(0, iSurf)->VtxDesc(); + FVertexDescription MatAttribs = mpModel->GetMaterialBySurface(0, iSurf)->VtxDesc(); for (u32 iPrim = 0; iPrim < pSurface->Primitives.size(); iPrim++) { diff --git a/src/Core/Resource/Cooker/CModelCooker.h b/src/Core/Resource/Cooker/CModelCooker.h index 07d912f1..3e31c800 100644 --- a/src/Core/Resource/Cooker/CModelCooker.h +++ b/src/Core/Resource/Cooker/CModelCooker.h @@ -14,7 +14,7 @@ class CModelCooker u32 mNumVertices; u8 mVertexFormat; std::vector mVertices; - EVertexDescription mVtxAttribs; + FVertexDescription mVtxAttribs; CModelCooker(); void GenerateSurfaceData(); diff --git a/src/Core/Resource/Factory/CMaterialLoader.cpp b/src/Core/Resource/Factory/CMaterialLoader.cpp index 62fd1919..b4751c28 100644 --- a/src/Core/Resource/Factory/CMaterialLoader.cpp +++ b/src/Core/Resource/Factory/CMaterialLoader.cpp @@ -50,7 +50,7 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial() pMat->mEnableBloom = false; // Flags - pMat->mOptions = (CMaterial::EMaterialOptions) (mpFile->ReadLong() & CMaterial::eAllSettings); + pMat->mOptions = (mpFile->ReadLong() & CMaterial::eAllSettings); // Textures u32 NumTextures = mpFile->ReadLong(); @@ -63,7 +63,7 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial() } // Vertex description - pMat->mVtxDesc = (EVertexDescription) mpFile->ReadLong(); + pMat->mVtxDesc = (FVertexDescription) mpFile->ReadLong(); // Unknowns if (mVersion >= eEchoesDemo) @@ -266,7 +266,7 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial() mHas0x400 = ((Flags & 0x400) != 0); mpFile->Seek(0x8, SEEK_CUR); // Don't know what any of this is - pMat->mVtxDesc = (EVertexDescription) mpFile->ReadLong(); + pMat->mVtxDesc = (FVertexDescription) mpFile->ReadLong(); mpFile->Seek(0xC, SEEK_CUR); // Initialize all KColors to white diff --git a/src/Core/Resource/Factory/CModelLoader.cpp b/src/Core/Resource/Factory/CModelLoader.cpp index 5ee3a03a..47131771 100644 --- a/src/Core/Resource/Factory/CModelLoader.cpp +++ b/src/Core/Resource/Factory/CModelLoader.cpp @@ -142,7 +142,7 @@ SSurface* CModelLoader::LoadSurface(IInputStream& Model) for (u16 iVtx = 0; iVtx < VertexCount; iVtx++) { CVertex Vtx; - EVertexDescription VtxDesc = pMat->VtxDesc(); + FVertexDescription VtxDesc = pMat->VtxDesc(); for (u32 iMtxAttr = 0; iMtxAttr < 8; iMtxAttr++) if (VtxDesc & (ePosMtx << iMtxAttr)) Model.Seek(0x1, SEEK_CUR); @@ -277,7 +277,7 @@ SSurface* CModelLoader::LoadAssimpMesh(const aiMesh *pMesh, CMaterialSet *pSet) { // Create vertex description and assign it to material CMaterial *pMat = pSet->MaterialByIndex(pMesh->mMaterialIndex); - EVertexDescription desc = pMat->VtxDesc(); + FVertexDescription desc = pMat->VtxDesc(); if (desc == eNoAttributes) { diff --git a/src/Core/Resource/Factory/CModelLoader.h b/src/Core/Resource/Factory/CModelLoader.h index 5f02ad4b..0810fcf8 100644 --- a/src/Core/Resource/Factory/CModelLoader.h +++ b/src/Core/Resource/Factory/CModelLoader.h @@ -6,7 +6,7 @@ #include "Core/Resource/Model/CModel.h" #include "Core/Resource/CResCache.h" #include "Core/Resource/EGame.h" -#include +#include #include #include @@ -14,7 +14,7 @@ class CModelLoader { public: - enum EModelFlags + enum EModelFlag { eNoFlags = 0x0, eShortPositions = 0x1, @@ -22,6 +22,7 @@ public: eHasTex1 = 0x4, eHasVisGroups = 0x8 }; + DECLARE_FLAGS(EModelFlag, FModelFlags) private: TResPtr mpModel; @@ -41,7 +42,7 @@ private: u32 mSurfaceCount; std::vector mSurfaceOffsets; - EModelFlags mFlags; + FModelFlags mFlags; CModelLoader(); ~CModelLoader(); @@ -62,6 +63,4 @@ public: static EGame GetFormatVersion(u32 Version); }; -DEFINE_ENUM_FLAGS(CModelLoader::EModelFlags) - #endif // CMODELLOADER_H diff --git a/src/Core/Resource/Model/CModel.cpp b/src/Core/Resource/Model/CModel.cpp index 1e67f7d8..7d207bd4 100644 --- a/src/Core/Resource/Model/CModel.cpp +++ b/src/Core/Resource/Model/CModel.cpp @@ -82,14 +82,14 @@ void CModel::ClearGLBuffer() mBuffered = false; } -void CModel::Draw(ERenderOptions Options, u32 MatSet) +void CModel::Draw(FRenderOptions Options, u32 MatSet) { if (!mBuffered) BufferGL(); for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++) DrawSurface(Options, iSurf, MatSet); } -void CModel::DrawSurface(ERenderOptions Options, u32 Surface, u32 MatSet) +void CModel::DrawSurface(FRenderOptions Options, u32 Surface, u32 MatSet) { if (!mBuffered) BufferGL(); @@ -122,7 +122,7 @@ void CModel::DrawSurface(ERenderOptions Options, u32 Surface, u32 MatSet) mVBO.Unbind(); } -void CModel::DrawWireframe(ERenderOptions Options, CColor WireColor /*= CColor::skWhite*/) +void CModel::DrawWireframe(FRenderOptions Options, CColor WireColor /*= CColor::skWhite*/) { if (!mBuffered) BufferGL(); diff --git a/src/Core/Resource/Model/CModel.h b/src/Core/Resource/Model/CModel.h index 7b54d3b5..5ceaee2f 100644 --- a/src/Core/Resource/Model/CModel.h +++ b/src/Core/Resource/Model/CModel.h @@ -6,7 +6,7 @@ #include "Core/Resource/CMaterialSet.h" #include "Core/OpenGL/CIndexBuffer.h" #include "Core/OpenGL/GLCommon.h" -#include "Core/Render/ERenderOptions.h" +#include "Core/Render/FRenderOptions.h" class CModel : public CBasicModel { @@ -24,9 +24,9 @@ public: void BufferGL(); void ClearGLBuffer(); - void Draw(ERenderOptions Options, u32 MatSet); - void DrawSurface(ERenderOptions Options, u32 Surface, u32 MatSet); - void DrawWireframe(ERenderOptions Options, CColor WireColor = CColor::skWhite); + void Draw(FRenderOptions Options, u32 MatSet); + void DrawSurface(FRenderOptions Options, u32 Surface, u32 MatSet); + void DrawWireframe(FRenderOptions Options, CColor WireColor = CColor::skWhite); u32 GetMatSetCount(); u32 GetMatCount(); diff --git a/src/Core/Resource/Model/CStaticModel.cpp b/src/Core/Resource/Model/CStaticModel.cpp index dea8ea91..509dd9cb 100644 --- a/src/Core/Resource/Model/CStaticModel.cpp +++ b/src/Core/Resource/Model/CStaticModel.cpp @@ -97,7 +97,7 @@ void CStaticModel::ClearGLBuffer() mBuffered = false; } -void CStaticModel::Draw(ERenderOptions Options) +void CStaticModel::Draw(FRenderOptions Options) { if (!mBuffered) BufferGL(); @@ -119,7 +119,7 @@ void CStaticModel::Draw(ERenderOptions Options) mVBO.Unbind(); } -void CStaticModel::DrawSurface(ERenderOptions Options, u32 Surface) +void CStaticModel::DrawSurface(FRenderOptions Options, u32 Surface) { if (!mBuffered) BufferGL(); @@ -144,7 +144,7 @@ void CStaticModel::DrawSurface(ERenderOptions Options, u32 Surface) mVBO.Unbind(); } -void CStaticModel::DrawWireframe(ERenderOptions Options, CColor WireColor /*= CColor::skWhite*/) +void CStaticModel::DrawWireframe(FRenderOptions Options, CColor WireColor /*= CColor::skWhite*/) { if (!mBuffered) BufferGL(); diff --git a/src/Core/Resource/Model/CStaticModel.h b/src/Core/Resource/Model/CStaticModel.h index cdbf8b12..b6ba40fc 100644 --- a/src/Core/Resource/Model/CStaticModel.h +++ b/src/Core/Resource/Model/CStaticModel.h @@ -2,7 +2,7 @@ #define CSTATICMODEL_H #include "CBasicModel.h" -#include "Core/Render/ERenderOptions.h" +#include "Core/Render/FRenderOptions.h" #include "Core/OpenGL/CIndexBuffer.h" /* A CStaticModel is meant for meshes that don't move. It's built specifically with terrain in mind. @@ -23,9 +23,9 @@ public: void BufferGL(); void ClearGLBuffer(); - void Draw(ERenderOptions Options); - void DrawSurface(ERenderOptions Options, u32 Surface); - void DrawWireframe(ERenderOptions Options, CColor WireColor = CColor::skWhite); + void Draw(FRenderOptions Options); + void DrawSurface(FRenderOptions Options, u32 Surface); + void DrawWireframe(FRenderOptions Options, CColor WireColor = CColor::skWhite); CMaterial* GetMaterial(); void SetMaterial(CMaterial *pMat); diff --git a/src/Core/Resource/Model/EVertexDescription.h b/src/Core/Resource/Model/EVertexAttribute.h similarity index 75% rename from src/Core/Resource/Model/EVertexDescription.h rename to src/Core/Resource/Model/EVertexAttribute.h index edb81d79..e31e0637 100644 --- a/src/Core/Resource/Model/EVertexDescription.h +++ b/src/Core/Resource/Model/EVertexAttribute.h @@ -1,9 +1,9 @@ -#ifndef EVERTEXDESCRIPTION -#define EVERTEXDESCRIPTION +#ifndef EVERTEXATTRIBUTE +#define EVERTEXATTRIBUTE -#include +#include -enum EVertexDescription +enum EVertexAttribute { eNoAttributes = 0x0, ePosition = 0x3, @@ -27,7 +27,7 @@ enum EVertexDescription eTex5Mtx = 0x40000000, eTex6Mtx = 0x80000000 }; -DEFINE_ENUM_FLAGS(EVertexDescription) +DECLARE_FLAGS(EVertexAttribute, FVertexDescription) -#endif // EVERTEXDESCRIPTION +#endif // EVERTEXATTRIBUTE diff --git a/src/Core/Resource/Script/EObjectType.h b/src/Core/Resource/Script/EObjectType.h deleted file mode 100644 index 0e51c81a..00000000 --- a/src/Core/Resource/Script/EObjectType.h +++ /dev/null @@ -1,130 +0,0 @@ -#ifndef EOBJECTTYPE_H -#define EOBJECTTYPE_H - -// dunno if this is actually needed, but here it is. -enum EObjectType -{ - Actor = 0x0, - Waypoint = 0x2, - DoorArea = 0x3, - Trigger = 0x4, - Timer = 0x5, - Counter = 0x6, - Effect = 0x7, - Platform = 0x8, - Sound = 0x9, - Generator = 0xA, - Dock = 0xB, - Camera = 0xC, - CameraWaypoint = 0xD, - NewIntroBoss = 0xE, - SpawnPoint = 0xF, - CameraHint = 0x10, - Pickup = 0x11, - MemoryRelay = 0x13, - RandomRelay = 0x14, - Relay = 0x15, - Beetle = 0x16, - HUDMemo = 0x17, - CameraFilterKeyframe = 0x18, - CameraBlurKeyframe = 0x19, - DamageableTrigger = 0x1A, - Debris = 0x1B, - CameraShaker = 0x1C, - ActorKeyFrame = 0x1D, - Water = 0x20, - Warwasp = 0x21, - SpacePirate = 0x24, - FlyingPirate = 0x25, - ElitePirate = 0x26, - MetroidBeta = 0x27, - ChozoGhost = 0x28, - CoverPoint = 0x2A, - SpiderBallWaypoint = 0x2C, - BloodFlower = 0x2D, - FlickerBat = 0x2E, - PathCamera = 0x2F, - GrapplePoint = 0x30, - PuddleSpore = 0x31, - SpiderBallAttractionSurface = 0x33, - PuddleToadGamma = 0x34, - Fog = 0x35, - FireFlea = 0x36, - MetareeAlpha = 0x37, - ActorRotate = 0x39, - SpecialFunction = 0x3A, - SpankWeed = 0x3B, - Zoomer = 0x3D, - PlayerHint = 0x3E, - Ripper = 0x3F, - PickupGenerator = 0x40, - PointOfInterest = 0x42, - Drone = 0x43, - MetroidAlpha = 0x44, - DebrisExtended = 0x45, - Steam = 0x46, - Ripple = 0x47, - BallTrigger = 0x48, - TargetingPoint = 0x49, - ElectroMagneticPulse = 0x4A, - IceSheegoth = 0x4B, - PlayerActor = 0x4C, - Flaahgra = 0x4D, - AreaAttributes = 0x4E, - FishCloud = 0x4F, - FishCloudModifier = 0x50, - VisorFlare = 0x51, - VisorGoo = 0x53, - JellyZap = 0x54, - ControllerAction = 0x55, - Switch = 0x56, - PlayerStateChange = 0x57, - Thardus = 0x58, - WallCrawlerSwarm = 0x5A, - AIJumpPoint = 0x5B, - FlaahgraTentacle = 0x5C, - RoomAcoustics = 0x5D, - ColorModulate = 0x5E, - ThardusRockProjectile = 0x5F, - Midi = 0x60, - StreamedAudio = 0x61, - WorldTeleporter = 0x62, - Repulsor = 0x63, - GunTurret = 0x64, - Babygoth = 0x66, - Eyeball = 0x67, - RadialKnockback = 0x68, - CameraPitchVolume = 0x69, - EnvFxDensityController = 0x6A, - Magdolite = 0x6B, - TeamAIMgr = 0x6C, - SnakeWeedSwarm = 0x6D, - ActorContraption = 0x6E, - Oculus = 0x6F, - Geemer = 0x70, - SpindleCamera = 0x71, - AtomicAlpha = 0x72, - CameraHintTrigger = 0x73, - RumbleEffect = 0x74, - AmbientAI = 0x75, - AtomicBeta = 0x77, - Puffer = 0x79, - Tryclops = 0x7A, - Ridley = 0x7B, - Seedling = 0x7C, - ThermalHeatFader = 0x7D, - Burrower = 0x7F, - ScriptBeam = 0x81, - WorldLightFader = 0x82, - MetroidPrimeStage2 = 0x83, - MetroidPrimeRelay = 0x84, - MazeNode = 0x85, - OmegaPirate = 0x86, - PhazonPool = 0x87, - PhazonHealingNodule = 0x88, - NewCameraShaker = 0x89, - ShadowProjector = 0x8A, - BeamEnergyBall = 0x8B -}; - -#endif // EOBJECTTYPE_H diff --git a/src/Core/Scene/CCollisionNode.cpp b/src/Core/Scene/CCollisionNode.cpp index 2e9dfc55..8fcd1aff 100644 --- a/src/Core/Scene/CCollisionNode.cpp +++ b/src/Core/Scene/CCollisionNode.cpp @@ -27,7 +27,7 @@ void CCollisionNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewIn pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection); } -void CCollisionNode::Draw(ERenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& ViewInfo) +void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& ViewInfo) { if (!mpCollision) return; diff --git a/src/Core/Scene/CCollisionNode.h b/src/Core/Scene/CCollisionNode.h index f1af51ab..15ab524b 100644 --- a/src/Core/Scene/CCollisionNode.h +++ b/src/Core/Scene/CCollisionNode.h @@ -12,7 +12,7 @@ public: CCollisionNode(CSceneManager *pScene, CSceneNode *pParent = 0, CCollisionMeshGroup *pCollision = 0); ENodeType NodeType(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); void SetCollision(CCollisionMeshGroup *pCollision); }; diff --git a/src/Core/Scene/CLightNode.cpp b/src/Core/Scene/CLightNode.cpp index 4dea6d14..7e08b805 100644 --- a/src/Core/Scene/CLightNode.cpp +++ b/src/Core/Scene/CLightNode.cpp @@ -41,7 +41,7 @@ void CLightNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo) } } -void CLightNode::Draw(ERenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& ViewInfo) +void CLightNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& ViewInfo) { CDrawUtil::DrawLightBillboard(mpLight->GetType(), mpLight->GetColor(), mPosition, BillboardScale(), TintColor(ViewInfo)); } diff --git a/src/Core/Scene/CLightNode.h b/src/Core/Scene/CLightNode.h index 1fbc8ff5..6a4218f1 100644 --- a/src/Core/Scene/CLightNode.h +++ b/src/Core/Scene/CLightNode.h @@ -11,7 +11,7 @@ public: CLightNode(CSceneManager *pScene, CSceneNode *pParent = 0, CLight *Light = 0); ENodeType NodeType(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); diff --git a/src/Core/Scene/CModelNode.cpp b/src/Core/Scene/CModelNode.cpp index 63923fcd..9205d4c7 100644 --- a/src/Core/Scene/CModelNode.cpp +++ b/src/Core/Scene/CModelNode.cpp @@ -32,10 +32,10 @@ void CModelNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo) pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection); } -void CModelNode::Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo) +void CModelNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo) { if (!mpModel) return; - if (mForceAlphaOn) Options = (ERenderOptions) (Options & ~eNoAlpha); + if (mForceAlphaOn) Options = (FRenderOptions) (Options & ~eNoAlpha); if (mLightingEnabled) { @@ -84,7 +84,7 @@ SRayIntersection CModelNode::RayNodeIntersectTest(const CRay &Ray, u32 AssetID, out.ComponentIndex = AssetID; CRay TransformedRay = Ray.Transformed(Transform().Inverse()); - ERenderOptions options = ViewInfo.pRenderer->RenderOptions(); + FRenderOptions options = ViewInfo.pRenderer->RenderOptions(); std::pair Result = mpModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((options & eEnableBackfaceCull) == 0)); if (Result.first) diff --git a/src/Core/Scene/CModelNode.h b/src/Core/Scene/CModelNode.h index 2533aac9..6d7cd857 100644 --- a/src/Core/Scene/CModelNode.h +++ b/src/Core/Scene/CModelNode.h @@ -16,7 +16,7 @@ public: virtual ENodeType NodeType(); virtual void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - virtual void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); + virtual void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); virtual void DrawSelection(); virtual void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); virtual SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); diff --git a/src/Core/Scene/CRootNode.h b/src/Core/Scene/CRootNode.h index 15ee2999..eeb6c384 100644 --- a/src/Core/Scene/CRootNode.h +++ b/src/Core/Scene/CRootNode.h @@ -11,7 +11,7 @@ public: explicit CRootNode(CSceneManager *pScene, CSceneNode *pParent = 0) : CSceneNode(pScene, pParent) {} ~CRootNode() {} - inline ENodeType NodeType() { + ENodeType NodeType() { return eRootNode; } diff --git a/src/Core/Scene/CSceneManager.cpp b/src/Core/Scene/CSceneManager.cpp index fa6b1b97..9979462b 100644 --- a/src/Core/Scene/CSceneManager.cpp +++ b/src/Core/Scene/CSceneManager.cpp @@ -214,7 +214,7 @@ void CSceneManager::ClearScene() void CSceneManager::AddSceneToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo) { - ERenderOptions Options = pRenderer->RenderOptions(); + FRenderOptions Options = pRenderer->RenderOptions(); if (Options & eDrawWorld || ViewInfo.GameMode) { @@ -254,7 +254,7 @@ SRayIntersection CSceneManager::SceneRayCast(const CRay& Ray, const SViewInfo& V // Terribly hacky stuff to avoid having tons of redundant code // because I'm too lazy to rewrite CSceneManager right now and fix it // (I'm probably going to do it soon...) - ERenderOptions renderOptions = ViewInfo.pRenderer->RenderOptions(); + FRenderOptions renderOptions = ViewInfo.pRenderer->RenderOptions(); std::vector *pNodeVectors[5] = { reinterpret_cast*>(&mModelNodes), @@ -265,7 +265,7 @@ SRayIntersection CSceneManager::SceneRayCast(const CRay& Ray, const SViewInfo& V }; bool NodesVisible[5] = { true, ((renderOptions & eDrawWorld) != 0), ((renderOptions & eDrawWorldCollision) != 0), - ((renderOptions & ((ERenderOptions) (eDrawObjects | eDrawObjectCollision))) != 0), ((renderOptions & eDrawLights) != 0) + ((renderOptions & ((FRenderOptions) (eDrawObjects | eDrawObjectCollision))) != 0), ((renderOptions & eDrawLights) != 0) }; // Override visibility for game mode diff --git a/src/Core/Scene/CSceneNode.h b/src/Core/Scene/CSceneNode.h index 4ff68648..0b85a1c2 100644 --- a/src/Core/Scene/CSceneNode.h +++ b/src/Core/Scene/CSceneNode.h @@ -2,7 +2,7 @@ #define CSCENENODE_H #include "ENodeType.h" -#include "Core/Render/ERenderOptions.h" +#include "Core/Render/FRenderOptions.h" #include "Core/Render/IRenderable.h" #include "Core/Resource/CLight.h" #include "Core/Resource/CGameArea.h" diff --git a/src/Core/Scene/CScriptNode.cpp b/src/Core/Scene/CScriptNode.cpp index c8f27389..0e9c826c 100644 --- a/src/Core/Scene/CScriptNode.cpp +++ b/src/Core/Scene/CScriptNode.cpp @@ -119,7 +119,7 @@ void CScriptNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo) if (ShouldDraw) { // Otherwise, we proceed as normal - ERenderOptions options = pRenderer->RenderOptions(); + FRenderOptions options = pRenderer->RenderOptions(); if ((options & eDrawObjectCollision) && (!ViewInfo.GameMode)) mpCollisionNode->AddToRenderer(pRenderer, ViewInfo); @@ -154,7 +154,7 @@ void CScriptNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo) } } -void CScriptNode::Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo) +void CScriptNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo) { if (!mpInstance) return; @@ -282,7 +282,7 @@ void CScriptNode::RayAABoxIntersectTest(CRayCollisionTester& Tester, const SView SRayIntersection CScriptNode::RayNodeIntersectTest(const CRay& Ray, u32 AssetID, const SViewInfo& ViewInfo) { - ERenderOptions options = ViewInfo.pRenderer->RenderOptions(); + FRenderOptions options = ViewInfo.pRenderer->RenderOptions(); SRayIntersection out; out.pNode = this; diff --git a/src/Core/Scene/CScriptNode.h b/src/Core/Scene/CScriptNode.h index 3bd9aa9e..0384070d 100644 --- a/src/Core/Scene/CScriptNode.h +++ b/src/Core/Scene/CScriptNode.h @@ -26,7 +26,7 @@ public: CScriptNode(CSceneManager *pScene, CSceneNode *pParent = 0, CScriptObject *pObject = 0); ENodeType NodeType(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); diff --git a/src/Core/Scene/CStaticNode.cpp b/src/Core/Scene/CStaticNode.cpp index 962abe90..1433ff9b 100644 --- a/src/Core/Scene/CStaticNode.cpp +++ b/src/Core/Scene/CStaticNode.cpp @@ -44,7 +44,7 @@ void CStaticNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo) pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection); } -void CStaticNode::Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo) +void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo) { if (!mpModel) return; @@ -96,7 +96,7 @@ SRayIntersection CStaticNode::RayNodeIntersectTest(const CRay &Ray, u32 AssetID, out.ComponentIndex = AssetID; CRay TransformedRay = Ray.Transformed(Transform().Inverse()); - ERenderOptions options = ViewInfo.pRenderer->RenderOptions(); + FRenderOptions options = ViewInfo.pRenderer->RenderOptions(); std::pair Result = mpModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((options & eEnableBackfaceCull) == 0)); if (Result.first) diff --git a/src/Core/Scene/CStaticNode.h b/src/Core/Scene/CStaticNode.h index 3a02c9f0..7a94319b 100644 --- a/src/Core/Scene/CStaticNode.h +++ b/src/Core/Scene/CStaticNode.h @@ -12,7 +12,7 @@ public: CStaticNode(CSceneManager *pScene, CSceneNode *pParent = 0, CStaticModel *pModel = 0); ENodeType NodeType(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); diff --git a/src/Core/Scene/ENodeType.h b/src/Core/Scene/ENodeType.h index c808cba0..b97d6f93 100644 --- a/src/Core/Scene/ENodeType.h +++ b/src/Core/Scene/ENodeType.h @@ -1,5 +1,5 @@ -#ifndef ENODETYPE -#define ENODETYPE +#ifndef ENODETYPE_H +#define ENODETYPE_H enum ENodeType { @@ -12,5 +12,5 @@ enum ENodeType eLightNode }; -#endif // ENODETYPE +#endif // ENODETYPE_H diff --git a/src/Core/Scene/EVisibilityFlags.h b/src/Core/Scene/EVisibilityFlags.h new file mode 100644 index 00000000..9139af71 --- /dev/null +++ b/src/Core/Scene/EVisibilityFlags.h @@ -0,0 +1,19 @@ +#ifndef EVISIBILITYFLAGS +#define EVISIBILITYFLAGS + +#include + +enum EVisibilityFlags +{ + eShowNomr = 0x00, + eShowWorld = 0x01, + eShowWorldCollision = 0x02, + eShowObjects = 0x04, + eShowObjectCollision = 0x08, + eShowLights = 0x10, + eShowAll = 0x1F +}; +DEFINE_ENUM_FLAGS(EVisibilityFlags) + +#endif // EVISIBILITYFLAGS + diff --git a/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp b/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp index 242550e3..1bb500ae 100644 --- a/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp +++ b/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp @@ -198,7 +198,7 @@ void CDamageableTriggerExtra::AddToRenderer(CRenderer *pRenderer, const SViewInf } } -void CDamageableTriggerExtra::Draw(ERenderOptions Options, int /*ComponentIndex*/, const SViewInfo& ViewInfo) +void CDamageableTriggerExtra::Draw(FRenderOptions Options, int /*ComponentIndex*/, const SViewInfo& ViewInfo) { LoadModelMatrix(); CGraphics::sPixelBlock.TintColor = mpParent->TintColor(ViewInfo); diff --git a/src/Core/ScriptExtra/CDamageableTriggerExtra.h b/src/Core/ScriptExtra/CDamageableTriggerExtra.h index 8b9dedbc..48836be9 100644 --- a/src/Core/ScriptExtra/CDamageableTriggerExtra.h +++ b/src/Core/ScriptExtra/CDamageableTriggerExtra.h @@ -36,7 +36,7 @@ public: void PropertyModified(IProperty *pProperty); bool ShouldDrawNormalAssets(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay& Ray, u32 ComponentIndex, const SViewInfo& ViewInfo); diff --git a/src/Core/ScriptExtra/CDoorExtra.cpp b/src/Core/ScriptExtra/CDoorExtra.cpp index 00f07b22..a3d68028 100644 --- a/src/Core/ScriptExtra/CDoorExtra.cpp +++ b/src/Core/ScriptExtra/CDoorExtra.cpp @@ -85,7 +85,7 @@ void CDoorExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo) } } -void CDoorExtra::Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo) +void CDoorExtra::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo) { LoadModelMatrix(); mpParent->LoadLights(ViewInfo); @@ -126,7 +126,7 @@ void CDoorExtra::RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewI SRayIntersection CDoorExtra::RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo) { - ERenderOptions Options = ViewInfo.pRenderer->RenderOptions(); + FRenderOptions Options = ViewInfo.pRenderer->RenderOptions(); SRayIntersection out; out.pNode = mpParent; diff --git a/src/Core/ScriptExtra/CDoorExtra.h b/src/Core/ScriptExtra/CDoorExtra.h index 79fb250b..c0050578 100644 --- a/src/Core/ScriptExtra/CDoorExtra.h +++ b/src/Core/ScriptExtra/CDoorExtra.h @@ -16,7 +16,7 @@ public: explicit CDoorExtra(CScriptObject *pInstance, CSceneManager *pScene, CSceneNode *pParent = 0); void PropertyModified(IProperty *pProperty); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); diff --git a/src/Core/ScriptExtra/CRadiusSphereExtra.cpp b/src/Core/ScriptExtra/CRadiusSphereExtra.cpp index 35c36260..66280681 100644 --- a/src/Core/ScriptExtra/CRadiusSphereExtra.cpp +++ b/src/Core/ScriptExtra/CRadiusSphereExtra.cpp @@ -36,7 +36,7 @@ void CRadiusSphereExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rk } } -void CRadiusSphereExtra::Draw(ERenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& /*rkViewInfo*/) +void CRadiusSphereExtra::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& /*rkViewInfo*/) { glBlendFunc(GL_ONE, GL_ZERO); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); diff --git a/src/Core/ScriptExtra/CRadiusSphereExtra.h b/src/Core/ScriptExtra/CRadiusSphereExtra.h index 0d585a79..c7fda10f 100644 --- a/src/Core/ScriptExtra/CRadiusSphereExtra.h +++ b/src/Core/ScriptExtra/CRadiusSphereExtra.h @@ -12,7 +12,7 @@ class CRadiusSphereExtra : public CScriptExtra public: explicit CRadiusSphereExtra(CScriptObject *pInstance, CSceneManager *pScene, CSceneNode *pParent = 0); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); - void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo); CColor Color() const; CAABox Bounds() const; }; diff --git a/src/Core/ScriptExtra/CWaypointExtra.cpp b/src/Core/ScriptExtra/CWaypointExtra.cpp index d7aef8f6..224e88c6 100644 --- a/src/Core/ScriptExtra/CWaypointExtra.cpp +++ b/src/Core/ScriptExtra/CWaypointExtra.cpp @@ -94,7 +94,7 @@ void CWaypointExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewIn } } -void CWaypointExtra::Draw(ERenderOptions /*Options*/, int ComponentIndex, const SViewInfo& /*ViewInfo*/) +void CWaypointExtra::Draw(FRenderOptions /*Options*/, int ComponentIndex, const SViewInfo& /*ViewInfo*/) { glBlendFunc(GL_ONE, GL_ZERO); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); diff --git a/src/Core/ScriptExtra/CWaypointExtra.h b/src/Core/ScriptExtra/CWaypointExtra.h index 7a6bc517..2826ecc1 100644 --- a/src/Core/ScriptExtra/CWaypointExtra.h +++ b/src/Core/ScriptExtra/CWaypointExtra.h @@ -24,7 +24,7 @@ public: void LinksModified(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); }; #endif // CWAYPOINTEXTRA_H diff --git a/src/Editor/CBasicViewport.cpp b/src/Editor/CBasicViewport.cpp index f734f9a3..3e0fb11c 100644 --- a/src/Editor/CBasicViewport.cpp +++ b/src/Editor/CBasicViewport.cpp @@ -256,7 +256,7 @@ void CBasicViewport::ProcessInput() if ((XMovement != 0) || (YMovement != 0)) { - mCamera.ProcessMouseInput((EKeyInputs) mKeysPressed, (EMouseInputs) mButtonsPressed, XMovement, YMovement); + mCamera.ProcessMouseInput((FKeyInputs) mKeysPressed, (FMouseInputs) mButtonsPressed, XMovement, YMovement); QCursor::setPos(mLastMousePos); mMouseMoved = true; } @@ -264,7 +264,7 @@ void CBasicViewport::ProcessInput() if (IsKeyboardInputActive()) if ((mKeysPressed & eCtrlKey) == 0) - mCamera.ProcessKeyInput((EKeyInputs) mKeysPressed, DeltaTime); + mCamera.ProcessKeyInput((FKeyInputs) mKeysPressed, DeltaTime); // Update view info const CMatrix4f& View = mCamera.ViewMatrix(); diff --git a/src/Editor/CGizmo.cpp b/src/Editor/CGizmo.cpp index 84c46611..d4c4922d 100644 --- a/src/Editor/CGizmo.cpp +++ b/src/Editor/CGizmo.cpp @@ -55,7 +55,7 @@ void CGizmo::AddToRenderer(CRenderer *pRenderer, const SViewInfo&) CModel *pModel = pPart->pModel; // Determine whether to use the mat set for regular (0) or highlight (1) - EGizmoAxes partAxes = pPart->modelAxes; + FGizmoAxes partAxes = pPart->modelAxes; bool isHighlighted = (partAxes != eNone) && ((mSelectedAxes & partAxes) == pPart->modelAxes); u32 setID = (isHighlighted ? 1 : 0); @@ -69,7 +69,7 @@ void CGizmo::AddToRenderer(CRenderer *pRenderer, const SViewInfo&) } } -void CGizmo::Draw(ERenderOptions /*Options*/, int ComponentIndex, const SViewInfo& /*ViewInfo*/) +void CGizmo::Draw(FRenderOptions /*Options*/, int ComponentIndex, const SViewInfo& /*ViewInfo*/) { // Determine which SModelPart array to use if (ComponentIndex >= (int) mNumCurrentParts) return; @@ -90,12 +90,12 @@ void CGizmo::Draw(ERenderOptions /*Options*/, int ComponentIndex, const SViewInf CGraphics::UpdatePixelBlock(); // Choose material set - EGizmoAxes partAxes = pPart[ComponentIndex].modelAxes; + FGizmoAxes partAxes = pPart[ComponentIndex].modelAxes; bool isHighlighted = (partAxes != eNone) && ((mSelectedAxes & partAxes) == pPart[ComponentIndex].modelAxes); u32 setID = (isHighlighted ? 1 : 0); // Draw model - pPart[ComponentIndex].pModel->Draw((ERenderOptions) 0, setID); + pPart[ComponentIndex].pModel->Draw((FRenderOptions) 0, setID); } void CGizmo::IncrementSize() @@ -221,7 +221,7 @@ u32 CGizmo::NumSelectedAxes() u32 out = 0; for (u32 iAxis = 1; iAxis < 8; iAxis <<= 1) - if (mSelectedAxes & (EGizmoAxes) iAxis) out++; + if (mSelectedAxes & FGizmoAxes(iAxis)) out++; return out; } diff --git a/src/Editor/CGizmo.h b/src/Editor/CGizmo.h index 29fc3909..eecd6dae 100644 --- a/src/Editor/CGizmo.h +++ b/src/Editor/CGizmo.h @@ -1,7 +1,7 @@ #ifndef CGIZMO_H #define CGIZMO_H -#include +#include #include #include #include @@ -44,7 +44,7 @@ public: eTranslate, eRotate, eScale, eOff }; - enum EGizmoAxes + enum EGizmoAxis { eNone = 0x0, eX = 0x1, @@ -55,10 +55,11 @@ public: eYZ = eY | eZ, eXYZ = eX | eY | eZ }; + DECLARE_FLAGS(EGizmoAxis, FGizmoAxes) private: EGizmoMode mMode; - EGizmoAxes mSelectedAxes; + FGizmoAxes mSelectedAxes; ETransformSpace mTransformSpace; CQuaternion mBillboardRotation; float mGizmoSize; @@ -101,13 +102,13 @@ private: // Model parts struct SModelPart { - EGizmoAxes modelAxes; + FGizmoAxes modelAxes; bool enableRayCast; bool isBillboard; TResPtr pModel; SModelPart() {} - SModelPart(EGizmoAxes axes, bool rayCastOn, bool billboard, TResPtr _pModel) : + SModelPart(FGizmoAxes axes, bool rayCastOn, bool billboard, TResPtr _pModel) : modelAxes(axes), enableRayCast(rayCastOn), isBillboard(billboard), pModel(_pModel) {} }; SModelPart *mpCurrentParts; @@ -124,7 +125,7 @@ public: ~CGizmo(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); void IncrementSize(); void DecrementSize(); @@ -164,6 +165,5 @@ protected: private: static void LoadModels(); }; -DEFINE_ENUM_FLAGS(CGizmo::EGizmoAxes) #endif // CGIZMO_H diff --git a/src/Editor/ModelEditor/CModelEditorWindow.cpp b/src/Editor/ModelEditor/CModelEditorWindow.cpp index 197a2257..9da3bd6c 100644 --- a/src/Editor/ModelEditor/CModelEditorWindow.cpp +++ b/src/Editor/ModelEditor/CModelEditorWindow.cpp @@ -206,7 +206,7 @@ void CModelEditorWindow::SetActiveMaterial(int MatIndex) //mpCurrentMat->SetTint(CColor(1.f, 0.5f, 0.5f, 1.f)); // Set up UI - CMaterial::EMaterialOptions Settings = mpCurrentMat->Options(); + CMaterial::FMaterialOptions Settings = mpCurrentMat->Options(); mIgnoreSignals = true; ui->EnableTransparencyCheck->setChecked( Settings & CMaterial::eTransparent ); @@ -267,7 +267,7 @@ void CModelEditorWindow::SetActiveMaterial(int MatIndex) // Set up the tex coord source combo box so it only shows vertex attributes that exist on this material ui->TexCoordSrcComboBox->clear(); - EVertexDescription Desc = mpCurrentMat->VtxDesc(); + FVertexDescription Desc = mpCurrentMat->VtxDesc(); ui->TexCoordSrcComboBox->addItem("None"); if (Desc & ePosition) ui->TexCoordSrcComboBox->addItem("Position"); @@ -516,7 +516,7 @@ void CModelEditorWindow::UpdateMaterial(bool Value) case eEnableOccluderCheckBox: case eEnableLightmapCheckBox: { - CMaterial::EMaterialOptions Options = (CMaterial::EMaterialOptions) (mpCurrentMat->Options() & 0x2408); + CMaterial::FMaterialOptions Options = (mpCurrentMat->Options() & 0x2408); Options |= (ui->EnableTransparencyCheck->isChecked() << 4); Options |= (ui->EnablePunchthroughCheck->isChecked() << 5); Options |= (ui->EnableReflectionCheck->isChecked() << 6);