mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 03:09:45 +02:00
More work on deltas.
This commit is contained in:
parent
31443e4f4e
commit
3504cc6d5a
4 changed files with 26 additions and 5 deletions
|
@ -112,7 +112,7 @@ void MetavoxelSession::receivedData(const QByteArray& data, const HifiSockAddr&
|
|||
void MetavoxelSession::sendDelta() {
|
||||
Bitstream& out = _sequencer.startPacket();
|
||||
out << QVariant::fromValue(MetavoxelDeltaMessage());
|
||||
_server->getData()->writeDelta(*_sendRecords.first().data, out);
|
||||
writeDelta(_server->getData(), _sendRecords.first().data, out);
|
||||
_sequencer.endPacket();
|
||||
|
||||
// record the send
|
||||
|
|
|
@ -234,7 +234,7 @@ void MetavoxelClient::clearReceiveRecordsBefore(int index) {
|
|||
void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) {
|
||||
int userType = message.userType();
|
||||
if (userType == MetavoxelDeltaMessage::Type) {
|
||||
_data->readDelta(*_receiveRecords.first().data, in);
|
||||
readDelta(_data, _receiveRecords.first().data, in);
|
||||
|
||||
} else if (userType == QMetaType::QVariantList) {
|
||||
foreach (const QVariant& element, message.toList()) {
|
||||
|
|
|
@ -125,6 +125,24 @@ void MetavoxelData::decrementRootReferenceCounts() {
|
|||
}
|
||||
}
|
||||
|
||||
void writeDelta(const MetavoxelDataPointer& data, const MetavoxelDataPointer& reference, Bitstream& out) {
|
||||
if (data == reference) {
|
||||
out << false;
|
||||
return;
|
||||
}
|
||||
out << true;
|
||||
data->writeDelta(*reference, out);
|
||||
}
|
||||
|
||||
void readDelta(MetavoxelDataPointer& data, const MetavoxelDataPointer& reference, Bitstream& in) {
|
||||
bool changed;
|
||||
in >> changed;
|
||||
if (changed) {
|
||||
data.detach();
|
||||
data->readDelta(*reference, in);
|
||||
}
|
||||
}
|
||||
|
||||
MetavoxelNode::MetavoxelNode(const AttributeValue& attributeValue) : _referenceCount(1) {
|
||||
_attributeValue = attributeValue.copy();
|
||||
for (int i = 0; i < CHILD_COUNT; i++) {
|
||||
|
|
|
@ -23,14 +23,11 @@
|
|||
|
||||
class QScriptContext;
|
||||
|
||||
class MetavoxelData;
|
||||
class MetavoxelNode;
|
||||
class MetavoxelPath;
|
||||
class MetavoxelVisitation;
|
||||
class MetavoxelVisitor;
|
||||
|
||||
typedef QExplicitlySharedDataPointer<MetavoxelData> MetavoxelDataPointer;
|
||||
|
||||
/// The base metavoxel representation shared between server and client.
|
||||
class MetavoxelData : public QSharedData {
|
||||
public:
|
||||
|
@ -64,6 +61,12 @@ private:
|
|||
QHash<AttributePointer, MetavoxelNode*> _roots;
|
||||
};
|
||||
|
||||
typedef QExplicitlySharedDataPointer<MetavoxelData> MetavoxelDataPointer;
|
||||
|
||||
void writeDelta(const MetavoxelDataPointer& data, const MetavoxelDataPointer& reference, Bitstream& out);
|
||||
|
||||
void readDelta(MetavoxelDataPointer& data, const MetavoxelDataPointer& reference, Bitstream& in);
|
||||
|
||||
/// A single node within a metavoxel layer.
|
||||
class MetavoxelNode {
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue