Panda3D
odeWorld.h
Go to the documentation of this file.
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 
14 #ifndef ODEWORLD_H
15 #define ODEWORLD_H
16 
17 #include "pandabase.h"
18 #include "typedObject.h"
19 #include "luse.h"
20 #include "ode_includes.h"
21 #include "pmap.h"
22 #include "numeric_types.h"
23 
24 #include "ode_includes.h"
25 #include "odeHelperStructs.h"
26 
27 class OdeBody;
28 class OdeJoint;
29 
30 /**
31  *
32  */
33 class EXPCL_PANDAODE OdeWorld : public TypedObject {
34 PUBLISHED:
35  OdeWorld();
36  OdeWorld(const OdeWorld &copy);
37  virtual ~OdeWorld();
38  void destroy();
39  INLINE bool is_empty() const;
40  INLINE dWorldID get_id() const;
41 
42  INLINE void set_gravity(dReal x, dReal y, dReal z);
43  INLINE void set_gravity(const LVecBase3f &vec);
44  INLINE void set_erp(dReal erp);
45  INLINE void set_cfm(dReal cfm);
46  INLINE void set_quick_step_num_iterations(int num);
47 
48  INLINE void set_quick_step_w(dReal over_relaxation);
49  INLINE void set_contact_max_correcting_vel(dReal vel);
50  INLINE void set_contact_surface_layer(dReal depth);
51  INLINE void set_auto_disable_linear_threshold(dReal linear_threshold);
52  INLINE void set_auto_disable_angular_threshold(dReal angular_threshold);
53  INLINE void set_auto_disable_steps(int steps);
54  INLINE void set_auto_disable_time(dReal time);
55  INLINE void set_auto_disable_flag(int do_auto_disable);
56 
57  INLINE LVecBase3f get_gravity() const;
58  INLINE dReal get_erp() const;
59  INLINE dReal get_cfm() const;
60  INLINE int get_quick_step_num_iterations() const;
61  INLINE dReal get_quick_step_w() const;
62  INLINE dReal get_contact_max_correcting_vel() const;
63  INLINE dReal get_contact_surface_layer() const;
64  INLINE dReal get_auto_disable_linear_threshold() const;
65  INLINE dReal get_auto_disable_angular_threshold() const;
66  INLINE int get_auto_disable_steps() const;
67  INLINE dReal get_auto_disable_time() const;
68  INLINE int get_auto_disable_flag() const;
69 
70  INLINE LVecBase3f impulse_to_force(dReal stepsize, \
71  dReal ix, dReal iy, dReal iz);
72  INLINE LVecBase3f impulse_to_force(dReal stepsize, \
73  const LVecBase3f &impulse);
74 
75  INLINE void step(dReal stepsize);
76  INLINE void quick_step(dReal stepsize);
77 
78  INLINE int compare_to(const OdeWorld &other) const;
79 
80  void init_surface_table(uint8_t num_surfaces);
81  // void assign_surface_body(OdeBody& body, int surface);
82  void add_body_dampening(OdeBody& body, int surface);
83  void set_surface_entry(uint8_t pos1, uint8_t pos2,
84  dReal mu,
85  dReal bounce,
86  dReal bounce_vel,
87  dReal soft_erp,
88  dReal soft_cfm,
89  dReal slip,
90  dReal dampen);
91  float apply_dampening(float dt, OdeBody& body);
92 
93  operator bool () const;
94 
95 public:
96  sSurfaceParams& get_surface(uint8_t surface1, uint8_t surface2);
97  void set_surface(int pos1, int pos2, sSurfaceParams& entry);
98  sBodyParams get_surface_body(dBodyID id);
99  void set_dampen_on_bodies(dBodyID id1, dBodyID id2,dReal damp);
100 
101 
102 private:
103  dWorldID _id;
104  sSurfaceParams *_surface_table;
105  uint8_t _num_surfaces;
107  BodyDampenMap _body_dampen_map;
108 
109 
110 
111 
112 public:
113  static TypeHandle get_class_type() {
114  return _type_handle;
115  }
116  static void init_type() {
118  register_type(_type_handle, "OdeWorld",
119  TypedObject::get_class_type());
120  }
121  virtual TypeHandle get_type() const {
122  return get_class_type();
123  }
124  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
125 
126 private:
127  static TypeHandle _type_handle;
128 };
129 
130 #include "odeWorld.I"
131 
132 #endif
TypedObject::init_type
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Definition: typedObject.cxx:44
sBodyParams
Definition: odeHelperStructs.h:11
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap< dBodyID, sBodyParams >
numeric_types.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
compare_to
An STL function object class, this is intended to be used on any ordered collection of class objects ...
Definition: stl_compares.h:73
OdeJoint
Definition: odeJoint.h:51
sSurfaceParams
Definition: odeHelperStructs.h:5
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
typedObject.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
ode_includes.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
odeWorld.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
OdeBody
Definition: odeBody.h:32
OdeWorld
Definition: odeWorld.h:33
TypedObject
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:88