Reapply canvas placements upon aircraft-model reinit
This commit is contained in:
parent
1dd3b40907
commit
7ce1e100d7
3 changed files with 24 additions and 1 deletions
|
@ -25,15 +25,22 @@
|
|||
|
||||
#include <simgear/canvas/Canvas.hxx>
|
||||
|
||||
using simgear::canvas::Canvas;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
CanvasMgr::CanvasMgr():
|
||||
simgear::canvas::CanvasMgr
|
||||
(
|
||||
fgGetNode("/canvas/by-index", true),
|
||||
simgear::canvas::SystemAdapterPtr( new canvas::FGCanvasSystemAdapter )
|
||||
),
|
||||
_cb_model_reinit
|
||||
(
|
||||
this,
|
||||
&CanvasMgr::handleModelReinit,
|
||||
fgGetNode("/sim/signals/model-reinit", true)
|
||||
)
|
||||
{
|
||||
using simgear::canvas::Canvas;
|
||||
Canvas::addPlacementFactory
|
||||
(
|
||||
"object",
|
||||
|
@ -75,3 +82,11 @@ CanvasMgr::getCanvasTexId(const simgear::canvas::CanvasPtr& canvas) const
|
|||
|
||||
return tobj->_id;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void CanvasMgr::handleModelReinit(SGPropertyNode*)
|
||||
{
|
||||
for(size_t i = 0; i < _elements.size(); ++i)
|
||||
boost::static_pointer_cast<Canvas>(_elements[i])
|
||||
->reloadPlacements("object");
|
||||
}
|
||||
|
|
|
@ -38,6 +38,12 @@ class CanvasMgr:
|
|||
* @return OpenGL texture name
|
||||
*/
|
||||
unsigned int getCanvasTexId(const simgear::canvas::CanvasPtr& canvas) const;
|
||||
|
||||
protected:
|
||||
|
||||
SGPropertyChangeCallback<CanvasMgr> _cb_model_reinit;
|
||||
|
||||
void handleModelReinit(SGPropertyNode*);
|
||||
};
|
||||
|
||||
#endif /* CANVAS_MGR_H_ */
|
||||
|
|
|
@ -102,6 +102,8 @@ FGAircraftModel::reinit()
|
|||
deinit();
|
||||
_fx->reinit();
|
||||
init();
|
||||
// TODO globally create signals for all subsystems (re)initialized
|
||||
fgSetBool("/sim/signals/model-reinit", true);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue