Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 10 files). Show all
Unified · Split
| @@ -41,7 +41,7 @@ void MetavoxelSystem::init() { · 40 unmodified lines | ||
| 41 | 41 | _buffer.create(); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | −void MetavoxelSystem::applyEdit(const MetavoxelEdit& edit) { | |
| 44 | +void MetavoxelSystem::applyEdit(const MetavoxelEditMessage& edit) { | |
| 45 | 45 | foreach (MetavoxelClient* client, _clients) { |
| 46 | 46 | client->applyEdit(edit); |
| 47 | 47 | } |
| @@ -190,7 +190,14 @@ MetavoxelClient::MetavoxelClient(const HifiSockAddr& address) : · 142 unmodified lines | ||
| 190 | 190 | _receiveRecords.append(record); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | −void MetavoxelClient::applyEdit(const MetavoxelEdit& edit) { | |
| 193 | +MetavoxelClient::~MetavoxelClient() { | |
| 194 | + // close the session | |
| 195 | + Bitstream& out = _sequencer.startPacket(); | |
| 196 | + out << QVariant::fromValue(CloseSessionMessage()); | |
| 197 | + _sequencer.endPacket(); | |
| 198 | +} | |
| 199 | + | |
| 200 | +void MetavoxelClient::applyEdit(const MetavoxelEditMessage& edit) { | |
| 194 | 201 | // apply immediately to local tree |
| 195 | 202 | edit.apply(_data); |
| 196 | 203 | |
| @@ -227,6 +234,13 @@ void MetavoxelClient::readPacket(Bitstream& in) { · 30 unmodified lines | ||
| 227 | 234 | // record the receipt |
| 228 | 235 | ReceiveRecord record = { _sequencer.getIncomingPacketNumber(), _data }; |
| 229 | 236 | _receiveRecords.append(record); |
| 237 | + | |
| 238 | + // reapply local edits | |
| 239 | + foreach (const DatagramSequencer::HighPriorityMessage& message, _sequencer.getHighPriorityMessages()) { | |
| 240 | + if (message.data.userType() == MetavoxelEditMessage::Type) { | |
| 241 | + message.data.value<MetavoxelEditMessage>().apply(_data); | |
| 242 | + } | |
| 243 | + } | |
| 230 | 244 | } |
| 231 | 245 | |
| 232 | 246 | void MetavoxelClient::clearReceiveRecordsBefore(int index) { |
| @@ -236,7 +250,7 @@ void MetavoxelClient::clearReceiveRecordsBefore(int index) { · 3 unmodified lines | ||
| 236 | 250 | void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) { |
| 237 | 251 | int userType = message.userType(); |
| 238 | 252 | if (userType == MetavoxelDeltaMessage::Type) { |
| 239 | − // readDelta(_data, _receiveRecords.first().data, in); | |
| 253 | + _data.readDelta(_receiveRecords.first().data, in); | |
| 240 | 254 | |
| 241 | 255 | } else if (userType == QMetaType::QVariantList) { |
| 242 | 256 | foreach (const QVariant& element, message.toList()) { |