From 2de920e091e256f33585c43c4756315f81be1b46 Mon Sep 17 00:00:00 2001 From: Michael Lemaire Date: Wed, 22 Jul 2015 18:39:46 +0200 Subject: [PATCH] Fixed quick ui camera to stay above ground and water --- src/definition/Scenery.cpp | 6 +++--- src/definition/Scenery.h | 2 +- src/interface/modeler/quickapp/ModelerCameras.cpp | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/definition/Scenery.cpp b/src/definition/Scenery.cpp index 7ced63c..cdabef4 100644 --- a/src/definition/Scenery.cpp +++ b/src/definition/Scenery.cpp @@ -43,7 +43,7 @@ void Scenery::validate() { BaseDefinition::validate(); - checkCameraAboveGround(); + keepCameraAboveGround(camera); } Scenery::FileOperationResult Scenery::saveGlobal(const std::string &filepath) const @@ -131,7 +131,7 @@ void Scenery::getAtmosphere(AtmosphereDefinition* atmosphere) void Scenery::setCamera(CameraDefinition* camera) { camera->copy(this->camera); - checkCameraAboveGround(); + keepCameraAboveGround(this->camera); } void Scenery::getCamera(CameraDefinition* camera) @@ -179,7 +179,7 @@ void Scenery::getWater(WaterDefinition* water) this->water->copy(water); } -void Scenery::checkCameraAboveGround() +void Scenery::keepCameraAboveGround(CameraDefinition* camera) { Vector3 camera_location = camera->getLocation(); double terrain_height = terrain->getInterpolatedHeight(camera_location.x, camera_location.z, true, true) + 2.0; diff --git a/src/definition/Scenery.h b/src/definition/Scenery.h index b252de5..85cfb4f 100644 --- a/src/definition/Scenery.h +++ b/src/definition/Scenery.h @@ -62,7 +62,7 @@ public: inline WaterDefinition* getWater() const {return water;} void getWater(WaterDefinition* water); - void checkCameraAboveGround(); + void keepCameraAboveGround(CameraDefinition* camera); private: AtmosphereDefinition* atmosphere; diff --git a/src/interface/modeler/quickapp/ModelerCameras.cpp b/src/interface/modeler/quickapp/ModelerCameras.cpp index 3b87f19..5340aaa 100644 --- a/src/interface/modeler/quickapp/ModelerCameras.cpp +++ b/src/interface/modeler/quickapp/ModelerCameras.cpp @@ -65,6 +65,8 @@ void ModelerCameras::timerEvent(QTimerEvent *) void ModelerCameras::validate() { + parent->getScenery()->keepCameraAboveGround(active); + if (active == render) { parent->getScenery()->setCamera(active); }