CSceneViewport: Make use of in-class initializers where applicable
This commit is contained in:
parent
145dc11c58
commit
38cdcbdbd3
|
@ -11,34 +11,23 @@
|
||||||
|
|
||||||
CSceneViewport::CSceneViewport(QWidget *pParent)
|
CSceneViewport::CSceneViewport(QWidget *pParent)
|
||||||
: CBasicViewport(pParent)
|
: CBasicViewport(pParent)
|
||||||
, mpEditor(nullptr)
|
|
||||||
, mpScene(nullptr)
|
|
||||||
, mRenderingMergedWorld(true)
|
|
||||||
, mGizmoTransforming(false)
|
|
||||||
, mpHoverNode(nullptr)
|
|
||||||
, mHoverPoint(CVector3f::Zero())
|
|
||||||
, mpContextMenu(nullptr)
|
|
||||||
, mpMenuNode(nullptr)
|
|
||||||
{
|
{
|
||||||
mGrid.SetColor(CColor(0.f, 0.f, 0.6f, 0.f), CColor(0.f, 0.f, 1.f, 0.f));
|
mGrid.SetColor(CColor(0.f, 0.f, 0.6f, 0.f), CColor(0.f, 0.f, 1.f, 0.f));
|
||||||
mLinkLine.SetColor(CColor::Yellow());
|
mLinkLine.SetColor(CColor::Yellow());
|
||||||
|
|
||||||
mpRenderer = new CRenderer();
|
mpRenderer = std::make_unique<CRenderer>();
|
||||||
mpRenderer->SetClearColor(CColor::Black());
|
mpRenderer->SetClearColor(CColor::Black());
|
||||||
qreal pixelRatio = devicePixelRatioF();
|
const qreal pixelRatio = devicePixelRatioF();
|
||||||
mpRenderer->SetViewportSize(width() * pixelRatio, height() * pixelRatio);
|
mpRenderer->SetViewportSize(width() * pixelRatio, height() * pixelRatio);
|
||||||
|
|
||||||
mViewInfo.pScene = mpScene;
|
mViewInfo.pScene = mpScene;
|
||||||
mViewInfo.pRenderer = mpRenderer;
|
mViewInfo.pRenderer = mpRenderer.get();
|
||||||
mViewInfo.ShowFlags = EShowFlag::MergedWorld | EShowFlag::ObjectGeometry | EShowFlag::Lights | EShowFlag::Sky;
|
mViewInfo.ShowFlags = EShowFlag::MergedWorld | EShowFlag::ObjectGeometry | EShowFlag::Lights | EShowFlag::Sky;
|
||||||
|
|
||||||
CreateContextMenu();
|
CreateContextMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSceneViewport::~CSceneViewport()
|
CSceneViewport::~CSceneViewport() = default;
|
||||||
{
|
|
||||||
delete mpRenderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSceneViewport::SetScene(INodeEditor *pEditor, CScene *pScene)
|
void CSceneViewport::SetScene(INodeEditor *pEditor, CScene *pScene)
|
||||||
{
|
{
|
||||||
|
@ -72,7 +61,7 @@ FShowFlags CSceneViewport::ShowFlags() const
|
||||||
|
|
||||||
CRenderer* CSceneViewport::Renderer()
|
CRenderer* CSceneViewport::Renderer()
|
||||||
{
|
{
|
||||||
return mpRenderer;
|
return mpRenderer.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSceneNode* CSceneViewport::HoverNode()
|
CSceneNode* CSceneViewport::HoverNode()
|
||||||
|
@ -317,22 +306,22 @@ void CSceneViewport::Paint()
|
||||||
}
|
}
|
||||||
|
|
||||||
mCamera.LoadMatrices();
|
mCamera.LoadMatrices();
|
||||||
mpScene->AddSceneToRenderer(mpRenderer, mViewInfo);
|
mpScene->AddSceneToRenderer(mpRenderer.get(), mViewInfo);
|
||||||
|
|
||||||
// Add gizmo to renderer
|
// Add gizmo to renderer
|
||||||
if (mpEditor->IsGizmoVisible() && !mViewInfo.GameMode)
|
if (mpEditor->IsGizmoVisible() && !mViewInfo.GameMode)
|
||||||
{
|
{
|
||||||
CGizmo *pGizmo = mpEditor->Gizmo();
|
CGizmo *pGizmo = mpEditor->Gizmo();
|
||||||
pGizmo->UpdateForCamera(mCamera);
|
pGizmo->UpdateForCamera(mCamera);
|
||||||
pGizmo->AddToRenderer(mpRenderer, mViewInfo);
|
pGizmo->AddToRenderer(mpRenderer.get(), mViewInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw grid if the scene is empty
|
// Draw grid if the scene is empty
|
||||||
if (!mViewInfo.GameMode && mpScene->ActiveArea() == nullptr)
|
if (!mViewInfo.GameMode && mpScene->ActiveArea() == nullptr)
|
||||||
mGrid.AddToRenderer(mpRenderer, mViewInfo);
|
mGrid.AddToRenderer(mpRenderer.get(), mViewInfo);
|
||||||
|
|
||||||
// Draw the line for the link the user is editing.
|
// Draw the line for the link the user is editing.
|
||||||
if (mLinkLineEnabled) mLinkLine.AddToRenderer(mpRenderer, mViewInfo);
|
if (mLinkLineEnabled) mLinkLine.AddToRenderer(mpRenderer.get(), mViewInfo);
|
||||||
|
|
||||||
mpRenderer->RenderBuckets(mViewInfo);
|
mpRenderer->RenderBuckets(mViewInfo);
|
||||||
mpRenderer->EndFrame();
|
mpRenderer->EndFrame();
|
||||||
|
|
|
@ -10,20 +10,20 @@ class CSceneViewport : public CBasicViewport
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
INodeEditor *mpEditor;
|
INodeEditor *mpEditor = nullptr;
|
||||||
CScene *mpScene;
|
CScene *mpScene = nullptr;
|
||||||
CRenderer *mpRenderer;
|
std::unique_ptr<CRenderer> mpRenderer;
|
||||||
bool mRenderingMergedWorld;
|
bool mRenderingMergedWorld = true;
|
||||||
|
|
||||||
// Scene interaction
|
// Scene interaction
|
||||||
bool mGizmoHovering;
|
bool mGizmoHovering = false;
|
||||||
bool mGizmoTransforming;
|
bool mGizmoTransforming = false;
|
||||||
SRayIntersection mRayIntersection;
|
SRayIntersection mRayIntersection;
|
||||||
CSceneNode *mpHoverNode;
|
CSceneNode *mpHoverNode = nullptr;
|
||||||
CVector3f mHoverPoint;
|
CVector3f mHoverPoint{CVector3f::Zero()};
|
||||||
|
|
||||||
// Context Menu
|
// Context Menu
|
||||||
QMenu *mpContextMenu;
|
QMenu *mpContextMenu = nullptr;
|
||||||
QAction *mpToggleSelectAction;
|
QAction *mpToggleSelectAction;
|
||||||
QAction *mpHideSelectionSeparator;
|
QAction *mpHideSelectionSeparator;
|
||||||
QAction *mpHideSelectionAction;
|
QAction *mpHideSelectionAction;
|
||||||
|
@ -36,7 +36,7 @@ class CSceneViewport : public CBasicViewport
|
||||||
QAction *mpUnhideAllAction;
|
QAction *mpUnhideAllAction;
|
||||||
QAction *mpPlayFromHereSeparator;
|
QAction *mpPlayFromHereSeparator;
|
||||||
QAction *mpPlayFromHereAction;
|
QAction *mpPlayFromHereAction;
|
||||||
CSceneNode *mpMenuNode;
|
CSceneNode *mpMenuNode = nullptr;
|
||||||
CVector3f mMenuPoint;
|
CVector3f mMenuPoint;
|
||||||
|
|
||||||
QMenu *mpSelectConnectedMenu;
|
QMenu *mpSelectConnectedMenu;
|
||||||
|
@ -52,8 +52,9 @@ class CSceneViewport : public CBasicViewport
|
||||||
CLineRenderable mLinkLine;
|
CLineRenderable mLinkLine;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSceneViewport(QWidget *pParent = 0);
|
explicit CSceneViewport(QWidget *pParent = nullptr);
|
||||||
~CSceneViewport();
|
~CSceneViewport() override;
|
||||||
|
|
||||||
void SetScene(INodeEditor *pEditor, CScene *pScene);
|
void SetScene(INodeEditor *pEditor, CScene *pScene);
|
||||||
void SetShowWorld(bool Visible);
|
void SetShowWorld(bool Visible);
|
||||||
void SetRenderMergedWorld(bool RenderMerged);
|
void SetRenderMergedWorld(bool RenderMerged);
|
||||||
|
@ -66,11 +67,11 @@ public:
|
||||||
void ResetHover();
|
void ResetHover();
|
||||||
bool IsHoveringGizmo();
|
bool IsHoveringGizmo();
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent* pEvent);
|
void keyPressEvent(QKeyEvent* pEvent) override;
|
||||||
void keyReleaseEvent(QKeyEvent* pEvent);
|
void keyReleaseEvent(QKeyEvent* pEvent) override;
|
||||||
|
|
||||||
inline void SetLinkLineEnabled(bool Enable) { mLinkLineEnabled = Enable; }
|
void SetLinkLineEnabled(bool Enable) { mLinkLineEnabled = Enable; }
|
||||||
inline void SetLinkLine(const CVector3f& rkPointA, const CVector3f& rkPointB) { mLinkLine.SetPoints(rkPointA, rkPointB); }
|
void SetLinkLine(const CVector3f& rkPointA, const CVector3f& rkPointB) { mLinkLine.SetPoints(rkPointA, rkPointB); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CreateContextMenu();
|
void CreateContextMenu();
|
||||||
|
@ -84,12 +85,12 @@ signals:
|
||||||
void CameraOrbit();
|
void CameraOrbit();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void CheckUserInput();
|
void CheckUserInput() override;
|
||||||
void Paint();
|
void Paint() override;
|
||||||
void ContextMenu(QContextMenuEvent *pEvent);
|
void ContextMenu(QContextMenuEvent *pEvent) override;
|
||||||
void OnResize();
|
void OnResize() override;
|
||||||
void OnMouseClick(QMouseEvent *pEvent);
|
void OnMouseClick(QMouseEvent *pEvent) override;
|
||||||
void OnMouseRelease(QMouseEvent *pEvent);
|
void OnMouseRelease(QMouseEvent *pEvent) override;
|
||||||
|
|
||||||
// Menu Actions
|
// Menu Actions
|
||||||
void OnToggleSelect();
|
void OnToggleSelect();
|
||||||
|
|
Loading…
Reference in New Issue