diff --git a/src/Core/Core.pro b/src/Core/Core.pro index 0dc779fb..9ae9fa02 100644 --- a/src/Core/Core.pro +++ b/src/Core/Core.pro @@ -193,7 +193,8 @@ HEADERS += \ Resource/Factory/CAnimationLoader.h \ Render/CBoneTransformData.h \ Resource/CSkin.h \ - Resource/Factory/CSkinLoader.h + Resource/Factory/CSkinLoader.h \ + Render/EDepthGroup.h # Source Files SOURCES += \ diff --git a/src/Core/Render/CRenderBucket.cpp b/src/Core/Render/CRenderBucket.cpp index f5c4cd70..4fecb624 100644 --- a/src/Core/Render/CRenderBucket.cpp +++ b/src/Core/Render/CRenderBucket.cpp @@ -4,7 +4,8 @@ #include "CRenderer.h" #include -void CRenderBucket::Add(const SRenderablePtr& rkPtr) +// ************ CSubBucket ************ +void CRenderBucket::CSubBucket::Add(const SRenderablePtr& rkPtr) { if (mSize >= mEstSize) mRenderables.push_back(rkPtr); @@ -14,63 +15,84 @@ void CRenderBucket::Add(const SRenderablePtr& rkPtr) mSize++; } -void CRenderBucket::Sort(CCamera* pCamera) +void CRenderBucket::CSubBucket::Sort(const CCamera* pkCamera, bool DebugVisualization) { - if (mEnableDepthSort) + std::stable_sort(mRenderables.begin(), mRenderables.begin() + mSize, + [&, pkCamera](const SRenderablePtr& rkLeft, const SRenderablePtr& rkRight) -> bool { - std::stable_sort(mRenderables.begin(), mRenderables.begin() + mSize, - [&, pCamera](const SRenderablePtr& rkLeft, const SRenderablePtr& rkRight) -> bool + CVector3f CamPos = pkCamera->Position(); + CVector3f CamDir = pkCamera->Direction(); + + CVector3f DistL = rkLeft.AABox.ClosestPointAlongVector(CamDir) - CamPos; + CVector3f DistR = rkRight.AABox.ClosestPointAlongVector(CamDir) - CamPos; + float DotL = DistL.Dot(CamDir); + float DotR = DistR.Dot(CamDir); + return (DotL > DotR); + }); + + if (DebugVisualization) + { + for (u32 iPtr = 0; iPtr < mSize; iPtr++) { - CVector3f CamPos = pCamera->Position(); - CVector3f CamDir = pCamera->Direction(); + SRenderablePtr *pPtr = &mRenderables[iPtr]; + CVector3f Point = pPtr->AABox.ClosestPointAlongVector(pkCamera->Direction()); + CDrawUtil::DrawWireCube(pPtr->AABox, CColor::skWhite); - CVector3f DistL = rkLeft.AABox.ClosestPointAlongVector(CamDir) - CamPos; - CVector3f DistR = rkRight.AABox.ClosestPointAlongVector(CamDir) - CamPos; - float DotL = DistL.Dot(CamDir); - float DotR = DistR.Dot(CamDir); - return (DotL > DotR); - }); + CVector3f Dist = Point - pkCamera->Position(); + float Dot = Dist.Dot(pkCamera->Direction()); + if (Dot < 0.f) Dot = -Dot; + if (Dot > 50.f) Dot = 50.f; + float Intensity = 1.f - (Dot / 50.f); + CColor CubeColor(Intensity, Intensity, Intensity, 1.f); - if (mEnableDepthSortDebugVisualization) - { - for (u32 iPtr = 0; iPtr < mSize; iPtr++) - { - SRenderablePtr *pPtr = &mRenderables[iPtr]; - CVector3f Point = pPtr->AABox.ClosestPointAlongVector(pCamera->Direction()); - CDrawUtil::DrawWireCube(pPtr->AABox, CColor::skWhite); - - CVector3f Dist = Point - pCamera->Position(); - float Dot = Dist.Dot(pCamera->Direction()); - if (Dot < 0.f) Dot = -Dot; - if (Dot > 50.f) Dot = 50.f; - float Intensity = 1.f - (Dot / 50.f); - CColor CubeColor(Intensity, Intensity, Intensity, 1.f); - - CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Point); - CGraphics::UpdateMVPBlock(); - CDrawUtil::DrawCube(CubeColor); - } + CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Point); + CGraphics::UpdateMVPBlock(); + CDrawUtil::DrawCube(CubeColor); } } } -void CRenderBucket::Clear() +void CRenderBucket::CSubBucket::Clear() { mEstSize = mSize; if (mRenderables.size() > mSize) mRenderables.resize(mSize); mSize = 0; } -void CRenderBucket::Draw(const SViewInfo& rkViewInfo) +void CRenderBucket::CSubBucket::Draw(const SViewInfo& rkViewInfo) { FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions(); for (u32 iPtr = 0; iPtr < mSize; iPtr++) { - if (mRenderables[iPtr].Command == eDrawMesh) - mRenderables[iPtr].pRenderable->Draw(Options, mRenderables[iPtr].ComponentIndex, rkViewInfo); + const SRenderablePtr& rkPtr = mRenderables[iPtr]; - else if (mRenderables[iPtr].Command == eDrawSelection) - mRenderables[iPtr].pRenderable->DrawSelection(); + if (rkPtr.Command == eDrawMesh) + rkPtr.pRenderable->Draw(Options, rkPtr.ComponentIndex, rkViewInfo); + + else if (rkPtr.Command == eDrawSelection) + rkPtr.pRenderable->DrawSelection(); } } + +// ************ CRenderBucket ************ +void CRenderBucket::Add(const SRenderablePtr& rkPtr, bool Transparent) +{ + if (Transparent) + mTransparentSubBucket.Add(rkPtr); + else + mOpaqueSubBucket.Add(rkPtr); +} + +void CRenderBucket::Clear() +{ + mOpaqueSubBucket.Clear(); + mTransparentSubBucket.Clear(); +} + +void CRenderBucket::Draw(const SViewInfo& rkViewInfo) +{ + mOpaqueSubBucket.Draw(rkViewInfo); + mTransparentSubBucket.Sort(rkViewInfo.pCamera, mEnableDepthSortDebugVisualization); + mTransparentSubBucket.Draw(rkViewInfo); +} diff --git a/src/Core/Render/CRenderBucket.h b/src/Core/Render/CRenderBucket.h index aca6f1bc..26f4182e 100644 --- a/src/Core/Render/CRenderBucket.h +++ b/src/Core/Render/CRenderBucket.h @@ -12,27 +12,35 @@ class CRenderBucket { - bool mEnableDepthSort; bool mEnableDepthSortDebugVisualization; - std::vector mRenderables; - u32 mEstSize; - u32 mSize; + + class CSubBucket + { + std::vector mRenderables; + u32 mEstSize; + u32 mSize; + + public: + CSubBucket() + : mEstSize(0) + , mSize(0) + {} + + void Add(const SRenderablePtr &rkPtr); + void Sort(const CCamera *pkCamera, bool DebugVisualization); + void Clear(); + void Draw(const SViewInfo& rkViewInfo); + }; + + CSubBucket mOpaqueSubBucket; + CSubBucket mTransparentSubBucket; public: CRenderBucket() - : mEnableDepthSort(false) - , mEnableDepthSortDebugVisualization(false) - , mEstSize(0) - , mSize(0) + : mEnableDepthSortDebugVisualization(false) {} - inline void SetDepthSortingEnabled(bool Enabled) - { - mEnableDepthSort = Enabled; - } - - void Add(const SRenderablePtr& rkPtr); - void Sort(CCamera* pCamera); + void Add(const SRenderablePtr& rkPtr, bool Transparent); void Clear(); void Draw(const SViewInfo& rkViewInfo); }; diff --git a/src/Core/Render/CRenderer.cpp b/src/Core/Render/CRenderer.cpp index 2cefb8f4..e1368749 100644 --- a/src/Core/Render/CRenderer.cpp +++ b/src/Core/Render/CRenderer.cpp @@ -24,7 +24,6 @@ CRenderer::CRenderer() , mInitialized(false) , mContextIndex(-1) { - mTransparentBucket.SetDepthSortingEnabled(true); sNumRenderers++; } @@ -127,11 +126,21 @@ void CRenderer::RenderBuckets(const SViewInfo& rkViewInfo) glDepthRange(0.f, 1.f); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - mOpaqueBucket.Draw(rkViewInfo); - mOpaqueBucket.Clear(); - mTransparentBucket.Sort(rkViewInfo.pCamera); - mTransparentBucket.Draw(rkViewInfo); - mTransparentBucket.Clear(); + mBackgroundBucket.Draw(rkViewInfo); + mBackgroundBucket.Clear(); + ClearDepthBuffer(); + mMidgroundBucket.Draw(rkViewInfo); + mMidgroundBucket.Clear(); + ClearDepthBuffer(); + RenderBloom(); + ClearDepthBuffer(); + rkViewInfo.pCamera->LoadMatrices(); + mForegroundBucket.Draw(rkViewInfo); + mForegroundBucket.Clear(); + ClearDepthBuffer(); + mUIBucket.Draw(rkViewInfo); + mUIBucket.Clear(); + ClearDepthBuffer(); } void CRenderer::RenderBloom() @@ -266,24 +275,32 @@ void CRenderer::RenderSky(CModel *pSkyboxModel, const SViewInfo& rkViewInfo) pSkyboxModel->Draw(mOptions, 0); } -void CRenderer::AddOpaqueMesh(IRenderable *pRenderable, int AssetID, const CAABox& rkAABox, ERenderCommand Command) +void CRenderer::AddMesh(IRenderable *pRenderable, int ComponentIndex, const CAABox& rkAABox, bool Transparent, ERenderCommand Command, EDepthGroup DepthGroup /*= eMidground*/) { SRenderablePtr Ptr; Ptr.pRenderable = pRenderable; - Ptr.ComponentIndex = AssetID; + Ptr.ComponentIndex = ComponentIndex; Ptr.AABox = rkAABox; Ptr.Command = Command; - mOpaqueBucket.Add(Ptr); -} -void CRenderer::AddTransparentMesh(IRenderable *pRenderable, int AssetID, const CAABox& rkAABox, ERenderCommand Command) -{ - SRenderablePtr Ptr; - Ptr.pRenderable = pRenderable; - Ptr.ComponentIndex = AssetID; - Ptr.AABox = rkAABox; - Ptr.Command = Command; - mTransparentBucket.Add(Ptr); + switch (DepthGroup) + { + case eBackground: + mBackgroundBucket.Add(Ptr, Transparent); + break; + + case eMidground: + mMidgroundBucket.Add(Ptr, Transparent); + break; + + case eForeground: + mForegroundBucket.Add(Ptr, Transparent); + break; + + case eUI: + mUIBucket.Add(Ptr, Transparent); + break; + } } void CRenderer::BeginFrame() diff --git a/src/Core/Render/CRenderer.h b/src/Core/Render/CRenderer.h index abea8655..5e8885aa 100644 --- a/src/Core/Render/CRenderer.h +++ b/src/Core/Render/CRenderer.h @@ -4,8 +4,9 @@ #include "CCamera.h" #include "CGraphics.h" #include "CRenderBucket.h" -#include "FRenderOptions.h" +#include "EDepthGroup.h" #include "ERenderCommand.h" +#include "FRenderOptions.h" #include "SRenderablePtr.h" #include "SViewInfo.h" #include "Core/OpenGL/CFramebuffer.h" @@ -33,8 +34,6 @@ private: bool mDrawGrid; CColor mClearColor; u32 mContextIndex; - CRenderBucket mOpaqueBucket; - CRenderBucket mTransparentBucket; bool mInitialized; u32 mViewportWidth, mViewportHeight; u32 mBloomWidth, mBloomHeight; @@ -44,6 +43,11 @@ private: CFramebuffer mBloomFramebuffers[3]; GLint mDefaultFramebuffer; + CRenderBucket mBackgroundBucket; + CRenderBucket mMidgroundBucket; + CRenderBucket mForegroundBucket; + CRenderBucket mUIBucket; + // Static Members static u32 sNumRenderers; @@ -68,8 +72,7 @@ public: void RenderBuckets(const SViewInfo& rkViewInfo); void RenderBloom(); void RenderSky(CModel *pSkyboxModel, const SViewInfo& rkViewInfo); - void AddOpaqueMesh(IRenderable *pRenderable, int AssetID, const CAABox& rkAABox, ERenderCommand Command); - void AddTransparentMesh(IRenderable *pRenderable, int AssetID, const CAABox& rkAABox, ERenderCommand Command); + void AddMesh(IRenderable *pRenderable, int AssetID, const CAABox& rkAABox, bool Transparent, ERenderCommand Command, EDepthGroup DepthGroup = eMidground); void BeginFrame(); void EndFrame(); void ClearDepthBuffer(); diff --git a/src/Core/Render/EDepthGroup.h b/src/Core/Render/EDepthGroup.h new file mode 100644 index 00000000..bfcd6135 --- /dev/null +++ b/src/Core/Render/EDepthGroup.h @@ -0,0 +1,13 @@ +#ifndef EDEPTHGROUP +#define EDEPTHGROUP + +enum EDepthGroup +{ + eBackground, + eMidground, + eForeground, + eUI +}; + +#endif // EDEPTHGROUP + diff --git a/src/Core/Resource/CSkeleton.cpp b/src/Core/Resource/CSkeleton.cpp index 84e0a38c..9f9a13cb 100644 --- a/src/Core/Resource/CSkeleton.cpp +++ b/src/Core/Resource/CSkeleton.cpp @@ -40,7 +40,10 @@ CVector3f CBone::TransformedPosition(const CBoneTransformData& rkData) const bool CBone::IsRoot() const { - return (mpParent == nullptr); + // In Retro's engine most skeletons have another bone named Skeleton_Root parented directly under the + // actual root bone... that bone sometimes acts as the actual root (transforming the entire skeleton), + // so we need to account for both + return (mpParent == nullptr || mpParent->Parent() == nullptr); } // ************ CSkeleton ************ diff --git a/src/Core/Scene/CCharacterNode.cpp b/src/Core/Scene/CCharacterNode.cpp index 74d56c9a..3393f3b0 100644 --- a/src/Core/Scene/CCharacterNode.cpp +++ b/src/Core/Scene/CCharacterNode.cpp @@ -35,9 +35,9 @@ void CCharacterNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkView if (pModel) { if (!pModel->HasTransparency(0)) - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); else - AddSurfacesToRenderer(pRenderer, pModel, 0, rkViewInfo, false); + AddSurfacesToRenderer(pRenderer, pModel, 0, rkViewInfo, eMidground, false); } if (pSkel) @@ -46,7 +46,7 @@ void CCharacterNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkView pSkel->UpdateTransform(mTransformData, pAnim, mAnimTime, false); if (rkViewInfo.ShowFlags.HasFlag(eShowSkeletons)) - pRenderer->AddOpaqueMesh(this, -2, AABox(), eDrawMesh); + pRenderer->AddMesh(this, -2, AABox(), false, eDrawMesh, eForeground); } } diff --git a/src/Core/Scene/CCollisionNode.cpp b/src/Core/Scene/CCollisionNode.cpp index 32a88044..abf5a5c4 100644 --- a/src/Core/Scene/CCollisionNode.cpp +++ b/src/Core/Scene/CCollisionNode.cpp @@ -21,10 +21,10 @@ void CCollisionNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkView if (!rkViewInfo.ViewFrustum.BoxInFrustum(AABox())) return; if (rkViewInfo.GameMode) return; - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); if (mSelected) - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawSelection); } void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& rkViewInfo) diff --git a/src/Core/Scene/CLightNode.cpp b/src/Core/Scene/CLightNode.cpp index c62dc7bf..2ed815d2 100644 --- a/src/Core/Scene/CLightNode.cpp +++ b/src/Core/Scene/CLightNode.cpp @@ -30,14 +30,14 @@ void CLightNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo if (rkViewInfo.GameMode) return; if (rkViewInfo.ViewFrustum.BoxInFrustum(AABox())) - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); if (IsSelected() && mpLight->Type() == eCustom) { CAABox RadiusBox = (CAABox::skOne * 2.f * mpLight->GetRadius()) + mPosition; if (rkViewInfo.ViewFrustum.BoxInFrustum(RadiusBox)) - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawSelection); } } diff --git a/src/Core/Scene/CModelNode.cpp b/src/Core/Scene/CModelNode.cpp index 6eafe6bb..1f39f71f 100644 --- a/src/Core/Scene/CModelNode.cpp +++ b/src/Core/Scene/CModelNode.cpp @@ -36,12 +36,12 @@ void CModelNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo if (rkViewInfo.GameMode) return; if (!mpModel->HasTransparency(mActiveMatSet)) - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); else AddSurfacesToRenderer(pRenderer, mpModel, mActiveMatSet, rkViewInfo); if (mSelected) - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawSelection); } void CModelNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo) diff --git a/src/Core/Scene/CSceneNode.cpp b/src/Core/Scene/CSceneNode.cpp index 0b299098..46666364 100644 --- a/src/Core/Scene/CSceneNode.cpp +++ b/src/Core/Scene/CSceneNode.cpp @@ -224,7 +224,7 @@ void CSceneNode::DrawRotationArrow() const spArrowModel->Draw(eNoRenderOptions, 0); } -void CSceneNode::AddSurfacesToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet, const SViewInfo& rkViewInfo, bool DoFrustumTest /*= true*/) +void CSceneNode::AddSurfacesToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet, const SViewInfo& rkViewInfo, EDepthGroup DepthGroup /*= eMidground*/, bool DoFrustumTest /*= true*/) { u32 SurfaceCount = pModel->GetSurfaceCount(); @@ -234,10 +234,7 @@ void CSceneNode::AddSurfacesToRenderer(CRenderer *pRenderer, CModel *pModel, u32 if (!DoFrustumTest || rkViewInfo.ViewFrustum.BoxInFrustum(TransformedBox)) { - if (!pModel->IsSurfaceTransparent(iSurf, MatSet)) - pRenderer->AddOpaqueMesh(this, (int) iSurf, TransformedBox, eDrawMesh); - else - pRenderer->AddTransparentMesh(this, (int) iSurf, TransformedBox, eDrawMesh); + pRenderer->AddMesh(this, (int) iSurf, TransformedBox, pModel->IsSurfaceTransparent(iSurf, MatSet), eDrawMesh, DepthGroup); } } } diff --git a/src/Core/Scene/CSceneNode.h b/src/Core/Scene/CSceneNode.h index 232e4c49..e4bbed73 100644 --- a/src/Core/Scene/CSceneNode.h +++ b/src/Core/Scene/CSceneNode.h @@ -2,6 +2,7 @@ #define CSCENENODE_H #include "ENodeType.h" +#include "Core/Render/EDepthGroup.h" #include "Core/Render/FRenderOptions.h" #include "Core/Render/IRenderable.h" #include "Core/Resource/CLight.h" @@ -79,7 +80,7 @@ public: void LoadLights(const SViewInfo& rkViewInfo); void DrawBoundingBox() const; void DrawRotationArrow() const; - void AddSurfacesToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet, const SViewInfo& rkViewInfo, bool DoFrustumTest = true); + void AddSurfacesToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet, const SViewInfo& rkViewInfo, EDepthGroup DepthGroup = eMidground, bool DoFrustumTest = true); // Transform void Translate(const CVector3f& rkTranslation, ETransformSpace TransformSpace); diff --git a/src/Core/Scene/CScriptNode.cpp b/src/Core/Scene/CScriptNode.cpp index 7f13e600..337e3c03 100644 --- a/src/Core/Scene/CScriptNode.cpp +++ b/src/Core/Scene/CScriptNode.cpp @@ -133,12 +133,12 @@ void CScriptNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInf if (rkViewInfo.ViewFrustum.BoxInFrustum(AABox())) { if (!mpActiveModel) - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); else { if (!mpActiveModel->HasTransparency(0)) - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); else AddSurfacesToRenderer(pRenderer, mpActiveModel, 0, rkViewInfo); } @@ -151,7 +151,7 @@ void CScriptNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInf // Script nodes always draw their selections regardless of frustum planes // in order to ensure that script connection lines don't get improperly culled. if (ShouldDraw) - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawSelection); if (mHasVolumePreview && (!mpExtra || mpExtra->ShouldDrawVolume())) mpVolumePreviewNode->AddToRenderer(pRenderer, rkViewInfo); @@ -193,6 +193,8 @@ void CScriptNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewIn // Draw model if possible! if (mpActiveModel) { + if (mpActiveModel->IsSkinned()) CGraphics::LoadIdentityBoneTransforms(); + if (mpExtra) CGraphics::sPixelBlock.TevColor = mpExtra->TevColor(); else CGraphics::sPixelBlock.TevColor = CColor::skWhite; diff --git a/src/Core/Scene/CStaticNode.cpp b/src/Core/Scene/CStaticNode.cpp index 660e0401..6169d6f3 100644 --- a/src/Core/Scene/CStaticNode.cpp +++ b/src/Core/Scene/CStaticNode.cpp @@ -34,7 +34,7 @@ void CStaticNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInf if (!rkViewInfo.ViewFrustum.BoxInFrustum(AABox())) return; if (!mpModel->IsTransparent()) - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); else { @@ -44,12 +44,12 @@ void CStaticNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInf CAABox TransformedBox = mpModel->GetSurfaceAABox(iSurf).Transformed(Transform()); if (rkViewInfo.ViewFrustum.BoxInFrustum(TransformedBox)) - pRenderer->AddTransparentMesh(this, iSurf, TransformedBox, eDrawMesh); + pRenderer->AddMesh(this, iSurf, TransformedBox, true, eDrawMesh); } } if (mSelected && !rkViewInfo.GameMode) - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawSelection); } void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo) diff --git a/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp b/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp index a4fe1b5f..47410686 100644 --- a/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp +++ b/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp @@ -183,9 +183,9 @@ void CDamageableTriggerExtra::AddToRenderer(CRenderer *pRenderer, const SViewInf if (mRenderSide != eNoRender) { if (rkViewInfo.ViewFrustum.BoxInFrustum(AABox())) - pRenderer->AddTransparentMesh(this, -1, AABox(), eDrawMesh); + pRenderer->AddMesh(this, -1, AABox(), true, eDrawMesh); if (mpParent->IsSelected() && !rkViewInfo.GameMode) - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawSelection); } } diff --git a/src/Core/ScriptExtra/CDoorExtra.cpp b/src/Core/ScriptExtra/CDoorExtra.cpp index bb40aa77..9c1ec83d 100644 --- a/src/Core/ScriptExtra/CDoorExtra.cpp +++ b/src/Core/ScriptExtra/CDoorExtra.cpp @@ -67,10 +67,10 @@ void CDoorExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo if (mpShieldModel->HasTransparency(0)) AddSurfacesToRenderer(pRenderer, mpShieldModel, 0, rkViewInfo); else - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); if (mpParent->IsSelected() && !rkViewInfo.GameMode) - pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection); + pRenderer->AddMesh(this, -1, AABox(), false, eDrawSelection); } } diff --git a/src/Core/ScriptExtra/CRadiusSphereExtra.cpp b/src/Core/ScriptExtra/CRadiusSphereExtra.cpp index 3ce81c25..2d7c0955 100644 --- a/src/Core/ScriptExtra/CRadiusSphereExtra.cpp +++ b/src/Core/ScriptExtra/CRadiusSphereExtra.cpp @@ -32,7 +32,7 @@ void CRadiusSphereExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rk CAABox BoundingBox = Bounds(); if (rkViewInfo.ViewFrustum.BoxInFrustum(BoundingBox)) - pRenderer->AddOpaqueMesh(this, -1, BoundingBox, eDrawMesh); + pRenderer->AddMesh(this, -1, BoundingBox, false, eDrawMesh); } } diff --git a/src/Core/ScriptExtra/CWaypointExtra.cpp b/src/Core/ScriptExtra/CWaypointExtra.cpp index 4f85c1db..8bbe45df 100644 --- a/src/Core/ScriptExtra/CWaypointExtra.cpp +++ b/src/Core/ScriptExtra/CWaypointExtra.cpp @@ -167,7 +167,7 @@ void CWaypointExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkView CScriptNode *pNode = mLinks[iLink].pWaypoint; if (pNode->IsVisible() && !pNode->IsSelected() && rkViewInfo.ViewFrustum.BoxInFrustum(mLinks[iLink].LineAABB)) - pRenderer->AddOpaqueMesh(this, iLink, mLinks[iLink].LineAABB, eDrawMesh); + pRenderer->AddMesh(this, iLink, mLinks[iLink].LineAABB, false, eDrawMesh); } } } diff --git a/src/Editor/CGizmo.cpp b/src/Editor/CGizmo.cpp index db038178..e9150327 100644 --- a/src/Editor/CGizmo.cpp +++ b/src/Editor/CGizmo.cpp @@ -57,11 +57,7 @@ void CGizmo::AddToRenderer(CRenderer *pRenderer, const SViewInfo&) u32 SetID = (IsHighlighted ? 1 : 0); // Add to renderer... - if (pModel->HasTransparency(SetID)) - pRenderer->AddTransparentMesh(this, iPart, pModel->AABox().Transformed(mTransform), eDrawMesh); - else - pRenderer->AddOpaqueMesh(this, iPart, pModel->AABox().Transformed(mTransform), eDrawMesh); - + pRenderer->AddMesh(this, iPart, pModel->AABox().Transformed(mTransform), pModel->HasTransparency(SetID), eDrawMesh, eForeground); pPart++; } } diff --git a/src/Editor/CSceneViewport.cpp b/src/Editor/CSceneViewport.cpp index 63aec7cc..bc406c82 100644 --- a/src/Editor/CSceneViewport.cpp +++ b/src/Editor/CSceneViewport.cpp @@ -299,6 +299,7 @@ void CSceneViewport::Paint() mpRenderer->BeginFrame(); + // todo: The sky should really just be a regular node in the background depth group instead of having special rendering code here if ((mViewInfo.ShowFlags & eShowSky) || mViewInfo.GameMode) { CModel *pSky = mpScene->ActiveSkybox(); @@ -308,6 +309,14 @@ void CSceneViewport::Paint() mCamera.LoadMatrices(); mpScene->AddSceneToRenderer(mpRenderer, mViewInfo); + // Add gizmo to renderer + if (mpEditor->IsGizmoVisible() && !mViewInfo.GameMode) + { + CGizmo *pGizmo = mpEditor->Gizmo(); + pGizmo->UpdateForCamera(mCamera); + pGizmo->AddToRenderer(mpRenderer, mViewInfo); + } + // Draw the line for the link the user is editing. This is a little hacky but I don't really have a better way to do this atm. if (mLinkLineEnabled) { @@ -318,19 +327,6 @@ void CSceneViewport::Paint() } mpRenderer->RenderBuckets(mViewInfo); - mpRenderer->RenderBloom(); - - if (mpEditor->IsGizmoVisible() && !mViewInfo.GameMode) - { - CGizmo *pGizmo = mpEditor->Gizmo(); - mCamera.LoadMatrices(); - - mpRenderer->ClearDepthBuffer(); - pGizmo->UpdateForCamera(mCamera); - pGizmo->AddToRenderer(mpRenderer, mViewInfo); - mpRenderer->RenderBuckets(mViewInfo); - } - mpRenderer->EndFrame(); }