mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 14:15:28 +02:00
Revert "cleaned up some comments and code"
This reverts commit 99c427c97d
.
This commit is contained in:
parent
99c427c97d
commit
0f66f4c1bd
6 changed files with 19 additions and 81 deletions
|
@ -60,7 +60,7 @@ bool shouldDo(float desiredInterval, float deltaTime) {
|
|||
return randFloat() < deltaTime / desiredInterval;
|
||||
}
|
||||
|
||||
void outputBufferBits(const unsigned char* buffer, int length, bool withNewLine) {
|
||||
void outputBufferBits(unsigned char* buffer, int length, bool withNewLine) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
outputBits(buffer[i], false);
|
||||
}
|
||||
|
@ -71,18 +71,18 @@ void outputBufferBits(const unsigned char* buffer, int length, bool withNewLine)
|
|||
|
||||
void outputBits(unsigned char byte, bool withNewLine) {
|
||||
if (isalnum(byte)) {
|
||||
printf("[ %d (%c): ", byte, byte);
|
||||
qDebug("[ %d (%c): ", byte, byte);
|
||||
} else {
|
||||
printf("[ %d (0x%x): ", byte, byte);
|
||||
qDebug("[ %d (0x%x): ", byte, byte);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
printf("%d", byte >> (7 - i) & 1);
|
||||
qDebug("%d", byte >> (7 - i) & 1);
|
||||
}
|
||||
printf(" ] ");
|
||||
qDebug(" ] ");
|
||||
|
||||
if (withNewLine) {
|
||||
printf("\n");
|
||||
qDebug("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ bool randomBoolean();
|
|||
|
||||
bool shouldDo(float desiredInterval, float deltaTime);
|
||||
|
||||
void outputBufferBits(const unsigned char* buffer, int length, bool withNewLine = true);
|
||||
void outputBufferBits(unsigned char* buffer, int length, bool withNewLine = true);
|
||||
void outputBits(unsigned char byte, bool withNewLine = true);
|
||||
void printVoxelCode(unsigned char* voxelCode);
|
||||
int numberOfOnes(unsigned char byte);
|
||||
|
|
|
@ -105,7 +105,7 @@ void VoxelNodeData::resetVoxelPacket() {
|
|||
_voxelPacketWaiting = false;
|
||||
}
|
||||
|
||||
void VoxelNodeData::writeToPacket(const unsigned char* buffer, int bytes) {
|
||||
void VoxelNodeData::writeToPacket(unsigned char* buffer, int bytes) {
|
||||
memcpy(_voxelPacketAt, buffer, bytes);
|
||||
_voxelPacketAvailableBytes -= bytes;
|
||||
_voxelPacketAt += bytes;
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
|
||||
void resetVoxelPacket(); // resets voxel packet to after "V" header
|
||||
|
||||
void writeToPacket(const unsigned char* buffer, int bytes); // writes to end of packet
|
||||
void writeToPacket(unsigned char* buffer, int bytes); // writes to end of packet
|
||||
|
||||
const unsigned char* getPacket() const { return _voxelPacket; }
|
||||
int getPacketLength() const { return (MAX_VOXEL_PACKET_SIZE - _voxelPacketAvailableBytes); }
|
||||
|
|
|
@ -16,10 +16,6 @@ void VoxelPacket::reset() {
|
|||
_bytesInUse = 0;
|
||||
_bytesAvailable = MAX_VOXEL_PACKET_SIZE;
|
||||
_subTreeAt = 0;
|
||||
_uncompressedData.clear();
|
||||
|
||||
//printf("VoxelPacket::reset()... ");
|
||||
//debugCompareBuffers();
|
||||
}
|
||||
|
||||
VoxelPacket::~VoxelPacket() {
|
||||
|
@ -29,24 +25,10 @@ bool VoxelPacket::append(const unsigned char* data, int length) {
|
|||
bool success = false;
|
||||
|
||||
if (length <= _bytesAvailable) {
|
||||
int priorBytesInUse = _bytesInUse;
|
||||
|
||||
memcpy(&_buffer[_bytesInUse], data, length);
|
||||
//QByteArray newData((const char*)data, length);
|
||||
//_uncompressedData.append(newData);
|
||||
|
||||
_uncompressedData.resize(_bytesInUse+length);
|
||||
char* writeable = _uncompressedData.data();
|
||||
memcpy(&writeable[_bytesInUse], data, length);
|
||||
|
||||
_bytesInUse += length;
|
||||
_bytesAvailable -= length;
|
||||
success = true;
|
||||
|
||||
|
||||
//printf("VoxelPacket::append(data, length=%d... priorBytesInUse=%d)... ", length, priorBytesInUse);
|
||||
debugCompareBuffers();
|
||||
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -55,16 +37,9 @@ bool VoxelPacket::append(unsigned char byte) {
|
|||
bool success = false;
|
||||
if (_bytesAvailable > 0) {
|
||||
_buffer[_bytesInUse] = byte;
|
||||
//_uncompressedData.append(byte);
|
||||
_uncompressedData[_bytesInUse] = byte;
|
||||
|
||||
_bytesInUse++;
|
||||
_bytesAvailable--;
|
||||
success = true;
|
||||
|
||||
//printf("VoxelPacket::append(byte)... ");
|
||||
debugCompareBuffers();
|
||||
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -73,12 +48,7 @@ bool VoxelPacket::updatePriorBitMask(int offset, unsigned char bitmask) {
|
|||
bool success = false;
|
||||
if (offset >= 0 && offset < _bytesInUse) {
|
||||
_buffer[offset] = bitmask;
|
||||
_uncompressedData.replace(offset, sizeof(bitmask), (const char*)&bitmask, sizeof(bitmask));
|
||||
success = true;
|
||||
|
||||
//printf("VoxelPacket::updatePriorBitMask()... ");
|
||||
debugCompareBuffers();
|
||||
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -87,12 +57,7 @@ bool VoxelPacket::updatePriorBytes(int offset, const unsigned char* replacementB
|
|||
bool success = false;
|
||||
if (length >= 0 && offset >= 0 && ((offset + length) <= _bytesInUse)) {
|
||||
memcpy(&_buffer[offset], replacementBytes, length);
|
||||
_uncompressedData.replace(offset, length, (const char*)replacementBytes, length);
|
||||
success = true;
|
||||
|
||||
//printf("VoxelPacket::updatePriorBytes(offset=%d length=%d)...", offset, length);
|
||||
debugCompareBuffers();
|
||||
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -141,12 +106,17 @@ void VoxelPacket::endLevel() {
|
|||
}
|
||||
|
||||
bool VoxelPacket::appendBitMask(unsigned char bitmask) {
|
||||
printf("VoxelPacket::appendBitMask()...\n");
|
||||
return append(bitmask);
|
||||
bool success = false;
|
||||
if (_bytesAvailable > 0) {
|
||||
_buffer[_bytesInUse] = bitmask;
|
||||
_bytesInUse++;
|
||||
_bytesAvailable--;
|
||||
success = true;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
bool VoxelPacket::appendColor(const nodeColor& color) {
|
||||
printf("VoxelPacket::appendColor()...\n");
|
||||
// eventually we can make this use a dictionary...
|
||||
bool success = false;
|
||||
const int BYTES_PER_COLOR = 3;
|
||||
|
@ -183,22 +153,5 @@ void VoxelPacket::uncompressPacket() {
|
|||
}
|
||||
***/
|
||||
|
||||
void VoxelPacket::debugCompareBuffers() const {
|
||||
const unsigned char* buffer = &_buffer[0];
|
||||
const unsigned char* byteArray = (const unsigned char*)_uncompressedData.constData();
|
||||
|
||||
if (memcmp(buffer, byteArray, _bytesInUse) == 0) {
|
||||
//printf("VoxelPacket::debugCompareBuffers()... they match...\n");
|
||||
//printf("\n");
|
||||
} else {
|
||||
printf("VoxelPacket::debugCompareBuffers()... THEY DON'T MATCH <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
|
||||
printf("_buffer=");
|
||||
outputBufferBits(buffer, _bytesInUse);
|
||||
printf("_uncompressedData=");
|
||||
outputBufferBits(byteArray, _bytesInUse);
|
||||
printf("VoxelPacket::debugCompareBuffers()... THEY DON'T MATCH <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
#ifndef __hifi__VoxelPacket__
|
||||
#define __hifi__VoxelPacket__
|
||||
|
||||
#include <QByteArray>
|
||||
|
||||
#include <SharedUtil.h>
|
||||
#include "VoxelConstants.h"
|
||||
#include "VoxelNode.h"
|
||||
|
@ -68,20 +66,12 @@ public:
|
|||
int getUncompressedByteOffset(int offsetFromEnd = 0) const { return _bytesInUse - offsetFromEnd; }
|
||||
|
||||
/// get access to the finalized data (it may be compressed or rewritten into optimal form)
|
||||
const unsigned char* getFinalizedData() {
|
||||
debugCompareBuffers();
|
||||
return &_buffer[0];
|
||||
//return (const unsigned char*)_uncompressedData.constData();
|
||||
}
|
||||
unsigned char* getFinalizedData() { return &_buffer[0]; }
|
||||
/// get size of the finalized data (it may be compressed or rewritten into optimal form)
|
||||
int getFinalizedSize() const { return _bytesInUse; }
|
||||
|
||||
/// get pointer to the start of uncompressed stream buffer
|
||||
const unsigned char* getUncompressedData() {
|
||||
debugCompareBuffers();
|
||||
return &_buffer[0];
|
||||
//return (const unsigned char*)_uncompressedData.constData();
|
||||
}
|
||||
const unsigned char* getUncompressedData() { return &_buffer[0]; }
|
||||
/// the size of the packet in uncompressed form
|
||||
int getUncompressedSize() { return _bytesInUse; }
|
||||
|
||||
|
@ -95,15 +85,10 @@ private:
|
|||
/// append a single byte, might fail if byte would cause packet to be too large
|
||||
bool append(unsigned char byte);
|
||||
|
||||
QByteArray _uncompressedData;
|
||||
unsigned char _buffer[MAX_VOXEL_PACKET_SIZE];
|
||||
|
||||
int _bytesInUse;
|
||||
int _bytesAvailable;
|
||||
int _subTreeAt;
|
||||
|
||||
void debugCompareBuffers() const;
|
||||
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__VoxelPacket__) */
|
Loading…
Reference in a new issue