From f142f9bf8634faa984d121e9db8711d36950e7b0 Mon Sep 17 00:00:00 2001 From: LohikaarmeHav Date: Wed, 27 Jul 2016 21:35:05 +0300 Subject: [PATCH 1/9] wtf --- CMakeLists.txt | 1 - apps/opencs/view/world/dragrecordtable.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 133d9f7e6..0790c0878 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -802,7 +802,6 @@ if (APPLE) set(\${default_embedded_path_var} \"\${path}\" PARENT_SCOPE) endif() endfunction() - cmake_policy(SET CMP0009 OLD) fixup_bundle(\"${INSTALLED_OPENMW_APP}\" \"${PLUGINS}\" \"\") fixup_bundle(\"${INSTALLED_OPENCS_APP}\" \"${OPENCS_PLUGINS}\" \"\") diff --git a/apps/opencs/view/world/dragrecordtable.cpp b/apps/opencs/view/world/dragrecordtable.cpp index a5f933283..8bb5659fd 100644 --- a/apps/opencs/view/world/dragrecordtable.cpp +++ b/apps/opencs/view/world/dragrecordtable.cpp @@ -62,7 +62,7 @@ void CSVWorld::DragRecordTable::dragMoveEvent(QDragMoveEvent *event) } void CSVWorld::DragRecordTable::dropEvent(QDropEvent *event) -{ +{(void)write(1,"H\n",2); QModelIndex index = indexAt(event->pos()); CSMWorld::ColumnBase::Display display = getIndexDisplayType(index); if (CSVWorld::DragDropUtils::canAcceptData(*event, display)) From c6ec473280d00a4f8b92ca13b1335472f5edae5f Mon Sep 17 00:00:00 2001 From: LohikaarmeHav Date: Tue, 2 Aug 2016 13:46:43 +0300 Subject: [PATCH 2/9] Camera reset now every time cell object->view is pressed. --- CMakeLists.txt | 1 + apps/opencs/model/world/cellcoordinates.hpp | 2 ++ apps/opencs/view/render/pagedworldspacewidget.cpp | 8 ++++++-- apps/opencs/view/render/pagedworldspacewidget.hpp | 2 ++ apps/opencs/view/render/scenewidget.cpp | 11 +---------- apps/opencs/view/render/scenewidget.hpp | 3 --- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 373301ddc..aa6d76a4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -810,6 +810,7 @@ if (APPLE) set(\${default_embedded_path_var} \"\${path}\" PARENT_SCOPE) endif() endfunction() + cmake_policy(SET CMP0009 OLD) fixup_bundle(\"${INSTALLED_OPENMW_APP}\" \"${PLUGINS}\" \"\") fixup_bundle(\"${INSTALLED_OPENCS_APP}\" \"${OPENCS_PLUGINS}\" \"\") diff --git a/apps/opencs/model/world/cellcoordinates.hpp b/apps/opencs/model/world/cellcoordinates.hpp index f8851a6d9..6ff4e4b5d 100644 --- a/apps/opencs/model/world/cellcoordinates.hpp +++ b/apps/opencs/model/world/cellcoordinates.hpp @@ -38,7 +38,9 @@ namespace CSMWorld /// \note The worldspace part of \a id is ignored static std::pair fromId (const std::string& id); + /// \return cell coordinates such that given world coordinates are in it. static std::pair coordinatesToCellIndex (float x, float y); + }; bool operator== (const CellCoordinates& left, const CellCoordinates& right); diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index a01df4392..3baf4e972 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -17,6 +17,7 @@ #include "editmode.hpp" #include "mask.hpp" +#include "cameracontroller.hpp" bool CSVRender::PagedWorldspaceWidget::adjustCells() { @@ -477,12 +478,15 @@ void CSVRender::PagedWorldspaceWidget::useViewHint (const std::string& hint) { char ignore1; // : or ; char ignore2; // # + // Current coordinate int x, y; + // Loop throught all the coordinates to add them to selection while (stream >> ignore1 >> ignore2 >> x >> y) selection.add (CSMWorld::CellCoordinates (x, y)); - - /// \todo adjust camera position + + // Setup camera + mCurrentCamControl->setup(mRootNode, Mask_Reference | Mask_Terrain, CameraController::WorldUp); } } else if (hint[0]=='r') diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index 692000708..e96cb9e8e 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -83,6 +83,8 @@ namespace CSVRender virtual ~PagedWorldspaceWidget(); + /// \brief Decodes the the hint string to set of cell that are rendered. + /// Calculates avarage of cell's coordinates to be new camera location. void useViewHint (const std::string& hint); void setCellSelection(const CSMWorld::CellSelection& selection); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index b2b5b30d6..a36ff8c49 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -31,7 +31,6 @@ RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) , mRootNode(0) { - osgViewer::CompositeViewer& viewer = CompositeViewer::get(); osg::DisplaySettings* ds = osg::DisplaySettings::instance().get(); @@ -314,15 +313,7 @@ void SceneWidget::keyReleaseEvent (QKeyEvent *event) void SceneWidget::update(double dt) { - if (mCamPositionSet) - { - mCurrentCamControl->update(dt); - } - else - { - mCurrentCamControl->setup(mRootNode, Mask_Reference | Mask_Terrain, CameraController::WorldUp); - mCamPositionSet = true; - } + mCurrentCamControl->update(dt); } void SceneWidget::settingChanged (const CSMPrefs::Setting *setting) diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index 4df49543a..d3ab28adc 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -121,9 +121,6 @@ namespace CSVRender std::map, std::string> mButtonMapping; - private: - bool mCamPositionSet; - public slots: void update(double dt); From 2e6f80688c89df832e3a44cba151f358a121c5d6 Mon Sep 17 00:00:00 2001 From: LohikaarmeHav Date: Tue, 2 Aug 2016 14:10:08 +0300 Subject: [PATCH 3/9] Removed debug --- apps/opencs/view/world/dragrecordtable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/view/world/dragrecordtable.cpp b/apps/opencs/view/world/dragrecordtable.cpp index 8bb5659fd..a5f933283 100644 --- a/apps/opencs/view/world/dragrecordtable.cpp +++ b/apps/opencs/view/world/dragrecordtable.cpp @@ -62,7 +62,7 @@ void CSVWorld::DragRecordTable::dragMoveEvent(QDragMoveEvent *event) } void CSVWorld::DragRecordTable::dropEvent(QDropEvent *event) -{(void)write(1,"H\n",2); +{ QModelIndex index = indexAt(event->pos()); CSMWorld::ColumnBase::Display display = getIndexDisplayType(index); if (CSVWorld::DragDropUtils::canAcceptData(*event, display)) From c6bc30d6a837cef928c1ecf733b4f198ac5b9863 Mon Sep 17 00:00:00 2001 From: LohikaarmeHav Date: Tue, 2 Aug 2016 14:27:19 +0300 Subject: [PATCH 4/9] Forgot to remove line and add comment. --- apps/opencs/view/render/scenewidget.cpp | 1 - apps/opencs/view/render/scenewidget.hpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index a36ff8c49..ef5b8959b 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -160,7 +160,6 @@ SceneWidget::SceneWidget(boost::shared_ptr resourceSys , mFreeCamControl(new FreeCameraController()) , mOrbitCamControl(new OrbitCameraController()) , mCurrentCamControl(mFreeCamControl.get()) - , mCamPositionSet(false) { mOrbitCamControl->setPickingMask(Mask_Reference | Mask_Terrain); selectNavigationMode("free"); diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index d3ab28adc..c36c57e4e 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -122,6 +122,7 @@ namespace CSVRender std::map, std::string> mButtonMapping; public slots: + /// \note Remember set the camera before running void update(double dt); protected slots: From 7cd991107c637f95663c38efc4fd2ecb1084bd24 Mon Sep 17 00:00:00 2001 From: LohikaarmeHav Date: Tue, 2 Aug 2016 15:26:12 +0300 Subject: [PATCH 5/9] Nah Preview seem to not like removing mCamPositionSet and I have do other things. --- apps/opencs/view/render/pagedworldspacewidget.cpp | 4 ++-- apps/opencs/view/render/scenewidget.cpp | 11 ++++++++++- apps/opencs/view/render/scenewidget.hpp | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index 3baf4e972..d206c43b6 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -485,8 +485,8 @@ void CSVRender::PagedWorldspaceWidget::useViewHint (const std::string& hint) while (stream >> ignore1 >> ignore2 >> x >> y) selection.add (CSMWorld::CellCoordinates (x, y)); - // Setup camera - mCurrentCamControl->setup(mRootNode, Mask_Reference | Mask_Terrain, CameraController::WorldUp); + // Mark that camera needs setup + mCamPositionSet=false; } } else if (hint[0]=='r') diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index ef5b8959b..1ebc5c3e7 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -160,6 +160,7 @@ SceneWidget::SceneWidget(boost::shared_ptr resourceSys , mFreeCamControl(new FreeCameraController()) , mOrbitCamControl(new OrbitCameraController()) , mCurrentCamControl(mFreeCamControl.get()) + , mCamPositionSet(false) { mOrbitCamControl->setPickingMask(Mask_Reference | Mask_Terrain); selectNavigationMode("free"); @@ -312,7 +313,15 @@ void SceneWidget::keyReleaseEvent (QKeyEvent *event) void SceneWidget::update(double dt) { - mCurrentCamControl->update(dt); + if(mCamPositionSet) + { + mCurrentCamControl->update(dt); + } + else + { + mCurrentCamControl->setup(mRootNode, Mask_Reference | Mask_Terrain, CameraController::WorldUp); + mCamPositionSet = true; + } } void SceneWidget::settingChanged (const CSMPrefs::Setting *setting) diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index c36c57e4e..e21599373 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -118,6 +118,7 @@ namespace CSVRender std::auto_ptr mFreeCamControl; std::auto_ptr mOrbitCamControl; CameraController* mCurrentCamControl; + bool mCamPositionSet; std::map, std::string> mButtonMapping; From b0cf276cfc83ecf0e340d1c5f50c2761927e0013 Mon Sep 17 00:00:00 2001 From: LohikaarmeHav Date: Tue, 2 Aug 2016 15:27:40 +0300 Subject: [PATCH 6/9] hups --- apps/opencs/view/render/scenewidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 1ebc5c3e7..77d68eb01 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -313,7 +313,7 @@ void SceneWidget::keyReleaseEvent (QKeyEvent *event) void SceneWidget::update(double dt) { - if(mCamPositionSet) + if (mCamPositionSet) { mCurrentCamControl->update(dt); } From 48bcde8cc99afbd835d203913c9a69f32973b2cc Mon Sep 17 00:00:00 2001 From: lohikaarme Date: Tue, 2 Aug 2016 15:41:52 +0300 Subject: [PATCH 7/9] ... --- apps/opencs/view/render/scenewidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 77d68eb01..a890fa3cb 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -31,6 +31,7 @@ RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) , mRootNode(0) { + osgViewer::CompositeViewer& viewer = CompositeViewer::get(); osg::DisplaySettings* ds = osg::DisplaySettings::instance().get(); From 0592d1cdcfa5088e151d7c6f99b25a60932874a5 Mon Sep 17 00:00:00 2001 From: lohikaarme Date: Wed, 3 Aug 2016 14:22:25 +0300 Subject: [PATCH 8/9] Commnent? --- apps/opencs/view/render/pagedworldspacewidget.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index e96cb9e8e..8b6f2ee01 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -84,7 +84,7 @@ namespace CSVRender virtual ~PagedWorldspaceWidget(); /// \brief Decodes the the hint string to set of cell that are rendered. - /// Calculates avarage of cell's coordinates to be new camera location. + /// \details Calculates avarage of cell's coordinates to be new camera location. void useViewHint (const std::string& hint); void setCellSelection(const CSMWorld::CellSelection& selection); From e8ef5c233f2f6a6097bbec7eafb606ec1883b248 Mon Sep 17 00:00:00 2001 From: lohikaarme Date: Wed, 3 Aug 2016 14:24:21 +0300 Subject: [PATCH 9/9] Miss info --- apps/opencs/view/render/pagedworldspacewidget.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index 8b6f2ee01..1c4caeb7f 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -83,8 +83,7 @@ namespace CSVRender virtual ~PagedWorldspaceWidget(); - /// \brief Decodes the the hint string to set of cell that are rendered. - /// \details Calculates avarage of cell's coordinates to be new camera location. + /// Decodes the the hint string to set of cell that are rendered. void useViewHint (const std::string& hint); void setCellSelection(const CSMWorld::CellSelection& selection);