mostly debug output changes

This commit is contained in:
Dave Schuyler 2003-07-16 01:07:15 +00:00
parent 91451f3f80
commit acc6620779
3 changed files with 37 additions and 25 deletions

View File

@ -126,8 +126,9 @@ void ActorNode::
write(ostream &out, unsigned int indent) const { write(ostream &out, unsigned int indent) const {
#ifndef NDEBUG //[ #ifndef NDEBUG //[
out.width(indent); out<<""; out<<"ActorNode:\n"; out.width(indent); out<<""; out<<"ActorNode:\n";
out.width(indent+2); out<<""; out<<"_mass_center "<<_mass_center<<"\n";
out.width(indent+2); out<<""; out<<"_ok_to_callback "<<_ok_to_callback<<"\n"; out.width(indent+2); out<<""; out<<"_ok_to_callback "<<_ok_to_callback<<"\n";
out.width(indent+2); out<<""; out<<"_mass_center\n";
_mass_center->write(out, indent+4);
PhysicalNode::write(out, indent+2); PhysicalNode::write(out, indent+2);
#endif //] NDEBUG #endif //] NDEBUG
} }

View File

@ -31,9 +31,27 @@ extern EXPCL_PANDAPHYSICS void init_libphysics();
#ifndef NDEBUG //[ #ifndef NDEBUG //[
// Non-release build: // Non-release build:
#define PHYSICS_DEBUG #define PHYSICS_DEBUG
#define physics_debug(msg) \
if (physics_cat.is_debug()) { \
physics_cat->debug() << msg << endl; \
} else {}
#define physics_info(msg) \
physics_cat->info() << msg << endl
#define physics_warning(msg) \
physics_cat->warning() << msg << endl
#else //][ #else //][
// Release build: // Release build:
#undef PHYSICS_DEBUG #undef PHYSICS_DEBUG
#define physics_debug(msg) ((void)0)
#define physics_info(msg) ((void)0)
#define physics_warning(msg) ((void)0)
#endif //] #endif //]
#define audio_error(msg) \
audio_cat->error() << msg << endl
#endif // CONFIG_PHYSICS_H #endif // CONFIG_PHYSICS_H

View File

@ -61,49 +61,42 @@ apply_linear_force(ColliderDef &def, const LVector3f &force) {
ActorNode *actor=DCAST(ActorNode, def._node); ActorNode *actor=DCAST(ActorNode, def._node);
float friction=0.9f; float friction=0.9f;
LVector3f vel=actor->get_physics_object()->get_velocity(); LVector3f vel=actor->get_physics_object()->get_velocity();
physics_debug("apply_linear_force() {");
physics_debug(" vel "<<vel<<" len "<<vel.length());
physics_debug(" force "<<force<<" len "<<force.length());
LVector3f old_vel=vel; LVector3f old_vel=vel;
LVector3f adjustment=force; LVector3f adjustment=force;
adjustment.normalize(); adjustment.normalize();
adjustment*=adjustment.dot(vel); adjustment*=adjustment.dot(vel);
#if 0 //[ physics_debug(" adjustment "<<adjustment<<" len "<<adjustment.length());
float initialVelMag=vel.length();
float temp=((vel-c)*friction).length();
if ((vel-c)[2]) {
cerr<<"\n\napply_linear_force"
<<"\n old_vel "<<old_vel<<" len "<<old_vel.length()
<<"\n force "<<force<<" len "<<force.length()
<<"\n adjustment "<<adjustment<<" len"<<adjustment.length()
<<"\n vel "<<vel-c<<" len "<<(vel-c).length()
<<"\n friction "<<friction
<<"\n vel "<<((vel-c)*friction)<<" len "<<temp
<<"\n initialVelLen > "<<(initialVelMag>temp)
<<endl;
if (initialVelMag<temp) {
cerr<<"\n*************************************"<<endl;
}
}
#endif //]
float angle=adjustment.dot(vel); float angle=adjustment.dot(vel);
vel-=adjustment; vel-=adjustment;
physics_debug(" vel "<<vel<<" len "<<vel.length());
physics_debug(" angle "<<angle);
if (angle<=0.0f) { if (angle<=0.0f) {
// ...avoid amplifying the velocity by checking to see // ...avoid amplifying the velocity by checking to see
// that the adjustment and the velocity are more than // that the adjustment and the velocity are more than
// right-angles (i.e. obtuse angle). // right-angles (i.e. obtuse angle).
float almostStationary=1.0f; float almostStationary=0.1f;
if (vel.dot(vel)>almostStationary) { if (vel.length()>almostStationary) {
friction*=0.01f; cerr<<"not almostStationary"<<endl; physics_debug(" vel > almostStationary");
friction*=0.01f;
} }
//vel*=1.0f-friction; //vel*=1.0f-friction;
} }
LVector3f new_vel=vel; #ifndef NDEBUG //[
if (vel.length() > old_vel.length()) { if (vel.length() > old_vel.length()) {
cerr<<"\nvel.length() > old_vel.length() "<<vel.length()<<" > "<<old_vel.length()<<endl; physics_debug(" vel.length() > old_vel.length() "<<vel.length()<<" > "<<old_vel.length());
} }
if (vel.length() > 10.0f) { if (vel.length() > 10.0f) {
cerr<<"\nvel.length() > 10.0f "<<vel.length()<<endl; physics_debug(" vel.length() > 10.0f "<<vel.length());
} }
#endif //]
physics_debug(" force "<<force<<" len "<<force.length());
physics_debug(" vel "<<vel<<" len "<<vel.length());
physics_debug("}");
actor->set_contact_vector(force); actor->set_contact_vector(force);
actor->get_physics_object()->set_velocity(vel); actor->get_physics_object()->set_velocity(vel);
} }