diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c4739c044d..c36f1a0545 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -221,8 +221,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _audio(&_audioScope, STARTUP_JITTER_SAMPLES), #endif _stopNetworkReceiveThread(false), - _voxelProcessor(this), - _voxelEditSender(this), + _voxelProcessor(), + _voxelEditSender(), _packetCount(0), _packetsPerSecond(0), _bytesPerSecond(0), diff --git a/interface/src/VoxelEditPacketSender.cpp b/interface/src/VoxelEditPacketSender.cpp index c663977268..621e09bd22 100644 --- a/interface/src/VoxelEditPacketSender.cpp +++ b/interface/src/VoxelEditPacketSender.cpp @@ -13,15 +13,12 @@ #include "Application.h" #include "VoxelEditPacketSender.h" -VoxelEditPacketSender::VoxelEditPacketSender(Application* app) : - _app(app) -{ -} - void VoxelEditPacketSender::sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& detail) { + Application* app = Application::getInstance(); + // if the app has Voxels disabled, we don't do any of this... - if (!_app->_renderVoxels->isChecked()) { + if (!app->_renderVoxels->isChecked()) { return; // bail early } @@ -35,7 +32,7 @@ void VoxelEditPacketSender::sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& } // Tell the application's bandwidth meters about what we've sent - _app->_bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(totalBytesSent); + app->_bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(totalBytesSent); } void VoxelEditPacketSender::actuallySendMessage(uint16_t nodeID, unsigned char* bufferOut, ssize_t sizeOut) { @@ -51,6 +48,8 @@ void VoxelEditPacketSender::actuallySendMessage(uint16_t nodeID, unsigned char* } void VoxelEditPacketSender::queueVoxelEditMessage(PACKET_TYPE type, unsigned char* codeColorBuffer, ssize_t length) { + Application* app = Application::getInstance(); + // We want to filter out edit messages for voxel servers based on the server's Jurisdiction // But we can't really do that with a packed message, since each edit message could be destined // for a different voxel server... So we need to actually manage multiple queued packets... one @@ -63,7 +62,7 @@ void VoxelEditPacketSender::queueVoxelEditMessage(PACKET_TYPE type, unsigned cha // we need to get the jurisdiction for this // here we need to get the "pending packet" for this server uint16_t nodeID = node->getNodeID(); - const JurisdictionMap& map = _app->_voxelServerJurisdictions[nodeID]; + const JurisdictionMap& map = app->_voxelServerJurisdictions[nodeID]; if (map.isMyJurisdiction(codeColorBuffer, CHECK_NODE_ONLY) == JurisdictionMap::WITHIN) { EditPacketBuffer& packetBuffer = _pendingEditPackets[nodeID]; packetBuffer._nodeID = nodeID; diff --git a/interface/src/VoxelEditPacketSender.h b/interface/src/VoxelEditPacketSender.h index d3058828e3..e3b0f7d18a 100644 --- a/interface/src/VoxelEditPacketSender.h +++ b/interface/src/VoxelEditPacketSender.h @@ -14,8 +14,6 @@ #include #include // for VoxelDetail -class Application; - /// Used for construction of edit voxel packets class EditPacketBuffer { public: @@ -29,8 +27,6 @@ public: /// Threaded processor for queueing and sending of outbound edit voxel packets. class VoxelEditPacketSender : public PacketSender { public: - VoxelEditPacketSender(Application* app); - /// Send voxel edit message immediately void sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& detail); @@ -46,7 +42,6 @@ private: void initializePacket(EditPacketBuffer& packetBuffer, PACKET_TYPE type); void flushQueue(EditPacketBuffer& packetBuffer); // flushes specific queued packet - Application* _app; std::map _pendingEditPackets; }; #endif // __shared__VoxelEditPacketSender__ diff --git a/interface/src/VoxelPacketProcessor.cpp b/interface/src/VoxelPacketProcessor.cpp index 558037b0bc..86188b2bf8 100644 --- a/interface/src/VoxelPacketProcessor.cpp +++ b/interface/src/VoxelPacketProcessor.cpp @@ -13,18 +13,16 @@ #include "Application.h" #include "VoxelPacketProcessor.h" -VoxelPacketProcessor::VoxelPacketProcessor(Application* app) : - _app(app) { -} - void VoxelPacketProcessor::processPacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength) { - PerformanceWarning warn(_app->_renderPipelineWarnings->isChecked(),"VoxelPacketProcessor::processPacket()"); + Application* app = Application::getInstance(); + + PerformanceWarning warn(app->_renderPipelineWarnings->isChecked(),"VoxelPacketProcessor::processPacket()"); ssize_t messageLength = packetLength; // check to see if the UI thread asked us to kill the voxel tree. since we're the only thread allowed to do that - if (_app->_wantToKillLocalVoxels) { - _app->_voxels.killLocalVoxels(); - _app->_wantToKillLocalVoxels = false; + if (app->_wantToKillLocalVoxels) { + app->_voxels.killLocalVoxels(); + app->_wantToKillLocalVoxels = false; } // note: PACKET_TYPE_VOXEL_STATS can have PACKET_TYPE_VOXEL_DATA or PACKET_TYPE_VOXEL_DATA_MONOCHROME @@ -32,7 +30,7 @@ void VoxelPacketProcessor::processPacket(sockaddr& senderAddress, unsigned char* // then process any remaining bytes as if it was another packet if (packetData[0] == PACKET_TYPE_VOXEL_STATS) { - int statsMessageLength = _app->parseVoxelStats(packetData, messageLength, senderAddress); + int statsMessageLength = app->parseVoxelStats(packetData, messageLength, senderAddress); if (messageLength > statsMessageLength) { packetData += statsMessageLength; messageLength -= statsMessageLength; @@ -44,16 +42,16 @@ void VoxelPacketProcessor::processPacket(sockaddr& senderAddress, unsigned char* } } // fall through to piggyback message - if (_app->_renderVoxels->isChecked()) { + if (app->_renderVoxels->isChecked()) { Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress); if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) { voxelServer->lock(); if (packetData[0] == PACKET_TYPE_ENVIRONMENT_DATA) { - _app->_environment.parseData(&senderAddress, packetData, messageLength); + app->_environment.parseData(&senderAddress, packetData, messageLength); } else { - _app->_voxels.setDataSourceID(voxelServer->getNodeID()); - _app->_voxels.parseData(packetData, messageLength); - _app->_voxels.setDataSourceID(UNKNOWN_NODE_ID); + app->_voxels.setDataSourceID(voxelServer->getNodeID()); + app->_voxels.parseData(packetData, messageLength); + app->_voxels.setDataSourceID(UNKNOWN_NODE_ID); } voxelServer->unlock(); } diff --git a/interface/src/VoxelPacketProcessor.h b/interface/src/VoxelPacketProcessor.h index f55daf5aba..0a89d0d03e 100644 --- a/interface/src/VoxelPacketProcessor.h +++ b/interface/src/VoxelPacketProcessor.h @@ -13,17 +13,9 @@ #include -class Application; - /// Handles processing of incoming voxel packets for the interface application. class VoxelPacketProcessor : public ReceivedPacketProcessor { -public: - VoxelPacketProcessor(Application* app); - protected: virtual void processPacket(sockaddr& senderAddress, unsigned char* packetData, ssize_t packetLength); - -private: - Application* _app; }; #endif // __shared__VoxelPacketProcessor__