Fixed quick ui camera to stay above ground and water

This commit is contained in:
Michaël Lemaire 2015-07-22 18:39:46 +02:00
parent 2c877953e7
commit 2de920e091
3 changed files with 6 additions and 4 deletions

View file

@ -43,7 +43,7 @@ void Scenery::validate()
{ {
BaseDefinition::validate(); BaseDefinition::validate();
checkCameraAboveGround(); keepCameraAboveGround(camera);
} }
Scenery::FileOperationResult Scenery::saveGlobal(const std::string &filepath) const Scenery::FileOperationResult Scenery::saveGlobal(const std::string &filepath) const
@ -131,7 +131,7 @@ void Scenery::getAtmosphere(AtmosphereDefinition* atmosphere)
void Scenery::setCamera(CameraDefinition* camera) void Scenery::setCamera(CameraDefinition* camera)
{ {
camera->copy(this->camera); camera->copy(this->camera);
checkCameraAboveGround(); keepCameraAboveGround(this->camera);
} }
void Scenery::getCamera(CameraDefinition* camera) void Scenery::getCamera(CameraDefinition* camera)
@ -179,7 +179,7 @@ void Scenery::getWater(WaterDefinition* water)
this->water->copy(water); this->water->copy(water);
} }
void Scenery::checkCameraAboveGround() void Scenery::keepCameraAboveGround(CameraDefinition* camera)
{ {
Vector3 camera_location = camera->getLocation(); Vector3 camera_location = camera->getLocation();
double terrain_height = terrain->getInterpolatedHeight(camera_location.x, camera_location.z, true, true) + 2.0; double terrain_height = terrain->getInterpolatedHeight(camera_location.x, camera_location.z, true, true) + 2.0;

View file

@ -62,7 +62,7 @@ public:
inline WaterDefinition* getWater() const {return water;} inline WaterDefinition* getWater() const {return water;}
void getWater(WaterDefinition* water); void getWater(WaterDefinition* water);
void checkCameraAboveGround(); void keepCameraAboveGround(CameraDefinition* camera);
private: private:
AtmosphereDefinition* atmosphere; AtmosphereDefinition* atmosphere;

View file

@ -65,6 +65,8 @@ void ModelerCameras::timerEvent(QTimerEvent *)
void ModelerCameras::validate() void ModelerCameras::validate()
{ {
parent->getScenery()->keepCameraAboveGround(active);
if (active == render) { if (active == render) {
parent->getScenery()->setCamera(active); parent->getScenery()->setCamera(active);
} }