Ignore:
Timestamp:
03/31/06 17:29:32 (18 years ago)
Author:
igarcia
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/IMG/IMGNodeBsp.h

    r700 r721  
    77namespace IMG { 
    88 
    9 class NodeBsp { 
     9// Fordward declaration... 
     10class 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{ 
    1022  public: 
    1123    NodeBsp(); 
    1224 
    13     Box2d * GetBound(); 
     25    virtual ~NodeBsp(); 
    1426 
    15     inline void SetBound(Box2d * box) { bound = box; }; 
     27    Box2d* GetBound(); 
    1628 
    17     inline NodeBsp * GetChild(int i) { return child[i]; }; 
     29    void SetBound(Box2d *box); 
    1830 
    19     inline void SetId(int id_) { id = id_; }; 
     31    NodeBspPtr GetChild(int i); 
    2032 
    21     inline unsigned int GetId() const { return id; }; 
     33    void SetId(int id_); 
    2234 
    23     inline void SetChild(NodeBsp * node, int i) { child[i] = node; }; 
     35    unsigned int GetId() const; 
     36 
     37    void SetChild(NodeBspPtr node, int i); 
    2438 
    2539    void Print(); 
    2640 
    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); 
    3042 
    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); 
    4144 
     45  protected: 
    4246 
    43   private: 
    4447    bool fit; 
    4548 
    46     Box2d * bound; 
     49    Box2d bound; 
    4750 
    48     NodeBsp * child[2]; 
     51    NodeBspPtr child[2]; 
    4952 
    5053    static unsigned int ID; 
     
    5255    int id; 
    5356 
     57private: 
     58     
     59        long references; 
    5460 
    55   public: 
    56     ~NodeBsp(); 
     61    friend void boost::intrusive_ptr_add_ref(NodeBsp * p); 
    5762 
     63    friend void boost::intrusive_ptr_release(NodeBsp * p); 
    5864}; 
     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 
    5985 
    6086} 
Note: See TracChangeset for help on using the changeset viewer.