diff --git a/simgear/scene/sky/cloudfield.cxx b/simgear/scene/sky/cloudfield.cxx index bb2bb527..313e255a 100644 --- a/simgear/scene/sky/cloudfield.cxx +++ b/simgear/scene/sky/cloudfield.cxx @@ -80,6 +80,10 @@ bool SGCloudField::reposition( const SGVec3f& p, const SGVec3f& up, double lon, { osg::Matrix T, LON, LAT; + // Always update the altitude transform, as this allows + // the clouds to rise and fall smoothly depending on environment updates. + altitude_transform->setPosition(osg::Vec3d(0.0, 0.0, (double) asl)); + // Calculating the reposition information is expensive. // Only perform the reposition every 60 frames. reposition_count = (reposition_count + 1) % 60; @@ -142,6 +146,7 @@ bool SGCloudField::reposition( const SGVec3f& p, const SGVec3f& up, double lon, SGCloudField::SGCloudField() : field_root(new osg::Group), field_transform(new osg::MatrixTransform), + altitude_transform(new osg::PositionAttitudeTransform), deltax(0.0), deltay(0.0), last_course(0.0), @@ -179,7 +184,9 @@ SGCloudField::SGCloudField() : quad[i][j]->addChild(field_group[x][y].get(), 0.0f, view_distance); } } - + + field_transform->addChild(altitude_transform.get()); + // We duplicate the defined field group in a 3x3 array. This way, // we can simply shift entire groups around. // TODO: "Bend" the edge groups so when shifted they line up. @@ -191,7 +198,7 @@ SGCloudField::SGCloudField() : transform->addChild(quad_root.get()); transform->setPosition(osg::Vec3(x*fieldSize, y * fieldSize, 0.0)); - field_transform->addChild(transform.get()); + altitude_transform->addChild(transform.get()); } } } diff --git a/simgear/scene/sky/cloudfield.hxx b/simgear/scene/sky/cloudfield.hxx index 75a94091..f844a98d 100644 --- a/simgear/scene/sky/cloudfield.hxx +++ b/simgear/scene/sky/cloudfield.hxx @@ -74,6 +74,7 @@ private: osg::ref_ptr field_root; osg::ref_ptr field_transform; + osg::ref_ptr altitude_transform; osg::ref_ptr field_group[QUADTREE_SIZE][QUADTREE_SIZE]; osg::ref_ptr quad[BRANCH_SIZE][BRANCH_SIZE]; diff --git a/simgear/scene/sky/newcloud.cxx b/simgear/scene/sky/newcloud.cxx index 165e1268..43ed8e69 100644 --- a/simgear/scene/sky/newcloud.cxx +++ b/simgear/scene/sky/newcloud.cxx @@ -192,7 +192,7 @@ SGNewCloud::SGNewCloud(string type, // Generate the shader etc, if we don't already have one. if (!program.valid()) { alphaFunc = new AlphaFunc; - alphaFunc->setFunction(AlphaFunc::GREATER,0.001f); + alphaFunc->setFunction(AlphaFunc::GREATER,0.05f); program = new Program; baseTextureSampler = new osg::Uniform("baseTexture", 0); Shader* vertex_shader = new Shader(Shader::VERTEX, vertexShaderSource);