Fixed edit link line being drawn at the wrong depth
This commit is contained in:
parent
f64ee6b3b7
commit
7423cdce42
|
@ -0,0 +1,45 @@
|
|||
#ifndef CLINERENDERABLE
|
||||
#define CLINERENDERABLE
|
||||
|
||||
#include <Common/CColor.h>
|
||||
#include <Math/CVector3f.h>
|
||||
#include <Core/Render/CDrawUtil.h>
|
||||
#include <Core/Render/CRenderer.h>
|
||||
#include <Core/Render/IRenderable.h>
|
||||
|
||||
class CLineRenderable : public IRenderable
|
||||
{
|
||||
CVector3f mPoints[2];
|
||||
CColor mColor;
|
||||
|
||||
public:
|
||||
CLineRenderable() : IRenderable() {}
|
||||
|
||||
inline void SetPoints(const CVector3f& rkPointA, const CVector3f& rkPointB)
|
||||
{
|
||||
mPoints[0] = rkPointA;
|
||||
mPoints[1] = rkPointB;
|
||||
}
|
||||
|
||||
inline void SetColor(const CColor& rkColor)
|
||||
{
|
||||
mColor = rkColor;
|
||||
}
|
||||
|
||||
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& /*rkViewInfo*/)
|
||||
{
|
||||
pRenderer->AddMesh(this, -1, CAABox::skInfinite, false, eDrawMesh);
|
||||
}
|
||||
|
||||
void Draw(FRenderOptions, int, ERenderCommand, const SViewInfo&)
|
||||
{
|
||||
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
||||
CGraphics::UpdateMVPBlock();
|
||||
glDepthRange(0.f, 1.f);
|
||||
glLineWidth(1.f);
|
||||
CDrawUtil::DrawLine(mPoints[0], mPoints[1], mColor);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CLINERENDERABLE
|
||||
|
|
@ -20,6 +20,8 @@ CSceneViewport::CSceneViewport(QWidget *pParent)
|
|||
, mpContextMenu(nullptr)
|
||||
, mpMenuNode(nullptr)
|
||||
{
|
||||
mLinkLine.SetColor(CColor::skYellow);
|
||||
|
||||
mpRenderer = new CRenderer();
|
||||
mpRenderer->SetClearColor(CColor::skBlack);
|
||||
mpRenderer->SetViewportSize(width(), height());
|
||||
|
@ -317,14 +319,8 @@ void CSceneViewport::Paint()
|
|||
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)
|
||||
{
|
||||
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
||||
CGraphics::UpdateMVPBlock();
|
||||
glDepthRange(0.f, 1.f);
|
||||
CDrawUtil::DrawLine(mLinkLinePoints[0], mLinkLinePoints[1], CColor::skYellow);
|
||||
}
|
||||
// Draw the line for the link the user is editing.
|
||||
if (mLinkLineEnabled) mLinkLine.AddToRenderer(mpRenderer, mViewInfo);
|
||||
|
||||
mpRenderer->RenderBuckets(mViewInfo);
|
||||
mpRenderer->EndFrame();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define CSCENEVIEWPORT_H
|
||||
|
||||
#include "CBasicViewport.h"
|
||||
#include "CLineRenderable.h"
|
||||
#include "INodeEditor.h"
|
||||
|
||||
class CSceneViewport : public CBasicViewport
|
||||
|
@ -41,7 +42,7 @@ class CSceneViewport : public CBasicViewport
|
|||
|
||||
// Link Line
|
||||
bool mLinkLineEnabled;
|
||||
CVector3f mLinkLinePoints[2];
|
||||
CLineRenderable mLinkLine;
|
||||
|
||||
public:
|
||||
CSceneViewport(QWidget *pParent = 0);
|
||||
|
@ -61,13 +62,8 @@ public:
|
|||
void keyPressEvent(QKeyEvent* pEvent);
|
||||
void keyReleaseEvent(QKeyEvent* pEvent);
|
||||
|
||||
inline void SetLinkLineEnabled(bool Enable) { mLinkLineEnabled = Enable; }
|
||||
|
||||
inline void SetLinkLine(const CVector3f& rkPointA, const CVector3f& rkPointB)
|
||||
{
|
||||
mLinkLinePoints[0] = rkPointA;
|
||||
mLinkLinePoints[1] = rkPointB;
|
||||
}
|
||||
inline void SetLinkLineEnabled(bool Enable) { mLinkLineEnabled = Enable; }
|
||||
inline void SetLinkLine(const CVector3f& rkPointA, const CVector3f& rkPointB) { mLinkLine.SetPoints(rkPointA, rkPointB); }
|
||||
|
||||
protected:
|
||||
void CreateContextMenu();
|
||||
|
|
|
@ -163,7 +163,8 @@ HEADERS += \
|
|||
CharacterEditor/CCharacterEditor.h \
|
||||
CharacterEditor/CCharacterEditorViewport.h \
|
||||
CGridRenderable.h \
|
||||
CharacterEditor/CSkeletonHierarchyModel.h
|
||||
CharacterEditor/CSkeletonHierarchyModel.h \
|
||||
CLineRenderable.h
|
||||
|
||||
# Source Files
|
||||
SOURCES += \
|
||||
|
|
Loading…
Reference in New Issue