Panda3D
odeSpace.h
1 // Filename: odeSpace.h
2 // Created by: joswilso (27Dec06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef ODESPACE_H
16 #define ODESPACE_H
17 
18 #include "pandabase.h"
19 #include "typedObject.h"
20 #include "luse.h"
21 #include "bitMask.h"
22 
23 //included for collision tests
24 #include "odeWorld.h"
25 #include "odeJointGroup.h"
26 
27 #include "ode_includes.h"
28 
29 class OdeGeom;
30 class OdeTriMeshGeom;
31 class OdeSimpleSpace;
32 class OdeHashSpace;
33 class OdeQuadTreeSpace;
34 
35 ////////////////////////////////////////////////////////////////////
36 // Class : OdeSpace
37 // Description :
38 ////////////////////////////////////////////////////////////////////
39 class EXPCL_PANDAODE OdeSpace : public TypedObject {
40  friend class OdeGeom;
41  static const int MAX_CONTACTS;
42 
43 public:
44  OdeSpace(dSpaceID id);
45 
46 PUBLISHED:
47  virtual ~OdeSpace();
48  void destroy();
49  INLINE bool is_empty() const;
50 
51  INLINE void set_cleanup(int mode);
52  INLINE int get_cleanup() const;
53  int query(const OdeGeom& geom) const;
54  int query(const OdeSpace& space) const;
55  INLINE int get_num_geoms() const;
56  INLINE void get_AABB(LVecBase3f &min, LVecBase3f &max) const;
57  EXTENSION(INLINE PyObject *get_AA_bounds() const);
58  INLINE int is_space();
59  INLINE int get_class() const;
60  INLINE void set_category_bits(const BitMask32 &bits);
61  INLINE void set_collide_bits(const BitMask32 &bits);
62  INLINE BitMask32 get_category_bits();
63  INLINE BitMask32 get_collide_bits();
64  INLINE void enable();
65  INLINE void disable();
66  INLINE int is_enabled();
67  void set_auto_collide_world(OdeWorld&);
68  void set_auto_collide_joint_group(OdeJointGroup&);
69 
70  void add(OdeGeom& geom);
71  void add(OdeSpace& space);
72  void remove(OdeGeom& geom);
73  void remove(OdeSpace& space);
74  void clean();
75  OdeGeom get_geom(int i); // Not INLINE because of forward declaration
76  //static int get_surface_type(OdeSpace * self, dGeomID o1);
77 
78  INLINE OdeSpace get_space() const;
79 
80  virtual void write(ostream &out = cout, unsigned int indent=0) const;
81  operator bool () const;
82 
83  OdeSimpleSpace convert_to_simple_space() const;
84  OdeHashSpace convert_to_hash_space() const;
85  OdeQuadTreeSpace convert_to_quad_tree_space() const;
86 
87  EXTENSION(PyObject *convert() const);
88  EXTENSION(INLINE PyObject *get_converted_geom(int i) const);
89  EXTENSION(INLINE PyObject *get_converted_space() const);
90 
91  void auto_collide();
92  EXTENSION(int collide(PyObject* arg, PyObject* near_callback));
93  int set_collide_id(int collide_id, dGeomID id);
94  int set_collide_id(OdeGeom& geom, int collide_id);
95  void set_surface_type( int surface_type, dGeomID id);
96  void set_surface_type(OdeGeom& geom, int surface_type);
97  int get_surface_type(dGeomID o1);
98  int get_surface_type(OdeGeom& geom);
99  int get_collide_id(dGeomID o1);
100  int get_collide_id(OdeGeom& geom);
101 
102  INLINE void set_collision_event(const string &event_name);
103  INLINE string get_collision_event();
104 
105 public:
106  static void auto_callback(void*, dGeomID, dGeomID);
107 
108  INLINE dSpaceID get_id() const;
109  static OdeWorld* _static_auto_collide_world;
110  static OdeSpace* _static_auto_collide_space;
111  static dJointGroupID _static_auto_collide_joint_group;
112  static int contactCount;
113  string _collision_event;
114 
115 protected:
116  dSpaceID _id;
117  OdeWorld* _auto_collide_world;
118  dJointGroupID _auto_collide_joint_group;
119 
120 public:
121  static TypeHandle get_class_type() {
122  return _type_handle;
123  }
124  static void init_type() {
126  register_type(_type_handle, "OdeSpace",
127  TypedObject::get_class_type());
128  }
129  virtual TypeHandle get_type() const {
130  return get_class_type();
131  }
132  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
133 
134 private:
135  static TypeHandle _type_handle;
136 
138  GeomSurfaceMap _geom_surface_map;
139 
141  GeomCollideIdMap _geom_collide_id_map;
142 
143 };
144 
145 #include "odeSpace.I"
146 
147 #endif
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Definition: typedObject.cxx:52
bool is_empty() const
Returns true if the ID is 0, meaning the OdeGeom does not point to a valid geom.
Definition: odeGeom.I:24
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:98
dGeomID get_id() const
Returns the underlying dGeomID.
Definition: odeGeom.I:34
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85