Hi Oleg,

As long as you set you dynamic Drawable and StateSet's DataVariance
field to DYNAMIC the viewer update and rendering traversals will not
overlap.  There has been lots of discussion about this over the years
so please do some searches.

No if the problem is that you have the frame loop running in it own
thread AND you want to do updates you own thread then we'll it's your
problem to synchronize the threads.  Might I suggest you avoid these
complexity and just get your code to do updates during the viewers
update traversal, either via an update callback, an viewer update
Operation or by subclass your own Viewer and overriding the
updateTraversal() method to add you own custom code in.

Robert.

On Wed, Apr 14, 2010 at 7:27 PM, Oleg Shistik <[email protected]> wrote:
> Hi,
>
> I am a relative new OSG user and I am developing OSG ActiveX application.
> My C++ project is compiled in VS2008 with /CLR (I am using .NET platform for 
> the Web services communication).
> In my application the rendering (viewer->frame()) is running in a separate 
> thread which is started when the application in initialized. The 
> OpenLocalFile function (running in the main thread) is responsible for 
> loading scenes from the local disk.
>
> The following is the function source code:
> void CDl3dViewerCtrl::OpenLocalFile()
> {
>  // sigal the rendering thread to stop and wait for it
>  StopRenderingThread();
>  // clean the model (except of the service nodes)
>  int cnt = _root->getNumChildren();
>  _root->removeChildren(NUMBER_SERVICE_NODES, cnt - NUMBER_SERVICE_NODES);
>  // Load a new model
>  osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(_loadedFile);
>  if (node.valid())
>  {
>  node->setDataVariance(osg::Object::DYNAMIC);
>  _root->addChild(node.get());
>  _viewer->setSceneData(_root.get());
>  // Back to home position to see the whole scene
>  _viewer->getCameraManipulator()->computeHomePosition();
>  _viewer->getCameraManipulator()->home( 0.0 );
>  _viewer->realize();
>  }
>  else
>  {
>  ::MessageBox(0, A2BSTR("Fail to open file."), L"Error", MB_OK);
>  }
>  // run the rendering thread
>  StartRenderingThread();
> }
>
> My problem is that without StopRenderingThread() the code doesn't work. 
> Actually it works, but after number of sequential calls i am getting debug 
> assertion: Expression: ("this->_Has_container()", 0). That call stack 
> presented below.
> I suppose that is normal practice to make changes in the scene graph when the 
> rendering is running, but in my case it makes problems.
>
> I'd happy to get any suggestion/ideas regarding this problem.
> Thanks and Best Regards
>
> Oleg
>
> Some additional info:
>
> I took Wang Rui http://markmail.org/message/shdd6p5lqcqg62bf sample as a 
> start point for my application.
> The same problem is reproducible in the original (Wang Rui) ActiveX, that is 
> not /CLR.
> It also occurs when the ActiveX is running in my tester (ActiveX container), 
> so I think the Internet Explorer is not guilty here.
> It is happing at least on four computers (Vista/Windows 7).
>
> The call stack:
>> osg55-osgd.dll!std::_Vector_const_iterator<osg::ref_ptr<osg::Node>,std::allocator<osg::ref_ptr<osg::Node>
>>  > >::operator++()  Line 116 + 0x3a bytes C++
>  osg55-osgd.dll!std::_Vector_iterator<osg::ref_ptr<osg::Node>,std::allocator<osg::ref_ptr<osg::Node>
>  > >::operator++()  Line 350 C++
>  osg55-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv={...})  Line 60 + 
> 0x8 bytes C++
>  osg55-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node={...})  Line 191 
> + 0x1c bytes C++
>  osg55-osgUtild.dll!osgUtil::CullVisitor::handle_cull_callbacks_and_traverse(osg::Node
>  & node={...})  Line 300 + 0xf bytes C++
>  osg55-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Transform & node={...})  
> Line 1034 C++
>  osg55-osgd.dll!osg::NodeVisitor::apply(osg::MatrixTransform & node={...})  
> Line 136 + 0x13 bytes C++
>  osg55-osgd.dll!osg::MatrixTransform::accept(osg::NodeVisitor & nv={...})  
> Line 37 + 0x41 bytes C++
>  osg55-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv={...})  Line 62 + 
> 0x25 bytes C++
>  osg55-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node={...})  Line 191 
> + 0x1c bytes C++
>  osg55-osgUtild.dll!osgUtil::CullVisitor::handle_cull_callbacks_and_traverse(osg::Node
>  & node={...})  Line 300 + 0xf bytes C++
>  osg55-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Transform & node={...})  
> Line 1034 C++
>  osg55-osgd.dll!osg::NodeVisitor::apply(osg::MatrixTransform & node={...})  
> Line 136 + 0x13 bytes C++
>  osg55-osgd.dll!osg::MatrixTransform::accept(osg::NodeVisitor & nv={...})  
> Line 37 + 0x41 bytes C++
>  osg55-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv={...})  Line 62 + 
> 0x25 bytes C++
>  osg55-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node={...})  Line 191 
> + 0x1c bytes C++
>  osg55-osgUtild.dll!osgUtil::CullVisitor::handle_cull_callbacks_and_traverse(osg::Node
>  & node={...})  Line 300 + 0xf bytes C++
>  osg55-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Group & node={...})  
> Line 1011 C++
>  osg55-osgd.dll!osg::Group::accept(osg::NodeVisitor & nv={...})  Line 38 + 
> 0x41 bytes C++
>  osg55-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv={...})  Line 62 + 
> 0x25 bytes C++
>  osg55-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node={...})  Line 191 
> + 0x1c bytes C++
>  osg55-osgUtild.dll!osgUtil::CullVisitor::handle_cull_callbacks_and_traverse(osg::Node
>  & node={...})  Line 300 + 0xf bytes C++
>  osg55-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Group & node={...})  
> Line 1011 C++
>  osg55-osgd.dll!osg::Group::accept(osg::NodeVisitor & nv={...})  Line 38 + 
> 0x41 bytes C++
>  osg55-osgUtild.dll!osgUtil::SceneView::cullStage(const osg::Matrixd & 
> projection={...}, const osg::Matrixd & modelview={...}, osgUtil::CullVisitor 
> * cullVisitor=0x027cd700, osgUtil::StateGraph * rendergraph=0x027c9638, 
> osgUtil::RenderStage * renderStage=0x027cd358, osg::Viewport * 
> viewport=0x027c55b8)  Line 962 + 0x42 bytes C++
>  osg55-osgUtild.dll!osgUtil::SceneView::cull()  Line 828 + 0x57 bytes C++
>  osg55-osgViewerd.dll!osgViewer::Renderer::cull_draw()  Line 546 + 0xf bytes 
> C++
>  osg55-osgViewerd.dll!osgViewer::Renderer::operator()(osg::GraphicsContext * 
> context=0x027c3c10)  Line 689 + 0xf bytes C++
>  osg55-osgd.dll!osg::GraphicsContext::runOperations()  Line 688 + 0x33 bytes 
> C++
>  osg55-osgViewerd.dll!osgViewer::ViewerBase::renderingTraversals()  Line 772 
> + 0x15 bytes C++
>  osg55-osgViewerd.dll!osgViewer::ViewerBase::frame(double 
> simulationTime=1.7976931348623157e+308)  Line 609 + 0xf bytes C++
>  [External Code]
>  DL3DVI~1.OCX!RenderThread(void* ptr = 0x027C5970) Line 153 C++
>  [Frames below may be incorrect and/or missing, no symbols loaded for 
> mscorwks.dll]
>  [External Code]
>  msvcr90d.dll!_callthreadstart()  Line 293 + 0xf bytes C
>  msvcr90d.dll!_threadstart(void * ptd=0x027eb2d0)  Line 277 C
>  kernel32.dll!75833677()
>  ntdll.dll!77509d72()
>  ntdll.dll!77509d45()
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=26799#26799
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to