source:
GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGNodeBsp.h
@
731
Revision 731, 1.5 KB checked in by igarcia, 18 years ago (diff) |
---|
Rev | Line | |
---|---|---|
[700] | 1 | #ifndef _IMGNODEBSP_H |
2 | #define _IMGNODEBSP_H | |
3 | ||
4 | #include "IMGPrerequisites.h" | |
5 | #include "IMGBox2d.h" | |
6 | ||
7 | namespace IMG { | |
8 | ||
[721] | 9 | // Fordward declaration... |
[731] | 10 | class _IMGExport NodeBsp; |
[721] | 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 | { | |
[700] | 22 | public: |
23 | NodeBsp(); | |
24 | ||
[721] | 25 | virtual ~NodeBsp(); |
[700] | 26 | |
[731] | 27 | Box2d* getBound(); |
[700] | 28 | |
[731] | 29 | void setBound(Box2d *box); |
[700] | 30 | |
[731] | 31 | NodeBspPtr getChild(int i); |
[700] | 32 | |
[731] | 33 | void setId(int id_); |
[700] | 34 | |
[731] | 35 | unsigned int getId() const; |
[700] | 36 | |
[731] | 37 | void setChild(NodeBspPtr node, int i); |
[721] | 38 | |
[731] | 39 | void print(); |
[700] | 40 | |
[731] | 41 | NodeBspPtr insert(int w, int h); |
[700] | 42 | |
[731] | 43 | NodeBspPtr get(NodeBspPtr node, int i); |
[700] | 44 | |
[721] | 45 | protected: |
[700] | 46 | |
47 | bool fit; | |
48 | ||
[721] | 49 | Box2d bound; |
[700] | 50 | |
[721] | 51 | NodeBspPtr child[2]; |
[700] | 52 | |
53 | static unsigned int ID; | |
54 | ||
55 | int id; | |
56 | ||
[721] | 57 | private: |
58 | ||
59 | long references; | |
60 | ||
61 | friend void boost::intrusive_ptr_add_ref(NodeBsp * p); | |
62 | ||
63 | friend void boost::intrusive_ptr_release(NodeBsp * p); | |
64 | }; | |
[700] | 65 | |
[721] | 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 | |
[700] | 85 | |
86 | } | |
87 | #endif |
Note: See TracBrowser
for help on using the repository browser.