gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.51k stars 779 forks source link

GeodeticGraticule is conflicted with osgParticle::PrecipitationEffect #1131

Closed airscrat closed 6 years ago

airscrat commented 6 years ago

When adding snow effect in Sample osgearth_graticule, the example exe will crash.

    // set a near/far ratio that is smaller than the default. This allows us to get
    // closer to the ground without near clipping. If you need more, use --logdepth
    viewer.getCamera()->setNearFarRatio(0.0001);

    osgParticle::PrecipitationEffect* precipitationEffect =
        new osgParticle::PrecipitationEffect;
    precipitationEffect->snow(0.5);
    root->addChild(precipitationEffect);

    // finalize setup and run.
    viewer.setSceneData( root );

then type> osgearth_graticuled.exe simple.earth --geodetic. It will crash. But this example works well without root->addChild(precipitationEffect);

my enviroment is: window 10 x64. visual studio 2017. osg 3.6.1. osgearth master.

gwaldron commented 6 years ago

Were you ever able to get a debug stack trace for this?

airscrat commented 6 years ago

Hi Glenn, Here is the debug stack trace. Thanks for your attention!

ucrtbased.dll!00007ffb6ff897dc()    Unknown
ucrtbased.dll!00007ffb6ff89727()    Unknown
osg157-osgd.dll!std::vector<osg::Group *,std::allocator<osg::Group *> >::operator[](const unsigned __int64 _Pos) Line 1742  C++
osg157-osgd.dll!osg::Node::getParent(unsigned int i) Line 186   C++
osgEarthd.dll!`anonymous namespace'::SortFrontToBackPreservingGeodeTraversalOrder::operator()(const osgUtil::RenderLeaf * lhs, const osgUtil::RenderLeaf * rhs) Line 56 C++
osgEarthd.dll!std::_Debug_lt_pred<`anonymous namespace'::SortFrontToBackPreservingGeodeTraversalOrder &,osgUtil::RenderLeaf * &,osgUtil::RenderLeaf * &>(`anonymous-namespace'::SortFrontToBackPreservingGeodeTraversalOrder & _Pred, osgUtil::RenderLeaf * & _Left, osgUtil::RenderLeaf * & _Right) Line 1110  C++
osgEarthd.dll!std::_Insertion_sort_unchecked<osgUtil::RenderLeaf * *,`anonymous namespace'::SortFrontToBackPreservingGeodeTraversalOrder>(osgUtil::RenderLeaf * * _First, osgUtil::RenderLeaf * * const _Last, `anonymous-namespace'::SortFrontToBackPreservingGeodeTraversalOrder _Pred) Line 3832 C++
osgEarthd.dll!std::_Sort_unchecked<osgUtil::RenderLeaf * *,`anonymous namespace'::SortFrontToBackPreservingGeodeTraversalOrder>(osgUtil::RenderLeaf * * _First, osgUtil::RenderLeaf * * _Last, __int64 _Ideal, `anonymous-namespace'::SortFrontToBackPreservingGeodeTraversalOrder _Pred) Line 4025 C++
osgEarthd.dll!std::sort<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<osgUtil::RenderLeaf *> > >,`anonymous namespace'::SortFrontToBackPreservingGeodeTraversalOrder>(const std::_Vector_iterator<std::_Vector_val<std::_Simple_types<osgUtil::RenderLeaf *> > > _First, const std::_Vector_iterator<std::_Vector_val<std::_Simple_types<osgUtil::RenderLeaf *> > > _Last, `anonymous-namespace'::SortFrontToBackPreservingGeodeTraversalOrder _Pred) Line 4034 C++
osgEarthd.dll!DeclutterSort::sortImplementation(osgUtil::RenderBin * bin) Line 276  C++
osg157-osgUtild.dll!osgUtil::RenderBin::sort() Line 222 C++
osg157-osgUtild.dll!osgUtil::RenderBin::sort() Line 217 C++
osg157-osgUtild.dll!osgUtil::RenderStage::sort() Line 169   C++
osg157-osgUtild.dll!osgUtil::SceneView::cullStage(const osg::Matrixd & projection, const osg::Matrixd & modelview, osgUtil::CullVisitor * cullVisitor, osgUtil::StateGraph * rendergraph, osgUtil::RenderStage * renderStage, osg::Viewport * viewport) Line 917    C++
osg157-osgUtild.dll!osgUtil::SceneView::cull() Line 762 C++
osg157-osgViewerd.dll!osgViewer::Renderer::cull() Line 662  C++
osg157-osgViewerd.dll!osgViewer::ViewerBase::renderingTraversals() Line 883 C++
osg157-osgViewerd.dll!osgViewer::ViewerBase::frame(double simulationTime) Line 751  C++
osg157-osgViewerd.dll!osgViewer::ViewerBase::run() Line 721 C++
osg157-osgViewerd.dll!osgViewer::Viewer::run() Line 444 C++
osgearth_graticuled.exe!main(int argc, char * * argv) Line 142  C++
osgearth_graticuled.exe!invoke_main() Line 79   C++
osgearth_graticuled.exe!__scrt_common_main_seh() Line 288   C++
osgearth_graticuled.exe!__scrt_common_main() Line 331   C++
osgearth_graticuled.exe!mainCRTStartup() Line 17    C++
kernel32.dll!00007ffba7a43034() Unknown
ntdll.dll!00007ffba8821461()    Unknown
airscrat commented 6 years ago

Tested with latest osgearth master and osg 3.6.3.

ucrtbased.dll!00007ffb68a297dc()    Unknown
ucrtbased.dll!00007ffb68a29727()    Unknown
osg158-osgd.dll!std::vector<osg::Group *,std::allocator<osg::Group *> >::operator[](const unsigned __int64 _Pos) Line 1742  C++
osg158-osgd.dll!osg::Node::getParent(unsigned int i) Line 186   C++
osgEarthd.dll!`anonymous namespace'::SortFrontToBackPreservingGeodeTraversalOrder::operator()(const osgUtil::RenderLeaf * lhs, const osgUtil::RenderLeaf * rhs) Line 56 C++
osgEarthd.dll!std::_Debug_lt_pred<`anonymous namespace'::SortFrontToBackPreservingGeodeTraversalOrder &,osgUtil::RenderLeaf * &,osgUtil::RenderLeaf * &>(`anonymous-namespace'::SortFrontToBackPreservingGeodeTraversalOrder & _Pred, osgUtil::RenderLeaf * & _Left, osgUtil::RenderLeaf * & _Right) Line 1110  C++
osgEarthd.dll!std::_Insertion_sort_unchecked<osgUtil::RenderLeaf * *,`anonymous namespace'::SortFrontToBackPreservingGeodeTraversalOrder>(osgUtil::RenderLeaf * * _First, osgUtil::RenderLeaf * * const _Last, `anonymous-namespace'::SortFrontToBackPreservingGeodeTraversalOrder _Pred) Line 3832 C++
osgEarthd.dll!std::_Sort_unchecked<osgUtil::RenderLeaf * *,`anonymous namespace'::SortFrontToBackPreservingGeodeTraversalOrder>(osgUtil::RenderLeaf * * _First, osgUtil::RenderLeaf * * _Last, __int64 _Ideal, `anonymous-namespace'::SortFrontToBackPreservingGeodeTraversalOrder _Pred) Line 4025 C++
osgEarthd.dll!std::sort<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<osgUtil::RenderLeaf *> > >,`anonymous namespace'::SortFrontToBackPreservingGeodeTraversalOrder>(const std::_Vector_iterator<std::_Vector_val<std::_Simple_types<osgUtil::RenderLeaf *> > > _First, const std::_Vector_iterator<std::_Vector_val<std::_Simple_types<osgUtil::RenderLeaf *> > > _Last, `anonymous-namespace'::SortFrontToBackPreservingGeodeTraversalOrder _Pred) Line 4034 C++
osgEarthd.dll!DeclutterSort::sortImplementation(osgUtil::RenderBin * bin) Line 276  C++
osg158-osgUtild.dll!osgUtil::RenderBin::sort() Line 222 C++
osg158-osgUtild.dll!osgUtil::RenderBin::sort() Line 217 C++
osg158-osgUtild.dll!osgUtil::RenderStage::sort() Line 169   C++
osg158-osgUtild.dll!osgUtil::SceneView::cullStage(const osg::Matrixd & projection, const osg::Matrixd & modelview, osgUtil::CullVisitor * cullVisitor, osgUtil::StateGraph * rendergraph, osgUtil::RenderStage * renderStage, osg::Viewport * viewport) Line 917    C++
osg158-osgUtild.dll!osgUtil::SceneView::cull() Line 762 C++
osg158-osgViewerd.dll!osgViewer::Renderer::cull() Line 662  C++
osg158-osgViewerd.dll!osgViewer::ViewerBase::renderingTraversals() Line 881 C++
osg158-osgViewerd.dll!osgViewer::ViewerBase::frame(double simulationTime) Line 749  C++
osg158-osgViewerd.dll!osgViewer::ViewerBase::run() Line 719 C++
osg158-osgViewerd.dll!osgViewer::Viewer::run() Line 444 C++
osgearth_geodetic_graticuled.exe!main(int argc, char * * argv) Line 153 C++
osgearth_geodetic_graticuled.exe!invoke_main() Line 79  C++
osgearth_geodetic_graticuled.exe!__scrt_common_main_seh() Line 288  C++
osgearth_geodetic_graticuled.exe!__scrt_common_main() Line 331  C++
osgearth_geodetic_graticuled.exe!mainCRTStartup() Line 17   C++
kernel32.dll!00007ffba7a43034() Unknown
ntdll.dll!00007ffba8821461()    Unknown
gwaldron commented 6 years ago

Thanks. That is helpful. I've pushed a patch that prevents the crash to the master branch.

The reason that particles were making their way into the osgEarth decluttering bin in the first place is due to how OSG's render bins work internally. Both the bin used to render the graticule labels and the bin that particles use have the same bin number, so OSG decided to re-use it for particles. This is just an unfortunate peculiarity of how render bins work internally in OSG -- at least it's a known issue.

To circumvent it you need to change one of those bin numbers. You can do that easily in osgEarth with this in your earth file:

14

(or, pick another number that doesn't conflict with the bin numbers at PrecipitationEffect.cpp:420)

I have not actually tested this since I only have a GL CORE build, and particles do not work in GL CORE.

airscrat commented 6 years ago

Thanks to your patch,the application no longer crashes. And thank you for your explanation!