Implemented TFlags for easy, type-safe bitflags

This commit is contained in:
parax0 2016-01-05 11:50:10 -07:00
parent ee5d5fae0a
commit 5375f34c19
63 changed files with 207 additions and 329 deletions

View File

@ -65,8 +65,8 @@ HEADERS += \
CUniqueID.h \ CUniqueID.h \
EKeyInputs.h \ EKeyInputs.h \
EMouseInputs.h \ EMouseInputs.h \
EnumUtil.h \
ETransformSpace.h \ ETransformSpace.h \
Flags.h \
TString.h \ TString.h \
types.h types.h

View File

@ -1,11 +1,10 @@
#ifndef EKEYINPUTS #ifndef EKEYINPUTS
#define EKEYINPUTS #define EKEYINPUTS
#include "EnumUtil.h" #include "Flags.h"
enum EKeyInputs enum EKeyInput
{ {
eNoKeys = 0,
eCtrlKey = 0x1, eCtrlKey = 0x1,
eAltKey = 0x2, eAltKey = 0x2,
eQKey = 0x4, eQKey = 0x4,
@ -15,7 +14,7 @@ enum EKeyInputs
eSKey = 0x40, eSKey = 0x40,
eDKey = 0x80 eDKey = 0x80
}; };
DEFINE_ENUM_FLAGS(EKeyInputs) DECLARE_FLAGS(EKeyInput, FKeyInputs)
#endif // EKEYINPUTS #endif // EKEYINPUTS

View File

@ -1,15 +1,15 @@
#ifndef EMOUSEINPUTS #ifndef EMOUSEINPUTS
#define EMOUSEINPUTS #define EMOUSEINPUTS
#include "EnumUtil.h" #include "Flags.h"
enum EMouseInputs enum EMouseInput
{ {
eLeftButton = 0x1, eLeftButton = 0x1,
eMiddleButton = 0x2, eMiddleButton = 0x2,
eRightButton = 0x4 eRightButton = 0x4
}; };
DEFINE_ENUM_FLAGS(EMouseInputs) DECLARE_FLAGS(EMouseInput, FMouseInputs)
#endif // EMOUSEINPUTS #endif // EMOUSEINPUTS

View File

@ -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

35
src/Common/Flags.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef FLAGS_H
#define FLAGS_H
#include <Common/types.h>
template<typename FlagEnum>
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<Enum> FlagTypeName;
#endif // FLAGS_H

View File

@ -83,7 +83,6 @@ HEADERS += \
Render/CRenderBucket.h \ Render/CRenderBucket.h \
Render/CRenderer.h \ Render/CRenderer.h \
Render/ERenderCommand.h \ Render/ERenderCommand.h \
Render/ERenderOptions.h \
Render/IRenderable.h \ Render/IRenderable.h \
Render/SRenderablePtr.h \ Render/SRenderablePtr.h \
Render/SViewInfo.h \ Render/SViewInfo.h \
@ -110,13 +109,11 @@ HEADERS += \
Resource/Model/CModel.h \ Resource/Model/CModel.h \
Resource/Model/CStaticModel.h \ Resource/Model/CStaticModel.h \
Resource/Model/CVertex.h \ Resource/Model/CVertex.h \
Resource/Model/EVertexDescription.h \
Resource/Model/SSurface.h \ Resource/Model/SSurface.h \
Resource/Script/CMasterTemplate.h \ Resource/Script/CMasterTemplate.h \
Resource/Script/CScriptLayer.h \ Resource/Script/CScriptLayer.h \
Resource/Script/CScriptObject.h \ Resource/Script/CScriptObject.h \
Resource/Script/CScriptTemplate.h \ Resource/Script/CScriptTemplate.h \
Resource/Script/EObjectType.h \
Resource/Script/EPropertyType.h \ Resource/Script/EPropertyType.h \
Resource/Script/EVolumeShape.h \ Resource/Script/EVolumeShape.h \
Resource/Script/SConnection.h \ Resource/Script/SConnection.h \
@ -180,7 +177,9 @@ HEADERS += \
Resource/Cooker/CAreaCooker.h \ Resource/Cooker/CAreaCooker.h \
Resource/Script/IPropertyValue.h \ Resource/Script/IPropertyValue.h \
Resource/Script/IPropertyTemplate.h \ Resource/Script/IPropertyTemplate.h \
Resource/Script/IProperty.h Resource/Script/IProperty.h \
Resource/Model/EVertexAttribute.h \
Render/FRenderOptions.h
# Source Files # Source Files
SOURCES += \ SOURCES += \

View File

@ -35,14 +35,14 @@ void CDynamicVertexBuffer::Unbind()
glBindVertexArray(0); glBindVertexArray(0);
} }
void CDynamicVertexBuffer::SetActiveAttribs(u32 AttribFlags) void CDynamicVertexBuffer::SetActiveAttribs(FVertexDescription AttribFlags)
{ {
ClearBuffers(); ClearBuffers();
mAttribFlags = (EVertexDescription) AttribFlags; mAttribFlags = AttribFlags;
InitBuffers(); InitBuffers();
} }
void CDynamicVertexBuffer::BufferAttrib(EVertexDescription Attrib, const void *pData) void CDynamicVertexBuffer::BufferAttrib(EVertexAttribute Attrib, const void *pData)
{ {
u32 Index; u32 Index;

View File

@ -1,7 +1,7 @@
#ifndef CDYNAMICVERTEXBUFFER_H #ifndef CDYNAMICVERTEXBUFFER_H
#define CDYNAMICVERTEXBUFFER_H #define CDYNAMICVERTEXBUFFER_H
#include "Core/Resource/Model/EVertexDescription.h" #include "Core/Resource/Model/EVertexAttribute.h"
#include <Common/types.h> #include <Common/types.h>
#include <Math/CVector2f.h> #include <Math/CVector2f.h>
#include <Math/CVector3f.h> #include <Math/CVector3f.h>
@ -11,8 +11,8 @@
class CDynamicVertexBuffer class CDynamicVertexBuffer
{ {
EVertexDescription mAttribFlags; FVertexDescription mAttribFlags;
EVertexDescription mBufferedFlags; FVertexDescription mBufferedFlags;
u32 mNumVertices; u32 mNumVertices;
GLuint mAttribBuffers[12]; GLuint mAttribBuffers[12];
@ -22,8 +22,8 @@ public:
void SetVertexCount(u32 NumVerts); void SetVertexCount(u32 NumVerts);
void Bind(); void Bind();
void Unbind(); void Unbind();
void SetActiveAttribs(u32 AttribFlags); void SetActiveAttribs(FVertexDescription AttribFlags);
void BufferAttrib(EVertexDescription Attrib, const void *pData); void BufferAttrib(EVertexAttribute Attrib, const void *pData);
void ClearBuffers(); void ClearBuffers();
GLuint CreateVAO(); GLuint CreateVAO();
private: private:

View File

@ -153,7 +153,7 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& Mat)
// Input // Input
ShaderCode << "// Input\n"; ShaderCode << "// Input\n";
EVertexDescription VtxDesc = Mat.VtxDesc(); FVertexDescription VtxDesc = Mat.VtxDesc();
if (VtxDesc & ePosition) ShaderCode << "layout(location = 0) in vec3 RawPosition;\n"; if (VtxDesc & ePosition) ShaderCode << "layout(location = 0) in vec3 RawPosition;\n";
if (VtxDesc & eNormal) ShaderCode << "layout(location = 1) in vec3 RawNormal;\n"; if (VtxDesc & eNormal) ShaderCode << "layout(location = 1) in vec3 RawNormal;\n";
if (VtxDesc & eColor0) ShaderCode << "layout(location = 2) in vec4 RawColor0;\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" ShaderCode << "#version 330 core\n"
<< "\n"; << "\n";
EVertexDescription VtxDesc = Mat.VtxDesc(); FVertexDescription VtxDesc = Mat.VtxDesc();
if (VtxDesc & ePosition) ShaderCode << "in vec3 Position;\n"; if (VtxDesc & ePosition) ShaderCode << "in vec3 Position;\n";
if (VtxDesc & eNormal) ShaderCode << "in vec3 Normal;\n"; if (VtxDesc & eNormal) ShaderCode << "in vec3 Normal;\n";
if (VtxDesc & eColor0) ShaderCode << "in vec4 Color0;\n"; if (VtxDesc & eColor0) ShaderCode << "in vec4 Color0;\n";

View File

@ -7,7 +7,7 @@ CVertexBuffer::CVertexBuffer()
SetVertexDesc(ePosition | eNormal | eTex0 | eTex1 | eTex2 | eTex3 | eTex4 | eTex5 | eTex6 | eTex7); SetVertexDesc(ePosition | eNormal | eTex0 | eTex1 | eTex2 | eTex3 | eTex4 | eTex5 | eTex6 | eTex7);
} }
CVertexBuffer::CVertexBuffer(EVertexDescription Desc) CVertexBuffer::CVertexBuffer(FVertexDescription Desc)
{ {
mBuffered = false; mBuffered = false;
SetVertexDesc(Desc); SetVertexDesc(Desc);
@ -174,12 +174,12 @@ bool CVertexBuffer::IsBuffered()
return mBuffered; return mBuffered;
} }
EVertexDescription CVertexBuffer::VertexDesc() FVertexDescription CVertexBuffer::VertexDesc()
{ {
return mVtxDesc; return mVtxDesc;
} }
void CVertexBuffer::SetVertexDesc(EVertexDescription Desc) void CVertexBuffer::SetVertexDesc(FVertexDescription Desc)
{ {
Clear(); Clear();
mVtxDesc = Desc; mVtxDesc = Desc;

View File

@ -2,13 +2,13 @@
#define CVERTEXBUFFER_H #define CVERTEXBUFFER_H
#include "Core/Resource/Model/CVertex.h" #include "Core/Resource/Model/CVertex.h"
#include "Core/Resource/Model/EVertexDescription.h" #include "Core/Resource/Model/EVertexAttribute.h"
#include <vector> #include <vector>
#include <GL/glew.h> #include <GL/glew.h>
class CVertexBuffer 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. GLuint mAttribBuffers[12]; // Separate GL buffer for each attribute to allow not tracking unused attribs. No support for matrix indices currently.
std::vector<CVector3f> mPositions; // Vector of vertex positions std::vector<CVector3f> mPositions; // Vector of vertex positions
std::vector<CVector3f> mNormals; // Vector of vertex normals std::vector<CVector3f> mNormals; // Vector of vertex normals
@ -18,7 +18,7 @@ class CVertexBuffer
public: public:
CVertexBuffer(); CVertexBuffer();
CVertexBuffer(EVertexDescription Desc); CVertexBuffer(FVertexDescription Desc);
~CVertexBuffer(); ~CVertexBuffer();
u16 AddVertex(const CVertex& vtx); u16 AddVertex(const CVertex& vtx);
u16 AddIfUnique(const CVertex& vtx, u16 start); u16 AddIfUnique(const CVertex& vtx, u16 start);
@ -28,8 +28,8 @@ public:
void Bind(); void Bind();
void Unbind(); void Unbind();
bool IsBuffered(); bool IsBuffered();
EVertexDescription VertexDesc(); FVertexDescription VertexDesc();
void SetVertexDesc(EVertexDescription Desc); void SetVertexDesc(FVertexDescription Desc);
u32 Size(); u32 Size();
GLuint CreateVAO(); GLuint CreateVAO();
}; };

View File

@ -85,7 +85,7 @@ void CCamera::Snap(CVector3f Position)
mFrustumPlanesDirty = true; mFrustumPlanesDirty = true;
} }
void CCamera::ProcessKeyInput(EKeyInputs KeyFlags, double DeltaTime) void CCamera::ProcessKeyInput(FKeyInputs KeyFlags, double DeltaTime)
{ {
float FDeltaTime = (float) DeltaTime; float FDeltaTime = (float) DeltaTime;
@ -97,7 +97,7 @@ void CCamera::ProcessKeyInput(EKeyInputs KeyFlags, double DeltaTime)
if (KeyFlags & eDKey) Pan(FDeltaTime * 25.f, 0); 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 // Free Camera
if (mMode == eFreeCamera) if (mMode == eFreeCamera)

View File

@ -57,8 +57,8 @@ public:
void Rotate(float XAmount, float YAmount); void Rotate(float XAmount, float YAmount);
void Zoom(float Amount); void Zoom(float Amount);
void Snap(CVector3f Position); void Snap(CVector3f Position);
void ProcessKeyInput(EKeyInputs KeyFlags, double DeltaTime); void ProcessKeyInput(FKeyInputs KeyFlags, double DeltaTime);
void ProcessMouseInput(EKeyInputs KeyFlags, EMouseInputs MouseFlags, float XMovement, float YMovement); void ProcessMouseInput(FKeyInputs KeyFlags, FMouseInputs MouseFlags, float XMovement, float YMovement);
CRay CastRay(CVector2f DeviceCoords) const; CRay CastRay(CVector2f DeviceCoords) const;
void LoadMatrices() const; void LoadMatrices() const;

View File

@ -85,7 +85,7 @@ void CDrawUtil::DrawSquare(const float *pTexCoords)
// Set tex coords // Set tex coords
for (u32 iTex = 0; iTex < 8; iTex++) for (u32 iTex = 0; iTex < 8; iTex++)
{ {
EVertexDescription TexAttrib = (EVertexDescription) (eTex0 << (iTex *2)); EVertexAttribute TexAttrib = (EVertexAttribute) (eTex0 << (iTex *2));
mSquareVertices.BufferAttrib(TexAttrib, pTexCoords); mSquareVertices.BufferAttrib(TexAttrib, pTexCoords);
} }
@ -453,7 +453,7 @@ void CDrawUtil::InitSquare()
for (u32 iTex = 0; iTex < 8; iTex++) for (u32 iTex = 0; iTex < 8; iTex++)
{ {
EVertexDescription Attrib = (EVertexDescription) (eTex0 << (iTex *2)); EVertexAttribute Attrib = (EVertexAttribute) (eTex0 << (iTex *2));
mSquareVertices.BufferAttrib(Attrib, SquareTexCoords); mSquareVertices.BufferAttrib(Attrib, SquareTexCoords);
} }

View File

@ -74,7 +74,7 @@ void CRenderBucket::Clear()
void CRenderBucket::Draw(const SViewInfo& ViewInfo) void CRenderBucket::Draw(const SViewInfo& ViewInfo)
{ {
ERenderOptions Options = ViewInfo.pRenderer->RenderOptions(); FRenderOptions Options = ViewInfo.pRenderer->RenderOptions();
for (u32 n = 0; n < mSize; n++) for (u32 n = 0; n < mSize; n++)
{ {

View File

@ -2,7 +2,7 @@
#define CRENDERBUCKET_H #define CRENDERBUCKET_H
#include "CCamera.h" #include "CCamera.h"
#include "ERenderOptions.h" #include "FRenderOptions.h"
#include "SRenderablePtr.h" #include "SRenderablePtr.h"
#include <Common/types.h> #include <Common/types.h>
#include <vector> #include <vector>

View File

@ -53,7 +53,7 @@ void CRenderer::Init()
} }
// ************ GETTERS/SETTERS ************ // ************ GETTERS/SETTERS ************
ERenderOptions CRenderer::RenderOptions() const FRenderOptions CRenderer::RenderOptions() const
{ {
return mOptions; return mOptions;
} }

View File

@ -4,7 +4,7 @@
#include "CCamera.h" #include "CCamera.h"
#include "CGraphics.h" #include "CGraphics.h"
#include "CRenderBucket.h" #include "CRenderBucket.h"
#include "ERenderOptions.h" #include "FRenderOptions.h"
#include "ERenderCommand.h" #include "ERenderCommand.h"
#include "SRenderablePtr.h" #include "SRenderablePtr.h"
#include "SViewInfo.h" #include "SViewInfo.h"
@ -28,7 +28,7 @@ public:
}; };
private: private:
ERenderOptions mOptions; FRenderOptions mOptions;
EBloomMode mBloomMode; EBloomMode mBloomMode;
bool mDrawGrid; bool mDrawGrid;
CColor mClearColor; CColor mClearColor;
@ -54,7 +54,7 @@ public:
void Init(); void Init();
// Getters/Setters // Getters/Setters
ERenderOptions RenderOptions() const; FRenderOptions RenderOptions() const;
void ToggleWorld(bool b); void ToggleWorld(bool b);
void ToggleWorldCollision(bool b); void ToggleWorldCollision(bool b);
void ToggleObjects(bool b); void ToggleObjects(bool b);

View File

@ -1,9 +1,9 @@
#ifndef ERENDEROPTIONS #ifndef FRENDEROPTIONS_H
#define ERENDEROPTIONS #define FRENDEROPTIONS_H
#include <Common/EnumUtil.h> #include <Common/Flags.h>
enum ERenderOptions enum ERenderOption
{ {
eNoRenderOptions = 0x0, eNoRenderOptions = 0x0,
eDrawWorld = 0x1, eDrawWorld = 0x1,
@ -19,7 +19,7 @@ enum ERenderOptions
eEnableBloom = 0x400, eEnableBloom = 0x400,
eNoAlpha = 0x800 eNoAlpha = 0x800
}; };
DEFINE_ENUM_FLAGS(ERenderOptions) DECLARE_FLAGS(ERenderOption, FRenderOptions)
#endif // ERENDEROPTIONS #endif // FRENDEROPTIONS_H

View File

@ -1,7 +1,7 @@
#ifndef IRENDERABLE_H #ifndef IRENDERABLE_H
#define IRENDERABLE_H #define IRENDERABLE_H
#include "ERenderOptions.h" #include "FRenderOptions.h"
#include "SViewInfo.h" #include "SViewInfo.h"
#include <Common/types.h> #include <Common/types.h>
@ -13,7 +13,7 @@ public:
IRenderable() {} IRenderable() {}
virtual ~IRenderable() {} virtual ~IRenderable() {}
virtual void AddToRenderer(CRenderer* pRenderer, const SViewInfo& ViewInfo) = 0; 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() {} virtual void DrawSelection() {}
}; };

View File

@ -29,7 +29,7 @@ CMaterial::CMaterial()
mpIndirectTexture = nullptr; mpIndirectTexture = nullptr;
} }
CMaterial::CMaterial(EGame version, EVertexDescription vtxDesc) CMaterial::CMaterial(EGame version, FVertexDescription vtxDesc)
{ {
mpShader = nullptr; mpShader = nullptr;
mShaderStatus = eNoShader; mShaderStatus = eNoShader;
@ -87,7 +87,7 @@ void CMaterial::GenerateShader()
else mShaderStatus = eShaderExists; else mShaderStatus = eShaderExists;
} }
bool CMaterial::SetCurrent(ERenderOptions Options) bool CMaterial::SetCurrent(FRenderOptions Options)
{ {
// Bind textures // Bind textures
const char *skpSamplers[8] = { const char *skpSamplers[8] = {
@ -226,12 +226,12 @@ EGame CMaterial::Version() const
return mVersion; return mVersion;
} }
CMaterial::EMaterialOptions CMaterial::Options() const CMaterial::FMaterialOptions CMaterial::Options() const
{ {
return mOptions; return mOptions;
} }
EVertexDescription CMaterial::VtxDesc() const FVertexDescription CMaterial::VtxDesc() const
{ {
return mVtxDesc; return mVtxDesc;
} }
@ -287,13 +287,13 @@ void CMaterial::SetName(const TString& name)
mName = name; mName = name;
} }
void CMaterial::SetOptions(EMaterialOptions Options) void CMaterial::SetOptions(FMaterialOptions Options)
{ {
mOptions = Options; mOptions = Options;
mRecalcHash = true; mRecalcHash = true;
} }
void CMaterial::SetVertexDescription(EVertexDescription desc) void CMaterial::SetVertexDescription(FVertexDescription desc)
{ {
mVtxDesc = desc; mVtxDesc = desc;
mRecalcHash = true; mRecalcHash = true;

View File

@ -5,12 +5,12 @@
#include "CTexture.h" #include "CTexture.h"
#include "EGame.h" #include "EGame.h"
#include "TResPtr.h" #include "TResPtr.h"
#include "Core/Resource/Model/EVertexDescription.h" #include "Core/Resource/Model/EVertexAttribute.h"
#include "Core/Render/ERenderOptions.h" #include "Core/Render/FRenderOptions.h"
#include "Core/OpenGL/CShader.h" #include "Core/OpenGL/CShader.h"
#include <Common/CColor.h> #include <Common/CColor.h>
#include <Common/EnumUtil.h> #include <Common/Flags.h>
#include <Common/types.h> #include <Common/types.h>
#include <FileIO/IInputStream.h> #include <FileIO/IInputStream.h>
@ -23,7 +23,7 @@ public:
friend class CMaterialCooker; friend class CMaterialCooker;
// Enums // Enums
enum EMaterialOptions enum EMaterialOption
{ {
eNoSettings = 0, eNoSettings = 0,
eKonst = 0x8, eKonst = 0x8,
@ -38,6 +38,7 @@ public:
eShortTexCoord = 0x2000, eShortTexCoord = 0x2000,
eAllSettings = 0x2FF8 eAllSettings = 0x2FF8
}; };
DECLARE_FLAGS(EMaterialOption, FMaterialOptions)
private: private:
enum EShaderStatus 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. bool mEnableBloom; // Bool that toggles bloom on or off. On by default on MP3 materials, off by default on MP1 materials.
EGame mVersion; EGame mVersion;
EMaterialOptions mOptions; // See the EMaterialOptions enum above FMaterialOptions mOptions; // See the EMaterialOptions enum above
EVertexDescription mVtxDesc; // Descriptor of vertex attributes used by this material FVertexDescription mVtxDesc; // Descriptor of vertex attributes used by this material
CColor mKonstColors[4]; // Konst color values for TEV CColor mKonstColors[4]; // Konst color values for TEV
GLenum mBlendSrcFac; // Source blend factor GLenum mBlendSrcFac; // Source blend factor
GLenum mBlendDstFac; // Dest blend factor GLenum mBlendDstFac; // Dest blend factor
@ -72,19 +73,19 @@ private:
public: public:
CMaterial(); CMaterial();
CMaterial(EGame version, EVertexDescription vtxDesc); CMaterial(EGame version, FVertexDescription vtxDesc);
~CMaterial(); ~CMaterial();
CMaterial* Clone(); CMaterial* Clone();
void GenerateShader(); void GenerateShader();
bool SetCurrent(ERenderOptions Options); bool SetCurrent(FRenderOptions Options);
u64 HashParameters(); u64 HashParameters();
void Update(); void Update();
// Getters // Getters
TString Name() const; TString Name() const;
EGame Version() const; EGame Version() const;
EMaterialOptions Options() const; FMaterialOptions Options() const;
EVertexDescription VtxDesc() const; FVertexDescription VtxDesc() const;
GLenum BlendSrcFac() const; GLenum BlendSrcFac() const;
GLenum BlendDstFac() const; GLenum BlendDstFac() const;
CColor Konst(u32 KIndex) const; CColor Konst(u32 KIndex) const;
@ -97,8 +98,8 @@ public:
// Setters // Setters
void SetName(const TString& name); void SetName(const TString& name);
void SetOptions(EMaterialOptions Options); void SetOptions(FMaterialOptions Options);
void SetVertexDescription(EVertexDescription desc); void SetVertexDescription(FVertexDescription desc);
void SetBlendMode(GLenum SrcFac, GLenum DstFac); void SetBlendMode(GLenum SrcFac, GLenum DstFac);
void SetKonst(CColor& Konst, u32 KIndex); void SetKonst(CColor& Konst, u32 KIndex);
void SetIndTexture(CTexture *pTex); void SetIndTexture(CTexture *pTex);
@ -108,6 +109,5 @@ public:
// Static // Static
static void KillCachedMaterial(); static void KillCachedMaterial();
}; };
DEFINE_ENUM_FLAGS(CMaterial::EMaterialOptions)
#endif // MATERIAL_H #endif // MATERIAL_H

View File

@ -81,7 +81,7 @@ void CMaterialPass::LoadTexture(u32 PassIndex)
mpTexture->Bind(PassIndex); mpTexture->Bind(PassIndex);
} }
void CMaterialPass::SetAnimCurrent(ERenderOptions Options, u32 PassIndex) void CMaterialPass::SetAnimCurrent(FRenderOptions Options, u32 PassIndex)
{ {
if (mAnimMode == eNoUVAnim) return; if (mAnimMode == eNoUVAnim) return;

View File

@ -4,7 +4,7 @@
#include "TResPtr.h" #include "TResPtr.h"
#include "CTexture.h" #include "CTexture.h"
#include "ETevEnums.h" #include "ETevEnums.h"
#include "Core/Render/ERenderOptions.h" #include "Core/Render/FRenderOptions.h"
#include <Common/CFourCC.h> #include <Common/CFourCC.h>
#include <Common/CHashFNV1A.h> #include <Common/CHashFNV1A.h>
@ -47,7 +47,7 @@ public:
CMaterialPass* Clone(CMaterial *pParent); CMaterialPass* Clone(CMaterial *pParent);
void HashParameters(CHashFNV1A& Hash); void HashParameters(CHashFNV1A& Hash);
void LoadTexture(u32 PassIndex); void LoadTexture(u32 PassIndex);
void SetAnimCurrent(ERenderOptions Options, u32 PassIndex); void SetAnimCurrent(FRenderOptions Options, u32 PassIndex);
// Setters // Setters
void SetType(CFourCC Type); void SetType(CFourCC Type);

View File

@ -141,7 +141,7 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out)
else else
Flags = 0x4002; Flags = 0x4002;
Flags |= (HasKonst << 3) | mpMat->Options() | (TexFlags << 16); Flags |= (HasKonst ? 0x8 : 0x0) | mpMat->Options() | (TexFlags << 16);
Out.WriteLong(Flags); Out.WriteLong(Flags);
@ -151,10 +151,10 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& Out)
Out.WriteLong(TexIndices[iTex]); Out.WriteLong(TexIndices[iTex]);
// Vertex description // Vertex description
EVertexDescription Desc = mpMat->VtxDesc(); FVertexDescription Desc = mpMat->VtxDesc();
if (mVersion < eEchoes) if (mVersion < eEchoes)
Desc = (EVertexDescription) (Desc & 0x00FFFFFF); Desc &= 0x00FFFFFF;
Out.WriteLong(Desc); Out.WriteLong(Desc);

View File

@ -164,7 +164,7 @@ void CModelCooker::WriteModelPrime(IOutputStream& Out)
Out.WriteToBoundary(32, 0); Out.WriteToBoundary(32, 0);
u32 PrimTableStart = Out.Tell(); 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++) for (u32 iPrim = 0; iPrim < pSurface->Primitives.size(); iPrim++)
{ {

View File

@ -14,7 +14,7 @@ class CModelCooker
u32 mNumVertices; u32 mNumVertices;
u8 mVertexFormat; u8 mVertexFormat;
std::vector<CVertex> mVertices; std::vector<CVertex> mVertices;
EVertexDescription mVtxAttribs; FVertexDescription mVtxAttribs;
CModelCooker(); CModelCooker();
void GenerateSurfaceData(); void GenerateSurfaceData();

View File

@ -50,7 +50,7 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
pMat->mEnableBloom = false; pMat->mEnableBloom = false;
// Flags // Flags
pMat->mOptions = (CMaterial::EMaterialOptions) (mpFile->ReadLong() & CMaterial::eAllSettings); pMat->mOptions = (mpFile->ReadLong() & CMaterial::eAllSettings);
// Textures // Textures
u32 NumTextures = mpFile->ReadLong(); u32 NumTextures = mpFile->ReadLong();
@ -63,7 +63,7 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
} }
// Vertex description // Vertex description
pMat->mVtxDesc = (EVertexDescription) mpFile->ReadLong(); pMat->mVtxDesc = (FVertexDescription) mpFile->ReadLong();
// Unknowns // Unknowns
if (mVersion >= eEchoesDemo) if (mVersion >= eEchoesDemo)
@ -266,7 +266,7 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
mHas0x400 = ((Flags & 0x400) != 0); mHas0x400 = ((Flags & 0x400) != 0);
mpFile->Seek(0x8, SEEK_CUR); // Don't know what any of this is 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); mpFile->Seek(0xC, SEEK_CUR);
// Initialize all KColors to white // Initialize all KColors to white

View File

@ -142,7 +142,7 @@ SSurface* CModelLoader::LoadSurface(IInputStream& Model)
for (u16 iVtx = 0; iVtx < VertexCount; iVtx++) for (u16 iVtx = 0; iVtx < VertexCount; iVtx++)
{ {
CVertex Vtx; CVertex Vtx;
EVertexDescription VtxDesc = pMat->VtxDesc(); FVertexDescription VtxDesc = pMat->VtxDesc();
for (u32 iMtxAttr = 0; iMtxAttr < 8; iMtxAttr++) for (u32 iMtxAttr = 0; iMtxAttr < 8; iMtxAttr++)
if (VtxDesc & (ePosMtx << iMtxAttr)) Model.Seek(0x1, SEEK_CUR); 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 // Create vertex description and assign it to material
CMaterial *pMat = pSet->MaterialByIndex(pMesh->mMaterialIndex); CMaterial *pMat = pSet->MaterialByIndex(pMesh->mMaterialIndex);
EVertexDescription desc = pMat->VtxDesc(); FVertexDescription desc = pMat->VtxDesc();
if (desc == eNoAttributes) if (desc == eNoAttributes)
{ {

View File

@ -6,7 +6,7 @@
#include "Core/Resource/Model/CModel.h" #include "Core/Resource/Model/CModel.h"
#include "Core/Resource/CResCache.h" #include "Core/Resource/CResCache.h"
#include "Core/Resource/EGame.h" #include "Core/Resource/EGame.h"
#include <Common/EnumUtil.h> #include <Common/Flags.h>
#include <FileIO/FileIO.h> #include <FileIO/FileIO.h>
#include <assimp/scene.h> #include <assimp/scene.h>
@ -14,7 +14,7 @@
class CModelLoader class CModelLoader
{ {
public: public:
enum EModelFlags enum EModelFlag
{ {
eNoFlags = 0x0, eNoFlags = 0x0,
eShortPositions = 0x1, eShortPositions = 0x1,
@ -22,6 +22,7 @@ public:
eHasTex1 = 0x4, eHasTex1 = 0x4,
eHasVisGroups = 0x8 eHasVisGroups = 0x8
}; };
DECLARE_FLAGS(EModelFlag, FModelFlags)
private: private:
TResPtr<CModel> mpModel; TResPtr<CModel> mpModel;
@ -41,7 +42,7 @@ private:
u32 mSurfaceCount; u32 mSurfaceCount;
std::vector<u32> mSurfaceOffsets; std::vector<u32> mSurfaceOffsets;
EModelFlags mFlags; FModelFlags mFlags;
CModelLoader(); CModelLoader();
~CModelLoader(); ~CModelLoader();
@ -62,6 +63,4 @@ public:
static EGame GetFormatVersion(u32 Version); static EGame GetFormatVersion(u32 Version);
}; };
DEFINE_ENUM_FLAGS(CModelLoader::EModelFlags)
#endif // CMODELLOADER_H #endif // CMODELLOADER_H

View File

@ -82,14 +82,14 @@ void CModel::ClearGLBuffer()
mBuffered = false; mBuffered = false;
} }
void CModel::Draw(ERenderOptions Options, u32 MatSet) void CModel::Draw(FRenderOptions Options, u32 MatSet)
{ {
if (!mBuffered) BufferGL(); if (!mBuffered) BufferGL();
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++) for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
DrawSurface(Options, iSurf, MatSet); 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(); if (!mBuffered) BufferGL();
@ -122,7 +122,7 @@ void CModel::DrawSurface(ERenderOptions Options, u32 Surface, u32 MatSet)
mVBO.Unbind(); mVBO.Unbind();
} }
void CModel::DrawWireframe(ERenderOptions Options, CColor WireColor /*= CColor::skWhite*/) void CModel::DrawWireframe(FRenderOptions Options, CColor WireColor /*= CColor::skWhite*/)
{ {
if (!mBuffered) BufferGL(); if (!mBuffered) BufferGL();

View File

@ -6,7 +6,7 @@
#include "Core/Resource/CMaterialSet.h" #include "Core/Resource/CMaterialSet.h"
#include "Core/OpenGL/CIndexBuffer.h" #include "Core/OpenGL/CIndexBuffer.h"
#include "Core/OpenGL/GLCommon.h" #include "Core/OpenGL/GLCommon.h"
#include "Core/Render/ERenderOptions.h" #include "Core/Render/FRenderOptions.h"
class CModel : public CBasicModel class CModel : public CBasicModel
{ {
@ -24,9 +24,9 @@ public:
void BufferGL(); void BufferGL();
void ClearGLBuffer(); void ClearGLBuffer();
void Draw(ERenderOptions Options, u32 MatSet); void Draw(FRenderOptions Options, u32 MatSet);
void DrawSurface(ERenderOptions Options, u32 Surface, u32 MatSet); void DrawSurface(FRenderOptions Options, u32 Surface, u32 MatSet);
void DrawWireframe(ERenderOptions Options, CColor WireColor = CColor::skWhite); void DrawWireframe(FRenderOptions Options, CColor WireColor = CColor::skWhite);
u32 GetMatSetCount(); u32 GetMatSetCount();
u32 GetMatCount(); u32 GetMatCount();

View File

@ -97,7 +97,7 @@ void CStaticModel::ClearGLBuffer()
mBuffered = false; mBuffered = false;
} }
void CStaticModel::Draw(ERenderOptions Options) void CStaticModel::Draw(FRenderOptions Options)
{ {
if (!mBuffered) BufferGL(); if (!mBuffered) BufferGL();
@ -119,7 +119,7 @@ void CStaticModel::Draw(ERenderOptions Options)
mVBO.Unbind(); mVBO.Unbind();
} }
void CStaticModel::DrawSurface(ERenderOptions Options, u32 Surface) void CStaticModel::DrawSurface(FRenderOptions Options, u32 Surface)
{ {
if (!mBuffered) BufferGL(); if (!mBuffered) BufferGL();
@ -144,7 +144,7 @@ void CStaticModel::DrawSurface(ERenderOptions Options, u32 Surface)
mVBO.Unbind(); mVBO.Unbind();
} }
void CStaticModel::DrawWireframe(ERenderOptions Options, CColor WireColor /*= CColor::skWhite*/) void CStaticModel::DrawWireframe(FRenderOptions Options, CColor WireColor /*= CColor::skWhite*/)
{ {
if (!mBuffered) BufferGL(); if (!mBuffered) BufferGL();

View File

@ -2,7 +2,7 @@
#define CSTATICMODEL_H #define CSTATICMODEL_H
#include "CBasicModel.h" #include "CBasicModel.h"
#include "Core/Render/ERenderOptions.h" #include "Core/Render/FRenderOptions.h"
#include "Core/OpenGL/CIndexBuffer.h" #include "Core/OpenGL/CIndexBuffer.h"
/* A CStaticModel is meant for meshes that don't move. It's built specifically with terrain in mind. /* 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 BufferGL();
void ClearGLBuffer(); void ClearGLBuffer();
void Draw(ERenderOptions Options); void Draw(FRenderOptions Options);
void DrawSurface(ERenderOptions Options, u32 Surface); void DrawSurface(FRenderOptions Options, u32 Surface);
void DrawWireframe(ERenderOptions Options, CColor WireColor = CColor::skWhite); void DrawWireframe(FRenderOptions Options, CColor WireColor = CColor::skWhite);
CMaterial* GetMaterial(); CMaterial* GetMaterial();
void SetMaterial(CMaterial *pMat); void SetMaterial(CMaterial *pMat);

View File

@ -1,9 +1,9 @@
#ifndef EVERTEXDESCRIPTION #ifndef EVERTEXATTRIBUTE
#define EVERTEXDESCRIPTION #define EVERTEXATTRIBUTE
#include <Common/EnumUtil.h> #include <Common/Flags.h>
enum EVertexDescription enum EVertexAttribute
{ {
eNoAttributes = 0x0, eNoAttributes = 0x0,
ePosition = 0x3, ePosition = 0x3,
@ -27,7 +27,7 @@ enum EVertexDescription
eTex5Mtx = 0x40000000, eTex5Mtx = 0x40000000,
eTex6Mtx = 0x80000000 eTex6Mtx = 0x80000000
}; };
DEFINE_ENUM_FLAGS(EVertexDescription) DECLARE_FLAGS(EVertexAttribute, FVertexDescription)
#endif // EVERTEXDESCRIPTION #endif // EVERTEXATTRIBUTE

View File

@ -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

View File

@ -27,7 +27,7 @@ void CCollisionNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewIn
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection); 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; if (!mpCollision) return;

View File

@ -12,7 +12,7 @@ public:
CCollisionNode(CSceneManager *pScene, CSceneNode *pParent = 0, CCollisionMeshGroup *pCollision = 0); CCollisionNode(CSceneManager *pScene, CSceneNode *pParent = 0, CCollisionMeshGroup *pCollision = 0);
ENodeType NodeType(); ENodeType NodeType();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); 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); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);
void SetCollision(CCollisionMeshGroup *pCollision); void SetCollision(CCollisionMeshGroup *pCollision);
}; };

View File

@ -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)); CDrawUtil::DrawLightBillboard(mpLight->GetType(), mpLight->GetColor(), mPosition, BillboardScale(), TintColor(ViewInfo));
} }

View File

@ -11,7 +11,7 @@ public:
CLightNode(CSceneManager *pScene, CSceneNode *pParent = 0, CLight *Light = 0); CLightNode(CSceneManager *pScene, CSceneNode *pParent = 0, CLight *Light = 0);
ENodeType NodeType(); ENodeType NodeType();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); 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 DrawSelection();
void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo);
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);

View File

@ -32,10 +32,10 @@ void CModelNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection); 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 (!mpModel) return;
if (mForceAlphaOn) Options = (ERenderOptions) (Options & ~eNoAlpha); if (mForceAlphaOn) Options = (FRenderOptions) (Options & ~eNoAlpha);
if (mLightingEnabled) if (mLightingEnabled)
{ {
@ -84,7 +84,7 @@ SRayIntersection CModelNode::RayNodeIntersectTest(const CRay &Ray, u32 AssetID,
out.ComponentIndex = AssetID; out.ComponentIndex = AssetID;
CRay TransformedRay = Ray.Transformed(Transform().Inverse()); CRay TransformedRay = Ray.Transformed(Transform().Inverse());
ERenderOptions options = ViewInfo.pRenderer->RenderOptions(); FRenderOptions options = ViewInfo.pRenderer->RenderOptions();
std::pair<bool,float> Result = mpModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((options & eEnableBackfaceCull) == 0)); std::pair<bool,float> Result = mpModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((options & eEnableBackfaceCull) == 0));
if (Result.first) if (Result.first)

View File

@ -16,7 +16,7 @@ public:
virtual ENodeType NodeType(); virtual ENodeType NodeType();
virtual void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); 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 DrawSelection();
virtual void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); virtual void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo);
virtual SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); virtual SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);

View File

@ -11,7 +11,7 @@ public:
explicit CRootNode(CSceneManager *pScene, CSceneNode *pParent = 0) : CSceneNode(pScene, pParent) {} explicit CRootNode(CSceneManager *pScene, CSceneNode *pParent = 0) : CSceneNode(pScene, pParent) {}
~CRootNode() {} ~CRootNode() {}
inline ENodeType NodeType() { ENodeType NodeType() {
return eRootNode; return eRootNode;
} }

View File

@ -214,7 +214,7 @@ void CSceneManager::ClearScene()
void CSceneManager::AddSceneToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo) void CSceneManager::AddSceneToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
{ {
ERenderOptions Options = pRenderer->RenderOptions(); FRenderOptions Options = pRenderer->RenderOptions();
if (Options & eDrawWorld || ViewInfo.GameMode) 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 // Terribly hacky stuff to avoid having tons of redundant code
// because I'm too lazy to rewrite CSceneManager right now and fix it // because I'm too lazy to rewrite CSceneManager right now and fix it
// (I'm probably going to do it soon...) // (I'm probably going to do it soon...)
ERenderOptions renderOptions = ViewInfo.pRenderer->RenderOptions(); FRenderOptions renderOptions = ViewInfo.pRenderer->RenderOptions();
std::vector<CSceneNode*> *pNodeVectors[5] = { std::vector<CSceneNode*> *pNodeVectors[5] = {
reinterpret_cast<std::vector<CSceneNode*>*>(&mModelNodes), reinterpret_cast<std::vector<CSceneNode*>*>(&mModelNodes),
@ -265,7 +265,7 @@ SRayIntersection CSceneManager::SceneRayCast(const CRay& Ray, const SViewInfo& V
}; };
bool NodesVisible[5] = { bool NodesVisible[5] = {
true, ((renderOptions & eDrawWorld) != 0), ((renderOptions & eDrawWorldCollision) != 0), 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 // Override visibility for game mode

View File

@ -2,7 +2,7 @@
#define CSCENENODE_H #define CSCENENODE_H
#include "ENodeType.h" #include "ENodeType.h"
#include "Core/Render/ERenderOptions.h" #include "Core/Render/FRenderOptions.h"
#include "Core/Render/IRenderable.h" #include "Core/Render/IRenderable.h"
#include "Core/Resource/CLight.h" #include "Core/Resource/CLight.h"
#include "Core/Resource/CGameArea.h" #include "Core/Resource/CGameArea.h"

View File

@ -119,7 +119,7 @@ void CScriptNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
if (ShouldDraw) if (ShouldDraw)
{ {
// Otherwise, we proceed as normal // Otherwise, we proceed as normal
ERenderOptions options = pRenderer->RenderOptions(); FRenderOptions options = pRenderer->RenderOptions();
if ((options & eDrawObjectCollision) && (!ViewInfo.GameMode)) if ((options & eDrawObjectCollision) && (!ViewInfo.GameMode))
mpCollisionNode->AddToRenderer(pRenderer, ViewInfo); 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; 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) SRayIntersection CScriptNode::RayNodeIntersectTest(const CRay& Ray, u32 AssetID, const SViewInfo& ViewInfo)
{ {
ERenderOptions options = ViewInfo.pRenderer->RenderOptions(); FRenderOptions options = ViewInfo.pRenderer->RenderOptions();
SRayIntersection out; SRayIntersection out;
out.pNode = this; out.pNode = this;

View File

@ -26,7 +26,7 @@ public:
CScriptNode(CSceneManager *pScene, CSceneNode *pParent = 0, CScriptObject *pObject = 0); CScriptNode(CSceneManager *pScene, CSceneNode *pParent = 0, CScriptObject *pObject = 0);
ENodeType NodeType(); ENodeType NodeType();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); 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 DrawSelection();
void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo);
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);

View File

@ -44,7 +44,7 @@ void CStaticNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection); 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; if (!mpModel) return;
@ -96,7 +96,7 @@ SRayIntersection CStaticNode::RayNodeIntersectTest(const CRay &Ray, u32 AssetID,
out.ComponentIndex = AssetID; out.ComponentIndex = AssetID;
CRay TransformedRay = Ray.Transformed(Transform().Inverse()); CRay TransformedRay = Ray.Transformed(Transform().Inverse());
ERenderOptions options = ViewInfo.pRenderer->RenderOptions(); FRenderOptions options = ViewInfo.pRenderer->RenderOptions();
std::pair<bool,float> Result = mpModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((options & eEnableBackfaceCull) == 0)); std::pair<bool,float> Result = mpModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((options & eEnableBackfaceCull) == 0));
if (Result.first) if (Result.first)

View File

@ -12,7 +12,7 @@ public:
CStaticNode(CSceneManager *pScene, CSceneNode *pParent = 0, CStaticModel *pModel = 0); CStaticNode(CSceneManager *pScene, CSceneNode *pParent = 0, CStaticModel *pModel = 0);
ENodeType NodeType(); ENodeType NodeType();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); 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 DrawSelection();
void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo);
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);

View File

@ -1,5 +1,5 @@
#ifndef ENODETYPE #ifndef ENODETYPE_H
#define ENODETYPE #define ENODETYPE_H
enum ENodeType enum ENodeType
{ {
@ -12,5 +12,5 @@ enum ENodeType
eLightNode eLightNode
}; };
#endif // ENODETYPE #endif // ENODETYPE_H

View File

@ -0,0 +1,19 @@
#ifndef EVISIBILITYFLAGS
#define EVISIBILITYFLAGS
#include <Common/EnumUtil.h>
enum EVisibilityFlags
{
eShowNomr = 0x00,
eShowWorld = 0x01,
eShowWorldCollision = 0x02,
eShowObjects = 0x04,
eShowObjectCollision = 0x08,
eShowLights = 0x10,
eShowAll = 0x1F
};
DEFINE_ENUM_FLAGS(EVisibilityFlags)
#endif // EVISIBILITYFLAGS

View File

@ -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(); LoadModelMatrix();
CGraphics::sPixelBlock.TintColor = mpParent->TintColor(ViewInfo); CGraphics::sPixelBlock.TintColor = mpParent->TintColor(ViewInfo);

View File

@ -36,7 +36,7 @@ public:
void PropertyModified(IProperty *pProperty); void PropertyModified(IProperty *pProperty);
bool ShouldDrawNormalAssets(); bool ShouldDrawNormalAssets();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); 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 DrawSelection();
void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo);
SRayIntersection RayNodeIntersectTest(const CRay& Ray, u32 ComponentIndex, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay& Ray, u32 ComponentIndex, const SViewInfo& ViewInfo);

View File

@ -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(); LoadModelMatrix();
mpParent->LoadLights(ViewInfo); 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) SRayIntersection CDoorExtra::RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo)
{ {
ERenderOptions Options = ViewInfo.pRenderer->RenderOptions(); FRenderOptions Options = ViewInfo.pRenderer->RenderOptions();
SRayIntersection out; SRayIntersection out;
out.pNode = mpParent; out.pNode = mpParent;

View File

@ -16,7 +16,7 @@ public:
explicit CDoorExtra(CScriptObject *pInstance, CSceneManager *pScene, CSceneNode *pParent = 0); explicit CDoorExtra(CScriptObject *pInstance, CSceneManager *pScene, CSceneNode *pParent = 0);
void PropertyModified(IProperty *pProperty); void PropertyModified(IProperty *pProperty);
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); 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 DrawSelection();
void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo);
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);

View File

@ -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); glBlendFunc(GL_ONE, GL_ZERO);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

View File

@ -12,7 +12,7 @@ class CRadiusSphereExtra : public CScriptExtra
public: public:
explicit CRadiusSphereExtra(CScriptObject *pInstance, CSceneManager *pScene, CSceneNode *pParent = 0); explicit CRadiusSphereExtra(CScriptObject *pInstance, CSceneManager *pScene, CSceneNode *pParent = 0);
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); 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; CColor Color() const;
CAABox Bounds() const; CAABox Bounds() const;
}; };

View File

@ -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); glBlendFunc(GL_ONE, GL_ZERO);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

View File

@ -24,7 +24,7 @@ public:
void LinksModified(); void LinksModified();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); 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 #endif // CWAYPOINTEXTRA_H

View File

@ -256,7 +256,7 @@ void CBasicViewport::ProcessInput()
if ((XMovement != 0) || (YMovement != 0)) if ((XMovement != 0) || (YMovement != 0))
{ {
mCamera.ProcessMouseInput((EKeyInputs) mKeysPressed, (EMouseInputs) mButtonsPressed, XMovement, YMovement); mCamera.ProcessMouseInput((FKeyInputs) mKeysPressed, (FMouseInputs) mButtonsPressed, XMovement, YMovement);
QCursor::setPos(mLastMousePos); QCursor::setPos(mLastMousePos);
mMouseMoved = true; mMouseMoved = true;
} }
@ -264,7 +264,7 @@ void CBasicViewport::ProcessInput()
if (IsKeyboardInputActive()) if (IsKeyboardInputActive())
if ((mKeysPressed & eCtrlKey) == 0) if ((mKeysPressed & eCtrlKey) == 0)
mCamera.ProcessKeyInput((EKeyInputs) mKeysPressed, DeltaTime); mCamera.ProcessKeyInput((FKeyInputs) mKeysPressed, DeltaTime);
// Update view info // Update view info
const CMatrix4f& View = mCamera.ViewMatrix(); const CMatrix4f& View = mCamera.ViewMatrix();

View File

@ -55,7 +55,7 @@ void CGizmo::AddToRenderer(CRenderer *pRenderer, const SViewInfo&)
CModel *pModel = pPart->pModel; CModel *pModel = pPart->pModel;
// Determine whether to use the mat set for regular (0) or highlight (1) // 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); bool isHighlighted = (partAxes != eNone) && ((mSelectedAxes & partAxes) == pPart->modelAxes);
u32 setID = (isHighlighted ? 1 : 0); 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 // Determine which SModelPart array to use
if (ComponentIndex >= (int) mNumCurrentParts) return; if (ComponentIndex >= (int) mNumCurrentParts) return;
@ -90,12 +90,12 @@ void CGizmo::Draw(ERenderOptions /*Options*/, int ComponentIndex, const SViewInf
CGraphics::UpdatePixelBlock(); CGraphics::UpdatePixelBlock();
// Choose material set // Choose material set
EGizmoAxes partAxes = pPart[ComponentIndex].modelAxes; FGizmoAxes partAxes = pPart[ComponentIndex].modelAxes;
bool isHighlighted = (partAxes != eNone) && ((mSelectedAxes & partAxes) == pPart[ComponentIndex].modelAxes); bool isHighlighted = (partAxes != eNone) && ((mSelectedAxes & partAxes) == pPart[ComponentIndex].modelAxes);
u32 setID = (isHighlighted ? 1 : 0); u32 setID = (isHighlighted ? 1 : 0);
// Draw model // Draw model
pPart[ComponentIndex].pModel->Draw((ERenderOptions) 0, setID); pPart[ComponentIndex].pModel->Draw((FRenderOptions) 0, setID);
} }
void CGizmo::IncrementSize() void CGizmo::IncrementSize()
@ -221,7 +221,7 @@ u32 CGizmo::NumSelectedAxes()
u32 out = 0; u32 out = 0;
for (u32 iAxis = 1; iAxis < 8; iAxis <<= 1) for (u32 iAxis = 1; iAxis < 8; iAxis <<= 1)
if (mSelectedAxes & (EGizmoAxes) iAxis) out++; if (mSelectedAxes & FGizmoAxes(iAxis)) out++;
return out; return out;
} }

View File

@ -1,7 +1,7 @@
#ifndef CGIZMO_H #ifndef CGIZMO_H
#define CGIZMO_H #define CGIZMO_H
#include <Common/EnumUtil.h> #include <Common/Flags.h>
#include <Math/CPlane.h> #include <Math/CPlane.h>
#include <Math/CQuaternion.h> #include <Math/CQuaternion.h>
#include <Math/CVector3f.h> #include <Math/CVector3f.h>
@ -44,7 +44,7 @@ public:
eTranslate, eRotate, eScale, eOff eTranslate, eRotate, eScale, eOff
}; };
enum EGizmoAxes enum EGizmoAxis
{ {
eNone = 0x0, eNone = 0x0,
eX = 0x1, eX = 0x1,
@ -55,10 +55,11 @@ public:
eYZ = eY | eZ, eYZ = eY | eZ,
eXYZ = eX | eY | eZ eXYZ = eX | eY | eZ
}; };
DECLARE_FLAGS(EGizmoAxis, FGizmoAxes)
private: private:
EGizmoMode mMode; EGizmoMode mMode;
EGizmoAxes mSelectedAxes; FGizmoAxes mSelectedAxes;
ETransformSpace mTransformSpace; ETransformSpace mTransformSpace;
CQuaternion mBillboardRotation; CQuaternion mBillboardRotation;
float mGizmoSize; float mGizmoSize;
@ -101,13 +102,13 @@ private:
// Model parts // Model parts
struct SModelPart struct SModelPart
{ {
EGizmoAxes modelAxes; FGizmoAxes modelAxes;
bool enableRayCast; bool enableRayCast;
bool isBillboard; bool isBillboard;
TResPtr<CModel> pModel; TResPtr<CModel> pModel;
SModelPart() {} SModelPart() {}
SModelPart(EGizmoAxes axes, bool rayCastOn, bool billboard, TResPtr<CModel> _pModel) : SModelPart(FGizmoAxes axes, bool rayCastOn, bool billboard, TResPtr<CModel> _pModel) :
modelAxes(axes), enableRayCast(rayCastOn), isBillboard(billboard), pModel(_pModel) {} modelAxes(axes), enableRayCast(rayCastOn), isBillboard(billboard), pModel(_pModel) {}
}; };
SModelPart *mpCurrentParts; SModelPart *mpCurrentParts;
@ -124,7 +125,7 @@ public:
~CGizmo(); ~CGizmo();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); 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 IncrementSize();
void DecrementSize(); void DecrementSize();
@ -164,6 +165,5 @@ protected:
private: private:
static void LoadModels(); static void LoadModels();
}; };
DEFINE_ENUM_FLAGS(CGizmo::EGizmoAxes)
#endif // CGIZMO_H #endif // CGIZMO_H

View File

@ -206,7 +206,7 @@ void CModelEditorWindow::SetActiveMaterial(int MatIndex)
//mpCurrentMat->SetTint(CColor(1.f, 0.5f, 0.5f, 1.f)); //mpCurrentMat->SetTint(CColor(1.f, 0.5f, 0.5f, 1.f));
// Set up UI // Set up UI
CMaterial::EMaterialOptions Settings = mpCurrentMat->Options(); CMaterial::FMaterialOptions Settings = mpCurrentMat->Options();
mIgnoreSignals = true; mIgnoreSignals = true;
ui->EnableTransparencyCheck->setChecked( Settings & CMaterial::eTransparent ); 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 // Set up the tex coord source combo box so it only shows vertex attributes that exist on this material
ui->TexCoordSrcComboBox->clear(); ui->TexCoordSrcComboBox->clear();
EVertexDescription Desc = mpCurrentMat->VtxDesc(); FVertexDescription Desc = mpCurrentMat->VtxDesc();
ui->TexCoordSrcComboBox->addItem("None"); ui->TexCoordSrcComboBox->addItem("None");
if (Desc & ePosition) ui->TexCoordSrcComboBox->addItem("Position"); if (Desc & ePosition) ui->TexCoordSrcComboBox->addItem("Position");
@ -516,7 +516,7 @@ void CModelEditorWindow::UpdateMaterial(bool Value)
case eEnableOccluderCheckBox: case eEnableOccluderCheckBox:
case eEnableLightmapCheckBox: case eEnableLightmapCheckBox:
{ {
CMaterial::EMaterialOptions Options = (CMaterial::EMaterialOptions) (mpCurrentMat->Options() & 0x2408); CMaterial::FMaterialOptions Options = (mpCurrentMat->Options() & 0x2408);
Options |= (ui->EnableTransparencyCheck->isChecked() << 4); Options |= (ui->EnableTransparencyCheck->isChecked() << 4);
Options |= (ui->EnablePunchthroughCheck->isChecked() << 5); Options |= (ui->EnablePunchthroughCheck->isChecked() << 5);
Options |= (ui->EnableReflectionCheck->isChecked() << 6); Options |= (ui->EnableReflectionCheck->isChecked() << 6);