History

Working on factoring out the common metavoxel endpoint/client code.

Andrzej Kapolka committed 12 years ago

Commit 4b2d1221 parent 463ac9c13 files · +453 −38Browse files

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

Unified · Split

interface/src/MetavoxelSystem.cpp+16−16
@@ -54,7 +54,7 @@ SharedObjectPointer MetavoxelSystem::findFirstRaySpannerIntersection( · 53 unmodified lines
5454 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
5555 if (node->getType() == NodeType::MetavoxelServer) {
5656 QMutexLocker locker(&node->getMutex());
57− MetavoxelClient* client = static_cast<MetavoxelClient*>(node->getLinkedData());
57+ MetavoxelSystemClient* client = static_cast<MetavoxelSystemClient*>(node->getLinkedData());
5858 if (client) {
5959 float clientDistance;
6060 SharedObjectPointer clientSpanner = client->getData().findFirstRaySpannerIntersection(
@@ -76,7 +76,7 @@ void MetavoxelSystem::applyEdit(const MetavoxelEditMessage& edit, bool reliable) · 15 unmodified lines
7676 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
7777 if (node->getType() == NodeType::MetavoxelServer) {
7878 QMutexLocker locker(&node->getMutex());
79− MetavoxelClient* client = static_cast<MetavoxelClient*>(node->getLinkedData());
79+ MetavoxelSystemClient* client = static_cast<MetavoxelSystemClient*>(node->getLinkedData());
8080 if (client) {
8181 client->applyEdit(edit, reliable);
8282 }
@@ -92,7 +92,7 @@ void MetavoxelSystem::simulate(float deltaTime) { · 9 unmodified lines
9292 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
9393 if (node->getType() == NodeType::MetavoxelServer) {
9494 QMutexLocker locker(&node->getMutex());
95− MetavoxelClient* client = static_cast<MetavoxelClient*>(node->getLinkedData());
95+ MetavoxelSystemClient* client = static_cast<MetavoxelSystemClient*>(node->getLinkedData());
9696 if (client) {
9797 client->simulate(deltaTime);
9898 client->guide(_simulateVisitor);
@@ -153,7 +153,7 @@ void MetavoxelSystem::render() { · 54 unmodified lines
153153 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
154154 if (node->getType() == NodeType::MetavoxelServer) {
155155 QMutexLocker locker(&node->getMutex());
156− MetavoxelClient* client = static_cast<MetavoxelClient*>(node->getLinkedData());
156+ MetavoxelSystemClient* client = static_cast<MetavoxelSystemClient*>(node->getLinkedData());
157157 if (client) {
158158 client->guide(_renderVisitor);
159159 }
@@ -164,7 +164,7 @@ void MetavoxelSystem::render() { · 4 unmodified lines
164164 void MetavoxelSystem::maybeAttachClient(const SharedNodePointer& node) {
165165 if (node->getType() == NodeType::MetavoxelServer) {
166166 QMutexLocker locker(&node->getMutex());
167− node->setLinkedData(new MetavoxelClient(NodeList::getInstance()->nodeWithUUID(node->getUUID())));
167+ node->setLinkedData(new MetavoxelSystemClient(NodeList::getInstance()->nodeWithUUID(node->getUUID())));
168168 }
169169 }
170170
@@ -235,7 +235,7 @@ bool MetavoxelSystem::RenderVisitor::visit(Spanner* spanner, const glm::vec3& cl · 64 unmodified lines
235235 return true;
236236 }
237237
238−MetavoxelClient::MetavoxelClient(const SharedNodePointer& node) :
238+MetavoxelSystemClient::MetavoxelSystemClient(const SharedNodePointer& node) :
239239 _node(node),
240240 _sequencer(byteArrayWithPopulatedHeader(PacketTypeMetavoxelData)) {
241241
@@ -253,7 +253,7 @@ MetavoxelClient::MetavoxelClient(const SharedNodePointer& node) : · 11 unmodified lines
253253 _receiveRecords.append(receiveRecord);
254254 }
255255
256−MetavoxelClient::~MetavoxelClient() {
256+MetavoxelSystemClient::~MetavoxelSystemClient() {
257257 // close the session
258258 Bitstream& out = _sequencer.startPacket();
259259 out << QVariant::fromValue(CloseSessionMessage());
@@ -265,12 +265,12 @@ static MetavoxelLOD getLOD() { · 5 unmodified lines
265265 return MetavoxelLOD(Application::getInstance()->getCamera()->getPosition(), FIXED_LOD_THRESHOLD);
266266 }
267267
268−void MetavoxelClient::guide(MetavoxelVisitor& visitor) {
268+void MetavoxelSystemClient::guide(MetavoxelVisitor& visitor) {
269269 visitor.setLOD(getLOD());
270270 _data.guide(visitor);
271271 }
272272
273−void MetavoxelClient::applyEdit(const MetavoxelEditMessage& edit, bool reliable) {
273+void MetavoxelSystemClient::applyEdit(const MetavoxelEditMessage& edit, bool reliable) {
274274 if (reliable) {
275275 _sequencer.getReliableOutputChannel()->sendMessage(QVariant::fromValue(edit));
276276
@@ -283,7 +283,7 @@ void MetavoxelClient::applyEdit(const MetavoxelEditMessage& edit, bool reliable) · 6 unmodified lines
283283 }
284284 }
285285
286−void MetavoxelClient::simulate(float deltaTime) {
286+void MetavoxelSystemClient::simulate(float deltaTime) {
287287 Bitstream& out = _sequencer.startPacket();
288288
289289 ClientStateMessage state = { getLOD() };
@@ -295,19 +295,19 @@ void MetavoxelClient::simulate(float deltaTime) { · 5 unmodified lines
295295 _sendRecords.append(record);
296296 }
297297
298−int MetavoxelClient::parseData(const QByteArray& packet) {
298+int MetavoxelSystemClient::parseData(const QByteArray& packet) {
299299 // process through sequencer
300300 QMetaObject::invokeMethod(&_sequencer, "receivedDatagram", Q_ARG(const QByteArray&, packet));
301301 Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::METAVOXELS).updateValue(packet.size());
302302 return packet.size();
303303 }
304304
305−void MetavoxelClient::sendData(const QByteArray& data) {
305+void MetavoxelSystemClient::sendData(const QByteArray& data) {
306306 NodeList::getInstance()->writeDatagram(data, _node);
307307 Application::getInstance()->getBandwidthMeter()->outputStream(BandwidthMeter::METAVOXELS).updateValue(data.size());
308308 }
309309
310−void MetavoxelClient::readPacket(Bitstream& in) {
310+void MetavoxelSystemClient::readPacket(Bitstream& in) {
311311 QVariant message;
312312 in >> message;
313313 handleMessage(message, in);
@@ -324,15 +324,15 @@ void MetavoxelClient::readPacket(Bitstream& in) { · 10 unmodified lines
324324 }
325325 }
326326
327−void MetavoxelClient::clearSendRecordsBefore(int index) {
327+void MetavoxelSystemClient::clearSendRecordsBefore(int index) {
328328 _sendRecords.erase(_sendRecords.begin(), _sendRecords.begin() + index + 1);
329329 }
330330
331−void MetavoxelClient::clearReceiveRecordsBefore(int index) {
331+void MetavoxelSystemClient::clearReceiveRecordsBefore(int index) {
332332 _receiveRecords.erase(_receiveRecords.begin(), _receiveRecords.begin() + index + 1);
333333 }
334334
335−void MetavoxelClient::handleMessage(const QVariant& message, Bitstream& in) {
335+void MetavoxelSystemClient::handleMessage(const QVariant& message, Bitstream& in) {
336336 int userType = message.userType();
337337 if (userType == MetavoxelDeltaMessage::Type) {
338338 _data.readDelta(_receiveRecords.first().data, _receiveRecords.first().lod, in, _sendRecords.first().lod);