CameraGroup: Add compositor reload callbacks
Add a compositor reload callback object to CameraInfo, with callbacks for just prior and after the CameraInfo's compositor is reloaded by reloadCompositors(). This will allow VR cameras to be reconfigured after a reload.
This commit is contained in:
parent
9e430b3fc2
commit
e25a560591
2 changed files with 16 additions and 1 deletions
|
@ -982,6 +982,9 @@ void reloadCompositors(CameraGroup *cgroup)
|
||||||
SGReaderWriterOptions::fromPath(globals->get_fg_root());
|
SGReaderWriterOptions::fromPath(globals->get_fg_root());
|
||||||
options->setPropertyNode(globals->get_props());
|
options->setPropertyNode(globals->get_props());
|
||||||
|
|
||||||
|
if (info->reloadCompositorCallback.valid())
|
||||||
|
info->reloadCompositorCallback->preReloadCompositor(cgroup, info);
|
||||||
|
|
||||||
// Force deletion
|
// Force deletion
|
||||||
info->compositor.reset(nullptr);
|
info->compositor.reset(nullptr);
|
||||||
// Then replace it with a new instance
|
// Then replace it with a new instance
|
||||||
|
@ -993,6 +996,9 @@ void reloadCompositors(CameraGroup *cgroup)
|
||||||
viewport,
|
viewport,
|
||||||
compositor_path,
|
compositor_path,
|
||||||
options));
|
options));
|
||||||
|
|
||||||
|
if (info->reloadCompositorCallback.valid())
|
||||||
|
info->reloadCompositorCallback->postReloadCompositor(cgroup, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroup->_viewer->getViewerBase()->startThreading();
|
cgroup->_viewer->getViewerBase()->startThreading();
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace flightgear
|
||||||
|
|
||||||
class CameraGroupListener;
|
class CameraGroupListener;
|
||||||
class GraphicsWindow;
|
class GraphicsWindow;
|
||||||
|
class CameraGroup;
|
||||||
|
|
||||||
/** A wrapper around osg::Camera that contains some extra information.
|
/** A wrapper around osg::Camera that contains some extra information.
|
||||||
*/
|
*/
|
||||||
|
@ -76,7 +77,7 @@ struct CameraInfo : public osg::Referenced
|
||||||
flags(flags_),
|
flags(flags_),
|
||||||
physicalWidth(0), physicalHeight(0), bezelHeightTop(0),
|
physicalWidth(0), physicalHeight(0), bezelHeightTop(0),
|
||||||
bezelHeightBottom(0), bezelWidthLeft(0), bezelWidthRight(0),
|
bezelHeightBottom(0), bezelWidthLeft(0), bezelWidthRight(0),
|
||||||
relativeCameraParent(0) { }
|
relativeCameraParent(0), reloadCompositorCallback(nullptr) { }
|
||||||
/** The name as given in the config file.
|
/** The name as given in the config file.
|
||||||
*/
|
*/
|
||||||
std::string name;
|
std::string name;
|
||||||
|
@ -120,6 +121,14 @@ struct CameraInfo : public osg::Referenced
|
||||||
* Compositor path and should use the default one.
|
* Compositor path and should use the default one.
|
||||||
*/
|
*/
|
||||||
std::string compositor_path;
|
std::string compositor_path;
|
||||||
|
|
||||||
|
struct ReloadCompositorCallback : public virtual osg::Referenced
|
||||||
|
{
|
||||||
|
virtual void preReloadCompositor(CameraGroup *, CameraInfo *) = 0;
|
||||||
|
virtual void postReloadCompositor(CameraGroup *, CameraInfo *) = 0;
|
||||||
|
};
|
||||||
|
osg::ref_ptr<ReloadCompositorCallback> reloadCompositorCallback;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CameraGroup : public osg::Referenced
|
class CameraGroup : public osg::Referenced
|
||||||
|
|
Loading…
Add table
Reference in a new issue