OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

RayIntersector with KdTree causes a crash

Goto page 1, 2  Next
 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Ale
User


Joined: 26 Nov 2012
Posts: 56

PostPosted: Thu Jul 26, 2018 9:33 am    Post subject:
RayIntersector with KdTree causes a crash
Reply with quote

Hi,

we have a problem with OSG 3.6.2 and Visual Studio 2017

We have a pick functionality in our software that uses RayIntersector.
We enabled KdTrees for this use.

When we apply the intersector to an object with a negative scale in the MatrixTransform parent node (e.g. scale = (-1, 1, 1)), it crashes inside the KdTree code.

If we disable kdtree everything works fine.
It also works with Visual Studio 2013 and OSG 3.4.0.

Here is the call stack when crashed:

Quote:

> osg157-osgUtild.dll!std::vector<unsigned int,std::allocator<unsigned int> >::operator[](const unsigned __int64 _Pos) Line 1818 C++
osg157-osgUtild.dll!osg::KdTree::intersect<osg::TemplatePrimitiveFunctor<LineSegmentIntersectorUtils::IntersectFunctor<osg::Vec3d,double> > >(osg::TemplatePrimitiveFunctor<LineSegmentIntersectorUtils::IntersectFunctor<osg::Vec3d,double> > & functor, const osg::KdTree::KdNode & node) Line 160 C++
osg157-osgUtild.dll!osg::KdTree::intersect<osg::TemplatePrimitiveFunctor<LineSegmentIntersectorUtils::IntersectFunctor<osg::Vec3d,double> > >(osg::TemplatePrimitiveFunctor<LineSegmentIntersectorUtils::IntersectFunctor<osg::Vec3d,double> > & functor, const osg::KdTree::KdNode & node) Line 176 C++
osg157-osgUtild.dll!osg::KdTree::intersect<osg::TemplatePrimitiveFunctor<LineSegmentIntersectorUtils::IntersectFunctor<osg::Vec3d,double> > >(osg::TemplatePrimitiveFunctor<LineSegmentIntersectorUtils::IntersectFunctor<osg::Vec3d,double> > & functor, const osg::KdTree::KdNode & node) Line 176 C++
osg157-osgUtild.dll!osgUtil::LineSegmentIntersector::intersect(osgUtil::IntersectionVisitor & iv, osg::Drawable * drawable, const osg::Vec3d & s, const osg::Vec3d & e) Line 540 C++
osg157-osgUtild.dll!osgUtil::RayIntersector::intersect(osgUtil::IntersectionVisitor & iv, osg::Drawable * drawable) Line 122 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::intersect(osg::Drawable * drawable) Line 282 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Geode & geode) Line 240 C++
osg157-osgd.dll!osg::Geode::accept(osg::NodeVisitor & nv) Line 37 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgFXd.dll!osgFX::Effect::inherited_traverse(osg::NodeVisitor & nv) Line 213 C++
osg157-osgFXd.dll!osgFX::Effect::traverse(osg::NodeVisitor & nv) Line 51 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Group & group) Line 221 C++
osg157-osgFXd.dll!osgFX::Outline::accept(osg::NodeVisitor & nv) Line 54 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Transform & transform) Line 417 C++
osg157-osgd.dll!osg::NodeVisitor::apply(osg::MatrixTransform & node) Line 158 C++
osg157-osgd.dll!osg::MatrixTransform::accept(osg::NodeVisitor & nv) Line 37 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Group & group) Line 221 C++
osg157-osgd.dll!osg::Group::accept(osg::NodeVisitor & nv) Line 38 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Transform & transform) Line 417 C++
osg157-osgd.dll!osg::NodeVisitor::apply(osg::MatrixTransform & node) Line 158 C++
osg157-osgd.dll!osg::MatrixTransform::accept(osg::NodeVisitor & nv) Line 37 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Group & group) Line 221 C++
osg157-osgd.dll!osg::Group::accept(osg::NodeVisitor & nv) Line 38 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgShadowd.dll!osgShadow::ShadowedScene::traverse(osg::NodeVisitor & nv) Line 69 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Group & group) Line 221 C++
osg157-osgShadowd.dll!osgShadow::ShadowedScene::accept(osg::NodeVisitor & nv) Line 36 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Group & group) Line 221 C++
osg157-osgd.dll!osg::NodeVisitor::apply(osg::ClipNode & node) Line 128 C++
osg157-osgd.dll!osg::ClipNode::accept(osg::NodeVisitor & nv) Line 35 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Group & group) Line 221 C++
osg157-osgd.dll!osg::Group::accept(osg::NodeVisitor & nv) Line 38 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Camera & camera) Line 498 C++
osg157-osgd.dll!osg::Camera::accept(osg::NodeVisitor & nv) Line 54 C++




Thank you in advance.


Berst regards

Ale
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12149

PostPosted: Thu Jul 26, 2018 10:42 am    Post subject:
RayIntersector with KdTree causes a crash
Reply with quote

Hi Ale,

The KdTree was refactored in 3.6.x to add support for points and lines
and PolytopeIntersector. While there has been lots of internal
changes in it, it of course shouldn't crash.

At this point in time I don't have any idea where the issue stems
from. Could you create a small example that reproduces the crash, I
or others can then step through what is happening and work out a fix.

Given this regression it looks like we'll have to make a 3.6.3 sooner
rather than later, but not before we fix the crash...

Cheers,
Robert.
On Thu, 26 Jul 2018 at 10:39, Ale Maro <> wrote:
Quote:

Hi,

we have a problem with OSG 3.6.2 and Visual Studio 2017

We have a pick functionality in our software that uses RayIntersector.
We enabled KdTrees for this use.

When we apply the intersector to an object with a negative scale in the MatrixTransform parent node (e.g. scale = (-1, 1, 1)), it crashes inside the KdTree code.

If we disable kdtree everything works fine.
It also works with Visual Studio 2013 and OSG 3.4.0.

Here is the call stack when crashed:


Quote:

Quote:
osg157-osgUtild.dll!std::vector<unsigned int,std::allocator<unsigned int> >::operator[](const unsigned __int64 _Pos) Line 1818 C++
osg157-osgUtild.dll!osg::KdTree::intersect<osg::TemplatePrimitiveFunctor<LineSegmentIntersectorUtils::IntersectFunctor<osg::Vec3d,double> > >(osg::TemplatePrimitiveFunctor<LineSegmentIntersectorUtils::IntersectFunctor<osg::Vec3d,double> > & functor, const osg::KdTree::KdNode & node) Line 160 C++
osg157-osgUtild.dll!osg::KdTree::intersect<osg::TemplatePrimitiveFunctor<LineSegmentIntersectorUtils::IntersectFunctor<osg::Vec3d,double> > >(osg::TemplatePrimitiveFunctor<LineSegmentIntersectorUtils::IntersectFunctor<osg::Vec3d,double> > & functor, const osg::KdTree::KdNode & node) Line 176 C++
osg157-osgUtild.dll!osg::KdTree::intersect<osg::TemplatePrimitiveFunctor<LineSegmentIntersectorUtils::IntersectFunctor<osg::Vec3d,double> > >(osg::TemplatePrimitiveFunctor<LineSegmentIntersectorUtils::IntersectFunctor<osg::Vec3d,double> > & functor, const osg::KdTree::KdNode & node) Line 176 C++
osg157-osgUtild.dll!osgUtil::LineSegmentIntersector::intersect(osgUtil::IntersectionVisitor & iv, osg::Drawable * drawable, const osg::Vec3d & s, const osg::Vec3d & e) Line 540 C++
osg157-osgUtild.dll!osgUtil::RayIntersector::intersect(osgUtil::IntersectionVisitor & iv, osg::Drawable * drawable) Line 122 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::intersect(osg::Drawable * drawable) Line 282 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Geode & geode) Line 240 C++
osg157-osgd.dll!osg::Geode::accept(osg::NodeVisitor & nv) Line 37 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgFXd.dll!osgFX::Effect::inherited_traverse(osg::NodeVisitor & nv) Line 213 C++
osg157-osgFXd.dll!osgFX::Effect::traverse(osg::NodeVisitor & nv) Line 51 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Group & group) Line 221 C++
osg157-osgFXd.dll!osgFX::Outline::accept(osg::NodeVisitor & nv) Line 54 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Transform & transform) Line 417 C++
osg157-osgd.dll!osg::NodeVisitor::apply(osg::MatrixTransform & node) Line 158 C++
osg157-osgd.dll!osg::MatrixTransform::accept(osg::NodeVisitor & nv) Line 37 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Group & group) Line 221 C++
osg157-osgd.dll!osg::Group::accept(osg::NodeVisitor & nv) Line 38 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Transform & transform) Line 417 C++
osg157-osgd.dll!osg::NodeVisitor::apply(osg::MatrixTransform & node) Line 158 C++
osg157-osgd.dll!osg::MatrixTransform::accept(osg::NodeVisitor & nv) Line 37 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Group & group) Line 221 C++
osg157-osgd.dll!osg::Group::accept(osg::NodeVisitor & nv) Line 38 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgShadowd.dll!osgShadow::ShadowedScene::traverse(osg::NodeVisitor & nv) Line 69 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Group & group) Line 221 C++
osg157-osgShadowd.dll!osgShadow::ShadowedScene::accept(osg::NodeVisitor & nv) Line 36 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Group & group) Line 221 C++
osg157-osgd.dll!osg::NodeVisitor::apply(osg::ClipNode & node) Line 128 C++
osg157-osgd.dll!osg::ClipNode::accept(osg::NodeVisitor & nv) Line 35 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Group & group) Line 221 C++
osg157-osgd.dll!osg::Group::accept(osg::NodeVisitor & nv) Line 38 C++
osg157-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63 C++
osg157-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 278 C++
osg157-osgUtild.dll!osgUtil::IntersectionVisitor::apply(osg::Camera & camera) Line 498 C++
osg157-osgd.dll!osg::Camera::accept(osg::NodeVisitor & nv) Line 54 C++





Thank you in advance.


Berst regards

Ale

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








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Ale
User


Joined: 26 Nov 2012
Posts: 56

PostPosted: Fri Jul 27, 2018 8:06 am    Post subject:
Reply with quote

Hi Robert,

my colleague reproduced the crash by modifying the osgPick example.
He created a sphere with a negative scaling transformation, build the kdtree and attached to the osgPick scene.
It crashes at the first intersection calculation.
If you do not build the kdtree or if the scaling transformation is positive it does not crash.

Attached is the modified osgPick.cpp

Thank you.

Best regards
Ale
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12149

PostPosted: Fri Jul 27, 2018 10:29 am    Post subject:
RayIntersector with KdTree causes a crash
Reply with quote

Thanks for the test example. I don't have time right now to look into
it, but once I've achieved a couple of milestones on my Vulkan work
I'll return to clear up outstanding OSG bugs. Do I need any special
data to reproduce the crash?
On Fri, 27 Jul 2018 at 09:24, Ale Maro <> wrote:
Quote:

Hi Robert,

my colleague reproduced the crash by modifying the osgPick example.
He created a sphere with a negative scaling transformation, build the kdtree and attached to the osgPick scene.
It crashes at the first intersection calculation.
If you do not build the kdtree or if the scaling transformation is positive it does not crash.

Attached is the modified osgPick.cpp

Thank you.

Best regards
Ale

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




Attachments:
http://forum.openscenegraph.org//files/osgpick_163.cpp





------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Ale
User


Joined: 26 Nov 2012
Posts: 56

PostPosted: Fri Jul 27, 2018 12:04 pm    Post subject:
RayIntersector with KdTree causes a crash
Reply with quote

No special data needed.
The scene is built from code.

Cheers,
Ale
Back to top
View user's profile Send private message
Ale
User


Joined: 26 Nov 2012
Posts: 56

PostPosted: Wed Aug 29, 2018 8:17 am    Post subject:
Reply with quote

Hi Robert,

sorry for asking again. Did you have time to take a look to my example?

Thank you.

Ale
Back to top
View user's profile Send private message
Ale
User


Joined: 26 Nov 2012
Posts: 56

PostPosted: Wed Aug 29, 2018 8:18 am    Post subject:
Reply with quote

Hi Robert,

sorry for asking again. Did you have time to take a look to my example?

Thank you.

Ale
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12149

PostPosted: Wed Aug 29, 2018 8:21 am    Post subject:
RayIntersector with KdTree causes a crash
Reply with quote

On Wed, 29 Aug 2018 at 09:17, Ale Maro <> wrote:
Quote:
sorry for asking again. Did you have time to take a look to my example?

Not yet. Still busy wrapping up the last week of the Exploration Phase
of the VSG project. Next week I'll spend time on the OSG side and
will have a look.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12149

PostPosted: Mon Sep 03, 2018 10:06 am    Post subject:
RayIntersector with KdTree causes a crash
Reply with quote

Hi Ale,

I have now built and run your test and it works fine for me.

I have run with the --relative-camera-scene command line option and I
don't see any cube or sphere, but I do see reports of hits.

This is testing with the 3.6 branch under Kubuntu 18.04.

At this point I don't have anything to go any further. Ideally I need
a test case that I can reproduce a problem, and if this isn't straight
forward then I need stack traces of what is happening on your system.

Cheers,
Robert,


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Ale
User


Joined: 26 Nov 2012
Posts: 56

PostPosted: Mon Sep 03, 2018 1:41 pm    Post subject:
Reply with quote

Hi Robert,

thanks for the update.

Have you built in release?
We are seeing now that the release version has the behaviour you described (that is also strange becouse I expect to see something… if you do not build the KdTree in the code you can see the sphere).

The debug version crashes (the assert Windows says there is a call to front() of an empty vector).

It is correct you run with the --relative-camera-scene command line option.

If needed I can send you the Windows binaries of the example.


Cheers,
Ale
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12149

PostPosted: Mon Sep 03, 2018 3:37 pm    Post subject:
RayIntersector with KdTree causes a crash
Reply with quote

Hi Ale,

I built with release.

I will try with a debug build. A change in behaviour between release
a debug would suggest an unintialized variable.

Could you provide the stack trace.

A binary for Windows isn't required at this point.

Cheers,
Robert.
On Mon, 3 Sep 2018 at 15:00, Ale Maro <> wrote:
Quote:

Hi Robert,

thanks for the update.

Have you built in release?
We are seeing now that the release version has the behaviour you described (that is also strange becouse I expect to see something… if you do not build the KdTree in the code you can see the sphere).

The debug version crashes (the assert Windows says there is a call to front() of an empty vector).

It is correct you run with the --relative-camera-scene command line option.

If needed I can send you the Windows binaries of the example.


Cheers,
Ale

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








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Ale
User


Joined: 26 Nov 2012
Posts: 56

PostPosted: Tue Sep 04, 2018 7:06 am    Post subject:
Reply with quote

Hi Robert,


I attached the stack trace for the modified osgPick example.

We analyzed the LineSegmentIntersector::intersect code (see below) and we saw that if we build KDTree AND the transofmation matrix has negative scale then "geometry->getVertexArray()" returns an empty array and "settings._vertices" becomes empty.
In debug an assert stops the execution (see stack trace), in release the execution continue but the geometry is not shown

Code:

void LineSegmentIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable,
                                       const osg::Vec3d& s, const osg::Vec3d& e)
{
    if (reachedLimit()) return;

    LineSegmentIntersectorUtils::Settings settings;
    settings._lineSegIntersector = this;
    settings._iv = &iv;
    settings._drawable = drawable;
    settings._limitOneIntersection = (_intersectionLimit == LIMIT_ONE_PER_DRAWABLE || _intersectionLimit == LIMIT_ONE);

    osg::Geometry* geometry = drawable->asGeometry();
    if (geometry)
    {
        settings._vertices = dynamic_cast<osg::Vec3Array*>(geometry->getVertexArray());
    }




Cheers,
Ale
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12149

PostPosted: Tue Sep 04, 2018 2:40 pm    Post subject:
RayIntersector with KdTree causes a crash
Reply with quote

Hi Ale,

I have invested the issue further, focusing on why the sphere appears
fine when the KdTree isn't build, but disappears when it is. I
tracked this issue down to the ShapeDrawable::setShape() being invoked
by the KdTreeBuilder that creates a KdTree for a ShapeDrawable then
assigns this KdTree to the ShapeDrawable via the Drawable::setShape()
method which in turn invokes the ShapeDrawable::build() method that
attempts to build a geometry from the KdTree. It's a bit of circular
reference - KdTree wasn't ever meant to work with ShapeDrawable, it's
only now working because of the change of ShapeDrawable from
subclassing from Drawable to subclassing from Geometry.

To prevent the unintended rebuild I have disable the
ShapeDrawable::build() from doing anything when the shape assigned is
a KdTree.

https://github.com/openscenegraph/OpenSceneGraph/commit/5f9c6a01704e26e6760cc023e09ab1dcf0da1a15

There is still a bit of mismatch in that KdTree is a special case of a
Shape, but still a valid use. Shape's were always intended to be used
for intersection testing and physics, but never originally intended to
support a ShapeDrawable. The ShapeDrawable was a quick and easy thing
to add to help visualize primitive shapes but in hindsight I should
never have implemented it as it's misused too much by the community as
a serious means for drawing objects. It's not possible to remove
ShapeDrawable without breaking lots of user applications so it's still
part of the OSG. Please consider it just there for backwards
compatibility.

The above change is now checked into master and the OpenSceneGraph-3.6
branch. so it will be part of the 3.6.3 release I'll make this month.

Testing of these changes would be appreciated.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Ale
User


Joined: 26 Nov 2012
Posts: 56

PostPosted: Wed Sep 05, 2018 1:51 pm    Post subject:
Reply with quote

Hi Robert,

thanks for the update.
The issue with ShapeDrawable take us to the wrong way.

So at the end we find the cause of the problem is different.
I will describe it again:

1 - Take a geode (e.g. we loaded "cow.osg") and build a kdtree
2 - Make a clone with DEEP_COPY_ALL
3 - Applying LineSegmentIntersection to the clone we get the crash

If we clone with SHALLOW_COPY it works fine

Attached is the modified osgPick example that reproduces the crash.
You just need to set the correct path to the file to be loaded and specify the --relative-camera-scene option as before

Here is an extract of the code. If you use a SHALLOW_COPY instead of DEEP_COPY_ALL it does not crash.

[code]
osg::MatrixTransform* xform = new osg::MatrixTransform();
osg::MatrixTransform* xform2 = new osg::MatrixTransform(osg::Matrix::translate(10.0,0.0,0.));

osg::ref_ptr<osg::KdTreeBuilder> kdtreeBuilder = NULL;
kdtreeBuilder = osgDB::Registry::instance()->getKdTreeBuilder()->clone();

xform->addChild(cow);
// xform->accept(*kdtreeBuilder);

osg::Object * cow2 = cow->clone(osg::CopyOp::DEEP_COPY_ALL);

xform2->addChild(cow2->asNode());

group->addChild(xform);
group->addChild(xform2);
[\code]




Cheers,
Ale
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12149

PostPosted: Wed Sep 05, 2018 5:09 pm    Post subject:
RayIntersector with KdTree causes a crash
Reply with quote

Hi Ale,

Thanks for the updating test program, this illustrates a separate bug
in the KdTree copy constructor. I have added missing copying of the
indices:

~/OpenSceneGraph/src/osg$ git diff
diff --git a/src/osg/KdTree.cpp b/src/osg/KdTree.cpp
index 709c12f99..3f7a4a34a 100644
--- a/src/osg/KdTree.cpp
+++ b/src/osg/KdTree.cpp
@@ -492,6 +492,8 @@ KdTree::KdTree(const KdTree& rhs, const
osg::CopyOp& copyop):
Shape(rhs, copyop),
_degenerateCount(rhs._degenerateCount),
_vertices(rhs._vertices),
+ _primitiveIndices(rhs._primitiveIndices),
+ _vertexIndices(rhs._vertexIndices),
_kdNodes(rhs._kdNodes)
{
}

Could you test out the commit?

https://github.com/openscenegraph/OpenSceneGraph/commit/34d58d447d7f0b35d7bb20572a2f5d4fd26b7961

Cheers.
Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts osgText 3.6.3 crash Trajce Nikolov NICK General 2 Wed Sep 12, 2018 12:25 pm View latest post
No new posts Crash when using LineSegmentIntersector sbrkopac General 5 Thu Aug 02, 2018 10:03 pm View latest post
No new posts [Crash issue] no error info even set ... pwang General 1 Sun Jul 29, 2018 1:20 pm View latest post
No new posts [Crash issue] How to add&remove d... pwang General 2 Thu Jul 26, 2018 10:10 am View latest post
No new posts RayIntersector with KdTree causes a c... Ale General 0 Thu Jul 26, 2018 9:30 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP