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)
|
, mpContextMenu(nullptr)
|
||||||
, mpMenuNode(nullptr)
|
, mpMenuNode(nullptr)
|
||||||
{
|
{
|
||||||
|
mLinkLine.SetColor(CColor::skYellow);
|
||||||
|
|
||||||
mpRenderer = new CRenderer();
|
mpRenderer = new CRenderer();
|
||||||
mpRenderer->SetClearColor(CColor::skBlack);
|
mpRenderer->SetClearColor(CColor::skBlack);
|
||||||
mpRenderer->SetViewportSize(width(), height());
|
mpRenderer->SetViewportSize(width(), height());
|
||||||
|
@ -317,14 +319,8 @@ void CSceneViewport::Paint()
|
||||||
pGizmo->AddToRenderer(mpRenderer, mViewInfo);
|
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.
|
// Draw the line for the link the user is editing.
|
||||||
if (mLinkLineEnabled)
|
if (mLinkLineEnabled) mLinkLine.AddToRenderer(mpRenderer, mViewInfo);
|
||||||
{
|
|
||||||
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
|
||||||
CGraphics::UpdateMVPBlock();
|
|
||||||
glDepthRange(0.f, 1.f);
|
|
||||||
CDrawUtil::DrawLine(mLinkLinePoints[0], mLinkLinePoints[1], CColor::skYellow);
|
|
||||||
}
|
|
||||||
|
|
||||||
mpRenderer->RenderBuckets(mViewInfo);
|
mpRenderer->RenderBuckets(mViewInfo);
|
||||||
mpRenderer->EndFrame();
|
mpRenderer->EndFrame();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define CSCENEVIEWPORT_H
|
#define CSCENEVIEWPORT_H
|
||||||
|
|
||||||
#include "CBasicViewport.h"
|
#include "CBasicViewport.h"
|
||||||
|
#include "CLineRenderable.h"
|
||||||
#include "INodeEditor.h"
|
#include "INodeEditor.h"
|
||||||
|
|
||||||
class CSceneViewport : public CBasicViewport
|
class CSceneViewport : public CBasicViewport
|
||||||
|
@ -41,7 +42,7 @@ class CSceneViewport : public CBasicViewport
|
||||||
|
|
||||||
// Link Line
|
// Link Line
|
||||||
bool mLinkLineEnabled;
|
bool mLinkLineEnabled;
|
||||||
CVector3f mLinkLinePoints[2];
|
CLineRenderable mLinkLine;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSceneViewport(QWidget *pParent = 0);
|
CSceneViewport(QWidget *pParent = 0);
|
||||||
|
@ -62,12 +63,7 @@ public:
|
||||||
void keyReleaseEvent(QKeyEvent* pEvent);
|
void keyReleaseEvent(QKeyEvent* pEvent);
|
||||||
|
|
||||||
inline void SetLinkLineEnabled(bool Enable) { mLinkLineEnabled = Enable; }
|
inline void SetLinkLineEnabled(bool Enable) { mLinkLineEnabled = Enable; }
|
||||||
|
inline void SetLinkLine(const CVector3f& rkPointA, const CVector3f& rkPointB) { mLinkLine.SetPoints(rkPointA, rkPointB); }
|
||||||
inline void SetLinkLine(const CVector3f& rkPointA, const CVector3f& rkPointB)
|
|
||||||
{
|
|
||||||
mLinkLinePoints[0] = rkPointA;
|
|
||||||
mLinkLinePoints[1] = rkPointB;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CreateContextMenu();
|
void CreateContextMenu();
|
||||||
|
|
|
@ -163,7 +163,8 @@ HEADERS += \
|
||||||
CharacterEditor/CCharacterEditor.h \
|
CharacterEditor/CCharacterEditor.h \
|
||||||
CharacterEditor/CCharacterEditorViewport.h \
|
CharacterEditor/CCharacterEditorViewport.h \
|
||||||
CGridRenderable.h \
|
CGridRenderable.h \
|
||||||
CharacterEditor/CSkeletonHierarchyModel.h
|
CharacterEditor/CSkeletonHierarchyModel.h \
|
||||||
|
CLineRenderable.h
|
||||||
|
|
||||||
# Source Files
|
# Source Files
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
|
Loading…
Reference in New Issue