Handles packing of the data portion of PacketType_OCTREE_DATA messages. More...
#include <OctreePacketData.h>
Public Member Functions | |
void | changeSettings (bool enableCompression=false, unsigned int targetSize=MAX_OCTREE_PACKET_DATA_SIZE) |
change compression and target size settings | |
void | reset () |
reset completely, all data is discarded | |
bool | startSubTree (const unsigned char *octcode=NULL) |
LevelDetails | startLevel () |
starts a level marker. returns an opaque key which can be used to discard the level | |
void | discardLevel (LevelDetails key) |
discards all content back to a previous marker key | |
bool | endLevel (LevelDetails key) |
bool | appendBitMask (unsigned char bitmask) |
appends a bitmask to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | updatePriorBitMask (int offset, unsigned char bitmask) |
bool | reserveBitMask () |
reserves space in the stream for a future bitmask, may fail if new data stream is too long to fit in packet | |
bool | reserveBytes (int numberOfBytes) |
bool | releaseReservedBitMask () |
releases previously reserved space in the stream. | |
bool | releaseReservedBytes (int numberOfBytes) |
releases previously reserved space in the stream. | |
bool | updatePriorBytes (int offset, const unsigned char *replacementBytes, int length) |
bool | appendColor (colorPart red, colorPart green, colorPart blue) |
appends a color to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const nodeColor &color) |
appends a color to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (uint8_t value) |
appends a unsigned 8 bit int to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (uint16_t value) |
appends a unsigned 16 bit int to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (uint32_t value) |
appends a unsigned 32 bit int to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (quint64 value) |
appends a unsigned 64 bit int to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (float value) |
appends a float value to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const glm::vec2 &value) |
appends a vec2 to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const glm::vec3 &value) |
appends a non-position vector to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const glm::u8vec3 &value) |
appends a color to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const QVector< glm::vec3 > &value) |
appends a QVector of vec3s to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const QVector< glm::quat > &value) |
appends a QVector of quats to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const QVector< float > &value) |
appends a QVector of floats to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const QVector< bool > &value) |
appends a QVector of bools to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const QVector< QUuid > &value) |
appends a QVector of QUuids to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const glm::quat &value) |
appends a packed quat to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (bool value) |
appends a bool value to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const QString &string) |
appends a string value to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const QUuid &uuid) |
appends a uuid value to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const QByteArray &bytes) |
appends a QByteArray value to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const AACube &aaCube) |
appends an AACube value to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendValue (const QRect &rect) |
appends an QRect value to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendPosition (const glm::vec3 &value) |
appends a position to the end of the stream, may fail if new data stream is too long to fit in packet | |
bool | appendRawData (const unsigned char *data, int length) |
appends raw bytes, might fail if byte would cause packet to be too large | |
int | getUncompressedByteOffset (int offsetFromEnd=0) const |
const unsigned char * | getFinalizedData () |
get access to the finalized data (it may be compressed or rewritten into optimal form) | |
int | getFinalizedSize () |
get size of the finalized data (it may be compressed or rewritten into optimal form) | |
const unsigned char * | getUncompressedData (int byteOffset=0) |
get pointer to the uncompressed stream buffer at the byteOffset | |
int | getUncompressedSize () |
the size of the packet in uncompressed form | |
void | setUncompressedSize (int newSize) |
update the size of the packet in uncompressed form | |
bool | hasContent () const |
has some content been written to the packet | |
void | loadFinalizedContent (const unsigned char *data, int length) |
load finalized content to allow access to decoded content for parsing | |
bool | isCompressed () const |
returns whether or not zlib compression enabled on finalization | |
unsigned int | getTargetSize () const |
returns the target uncompressed size | |
int | getReservedBytes () |
the number of bytes in the packet currently reserved | |
void | debugContent () |
displays contents for debugging | |
Static Public Member Functions | |
static quint64 | getCompressContentCalls () |
total time spent compressing content | |
static quint64 | getTotalBytesOfOctalCodes () |
total calls to compress content | |
static quint64 | getTotalBytesOfBitMasks () |
total bytes for octal codes | |
static quint64 | getTotalBytesOfColor () |
total bytes of bitmasks | |
static int | unpackDataFromBytes (const unsigned char *dataBytes, float &result) |
total bytes of color | |
Handles packing of the data portion of PacketType_OCTREE_DATA messages.
bool OctreePacketData::endLevel | ( | LevelDetails | key | ) |
ends a level, and performs any expensive finalization. may fail if finalization creates a stream which is too large if the finalization would fail, the packet will automatically discard the previous level.
|
inline |
returns a byte offset from beginning of the uncompressed stream based on offset from end. Positive offsetFromEnd returns that many bytes before the end of uncompressed stream
bool OctreePacketData::reserveBytes | ( | int | numberOfBytes | ) |
reserves space in the stream for a future number of bytes, may fail if new data stream is too long to fit in packet. The caller must call releaseReservedBytes() before attempting to fill the bytes.
bool OctreePacketData::startSubTree | ( | const unsigned char * | octcode = NULL | ) |
call to begin encoding a subtree starting at this point, this will append the octcode to the uncompressed stream at this point. May fail if new datastream is too long. In failure case the stream remains in it's previous state.
bool OctreePacketData::updatePriorBitMask | ( | int | offset, |
unsigned char | bitmask | ||
) |
updates the value of a bitmask from a previously appended portion of the uncompressed stream, might fail if the new bitmask would cause packet to be less compressed, or if offset was out of range.
bool OctreePacketData::updatePriorBytes | ( | int | offset, |
const unsigned char * | replacementBytes, | ||
int | length | ||
) |
updates the uncompressed content of the stream starting at byte offset with replacementBytes for length. Might fail if the new bytes would cause packet to be less compressed, or if offset and length was out of range.