source: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGNodeBsp.h @ 731

Revision 731, 1.5 KB checked in by igarcia, 19 years ago (diff)
Line 
1#ifndef _IMGNODEBSP_H
2#define _IMGNODEBSP_H
3
4#include "IMGPrerequisites.h"
5#include "IMGBox2d.h"
6
7namespace IMG {
8
9// Fordward declaration...
10class _IMGExport NodeBsp;
11
12typedef ::boost::intrusive_ptr<NodeBsp> NodeBspPtr;
13
14namespace boost
15{
16    void intrusive_ptr_add_ref(NodeBsp * p);
17    void intrusive_ptr_release(NodeBsp * p);
18};
19
20class NodeBsp
21{
22  public:
23    NodeBsp();
24
25    virtual ~NodeBsp();
26
27    Box2d* getBound();
28
29    void setBound(Box2d *box);
30
31    NodeBspPtr getChild(int i);
32
33    void setId(int id_);
34
35    unsigned int getId() const;
36
37    void setChild(NodeBspPtr node, int i);
38
39    void print();
40
41    NodeBspPtr insert(int w, int h);
42
43    NodeBspPtr get(NodeBspPtr node, int i);
44
45  protected:
46
47    bool fit;
48
49    Box2d bound;
50
51    NodeBspPtr child[2];
52
53    static unsigned int ID;
54
55    int id;
56
57private:
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};
65
66// class specific addref/release implementation
67// the two function overloads must be in the boost namespace on most compilers:
68namespace 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
85
86}
87#endif
Note: See TracBrowser for help on using the repository browser.