Moved view manipulator to a separate class.

This commit is contained in:
Leonardo Zide 2021-06-20 11:40:16 -07:00
parent bd12ad5842
commit c236ea02bb
7 changed files with 1126 additions and 1036 deletions

View file

@ -9,6 +9,7 @@
#include "texfont.h"
#include "lc_view.h"
#include "lc_viewsphere.h"
#include "lc_viewmanipulator.h"
#include "lc_stringcache.h"
#include "lc_partselectionwidget.h"
#include <QOpenGLFunctions_3_2_Core>
@ -94,6 +95,7 @@ bool lcContext::InitializeRenderer()
Context->CreateResources();
lcView::CreateResources(Context);
lcViewManipulator::CreateResources(Context);
lcViewSphere::CreateResources(Context);
if (!gSupportsShaderObjects && lcGetPreferences().mShadingMode == lcShadingMode::DefaultLights)
@ -121,6 +123,7 @@ void lcContext::ShutdownRenderer()
lcView::DestroyResources(Context);
Context->DestroyResources();
lcViewManipulator::DestroyResources(Context);
lcViewSphere::DestroyResources(Context);
mGlobalOffscreenContext.reset();

View file

@ -97,8 +97,11 @@ struct lcRenderMesh;
struct lcObjectSection;
class lcTexture;
class lcScene;
class lcViewManipulator;
class lcViewSphere;
enum class lcRenderMeshState : int;
enum class lcTrackTool;
enum class lcTrackButton;
class lcFile;
class lcMemFile;

File diff suppressed because it is too large Load diff

View file

@ -182,6 +182,11 @@ public:
mBackgroundColor = BackgroundColor;
}
lcMatrix44 GetActiveSubmodelTransform() const
{
return mActiveSubmodelTransform;
}
static std::vector<lcView*> GetModelViews(const lcModel* Model);
static void UpdateProjectViews(const Project* Project);
static void UpdateAllViews();
@ -243,6 +248,7 @@ public:
bool CloseFindReplaceDialog();
void ShowFindReplaceWidget(bool Replace);
float GetOverlayScale() const;
lcVector3 GetMoveDirection(const lcVector3& Direction) const;
lcMatrix44 GetPieceInsertPosition(bool IgnoreSelected, PieceInfo* Info) const;
lcVector3 GetCameraLightInsertPosition() const;
@ -250,6 +256,11 @@ public:
lcObjectSection FindObjectUnderPointer(bool PiecesOnly, bool IgnoreSelected) const;
lcArray<lcObject*> FindObjectsInBox(float x1, float y1, float x2, float y2) const;
lcVector3 ProjectPoint(const lcVector3& Point) const;
lcVector3 UnprojectPoint(const lcVector3& Point) const;
void UnprojectPoints(lcVector3* Points, int NumPoints) const;
lcMatrix44 GetProjectionMatrix() const;
bool BeginRenderToImage(int Width, int Height);
void EndRenderToImage();
QImage GetRenderImage() const;
@ -266,31 +277,21 @@ signals:
void CameraChanged();
protected:
static void CreateSelectMoveOverlayMesh(lcContext* Context);
void DrawBackground() const;
void DrawViewport() const;
void DrawAxes() const;
void DrawSelectMoveOverlay();
void DrawRotateOverlay();
void DrawSelectZoomRegionOverlay();
void DrawRotateViewOverlay();
void DrawGrid();
lcVector3 ProjectPoint(const lcVector3& Point) const;
lcVector3 UnprojectPoint(const lcVector3& Point) const;
void UnprojectPoints(lcVector3* Points, int NumPoints) const;
lcMatrix44 GetProjectionMatrix() const;
lcMatrix44 GetTileProjectionMatrix(int CurrentRow, int CurrentColumn, int CurrentTileWidth, int CurrentTileHeight) const;
lcCursor GetCursor() const;
void SetCursor(lcCursor Cursor);
lcTool GetCurrentTool() const;
void UpdateTrackTool();
bool IsTrackToolAllowed(lcTrackTool TrackTool, quint32 AllowedTransforms) const;
lcTrackTool GetOverrideTrackTool(Qt::MouseButton Button) const;
float GetOverlayScale() const;
void StartTracking(lcTrackButton TrackButton);
void StopTracking(bool Accept);
void OnButtonDown(lcTrackButton TrackButton);
@ -324,6 +325,7 @@ protected:
quint32 mBackgroundColor = 0;
std::unique_ptr<lcScene> mScene;
std::unique_ptr<lcViewManipulator> mViewManipulator;
std::unique_ptr<lcViewSphere> mViewSphere;
lcModel* mModel = nullptr;
@ -340,7 +342,4 @@ protected:
static lcView* mLastFocusedView;
static std::vector<lcView*> mViews;
static lcVertexBuffer mRotateMoveVertexBuffer;
static lcIndexBuffer mRotateMoveIndexBuffer;
};

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,26 @@
#pragma once
#include "lc_context.h"
class lcViewManipulator
{
public:
lcViewManipulator(lcView* View);
void DrawSelectMove(lcTrackButton TrackButton, lcTrackTool TrackTool);
void DrawRotate(lcTrackButton TrackButton, lcTrackTool TrackTool);
lcTrackTool UpdateSelectMove();
lcTrackTool UpdateRotate();
static void CreateResources(lcContext* Context);
static void DestroyResources(lcContext* Context);
protected:
static bool IsTrackToolAllowed(lcTrackTool TrackTool, quint32 AllowedTransforms);
lcView* mView = nullptr;
static lcVertexBuffer mRotateMoveVertexBuffer;
static lcIndexBuffer mRotateMoveIndexBuffer;
};

View file

@ -197,6 +197,7 @@ SOURCES += \
common/lc_texture.cpp \
common/lc_timelinewidget.cpp \
common/lc_view.cpp \
common/lc_viewsmanipulator.cpp \
common/lc_viewsphere.cpp \
common/lc_viewwidget.cpp \
common/lc_zipfile.cpp \
@ -265,6 +266,7 @@ HEADERS += \
common/lc_synth.h \
common/lc_texture.h \
common/lc_view.h \
common/lc_viewsmanipulator.h \
common/lc_viewsphere.h \
common/lc_viewwidget.h \
common/lc_zipfile.h \