Show
Ignore:
Timestamp:
11/28/06 17:00:52 (7 years ago)
Author:
robert
Message:

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

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgintersection/osgintersection.cpp

    r5675 r5763  
    1212#include <osgSim/LineOfSight> 
    1313#include <osgSim/HeightAboveTerrain> 
     14#include <osgSim/ElevationSlice> 
    1415 
    1516#include <iostream> 
     
    4344     
    4445    std::cout<<"Intersection "<<std::endl; 
    45  
    4646     
    4747    osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(scene.get()); 
     
    5656    if (useLineOfSight) 
    5757    { 
    58         osg::Timer_t startTick = osg::Timer::instance()->tick(); 
    5958     
    6059        osg::Vec3d start = bs.center() + osg::Vec3d(0.0,bs.radius(),0.0); 
    61         osg::Vec3d end = bs.center();// - osg::Vec3d(0.0, bs.radius(),0.0); 
     60        osg::Vec3d end = bs.center() - osg::Vec3d(0.0, bs.radius(),0.0); 
    6261        osg::Vec3d deltaRow( 0.0, 0.0, bs.radius()*0.01); 
    6362        osg::Vec3d deltaColumn( bs.radius()*0.01, 0.0, 0.0); 
     
    6766        osgSim::LineOfSight los; 
    6867         
     68#if 0 
    6969        osgSim::HeightAboveTerrain hat; 
    7070        hat.setDatabaseCacheReadCallback(los.getDatabaseCacheReadCallback()); 
     
    8282 
    8383 
    84         std::cout<<"Computing LineOfSight"<<std::endl; 
    85  
    86         los.computeIntersections(scene.get()); 
    87          
    88         osg::Timer_t endTick = osg::Timer::instance()->tick(); 
    89  
    90         std::cout<<"Completed in "<<osg::Timer::instance()->delta_s(startTick,endTick)<<std::endl; 
    91  
    92 #if 1 
    93         for(unsigned int i=0; i<los.getNumLOS(); i++) 
    94         { 
    95             const osgSim::LineOfSight::Intersections& intersections = los.getIntersections(i); 
    96             for(osgSim::LineOfSight::Intersections::const_iterator itr = intersections.begin(); 
    97                 itr != intersections.end(); 
    98                 ++itr) 
    99             { 
    100                  std::cout<<"  point "<<*itr<<std::endl; 
    101             } 
     84        { 
     85            std::cout<<"Computing LineOfSight"<<std::endl; 
     86 
     87            osg::Timer_t startTick = osg::Timer::instance()->tick(); 
     88 
     89            los.computeIntersections(scene.get()); 
     90 
     91            osg::Timer_t endTick = osg::Timer::instance()->tick(); 
     92 
     93            std::cout<<"Completed in "<<osg::Timer::instance()->delta_s(startTick,endTick)<<std::endl; 
     94 
     95            for(unsigned int i=0; i<los.getNumLOS(); i++) 
     96            { 
     97                const osgSim::LineOfSight::Intersections& intersections = los.getIntersections(i); 
     98                for(osgSim::LineOfSight::Intersections::const_iterator itr = intersections.begin(); 
     99                    itr != intersections.end(); 
     100                    ++itr) 
     101                { 
     102                     std::cout<<"  point "<<*itr<<std::endl; 
     103                } 
     104            } 
     105        } 
     106         
     107        { 
     108            // now do a second traversal to test performance of cache. 
     109            osg::Timer_t startTick = osg::Timer::instance()->tick(); 
     110 
     111            std::cout<<"Computing HeightAboveTerrain"<<std::endl; 
     112 
     113            hat.computeIntersections(scene.get()); 
     114 
     115            osg::Timer_t endTick = osg::Timer::instance()->tick(); 
     116 
     117            for(unsigned int i=0; i<hat.getNumPoints(); i++) 
     118            { 
     119                 std::cout<<"  point = "<<hat.getPoint(i)<<" hat = "<<hat.getHeightAboveTerrain(i)<<std::endl; 
     120            } 
     121 
     122 
     123            std::cout<<"Completed in "<<osg::Timer::instance()->delta_s(startTick,endTick)<<std::endl; 
    102124        } 
    103125#endif 
    104126 
    105         // now do a second traversal to test performance of cache. 
    106         startTick = osg::Timer::instance()->tick(); 
    107  
    108         std::cout<<"Computing HeightAboveTerrain"<<std::endl; 
    109  
    110         hat.computeIntersections(scene.get()); 
    111          
    112         for(unsigned int i=0; i<hat.getNumPoints(); i++) 
    113         { 
    114              std::cout<<"  point = "<<hat.getPoint(i)<<" hat = "<<hat.getHeightAboveTerrain(i)<<std::endl; 
    115         } 
    116  
    117         endTick = osg::Timer::instance()->tick(); 
    118  
    119         std::cout<<"Completed in "<<osg::Timer::instance()->delta_s(startTick,endTick)<<std::endl; 
    120  
     127        { 
     128            // now do a second traversal to test performance of cache. 
     129            osg::Timer_t startTick = osg::Timer::instance()->tick(); 
     130 
     131            std::cout<<"Computing ElevationSlice"<<std::endl; 
     132            osgSim::ElevationSlice es; 
     133            es.setDatabaseCacheReadCallback(los.getDatabaseCacheReadCallback()); 
     134 
     135            es.setStartPoint(bs.center()+osg::Vec3d(bs.radius(),0.0,0.0) ); 
     136            es.setEndPoint(bs.center()+osg::Vec3d(0.0,bs.radius(),0.0) ); 
     137 
     138            es.computeIntersections(scene.get()); 
     139 
     140            osg::Timer_t endTick = osg::Timer::instance()->tick(); 
     141 
     142            std::cout<<"Completed in "<<osg::Timer::instance()->delta_s(startTick,endTick)<<std::endl; 
     143        } 
    121144    } 
    122145    else if (useIntersectorGroup)