Major improvements to Voxel Packet "packing" and compression
Showing the changes to interface/src/Application.cpp (1 of 27 files). Show all
Unified · Split
| @@ -686,9 +686,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 685 unmodified lines | ||
| 686 | 686 | break; |
| 687 | 687 | |
| 688 | 688 | case Qt::Key_C: |
| 689 | − if (isShifted) { | |
| 690 | − Menu::getInstance()->triggerOption(MenuOption::OcclusionCulling); | |
| 691 | − } else if (_nudgeStarted) { | |
| 689 | + if (_nudgeStarted) { | |
| 692 | 690 | _nudgeGuidePosition.y -= _mouseVoxel.s; |
| 693 | 691 | } else { |
| 694 | 692 | _myAvatar.setDriveKeys(DOWN, 1); |
| @@ -1526,7 +1524,6 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { · 831 unmodified lines | ||
| 1526 | 1524 | SendVoxelsOperationArgs* args = (SendVoxelsOperationArgs*)extraData; |
| 1527 | 1525 | if (node->isColored()) { |
| 1528 | 1526 | const unsigned char* nodeOctalCode = node->getOctalCode(); |
| 1529 | − | |
| 1530 | 1527 | unsigned char* codeColorBuffer = NULL; |
| 1531 | 1528 | int codeLength = 0; |
| 1532 | 1529 | int bytesInCode = 0; |
| @@ -1547,10 +1544,9 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { · 14 unmodified lines | ||
| 1547 | 1544 | } |
| 1548 | 1545 | |
| 1549 | 1546 | // copy the colors over |
| 1550 | − codeColorBuffer[bytesInCode + RED_INDEX ] = node->getColor()[RED_INDEX ]; | |
| 1547 | + codeColorBuffer[bytesInCode + RED_INDEX] = node->getColor()[RED_INDEX]; | |
| 1551 | 1548 | 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]; | |
| 1554 | 1550 | getInstance()->_voxelEditSender.queueVoxelEditMessage(PACKET_TYPE_SET_VOXEL_DESTRUCTIVE, |
| 1555 | 1551 | codeColorBuffer, codeAndColorLength); |
| 1556 | 1552 | |
| @@ -1614,7 +1610,6 @@ void Application::pasteVoxelsToOctalCode(const unsigned char* octalCodeDestinati · 57 unmodified lines | ||
| 1614 | 1610 | // the server as an set voxel message, this will also rebase the voxels to the new location |
| 1615 | 1611 | SendVoxelsOperationArgs args; |
| 1616 | 1612 | args.newBaseOctCode = octalCodeDestination; |
| 1617 | − | |
| 1618 | 1613 | _sharedVoxelSystem.getTree()->recurseTreeWithOperation(sendVoxelsOperation, &args); |
| 1619 | 1614 | |
| 1620 | 1615 | if (_sharedVoxelSystem.getTree() != &_clipboard) { |
| @@ -1773,7 +1768,7 @@ void Application::init() { · 152 unmodified lines | ||
| 1773 | 1768 | _voxels.setMaxVoxels(Menu::getInstance()->getMaxVoxels()); |
| 1774 | 1769 | _voxels.setUseVoxelShader(Menu::getInstance()->isOptionChecked(MenuOption::UseVoxelShader)); |
| 1775 | 1770 | _voxels.setVoxelsAsPoints(Menu::getInstance()->isOptionChecked(MenuOption::VoxelsAsPoints)); |
| 1776 | − _voxels.setDisableFastVoxelPipeline(Menu::getInstance()->isOptionChecked(MenuOption::DisableFastVoxelPipeline)); | |
| 1771 | + _voxels.setDisableFastVoxelPipeline(false); | |
| 1777 | 1772 | _voxels.init(); |
| 1778 | 1773 | |
| 1779 | 1774 | |
| @@ -2580,10 +2575,11 @@ void Application::queryVoxels() { · 800 unmodified lines | ||
| 2580 | 2575 | bool wantExtraDebugging = Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging); |
| 2581 | 2576 | |
| 2582 | 2577 | // 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)); | |
| 2587 | 2583 | |
| 2588 | 2584 | _voxelQuery.setCameraPosition(_viewFrustum.getPosition()); |
| 2589 | 2585 | _voxelQuery.setCameraOrientation(_viewFrustum.getOrientation()); |
| @@ -2645,15 +2641,16 @@ void Application::queryVoxels() { · 55 unmodified lines | ||
| 2645 | 2641 | int perServerPPS = 0; |
| 2646 | 2642 | const int SMALL_BUDGET = 10; |
| 2647 | 2643 | int perUnknownServer = SMALL_BUDGET; |
| 2644 | + int totalPPS = Menu::getInstance()->getMaxVoxelPacketsPerSecond(); | |
| 2648 | 2645 | |
| 2649 | 2646 | // determine PPS based on number of servers |
| 2650 | 2647 | if (inViewServers >= 1) { |
| 2651 | 2648 | // set our preferred PPS to be exactly evenly divided among all of the voxel servers... and allocate 1 PPS |
| 2652 | 2649 | // for each unknown jurisdiction server |
| 2653 | − perServerPPS = (DEFAULT_MAX_VOXEL_PPS / inViewServers) - (unknownJurisdictionServers * perUnknownServer); | |
| 2650 | + perServerPPS = (totalPPS / inViewServers) - (unknownJurisdictionServers * perUnknownServer); | |
| 2654 | 2651 | } else { |
| 2655 | 2652 | if (unknownJurisdictionServers > 0) { |
| 2656 | − perUnknownServer = (DEFAULT_MAX_VOXEL_PPS / unknownJurisdictionServers); | |
| 2653 | + perUnknownServer = (totalPPS / unknownJurisdictionServers); | |
| 2657 | 2654 | } |
| 2658 | 2655 | } |
| 2659 | 2656 | |
| @@ -3611,7 +3608,7 @@ void Application::displayStats() { · 951 unmodified lines | ||
| 3611 | 3608 | // Voxel Rendering |
| 3612 | 3609 | voxelStats.str(""); |
| 3613 | 3610 | voxelStats.precision(4); |
| 3614 | − voxelStats << "Voxel Rendering Slots" << | |
| 3611 | + voxelStats << "Voxel Rendering Slots " << | |
| 3615 | 3612 | "Max: " << _voxels.getMaxVoxels() / 1000.f << "K " << |
| 3616 | 3613 | "Drawn: " << _voxels.getVoxelsWritten() / 1000.f << "K " << |
| 3617 | 3614 | "Abandoned: " << _voxels.getAbandonedVoxels() / 1000.f << "K "; |
| @@ -4321,6 +4318,24 @@ void Application::nodeKilled(Node* node) { · 703 unmodified lines | ||
| 4321 | 4318 | } |
| 4322 | 4319 | } |
| 4323 | 4320 | |
| 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 | + | |
| 4324 | 4339 | int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLength, sockaddr senderAddress) { |
| 4325 | 4340 | |
| 4326 | 4341 | // 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 | ||
| 4399 | 4414 | app->_audio.addReceivedAudioToBuffer(app->_incomingPacket, bytesReceived); |
| 4400 | 4415 | break; |
| 4401 | 4416 | case PACKET_TYPE_VOXEL_DATA: |
| 4402 | − case PACKET_TYPE_VOXEL_DATA_MONOCHROME: | |
| 4403 | − case PACKET_TYPE_Z_COMMAND: | |
| 4404 | 4417 | case PACKET_TYPE_ERASE_VOXEL: |
| 4405 | 4418 | case PACKET_TYPE_VOXEL_STATS: |
| 4406 | 4419 | case PACKET_TYPE_ENVIRONMENT_DATA: { |
| 4407 | 4420 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 4408 | 4421 | "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 | + } | |
| 4409 | 4437 | |
| 4410 | 4438 | // add this packet to our list of voxel packets and process them on the voxel processing |
| 4411 | 4439 | app->_voxelProcessor.queueReceivedPacket(senderAddress, app->_incomingPacket, bytesReceived); |