odeWorld.h 3.8 KB

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