| 48 | | |
| 49 | | if (useIntersectorGroup) |
| | 50 | bool useLineOfSight = true; |
| | 51 | |
| | 52 | if (useLineOfSight) |
| | 53 | { |
| | 54 | osg::Timer_t startTick = osg::Timer::instance()->tick(); |
| | 55 | |
| | 56 | osg::Vec3d start = bs.center() + osg::Vec3d(0.0,bs.radius(),0.0); |
| | 57 | osg::Vec3d end = bs.center();// - osg::Vec3d(0.0, bs.radius(),0.0); |
| | 58 | osg::Vec3d deltaRow( 0.0, 0.0, bs.radius()*0.01); |
| | 59 | osg::Vec3d deltaColumn( bs.radius()*0.01, 0.0, 0.0); |
| | 60 | unsigned int numRows = 50; |
| | 61 | unsigned int numColumns = 50; |
| | 62 | |
| | 63 | osgSim::LineOfSight los; |
| | 64 | |
| | 65 | for(unsigned int r=0; r<numRows; ++r) |
| | 66 | { |
| | 67 | for(unsigned int c=0; c<numColumns; ++c) |
| | 68 | { |
| | 69 | osg::Vec3d s = start + deltaColumn * double(c) + deltaRow * double(r); |
| | 70 | osg::Vec3d e = end + deltaColumn * double(c) + deltaRow * double(r); |
| | 71 | los.addLOS(s,e); |
| | 72 | } |
| | 73 | } |
| | 74 | |
| | 75 | |
| | 76 | los.computeIntersections(root.get()); |
| | 77 | |
| | 78 | osg::Timer_t endTick = osg::Timer::instance()->tick(); |
| | 79 | |
| | 80 | std::cout<<"Completed in "<<osg::Timer::instance()->delta_s(startTick,endTick)<<std::endl; |
| | 81 | |
| | 82 | #if 0 |
| | 83 | for(unsigned int i=0; i<los.getNumLOS(); i++) |
| | 84 | { |
| | 85 | const osgSim::LineOfSight::Intersections& intersections = los.getIntersections(i); |
| | 86 | for(osgSim::LineOfSight::Intersections::const_iterator itr = intersections.begin(); |
| | 87 | itr != intersections.end(); |
| | 88 | ++itr) |
| | 89 | { |
| | 90 | std::cout<<" point "<<*itr<<std::endl; |
| | 91 | } |
| | 92 | } |
| | 93 | #endif |
| | 94 | |
| | 95 | // now do a second traversal to test performance of cache. |
| | 96 | startTick = osg::Timer::instance()->tick(); |
| | 97 | |
| | 98 | los.computeIntersections(root.get()); |
| | 99 | |
| | 100 | endTick = osg::Timer::instance()->tick(); |
| | 101 | |
| | 102 | std::cout<<"Completed in "<<osg::Timer::instance()->delta_s(startTick,endTick)<<std::endl; |
| | 103 | |
| | 104 | } |
| | 105 | else if (useIntersectorGroup) |