Hi All,

Today I added support into osg::BoundingSphere and osg::BoundingBox to use
double or float versions of internal variables.  The support can be toggled
from CMake via the advanced options:

   OSG_USE_FLOAT_BOUNDINGSPHERE
   OSG_USE_FLOAT_BOUNDINGBOX

These options are ON by default right now, so the original settings remain
the same, so you have to explicitly choose the double versions.

As part of this work I realised that applications that link to the
OpenSceneGraph need to know which options are enabled during the build of
the OSG so they can declare the appropriate defines to select the same types
as the OSG libraries were built with.  As more users will use defaults this
won't be much of an issue, but if you select a different setting then it
becomes an issue.

To help solve this problem for appplications we can use a CMake's ability to
execute programs and check the results:

# Automatically detected build options
EXEC_PROGRAM(osgversion ARGS Matrix::value_type OUTPUT_VARIABLE
OSG_USE_FLOAT_MATRIX)
IF(OSG_USE_FLOAT_MATRIX MATCHES "float")
    ADD_DEFINITIONS(-DOSG_USE_FLOAT_MATRIX)
ENDIF(OSG_USE_FLOAT_MATRIX MATCHES "float")

EXEC_PROGRAM(osgversion ARGS Plane::value_type OUTPUT_VARIABLE
OSG_USE_FLOAT_PLANE)
IF(OSG_USE_FLOAT_PLANE MATCHES "float")
    ADD_DEFINITIONS(-DOSG_USE_FLOAT_PLANE)
ENDIF(OSG_USE_FLOAT_PLANE MATCHES "float")

EXEC_PROGRAM(osgversion ARGS BoundingSphere::value_type  OUTPUT_VARIABLE
OSG_USE_FLOAT_BOUNDINGSPHERE)
IF(OSG_USE_FLOAT_BOUNDINGSPHERE MATCHES "double")
    ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGSPHERE)
ENDIF(OSG_USE_FLOAT_BOUNDINGSPHERE MATCHES "double")

EXEC_PROGRAM(osgversion ARGS BoundingBox::value_type OUTPUT_VARIABLE
OSG_USE_FLOAT_BOUNDINGBOX)
IF(OSG_USE_FLOAT_BOUNDINGBOX MATCHES "double")
    ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGBOX)
ENDIF(OSG_USE_FLOAT_BOUNDINGBOX MATCHES "double")

You'll now find such an entry added VirtualPlanetBuilder/CMakeLists.txt and
Present3D/CMakeLists.txt files.

To facilitate the above I've added command line support of
Matrix::value_type, Plane::value_type, BoundingSphere::value_type and
BoundingBox::value_type that trigger osgversion to provide details on what
types the OSG was built with, i.e.

osgversion BoundingSphere::value_type
float

Hope this helps folks,
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to