Author Topic: Bugs & small API change requests  (Read 2514 times)

cmusch

  • Guest
Bugs & small API change requests
« on: September 06, 2006, 03:03:59 AM »
Hi!

After working some time with your lib, there are a few issues I would like to tell you about:


BitStream::ReadNormQuat():
w = sqrt(1.0f - x*x - y*y - z*z);
Numerical errors can cause the expression in the sqrt to be negative, yielding undefined results or a floating point exception. A simple max(0,expr) would prevent this.

BitStream::WriteOrthMatrix():

   qw = sqrt( 1 + m00 + m11 + m22  ) / 2;
   qx = sqrt( 1 + m00 - m11 - m22  ) / 2;
   qy = sqrt( 1 - m00 + m11 - m22  ) / 2;
   qz = sqrt( 1 - m00 - m11 + m22  ) / 2;
Same as above.


   qx = _copysign( qx, m21 - m12 );
   qy = _copysign( qy, m02 - m20 );
   qz = _copysign( qz, m20 - m02 ); // should be  qz = _copysign( qz, m10 - m01 );
There are two typos in there (they are on the web page you got the code from, too, but are corrected in a later post)
The expressions should be symmetrical.

 StringCompressor::EncodeString():
This should take a const char* as input.

RakPeer::PlayerIDToDottedIP():
IMHO this should be made a static function. It would be convenient to have access to this function without having a peer object around.


Hope I could help
christian

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: Bugs & small API change requests
« Reply #1 on: September 06, 2006, 11:07:56 AM »
That's a big help!  Thanks.

I made the changes except:

In RakNet 3.0:
The EncodeString function already takes a const char *.
PlayerIDToDottedIP is removed.  Use the ToString method of the PlayerID (or SystemAddress in 3.0) struct.