- Timestamp:
- 03/31/06 17:29:32 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGNodeBsp.h
r700 r721 7 7 namespace IMG { 8 8 9 class NodeBsp { 9 // Fordward declaration... 10 class NodeBsp; 11 12 typedef ::boost::intrusive_ptr<NodeBsp> NodeBspPtr; 13 14 namespace boost 15 { 16 void intrusive_ptr_add_ref(NodeBsp * p); 17 void intrusive_ptr_release(NodeBsp * p); 18 }; 19 20 class NodeBsp 21 { 10 22 public: 11 23 NodeBsp(); 12 24 13 Box2d * GetBound();25 virtual ~NodeBsp(); 14 26 15 inline void SetBound(Box2d * box) { bound = box; };27 Box2d* GetBound(); 16 28 17 inline NodeBsp * GetChild(int i) { return child[i]; };29 void SetBound(Box2d *box); 18 30 19 inline void SetId(int id_) { id = id_; };31 NodeBspPtr GetChild(int i); 20 32 21 inline unsigned int GetId() const { return id; };33 void SetId(int id_); 22 34 23 inline void SetChild(NodeBsp * node, int i) { child[i] = node; }; 35 unsigned int GetId() const; 36 37 void SetChild(NodeBspPtr node, int i); 24 38 25 39 void Print(); 26 40 27 //void SetPlane (Plane3 *pla) { plane = pla; } 28 //Plane3 * GetPlane () { return plane; } 29 NodeBsp * Insert(int w, int h); 41 NodeBspPtr Insert(int w, int h); 30 42 31 inline NodeBsp * Get(NodeBsp * node, int i) { 32 if (!node) return NULL; 33 if (node->GetId() == i ) return node; 34 35 NodeBsp *nod; 36 if (nod = node->GetChild(0)->Get (node->GetChild(0), i)) return nod; 37 38 return node->GetChild(0)->Get (node->GetChild(1), i); 39 40 }; 43 NodeBspPtr Get(NodeBspPtr node, int i); 41 44 45 protected: 42 46 43 private:44 47 bool fit; 45 48 46 Box2d *bound;49 Box2d bound; 47 50 48 NodeBsp *child[2];51 NodeBspPtr child[2]; 49 52 50 53 static unsigned int ID; … … 52 55 int id; 53 56 57 private: 58 59 long references; 54 60 55 public: 56 ~NodeBsp(); 61 friend void boost::intrusive_ptr_add_ref(NodeBsp * p); 57 62 63 friend void boost::intrusive_ptr_release(NodeBsp * p); 58 64 }; 65 66 // class specific addref/release implementation 67 // the two function overloads must be in the boost namespace on most compilers: 68 namespace boost 69 { 70 inline void intrusive_ptr_add_ref(NodeBsp * p) 71 { 72 // increment reference count of object *p 73 ++(p->references); 74 } 75 76 77 78 inline void intrusive_ptr_release(NodeBsp * p) 79 { 80 // decrement reference count, and delete object when reference count reaches 0 81 if (--(p->references) == 0) 82 delete p; 83 } 84 } // namespace boost 59 85 60 86 }
Note: See TracChangeset
for help on using the changeset viewer.