00001 // Filename: collisionLevelState.h 00002 // Created by: drose (16Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef COLLISIONLEVELSTATE_H 00020 #define COLLISIONLEVELSTATE_H 00021 00022 #include "pandabase.h" 00023 00024 #include "luse.h" 00025 #include "pointerToArray.h" 00026 #include "geometricBoundingVolume.h" 00027 #include "nodePath.h" 00028 #include "workingNodePath.h" 00029 00030 #include "plist.h" 00031 00032 class CollisionSolid; 00033 class CollisionNode; 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Class : CollisionLevelState 00037 // Description : This is the state information the 00038 // CollisionTraverser retains for each level during 00039 // traversal. 00040 //////////////////////////////////////////////////////////////////// 00041 class CollisionLevelState { 00042 public: 00043 class ColliderDef { 00044 public: 00045 CollisionSolid *_collider; 00046 CollisionNode *_node; 00047 LMatrix4f _space; 00048 LMatrix4f _inv_space; 00049 }; 00050 00051 INLINE CollisionLevelState(const NodePath &node_path); 00052 INLINE CollisionLevelState(const CollisionLevelState &parent, 00053 PandaNode *child); 00054 00055 void clear(); 00056 void reserve(int max_colliders); 00057 void prepare_collider(const ColliderDef &def); 00058 00059 bool any_in_bounds(); 00060 void apply_transform(); 00061 00062 INLINE NodePath get_node_path() const; 00063 INLINE PandaNode *node() const; 00064 00065 INLINE int get_num_colliders() const; 00066 INLINE bool has_collider(int n) const; 00067 INLINE bool has_collider_with_geom(int n) const; 00068 INLINE bool has_any_collider() const; 00069 INLINE bool has_any_collide_geom() const; 00070 00071 INLINE void reached_collision_node(); 00072 00073 INLINE CollisionSolid *get_collider(int n) const; 00074 INLINE CollisionNode *get_node(int n) const; 00075 INLINE const LMatrix4f &get_space(int n) const; 00076 INLINE const LMatrix4f &get_inv_space(int n) const; 00077 INLINE const GeometricBoundingVolume *get_local_bound(int n) const; 00078 INLINE const GeometricBoundingVolume *get_parent_bound(int n) const; 00079 00080 INLINE void omit_collider(int n); 00081 00082 private: 00083 // ColliderMask here is a locally-defined value that simply serves 00084 // to keep track of the colliders that are still interested in the 00085 // current node. Don't confuse it with CollideMask, which is a set 00086 // of user-defined bits that specify which CollisionSolids may 00087 // possibly intersect with each other. 00088 typedef int ColliderMask; 00089 00090 INLINE ColliderMask get_mask(int n) const; 00091 00092 WorkingNodePath _node_path; 00093 00094 typedef PTA(ColliderDef) Colliders; 00095 Colliders _colliders; 00096 ColliderMask _current; 00097 ColliderMask _colliders_with_geom; 00098 00099 typedef PTA(CPT(GeometricBoundingVolume)) BoundingVolumes; 00100 BoundingVolumes _local_bounds; 00101 BoundingVolumes _parent_bounds; 00102 }; 00103 00104 #include "collisionLevelState.I" 00105 00106 #endif 00107 00108