From c6ec473280d00a4f8b92ca13b1335472f5edae5f Mon Sep 17 00:00:00 2001 From: LohikaarmeHav Date: Tue, 2 Aug 2016 13:46:43 +0300 Subject: [PATCH] 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);