Blender V2.61 - r43446

SG_Node.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00032 #ifndef __SG_NODE_H
00033 #define __SG_NODE_H
00034 
00035 #include "SG_Spatial.h"
00036 #include <vector>
00037 
00038 typedef std::vector<SG_Node*> NodeList;
00039 
00043 class SG_Node : public SG_Spatial
00044 {
00045 public:
00046     SG_Node(
00047         void* clientobj,
00048         void* clientinfo,
00049         SG_Callbacks& callbacks
00050     );
00051 
00052     SG_Node(
00053         const SG_Node & other
00054     );
00055 
00056     virtual ~SG_Node();
00057 
00058 
00066         void    
00067     AddChild(
00068         SG_Node* child
00069     );
00070 
00078         void    
00079     RemoveChild(
00080         SG_Node* child
00081     );
00082 
00086         bool
00087     IsAncessor(
00088         const SG_Node* child
00089     ) const;
00097     NodeList& GetSGChildren()
00098     {
00099         return this->m_children;
00100     }
00101 
00107     const NodeList& GetSGChildren() const
00108     {
00109         return this->m_children;
00110     }
00111 
00116     void ClearSGChildren()
00117     {
00118         m_children.clear();
00119     }
00120 
00125     SG_Node* GetSGParent() const 
00126     { 
00127         return m_SGparent;
00128     }
00129 
00134     void SetSGParent(SG_Node* parent)
00135     {
00136         m_SGparent = parent;
00137     }
00138 
00143     const 
00144         SG_Node* 
00145     GetRootSGParent(
00146     ) const;
00147 
00152         void                
00153     DisconnectFromParent(
00154     );
00155 
00159     bool IsVertexParent()
00160     {
00161         if (m_parent_relation)
00162         {
00163             return m_parent_relation->IsVertexRelation();
00164         }
00165         return false;
00166     }
00167 
00168 
00173     bool IsSlowParent()
00174     {
00175         if (m_parent_relation)
00176         {
00177             return m_parent_relation->IsSlowRelation();
00178         }
00179         return false;
00180     }
00181 
00182 
00183 
00184 
00190         void        
00191     UpdateWorldData(
00192         double time,
00193         bool parentUpdated=false
00194     );
00195 
00201         void        
00202     SetSimulatedTime(
00203         double time,
00204         bool recurse
00205     );
00206 
00210     bool Schedule(SG_QList& head)
00211     {
00212         // Put top parent in front of list to make sure they are updated before their
00213         // children => the children will be udpated and removed from the list before
00214         // we get to them, should they be in the list too.
00215         return (m_SGparent)?head.AddBack(this):head.AddFront(this);
00216     }
00217 
00221     static SG_Node* GetNextScheduled(SG_QList& head)
00222     {
00223         return static_cast<SG_Node*>(head.Remove());
00224     }
00225 
00230     bool Reschedule(SG_QList& head)
00231     {
00232         return head.QAddBack(this);
00233     }
00234 
00238     static SG_Node* GetNextRescheduled(SG_QList& head)
00239     {
00240         return static_cast<SG_Node*>(head.QRemove());
00241     }
00242 
00247         SG_Node*    
00248     GetSGReplica(
00249     );
00250 
00251         void        
00252     Destruct(
00253     );
00254     
00255 private:
00256 
00257         void        
00258     ProcessSGReplica(
00259         SG_Node** replica
00260     );
00261 
00265     NodeList m_children;
00266 
00270     SG_Node* m_SGparent;
00271 
00272 
00273 #ifdef WITH_CXX_GUARDEDALLOC
00274 public:
00275     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_Node"); }
00276     void operator delete( void *mem ) { MEM_freeN(mem); }
00277 #endif
00278 };
00279 
00280 #endif //__SG_NODE_H
00281