00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef BVHNode_hxx
00019 #define BVHNode_hxx
00020
00021 #include <vector>
00022 #include <simgear/math/SGGeometry.hxx>
00023 #include <simgear/structure/SGReferenced.hxx>
00024
00025 namespace simgear {
00026
00027 class BVHGroup;
00028 class BVHVisitor;
00029
00030
00031 class BVHNode : public SGReferenced {
00032 public:
00033 BVHNode();
00034 virtual ~BVHNode();
00035
00036
00037 virtual void accept(BVHVisitor& visitor) = 0;
00038
00039 const SGSphered& getBoundingSphere() const
00040 {
00041 if (_dirtyBoundingSphere) {
00042 _boundingSphere = computeBoundingSphere();
00043 _dirtyBoundingSphere = false;
00044 }
00045 return _boundingSphere;
00046 }
00047 virtual SGSphered computeBoundingSphere() const = 0;
00048
00051 typedef unsigned Id;
00052
00053
00054 static Id getNewId();
00055
00056 protected:
00057 friend class BVHGroup;
00058 void addParent(BVHNode* parent);
00059 void removeParent(BVHNode* parent);
00060
00061 void invalidateParentBound();
00062 virtual void invalidateBound();
00063
00064 private:
00065 mutable bool _dirtyBoundingSphere;
00066 mutable SGSphered _boundingSphere;
00067
00068 typedef std::vector<BVHNode*> ParentList;
00069 ParentList _parents;
00070 };
00071
00072 }
00073
00074 #endif