writeBits vs writeFloat

Expanding and utilizing the engine via C++.
6 posts Page 1 of 1
Hodo33
Posts: 47
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Tue Oct 30, 2018 3:39 pm
I have implemented the door resource from Joshua Jewell later modified by Jeff Loveless. It has been working fine but I get occasional crash in bitstream.cpp
void BitStream::writeBits(S32 bitCount, const void *bitPtr) where bitCount has no value therefore -> crash

From the Door.cpp file
bstream->writeBits( 32, &rotation ); not sure how it would fail.

So the question is should I change this over to a writeFloat since rotation is a float value?
In the engine (3.8) there is only one other place writeBits is even used so is that being depricated in favor of a writeFloat ?
Not sure how that mechanism works other than to save net traffic sending only the number of bits needed and ignoring the lower part of the mantissa ... anyone guide me here?
Thanks...
LoLJester
Posts: 71
Joined: Thu Aug 13, 2015 5:58 pm
 
by LoLJester » Tue Oct 30, 2018 6:21 pm
Although, I don't know about this resource, yes, I think you could do that too. But, if rotation is a vector of type VectorF/Point3F, then you would have to pass each value of the vector (rotation.x, rotation.y, rotation.z) individually as a float.
Hodo33
Posts: 47
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Tue Oct 30, 2018 7:15 pm
It is declared as a F32. As I said the function writeBits and readBits is in the engine but only used in one place other than this door code so I was curious why it is not used and should I change it .. thanks for the reply...
LoLJester
Posts: 71
Joined: Thu Aug 13, 2015 5:58 pm
 
by LoLJester » Thu Nov 01, 2018 2:53 am
I would change it and see if the same error persists.
What's the error that you get?
JeffR
Steering Committee
Steering Committee
Posts: 863
Joined: Tue Feb 03, 2015 9:49 pm
 
by JeffR » Mon Nov 05, 2018 4:12 pm
It currently only gets used with ShapeBase's mesh hiding via passing in a BitVector.

Idea being you can have a list of bits(to signify which submeshes are shown or hidden) and quickly network it down as a set(among other possible uses).

In it's current state, it could probably considered a pretty specialized function now. I'd guess that the original resource used it because it was more common at the time.

If it's a F32, then I'd just suggest what LOLJester said. Used write/readFloat and that should take care of it.
Hodo33
Posts: 47
Joined: Fri Dec 29, 2017 4:34 pm
by Hodo33 » Tue Nov 06, 2018 2:17 am
Thanks for the input, makes sense.
So write float has a bit count parameter what part is being truncated if less than 32? single precision float = 1 sign, 7 exponent, 24 mantissa yes?
The float in question is a rotation ( I assume normalized 0 - 1 or radian) does the engine lerp the rotation ? Not sure how that mechanism works..
Thanks for any help
6 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests