00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef BVHLineSegmentVisitor_hxx
00019 #define BVHLineSegmentVisitor_hxx
00020
00021 #include <simgear/math/SGGeometry.hxx>
00022 #include <simgear/structure/SGSharedPtr.hxx>
00023 #include <simgear/scene/material/mat.hxx>
00024
00025 #include "BVHVisitor.hxx"
00026 #include "BVHNode.hxx"
00027
00028 namespace simgear {
00029
00030 class BVHLineSegmentVisitor : public BVHVisitor {
00031 public:
00032 BVHLineSegmentVisitor(const SGLineSegmentd& lineSegment,
00033 const double& t = 0) :
00034 _lineSegment(lineSegment),
00035 _time(t),
00036 _material(0),
00037 _id(0),
00038 _haveHit(false)
00039 { }
00040 virtual ~BVHLineSegmentVisitor()
00041 { }
00042
00043 bool empty() const
00044 { return !_haveHit; }
00045
00046 const SGLineSegmentd& getLineSegment() const
00047 { return _lineSegment; }
00048
00049 SGVec3d getPoint() const
00050 { return _lineSegment.getEnd(); }
00051 const SGVec3d& getNormal() const
00052 { return _normal; }
00053 const SGVec3d& getLinearVelocity() const
00054 { return _linearVelocity; }
00055 const SGVec3d& getAngularVelocity() const
00056 { return _angularVelocity; }
00057 const SGMaterial* getMaterial() const
00058 { return _material; }
00059 BVHNode::Id getId() const
00060 { return _id; }
00061
00062 virtual void apply(BVHGroup& group);
00063 virtual void apply(BVHTransform& transform);
00064 virtual void apply(BVHMotionTransform& transform);
00065 virtual void apply(BVHLineGeometry&);
00066 virtual void apply(BVHStaticGeometry& node);
00067
00068 virtual void apply(const BVHStaticBinary&, const BVHStaticData&);
00069 virtual void apply(const BVHStaticTriangle&, const BVHStaticData&);
00070
00071 protected:
00072 void setLineSegmentEnd(const SGVec3d& end)
00073 {
00074
00075
00076 #ifndef _NDEBUG
00077
00078 #endif
00079 _lineSegment.set(_lineSegment.getStart(), end);
00080 }
00081
00082 private:
00083 SGLineSegmentd _lineSegment;
00084 double _time;
00085
00086
00087 SGVec3d _normal;
00088 SGVec3d _linearVelocity;
00089 SGVec3d _angularVelocity;
00090 const SGMaterial* _material;
00091 BVHNode::Id _id;
00092
00093 bool _haveHit;
00094 };
00095
00096 }
00097
00098 #endif