00001 /* 00002 * $Id: bvhnode.h 722 2009-03-04 15:45:34Z bittner $ 00003 * 00004 * Description : One line description of file. 00005 * Author : Vaclav Kyba <mail/Jabber: vaseo1@gmail.com> <ICQ: 98576293> 00006 * 00007 * Purpose : 00008 * Long description of what the file is for. 00009 */ 00010 00011 00012 #ifndef __BVHNODE__H__ 00013 #define __BVHNODE__H__ 00014 00015 #include "moddefs.h" 00016 #include "bvolumes.h" 00017 00018 00019 namespace VRUT 00020 { 00022 class BVHNode 00023 { 00024 private: 00026 bool valid; 00028 AABB aabb; 00030 BSphere bSphere; 00032 NODE_ID sceneNodeID; 00034 BVHNode * lChild; 00036 BVHNode * rChild; 00038 int lastOut; 00040 BVHNode * parent; 00041 00042 public: 00044 int id; 00045 00047 BVHNode() 00048 { 00049 valid = false; 00050 lastOut = 0; 00051 parent = (BVHNode *)NULL; 00052 lChild = rChild = (BVHNode *)NULL; 00053 sceneNodeID = NODE_ID_NONE; 00054 } 00056 virtual ~BVHNode() 00057 { 00058 SAFE_DELETE(lChild); 00059 SAFE_DELETE(rChild); 00060 } 00061 00062 bool IsLeaf() const { 00063 return sceneNodeID != NODE_ID_NONE; 00064 } 00065 00067 bool IsValid() const 00068 { 00069 return valid; 00070 } 00072 BVHNode * GetLChild() const 00073 { 00074 return lChild; 00075 } 00077 BVHNode * GetRChild() const 00078 { 00079 return rChild; 00080 } 00082 BVHNode * GetParent() const 00083 { 00084 return parent; 00085 } 00087 const AABB * GetAABB() const 00088 { 00089 return &aabb; 00090 } 00092 const BSphere * GetBSphere() const 00093 { 00094 return &bSphere; 00095 } 00097 const int GetLastOut() const 00098 { 00099 return lastOut; 00100 } 00101 int &LastOut() 00102 { 00103 return lastOut; 00104 } 00105 00107 NODE_ID GetSceneNodeID() const 00108 { 00109 return sceneNodeID; 00110 } 00112 virtual wxString ToString() const 00113 { 00114 return wxString::Format(wxT("%s\nSceneNode ID: %i\n"), 00115 aabb.ToString().c_str(), sceneNodeID); 00116 } 00117 00118 friend class BVH; 00119 }; 00120 }; 00121 00122 #endif