23 if (odeworld_cat.is_debug()) {
24 odeworld_cat.debug() << get_type() <<
"(" << _id <<
")" <<
"\n";
39 if (odeworld_cat.is_debug()) {
40 odeworld_cat.debug() <<
"~" << get_type() <<
"(" << _id <<
")" <<
"\n";
46 if(_num_surfaces > 0) {
47 delete _surface_table;
64 add_body_dampening(
OdeBody& body,
int surface) {
65 _body_dampen_map[body.
get_id()].dampen = 0.0f;
70 init_surface_table(uint8_t num_surfaces) {
73 _num_surfaces = num_surfaces;
78 if (odeworld_cat.is_debug()) {
79 odeworld_cat.debug() <<
" pos1 " << pos1 <<
" pos2 " << pos2 <<
" num surfaces " << (int)_num_surfaces <<
" endline\n";
81 if((_num_surfaces <= pos1) || (_num_surfaces <= pos2)) {
82 odeworld_cat.error() <<
"surface position exceeds size of surface table, set num_surface in initSurfaceTable higher." <<
"\n";
85 int true_pos = (pos1 * _num_surfaces) + pos2;
86 _surface_table[true_pos].colparams.mode = entry.colparams.mode;
87 _surface_table[true_pos].colparams.mu = entry.colparams.mu;
88 _surface_table[true_pos].colparams.mu2 = entry.colparams.mu2;
89 _surface_table[true_pos].colparams.bounce = entry.colparams.bounce;
90 _surface_table[true_pos].colparams.bounce_vel = entry.colparams.bounce_vel;
91 _surface_table[true_pos].colparams.soft_cfm = entry.colparams.soft_cfm;
92 _surface_table[true_pos].colparams.motion1 = entry.colparams.motion1;
93 _surface_table[true_pos].colparams.motion2 = entry.colparams.motion2;
94 _surface_table[true_pos].colparams.slip1 = entry.colparams.slip1;
95 _surface_table[true_pos].colparams.slip2 = entry.colparams.slip2;
96 _surface_table[true_pos].dampen = entry.dampen;
101 get_surface(uint8_t surface1, uint8_t surface2) {
103 if(surface1 >= surface2) {
104 true_pos = (surface1 * _num_surfaces) + surface2;
106 true_pos = (surface2 * _num_surfaces) + surface1;
108 if((_num_surfaces <= surface1) || (_num_surfaces <= surface2)) {
109 odeworld_cat.error() <<
"surface position exceeds size of surface table, set num_surface in initSurfaceTable higher." <<
"\n";
113 return _surface_table[true_pos];
117 set_surface_entry(uint8_t pos1, uint8_t pos2,
128 if (bounce > 0.0001) {
129 someMode |= dContactBounce;
131 if (soft_erp > 0.0001) {
132 someMode |= dContactSoftERP;
134 if (soft_cfm > 0.0001) {
135 someMode |= dContactSoftCFM;
138 someMode = someMode | dContactSlip1 | dContactSlip2;
140 new_params.colparams.mode = dContactBounce | dContactSoftCFM | dContactApprox1;
141 new_params.colparams.mu = mu;
142 new_params.colparams.mu2 = mu;
143 new_params.colparams.bounce = bounce;
144 new_params.colparams.bounce_vel = bounce_vel;
145 new_params.colparams.soft_erp = soft_erp;
146 new_params.colparams.soft_cfm = soft_cfm;
147 new_params.colparams.slip1 = slip;
148 new_params.colparams.slip2 = slip;
149 new_params.colparams.motion1 = 0.0;
150 new_params.colparams.motion2 = 0.0;
151 new_params.dampen = dampen;
153 set_surface(pos1, pos2, new_params);
156 set_surface(pos1, pos2, new_params);
158 set_surface(pos2, pos1, new_params);
165 set_dampen_on_bodies(dBodyID id1, dBodyID id2,dReal damp) {
166 if(_body_dampen_map[id1].dampen < damp) {
167 _body_dampen_map[id1].dampen = damp;
169 if(_body_dampen_map[id2].dampen < damp) {
170 _body_dampen_map[id2].dampen = damp;
175 apply_dampening(
float dt,
OdeBody& body) {
176 dBodyID bodyId = body.
get_id();
177 dReal damp = _body_dampen_map[bodyId].dampen;
178 float dampening = 1.00 - (damp * dt);
179 body.set_angular_vel(body.get_angular_vel() * dampening);
180 body.set_linear_vel(body.get_linear_vel() * dampening);
181 _body_dampen_map[bodyId].dampen = 0.0;
186 operator bool ()
const {
187 return (_id !=
nullptr);
dBodyID get_id() const
Returns the underlying dBodyID.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.