mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-15 16:16:14 +00:00
Cleanup & refactoring
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include <Common/Math/MathUtil.h>
|
||||
|
||||
CCamera::CCamera()
|
||||
: mMode(eFreeCamera)
|
||||
: mMode(ECameraMoveMode::Free)
|
||||
, mPosition(0)
|
||||
, mAspectRatio(1.7777777f)
|
||||
, mYaw(-Math::skHalfPi)
|
||||
@@ -22,7 +22,7 @@ CCamera::CCamera()
|
||||
// todo: make it actually look at the target!
|
||||
// don't actually use this constructor, it's unfinished and won't work properly
|
||||
CCamera::CCamera(CVector3f Position, CVector3f /*Target*/)
|
||||
: mMode(eFreeCamera)
|
||||
: mMode(ECameraMoveMode::Free)
|
||||
, mMoveSpeed(1.f)
|
||||
, mLookSpeed(1.f)
|
||||
, mPosition(Position)
|
||||
@@ -33,7 +33,7 @@ CCamera::CCamera(CVector3f Position, CVector3f /*Target*/)
|
||||
|
||||
void CCamera::Pan(float XAmount, float YAmount)
|
||||
{
|
||||
if (mMode == eFreeCamera)
|
||||
if (mMode == ECameraMoveMode::Free)
|
||||
{
|
||||
mPosition += mRightVector * (XAmount * mMoveSpeed);
|
||||
mPosition += mUpVector * (YAmount * mMoveSpeed);
|
||||
@@ -59,7 +59,7 @@ void CCamera::Rotate(float XAmount, float YAmount)
|
||||
|
||||
void CCamera::Zoom(float Amount)
|
||||
{
|
||||
if (mMode == eFreeCamera)
|
||||
if (mMode == ECameraMoveMode::Free)
|
||||
mPosition += mDirection * (Amount * mMoveSpeed);
|
||||
|
||||
else
|
||||
@@ -86,32 +86,32 @@ void CCamera::ProcessKeyInput(FKeyInputs KeyFlags, double DeltaTime)
|
||||
{
|
||||
float FDeltaTime = (float) DeltaTime;
|
||||
|
||||
if (KeyFlags & eWKey) Zoom(FDeltaTime * 25.f);
|
||||
if (KeyFlags & eSKey) Zoom(-FDeltaTime * 25.f);
|
||||
if (KeyFlags & eQKey) Pan(0, -FDeltaTime * 25.f);
|
||||
if (KeyFlags & eEKey) Pan(0, FDeltaTime * 25.f);
|
||||
if (KeyFlags & eAKey) Pan(-FDeltaTime * 25.f, 0);
|
||||
if (KeyFlags & eDKey) Pan(FDeltaTime * 25.f, 0);
|
||||
if (KeyFlags & EKeyInput::W) Zoom(FDeltaTime * 25.f);
|
||||
if (KeyFlags & EKeyInput::S) Zoom(-FDeltaTime * 25.f);
|
||||
if (KeyFlags & EKeyInput::Q) Pan(0, -FDeltaTime * 25.f);
|
||||
if (KeyFlags & EKeyInput::E) Pan(0, FDeltaTime * 25.f);
|
||||
if (KeyFlags & EKeyInput::A) Pan(-FDeltaTime * 25.f, 0);
|
||||
if (KeyFlags & EKeyInput::D) Pan(FDeltaTime * 25.f, 0);
|
||||
}
|
||||
|
||||
void CCamera::ProcessMouseInput(FKeyInputs KeyFlags, FMouseInputs MouseFlags, float XMovement, float YMovement)
|
||||
{
|
||||
// Free Camera
|
||||
if (mMode == eFreeCamera)
|
||||
if (mMode == ECameraMoveMode::Free)
|
||||
{
|
||||
if (MouseFlags & eMiddleButton)
|
||||
if (MouseFlags & EMouseInput::MiddleButton)
|
||||
{
|
||||
if (KeyFlags & eCtrlKey) Zoom(-YMovement * 0.2f);
|
||||
else Pan(-XMovement, YMovement);
|
||||
if (KeyFlags & EKeyInput::Ctrl) Zoom(-YMovement * 0.2f);
|
||||
else Pan(-XMovement, YMovement);
|
||||
}
|
||||
|
||||
else if (MouseFlags & eRightButton) Rotate(XMovement, YMovement);
|
||||
else if (MouseFlags & EMouseInput::RightButton) Rotate(XMovement, YMovement);
|
||||
}
|
||||
|
||||
// Orbit Camera
|
||||
else if (mMode == eOrbitCamera)
|
||||
else if (mMode == ECameraMoveMode::Orbit)
|
||||
{
|
||||
if ((MouseFlags & eMiddleButton) || (MouseFlags & eRightButton))
|
||||
if ((MouseFlags & EMouseInput::MiddleButton) || (MouseFlags & EMouseInput::RightButton))
|
||||
Pan(-XMovement, YMovement);
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ void CCamera::SetMoveMode(ECameraMoveMode Mode)
|
||||
mViewDirty = true;
|
||||
mFrustumPlanesDirty = true;
|
||||
|
||||
if (mMode == eOrbitCamera)
|
||||
if (mMode == ECameraMoveMode::Orbit)
|
||||
mTransformDirty = true;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ void CCamera::SetOrbit(const CVector3f& OrbitTarget, float Distance)
|
||||
mOrbitTarget = OrbitTarget;
|
||||
mOrbitDistance = Distance;
|
||||
|
||||
if (mMode == eOrbitCamera)
|
||||
if (mMode == ECameraMoveMode::Orbit)
|
||||
{
|
||||
mTransformDirty = true;
|
||||
mViewDirty = true;
|
||||
@@ -161,7 +161,7 @@ void CCamera::SetOrbit(const CAABox& OrbitTarget, float DistScale /*= 1.75f*/)
|
||||
float Dist = OrbitTarget.Center().Distance(OrbitTarget.Max());
|
||||
mOrbitDistance = Dist * DistScale;
|
||||
|
||||
if (mMode == eOrbitCamera)
|
||||
if (mMode == ECameraMoveMode::Orbit)
|
||||
{
|
||||
mTransformDirty = true;
|
||||
mViewDirty = true;
|
||||
@@ -173,7 +173,7 @@ void CCamera::SetOrbitTarget(const CVector3f& rkOrbitTarget)
|
||||
{
|
||||
mOrbitTarget = rkOrbitTarget;
|
||||
|
||||
if (mMode == eOrbitCamera)
|
||||
if (mMode == ECameraMoveMode::Orbit)
|
||||
{
|
||||
mTransformDirty = true;
|
||||
mViewDirty = true;
|
||||
@@ -185,7 +185,7 @@ void CCamera::SetOrbitDistance(float Distance)
|
||||
{
|
||||
mOrbitDistance = Distance;
|
||||
|
||||
if (mMode == eOrbitCamera)
|
||||
if (mMode == ECameraMoveMode::Orbit)
|
||||
{
|
||||
mTransformDirty = true;
|
||||
mViewDirty = true;
|
||||
@@ -228,7 +228,7 @@ void CCamera::UpdateTransform() const
|
||||
mUpVector = mRightVector.Cross(mDirection);
|
||||
|
||||
// Update position
|
||||
if (mMode == eOrbitCamera)
|
||||
if (mMode == ECameraMoveMode::Orbit)
|
||||
{
|
||||
if (mOrbitDistance < 1.f) mOrbitDistance = 1.f;
|
||||
mPosition = mOrbitTarget + (mDirection * -mOrbitDistance);
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#include <Common/Math/CVector2i.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
|
||||
enum ECameraMoveMode
|
||||
enum class ECameraMoveMode
|
||||
{
|
||||
eFreeCamera, eOrbitCamera
|
||||
Free, Orbit
|
||||
};
|
||||
|
||||
/* This class uses a lot of mutable members as an optimization so that they can
|
||||
|
||||
@@ -87,7 +87,7 @@ void CDrawUtil::DrawSquare(const float *pTexCoords)
|
||||
// Set tex coords
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
{
|
||||
EVertexAttribute TexAttrib = (EVertexAttribute) (eTex0 << (iTex *2));
|
||||
EVertexAttribute TexAttrib = (EVertexAttribute) ((uint) (EVertexAttribute::Tex0) << iTex);
|
||||
mSquareVertices.BufferAttrib(TexAttrib, pTexCoords);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ void CDrawUtil::DrawLine(const CVector3f& PointA, const CVector3f& PointB, const
|
||||
|
||||
// Copy vec3s into an array to ensure they are adjacent in memory
|
||||
CVector3f Points[2] = { PointA, PointB };
|
||||
mLineVertices.BufferAttrib(ePosition, Points);
|
||||
mLineVertices.BufferAttrib(EVertexAttribute::Position, Points);
|
||||
|
||||
// Draw
|
||||
UseColorShader(LineColor);
|
||||
@@ -132,7 +132,7 @@ void CDrawUtil::DrawLine(const CVector2f& PointA, const CVector2f& PointB, const
|
||||
void CDrawUtil::DrawCube()
|
||||
{
|
||||
Init();
|
||||
mpCubeModel->Draw(eNoMaterialSetup, 0);
|
||||
mpCubeModel->Draw(ERenderOption::NoMaterialSetup, 0);
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawCube(const CColor& Color)
|
||||
@@ -186,9 +186,9 @@ void CDrawUtil::DrawSphere(bool DoubleSided)
|
||||
Init();
|
||||
|
||||
if (!DoubleSided)
|
||||
mpSphereModel->Draw(eNoMaterialSetup, 0);
|
||||
mpSphereModel->Draw(ERenderOption::NoMaterialSetup, 0);
|
||||
else
|
||||
mpDoubleSidedSphereModel->Draw(eNoMaterialSetup, 0);
|
||||
mpDoubleSidedSphereModel->Draw(ERenderOption::NoMaterialSetup, 0);
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawSphere(const CColor &kColor)
|
||||
@@ -217,7 +217,7 @@ void CDrawUtil::DrawWireSphere(const CVector3f& Position, float Radius, const CC
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
// Draw
|
||||
mpWireSphereModel->Draw(eNoMaterialSetup, 0);
|
||||
mpWireSphereModel->Draw(ERenderOption::NoMaterialSetup, 0);
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawBillboard(CTexture* pTexture, const CVector3f& Position, const CVector2f& Scale /*= CVector2f::skOne*/, const CColor& Tint /*= CColor::skWhite*/)
|
||||
@@ -366,13 +366,13 @@ void CDrawUtil::LoadCheckerboardTexture(uint32 GLTextureUnit)
|
||||
CTexture* CDrawUtil::GetLightTexture(ELightType Type)
|
||||
{
|
||||
Init();
|
||||
return mpLightTextures[Type];
|
||||
return mpLightTextures[(int) Type];
|
||||
}
|
||||
|
||||
CTexture* CDrawUtil::GetLightMask(ELightType Type)
|
||||
{
|
||||
Init();
|
||||
return mpLightMasks[Type];
|
||||
return mpLightMasks[(int) Type];
|
||||
}
|
||||
|
||||
CModel* CDrawUtil::GetCubeModel()
|
||||
@@ -413,7 +413,7 @@ void CDrawUtil::InitGrid()
|
||||
int MinIdx = (kGridSize - 1) / -2;
|
||||
int MaxIdx = (kGridSize - 1) / 2;
|
||||
|
||||
mGridVertices.SetVertexDesc(ePosition);
|
||||
mGridVertices.SetVertexDesc(EVertexAttribute::Position);
|
||||
mGridVertices.Reserve(kGridSize * 4);
|
||||
|
||||
for (int32 i = MinIdx; i <= MaxIdx; i++)
|
||||
@@ -439,9 +439,16 @@ void CDrawUtil::InitGrid()
|
||||
void CDrawUtil::InitSquare()
|
||||
{
|
||||
debugf("Creating square");
|
||||
mSquareVertices.SetActiveAttribs(ePosition | eNormal |
|
||||
eTex0 | eTex1 | eTex2 | eTex3 |
|
||||
eTex4 | eTex5 | eTex6 | eTex7);
|
||||
mSquareVertices.SetActiveAttribs(EVertexAttribute::Position |
|
||||
EVertexAttribute::Normal |
|
||||
EVertexAttribute::Tex0 |
|
||||
EVertexAttribute::Tex1 |
|
||||
EVertexAttribute::Tex2 |
|
||||
EVertexAttribute::Tex3 |
|
||||
EVertexAttribute::Tex4 |
|
||||
EVertexAttribute::Tex5 |
|
||||
EVertexAttribute::Tex6 |
|
||||
EVertexAttribute::Tex7 );
|
||||
mSquareVertices.SetVertexCount(4);
|
||||
|
||||
CVector3f SquareVertices[] = {
|
||||
@@ -465,12 +472,12 @@ void CDrawUtil::InitSquare()
|
||||
CVector2f(0.f, 0.f)
|
||||
};
|
||||
|
||||
mSquareVertices.BufferAttrib(ePosition, SquareVertices);
|
||||
mSquareVertices.BufferAttrib(eNormal, SquareNormals);
|
||||
mSquareVertices.BufferAttrib(EVertexAttribute::Position, SquareVertices);
|
||||
mSquareVertices.BufferAttrib(EVertexAttribute::Normal, SquareNormals);
|
||||
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
{
|
||||
EVertexAttribute Attrib = (EVertexAttribute) (eTex0 << (iTex *2));
|
||||
EVertexAttribute Attrib = (EVertexAttribute) (EVertexAttribute::Tex0 << iTex);
|
||||
mSquareVertices.BufferAttrib(Attrib, SquareTexCoords);
|
||||
}
|
||||
|
||||
@@ -485,7 +492,7 @@ void CDrawUtil::InitSquare()
|
||||
void CDrawUtil::InitLine()
|
||||
{
|
||||
debugf("Creating line");
|
||||
mLineVertices.SetActiveAttribs(ePosition);
|
||||
mLineVertices.SetActiveAttribs(EVertexAttribute::Position);
|
||||
mLineVertices.SetVertexCount(2);
|
||||
|
||||
mLineIndices.Reserve(2);
|
||||
@@ -503,7 +510,7 @@ void CDrawUtil::InitCube()
|
||||
void CDrawUtil::InitWireCube()
|
||||
{
|
||||
debugf("Creating wire cube");
|
||||
mWireCubeVertices.SetVertexDesc(ePosition);
|
||||
mWireCubeVertices.SetVertexDesc(EVertexAttribute::Position);
|
||||
mWireCubeVertices.Reserve(8);
|
||||
mWireCubeVertices.AddVertex(CVector3f(-0.5f, -0.5f, -0.5f));
|
||||
mWireCubeVertices.AddVertex(CVector3f(-0.5f, 0.5f, -0.5f));
|
||||
|
||||
@@ -7,9 +7,13 @@
|
||||
#include "Core/Resource/model/CModel.h"
|
||||
#include "Core/Resource/CLight.h"
|
||||
|
||||
/* todo: CDrawUtil should work with CRenderer to queue primitives for rendering
|
||||
* rather than trying to draw them straight away, so that CDrawUtil functions can
|
||||
* be called from anywhere in the codebase and still function correctly */
|
||||
/**
|
||||
* @todo there are a LOT of problems with how this is implemented; trying to
|
||||
* use CDrawUtil in a lot of places in the codebase just plain doesn't work
|
||||
* because it goes outside CRenderer to draw stuff, and also it's slow as heck
|
||||
* because it issues tons of draw calls instead of batching items together
|
||||
* which is a cause of significant performance problems
|
||||
*/
|
||||
class CDrawUtil
|
||||
{
|
||||
// 7x7 Grid
|
||||
|
||||
@@ -48,7 +48,7 @@ void CGraphics::Initialize()
|
||||
mpLightBlockBuffer = new CUniformBuffer(sizeof(sLightBlock));
|
||||
mpBoneTransformBuffer = new CUniformBuffer(sizeof(CTransform4f) * 100);
|
||||
|
||||
sLightMode = eWorldLighting;
|
||||
sLightMode = ELightingMode::World;
|
||||
sNumLights = 0;
|
||||
sWorldLightMultiplier = 1.f;
|
||||
|
||||
@@ -175,9 +175,9 @@ void CGraphics::SetDefaultLighting()
|
||||
|
||||
void CGraphics::SetupAmbientColor()
|
||||
{
|
||||
if (sLightMode == eWorldLighting)
|
||||
if (sLightMode == ELightingMode::World)
|
||||
sVertexBlock.COLOR0_Amb = sAreaAmbientColor * sWorldLightMultiplier;
|
||||
else if (sLightMode == eBasicLighting)
|
||||
else if (sLightMode == ELightingMode::Basic)
|
||||
sVertexBlock.COLOR0_Amb = skDefaultAmbientColor;
|
||||
else
|
||||
sVertexBlock.COLOR0_Amb = CColor::skWhite;
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
#include <GL/glew.h>
|
||||
|
||||
/**
|
||||
* todo: should probably be replaced with a CGraphicsState class which
|
||||
* can be instantiated and is probably more safe/functional than global access.
|
||||
* also, should probably have inline set/get functions rather than having all
|
||||
* members public so that we can track when a value is modified and maybe
|
||||
* execute extra functionality when certain values are changed
|
||||
* todo: this entire thing needs to be further abstracted, other classes shouldn't
|
||||
* need to get this close to the metal - makes it harder to extend and harder to
|
||||
* theoretically add support for other kinds of graphics backends. additionally,
|
||||
* all this stuff really shouldn't be global, and shouldn't all use public members
|
||||
* either... basically, there's a lot wrong with this system
|
||||
*/
|
||||
class CGraphics
|
||||
{
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
static SLightBlock sLightBlock;
|
||||
|
||||
// Lighting-related
|
||||
enum ELightingMode { eNoLighting, eBasicLighting, eWorldLighting };
|
||||
enum class ELightingMode { None, Basic, World };
|
||||
static ELightingMode sLightMode;
|
||||
static uint32 sNumLights;
|
||||
static const CColor skDefaultAmbientColor;
|
||||
|
||||
@@ -68,7 +68,7 @@ void CRenderBucket::CSubBucket::Draw(const SViewInfo& rkViewInfo)
|
||||
const SRenderablePtr& rkPtr = mRenderables[iPtr];
|
||||
|
||||
// todo: DrawSelection probably shouldn't be a separate function anymore.
|
||||
if (rkPtr.Command == eDrawSelection)
|
||||
if (rkPtr.Command == ERenderCommand::DrawSelection)
|
||||
rkPtr.pRenderable->DrawSelection();
|
||||
else
|
||||
rkPtr.pRenderable->Draw(Options, rkPtr.ComponentIndex, rkPtr.Command, rkViewInfo);
|
||||
|
||||
@@ -17,8 +17,8 @@ uint32 CRenderer::sNumRenderers = 0;
|
||||
|
||||
// ************ INITIALIZATION ************
|
||||
CRenderer::CRenderer()
|
||||
: mOptions(eEnableUVScroll | eEnableBackfaceCull)
|
||||
, mBloomMode(eNoBloom)
|
||||
: mOptions(ERenderOption::EnableUVScroll | ERenderOption::EnableBackfaceCull)
|
||||
, mBloomMode(EBloomMode::NoBloom)
|
||||
, mDrawGrid(true)
|
||||
, mInitialized(false)
|
||||
, mContextIndex(-1)
|
||||
@@ -55,14 +55,14 @@ FRenderOptions CRenderer::RenderOptions() const
|
||||
|
||||
void CRenderer::ToggleBackfaceCull(bool Enable)
|
||||
{
|
||||
if (Enable) mOptions |= eEnableBackfaceCull;
|
||||
else mOptions &= ~eEnableBackfaceCull;
|
||||
if (Enable) mOptions |= ERenderOption::EnableBackfaceCull;
|
||||
else mOptions &= ~ERenderOption::EnableBackfaceCull;
|
||||
}
|
||||
|
||||
void CRenderer::ToggleUVAnimation(bool Enable)
|
||||
{
|
||||
if (Enable) mOptions |= eEnableUVScroll;
|
||||
else mOptions &= ~eEnableUVScroll;
|
||||
if (Enable) mOptions |= ERenderOption::EnableUVScroll;
|
||||
else mOptions &= ~ERenderOption::EnableUVScroll;
|
||||
}
|
||||
|
||||
void CRenderer::ToggleGrid(bool Enable)
|
||||
@@ -72,24 +72,24 @@ void CRenderer::ToggleGrid(bool Enable)
|
||||
|
||||
void CRenderer::ToggleOccluders(bool Enable)
|
||||
{
|
||||
if (Enable) mOptions |= eEnableOccluders;
|
||||
else mOptions &= ~eEnableOccluders;
|
||||
if (Enable) mOptions |= ERenderOption::EnableOccluders;
|
||||
else mOptions &= ~ERenderOption::EnableOccluders;
|
||||
}
|
||||
|
||||
void CRenderer::ToggleAlphaDisabled(bool Enable)
|
||||
{
|
||||
if (Enable) mOptions |= eNoAlpha;
|
||||
else mOptions &= ~eNoAlpha;
|
||||
if (Enable) mOptions |= ERenderOption::NoAlpha;
|
||||
else mOptions &= ~ERenderOption::NoAlpha;
|
||||
}
|
||||
|
||||
void CRenderer::SetBloom(EBloomMode BloomMode)
|
||||
{
|
||||
mBloomMode = BloomMode;
|
||||
|
||||
if (BloomMode != eNoBloom)
|
||||
mOptions |= eEnableBloom;
|
||||
if (BloomMode != EBloomMode::NoBloom)
|
||||
mOptions |= ERenderOption::EnableBloom;
|
||||
else
|
||||
mOptions &= ~eEnableBloom;
|
||||
mOptions &= ~ERenderOption::EnableBloom;
|
||||
}
|
||||
|
||||
void CRenderer::SetClearColor(const CColor& rkClear)
|
||||
@@ -118,7 +118,7 @@ void CRenderer::RenderBuckets(const SViewInfo& rkViewInfo)
|
||||
mSceneFramebuffer.Bind();
|
||||
|
||||
// Set backface culling
|
||||
if (mOptions & eEnableBackfaceCull) glEnable(GL_CULL_FACE);
|
||||
if (mOptions & ERenderOption::EnableBackfaceCull) glEnable(GL_CULL_FACE);
|
||||
else glDisable(GL_CULL_FACE);
|
||||
|
||||
// Render scene to texture
|
||||
@@ -145,7 +145,7 @@ void CRenderer::RenderBuckets(const SViewInfo& rkViewInfo)
|
||||
void CRenderer::RenderBloom()
|
||||
{
|
||||
// Check to ensure bloom is enabled. Also don't render bloom in unlit mode.
|
||||
if (mBloomMode == eNoBloom || CGraphics::sLightMode != CGraphics::eWorldLighting) return;
|
||||
if (mBloomMode == EBloomMode::NoBloom || CGraphics::sLightMode != CGraphics::ELightingMode::World) return;
|
||||
|
||||
// Setup
|
||||
static const float skHOffset[6] = { -0.008595f, -0.005470f, -0.002345f,
|
||||
@@ -161,10 +161,10 @@ void CRenderer::RenderBloom()
|
||||
CColor::Integral(53, 53, 53),
|
||||
CColor::Integral(17, 17, 17) };
|
||||
|
||||
uint32 BloomWidth = (mBloomMode == eBloom ? mBloomWidth : mViewportWidth);
|
||||
uint32 BloomHeight = (mBloomMode == eBloom ? mBloomHeight : mViewportHeight);
|
||||
float BloomHScale = (mBloomMode == eBloom ? mBloomHScale : 0);
|
||||
float BloomVScale = (mBloomMode == eBloom ? mBloomVScale : 0);
|
||||
uint32 BloomWidth = (mBloomMode == EBloomMode::Bloom ? mBloomWidth : mViewportWidth);
|
||||
uint32 BloomHeight = (mBloomMode == EBloomMode::Bloom ? mBloomHeight : mViewportHeight);
|
||||
float BloomHScale = (mBloomMode == EBloomMode::Bloom ? mBloomHScale : 0);
|
||||
float BloomVScale = (mBloomMode == EBloomMode::Bloom ? mBloomVScale : 0);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glViewport(0, 0, BloomWidth, BloomHeight);
|
||||
@@ -242,7 +242,7 @@ void CRenderer::RenderBloom()
|
||||
mBloomFramebuffers[2].Texture()->Bind(0);
|
||||
CDrawUtil::DrawSquare();
|
||||
|
||||
if (mBloomMode == eBloomMaps)
|
||||
if (mBloomMode == EBloomMode::BloomMaps)
|
||||
{
|
||||
// Bloom maps are in the framebuffer alpha channel.
|
||||
// White * dst alpha = bloom map colors
|
||||
@@ -294,19 +294,19 @@ void CRenderer::AddMesh(IRenderable *pRenderable, int ComponentIndex, const CAAB
|
||||
|
||||
switch (DepthGroup)
|
||||
{
|
||||
case eBackground:
|
||||
case EDepthGroup::Background:
|
||||
mBackgroundBucket.Add(Ptr, Transparent);
|
||||
break;
|
||||
|
||||
case eMidground:
|
||||
case EDepthGroup::Midground:
|
||||
mMidgroundBucket.Add(Ptr, Transparent);
|
||||
break;
|
||||
|
||||
case eForeground:
|
||||
case EDepthGroup::Foreground:
|
||||
mForegroundBucket.Add(Ptr, Transparent);
|
||||
break;
|
||||
|
||||
case eUI:
|
||||
case EDepthGroup::UI:
|
||||
mUIBucket.Add(Ptr, Transparent);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -21,14 +21,35 @@
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
enum class EBloomMode
|
||||
{
|
||||
NoBloom,
|
||||
Bloom,
|
||||
BloomMaps,
|
||||
FakeBloom
|
||||
};
|
||||
|
||||
/**
|
||||
* @todo this rendering subsystem is bad and needs a rewrite
|
||||
* there's quite a lot of problems overall, but generally speaking, one of the
|
||||
* biggest problems with it is that scene nodes have too much control over how
|
||||
* they render, and the renderer doesn't have enough. for example, if a certain
|
||||
* render option is set, it should not be up to the node classes to respect that
|
||||
* option, the renderer should be able to enforce it. there's a lot of other issues
|
||||
* that make the renderer suboptimal and harder to maintain/extend than it should be.
|
||||
* this is also a more general issue but graphics stuff needs to be further abstracted
|
||||
* so that rendering code isn't directly calling OpenGL functions, ideally it should
|
||||
* just have more abstracted code that gets redirected to OpenGL at a lower level so
|
||||
* that other graphics backends could be supported in the future without needing to
|
||||
* majorly rewrite everything (but I guess that's the point we're at right now anyway).
|
||||
* I'm also pretty sure there's been no attempt made whatsoever to reduce the number of
|
||||
* shader/texture state changes needed per frame, outside batching world geometry (via
|
||||
* CStaticModel), which might be a performance drain.
|
||||
*
|
||||
* for more complaints about the rendering system implementation, see CSceneNode
|
||||
*/
|
||||
class CRenderer
|
||||
{
|
||||
public:
|
||||
enum EBloomMode {
|
||||
eNoBloom, eBloom, eBloomMaps, eFakeBloom
|
||||
};
|
||||
|
||||
private:
|
||||
FRenderOptions mOptions;
|
||||
EBloomMode mBloomMode;
|
||||
bool mDrawGrid;
|
||||
@@ -73,7 +94,7 @@ public:
|
||||
void RenderBuckets(const SViewInfo& rkViewInfo);
|
||||
void RenderBloom();
|
||||
void RenderSky(CModel *pSkyboxModel, const SViewInfo& rkViewInfo);
|
||||
void AddMesh(IRenderable *pRenderable, int ComponentIndex, const CAABox& rkAABox, bool Transparent, ERenderCommand Command, EDepthGroup DepthGroup = eMidground);
|
||||
void AddMesh(IRenderable *pRenderable, int ComponentIndex, const CAABox& rkAABox, bool Transparent, ERenderCommand Command, EDepthGroup DepthGroup = EDepthGroup::Midground);
|
||||
void BeginFrame();
|
||||
void EndFrame();
|
||||
void ClearDepthBuffer();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifndef EDEPTHGROUP
|
||||
#define EDEPTHGROUP
|
||||
|
||||
enum EDepthGroup
|
||||
enum class EDepthGroup
|
||||
{
|
||||
eBackground,
|
||||
eMidground,
|
||||
eForeground,
|
||||
eUI
|
||||
Background,
|
||||
Midground,
|
||||
Foreground,
|
||||
UI
|
||||
};
|
||||
|
||||
#endif // EDEPTHGROUP
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifndef ERENDERCOMMAND
|
||||
#define ERENDERCOMMAND
|
||||
|
||||
enum ERenderCommand
|
||||
enum class ERenderCommand
|
||||
{
|
||||
eDrawMesh,
|
||||
eDrawOpaqueParts,
|
||||
eDrawTransparentParts,
|
||||
eDrawSelection
|
||||
DrawMesh,
|
||||
DrawOpaqueParts,
|
||||
DrawTransparentParts,
|
||||
DrawSelection
|
||||
};
|
||||
|
||||
#endif // ERENDERCOMMAND
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
|
||||
#include <Common/Flags.h>
|
||||
|
||||
enum ERenderOption
|
||||
enum class ERenderOption
|
||||
{
|
||||
eNoRenderOptions = 0x0,
|
||||
eEnableUVScroll = 0x1,
|
||||
eEnableBackfaceCull = 0x2,
|
||||
eEnableOccluders = 0x4,
|
||||
eNoMaterialSetup = 0x8,
|
||||
eEnableBloom = 0x10,
|
||||
eNoAlpha = 0x20
|
||||
None = 0x0,
|
||||
EnableUVScroll = 0x1,
|
||||
EnableBackfaceCull = 0x2,
|
||||
EnableOccluders = 0x4,
|
||||
NoMaterialSetup = 0x8,
|
||||
EnableBloom = 0x10,
|
||||
NoAlpha = 0x20
|
||||
};
|
||||
DECLARE_FLAGS(ERenderOption, FRenderOptions)
|
||||
DECLARE_FLAGS_ENUMCLASS(ERenderOption, FRenderOptions)
|
||||
|
||||
#endif // FRENDEROPTIONS_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user