Panda3D

collisionLevelStateBase.h

00001 // Filename: collisionLevelStateBase.h
00002 // Created by:  drose (16Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef COLLISIONLEVELSTATEBASE_H
00016 #define COLLISIONLEVELSTATEBASE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "luse.h"
00021 #include "pointerToArray.h"
00022 #include "geometricBoundingVolume.h"
00023 #include "nodePath.h"
00024 #include "workingNodePath.h"
00025 #include "pointerTo.h"
00026 #include "plist.h"
00027 #include "pStatCollector.h"
00028 #include "bitMask.h"
00029 #include "lvector3.h"
00030 #include "register_type.h"
00031 #include "collisionSolid.h"
00032 
00033 
00034 class CollisionSolid;
00035 class CollisionNode;
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //       Class : CollisionLevelStateBase
00039 // Description : This is the state information the
00040 //               CollisionTraverser retains for each level during
00041 //               traversal.
00042 //
00043 //               The CollisionLevelStateBase is the non-template base
00044 //               class.  The template version further specifies this
00045 //               on CurrentMask type.
00046 ////////////////////////////////////////////////////////////////////
00047 class CollisionLevelStateBase {
00048 public:
00049   class ColliderDef {
00050   public:
00051     CPT(CollisionSolid) _collider;
00052     CollisionNode *_node;
00053     NodePath _node_path;
00054   };
00055 
00056   INLINE CollisionLevelStateBase(const NodePath &node_path);
00057   INLINE CollisionLevelStateBase(const CollisionLevelStateBase &parent, 
00058                              PandaNode *child);
00059   INLINE CollisionLevelStateBase(const CollisionLevelStateBase &copy);
00060   INLINE void operator = (const CollisionLevelStateBase &copy);
00061 
00062   void clear();
00063   void reserve(int num_colliders);
00064   void prepare_collider(const ColliderDef &def, const NodePath &root);
00065   
00066   INLINE NodePath get_node_path() const;
00067   INLINE PandaNode *node() const;
00068 
00069   INLINE int get_num_colliders() const;
00070 
00071   INLINE const CollisionSolid *get_collider(int n) const;
00072   INLINE CollisionNode *get_collider_node(int n) const;
00073   INLINE NodePath get_collider_node_path(int n) const;
00074   INLINE const GeometricBoundingVolume *get_local_bound(int n) const;
00075   INLINE const GeometricBoundingVolume *get_parent_bound(int n) const;
00076 
00077   INLINE void set_include_mask(CollideMask include_mask);
00078   INLINE CollideMask get_include_mask() const;
00079 
00080 protected:
00081   WorkingNodePath _node_path;
00082 
00083   typedef PTA(ColliderDef) Colliders;
00084   Colliders _colliders;
00085   CollideMask _include_mask;
00086 
00087   typedef PTA(CPT(GeometricBoundingVolume)) BoundingVolumes;
00088   BoundingVolumes _local_bounds;
00089   BoundingVolumes _parent_bounds;
00090 
00091   static PStatCollector _node_volume_pcollector;
00092 
00093 public:
00094   static TypeHandle get_class_type() {
00095     return _type_handle;
00096   }
00097   static void init_type() {
00098     register_type(_type_handle, "CollisionLevelStateBase");
00099   }
00100 
00101 private:
00102   static TypeHandle _type_handle;
00103 
00104   friend class CollisionTraverser;
00105 };
00106 
00107 #include "collisionLevelStateBase.I"
00108 
00109 #endif
00110 
00111 
 All Classes Functions Variables Enumerations