History

Lots of work on metavoxel LODs and spanners.

Andrzej Kapolka committed 12 years ago

Commit 63b4a241 parent 7a182ed10 files · +353 −169Browse files

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

Unified · Split

interface/src/MetavoxelSystem.cpp+19−5
@@ -182,11 +182,16 @@ MetavoxelClient::MetavoxelClient(const SharedNodePointer& node) : · 181 unmodified lines
182182
183183 connect(&_sequencer, SIGNAL(readyToWrite(const QByteArray&)), SLOT(sendData(const QByteArray&)));
184184 connect(&_sequencer, SIGNAL(readyToRead(Bitstream&)), SLOT(readPacket(Bitstream&)));
185+ connect(&_sequencer, SIGNAL(sendAcknowledged(int)), SLOT(clearSendRecordsBefore(int)));
185186 connect(&_sequencer, SIGNAL(receiveAcknowledged(int)), SLOT(clearReceiveRecordsBefore(int)));
186187
188+ // insert the baseline send record
189+ SendRecord sendRecord = { 0 };
190+ _sendRecords.append(sendRecord);
191+
187192 // insert the baseline receive record
188− ReceiveRecord record = { 0, _data };
189− _receiveRecords.append(record);
193+ ReceiveRecord receiveRecord = { 0, _data };
194+ _receiveRecords.append(receiveRecord);
190195 }
191196
192197 MetavoxelClient::~MetavoxelClient() {
@@ -206,9 +211,14 @@ void MetavoxelClient::applyEdit(const MetavoxelEditMessage& edit) { · 13 unmodified lines
206211
207212 void MetavoxelClient::simulate(float deltaTime) {
208213 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) };
210216 out << QVariant::fromValue(state);
211217 _sequencer.endPacket();
218+
219+ // record the send
220+ SendRecord record = { _sequencer.getOutgoingPacketNumber(), state.lod };
221+ _sendRecords.append(record);
212222 }
213223
214224 int MetavoxelClient::parseData(const QByteArray& packet) {
@@ -227,7 +237,7 @@ void MetavoxelClient::readPacket(Bitstream& in) { · 12 unmodified lines
227237 handleMessage(message, in);
228238
229239 // record the receipt
230− ReceiveRecord record = { _sequencer.getIncomingPacketNumber(), _data };
240+ ReceiveRecord record = { _sequencer.getIncomingPacketNumber(), _data, _sendRecords.first().lod };
231241 _receiveRecords.append(record);
232242
233243 // reapply local edits
@@ -238,6 +248,10 @@ void MetavoxelClient::readPacket(Bitstream& in) { · 4 unmodified lines
238248 }
239249 }
240250
251+void MetavoxelClient::clearSendRecordsBefore(int index) {
252+ _sendRecords.erase(_sendRecords.begin(), _sendRecords.begin() + index + 1);
253+}
254+
241255 void MetavoxelClient::clearReceiveRecordsBefore(int index) {
242256 _receiveRecords.erase(_receiveRecords.begin(), _receiveRecords.begin() + index + 1);
243257 }
@@ -245,7 +259,7 @@ void MetavoxelClient::clearReceiveRecordsBefore(int index) { · 1 unmodified line
245259 void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) {
246260 int userType = message.userType();
247261 if (userType == MetavoxelDeltaMessage::Type) {
248− _data.readDelta(_receiveRecords.first().data, in);
262+ _data.readDelta(_receiveRecords.first().data, _receiveRecords.first().lod, in, _sendRecords.first().lod);
249263
250264 } else if (userType == QMetaType::QVariantList) {
251265 foreach (const QVariant& element, message.toList()) {