Game Development Community

Bug in writeSignedFloat/readSignedFloat? (bitStream)

by Robert Lee · in Torque Game Engine · 02/03/2005 (9:41 am) · 3 replies

We can't seem to create a particle effect with a gravityCoefficient of zero due to the way the bitStream class reads and writes signed floats.

The following code ...

// ParticleEngine.cc, line 553
gravityCoefficient = stream->readSignedFloat(12) * 10;

... reads in a value of -0.0073260074 that should be 0, so our particles are always floating up in the air just a little bit (which is really noticeable for particles with a long lifespan).

I've temporarily 'fixed' the problem by reading and writing whole 32-bit floats for the gravityCoefficient field of the particle class, but was wondering if there is a better solution (or if this really is a bug that should be fixed).

#1
02/03/2005 (11:52 am)
What is the actual value (test case) that you are sending via writeSignedFloat() ?

The reason I ask is that the implementation for read/writeSignedFloat assumes that your floats are between either 0 and 1.0 or -1.0 and 1.0 (I can't remember which at the moment), and the two functions are not designed to pass floats outside this range, such as 10.325 or -242.373 for example.
#2
02/03/2005 (12:46 pm)
I'm throwing a zero into the writeSignedFloat().
#3
03/07/2005 (9:03 am)
Any updates on this problem?