From: mfranz Date: Wed, 12 Apr 2006 22:21:02 +0000 (+0000) Subject: defer occluder registration until the shadows subsytem is initialized. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9512ba5ff7ffc960a0ea6d5a203061aa96357a02;p=flightgear.git defer occluder registration until the shadows subsytem is initialized. That way models that are loaded early during startup get their shadows, too. --- diff --git a/src/Model/modelmgr.cxx b/src/Model/modelmgr.cxx index 4359a70b5..7be7e4e47 100644 --- a/src/Model/modelmgr.cxx +++ b/src/Model/modelmgr.cxx @@ -32,7 +32,6 @@ extern SGShadowVolume *shadows; FGModelMgr::FGModelMgr () : _models(fgGetNode("/models", true)), _listener(new Listener(this)) - { _models->addChangeListener(_listener); } @@ -81,8 +80,6 @@ FGModelMgr::add_model (SGPropertyNode * node) globals->get_sim_time_sec(), /*cache_object=*/false); model->init( object ); - if (shadows) - shadows->addOccluder((ssgBranch *)object, SGShadowVolume::occluderTypeTileObject); // Set position and orientation either // indirectly through property refs @@ -168,6 +165,12 @@ FGModelMgr::update (double dt) model->setHeadingDeg(instance->heading_deg_node->getDoubleValue()); instance->model->update(); + + if (shadows && !instance->shadow) { + ssgBranch *branch = (ssgBranch *)instance->model->getSceneGraph(); + shadows->addOccluder(branch, SGShadowVolume::occluderTypeTileObject); + instance->shadow = true; + } } } @@ -211,7 +214,8 @@ FGModelMgr::Instance::Instance () elev_ft_node(0), roll_deg_node(0), pitch_deg_node(0), - heading_deg_node(0) + heading_deg_node(0), + shadow(false) { } @@ -259,7 +263,7 @@ FGModelMgr::Listener::childRemoved(SGPropertyNode * parent, SGPropertyNode * chi _mgr->_instances.erase(it); ssgBranch *branch = (ssgBranch *)instance->model->getSceneGraph(); - if (shadows) + if (shadows && instance->shadow) shadows->deleteOccluder(branch); globals->get_scenery()->get_scene_graph()->removeKid(branch); diff --git a/src/Model/modelmgr.hxx b/src/Model/modelmgr.hxx index b1956e3f6..a2d267645 100644 --- a/src/Model/modelmgr.hxx +++ b/src/Model/modelmgr.hxx @@ -54,6 +54,7 @@ public: SGPropertyNode_ptr roll_deg_node; SGPropertyNode_ptr pitch_deg_node; SGPropertyNode_ptr heading_deg_node; + bool shadow; }; FGModelMgr ();