15 #include "config_ode.h" 24 odeworld_cat.debug() << get_type() <<
"(" << _id <<
")" <<
"\n";
38 odeworld_cat.debug() <<
"~" << get_type() <<
"(" << _id <<
")" <<
"\n";
43 if(_num_surfaces > 0) {
44 delete _surface_table;
60 add_body_dampening(
OdeBody& body,
int surface) {
61 _body_dampen_map[body.
get_id()].dampen = 0.0f;
66 init_surface_table(PN_uint8 num_surfaces) {
69 _num_surfaces = num_surfaces;
74 odeworld_cat.debug() <<
" pos1 " << pos1 <<
" pos2 " << pos2 <<
" num surfaces " << (int)_num_surfaces <<
" endline\n";
75 if((_num_surfaces <= pos1) || (_num_surfaces <= pos2)) {
76 odeworld_cat.error() <<
"surface position exceeds size of surface table, set num_surface in initSurfaceTable higher." <<
"\n";
79 int true_pos = (pos1 * _num_surfaces) + pos2;
80 _surface_table[true_pos].colparams.mode = entry.colparams.mode;
81 _surface_table[true_pos].colparams.mu = entry.colparams.mu;
82 _surface_table[true_pos].colparams.mu2 = entry.colparams.mu2;
83 _surface_table[true_pos].colparams.bounce = entry.colparams.bounce;
84 _surface_table[true_pos].colparams.bounce_vel = entry.colparams.bounce_vel;
85 _surface_table[true_pos].colparams.soft_cfm = entry.colparams.soft_cfm;
86 _surface_table[true_pos].colparams.motion1 = entry.colparams.motion1;
87 _surface_table[true_pos].colparams.motion2 = entry.colparams.motion2;
88 _surface_table[true_pos].colparams.slip1 = entry.colparams.slip1;
89 _surface_table[true_pos].colparams.slip2 = entry.colparams.slip2;
90 _surface_table[true_pos].dampen = entry.dampen;
95 get_surface(PN_uint8 surface1, PN_uint8 surface2) {
97 if(surface1 >= surface2) {
98 true_pos = (surface1 * _num_surfaces) + surface2;
100 true_pos = (surface2 * _num_surfaces) + surface1;
102 if((_num_surfaces <= surface1) || (_num_surfaces <= surface2)) {
103 odeworld_cat.error() <<
"surface position exceeds size of surface table, set num_surface in initSurfaceTable higher." <<
"\n";
106 return _surface_table[true_pos];
110 set_surface_entry(PN_uint8 pos1, PN_uint8 pos2,
121 if (bounce > 0.0001) {
122 someMode |= dContactBounce;
124 if (soft_erp > 0.0001) {
125 someMode |= dContactSoftERP;
127 if (soft_cfm > 0.0001) {
128 someMode |= dContactSoftCFM;
131 someMode = someMode | dContactSlip1 | dContactSlip2;
133 new_params.colparams.mode = dContactBounce | dContactSoftCFM | dContactApprox1;
134 new_params.colparams.mu = mu;
135 new_params.colparams.mu2 = mu;
136 new_params.colparams.bounce = bounce;
137 new_params.colparams.bounce_vel = bounce_vel;
138 new_params.colparams.soft_erp = soft_erp;
139 new_params.colparams.soft_cfm = soft_cfm;
140 new_params.colparams.slip1 = slip;
141 new_params.colparams.slip2 = slip;
142 new_params.colparams.motion1 = 0.0;
143 new_params.colparams.motion2 = 0.0;
144 new_params.dampen = dampen;
146 set_surface(pos1, pos2, new_params);
149 set_surface(pos1, pos2, new_params);
151 set_surface(pos2, pos1, new_params);
158 set_dampen_on_bodies(dBodyID id1, dBodyID id2,dReal damp) {
159 if(_body_dampen_map[id1].dampen < damp) {
160 _body_dampen_map[id1].dampen = damp;
162 if(_body_dampen_map[id2].dampen < damp) {
163 _body_dampen_map[id2].dampen = damp;
168 apply_dampening(
float dt,
OdeBody& body) {
169 dBodyID bodyId = body.
get_id();
170 dReal damp = _body_dampen_map[bodyId].dampen;
171 float dampening = 1.00 - (damp * dt);
172 body.set_angular_vel(body.get_angular_vel() * dampening);
173 body.set_linear_vel(body.get_linear_vel() * dampening);
174 _body_dampen_map[bodyId].dampen = 0.0;
179 operator bool ()
const {
180 return (_id != NULL);
dBodyID get_id() const
Returns the underlying dBodyID.
TypeHandle is the identifier used to differentiate C++ class types.