Show
Ignore:
Timestamp:
02/25/08 15:15:27 (2 years ago)
Author:
robert
Message:

From Wojciech Lewandowski, "----1----


Attached is a fixed version of OverlayNode?.cpp. I fixed CustomPolytope::cut( osg::Plane ) method. Bug was apparent in such scenario:


Let P1 be some random frustum polytope
Let P2 be the polytope that was created from P1 bounding box (P2 contains P1 entirely)


Then ignoring precision errors: P1.cut( P2 ) == P2.cut( P1 ) == P1. But this condition was not always met. Cut failed when some of the polytope reference points happened to lie exactly on some intersecting planes in both P1 & P2 (plane distance was = 0).


I only use CustomPolytope? for my shadowing stuff so I did not test how this affects rest of OverlayNode?.cpp.




Also attached is a minor precision improvement for osg::Plane intersect method (double version).




I have also one observation regarding osg::Plane - There are two intersect vertices methods (float and double flavour):


inline int intersect(const std::vector<Vec3>& vertices) const
inline int intersect(const std::vector<Vec3d>& vertices) const


I guess osg::Plane won't compile when someone changes default vec3 typedef to vec3d. Shouldn't the first method be changed to use vec3f explicitly ? Ie:


inline int intersect(const std::vector<Vec3f>& vertices) const"

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osg/Plane

    r7648 r7879  
    190190            return 0 if the bs intersects the plane, 
    191191            return -1 if the bs is completely below the plane.*/ 
    192         inline int intersect(const std::vector<Vec3>& vertices) const 
     192        inline int intersect(const std::vector<Vec3f>& vertices) const 
    193193        { 
    194194            if (vertices.empty()) return -1; 
     
    197197            int noBelow = 0; 
    198198            int noOn = 0; 
    199             for(std::vector<Vec3>::const_iterator itr=vertices.begin(); 
     199            for(std::vector<Vec3f>::const_iterator itr=vertices.begin(); 
    200200                itr != vertices.end(); 
    201201                ++itr) 
     
    230230                ++itr) 
    231231            { 
    232                 float d = distance(*itr); 
    233                 if (d>0.0f) ++noAbove; 
    234                 else if (d<0.0f) ++noBelow; 
     232                double d = distance(*itr); 
     233                if (d>0.0) ++noAbove; 
     234                else if (d<0.0) ++noBelow; 
    235235                else ++noOn; 
    236236            }