1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

LP-32 introduce incremental compile (experimental)

This commit is contained in:
Philippe Renon 2016-06-27 22:08:04 +02:00
parent b2abe1c265
commit d3d6a561ad
5 changed files with 41 additions and 8 deletions

View File

@ -41,6 +41,7 @@
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/StateSetManipulator>
#include <osgGA/CameraManipulator>
#include <osgUtil/IncrementalCompileOperation>
#include <QOpenGLContext>
#include <QQuickWindow>
@ -98,7 +99,7 @@
*/
namespace osgQtQuick {
// enum DirtyFlag { Scene = 1 << 0, Camera = 1 << 1 };
// enum DirtyFlag { Scene = 1 << 0, Camera = 1 << 1, Manipulator = 1 << 2, UpdateMode = 1 << 3, IncrementalCompile = 1 << 4 };
class ViewportRenderer;
@ -106,6 +107,7 @@ class MyViewer : public osgViewer::CompositeViewer {
public:
MyViewer() : osgViewer::CompositeViewer()
{}
virtual bool checkNeedToDoFrame()
{
if (_requestRedraw) {
@ -120,9 +122,13 @@ public:
if (view) {
// If the database pager is going to update the scene the render flag is
// set so that the updates show up
if (view->getDatabasePager()->requiresUpdateSceneGraph()) {
if (view->getDatabasePager()->getDataToCompileListSize() > 0) {
return true;
}
if (view->getDatabasePager()->getDataToMergeListSize() > 0) {
return true;
}
// if (view->getDatabasePager()->requiresUpdateSceneGraph()) return true;
// if (view->getDatabasePager()->getRequestsInProgress()) return true;
// if there update callbacks then we need to do frame.
@ -181,6 +187,8 @@ public:
UpdateMode::Enum updateMode;
bool incrementalCompile;
bool busy;
static osg::ref_ptr<osg::GraphicsContext> dummyGC;
@ -188,7 +196,8 @@ public:
static QtKeyboardMap keyMap;
Hidden(OSGViewport *self) : QObject(self), self(self), window(NULL), frameTimer(-1), frameCount(0),
sceneNode(NULL), cameraNode(NULL), manipulator(NULL), updateMode(UpdateMode::OnDemand), busy(false)
sceneNode(NULL), cameraNode(NULL), manipulator(NULL),
updateMode(UpdateMode::OnDemand), incrementalCompile(false), busy(false)
{
OsgEarth::initialize();
@ -411,6 +420,7 @@ private:
viewer = new MyViewer();
// viewer = new osgViewer::CompositeViewer();
viewer->setThreadingModel(osgViewer::ViewerBase::SingleThreaded);
// disable the default setting of viewer.done() by pressing Escape.
@ -782,7 +792,6 @@ OSGCameraManipulator *OSGViewport::manipulator() const
void OSGViewport::setManipulator(OSGCameraManipulator *manipulator)
{
if (h->acceptManipulator(manipulator)) {
// setDirty(Manipulator);
emit manipulatorChanged(manipulator);
}
}
@ -800,6 +809,22 @@ void OSGViewport::setUpdateMode(UpdateMode::Enum mode)
}
}
bool OSGViewport::incrementalCompile() const
{
return h->incrementalCompile;
}
void OSGViewport::setIncrementalCompile(bool incrementalCompile)
{
if (h->incrementalCompile != incrementalCompile) {
h->incrementalCompile = incrementalCompile;
// setDirty(IncrementalCompile);
// TODO not thread safe...
h->viewer->setIncrementalCompileOperation(incrementalCompile ? new osgUtil::IncrementalCompileOperation() : NULL);
emit incrementalCompileChanged(incrementalCompile);
}
}
bool OSGViewport::busy() const
{
return h->busy;

View File

@ -55,6 +55,7 @@ class OSGQTQUICK_EXPORT OSGViewport : public QQuickFramebufferObject {
Q_PROPERTY(osgQtQuick::OSGCamera * camera READ cameraNode WRITE setCameraNode NOTIFY cameraNodeChanged)
Q_PROPERTY(osgQtQuick::OSGCameraManipulator * manipulator READ manipulator WRITE setManipulator NOTIFY manipulatorChanged)
Q_PROPERTY(osgQtQuick::UpdateMode::Enum updateMode READ updateMode WRITE setUpdateMode NOTIFY updateModeChanged)
Q_PROPERTY(bool incrementalCompile READ incrementalCompile WRITE setIncrementalCompile NOTIFY incrementalCompileChanged)
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
typedef QQuickFramebufferObject Inherited;
@ -77,6 +78,9 @@ public:
UpdateMode::Enum updateMode() const;
void setUpdateMode(UpdateMode::Enum mode);
bool incrementalCompile() const;
void setIncrementalCompile(bool busy);
bool busy() const;
void setBusy(bool busy);
@ -85,10 +89,11 @@ public:
Renderer *createRenderer() const;
signals:
void sceneNodeChanged(OSGNode *node);
void cameraNodeChanged(OSGCamera *node);
void manipulatorChanged(OSGCameraManipulator *manipulator);
void updateModeChanged(UpdateMode::Enum mode);
void sceneNodeChanged(OSGNode *);
void cameraNodeChanged(OSGCamera *);
void manipulatorChanged(OSGCameraManipulator *);
void updateModeChanged(UpdateMode::Enum);
void incrementalCompileChanged(bool);
void busyChanged(bool busy);
protected:

View File

@ -35,6 +35,7 @@ Item {
sceneNode: skyNode
camera: camera
manipulator: earthManipulator
incrementalCompile: true
OSGCamera {
id: camera

View File

@ -36,6 +36,7 @@ Item {
sceneNode: skyNode
camera: camera
manipulator: nodeTrackerManipulator
//incrementalCompile: true
OSGCamera {
id: camera

View File

@ -43,6 +43,7 @@ OSGViewport {
sceneNode: skyNode
camera: camera
manipulator: geoTransformManipulator
//incrementalCompile: true
OSGCamera {
id: camera