From f64ee6b3b7372be3f9cdb5287abc45b1f8556181 Mon Sep 17 00:00:00 2001 From: parax0 Date: Tue, 3 May 2016 05:05:10 -0600 Subject: [PATCH] A model's surfaces are now depth sorted together (except on world geometry) --- src/Core/Render/CRenderBucket.cpp | 8 +-- src/Core/Render/ERenderCommand.h | 2 + src/Core/Render/IRenderable.h | 3 +- src/Core/Scene/CCharacterNode.cpp | 19 ++----- src/Core/Scene/CCharacterNode.h | 2 +- src/Core/Scene/CCollisionNode.cpp | 2 +- src/Core/Scene/CCollisionNode.h | 2 +- src/Core/Scene/CLightNode.cpp | 2 +- src/Core/Scene/CLightNode.h | 2 +- src/Core/Scene/CModelNode.cpp | 29 ++++++---- src/Core/Scene/CModelNode.h | 2 +- src/Core/Scene/CSceneNode.cpp | 53 +++++++++++++------ src/Core/Scene/CSceneNode.h | 3 +- src/Core/Scene/CScriptAttachNode.cpp | 13 ++--- src/Core/Scene/CScriptAttachNode.h | 2 +- src/Core/Scene/CScriptNode.cpp | 18 ++----- src/Core/Scene/CScriptNode.h | 2 +- src/Core/Scene/CStaticNode.cpp | 2 +- src/Core/Scene/CStaticNode.h | 2 +- .../ScriptExtra/CDamageableTriggerExtra.cpp | 2 +- .../ScriptExtra/CDamageableTriggerExtra.h | 2 +- src/Core/ScriptExtra/CDoorExtra.cpp | 13 ++--- src/Core/ScriptExtra/CDoorExtra.h | 2 +- src/Core/ScriptExtra/CRadiusSphereExtra.cpp | 2 +- src/Core/ScriptExtra/CRadiusSphereExtra.h | 2 +- src/Core/ScriptExtra/CWaypointExtra.cpp | 2 +- src/Core/ScriptExtra/CWaypointExtra.h | 2 +- src/Editor/CGizmo.cpp | 2 +- src/Editor/CGizmo.h | 2 +- src/Editor/CGridRenderable.h | 2 +- 30 files changed, 101 insertions(+), 100 deletions(-) diff --git a/src/Core/Render/CRenderBucket.cpp b/src/Core/Render/CRenderBucket.cpp index 4fecb624..47700e67 100644 --- a/src/Core/Render/CRenderBucket.cpp +++ b/src/Core/Render/CRenderBucket.cpp @@ -67,11 +67,11 @@ void CRenderBucket::CSubBucket::Draw(const SViewInfo& rkViewInfo) { const SRenderablePtr& rkPtr = mRenderables[iPtr]; - if (rkPtr.Command == eDrawMesh) - rkPtr.pRenderable->Draw(Options, rkPtr.ComponentIndex, rkViewInfo); - - else if (rkPtr.Command == eDrawSelection) + // todo: DrawSelection probably shouldn't be a separate function anymore. + if (rkPtr.Command == eDrawSelection) rkPtr.pRenderable->DrawSelection(); + else + rkPtr.pRenderable->Draw(Options, rkPtr.ComponentIndex, rkPtr.Command, rkViewInfo); } } diff --git a/src/Core/Render/ERenderCommand.h b/src/Core/Render/ERenderCommand.h index 287de1cf..3afdba11 100644 --- a/src/Core/Render/ERenderCommand.h +++ b/src/Core/Render/ERenderCommand.h @@ -4,6 +4,8 @@ enum ERenderCommand { eDrawMesh, + eDrawOpaqueParts, + eDrawTransparentParts, eDrawSelection }; diff --git a/src/Core/Render/IRenderable.h b/src/Core/Render/IRenderable.h index 776e9f55..394bf9fb 100644 --- a/src/Core/Render/IRenderable.h +++ b/src/Core/Render/IRenderable.h @@ -1,6 +1,7 @@ #ifndef IRENDERABLE_H #define IRENDERABLE_H +#include "ERenderCommand.h" #include "FRenderOptions.h" #include "SViewInfo.h" #include @@ -13,7 +14,7 @@ public: IRenderable() {} virtual ~IRenderable() {} virtual void AddToRenderer(CRenderer* pRenderer, const SViewInfo& rkViewInfo) = 0; - virtual void Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& /*rkViewInfo*/) {} + virtual void Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ERenderCommand /*Command*/, const SViewInfo& /*rkViewInfo*/) {} virtual void DrawSelection() {} }; diff --git a/src/Core/Scene/CCharacterNode.cpp b/src/Core/Scene/CCharacterNode.cpp index fcec9eb9..2ba42eb4 100644 --- a/src/Core/Scene/CCharacterNode.cpp +++ b/src/Core/Scene/CCharacterNode.cpp @@ -35,26 +35,21 @@ void CCharacterNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkView CSkeleton *pSkel = mpCharacter->NodeSkeleton(mActiveCharSet); if (pModel && rkViewInfo.ShowFlags.HasFlag(eShowObjectGeometry)) - { - if (!pModel->HasTransparency(0)) - pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); - else - AddSurfacesToRenderer(pRenderer, pModel, 0, rkViewInfo, eMidground, false); - } + AddModelToRenderer(pRenderer, pModel, 0); if (pSkel) { if (rkViewInfo.ShowFlags.HasFlag(eShowSkeletons)) - pRenderer->AddMesh(this, -2, AABox(), false, eDrawMesh, eForeground); + pRenderer->AddMesh(this, 0, AABox(), false, eDrawMesh, eForeground); } } -void CCharacterNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo) +void CCharacterNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo) { CSkeleton *pSkel = mpCharacter->NodeSkeleton(mActiveCharSet); // Draw skeleton - if (ComponentIndex == -2) + if (ComponentIndex == 0) { LoadModelMatrix(); pSkel->Draw(Options, &mTransformData); @@ -79,11 +74,7 @@ void CCharacterNode::Draw(FRenderOptions Options, int ComponentIndex, const SVie CGraphics::LoadIdentityBoneTransforms(); CModel *pModel = mpCharacter->NodeModel(mActiveCharSet); - - if (ComponentIndex < 0) - pModel->Draw(Options, 0); - else - pModel->DrawSurface(Options, ComponentIndex, 0); + DrawModelParts(pModel, Options, 0, Command); } } diff --git a/src/Core/Scene/CCharacterNode.h b/src/Core/Scene/CCharacterNode.h index e9418292..888781ce 100644 --- a/src/Core/Scene/CCharacterNode.h +++ b/src/Core/Scene/CCharacterNode.h @@ -22,7 +22,7 @@ public: virtual ENodeType NodeType(); virtual void PostLoad(); virtual void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); - virtual void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo); + virtual void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); virtual SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo); CVector3f BonePosition(u32 BoneID); diff --git a/src/Core/Scene/CCollisionNode.cpp b/src/Core/Scene/CCollisionNode.cpp index abf5a5c4..6af38244 100644 --- a/src/Core/Scene/CCollisionNode.cpp +++ b/src/Core/Scene/CCollisionNode.cpp @@ -27,7 +27,7 @@ void CCollisionNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkView pRenderer->AddMesh(this, -1, AABox(), false, eDrawSelection); } -void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& rkViewInfo) +void CCollisionNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ERenderCommand /*Command*/, const SViewInfo& rkViewInfo) { if (!mpCollision) return; diff --git a/src/Core/Scene/CCollisionNode.h b/src/Core/Scene/CCollisionNode.h index dcfa4464..236e5c0a 100644 --- a/src/Core/Scene/CCollisionNode.h +++ b/src/Core/Scene/CCollisionNode.h @@ -12,7 +12,7 @@ public: CCollisionNode(CScene *pScene, u32 NodeID, CSceneNode *pParent = 0, CCollisionMeshGroup *pCollision = 0); ENodeType NodeType(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); - void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo); void SetCollision(CCollisionMeshGroup *pCollision); }; diff --git a/src/Core/Scene/CLightNode.cpp b/src/Core/Scene/CLightNode.cpp index 2ed815d2..5e06ce41 100644 --- a/src/Core/Scene/CLightNode.cpp +++ b/src/Core/Scene/CLightNode.cpp @@ -41,7 +41,7 @@ void CLightNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo } } -void CLightNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& rkViewInfo) +void CLightNode::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ERenderCommand /*Command*/, const SViewInfo& rkViewInfo) { CDrawUtil::DrawLightBillboard(mpLight->Type(), mpLight->Color(), mPosition, BillboardScale(), TintColor(rkViewInfo)); } diff --git a/src/Core/Scene/CLightNode.h b/src/Core/Scene/CLightNode.h index 798f5157..51afc882 100644 --- a/src/Core/Scene/CLightNode.h +++ b/src/Core/Scene/CLightNode.h @@ -11,7 +11,7 @@ public: CLightNode(CScene *pScene, u32 NodeID, CSceneNode *pParent = 0, CLight *Light = 0); ENodeType NodeType(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& ViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); diff --git a/src/Core/Scene/CModelNode.cpp b/src/Core/Scene/CModelNode.cpp index 1f39f71f..6b01d945 100644 --- a/src/Core/Scene/CModelNode.cpp +++ b/src/Core/Scene/CModelNode.cpp @@ -35,16 +35,27 @@ void CModelNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo if (!rkViewInfo.ViewFrustum.BoxInFrustum(AABox())) return; if (rkViewInfo.GameMode) return; - if (!mpModel->HasTransparency(mActiveMatSet)) - pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); + // Transparent world models should have each surface processed separately + if (mWorldModel && mpModel->HasTransparency(mActiveMatSet)) + { + pRenderer->AddMesh(this, -1, AABox(), false, eDrawOpaqueParts); + + for (u32 iSurf = 0; iSurf < mpModel->GetSurfaceCount(); iSurf++) + { + if (mpModel->IsSurfaceTransparent(iSurf, mActiveMatSet)) + pRenderer->AddMesh(this, iSurf, mpModel->GetSurfaceAABox(iSurf).Transformed(Transform()), true, eDrawTransparentParts); + } + } + + // Other models should just draw all transparent surfaces sequentially else - AddSurfacesToRenderer(pRenderer, mpModel, mActiveMatSet, rkViewInfo); + AddModelToRenderer(pRenderer, mpModel, mActiveMatSet); if (mSelected) pRenderer->AddMesh(this, -1, AABox(), false, eDrawSelection); } -void CModelNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo) +void CModelNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo) { if (!mpModel) return; if (mForceAlphaOn) Options = (FRenderOptions) (Options & ~eNoAlpha); @@ -86,8 +97,8 @@ void CModelNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInf if (mpModel->IsSkinned()) CGraphics::LoadIdentityBoneTransforms(); - if (ComponentIndex < 0) - mpModel->Draw(Options, mActiveMatSet); + if (ComponentIndex == -1) + DrawModelParts(mpModel, Options, mActiveMatSet, Command); else mpModel->DrawSurface(Options, ComponentIndex, mActiveMatSet); @@ -96,11 +107,7 @@ void CModelNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInf CDrawUtil::UseColorShader(mScanOverlayColor); glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ZERO); Options |= eNoMaterialSetup; - - if (ComponentIndex < 0) - mpModel->Draw(Options, 0); - else - mpModel->DrawSurface(Options, ComponentIndex, mActiveMatSet); + DrawModelParts(mpModel, Options, 0, Command); } } diff --git a/src/Core/Scene/CModelNode.h b/src/Core/Scene/CModelNode.h index 13a7d10d..1c0ef115 100644 --- a/src/Core/Scene/CModelNode.h +++ b/src/Core/Scene/CModelNode.h @@ -20,7 +20,7 @@ public: virtual ENodeType NodeType(); virtual void PostLoad(); virtual void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); - virtual void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo); + virtual void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); virtual void DrawSelection(); virtual void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& rkViewInfo); virtual SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& rkViewInfo); diff --git a/src/Core/Scene/CSceneNode.cpp b/src/Core/Scene/CSceneNode.cpp index 46666364..55287584 100644 --- a/src/Core/Scene/CSceneNode.cpp +++ b/src/Core/Scene/CSceneNode.cpp @@ -4,6 +4,7 @@ #include "Core/Render/CDrawUtil.h" #include "Core/Resource/CGameArea.h" #include "Core/Resource/CResCache.h" +#include #include #include @@ -213,6 +214,43 @@ void CSceneNode::LoadLights(const SViewInfo& rkViewInfo) CGraphics::UpdateLightBlock(); } +void CSceneNode::AddModelToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet) +{ + ASSERT(pModel); + + if (!pModel->HasTransparency(MatSet)) + pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); + + else + { + pRenderer->AddMesh(this, -1, AABox(), false, eDrawOpaqueParts); + pRenderer->AddMesh(this, -1, AABox(), true, eDrawTransparentParts); + } +} + +void CSceneNode::DrawModelParts(CModel *pModel, FRenderOptions Options, u32 MatSet, ERenderCommand RenderCommand) +{ + // Common rendering functionality + if (RenderCommand == eDrawMesh) + pModel->Draw(Options, MatSet); + + else + { + bool DrawOpaque = (RenderCommand == eDrawMesh || RenderCommand == eDrawOpaqueParts); + bool DrawTransparent = (RenderCommand == eDrawMesh || RenderCommand == eDrawTransparentParts); + + for (u32 iSurf = 0; iSurf < pModel->GetSurfaceCount(); iSurf++) + { + bool ShouldRender = ( (DrawOpaque && DrawTransparent) || + (DrawOpaque && !pModel->IsSurfaceTransparent(iSurf, MatSet)) || + (DrawTransparent && pModel->IsSurfaceTransparent(iSurf, MatSet)) ); + + if (ShouldRender) + pModel->DrawSurface(Options, iSurf, MatSet); + } + } +} + void CSceneNode::DrawBoundingBox() const { CDrawUtil::DrawWireCube(AABox(), CColor::skWhite); @@ -224,21 +262,6 @@ void CSceneNode::DrawRotationArrow() const spArrowModel->Draw(eNoRenderOptions, 0); } -void CSceneNode::AddSurfacesToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet, const SViewInfo& rkViewInfo, EDepthGroup DepthGroup /*= eMidground*/, bool DoFrustumTest /*= true*/) -{ - u32 SurfaceCount = pModel->GetSurfaceCount(); - - for (u32 iSurf = 0; iSurf < SurfaceCount; iSurf++) - { - CAABox TransformedBox = pModel->GetSurfaceAABox(iSurf).Transformed(Transform()); - - if (!DoFrustumTest || rkViewInfo.ViewFrustum.BoxInFrustum(TransformedBox)) - { - pRenderer->AddMesh(this, (int) iSurf, TransformedBox, pModel->IsSurfaceTransparent(iSurf, MatSet), eDrawMesh, DepthGroup); - } - } -} - // ************ TRANSFORM ************ void CSceneNode::Translate(const CVector3f& rkTranslation, ETransformSpace TransformSpace) { diff --git a/src/Core/Scene/CSceneNode.h b/src/Core/Scene/CSceneNode.h index e4bbed73..8f3a7032 100644 --- a/src/Core/Scene/CSceneNode.h +++ b/src/Core/Scene/CSceneNode.h @@ -78,9 +78,10 @@ public: void LoadModelMatrix(); void BuildLightList(CGameArea *pArea); void LoadLights(const SViewInfo& rkViewInfo); + void AddModelToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet); + void DrawModelParts(CModel *pModel, FRenderOptions Options, u32 MatSet, ERenderCommand RenderCommand); void DrawBoundingBox() const; void DrawRotationArrow() const; - 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/CScriptAttachNode.cpp b/src/Core/Scene/CScriptAttachNode.cpp index 4e67bc53..a1fbea55 100644 --- a/src/Core/Scene/CScriptAttachNode.cpp +++ b/src/Core/Scene/CScriptAttachNode.cpp @@ -77,17 +77,14 @@ void CScriptAttachNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkV if (rkViewInfo.ViewFrustum.BoxInFrustum(AABox())) { - if (pModel->HasTransparency(0)) - AddSurfacesToRenderer(pRenderer, pModel, 0, rkViewInfo); - else - pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); + AddModelToRenderer(pRenderer, pModel, 0); if (mpParent->IsSelected() && !rkViewInfo.GameMode) pRenderer->AddMesh(this, -1, AABox(), false, eDrawSelection); } } -void CScriptAttachNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo) +void CScriptAttachNode::Draw(FRenderOptions Options, int /*ComponentIndex*/, ERenderCommand Command, const SViewInfo& rkViewInfo) { LoadModelMatrix(); mpParent->LoadLights(rkViewInfo); @@ -98,11 +95,7 @@ void CScriptAttachNode::Draw(FRenderOptions Options, int ComponentIndex, const S CGraphics::sPixelBlock.TintColor = mpParent->TintColor(rkViewInfo); CGraphics::sPixelBlock.TevColor = CColor::skWhite; CGraphics::UpdatePixelBlock(); - - if (ComponentIndex < 0) - Model()->Draw(Options, 0); - else - Model()->DrawSurface(Options, ComponentIndex, 0); + DrawModelParts(Model(), Options, 0, Command); } void CScriptAttachNode::DrawSelection() diff --git a/src/Core/Scene/CScriptAttachNode.h b/src/Core/Scene/CScriptAttachNode.h index e8b5ad93..5888de5a 100644 --- a/src/Core/Scene/CScriptAttachNode.h +++ b/src/Core/Scene/CScriptAttachNode.h @@ -25,7 +25,7 @@ public: ENodeType NodeType() { return eScriptAttachNode; } void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); - void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo); SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo); diff --git a/src/Core/Scene/CScriptNode.cpp b/src/Core/Scene/CScriptNode.cpp index d09ccbad..267633ca 100644 --- a/src/Core/Scene/CScriptNode.cpp +++ b/src/Core/Scene/CScriptNode.cpp @@ -151,14 +151,8 @@ void CScriptNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInf if (!pModel) pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); - else - { - if (!pModel->HasTransparency(0)) - pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); - else - AddSurfacesToRenderer(pRenderer, pModel, 0, rkViewInfo); - } + AddModelToRenderer(pRenderer, pModel, 0); } } } @@ -175,9 +169,9 @@ void CScriptNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInf } } -void CScriptNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo) +void CScriptNode::Draw(FRenderOptions Options, int /*ComponentIndex*/, ERenderCommand Command, const SViewInfo& rkViewInfo) { - if (!mpInstance || !mpDisplayAsset) return; + if (!mpInstance) return; // Draw model if (UsesModel()) @@ -219,11 +213,7 @@ void CScriptNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewIn CGraphics::sPixelBlock.TintColor = TintColor(rkViewInfo); CGraphics::UpdatePixelBlock(); - - if (ComponentIndex < 0) - pModel->Draw(Options, 0); - else - pModel->DrawSurface(Options, ComponentIndex, 0); + DrawModelParts(pModel, Options, 0, Command); } // If no model or billboard, default to drawing a purple box diff --git a/src/Core/Scene/CScriptNode.h b/src/Core/Scene/CScriptNode.h index 31100018..627a22e3 100644 --- a/src/Core/Scene/CScriptNode.h +++ b/src/Core/Scene/CScriptNode.h @@ -38,7 +38,7 @@ public: void PostLoad(); void OnTransformed(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); - void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo); SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo); diff --git a/src/Core/Scene/CStaticNode.cpp b/src/Core/Scene/CStaticNode.cpp index 6169d6f3..0accc717 100644 --- a/src/Core/Scene/CStaticNode.cpp +++ b/src/Core/Scene/CStaticNode.cpp @@ -52,7 +52,7 @@ void CStaticNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInf pRenderer->AddMesh(this, -1, AABox(), false, eDrawSelection); } -void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo) +void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand /*Command*/, const SViewInfo& rkViewInfo) { if (!mpModel) return; diff --git a/src/Core/Scene/CStaticNode.h b/src/Core/Scene/CStaticNode.h index b3bf03c5..5cf3876d 100644 --- a/src/Core/Scene/CStaticNode.h +++ b/src/Core/Scene/CStaticNode.h @@ -13,7 +13,7 @@ public: ENodeType NodeType(); void PostLoad(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); - void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo); SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo); diff --git a/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp b/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp index 68dfd0da..92b80eaa 100644 --- a/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp +++ b/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp @@ -234,7 +234,7 @@ void CDamageableTriggerExtra::AddToRenderer(CRenderer *pRenderer, const SViewInf } } -void CDamageableTriggerExtra::Draw(FRenderOptions Options, int /*ComponentIndex*/, const SViewInfo& rkViewInfo) +void CDamageableTriggerExtra::Draw(FRenderOptions Options, int /*ComponentIndex*/, ERenderCommand /*Command*/, const SViewInfo& rkViewInfo) { LoadModelMatrix(); CGraphics::sPixelBlock.TintColor = mpParent->TintColor(rkViewInfo); diff --git a/src/Core/ScriptExtra/CDamageableTriggerExtra.h b/src/Core/ScriptExtra/CDamageableTriggerExtra.h index 6c882c1f..56e88c76 100644 --- a/src/Core/ScriptExtra/CDamageableTriggerExtra.h +++ b/src/Core/ScriptExtra/CDamageableTriggerExtra.h @@ -41,7 +41,7 @@ public: void PropertyModified(IProperty *pProperty); bool ShouldDrawNormalAssets(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); - void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo); SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 ComponentIndex, const SViewInfo& rkViewInfo); diff --git a/src/Core/ScriptExtra/CDoorExtra.cpp b/src/Core/ScriptExtra/CDoorExtra.cpp index c78c4b00..84a8bb3e 100644 --- a/src/Core/ScriptExtra/CDoorExtra.cpp +++ b/src/Core/ScriptExtra/CDoorExtra.cpp @@ -64,17 +64,14 @@ void CDoorExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo if (mpParent->IsVisible() && rkViewInfo.ViewFrustum.BoxInFrustum(AABox())) { - if (mpShieldModel->HasTransparency(0)) - AddSurfacesToRenderer(pRenderer, mpShieldModel, 0, rkViewInfo); - else - pRenderer->AddMesh(this, -1, AABox(), false, eDrawMesh); + AddModelToRenderer(pRenderer, mpShieldModel, 0); if (mpParent->IsSelected() && !rkViewInfo.GameMode) pRenderer->AddMesh(this, -1, AABox(), false, eDrawSelection); } } -void CDoorExtra::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo) +void CDoorExtra::Draw(FRenderOptions Options, int /*ComponentIndex*/, ERenderCommand Command, const SViewInfo& rkViewInfo) { LoadModelMatrix(); mpParent->LoadLights(rkViewInfo); @@ -87,11 +84,7 @@ void CDoorExtra::Draw(FRenderOptions Options, int ComponentIndex, const SViewInf CGraphics::sPixelBlock.TintColor = Tint; CGraphics::sPixelBlock.TevColor = CColor::skWhite; CGraphics::UpdatePixelBlock(); - - if (ComponentIndex < 0) - mpShieldModel->Draw(Options, 0); - else - mpShieldModel->DrawSurface(Options, ComponentIndex, 0); + DrawModelParts(mpShieldModel, Options, 0, Command); } void CDoorExtra::DrawSelection() diff --git a/src/Core/ScriptExtra/CDoorExtra.h b/src/Core/ScriptExtra/CDoorExtra.h index b9d8b4f8..310335e7 100644 --- a/src/Core/ScriptExtra/CDoorExtra.h +++ b/src/Core/ScriptExtra/CDoorExtra.h @@ -16,7 +16,7 @@ public: explicit CDoorExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent = 0); void PropertyModified(IProperty *pProperty); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); - void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo); SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo); diff --git a/src/Core/ScriptExtra/CRadiusSphereExtra.cpp b/src/Core/ScriptExtra/CRadiusSphereExtra.cpp index 73440848..4eeb7527 100644 --- a/src/Core/ScriptExtra/CRadiusSphereExtra.cpp +++ b/src/Core/ScriptExtra/CRadiusSphereExtra.cpp @@ -36,7 +36,7 @@ void CRadiusSphereExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rk } } -void CRadiusSphereExtra::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& /*rkViewInfo*/) +void CRadiusSphereExtra::Draw(FRenderOptions /*Options*/, int /*ComponentIndex*/, ERenderCommand /*Command*/, const SViewInfo& /*rkViewInfo*/) { glBlendFunc(GL_ONE, GL_ZERO); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); diff --git a/src/Core/ScriptExtra/CRadiusSphereExtra.h b/src/Core/ScriptExtra/CRadiusSphereExtra.h index 9b0a9217..6f5c9180 100644 --- a/src/Core/ScriptExtra/CRadiusSphereExtra.h +++ b/src/Core/ScriptExtra/CRadiusSphereExtra.h @@ -12,7 +12,7 @@ class CRadiusSphereExtra : public CScriptExtra public: explicit CRadiusSphereExtra(CScriptObject *pInstance, CScene *pScene, CScriptNode *pParent = 0); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); - void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); CColor Color() const; CAABox Bounds() const; }; diff --git a/src/Core/ScriptExtra/CWaypointExtra.cpp b/src/Core/ScriptExtra/CWaypointExtra.cpp index 96125008..b84a5287 100644 --- a/src/Core/ScriptExtra/CWaypointExtra.cpp +++ b/src/Core/ScriptExtra/CWaypointExtra.cpp @@ -172,7 +172,7 @@ void CWaypointExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkView } } -void CWaypointExtra::Draw(FRenderOptions /*Options*/, int ComponentIndex, const SViewInfo& /*rkViewInfo*/) +void CWaypointExtra::Draw(FRenderOptions /*Options*/, int ComponentIndex, ERenderCommand /*Command*/, const SViewInfo& /*rkViewInfo*/) { glBlendFunc(GL_ONE, GL_ZERO); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); diff --git a/src/Core/ScriptExtra/CWaypointExtra.h b/src/Core/ScriptExtra/CWaypointExtra.h index b29dbd32..89e5550d 100644 --- a/src/Core/ScriptExtra/CWaypointExtra.h +++ b/src/Core/ScriptExtra/CWaypointExtra.h @@ -32,7 +32,7 @@ public: void OnTransformed(); void LinksModified(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); - void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); CColor TevColor(); }; diff --git a/src/Editor/CGizmo.cpp b/src/Editor/CGizmo.cpp index e9150327..44292c29 100644 --- a/src/Editor/CGizmo.cpp +++ b/src/Editor/CGizmo.cpp @@ -62,7 +62,7 @@ void CGizmo::AddToRenderer(CRenderer *pRenderer, const SViewInfo&) } } -void CGizmo::Draw(FRenderOptions /*Options*/, int ComponentIndex, const SViewInfo& /*rkViewInfo*/) +void CGizmo::Draw(FRenderOptions /*Options*/, int ComponentIndex, ERenderCommand /*Command*/, const SViewInfo& /*rkViewInfo*/) { // Determine which SModelPart array to use if (ComponentIndex >= (int) mNumCurrentParts) return; diff --git a/src/Editor/CGizmo.h b/src/Editor/CGizmo.h index 3e303141..15c4f1a3 100644 --- a/src/Editor/CGizmo.h +++ b/src/Editor/CGizmo.h @@ -128,7 +128,7 @@ public: ~CGizmo(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo); - void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo); + void Draw(FRenderOptions Options, int ComponentIndex, ERenderCommand Command, const SViewInfo& rkViewInfo); void IncrementSize(); void DecrementSize(); diff --git a/src/Editor/CGridRenderable.h b/src/Editor/CGridRenderable.h index 87bd715d..4d434642 100644 --- a/src/Editor/CGridRenderable.h +++ b/src/Editor/CGridRenderable.h @@ -13,7 +13,7 @@ public: pRenderer->AddMesh(this, 0, CAABox::skOne, false, eDrawMesh); } - void Draw(FRenderOptions, int, const SViewInfo&) + void Draw(FRenderOptions, int, ERenderCommand, const SViewInfo&) { CDrawUtil::DrawGrid(); }