mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 21:26:25 +02:00
cleaned up const semantics and DRYed up appendBitMask
This commit is contained in:
parent
0f66f4c1bd
commit
cd1d3765a9
6 changed files with 6 additions and 13 deletions
|
@ -60,7 +60,7 @@ bool shouldDo(float desiredInterval, float deltaTime) {
|
||||||
return randFloat() < deltaTime / desiredInterval;
|
return randFloat() < deltaTime / desiredInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void outputBufferBits(unsigned char* buffer, int length, bool withNewLine) {
|
void outputBufferBits(const unsigned char* buffer, int length, bool withNewLine) {
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
outputBits(buffer[i], false);
|
outputBits(buffer[i], false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ bool randomBoolean();
|
||||||
|
|
||||||
bool shouldDo(float desiredInterval, float deltaTime);
|
bool shouldDo(float desiredInterval, float deltaTime);
|
||||||
|
|
||||||
void outputBufferBits(unsigned char* buffer, int length, bool withNewLine = true);
|
void outputBufferBits(const unsigned char* buffer, int length, bool withNewLine = true);
|
||||||
void outputBits(unsigned char byte, bool withNewLine = true);
|
void outputBits(unsigned char byte, bool withNewLine = true);
|
||||||
void printVoxelCode(unsigned char* voxelCode);
|
void printVoxelCode(unsigned char* voxelCode);
|
||||||
int numberOfOnes(unsigned char byte);
|
int numberOfOnes(unsigned char byte);
|
||||||
|
|
|
@ -105,7 +105,7 @@ void VoxelNodeData::resetVoxelPacket() {
|
||||||
_voxelPacketWaiting = false;
|
_voxelPacketWaiting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelNodeData::writeToPacket(unsigned char* buffer, int bytes) {
|
void VoxelNodeData::writeToPacket(const unsigned char* buffer, int bytes) {
|
||||||
memcpy(_voxelPacketAt, buffer, bytes);
|
memcpy(_voxelPacketAt, buffer, bytes);
|
||||||
_voxelPacketAvailableBytes -= bytes;
|
_voxelPacketAvailableBytes -= bytes;
|
||||||
_voxelPacketAt += bytes;
|
_voxelPacketAt += bytes;
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
|
|
||||||
void resetVoxelPacket(); // resets voxel packet to after "V" header
|
void resetVoxelPacket(); // resets voxel packet to after "V" header
|
||||||
|
|
||||||
void writeToPacket(unsigned char* buffer, int bytes); // writes to end of packet
|
void writeToPacket(const unsigned char* buffer, int bytes); // writes to end of packet
|
||||||
|
|
||||||
const unsigned char* getPacket() const { return _voxelPacket; }
|
const unsigned char* getPacket() const { return _voxelPacket; }
|
||||||
int getPacketLength() const { return (MAX_VOXEL_PACKET_SIZE - _voxelPacketAvailableBytes); }
|
int getPacketLength() const { return (MAX_VOXEL_PACKET_SIZE - _voxelPacketAvailableBytes); }
|
||||||
|
|
|
@ -106,14 +106,7 @@ void VoxelPacket::endLevel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VoxelPacket::appendBitMask(unsigned char bitmask) {
|
bool VoxelPacket::appendBitMask(unsigned char bitmask) {
|
||||||
bool success = false;
|
return append(bitmask);
|
||||||
if (_bytesAvailable > 0) {
|
|
||||||
_buffer[_bytesInUse] = bitmask;
|
|
||||||
_bytesInUse++;
|
|
||||||
_bytesAvailable--;
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VoxelPacket::appendColor(const nodeColor& color) {
|
bool VoxelPacket::appendColor(const nodeColor& color) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
int getUncompressedByteOffset(int offsetFromEnd = 0) const { return _bytesInUse - offsetFromEnd; }
|
int getUncompressedByteOffset(int offsetFromEnd = 0) const { return _bytesInUse - offsetFromEnd; }
|
||||||
|
|
||||||
/// get access to the finalized data (it may be compressed or rewritten into optimal form)
|
/// get access to the finalized data (it may be compressed or rewritten into optimal form)
|
||||||
unsigned char* getFinalizedData() { return &_buffer[0]; }
|
const unsigned char* getFinalizedData() { return &_buffer[0]; }
|
||||||
/// get size of the finalized data (it may be compressed or rewritten into optimal form)
|
/// get size of the finalized data (it may be compressed or rewritten into optimal form)
|
||||||
int getFinalizedSize() const { return _bytesInUse; }
|
int getFinalizedSize() const { return _bytesInUse; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue