[osg-users] [Crash issue] How to add&remove drawable (geometry) property.

Jinh Tang peter.wang1013 at gmail.com
Thu Jul 26 06:55:40 PDT 2018


Hi Robert,
    thanks a lot!  I tried single thread, but it can meet project requirement, as we may have 500+ meshes need to update. each mesh has 12000+ points. the main GUI thread will be blocked for 10+ seconds....
   besides, I already set the viewer to use SingleThreaded. paste my code of initialization below:

 graphics_window_ = (new osgViewer::GraphicsWindowEmbedded(x, y, width, height) );
    viewer_ = new osgViewer::Viewer;
    scale_ = QApplication::desktop()->devicePixelRatio();
    root_ = new osg::Group;

    mouse_trans_ = new osg::PositionAttitudeTransform;
    root_->addChild(mouse_trans_);

    // init camera
    camera_ = new osg::Camera();
    //camera_ = viewer_->getCamera();
    camera_->setClearMask(GL_DEPTH_BUFFER_BIT);
    camera_->setClearMask(GL_COLOR_BUFFER_BIT);
    camera_->setViewport(x, y, width, height);
    camera_->setClearColor( osg::Vec4( 0.91f, 0.91f, 0.91f, 1.f ) );
    float aspectRatio = static_cast<float>(width) / static_cast<float>(height);
    camera_->setProjectionMatrixAsOrtho(-DEFAULT_ORTHO_RANGE * aspectRatio, DEFAULT_ORTHO_RANGE * aspectRatio, -DEFAULT_ORTHO_RANGE, DEFAULT_ORTHO_RANGE, -500.0, 500.0);
    camera_->setGraphicsContext( graphics_window_ );

    viewer_->setCamera(camera_);

    camera_->addChild(root_);
    viewer_->setSceneData(root_);

    camera_manipulator_ = new MeshCameraManipulator(camera_, osg::Vec3(0, 0, 100), osg::Vec3(0, 0, 0), osg::Vec3(0, 1, 0), mouse_trans_);
    camera_manipulator_->Setup(this);
    camera_manipulator_->SetWindowSize(width, height);
    viewer_->setCameraManipulator(camera_manipulator_);
    viewer_->setThreadingModel(osgViewer::Viewer::SingleThreaded);

    viewer_->realize();

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74394#74394







More information about the osg-users mailing list