[osg-users] KdTree support now checked in

rpingry at gmail.com rpingry at gmail.com
Sat Jul 12 13:11:42 PDT 2008

Hi J-S, et. al.

When you mention caching the intersect visitors, when should you use reset()
and when are setStart()/setEnd() used?

In my game, I keep simplified, bounding box representations of the ships in
the scene and then do line segment intersections.  When I do the
calculations, I start at the smaller ships, which have several "intersection
points".  For each point, I create a line segment for the global position of
where the point was last frame and where it is this frame.  I then bounce
that against each ship in the scene that is larger.  I also translate the
"last position" for the intersection point based on how the bigger ship has
moved.  I do all of this to make sure I catch ships flying right through
each other, because they are going fast.  This has all worked out really
well, but I am of course looking for any speed improvements I can get.

So my first question is about how I should try to cache the intersect
visitors?  Should I keep one around for each large ship (node passed in to
the getIntersections() function), or should I just make a single one that is
used over and over?

Next, how often should I call reset()?  Once for each big ship, or once for
each intersection check?  I do not see any setStart()/setEnd() functions.
Please forgive my ognorance, but where are they and what do they do?

Finally, I am doing a few checks before I try the line segments to see if
they are even close to the node I am checking.  Is this worth the check or
does the intersectVisitor do that all for me anyway?

-- Rick

On Fri, Jul 11, 2008 at 8:09 PM, Jean-Sébastien Guay <
jean-sebastien.guay at cm-labs.com> wrote:

> Hi Robert,
> To wrap, all these changes on now in SVN trunk and will be part of
>> 2.5.4 and hence the up coming 2.6.  If you enable the build of
>> automatic KdTrees of load and use
>> IntersectionVisitor/LineSegmentIntersector then you'll be able to go
>> straight ahead of use KdTree intersections without lifting a further
>> finger ;-)
> This is all very cool! I'll definitely be testing this out in the next few
> days to try it out with my Masters project (which was very
> intersection-heavy). I'll be setting up a little competition between your
> KdTree and Adrian Egli's... Just kidding!
> I think I may be able to help a bit regarding the higher-level setup and
> bookkeeping changes needed to speed things up on that regard. One thing I
> noticed before is that creating a new Intersector and IntersectionVisitor
> each time is costly, and instead keeping static or cached instances and
> using the reset() and setStart()/setEnd() methods is faster. There may be
> some other similar things that can be done too, we'll see what I can dig up.
> Thanks a lot for this work, it's a great addition, and I expect that it
> will be useful in lots of different applications.
> J-S
> --
> ______________________________________________________
> Jean-Sebastien Guay    jean-sebastien.guay at cm-labs.com
>                               http://www.cm-labs.com/
>                        http://whitestar02.webhop.org/
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

>> Rick
Check us out at http://fringe-online.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080712/fa0fa7b3/attachment-0003.htm>

More information about the osg-users mailing list