Added support for float or double osg::Plane, and the default osg::Plane to double.

Performance tests on big models did not indicate any performance penalty in using doubles over floats,
so the move to doubles should mainly impact precision improvements for whole earth databases.

Also made improvements to osgUtil::PlaneIntersector and osgSim::ElevationSlice classes
This commit is contained in:
Robert Osfield
2006-11-28 16:00:52 +00:00
parent 5e1c5cd556
commit 345810ef22
14 changed files with 262 additions and 135 deletions

View File

@@ -35,18 +35,54 @@ void ElevationSlice::computeIntersections(osg::Node* scene)
if (em)
{
osg::Vec3d upVector = em->computeLocalUpVector(_startPoint.x(), _startPoint.y(), _startPoint.z());
osg::Vec3d start_upVector = em->computeLocalUpVector(_startPoint.x(), _startPoint.y(), _startPoint.z());
osg::Vec3d end_upVector = em->computeLocalUpVector(_endPoint.x(), _endPoint.y(), _endPoint.z());
double latitude, longitude, height;
em->convertXYZToLatLongHeight(_startPoint.x(), _startPoint.y(), _startPoint.z(), latitude, longitude, height);
double start_latitude, start_longitude, start_height;
em->convertXYZToLatLongHeight(_startPoint.x(), _startPoint.y(), _startPoint.z(),
start_latitude, start_longitude, start_height);
osg::notify(osg::NOTICE)<<"lat = "<<latitude<<" longitude = "<<longitude<<" height = "<<height<<std::endl;
osg::notify(osg::NOTICE)<<"start_lat = "<<start_latitude<<" start_longitude = "<<start_longitude<<" start_height = "<<start_height<<std::endl;
double end_latitude, end_longitude, end_height;
em->convertXYZToLatLongHeight(_endPoint.x(), _endPoint.y(), _endPoint.z(),
end_latitude, end_longitude, end_height);
osg::notify(osg::NOTICE)<<"end_lat = "<<end_latitude<<" end_longitude = "<<end_longitude<<" end_height = "<<end_height<<std::endl;
// set up the main intersection plane
osg::Vec3d planeNormal = (_endPoint - _startPoint) ^ start_upVector;
planeNormal.normalize();
plane.set( planeNormal, _startPoint );
// set up the start cut off plane
osg::Vec3d startPlaneNormal = start_upVector ^ planeNormal;
startPlaneNormal.normalize();
boundingPolytope.add( osg::Plane(startPlaneNormal, _startPoint) );
// set up the end cut off plane
osg::Vec3d endPlaneNormal = planeNormal ^ end_upVector;
endPlaneNormal.normalize();
boundingPolytope.add( osg::Plane(endPlaneNormal, _endPoint) );
}
else
{
osg::Vec3d upVector (0.0, 0.0, 1.0);
// set up the main intersection plane
osg::Vec3d planeNormal = (_endPoint - _startPoint) ^ upVector;
planeNormal.normalize();
plane.set( planeNormal, _startPoint );
// set up the start cut off plane
osg::Vec3d startPlaneNormal = upVector ^ planeNormal;
startPlaneNormal.normalize();
boundingPolytope.add( osg::Plane(startPlaneNormal, _startPoint) );
// set up the end cut off plane
osg::Vec3d endPlaneNormal = planeNormal ^ upVector;
endPlaneNormal.normalize();
boundingPolytope.add( osg::Plane(endPlaneNormal, _endPoint) );
}
osg::ref_ptr<osgUtil::PlaneIntersector> intersector = new osgUtil::PlaneIntersector(plane, boundingPolytope);