From 69871b15ff32cce5facedb9f54ef466942efc451 Mon Sep 17 00:00:00 2001 From: fredb Date: Fri, 19 Dec 2008 07:39:09 +0000 Subject: [PATCH] Stuart Buchanan : Attached is yet another 3D clouds patch, to fix the following: 1) The 3D clouds were not modified by the cloud coverage, due to some problems with osg::Switch 2) METAR changes to cloud coverage were not obeyed. 3) Making changes via the Cloud dialog had no effect unless 3D clouds were toggled. 4) Cloud cover was too sparse. 5) 3D Stratus clouds caused performance issues on some hardware (fixed by removing 3D stratus from cloudlayers.xml - it will now be a 2D layer). --- simgear/scene/sky/cloudfield.cxx | 9 +++------ simgear/scene/sky/cloudfield.hxx | 8 ++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/simgear/scene/sky/cloudfield.cxx b/simgear/scene/sky/cloudfield.cxx index 313e255a..a567c91e 100644 --- a/simgear/scene/sky/cloudfield.cxx +++ b/simgear/scene/sky/cloudfield.cxx @@ -68,7 +68,6 @@ using namespace simgear; #endif float SGCloudField::fieldSize = 50000.0f; -float SGCloudField::coverage = 1.0f; double SGCloudField::timer_dt = 0.0; float SGCloudField::view_distance = 20000.0f; sgVec3 SGCloudField::view_vec, SGCloudField::view_X, SGCloudField::view_Y; @@ -151,6 +150,7 @@ SGCloudField::SGCloudField() : deltay(0.0), last_course(0.0), last_coverage(0.0), + coverage(0.0), defined3D(false), reposition_count(0) { @@ -211,10 +211,7 @@ void SGCloudField::clear(void) { for (int x = 0; x < QUADTREE_SIZE; x++) { for (int y = 0; y < QUADTREE_SIZE; y++) { int num_children = field_group[x][y]->getNumChildren(); - - for (int i = 0; i < num_children; i++) { - field_group[x][y]->removeChild(i); - } + field_group[x][y]->removeChildren(0, num_children); } } @@ -239,7 +236,7 @@ static int densTable[][10] = { void SGCloudField::applyCoverage(void) { int row = (int) (coverage * 10.0); - if (row > 10) row = 9; + if (row > 9) row = 9; int col = 0; if (coverage != last_coverage) { diff --git a/simgear/scene/sky/cloudfield.hxx b/simgear/scene/sky/cloudfield.hxx index f844a98d..beab904d 100644 --- a/simgear/scene/sky/cloudfield.hxx +++ b/simgear/scene/sky/cloudfield.hxx @@ -83,7 +83,8 @@ private: double deltax, deltay, alt; double last_course; sgSphere field_sphere; - float last_coverage; + float last_coverage; + float coverage; SGGeoc cld_pos; int reposition_count; struct CloudFog : public simgear::Singleton @@ -121,15 +122,14 @@ public: static sgVec3 view_vec, view_X, view_Y; - static float coverage; static float view_distance; static double timer_dt; static float fieldSize; bool defined3D; - static float getCoverage(void) { return coverage; } - static void setCoverage(float coverage) { coverage = coverage; } + float getCoverage(void) { return coverage; } + void setCoverage(float c) { coverage = c; } static float getVisRange(void) { return view_distance; } static void setVisRange(float d) { view_distance = d; } -- 2.39.5