Added copying of plane to surface intersections in the osgUtil::PlaneIntersector class, and update wrappers.

This commit is contained in:
Robert Osfield 2006-12-03 11:44:12 +00:00
parent dc250e6e1a
commit 56b7268c72
3 changed files with 25 additions and 18 deletions

View File

@ -55,14 +55,12 @@ class OSGUTIL_EXPORT PlaneIntersector : public Intersector
};
typedef std::set<Intersection> Intersections;
typedef std::vector<Intersection> Intersections;
inline void insertIntersection(const Intersection& intersection) { getIntersections().insert(intersection); }
inline void insertIntersection(const Intersection& intersection) { getIntersections().push_back(intersection); }
inline Intersections& getIntersections() { return _parent ? _parent->_intersections : _intersections; }
inline Intersection getFirstIntersection() { Intersections& intersections = getIntersections(); return intersections.empty() ? Intersection() : *(intersections.begin()); }
public:
virtual Intersector* clone(osgUtil::IntersectionVisitor& iv);

View File

@ -52,6 +52,7 @@ namespace PlaneIntersectorUtils
PolylineMap _startPolylineMap;
PolylineMap _endPolylineMap;
void add(const osg::Vec3d& v1, const osg::Vec3d& v2)
{
if (v1==v2) return;
@ -339,6 +340,12 @@ namespace PlaneIntersectorUtils
}
void fuse()
{
osg::notify(osg::NOTICE)<<"supposed to be doing a fuse..."<<std::endl;
}
};
@ -472,6 +479,7 @@ PlaneIntersector::PlaneIntersector(CoordinateFrame cf, const osg::Plane& plane,
{
}
Intersector* PlaneIntersector::clone(osgUtil::IntersectionVisitor& iv)
{
if (_coordinateFrame==MODEL && iv.getModelMatrix()==0)
@ -547,12 +555,20 @@ void PlaneIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable
if (ti._hit)
{
Intersections& intersections = getIntersections();
for(PlaneIntersectorUtils::PolylineConnector::PolylineList::iterator pitr = ti._polylineConnector._polylines.begin();
pitr != ti._polylineConnector._polylines.end();
++pitr)
{
unsigned int pos = intersections.size();
intersections.push_back(Intersection());
Intersection& new_intersection = intersections[pos];
Intersection hit;
hit.nodePath = iv.getNodePath();
hit.drawable = drawable;
insertIntersection(hit);
new_intersection.polyline = (*pitr)->_polyline;
new_intersection.nodePath = iv.getNodePath();
new_intersection.drawable = drawable;
}
osg::notify(osg::NOTICE)<<std::endl<<"++++++++++++ Found intersections +++++++++++++++++++++++++"<<std::endl<<std::endl;
}

View File

@ -25,7 +25,7 @@
#undef OUT
#endif
TYPE_NAME_ALIAS(std::set< osgUtil::PlaneIntersector::Intersection >, osgUtil::PlaneIntersector::Intersections);
TYPE_NAME_ALIAS(std::vector< osgUtil::PlaneIntersector::Intersection >, osgUtil::PlaneIntersector::Intersections);
BEGIN_OBJECT_REFLECTOR(osgUtil::PlaneIntersector)
I_BaseType(osgUtil::Intersector);
@ -45,10 +45,6 @@ BEGIN_OBJECT_REFLECTOR(osgUtil::PlaneIntersector)
__Intersections_R1__getIntersections,
"",
"");
I_Method0(osgUtil::PlaneIntersector::Intersection, getFirstIntersection,
__Intersection__getFirstIntersection,
"",
"");
I_Method1(osgUtil::Intersector *, clone, IN, osgUtil::IntersectionVisitor &, iv,
__Intersector_P1__clone__osgUtil_IntersectionVisitor_R1,
"",
@ -73,9 +69,6 @@ BEGIN_OBJECT_REFLECTOR(osgUtil::PlaneIntersector)
__bool__containsIntersections,
"",
"");
I_SimpleProperty(osgUtil::PlaneIntersector::Intersection, FirstIntersection,
__Intersection__getFirstIntersection,
0);
I_SimpleProperty(osgUtil::PlaneIntersector::Intersections &, Intersections,
__Intersections_R1__getIntersections,
0);
@ -93,5 +86,5 @@ BEGIN_VALUE_REFLECTOR(osgUtil::PlaneIntersector::Intersection)
I_PublicMemberProperty(osgUtil::PlaneIntersector::Intersection::Polyline, polyline);
END_REFLECTOR
STD_SET_REFLECTOR(std::set< osgUtil::PlaneIntersector::Intersection >);
STD_VECTOR_REFLECTOR(std::vector< osgUtil::PlaneIntersector::Intersection >);