BitStream

Engine/source/core/stream/bitStream.h

More...

Public Friends

Public Static Functions

Public Functions

BitStream(void * bufPtr, S32 bufSize, S32 maxWriteSize)
bool
_read(const U32 size, void * d)
bool
_write(const U32 size, const void * d)

Gets the position in the stream.

Gets the size of the stream.

bool

Checks to see if this stream has the capability of a given function.

bool
bool
readBits(S32 bitCount, void * bitPtr)
readClassId(U32 classType, U32 classGroup)
bool
readFloat(S32 bitCount)
readInt(S32 bitCount)
readNormalVector(Point3F * vec, S32 bitCount)
readQuat(QuatF * outQuat, U32 bitCount)

Reads a quaternion written with writeQuat.

readRangedF32(F32 min, F32 max, U32 numBits)

Reads a ranged floating point value written with writeRangedF32.

readRangedS32(S32 min, S32 max)

Reads a ranged signed integer written with writeRangedS32.

readRangedU32(U32 rangeStart, U32 rangeEnd)
readSignedInt(S32 bitCount)
readString(char stringBuf)

Reads a string of maximum 255 characters long.

readVector(Point3F * outVec, F32 maxMag, S32 magBits, S32 normalBits)

Reads a compressed vector.

setBit(S32 bitCount, bool set)
setBuffer(void * bufPtr, S32 bufSize, S32 maxSize)
bool
setPosition(const U32 in_newPosition)

Sets the position of the stream. Returns if the new position is valid or not.

setStringBuffer(char buffer)
bool
testBit(S32 bitCount)
writeBits(S32 bitCount, const void * bitPtr)
writeClassId(U32 classId, U32 classType, U32 classGroup)

Use this method to write out values in a concise but ass backwards way...

bool
writeFlag(bool val)
bool
bool
writeFlag(void * val)
writeFloat(F32 f, S32 bitCount)
writeInt(S32 value, S32 bitCount)
writeQuat(const QuatF & quat, U32 bitCount)

Writes a quaternion in a lossy compressed format that is ( bitCount * 3 ) + 2 bits in size.

writeRangedF32(F32 value, F32 min, F32 max, U32 numBits)

Writes a clamped floating point value to the stream with the desired bits of precision.

writeRangedS32(S32 value, S32 min, S32 max)

Writes a clamped signed integer to the stream using an optimal amount of bits for the range.

writeRangedU32(U32 value, U32 rangeStart, U32 rangeEnd)
writeSignedInt(S32 value, S32 bitCount)
writeString(const char * stringBuf, S32 maxLen)

Writes a string to the stream.

writeVector(Point3F vec, F32 maxMag, S32 magBits, S32 normalBits)

Writes a compressed vector as separate magnitude and normal components.

Detailed Description

Protected Attributes

S32 bitNum 
S32 bufSize 
bool error 
S32 maxReadBitNum 
S32 maxWriteBitNum 
Point3F mCompressPoint 
U8 * mDataPtr 
char * stringBuffer 

Public Friends

Public Static Functions

dumbDownNormal(const Point3F & vec, S32 bitCount)

getPacketStream(U32 writeSize)

sendPacketStream(const NetAddress * addr)

Public Functions

BitStream(void * bufPtr, S32 bufSize, S32 maxWriteSize)

_read(const U32 size, void * d)

Reimplemented from: Stream

_write(const U32 size, const void * d)

Reimplemented from: Stream

clear()

clearCompressionPoint()

clearStringBuffer()

getBitPosition()

getBuffer()

getBytePtr()

getCurPos()

getMaxWriteBitNum()

getPosition()

Reimplemented from: Stream

getReadByteSize()

getStreamSize()

Reimplemented from: Stream

getWriteByteSize()

hasCapability(const caps)

Reimplemented from: Stream

isFull()

isValid()

readAffineTransform(MatrixF * )

readBits(BitVector * bitvec)

readBits(S32 bitCount, void * bitPtr)

readClassId(U32 classType, U32 classGroup)

readCompressedPoint(Point3F * p, F32 scale)

readCussedU32()

readFlag()

readFloat(S32 bitCount)

readInt(S32 bitCount)

readNormalVector(Point3F * vec, S32 bitCount)

readQuat(QuatF * outQuat, U32 bitCount)

Reads a quaternion written with writeQuat.

Parameters:

quat

The quaternion that was read.

bitCount

The the storage space for the packed components of the quaternion. Must match the bitCount at write.

readRangedF32(F32 min, F32 max, U32 numBits)

Reads a ranged floating point value written with writeRangedF32.

readRangedS32(S32 min, S32 max)

Reads a ranged signed integer written with writeRangedS32.

readRangedU32(U32 rangeStart, U32 rangeEnd)

readSignedFloat(S32 bitCount)

readSignedInt(S32 bitCount)

readString(char stringBuf)

Reimplemented from: Stream

readVector(Point3F * outVec, F32 maxMag, S32 magBits, S32 normalBits)

Reads a compressed vector.

setBit(S32 bitCount, bool set)

setBuffer(void * bufPtr, S32 bufSize, S32 maxSize)

setCompressionPoint(const Point3F & p)

setCurPos(const U32)

setPosition(const U32 in_newPosition)

Reimplemented from: Stream

setStringBuffer(char buffer)

testBit(S32 bitCount)

writeAffineTransform(const MatrixF & )

writeBits(const BitVector & bitvec)

writeBits(S32 bitCount, const void * bitPtr)

Reimplemented by: InfiniteBitStream

writeClassId(U32 classId, U32 classType, U32 classGroup)

writeCompressedPoint(const Point3F & p, F32 scale)

writeCussedU32(U32 val)

Use this method to write out values in a concise but ass backwards way...

Good for values you expect to be frequently zero, often small. Worst case this will bloat values by nearly 20% (5 extra bits!) Best case you'll get one bit (if it's zero).

This is not so much for efficiency's sake, as to make life painful for people that want to reverse engineer our network or file formats.

writeFlag(bool val)

Reimplemented by: InfiniteBitStream

writeFlag(U32 val)

writeFlag(void * val)

writeFloat(F32 f, S32 bitCount)

writeInt(S32 value, S32 bitCount)

writeNormalVector(const Point3F & vec, S32 bitCount)

writeQuat(const QuatF & quat, U32 bitCount)

Writes a quaternion in a lossy compressed format that is ( bitCount * 3 ) + 2 bits in size.

Parameters:

quat

The normalized quaternion to write.

bitCount

The the storage space for the packed components of the quaternion.

writeRangedF32(F32 value, F32 min, F32 max, U32 numBits)

Writes a clamped floating point value to the stream with the desired bits of precision.

writeRangedS32(S32 value, S32 min, S32 max)

Writes a clamped signed integer to the stream using an optimal amount of bits for the range.

writeRangedU32(U32 value, U32 rangeStart, U32 rangeEnd)

writeSignedFloat(F32 f, S32 bitCount)

writeSignedInt(S32 value, S32 bitCount)

writeString(const char * stringBuf, S32 maxLen)

Reimplemented from: Stream

writeVector(Point3F vec, F32 maxMag, S32 magBits, S32 normalBits)

Writes a compressed vector as separate magnitude and normal components.

The final space used depends on the content of the vector.

  • 1 bit is used to skip over zero length vectors.

  • 1 bit is used to mark if the magnitude exceeds max.

  • The magnitude as: a. magBits if less than maxMag. b. a full 32bit value if greater than maxMag.

  • The normal as a phi and theta sized normalBits+1 and normalBits.