odeWorld.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // Filename: odeWorld.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. #ifndef ODEWORLD_H
  15. #define ODEWORLD_H
  16. #include "pandabase.h"
  17. #include "typedObject.h"
  18. #include "luse.h"
  19. #include "ode_includes.h"
  20. #include "pmap.h"
  21. #include "numeric_types.h"
  22. #include "ode_includes.h"
  23. #include "odeHelperStructs.h"
  24. class OdeBody;
  25. class OdeJoint;
  26. ////////////////////////////////////////////////////////////////////
  27. // Class : OdeWorld
  28. // Description :
  29. ////////////////////////////////////////////////////////////////////
  30. class EXPCL_PANDAODE OdeWorld : public TypedObject {
  31. PUBLISHED:
  32. OdeWorld();
  33. OdeWorld(const OdeWorld &copy);
  34. virtual ~OdeWorld();
  35. void destroy();
  36. INLINE bool is_empty() const;
  37. INLINE dWorldID get_id() const;
  38. INLINE void set_gravity(dReal x, dReal y, dReal z);
  39. INLINE void set_gravity(const LVecBase3f &vec);
  40. INLINE void set_erp(dReal erp);
  41. INLINE void set_cfm(dReal cfm);
  42. INLINE void set_quick_step_num_iterations(int num);
  43. INLINE void set_quick_step_w(dReal over_relaxation);
  44. INLINE void set_contact_max_correcting_vel(dReal vel);
  45. INLINE void set_contact_surface_layer(dReal depth);
  46. INLINE void set_auto_enable_depth_sf1(int auto_enable_depth);
  47. INLINE void set_auto_disable_linear_threshold(dReal linear_threshold);
  48. INLINE void set_auto_disable_angular_threshold(dReal angular_threshold);
  49. INLINE void set_auto_disable_steps(int steps);
  50. INLINE void set_auto_disable_time(dReal time);
  51. INLINE void set_auto_disable_flag(int do_auto_disable);
  52. INLINE LVecBase3f get_gravity() const;
  53. INLINE dReal get_erp() const;
  54. INLINE dReal get_cfm() const;
  55. INLINE int get_quick_step_num_iterations() const;
  56. INLINE dReal get_quick_step_w() const;
  57. INLINE dReal get_contact_max_correcting_vel() const;
  58. INLINE dReal get_contact_surface_layer() const;
  59. INLINE int get_auto_enable_depth_sf1() const;
  60. INLINE dReal get_auto_disable_linear_threshold() const;
  61. INLINE dReal get_auto_disable_angular_threshold() const;
  62. INLINE int get_auto_disable_steps() const;
  63. INLINE dReal get_auto_disable_time() const;
  64. INLINE int get_auto_disable_flag() const;
  65. INLINE LVecBase3f impulse_to_force(dReal stepsize, \
  66. dReal ix, dReal iy, dReal iz);
  67. INLINE LVecBase3f impulse_to_force(dReal stepsize, \
  68. const LVecBase3f &impulse);
  69. INLINE void step(dReal stepsize);
  70. INLINE void quick_step(dReal stepsize);
  71. INLINE void step_fast1(dReal stepsize, int maxiterations);
  72. INLINE int compare_to(const OdeWorld &other) const;
  73. void init_surface_table(PN_uint8 num_surfaces);
  74. //void assign_surface_body(OdeBody& body, int surface);
  75. void add_body_dampening(OdeBody& body, int surface);
  76. void set_surface_entry(PN_uint8 pos1, PN_uint8 pos2,
  77. dReal mu,
  78. dReal bounce,
  79. dReal bounce_vel,
  80. dReal soft_erp,
  81. dReal soft_cfm,
  82. dReal slip,
  83. dReal dampen);
  84. float apply_dampening(float dt, OdeBody& body);
  85. operator bool () const;
  86. public:
  87. INLINE sSurfaceParams& get_surface(PN_uint8 surface1, PN_uint8 surface2);
  88. INLINE void set_surface(int pos1, int pos2, sSurfaceParams& entry);
  89. INLINE sBodyParams get_surface_body(dBodyID id);
  90. INLINE void set_dampen_on_bodies(dBodyID id1, dBodyID id2,dReal damp);
  91. private:
  92. dWorldID _id;
  93. sSurfaceParams *_surface_table;
  94. PN_uint8 _num_surfaces;
  95. typedef pmap<dBodyID, sBodyParams> BodyDampenMap;
  96. BodyDampenMap _body_dampen_map;
  97. public:
  98. static TypeHandle get_class_type() {
  99. return _type_handle;
  100. }
  101. static void init_type() {
  102. TypedObject::init_type();
  103. register_type(_type_handle, "OdeWorld",
  104. TypedObject::get_class_type());
  105. }
  106. virtual TypeHandle get_type() const {
  107. return get_class_type();
  108. }
  109. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  110. private:
  111. static TypeHandle _type_handle;
  112. };
  113. #include "odeWorld.I"
  114. #endif