00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef BVHSubTreeCollector_hxx
00019 #define BVHSubTreeCollector_hxx
00020
00021 #include <simgear/math/SGGeometry.hxx>
00022
00023 #include "BVHVisitor.hxx"
00024 #include "BVHNode.hxx"
00025 #include "BVHGroup.hxx"
00026 #include "BVHStaticNode.hxx"
00027
00028 namespace simgear {
00029
00037
00038 class BVHSubTreeCollector : public BVHVisitor {
00039 public:
00040 typedef std::vector<SGSharedPtr<BVHNode> > NodeList;
00041
00042 BVHSubTreeCollector(const SGSphered& sphere = SGSphered());
00043 virtual ~BVHSubTreeCollector();
00044
00045 virtual void apply(BVHGroup&);
00046 virtual void apply(BVHTransform&);
00047 virtual void apply(BVHMotionTransform&);
00048 virtual void apply(BVHLineGeometry&);
00049 virtual void apply(BVHStaticGeometry&);
00050
00051 virtual void apply(const BVHStaticBinary&, const BVHStaticData&);
00052 virtual void apply(const BVHStaticTriangle&, const BVHStaticData&);
00053
00054 void setSphere(const SGSphered& sphere)
00055 { _sphere = sphere; }
00056 const SGSphered& getSphere() const
00057 { return _sphere; }
00058
00059 bool haveChildren() const
00060 { return !_nodeList.empty(); }
00061
00062 void addNode(BVHNode* node);
00063
00064 void pushNodeList(NodeList& parentNodeList)
00065 { _nodeList.swap(parentNodeList); }
00066 void popNodeList(NodeList& parentNodeList, BVHGroup* transform);
00067 void popNodeList(NodeList& parentNodeList);
00068
00069 SGSharedPtr<BVHNode> getNode() const;
00070
00071 protected:
00072 NodeList _nodeList;
00073 SGSharedPtr<const BVHStaticNode> _staticNode;
00074
00075 private:
00076 SGSphered _sphere;
00077 };
00078
00079 }
00080
00081 #endif