History

Merge pull request #1295 from ZappoMan/compressed_packets

Major improvements to Voxel Packet "packing" and compression

Philip Rosedale committed 12 years ago

Commit 14129cd2 parents 3ec785c a3b69c127 files · +1554 −450Browse files

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

Unified · Split

interface/src/Application.cpp+46−18
@@ -686,9 +686,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 685 unmodified lines
686686 break;
687687
688688 case Qt::Key_C:
689− if (isShifted) {
690− Menu::getInstance()->triggerOption(MenuOption::OcclusionCulling);
691− } else if (_nudgeStarted) {
689+ if (_nudgeStarted) {
692690 _nudgeGuidePosition.y -= _mouseVoxel.s;
693691 } else {
694692 _myAvatar.setDriveKeys(DOWN, 1);
@@ -1526,7 +1524,6 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { · 831 unmodified lines
15261524 SendVoxelsOperationArgs* args = (SendVoxelsOperationArgs*)extraData;
15271525 if (node->isColored()) {
15281526 const unsigned char* nodeOctalCode = node->getOctalCode();
1529−
15301527 unsigned char* codeColorBuffer = NULL;
15311528 int codeLength = 0;
15321529 int bytesInCode = 0;
@@ -1547,10 +1544,9 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { · 14 unmodified lines
15471544 }
15481545
15491546 // copy the colors over
1550− codeColorBuffer[bytesInCode + RED_INDEX ] = node->getColor()[RED_INDEX ];
1547+ codeColorBuffer[bytesInCode + RED_INDEX] = node->getColor()[RED_INDEX];
15511548 codeColorBuffer[bytesInCode + GREEN_INDEX] = node->getColor()[GREEN_INDEX];
1552− codeColorBuffer[bytesInCode + BLUE_INDEX ] = node->getColor()[BLUE_INDEX ];
1553−
1549+ codeColorBuffer[bytesInCode + BLUE_INDEX] = node->getColor()[BLUE_INDEX];
15541550 getInstance()->_voxelEditSender.queueVoxelEditMessage(PACKET_TYPE_SET_VOXEL_DESTRUCTIVE,
15551551 codeColorBuffer, codeAndColorLength);
15561552
@@ -1614,7 +1610,6 @@ void Application::pasteVoxelsToOctalCode(const unsigned char* octalCodeDestinati · 57 unmodified lines
16141610 // the server as an set voxel message, this will also rebase the voxels to the new location
16151611 SendVoxelsOperationArgs args;
16161612 args.newBaseOctCode = octalCodeDestination;
1617−
16181613 _sharedVoxelSystem.getTree()->recurseTreeWithOperation(sendVoxelsOperation, &args);
16191614
16201615 if (_sharedVoxelSystem.getTree() != &_clipboard) {
@@ -1773,7 +1768,7 @@ void Application::init() { · 152 unmodified lines
17731768 _voxels.setMaxVoxels(Menu::getInstance()->getMaxVoxels());
17741769 _voxels.setUseVoxelShader(Menu::getInstance()->isOptionChecked(MenuOption::UseVoxelShader));
17751770 _voxels.setVoxelsAsPoints(Menu::getInstance()->isOptionChecked(MenuOption::VoxelsAsPoints));
1776− _voxels.setDisableFastVoxelPipeline(Menu::getInstance()->isOptionChecked(MenuOption::DisableFastVoxelPipeline));
1771+ _voxels.setDisableFastVoxelPipeline(false);
17771772 _voxels.init();
17781773
17791774
@@ -2580,10 +2575,11 @@ void Application::queryVoxels() { · 800 unmodified lines
25802575 bool wantExtraDebugging = Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging);
25812576
25822577 // These will be the same for all servers, so we can set them up once and then reuse for each server we send to.
2583− _voxelQuery.setWantLowResMoving(Menu::getInstance()->isOptionChecked(MenuOption::LowRes));
2584− _voxelQuery.setWantColor(Menu::getInstance()->isOptionChecked(MenuOption::SendVoxelColors));
2585− _voxelQuery.setWantDelta(Menu::getInstance()->isOptionChecked(MenuOption::DeltaSending));
2586− _voxelQuery.setWantOcclusionCulling(Menu::getInstance()->isOptionChecked(MenuOption::OcclusionCulling));
2578+ _voxelQuery.setWantLowResMoving(!Menu::getInstance()->isOptionChecked(MenuOption::DisableLowRes));
2579+ _voxelQuery.setWantColor(!Menu::getInstance()->isOptionChecked(MenuOption::DisableColorVoxels));
2580+ _voxelQuery.setWantDelta(!Menu::getInstance()->isOptionChecked(MenuOption::DisableDeltaSending));
2581+ _voxelQuery.setWantOcclusionCulling(Menu::getInstance()->isOptionChecked(MenuOption::EnableOcclusionCulling));
2582+ _voxelQuery.setWantCompression(Menu::getInstance()->isOptionChecked(MenuOption::EnableVoxelPacketCompression));
25872583
25882584 _voxelQuery.setCameraPosition(_viewFrustum.getPosition());
25892585 _voxelQuery.setCameraOrientation(_viewFrustum.getOrientation());
@@ -2645,15 +2641,16 @@ void Application::queryVoxels() { · 55 unmodified lines
26452641 int perServerPPS = 0;
26462642 const int SMALL_BUDGET = 10;
26472643 int perUnknownServer = SMALL_BUDGET;
2644+ int totalPPS = Menu::getInstance()->getMaxVoxelPacketsPerSecond();
26482645
26492646 // determine PPS based on number of servers
26502647 if (inViewServers >= 1) {
26512648 // set our preferred PPS to be exactly evenly divided among all of the voxel servers... and allocate 1 PPS
26522649 // for each unknown jurisdiction server
2653− perServerPPS = (DEFAULT_MAX_VOXEL_PPS / inViewServers) - (unknownJurisdictionServers * perUnknownServer);
2650+ perServerPPS = (totalPPS / inViewServers) - (unknownJurisdictionServers * perUnknownServer);
26542651 } else {
26552652 if (unknownJurisdictionServers > 0) {
2656− perUnknownServer = (DEFAULT_MAX_VOXEL_PPS / unknownJurisdictionServers);
2653+ perUnknownServer = (totalPPS / unknownJurisdictionServers);
26572654 }
26582655 }
26592656
@@ -3611,7 +3608,7 @@ void Application::displayStats() { · 951 unmodified lines
36113608 // Voxel Rendering
36123609 voxelStats.str("");
36133610 voxelStats.precision(4);
3614− voxelStats << "Voxel Rendering Slots" <<
3611+ voxelStats << "Voxel Rendering Slots " <<
36153612 "Max: " << _voxels.getMaxVoxels() / 1000.f << "K " <<
36163613 "Drawn: " << _voxels.getVoxelsWritten() / 1000.f << "K " <<
36173614 "Abandoned: " << _voxels.getAbandonedVoxels() / 1000.f << "K ";
@@ -4321,6 +4318,24 @@ void Application::nodeKilled(Node* node) { · 703 unmodified lines
43214318 }
43224319 }
43234320
4321+void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t messageLength,
4322+ sockaddr senderAddress, bool wasStatsPacket) {
4323+
4324+ // Attempt to identify the sender from it's address.
4325+ Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress);
4326+ if (voxelServer) {
4327+ QUuid nodeUUID = voxelServer->getUUID();
4328+
4329+ // now that we know the node ID, let's add these stats to the stats for that node...
4330+ _voxelSceneStatsLock.lockForWrite();
4331+ if (_voxelServerSceneStats.find(nodeUUID) != _voxelServerSceneStats.end()) {
4332+ VoxelSceneStats& stats = _voxelServerSceneStats[nodeUUID];
4333+ stats.trackIncomingVoxelPacket(messageData, messageLength, wasStatsPacket);
4334+ }
4335+ _voxelSceneStatsLock.unlock();
4336+ }
4337+}
4338+
43244339 int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLength, sockaddr senderAddress) {
43254340
43264341 // But, also identify the sender, and keep track of the contained jurisdiction root for this server
@@ -4399,13 +4414,26 @@ void* Application::networkReceive(void* args) { · 72 unmodified lines
43994414 app->_audio.addReceivedAudioToBuffer(app->_incomingPacket, bytesReceived);
44004415 break;
44014416 case PACKET_TYPE_VOXEL_DATA:
4402− case PACKET_TYPE_VOXEL_DATA_MONOCHROME:
4403− case PACKET_TYPE_Z_COMMAND:
44044417 case PACKET_TYPE_ERASE_VOXEL:
44054418 case PACKET_TYPE_VOXEL_STATS:
44064419 case PACKET_TYPE_ENVIRONMENT_DATA: {
44074420 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
44084421 "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()");
4422+
4423+ bool wantExtraDebugging = Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging);
4424+ if (wantExtraDebugging && app->_incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) {
4425+ int numBytesPacketHeader = numBytesForPacketHeader(app->_incomingPacket);
4426+ unsigned char* dataAt = app->_incomingPacket + numBytesPacketHeader;
4427+ dataAt += sizeof(VOXEL_PACKET_FLAGS);
4428+ VOXEL_PACKET_SEQUENCE sequence = (*(VOXEL_PACKET_SEQUENCE*)dataAt);
4429+ dataAt += sizeof(VOXEL_PACKET_SEQUENCE);
4430+ VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt);
4431+ dataAt += sizeof(VOXEL_PACKET_SENT_TIME);
4432+ VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow();
4433+ int flightTime = arrivedAt - sentAt;
4434+
4435+ printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime);
4436+ }
44094437
44104438 // add this packet to our list of voxel packets and process them on the voxel processing
44114439 app->_voxelProcessor.queueReceivedPacket(senderAddress, app->_incomingPacket, bytesReceived);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t