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 

osgUtil::IntersectionVisitor slow with huge geometry


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
gambr
Appreciator


Joined: 22 Jun 2010
Posts: 355

PostPosted: Tue Jul 18, 2017 10:17 am    Post subject:
osgUtil::IntersectionVisitor slow with huge geometry
Reply with quote

Hi All,
I built a test geometry with about 9M triangles and 27M vertices. The intent of my spike solution (attached) is to select a triangle with mouse to change its color. I realized that the bottleneck of that code is the line where the camera accepts the "osgUtil::IntersectionVisitor" (line 51: camera->accept(iv)). That call takes most of the computation time.
Debugging the OSG code I fall into:

void LineSegmentIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable, const osg::Vec3d& s, const osg::Vec3d& e)

In that code there are different methods to be used: KdTree, USE_DOUBLE_CALCULATIONS or USE_FLOAT_CALCULATIONS.
On the basis of your experience, is one of the previous method ideal to solve my performance issue or something else must be done?

Best regards,
Gianni
Back to top
View user's profile Send private message
Jordi Torres
Guest





PostPosted: Tue Jul 18, 2017 10:44 am    Post subject:
osgUtil::IntersectionVisitor slow with huge geometry
Reply with quote

HI Gianni, 

For faster intersections it is far better to build the kdtree first. Also splitting your huge geometry in several could help to traverse the graph in case you don't want to use kdtrees. 


Cheers. 


2017-07-18 12:17 GMT+02:00 Gianni Ambrosio <g.ambrosio+ ([email]g.ambrosio+[/email])>:
Quote:
Hi All,
I built a test geometry with about 9M triangles and 27M vertices. The intent of my spike solution (attached) is to select a triangle with mouse to change its color. I realized that the bottleneck of that code is the line where the camera accepts the "osgUtil::IntersectionVisitor" (line 51: camera->accept(iv)). That call takes most of the computation time.
Debugging the OSG code I fall into:

void LineSegmentIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable, const osg::Vec3d& s, const osg::Vec3d& e)

In that code there are different methods to be used: KdTree, USE_DOUBLE_CALCULATIONS or USE_FLOAT_CALCULATIONS.
On the basis of your experience, is one of the previous method ideal to solve my performance issue or something else must be done?

Best regards,
Gianni

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




_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





--
Jordi Torres

------------------
Post generated by Mail2Forum
Back to top
gambr
Appreciator


Joined: 22 Jun 2010
Posts: 355

PostPosted: Tue Jul 18, 2017 1:58 pm    Post subject:
Reply with quote

Thanks Jordi for the fast reply.
I will try with Kdtrees. In fact USE_FLOAT_CALCULATIONS does not help much.

I have one more issue.
As you can see in my previously attached example, after mouse picking, I basically set:

geometry->dirtyDisplayList();
geometry->getColorArray()->dirty();

Those methods are pretty fast but in fact I have a delay of about one second on my PC (some seconds on other PCs) before seeing the picked triangle with a different color. Is there an obvious reason for that delay?


Regards,
Gianni
Back to top
View user's profile Send private message
gambr
Appreciator


Joined: 22 Jun 2010
Posts: 355

PostPosted: Tue Jul 18, 2017 2:50 pm    Post subject:
Reply with quote

Just an update.
OSG KdTree works great!

Computational time for "camera->accept(intersectionVisitor)":
before it was about 10M microseconds
with KdTree it is about 25 microseconds!

This is the code I modified in my example:
Code:

osg::Node* createScene() {
   osg::Geode* geode = new osg::Geode;
   osg::KdTree* kdtree = new osg::KdTree;
   osg::Geometry* geometry = buildGeometry();
   osg::KdTree::BuildOptions buildOptions;
   kdtree->build(buildOptions, geometry);
   geometry->setShape(kdtree);
   geode->addDrawable(geometry);
   return geode;
}


Gianni
Back to top
View user's profile Send private message
gambr
Appreciator


Joined: 22 Jun 2010
Posts: 355

PostPosted: Tue Jul 18, 2017 4:39 pm    Post subject:
Reply with quote

Debugging the OSG code it seems most of time spent before seeing the picked triangle with adifferent color is inside "ViewerBase::renderingTraversals()", and exactly in the following line:

if (_endDynamicDrawBlock.valid())
{
_endDynamicDrawBlock->block(); // <-- HERE!
}

Any idea?

Regards,
Gianni
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
Page 1 of 1

 
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 ViewerBase::frame() method slow after... gambr General 8 Fri Jul 21, 2017 9:11 am View latest post
No new posts draw primitive sets and geometry shad... wernerM General 0 Wed May 24, 2017 3:20 pm View latest post
No new posts Using Geometry with packed vertex arrays ravidavi General 2 Sat Mar 25, 2017 4:39 am View latest post
No new posts Slow down with shared nodes Andre Normann General 18 Tue Mar 07, 2017 8:24 am View latest post
No new posts Jittering/Flickering geometry problem umesh General 3 Tue Feb 14, 2017 10:53 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