CCharacterEditorViewport: Make use of in-class initializers where applicable
This commit is contained in:
parent
2f767d6b9a
commit
b42536fdea
|
@ -1,26 +1,20 @@
|
||||||
#include "CCharacterEditorViewport.h"
|
#include "CCharacterEditorViewport.h"
|
||||||
|
|
||||||
CCharacterEditorViewport::CCharacterEditorViewport(QWidget *pParent /*= 0*/)
|
CCharacterEditorViewport::CCharacterEditorViewport(QWidget *pParent)
|
||||||
: CBasicViewport(pParent)
|
: CBasicViewport(pParent), mpRenderer{std::make_unique<CRenderer>()}
|
||||||
, mpCharNode(nullptr)
|
|
||||||
, mGridEnabled(true)
|
|
||||||
{
|
{
|
||||||
mpRenderer = new CRenderer();
|
const qreal pixelRatio = devicePixelRatioF();
|
||||||
qreal pixelRatio = devicePixelRatioF();
|
|
||||||
mpRenderer->SetViewportSize(width() * pixelRatio, height() * pixelRatio);
|
mpRenderer->SetViewportSize(width() * pixelRatio, height() * pixelRatio);
|
||||||
mpRenderer->SetClearColor(CColor(0.3f, 0.3f, 0.3f));
|
mpRenderer->SetClearColor(CColor(0.3f, 0.3f, 0.3f));
|
||||||
mpRenderer->ToggleGrid(true);
|
mpRenderer->ToggleGrid(true);
|
||||||
|
|
||||||
mViewInfo.ShowFlags = EShowFlag::ObjectGeometry; // This enables the mesh and not the skeleton by default
|
mViewInfo.ShowFlags = EShowFlag::ObjectGeometry; // This enables the mesh and not the skeleton by default
|
||||||
mViewInfo.pRenderer = mpRenderer;
|
mViewInfo.pRenderer = mpRenderer.get();
|
||||||
mViewInfo.pScene = nullptr;
|
mViewInfo.pScene = nullptr;
|
||||||
mViewInfo.GameMode = false;
|
mViewInfo.GameMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCharacterEditorViewport::~CCharacterEditorViewport()
|
CCharacterEditorViewport::~CCharacterEditorViewport() = default;
|
||||||
{
|
|
||||||
delete mpRenderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCharacterEditorViewport::SetNode(CCharacterNode *pNode)
|
void CCharacterEditorViewport::SetNode(CCharacterNode *pNode)
|
||||||
{
|
{
|
||||||
|
@ -29,12 +23,12 @@ void CCharacterEditorViewport::SetNode(CCharacterNode *pNode)
|
||||||
|
|
||||||
void CCharacterEditorViewport::CheckUserInput()
|
void CCharacterEditorViewport::CheckUserInput()
|
||||||
{
|
{
|
||||||
uint32 HoverBoneID = -1;
|
uint32 HoverBoneID = UINT32_MAX;
|
||||||
|
|
||||||
if (underMouse() && !IsMouseInputActive())
|
if (underMouse() && !IsMouseInputActive())
|
||||||
{
|
{
|
||||||
CRay Ray = CastRay();
|
const CRay Ray = CastRay();
|
||||||
SRayIntersection Intersect = mpCharNode->RayNodeIntersectTest(Ray, 0, mViewInfo);
|
const SRayIntersection Intersect = mpCharNode->RayNodeIntersectTest(Ray, 0, mViewInfo);
|
||||||
|
|
||||||
if (Intersect.Hit)
|
if (Intersect.Hit)
|
||||||
HoverBoneID = Intersect.ComponentIndex;
|
HoverBoneID = Intersect.ComponentIndex;
|
||||||
|
@ -51,11 +45,12 @@ void CCharacterEditorViewport::Paint()
|
||||||
{
|
{
|
||||||
mpRenderer->BeginFrame();
|
mpRenderer->BeginFrame();
|
||||||
mCamera.LoadMatrices();
|
mCamera.LoadMatrices();
|
||||||
if (mGridEnabled) mGrid.AddToRenderer(mpRenderer, mViewInfo);
|
if (mGridEnabled)
|
||||||
|
mGrid.AddToRenderer(mpRenderer.get(), mViewInfo);
|
||||||
|
|
||||||
if (mpCharNode)
|
if (mpCharNode != nullptr)
|
||||||
{
|
{
|
||||||
mpCharNode->AddToRenderer(mpRenderer, mViewInfo);
|
mpCharNode->AddToRenderer(mpRenderer.get(), mViewInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
mpRenderer->RenderBuckets(mViewInfo);
|
mpRenderer->RenderBuckets(mViewInfo);
|
||||||
|
@ -64,7 +59,7 @@ void CCharacterEditorViewport::Paint()
|
||||||
|
|
||||||
void CCharacterEditorViewport::OnResize()
|
void CCharacterEditorViewport::OnResize()
|
||||||
{
|
{
|
||||||
qreal pixelRatio = devicePixelRatioF();
|
const qreal pixelRatio = devicePixelRatioF();
|
||||||
mpRenderer->SetViewportSize(width() * pixelRatio, height() * pixelRatio);
|
mpRenderer->SetViewportSize(width() * pixelRatio, height() * pixelRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,28 +4,29 @@
|
||||||
#include "Editor/CBasicViewport.h"
|
#include "Editor/CBasicViewport.h"
|
||||||
#include "Editor/CGridRenderable.h"
|
#include "Editor/CGridRenderable.h"
|
||||||
#include <Core/Scene/CCharacterNode.h>
|
#include <Core/Scene/CCharacterNode.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class CCharacterEditorViewport : public CBasicViewport
|
class CCharacterEditorViewport : public CBasicViewport
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
CCharacterNode *mpCharNode;
|
CCharacterNode *mpCharNode = nullptr;
|
||||||
CGridRenderable mGrid;
|
CGridRenderable mGrid;
|
||||||
CRenderer *mpRenderer;
|
std::unique_ptr<CRenderer> mpRenderer;
|
||||||
uint32 mHoverBone;
|
uint32 mHoverBone = 0;
|
||||||
bool mGridEnabled;
|
bool mGridEnabled = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCharacterEditorViewport(QWidget *pParent = 0);
|
explicit CCharacterEditorViewport(QWidget* pParent = nullptr);
|
||||||
~CCharacterEditorViewport();
|
~CCharacterEditorViewport();
|
||||||
void SetNode(CCharacterNode *pNode);
|
void SetNode(CCharacterNode *pNode);
|
||||||
void CheckUserInput();
|
void CheckUserInput() override;
|
||||||
void Paint();
|
void Paint() override;
|
||||||
void OnResize();
|
void OnResize() override;
|
||||||
void OnMouseClick(QMouseEvent *pEvent);
|
void OnMouseClick(QMouseEvent *pEvent) override;
|
||||||
|
|
||||||
inline uint32 HoverBoneID() const { return mHoverBone; }
|
uint32 HoverBoneID() const { return mHoverBone; }
|
||||||
inline void SetGridEnabled(bool Enable) { mGridEnabled = Enable; }
|
void SetGridEnabled(bool Enable) { mGridEnabled = Enable; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void HoverBoneChanged(uint32 BoneID);
|
void HoverBoneChanged(uint32 BoneID);
|
||||||
|
|
Loading…
Reference in New Issue