mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 18:32:34 +02:00
adding unpacking
This commit is contained in:
parent
f573645291
commit
7d5dd278a1
5 changed files with 38 additions and 16 deletions
|
@ -45,8 +45,8 @@ void RenderableLineEntityItem::render(RenderArgs* args) {
|
|||
glm::vec3 p1 = {0, 0, 0};
|
||||
glm::vec3 p2 = {1, 1, 0};
|
||||
points<<p1<<p2;
|
||||
// geometryCache->updateVertices(_lineVerticesID, getLinePoints(), lineColor);
|
||||
geometryCache->updateVertices(_lineVerticesID, points, lineColor);
|
||||
geometryCache->updateVertices(_lineVerticesID, getLinePoints(), lineColor);
|
||||
// geometryCache->updateVertices(_lineVerticesID, points, lineColor);
|
||||
|
||||
geometryCache->renderVertices(gpu::LINE_STRIP, _lineVerticesID);
|
||||
glPopMatrix();
|
||||
|
|
|
@ -753,9 +753,8 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
|
|||
}
|
||||
|
||||
if(properties.getType() == EntityTypes::Line){
|
||||
qDebug()<<"****** LINE WIDTH!!!!!!!!!!!!!!! **********" << properties.getLineWidth();
|
||||
APPEND_ENTITY_PROPERTY(PROP_LINE_WIDTH, properties.getLineWidth());
|
||||
// APPEND_ENTITY_PROPERTY(PROP_LINE_POINTS, properties.getLinePoints());
|
||||
APPEND_ENTITY_PROPERTY(PROP_LINE_POINTS, properties.getLinePoints());
|
||||
}
|
||||
|
||||
APPEND_ENTITY_PROPERTY(PROP_MARKETPLACE_ID, properties.getMarketplaceID());
|
||||
|
@ -993,10 +992,8 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
|||
}
|
||||
|
||||
if(properties.getType() == EntityTypes::Line) {
|
||||
qDebug()<<"READING LINE ENTITY";
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_LINE_WIDTH, float, setLineWidth);
|
||||
qDebug()<<"width: "<< properties._lineWidth;
|
||||
// READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_LINE_POINTS, QVector<glm::vec3>, setLinePoints);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_LINE_POINTS, QVector<glm::vec3>, setLinePoints);
|
||||
}
|
||||
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MARKETPLACE_ID, QString, setMarketplaceID);
|
||||
|
@ -1105,6 +1102,7 @@ void EntityItemProperties::markAllChanged() {
|
|||
_sourceUrlChanged = true;
|
||||
|
||||
_lineWidthChanged = true;
|
||||
_linePointsChanged = true;
|
||||
}
|
||||
|
||||
/// The maximum bounding cube for the entity, independent of it's rotation.
|
||||
|
|
|
@ -45,13 +45,14 @@ EntityItemProperties LineEntityItem::getProperties() const {
|
|||
|
||||
EntityItemProperties properties = EntityItem::getProperties(); // get the properties from our base class
|
||||
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(linePoints, getLinePoints);
|
||||
|
||||
properties._color = getXColor();
|
||||
properties._colorChanged = false;
|
||||
|
||||
properties._lineWidth = getLineWidth();
|
||||
properties._lineWidthChanged = false;
|
||||
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(linePoints, getLinePoints);
|
||||
|
||||
|
||||
properties._glowLevel = getGlowLevel();
|
||||
|
@ -91,7 +92,7 @@ int LineEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
|||
|
||||
READ_ENTITY_PROPERTY(PROP_COLOR, rgbColor, setColor);
|
||||
READ_ENTITY_PROPERTY(PROP_LINE_WIDTH, float, setLineWidth);
|
||||
// READ_ENTITY_PROPERTY(PROP_LINE_POINTS, QVector<glm::vec3>, setLinePoints);
|
||||
READ_ENTITY_PROPERTY(PROP_LINE_POINTS, QVector<glm::vec3>, setLinePoints);
|
||||
|
||||
|
||||
return bytesRead;
|
||||
|
@ -103,6 +104,7 @@ EntityPropertyFlags LineEntityItem::getEntityProperties(EncodeBitstreamParams& p
|
|||
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
||||
requestedProperties += PROP_COLOR;
|
||||
requestedProperties += PROP_LINE_WIDTH;
|
||||
requestedProperties += PROP_LINE_POINTS;
|
||||
return requestedProperties;
|
||||
}
|
||||
|
||||
|
@ -118,6 +120,7 @@ void LineEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits
|
|||
|
||||
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
|
||||
APPEND_ENTITY_PROPERTY(PROP_LINE_WIDTH, getLineWidth());
|
||||
APPEND_ENTITY_PROPERTY(PROP_LINE_POINTS, getLinePoints());
|
||||
}
|
||||
|
||||
void LineEntityItem::debugDump() const {
|
||||
|
|
|
@ -325,6 +325,7 @@ bool OctreePacketData::appendValue(uint8_t value) {
|
|||
|
||||
bool OctreePacketData::appendValue(uint16_t value) {
|
||||
const unsigned char* data = (const unsigned char*)&value;
|
||||
|
||||
int length = sizeof(value);
|
||||
bool success = append(data, length);
|
||||
if (success) {
|
||||
|
@ -381,12 +382,19 @@ bool OctreePacketData::appendValue(const glm::vec3& value) {
|
|||
}
|
||||
|
||||
bool OctreePacketData::appendValue(const QVector<glm::vec3>& value){
|
||||
const unsigned char* data = (const unsigned char*)&value;
|
||||
int length = sizeof(value);
|
||||
bool success = append(data, length);
|
||||
if (success){
|
||||
const unsigned char* data = (const unsigned char*)value.data();
|
||||
uint16_t qVecSize = (uint16_t)value.size();
|
||||
int length = qVecSize * sizeof(glm::vec3);
|
||||
const unsigned char* sizePointer = (const unsigned char*)&qVecSize;
|
||||
bool success = append(sizePointer, sizeof(uint16_t));
|
||||
if(success){
|
||||
_bytesOfValues += qVecSize;
|
||||
_totalBytesOfValues += qVecSize;
|
||||
success = append(data, length);
|
||||
if (success){
|
||||
_bytesOfValues += length;
|
||||
_totalBytesOfValues += length;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -462,6 +470,9 @@ bool OctreePacketData::appendRawData(const unsigned char* data, int length) {
|
|||
}
|
||||
return success;
|
||||
}
|
||||
bool OctreePacketData::appendRawData(QByteArray data) {
|
||||
return appendRawData((unsigned char *)data.data(), data.size());
|
||||
}
|
||||
|
||||
quint64 OctreePacketData::_compressContentTime = 0;
|
||||
quint64 OctreePacketData::_compressContentCalls = 0;
|
||||
|
@ -585,3 +596,13 @@ int OctreePacketData::uppackDataFromBytes(const unsigned char* dataBytes, xColor
|
|||
result.blue = dataBytes[BLUE_INDEX];
|
||||
return sizeof(rgbColor);
|
||||
}
|
||||
|
||||
int OctreePacketData::uppackDataFromBytes(const unsigned char *dataBytes, QVector<glm::vec3>& result){
|
||||
uint16_t length;
|
||||
memcpy(&length, dataBytes, sizeof(length));
|
||||
dataBytes+= sizeof(length);
|
||||
qDebug()<<"size of LENGTH: "<<length;
|
||||
QByteArray ba((const char*)dataBytes, length);
|
||||
qDebug()<<"size of BYTE ARRAY: " << ba.size();
|
||||
return 36;
|
||||
}
|
||||
|
|
|
@ -186,8 +186,9 @@ public:
|
|||
|
||||
/// appends raw bytes, might fail if byte would cause packet to be too large
|
||||
bool appendRawData(const unsigned char* data, int length);
|
||||
bool appendRawData(QByteArray);
|
||||
|
||||
/// returns a byte offset from beginning of the uncompressed stream based on offset from end.
|
||||
/// 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
|
||||
int getUncompressedByteOffset(int offsetFromEnd = 0) const { return _bytesInUse - offsetFromEnd; }
|
||||
|
||||
|
@ -231,7 +232,6 @@ public:
|
|||
|
||||
static int uppackDataFromBytes(const unsigned char* dataBytes, float& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); }
|
||||
static int uppackDataFromBytes(const unsigned char* dataBytes, glm::vec3& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); }
|
||||
static int uppackDataFromBytes(const unsigned char* dataBytes, QVector<glm::vec3>& result) {memcpy(&result, dataBytes, sizeof(result)); return sizeof(result);}
|
||||
static int uppackDataFromBytes(const unsigned char* dataBytes, bool& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); }
|
||||
static int uppackDataFromBytes(const unsigned char* dataBytes, quint64& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); }
|
||||
static int uppackDataFromBytes(const unsigned char* dataBytes, uint32_t& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); }
|
||||
|
@ -244,7 +244,7 @@ public:
|
|||
static int uppackDataFromBytes(const unsigned char* dataBytes, QString& result);
|
||||
static int uppackDataFromBytes(const unsigned char* dataBytes, QUuid& result);
|
||||
static int uppackDataFromBytes(const unsigned char* dataBytes, xColor& result);
|
||||
|
||||
static int uppackDataFromBytes(const unsigned char* dataBytes, QVector<glm::vec3>& result);
|
||||
|
||||
private:
|
||||
/// appends raw bytes, might fail if byte would cause packet to be too large
|
||||
|
|
Loading…
Reference in a new issue