-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Eddy Petrișor wrote: > Hello, > > Steve, thanks for the additional info, I didn't realised the value was > ....e+306 until you pointed it out. > > I will look into the physics engine to see what is wrong and try to > understand what is wrong. It appears that upstream is quite aware of the > issue that it exists, but they don't know why it happens: > > ---------8<--------------- > //Due to a bug in the physic engine > //sometimes, angle==infinite (according to gdb) ?? > GetSpeed(norme, angle); > > while(angle < -M_PI) angle += M_PI; > while(angle > M_PI) angle -= M_PI; > > ---------8<---------------
I have looked deeper into this issue, and (of course, still a problem just in front of me - the lack of coding in the last year starts to show its hideous face). I have seen this from the start, but I have payed too much attention. The issue is that angle and norme are declared locally instead of the class. The physics engine is quite ok from the GNU POV. I will be experimenting with some asserts in the code before providing a final patch. In care anyone cares, here is the current (debugging) state: - --- wormux-0.7.4.orig/src/object/physics.cpp +++ wormux-0.7.4/src/object/physics.cpp @@ -192,6 +192,12 @@ break; default: + assert(m_motion_type==NoMotion); + /* + printf ("\n> motion type:%d\n",m_motion_type); + printf ("> angle :%d\n",angle); + printf ("> norm :%d\n\n",norm); + */ break ; } } - --- wormux-0.7.4.orig/src/weapon/gnu.h +++ wormux-0.7.4/src/weapon/gnu.h @@ -39,6 +39,7 @@ int m_sens; int save_x, save_y; double angle; + double norme; public: Gnu(ExplosiveWeaponConfig& cfg); void Shoot(double strength); - --- wormux-0.7.4.orig/src/weapon/gnu.cpp +++ wormux-0.7.4/src/weapon/gnu.cpp @@ -47,6 +47,8 @@ save_y=GetY(); double angle = ActiveTeam().crosshair.GetAngleRad(); + assert(angle < M_PI); + assert(angle > -M_PI); if(angle<M_PI/2 && angle>-M_PI/2) m_sens = 1; @@ -58,7 +60,6 @@ { WeaponProjectile::Refresh(); - - double norme, angle; //When we hit the ground, jump ! if(!IsMoving()&& !FootsInVacuum()) { @@ -78,10 +79,23 @@ //Due to a bug in the physic engine //sometimes, angle==infinite (according to gdb) ?? + //No, is just the angle and norm should not be redefined locally + //Is so much easier to blame others, ain't it? :-) GetSpeed(norme, angle); + /* while(angle < -M_PI) angle += M_PI; + if(angle > M_PI) + { + long int chunk = (floor(angle/M_PI)) * M_PI ; + angle -= chunk ; + } while(angle > M_PI) angle -= M_PI; + */ + if (angle < M_PI) printf ("OUCH: angle=%f\n",angle); + assert(angle < M_PI); + if (angle > -M_PI) printf ("OUCH: angle=%f\n",angle); + assert(angle >= -M_PI); angle *= 180.0 / M_PI; angle /= 2.0; - ---------------8<----------- - -- Regards, EddyP ============================================= "Imagination is more important than knowledge" A.Einstein -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFUdpTY8Chqv3NRNoRAh6zAJ44q1BhY6LCYZyWTKthX/newJO55gCdGUFr e2rCby1HIaqPI/IMP9uPGZg= =qroI -----END PGP SIGNATURE----- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]