[osg-users] Intersectors with double precision

23 views
Skip to first unread message

Leandro Motta Barros

unread,
Nov 25, 2011, 6:47:17 AM11/25/11
to OpenSceneGraph Users
Hello,

In a project I am working on, I need to use intersectors
(PolytopeIntersectors, in particular) with double precision floating
point, but with the intersectors provided by OSG (using 3.0.1 here), I
get only single precision.

I noticed that osgUtil::PolytopeIntersector already contains code
intended to make it use osg::Vec3f or osg::Vec3d depending whether
OSG_USE_FLOAT_PLANE is defined or not -- but there are one or two
places in which a osg::Vec3 is used -- which ends up as floats.

osgUtil::LineSegmentIntersector, on the other hand, uses osg::Vec3
(i.e., floats) everywhere.

So, I am ready to change the few bits of osgUtil::PolytopeIntersector
still using hardcoded osg::Vec3 and to modify
osgUtil::LineSegmentIntersector so that it uses a similar approach
(that is, use osg::Vec3f and float if OSG_USE_FLOAT_PLANE is defined,
otherwise use osg::Vec3d and double) and send this to osg-submissions.
(I did some successful experiments with a fully-double
osgUtil::PolytopeIntersector already.)

Would this be OK? Am am missing something? Would some different
approach be preferable? Do you have any other feedback?

Cheers,

LMB
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Peter Hrenka

unread,
Nov 25, 2011, 7:52:05 AM11/25/11
to OpenSceneGraph Users
Hi Leandro,

Am 25.11.2011 12:47, schrieb Leandro Motta Barros:
> Hello,
>
> In a project I am working on, I need to use intersectors
> (PolytopeIntersectors, in particular) with double precision floating
> point, but with the intersectors provided by OSG (using 3.0.1 here), I
> get only single precision.
>
> I noticed that osgUtil::PolytopeIntersector already contains code
> intended to make it use osg::Vec3f or osg::Vec3d depending whether
> OSG_USE_FLOAT_PLANE is defined or not -- but there are one or two
> places in which a osg::Vec3 is used -- which ends up as floats.

The code that does is wrong is probably from me.

> osgUtil::LineSegmentIntersector, on the other hand, uses osg::Vec3
> (i.e., floats) everywhere.
>
> So, I am ready to change the few bits of osgUtil::PolytopeIntersector
> still using hardcoded osg::Vec3 and to modify
> osgUtil::LineSegmentIntersector so that it uses a similar approach
> (that is, use osg::Vec3f and float if OSG_USE_FLOAT_PLANE is defined,
> otherwise use osg::Vec3d and double) and send this to osg-submissions.
> (I did some successful experiments with a fully-double
> osgUtil::PolytopeIntersector already.)

Fixing the missing bits in PolytopeIntersector should be
done in any case.

The LineSegmentIntersector is a bit more complicated
as it uses the KdTree-class is float-only for now
and which also would have to me adjusted (it does
not look to complicated to do that through a typedef
and/or templates).

But for LineSegementIntersector I would not make it all depend on
OSG_USE_FLOAT_PLANE. That makes sense for PolytopeIntesector as it
practically only uses plane calculations. I would suggest
something like OSG_USE_FLOAT_LINE_INTERSECTIONS (default ON).

> Would this be OK? Am am missing something? Would some different
> approach be preferable? Do you have any other feedback?

I like your idea and I think it would be an improvement.

In the long run - as an application developer - I would
like the have the ability to have both options in
the same build. Usually I have raw data in double format
and build a float-scenegraph. But for some algorithms
I would like to use the original double data.


> Cheers,
>
> LMB

Cheers, looking forward to see your submmission

Peter
--
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier,
Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Philippe Miltin
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196

Leandro Motta Barros

unread,
Nov 25, 2011, 8:08:38 AM11/25/11
to OpenSceneGraph Users
Hi Peter,

On Fri, Nov 25, 2011 at 10:52 AM, Peter Hrenka
<p.hr...@science-computing.de> wrote:
> [...]


>> So, I am ready to change the few bits of osgUtil::PolytopeIntersector
>> still using hardcoded osg::Vec3 and to modify
>> osgUtil::LineSegmentIntersector so that it uses a similar approach
>> (that is, use osg::Vec3f and float if OSG_USE_FLOAT_PLANE is defined,
>> otherwise use osg::Vec3d and double) and send this to osg-submissions.
>> (I did some successful experiments with a fully-double
>> osgUtil::PolytopeIntersector already.)
>
> Fixing the missing bits in PolytopeIntersector should be
> done in any case.
>

> The LineSegmentIntersector is a bit more complicated [...]

Ha, I was learning this the hard way while you were writing your email :-)

> But for LineSegementIntersector I would not make it all depend on
> OSG_USE_FLOAT_PLANE. That makes sense for PolytopeIntesector as it
> practically only uses plane calculations. I would suggest
> something like OSG_USE_FLOAT_LINE_INTERSECTIONS (default ON).

Right, this makes sense!

Well, I'll focus on the submission for PolytopeIntersector, which is
really simple and solves the problem I have at hand. I'll try to take
a closer look at the LineSegmentIntersector case if I found the time
for that.

Thanks for the comments!

LMB

Reply all
Reply to author
Forward
0 new messages