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