Skip to content

Commit

Permalink
add osgWidget::Viewer subclass to keep OSG from setting the CPU affinity
Browse files Browse the repository at this point in the history
  • Loading branch information
WSoptics authored and Pseudomanifold committed Sep 30, 2016
1 parent ba613bb commit 759d4f5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
17 changes: 16 additions & 1 deletion OSGWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ QRect makeRectangle( const QPoint& first, const QPoint& second )

}

namespace osgWidget {
void Viewer::setUpThreading()
{
if(_threadingModel == SingleThreaded) {
if(_threadsRunning) {
stopThreading();
}
} else {
if(!_threadsRunning) {
startThreading();
}
}
}
}

OSGWidget::OSGWidget( QWidget* parent,
Qt::WindowFlags f )
: QOpenGLWidget( parent,
Expand All @@ -75,7 +90,7 @@ OSGWidget::OSGWidget( QWidget* parent,
this->y(),
this->width(),
this->height() ) )
, viewer_( new osgViewer::CompositeViewer )
, viewer_( new osgWidget::Viewer )
, selectionActive_( false )
, selectionFinished_( true )
{
Expand Down
15 changes: 14 additions & 1 deletion OSGWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@
#include <osgViewer/GraphicsWindow>
#include <osgViewer/CompositeViewer>

namespace osgWidget {
//! The subclass of osgViewer::CompositeViewer we use
/*!
* This subclassing allows us to remove the annoying automatic
* setting of the CPU affinity to core 0 by osgViewer::ViewerBase,
* osgViewer::CompositeViewer's base class.
*/
class Viewer : public osgViewer::CompositeViewer
{
public:
virtual void setUpThreading();
};
}
class OSGWidget : public QOpenGLWidget
{
Q_OBJECT
Expand Down Expand Up @@ -43,7 +56,7 @@ class OSGWidget : public QOpenGLWidget
osgGA::EventQueue* getEventQueue() const;

osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> graphicsWindow_;
osg::ref_ptr<osgViewer::CompositeViewer> viewer_;
osg::ref_ptr<osgWidget::Viewer> viewer_;

QPoint selectionStart_;
QPoint selectionEnd_;
Expand Down

0 comments on commit 759d4f5

Please sign in to comment.