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