odeSpace.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file odeSpace.h
  10. * @author joswilso
  11. * @date 2006-12-27
  12. */
  13. #ifndef ODESPACE_H
  14. #define ODESPACE_H
  15. #include "pandabase.h"
  16. #include "typedObject.h"
  17. #include "luse.h"
  18. #include "bitMask.h"
  19. // included for collision tests
  20. #include "odeWorld.h"
  21. #include "odeJointGroup.h"
  22. #include "ode_includes.h"
  23. class OdeGeom;
  24. class OdeTriMeshGeom;
  25. class OdeSimpleSpace;
  26. class OdeHashSpace;
  27. class OdeQuadTreeSpace;
  28. /**
  29. *
  30. */
  31. class EXPCL_PANDAODE OdeSpace : public TypedObject {
  32. friend class OdeGeom;
  33. static const int MAX_CONTACTS;
  34. public:
  35. OdeSpace(dSpaceID id);
  36. PUBLISHED:
  37. virtual ~OdeSpace();
  38. void destroy();
  39. INLINE bool is_empty() const;
  40. INLINE void set_cleanup(int mode);
  41. INLINE int get_cleanup() const;
  42. int query(const OdeGeom& geom) const;
  43. int query(const OdeSpace& space) const;
  44. INLINE int get_num_geoms() const;
  45. INLINE void get_AABB(LVecBase3f &min, LVecBase3f &max) const;
  46. EXTENSION(INLINE PyObject *get_AA_bounds() const);
  47. INLINE int is_space();
  48. INLINE int get_class() const;
  49. INLINE void set_category_bits(const BitMask32 &bits);
  50. INLINE void set_collide_bits(const BitMask32 &bits);
  51. INLINE BitMask32 get_category_bits();
  52. INLINE BitMask32 get_collide_bits();
  53. INLINE void enable();
  54. INLINE void disable();
  55. INLINE int is_enabled();
  56. void set_auto_collide_world(OdeWorld&);
  57. void set_auto_collide_joint_group(OdeJointGroup&);
  58. void add(OdeGeom& geom);
  59. void add(OdeSpace& space);
  60. void remove(OdeGeom& geom);
  61. void remove(OdeSpace& space);
  62. void clean();
  63. OdeGeom get_geom(int i); // Not INLINE because of forward declaration
  64. // static int get_surface_type(OdeSpace * self, dGeomID o1);
  65. INLINE OdeSpace get_space() const;
  66. virtual void write(std::ostream &out = std::cout, unsigned int indent=0) const;
  67. operator bool () const;
  68. OdeSimpleSpace convert_to_simple_space() const;
  69. OdeHashSpace convert_to_hash_space() const;
  70. OdeQuadTreeSpace convert_to_quad_tree_space() const;
  71. EXTENSION(PyObject *convert() const);
  72. EXTENSION(INLINE PyObject *get_converted_geom(int i) const);
  73. EXTENSION(INLINE PyObject *get_converted_space() const);
  74. void auto_collide();
  75. EXTENSION(int collide(PyObject* arg, PyObject* near_callback));
  76. int set_collide_id(int collide_id, dGeomID id);
  77. int set_collide_id(OdeGeom& geom, int collide_id);
  78. void set_surface_type( int surface_type, dGeomID id);
  79. void set_surface_type(OdeGeom& geom, int surface_type);
  80. int get_surface_type(dGeomID o1);
  81. int get_surface_type(OdeGeom& geom);
  82. int get_collide_id(dGeomID o1);
  83. int get_collide_id(OdeGeom& geom);
  84. INLINE void set_collision_event(const std::string &event_name);
  85. INLINE std::string get_collision_event();
  86. public:
  87. static void auto_callback(void*, dGeomID, dGeomID);
  88. INLINE dSpaceID get_id() const;
  89. static OdeWorld* _static_auto_collide_world;
  90. static OdeSpace* _static_auto_collide_space;
  91. static dJointGroupID _static_auto_collide_joint_group;
  92. static int contactCount;
  93. std::string _collision_event;
  94. protected:
  95. dSpaceID _id;
  96. OdeWorld* _auto_collide_world;
  97. dJointGroupID _auto_collide_joint_group;
  98. public:
  99. static TypeHandle get_class_type() {
  100. return _type_handle;
  101. }
  102. static void init_type() {
  103. TypedObject::init_type();
  104. register_type(_type_handle, "OdeSpace",
  105. TypedObject::get_class_type());
  106. }
  107. virtual TypeHandle get_type() const {
  108. return get_class_type();
  109. }
  110. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  111. private:
  112. static TypeHandle _type_handle;
  113. typedef pmap<dGeomID, int> GeomSurfaceMap;
  114. GeomSurfaceMap _geom_surface_map;
  115. typedef pmap<dGeomID, int> GeomCollideIdMap;
  116. GeomCollideIdMap _geom_collide_id_map;
  117. };
  118. #include "odeSpace.I"
  119. #endif