Shift of management of the precipitation OSG scene graph to the scenery manager.
The precipitation branch of the OSG scene graph is now centrally managed by the scenery manager rather the precipitation manager itself. The scene graph initialisation from the constructor has also been shifted into the new FGPrecipitationMgr::sceneGraphSetup() function.
This commit is contained in:
parent
b12a56b526
commit
977ec5063f
4 changed files with 31 additions and 31 deletions
|
@ -51,22 +51,10 @@
|
|||
*/
|
||||
FGPrecipitationMgr::FGPrecipitationMgr()
|
||||
{
|
||||
group = new osg::Group();
|
||||
transform = new osg::MatrixTransform();
|
||||
precipitation = new SGPrecipitation();
|
||||
|
||||
|
||||
// By default, no precipitation
|
||||
precipitation->setRainIntensity(0);
|
||||
precipitation->setSnowIntensity(0);
|
||||
|
||||
// set the clip distance from the config
|
||||
precipitation->setClipDistance(fgGetFloat("/environment/precipitation-control/clip-distance",5.0));
|
||||
transform->addChild(precipitation->build());
|
||||
group->addChild(transform.get());
|
||||
// Try to set up the scenegraph.
|
||||
setupSceneGraph();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief FGPrecipitaiton Manager destructor
|
||||
*/
|
||||
|
@ -87,9 +75,6 @@ void FGPrecipitationMgr::init()
|
|||
osg::Matrix position(makeZUpFrame(geod));
|
||||
// Move the precipitation object to player position
|
||||
transform->setMatrix(position);
|
||||
// Add to scene graph
|
||||
osg::Group* scenery = globals->get_scenery()->get_scene_graph();
|
||||
scenery->addChild(getObject());
|
||||
fgGetNode("environment/params/precipitation-level-ft", true);
|
||||
}
|
||||
|
||||
|
@ -106,21 +91,31 @@ void FGPrecipitationMgr::unbind ()
|
|||
_tiedProperties.Untie();
|
||||
}
|
||||
|
||||
// Set up the precipitation manager scenegraph.
|
||||
void FGPrecipitationMgr::setupSceneGraph(void)
|
||||
{
|
||||
FGScenery* scenery = globals->get_scenery();
|
||||
osg::Group* group = scenery->get_precipitation_branch();
|
||||
transform = new osg::MatrixTransform();
|
||||
precipitation = new SGPrecipitation();
|
||||
|
||||
|
||||
// By default, no precipitation
|
||||
precipitation->setRainIntensity(0);
|
||||
precipitation->setSnowIntensity(0);
|
||||
|
||||
// set the clip distance from the config
|
||||
precipitation->setClipDistance(fgGetFloat("/environment/precipitation-control/clip-distance",5.0));
|
||||
transform->addChild(precipitation->build());
|
||||
group->addChild(transform.get());
|
||||
}
|
||||
|
||||
|
||||
void FGPrecipitationMgr::setPrecipitationLevel(double a)
|
||||
{
|
||||
fgSetDouble("environment/params/precipitation-level-ft",a);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get OSG precipitation object
|
||||
*
|
||||
* @returns A pointer on the OSG object (osg::Group *)
|
||||
*/
|
||||
osg::Group * FGPrecipitationMgr::getObject(void)
|
||||
{
|
||||
return this->group.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculate the max alitutude with precipitation
|
||||
*
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
class FGPrecipitationMgr : public SGSubsystem
|
||||
{
|
||||
private:
|
||||
osg::ref_ptr<osg::Group> group;
|
||||
osg::ref_ptr<osg::MatrixTransform> transform;
|
||||
osg::ref_ptr<SGPrecipitation> precipitation;
|
||||
float getPrecipitationAtAltitudeMax(void);
|
||||
|
@ -52,10 +51,8 @@ public:
|
|||
virtual void init ();
|
||||
virtual void update (double dt);
|
||||
|
||||
void setupSceneGraph(void);
|
||||
void setPrecipitationLevel(double l);
|
||||
|
||||
osg::Group * getObject(void);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -340,6 +340,11 @@ void FGScenery::init() {
|
|||
scene_graph->addChild(particles_branch.get());
|
||||
simgear::GlobalParticleCallback::setSwitch(fgGetNode("/sim/rendering/particles", true));
|
||||
|
||||
// Set up the precipitation system.
|
||||
precipitation_branch = new osg::Group;
|
||||
precipitation_branch->setName("Precipitation");
|
||||
scene_graph->addChild(precipitation_branch.get());
|
||||
|
||||
_listener = new ScenerySwitchListener(this);
|
||||
|
||||
// Toggle the setup flag.
|
||||
|
@ -353,6 +358,7 @@ void FGScenery::shutdown()
|
|||
models_branch = NULL;
|
||||
aircraft_branch = NULL;
|
||||
particles_branch = NULL;
|
||||
precipitation_branch = NULL;
|
||||
|
||||
// Toggle the setup flag.
|
||||
_inited = false;
|
||||
|
|
|
@ -57,6 +57,7 @@ class FGScenery : public SGSubsystem
|
|||
osg::ref_ptr<osg::Group> aircraft_branch;
|
||||
osg::ref_ptr<osg::Group> interior_branch;
|
||||
osg::ref_ptr<osg::Group> particles_branch;
|
||||
osg::ref_ptr<osg::Group> precipitation_branch;
|
||||
|
||||
osg::ref_ptr<flightgear::SceneryPager> _pager;
|
||||
ScenerySwitchListener* _listener;
|
||||
|
@ -117,6 +118,7 @@ public:
|
|||
osg::Group *get_aircraft_branch () const { return aircraft_branch.get(); }
|
||||
osg::Group *get_interior_branch () const { return interior_branch.get(); }
|
||||
osg::Group *get_particles_branch () const { return particles_branch.get(); }
|
||||
osg::Group *get_precipitation_branch () const { return precipitation_branch.get(); }
|
||||
|
||||
/// Returns true if scenery is available for the given lat, lon position
|
||||
/// within a range of range_m.
|
||||
|
|
Loading…
Add table
Reference in a new issue