Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 10 files). Show all
Unified · Split
| @@ -182,11 +182,16 @@ MetavoxelClient::MetavoxelClient(const SharedNodePointer& node) : · 181 unmodified lines | |||
| 182 | 182 | ||
| 183 | connect(&_sequencer, SIGNAL(readyToWrite(const QByteArray&)), SLOT(sendData(const QByteArray&))); | 183 | connect(&_sequencer, SIGNAL(readyToWrite(const QByteArray&)), SLOT(sendData(const QByteArray&))); |
| 184 | connect(&_sequencer, SIGNAL(readyToRead(Bitstream&)), SLOT(readPacket(Bitstream&))); | 184 | connect(&_sequencer, SIGNAL(readyToRead(Bitstream&)), SLOT(readPacket(Bitstream&))); |
| 185 | connect(&_sequencer, SIGNAL(sendAcknowledged(int)), SLOT(clearSendRecordsBefore(int))); | ||
| 185 | connect(&_sequencer, SIGNAL(receiveAcknowledged(int)), SLOT(clearReceiveRecordsBefore(int))); | 186 | connect(&_sequencer, SIGNAL(receiveAcknowledged(int)), SLOT(clearReceiveRecordsBefore(int))); |
| 186 | 187 | ||
| 188 | // insert the baseline send record | ||
| 189 | SendRecord sendRecord = { 0 }; | ||
| 190 | _sendRecords.append(sendRecord); | ||
| 191 | |||
| 187 | // insert the baseline receive record | 192 | // insert the baseline receive record |
| 188 | ReceiveRecord record = { 0, _data }; | 193 | ReceiveRecord receiveRecord = { 0, _data }; |
| 189 | _receiveRecords.append(record); | 194 | _receiveRecords.append(receiveRecord); |
| 190 | } | 195 | } |
| 191 | 196 | ||
| 192 | MetavoxelClient::~MetavoxelClient() { | 197 | MetavoxelClient::~MetavoxelClient() { |
| @@ -206,9 +211,14 @@ void MetavoxelClient::applyEdit(const MetavoxelEditMessage& edit) { · 13 unmodified lines | |||
| 206 | 211 | ||
| 207 | void MetavoxelClient::simulate(float deltaTime) { | 212 | void MetavoxelClient::simulate(float deltaTime) { |
| 208 | Bitstream& out = _sequencer.startPacket(); | 213 | Bitstream& out = _sequencer.startPacket(); |
| 209 | ClientStateMessage state = { Application::getInstance()->getCamera()->getPosition() }; | 214 | const float FIXED_LOD_THRESHOLD = 0.0001f; |
| 215 | ClientStateMessage state = { MetavoxelLOD(Application::getInstance()->getCamera()->getPosition(), FIXED_LOD_THRESHOLD) }; | ||
| 210 | out << QVariant::fromValue(state); | 216 | out << QVariant::fromValue(state); |
| 211 | _sequencer.endPacket(); | 217 | _sequencer.endPacket(); |
| 218 | |||
| 219 | // record the send | ||
| 220 | SendRecord record = { _sequencer.getOutgoingPacketNumber(), state.lod }; | ||
| 221 | _sendRecords.append(record); | ||
| 212 | } | 222 | } |
| 213 | 223 | ||
| 214 | int MetavoxelClient::parseData(const QByteArray& packet) { | 224 | int MetavoxelClient::parseData(const QByteArray& packet) { |
| @@ -227,7 +237,7 @@ void MetavoxelClient::readPacket(Bitstream& in) { · 12 unmodified lines | |||
| 227 | handleMessage(message, in); | 237 | handleMessage(message, in); |
| 228 | 238 | ||
| 229 | // record the receipt | 239 | // record the receipt |
| 230 | ReceiveRecord record = { _sequencer.getIncomingPacketNumber(), _data }; | 240 | ReceiveRecord record = { _sequencer.getIncomingPacketNumber(), _data, _sendRecords.first().lod }; |
| 231 | _receiveRecords.append(record); | 241 | _receiveRecords.append(record); |
| 232 | 242 | ||
| 233 | // reapply local edits | 243 | // reapply local edits |
| @@ -238,6 +248,10 @@ void MetavoxelClient::readPacket(Bitstream& in) { · 4 unmodified lines | |||
| 238 | } | 248 | } |
| 239 | } | 249 | } |
| 240 | 250 | ||
| 251 | void MetavoxelClient::clearSendRecordsBefore(int index) { | ||
| 252 | _sendRecords.erase(_sendRecords.begin(), _sendRecords.begin() + index + 1); | ||
| 253 | } | ||
| 254 | |||
| 241 | void MetavoxelClient::clearReceiveRecordsBefore(int index) { | 255 | void MetavoxelClient::clearReceiveRecordsBefore(int index) { |
| 242 | _receiveRecords.erase(_receiveRecords.begin(), _receiveRecords.begin() + index + 1); | 256 | _receiveRecords.erase(_receiveRecords.begin(), _receiveRecords.begin() + index + 1); |
| 243 | } | 257 | } |
| @@ -245,7 +259,7 @@ void MetavoxelClient::clearReceiveRecordsBefore(int index) { · 1 unmodified line | |||
| 245 | void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) { | 259 | void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) { |
| 246 | int userType = message.userType(); | 260 | int userType = message.userType(); |
| 247 | if (userType == MetavoxelDeltaMessage::Type) { | 261 | if (userType == MetavoxelDeltaMessage::Type) { |
| 248 | _data.readDelta(_receiveRecords.first().data, in); | 262 | _data.readDelta(_receiveRecords.first().data, _receiveRecords.first().lod, in, _sendRecords.first().lod); |
| 249 | 263 | ||
| 250 | } else if (userType == QMetaType::QVariantList) { | 264 | } else if (userType == QMetaType::QVariantList) { |
| 251 | foreach (const QVariant& element, message.toList()) { | 265 | foreach (const QVariant& element, message.toList()) { |