History

Basic editing with delta streaming up and running.

Andrzej Kapolka committed 12 years ago

Commit d5695391 parent 62e8cbe10 files · +118 −68Browse files

Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 10 files). Show all

Unified · Split

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