23 odeworld_cat.debug() << get_type() <<
"(" << _id <<
")" <<
"\n";
37 odeworld_cat.debug() <<
"~" << get_type() <<
"(" << _id <<
")" <<
"\n";
42 if(_num_surfaces > 0) {
43 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(uint8_t 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(uint8_t surface1, uint8_t 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";
107 return _surface_table[true_pos];
111 set_surface_entry(uint8_t pos1, uint8_t pos2,
122 if (bounce > 0.0001) {
123 someMode |= dContactBounce;
125 if (soft_erp > 0.0001) {
126 someMode |= dContactSoftERP;
128 if (soft_cfm > 0.0001) {
129 someMode |= dContactSoftCFM;
132 someMode = someMode | dContactSlip1 | dContactSlip2;
134 new_params.colparams.mode = dContactBounce | dContactSoftCFM | dContactApprox1;
135 new_params.colparams.mu = mu;
136 new_params.colparams.mu2 = mu;
137 new_params.colparams.bounce = bounce;
138 new_params.colparams.bounce_vel = bounce_vel;
139 new_params.colparams.soft_erp = soft_erp;
140 new_params.colparams.soft_cfm = soft_cfm;
141 new_params.colparams.slip1 = slip;
142 new_params.colparams.slip2 = slip;
143 new_params.colparams.motion1 = 0.0;
144 new_params.colparams.motion2 = 0.0;
145 new_params.dampen = dampen;
147 set_surface(pos1, pos2, new_params);
150 set_surface(pos1, pos2, new_params);
152 set_surface(pos2, pos1, new_params);
159 set_dampen_on_bodies(dBodyID id1, dBodyID id2,dReal damp) {
160 if(_body_dampen_map[id1].dampen < damp) {
161 _body_dampen_map[id1].dampen = damp;
163 if(_body_dampen_map[id2].dampen < damp) {
164 _body_dampen_map[id2].dampen = damp;
169 apply_dampening(
float dt,
OdeBody& body) {
170 dBodyID bodyId = body.
get_id();
171 dReal damp = _body_dampen_map[bodyId].dampen;
172 float dampening = 1.00 - (damp * dt);
173 body.set_angular_vel(body.get_angular_vel() * dampening);
174 body.set_linear_vel(body.get_linear_vel() * dampening);
175 _body_dampen_map[bodyId].dampen = 0.0;
180 operator bool ()
const {
181 return (_id !=
nullptr);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dBodyID get_id() const
Returns the underlying dBodyID.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.