Showing the changes to interface/src/Application.cpp (1 of 23 files). Show all
Unified · Split
| @@ -114,8 +114,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 113 unmodified lines | |||
| 114 | _justEditedVoxel(false), | 114 | _justEditedVoxel(false), |
| 115 | _isLookingAtOtherAvatar(false), | 115 | _isLookingAtOtherAvatar(false), |
| 116 | _lookatIndicatorScale(1.0f), | 116 | _lookatIndicatorScale(1.0f), |
| 117 | _paintOn(false), | ||
| 118 | _dominantColor(0), | ||
| 119 | _perfStatsOn(false), | 117 | _perfStatsOn(false), |
| 120 | _chatEntryOn(false), | 118 | _chatEntryOn(false), |
| 121 | _oculusTextureID(0), | 119 | _oculusTextureID(0), |
| @@ -125,7 +123,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 3 unmodified lines | |||
| 125 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), | 123 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), |
| 126 | #endif | 124 | #endif |
| 127 | _stopNetworkReceiveThread(false), | 125 | _stopNetworkReceiveThread(false), |
| 128 | _stopProcessVoxelsThread(false), | 126 | _voxelProcessor(this), |
| 127 | _voxelEditSender(this), | ||
| 129 | _packetCount(0), | 128 | _packetCount(0), |
| 130 | _packetsPerSecond(0), | 129 | _packetsPerSecond(0), |
| 131 | _bytesPerSecond(0), | 130 | _bytesPerSecond(0), |
| @@ -278,9 +277,10 @@ void Application::initializeGL() { · 146 unmodified lines | |||
| 278 | } | 277 | } |
| 279 | 278 | ||
| 280 | // create thread for parsing of voxel data independent of the main network and rendering threads | 279 | // create thread for parsing of voxel data independent of the main network and rendering threads |
| 280 | _voxelProcessor.initialize(_enableProcessVoxelsThread); | ||
| 281 | _voxelEditSender.initialize(_enableProcessVoxelsThread); | ||
| 281 | if (_enableProcessVoxelsThread) { | 282 | if (_enableProcessVoxelsThread) { |
| 282 | pthread_create(&_processVoxelsThread, NULL, processVoxels, NULL); | 283 | qDebug("Voxel parsing thread created.\n"); |
| 283 | qDebug("Voxel parsing thread created.\n"); | ||
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | // call terminate before exiting | 286 | // call terminate before exiting |
| @@ -319,7 +319,7 @@ void Application::paintGL() { · 32 unmodified lines | |||
| 319 | PerfStat("display"); | 319 | PerfStat("display"); |
| 320 | 320 | ||
| 321 | glEnable(GL_LINE_SMOOTH); | 321 | glEnable(GL_LINE_SMOOTH); |
| 322 | 322 | ||
| 323 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | 323 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 324 | _myCamera.setTightness (100.0f); | 324 | _myCamera.setTightness (100.0f); |
| 325 | _myCamera.setTargetPosition(_myAvatar.getUprightHeadPosition()); | 325 | _myCamera.setTargetPosition(_myAvatar.getUprightHeadPosition()); |
| @@ -451,27 +451,20 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_ · 125 unmodified lines | |||
| 451 | // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise) | 451 | // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise) |
| 452 | BandwidthMeter::ChannelIndex channel; | 452 | BandwidthMeter::ChannelIndex channel; |
| 453 | switch (nodeTypes[i]) { | 453 | switch (nodeTypes[i]) { |
| 454 | case NODE_TYPE_AGENT: | 454 | case NODE_TYPE_AGENT: |
| 455 | case NODE_TYPE_AVATAR_MIXER: | 455 | case NODE_TYPE_AVATAR_MIXER: |
| 456 | channel = BandwidthMeter::AVATARS; | 456 | channel = BandwidthMeter::AVATARS; |
| 457 | break; | 457 | break; |
| 458 | case NODE_TYPE_VOXEL_SERVER: | 458 | case NODE_TYPE_VOXEL_SERVER: |
| 459 | channel = BandwidthMeter::VOXELS; | 459 | channel = BandwidthMeter::VOXELS; |
| 460 | break; | 460 | break; |
| 461 | default: | 461 | default: |
| 462 | continue; | 462 | continue; |
| 463 | } | 463 | } |
| 464 | self->_bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes); | 464 | self->_bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes); |
| 465 | } | 465 | } |
| 466 | } | 466 | } |
| 467 | 467 | ||
| 468 | void Application::sendVoxelServerAddScene() { | ||
| 469 | char message[100]; | ||
| 470 | sprintf(message,"%c%s",'Z',"add scene"); | ||
| 471 | int messageSize = strlen(message) + 1; | ||
| 472 | controlledBroadcastToNodes((unsigned char*)message, messageSize, & NODE_TYPE_VOXEL_SERVER, 1); | ||
| 473 | } | ||
| 474 | |||
| 475 | void Application::keyPressEvent(QKeyEvent* event) { | 468 | void Application::keyPressEvent(QKeyEvent* event) { |
| 476 | if (activeWindow() == _window) { | 469 | if (activeWindow() == _window) { |
| 477 | if (_chatEntryOn) { | 470 | if (_chatEntryOn) { |
| @@ -1056,10 +1049,8 @@ void Application::terminate() { · 578 unmodified lines | |||
| 1056 | pthread_join(_networkReceiveThread, NULL); | 1049 | pthread_join(_networkReceiveThread, NULL); |
| 1057 | } | 1050 | } |
| 1058 | 1051 | ||
| 1059 | if (_enableProcessVoxelsThread) { | 1052 | _voxelProcessor.terminate(); |
| 1060 | _stopProcessVoxelsThread = true; | 1053 | _voxelEditSender.terminate(); |
| 1061 | pthread_join(_processVoxelsThread, NULL); | ||
| 1062 | } | ||
| 1063 | } | 1054 | } |
| 1064 | 1055 | ||
| 1065 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { | 1056 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { |
| @@ -1251,12 +1242,7 @@ void Application::resetSwatchColors() { · 185 unmodified lines | |||
| 1251 | 1242 | ||
| 1252 | const int MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE = 1500; | 1243 | const int MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE = 1500; |
| 1253 | struct SendVoxelsOperationArgs { | 1244 | struct SendVoxelsOperationArgs { |
| 1254 | unsigned char* newBaseOctCode; | 1245 | unsigned char* newBaseOctCode; |
| 1255 | unsigned char messageBuffer[MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE]; | ||
| 1256 | int bufferInUse; | ||
| 1257 | uint64_t lastSendTime; | ||
| 1258 | int packetsSent; | ||
| 1259 | uint64_t bytesSent; | ||
| 1260 | }; | 1246 | }; |
| 1261 | 1247 | ||
| 1262 | bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { | 1248 | bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { |
| @@ -1287,38 +1273,11 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { · 24 unmodified lines | |||
| 1287 | codeColorBuffer[bytesInCode + RED_INDEX ] = node->getColor()[RED_INDEX ]; | 1273 | codeColorBuffer[bytesInCode + RED_INDEX ] = node->getColor()[RED_INDEX ]; |
| 1288 | codeColorBuffer[bytesInCode + GREEN_INDEX] = node->getColor()[GREEN_INDEX]; | 1274 | codeColorBuffer[bytesInCode + GREEN_INDEX] = node->getColor()[GREEN_INDEX]; |
| 1289 | codeColorBuffer[bytesInCode + BLUE_INDEX ] = node->getColor()[BLUE_INDEX ]; | 1275 | codeColorBuffer[bytesInCode + BLUE_INDEX ] = node->getColor()[BLUE_INDEX ]; |
| 1290 | |||
| 1291 | // if we have room don't have room in the buffer, then send the previously generated message first | ||
| 1292 | if (args->bufferInUse + codeAndColorLength > MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE) { | ||
| 1293 | |||
| 1294 | args->packetsSent++; | ||
| 1295 | args->bytesSent += args->bufferInUse; | ||
| 1296 | 1276 | ||
| 1297 | controlledBroadcastToNodes(args->messageBuffer, args->bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1); | 1277 | getInstance()->_voxelEditSender.queueVoxelEditMessage(PACKET_TYPE_SET_VOXEL_DESTRUCTIVE, |
| 1298 | args->bufferInUse = numBytesForPacketHeader((unsigned char*) &PACKET_TYPE_SET_VOXEL_DESTRUCTIVE) | 1278 | codeColorBuffer, codeAndColorLength); |
| 1299 | + sizeof(unsigned short int); // reset | ||
| 1300 | |||
| 1301 | uint64_t now = usecTimestampNow(); | ||
| 1302 | // dynamically sleep until we need to fire off the next set of voxels | ||
| 1303 | uint64_t elapsed = now - args->lastSendTime; | ||
| 1304 | int usecToSleep = CLIENT_TO_SERVER_VOXEL_SEND_INTERVAL_USECS - elapsed; | ||
| 1305 | if (usecToSleep > 0) { | ||
| 1306 | //qDebug("sendVoxelsOperation: packet: %d bytes:%lld elapsed %lld usecs, sleeping for %d usecs!\n", | ||
| 1307 | // args->packetsSent, (long long int)args->bytesSent, (long long int)elapsed, usecToSleep); | ||
| 1308 | |||
| 1309 | Application::getInstance()->timer(); | ||
| 1310 | |||
| 1311 | usleep(usecToSleep); | ||
| 1312 | } else { | ||
| 1313 | //qDebug("sendVoxelsOperation: packet: %d bytes:%lld elapsed %lld usecs, no need to sleep!\n", | ||
| 1314 | // args->packetsSent, (long long int)args->bytesSent, (long long int)elapsed); | ||
| 1315 | } | ||
| 1316 | args->lastSendTime = now; | ||
| 1317 | } | ||
| 1318 | 1279 | ||
| 1319 | // copy this node's code color details into our buffer. | 1280 | delete[] codeColorBuffer; |
| 1320 | memcpy(&args->messageBuffer[args->bufferInUse], codeColorBuffer, codeAndColorLength); | ||
| 1321 | args->bufferInUse += codeAndColorLength; | ||
| 1322 | } | 1281 | } |
| 1323 | return true; // keep going | 1282 | return true; // keep going |
| 1324 | } | 1283 | } |
| @@ -1500,15 +1459,6 @@ void Application::importVoxels() { · 175 unmodified lines | |||
| 1500 | // the server as an set voxel message, this will also rebase the voxels to the new location | 1459 | // the server as an set voxel message, this will also rebase the voxels to the new location |
| 1501 | unsigned char* calculatedOctCode = NULL; | 1460 | unsigned char* calculatedOctCode = NULL; |
| 1502 | SendVoxelsOperationArgs args; | 1461 | SendVoxelsOperationArgs args; |
| 1503 | args.lastSendTime = usecTimestampNow(); | ||
| 1504 | args.packetsSent = 0; | ||
| 1505 | args.bytesSent = 0; | ||
| 1506 | |||
| 1507 | int numBytesPacketHeader = populateTypeAndVersion(args.messageBuffer, PACKET_TYPE_SET_VOXEL_DESTRUCTIVE); | ||
| 1508 | |||
| 1509 | unsigned short int* sequenceAt = (unsigned short int*)&args.messageBuffer[numBytesPacketHeader]; | ||
| 1510 | *sequenceAt = 0; | ||
| 1511 | args.bufferInUse = numBytesPacketHeader + sizeof(unsigned short int); // set to command + sequence | ||
| 1512 | 1462 | ||
| 1513 | // we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the | 1463 | // we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the |
| 1514 | // voxel size/position details. | 1464 | // voxel size/position details. |
| @@ -1522,31 +1472,8 @@ void Application::importVoxels() { · 7 unmodified lines | |||
| 1522 | 1472 | ||
| 1523 | // send the insert/paste of these voxels | 1473 | // send the insert/paste of these voxels |
| 1524 | importVoxels.recurseTreeWithOperation(sendVoxelsOperation, &args); | 1474 | importVoxels.recurseTreeWithOperation(sendVoxelsOperation, &args); |
| 1475 | _voxelEditSender.flushQueue(); | ||
| 1525 | 1476 | ||
| 1526 | // If we have voxels left in the packet, then send the packet | ||
| 1527 | if (args.bufferInUse > (numBytesPacketHeader + sizeof(unsigned short int))) { | ||
| 1528 | controlledBroadcastToNodes(args.messageBuffer, args.bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1); | ||
| 1529 | |||
| 1530 | |||
| 1531 | args.packetsSent++; | ||
| 1532 | args.bytesSent += args.bufferInUse; | ||
| 1533 | |||
| 1534 | uint64_t now = usecTimestampNow(); | ||
| 1535 | // dynamically sleep until we need to fire off the next set of voxels | ||
| 1536 | uint64_t elapsed = now - args.lastSendTime; | ||
| 1537 | int usecToSleep = CLIENT_TO_SERVER_VOXEL_SEND_INTERVAL_USECS - elapsed; | ||
| 1538 | |||
| 1539 | if (usecToSleep > 0) { | ||
| 1540 | //qDebug("after sendVoxelsOperation: packet: %d bytes:%lld elapsed %lld usecs, sleeping for %d usecs!\n", | ||
| 1541 | // args.packetsSent, (long long int)args.bytesSent, (long long int)elapsed, usecToSleep); | ||
| 1542 | usleep(usecToSleep); | ||
| 1543 | } else { | ||
| 1544 | //qDebug("after sendVoxelsOperation: packet: %d bytes:%lld elapsed %lld usecs, no need to sleep!\n", | ||
| 1545 | // args.packetsSent, (long long int)args.bytesSent, (long long int)elapsed); | ||
| 1546 | } | ||
| 1547 | args.lastSendTime = now; | ||
| 1548 | } | ||
| 1549 | |||
| 1550 | if (calculatedOctCode) { | 1477 | if (calculatedOctCode) { |
| 1551 | delete[] calculatedOctCode; | 1478 | delete[] calculatedOctCode; |
| 1552 | } | 1479 | } |
| @@ -1580,15 +1507,6 @@ void Application::pasteVoxels() { · 27 unmodified lines | |||
| 1580 | // Recurse the clipboard tree, where everything is root relative, and send all the colored voxels to | 1507 | // Recurse the clipboard tree, where everything is root relative, and send all the colored voxels to |
| 1581 | // the server as an set voxel message, this will also rebase the voxels to the new location | 1508 | // the server as an set voxel message, this will also rebase the voxels to the new location |
| 1582 | SendVoxelsOperationArgs args; | 1509 | SendVoxelsOperationArgs args; |
| 1583 | args.lastSendTime = usecTimestampNow(); | ||
| 1584 | args.packetsSent = 0; | ||
| 1585 | args.bytesSent = 0; | ||
| 1586 | |||
| 1587 | int numBytesPacketHeader = populateTypeAndVersion(args.messageBuffer, PACKET_TYPE_SET_VOXEL_DESTRUCTIVE); | ||
| 1588 | |||
| 1589 | unsigned short int* sequenceAt = (unsigned short int*)&args.messageBuffer[numBytesPacketHeader]; | ||
| 1590 | *sequenceAt = 0; | ||
| 1591 | args.bufferInUse = numBytesPacketHeader + sizeof(unsigned short int); // set to command + sequence | ||
| 1592 | 1510 | ||
| 1593 | // we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the | 1511 | // we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the |
| 1594 | // voxel size/position details. If we don't have an actual selectedNode then use the mouseVoxel to create a | 1512 | // voxel size/position details. If we don't have an actual selectedNode then use the mouseVoxel to create a |
| @@ -1600,14 +1518,7 @@ void Application::pasteVoxels() { · 5 unmodified lines | |||
| 1600 | } | 1518 | } |
| 1601 | 1519 | ||
| 1602 | _clipboardTree.recurseTreeWithOperation(sendVoxelsOperation, &args); | 1520 | _clipboardTree.recurseTreeWithOperation(sendVoxelsOperation, &args); |
| 1603 | 1521 | _voxelEditSender.flushQueue(); | |
| 1604 | // If we have voxels left in the packet, then send the packet | ||
| 1605 | if (args.bufferInUse > (numBytesPacketHeader + sizeof(unsigned short int))) { | ||
| 1606 | controlledBroadcastToNodes(args.messageBuffer, args.bufferInUse, & NODE_TYPE_VOXEL_SERVER, 1); | ||
| 1607 | qDebug("sending packet: %d\n", ++args.packetsSent); | ||
| 1608 | args.bytesSent += args.bufferInUse; | ||
| 1609 | qDebug("total bytes sent: %lld\n", (long long int)args.bytesSent); | ||
| 1610 | } | ||
| 1611 | 1522 | ||
| 1612 | if (calculatedOctCode) { | 1523 | if (calculatedOctCode) { |
| 1613 | delete[] calculatedOctCode; | 1524 | delete[] calculatedOctCode; |
| @@ -1654,7 +1565,7 @@ void Application::init() { · 40 unmodified lines | |||
| 1654 | _voxels.init(); | 1565 | _voxels.init(); |
| 1655 | 1566 | ||
| 1656 | _environment.init(); | 1567 | _environment.init(); |
| 1657 | 1568 | ||
| 1658 | _glowEffect.init(); | 1569 | _glowEffect.init(); |
| 1659 | 1570 | ||
| 1660 | _handControl.setScreenDimensions(_glWidget->width(), _glWidget->height()); | 1571 | _handControl.setScreenDimensions(_glWidget->width(), _glWidget->height()); |
| @@ -2025,7 +1936,8 @@ void Application::update(float deltaTime) { · 364 unmodified lines | |||
| 2025 | 1936 | ||
| 2026 | // parse voxel packets | 1937 | // parse voxel packets |
| 2027 | if (!_enableProcessVoxelsThread) { | 1938 | if (!_enableProcessVoxelsThread) { |
| 2028 | processVoxels(0); | 1939 | _voxelProcessor.threadRoutine(); |
| 1940 | _voxelEditSender.threadRoutine(); | ||
| 2029 | } | 1941 | } |
| 2030 | 1942 | ||
| 2031 | //loop through all the other avatars and simulate them... | 1943 | //loop through all the other avatars and simulate them... |
| @@ -2725,15 +2637,6 @@ void Application::displayOverlay() { · 693 unmodified lines | |||
| 2725 | sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars); | 2637 | sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars); |
| 2726 | drawtext(_glWidget->width() - 150, 20, 0.10, 0, 1.0, 0, nodes, 1, 0, 0); | 2638 | drawtext(_glWidget->width() - 150, 20, 0.10, 0, 1.0, 0, nodes, 1, 0, 0); |
| 2727 | 2639 | ||
| 2728 | if (_paintOn) { | ||
| 2729 | |||
| 2730 | char paintMessage[100]; | ||
| 2731 | sprintf(paintMessage,"Painting (%.3f,%.3f,%.3f/%.3f/%d,%d,%d)", | ||
| 2732 | _paintingVoxel.x, _paintingVoxel.y, _paintingVoxel.z, _paintingVoxel.s, | ||
| 2733 | (unsigned int)_paintingVoxel.red, (unsigned int)_paintingVoxel.green, (unsigned int)_paintingVoxel.blue); | ||
| 2734 | drawtext(_glWidget->width() - 350, 50, 0.10, 0, 1.0, 0, paintMessage, 1, 1, 0); | ||
| 2735 | } | ||
| 2736 | |||
| 2737 | // render the webcam input frame | 2640 | // render the webcam input frame |
| 2738 | _webcam.renderPreview(_glWidget->width(), _glWidget->height()); | 2641 | _webcam.renderPreview(_glWidget->width(), _glWidget->height()); |
| 2739 | 2642 | ||
| @@ -3199,26 +3102,6 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 459 unmodified lines | |||
| 3199 | } | 3102 | } |
| 3200 | } | 3103 | } |
| 3201 | 3104 | ||
| 3202 | void Application::setupPaintingVoxel() { | ||
| 3203 | glm::vec3 avatarPos = _myAvatar.getPosition(); | ||
| 3204 | |||
| 3205 | _paintingVoxel.x = avatarPos.z/-10.0; // voxel space x is negative z head space | ||
| 3206 | _paintingVoxel.y = avatarPos.y/-10.0; // voxel space y is negative y head space | ||
| 3207 | _paintingVoxel.z = avatarPos.x/-10.0; // voxel space z is negative x head space | ||
| 3208 | _paintingVoxel.s = 1.0/256; | ||
| 3209 | |||
| 3210 | shiftPaintingColor(); | ||
| 3211 | } | ||
| 3212 | |||
| 3213 | void Application::shiftPaintingColor() { | ||
| 3214 | // About the color of the paintbrush... first determine the dominant color | ||
| 3215 | _dominantColor = (_dominantColor + 1) % 3; // 0=red,1=green,2=blue | ||
| 3216 | _paintingVoxel.red = (_dominantColor == 0) ? randIntInRange(200, 255) : randIntInRange(40, 100); | ||
| 3217 | _paintingVoxel.green = (_dominantColor == 1) ? randIntInRange(200, 255) : randIntInRange(40, 100); | ||
| 3218 | _paintingVoxel.blue = (_dominantColor == 2) ? randIntInRange(200, 255) : randIntInRange(40, 100); | ||
| 3219 | } | ||
| 3220 | |||
| 3221 | |||
| 3222 | void Application::injectVoxelAddedSoundEffect() { | 3105 | void Application::injectVoxelAddedSoundEffect() { |
| 3223 | AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(11025); | 3106 | AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(11025); |
| 3224 | 3107 | ||
| @@ -3329,7 +3212,7 @@ bool Application::maybeEditVoxelUnderCursor() { · 104 unmodified lines | |||
| 3329 | void Application::deleteVoxelUnderCursor() { | 3212 | void Application::deleteVoxelUnderCursor() { |
| 3330 | if (_mouseVoxel.s != 0) { | 3213 | if (_mouseVoxel.s != 0) { |
| 3331 | // sending delete to the server is sufficient, server will send new version so we see updates soon enough | 3214 | // sending delete to the server is sufficient, server will send new version so we see updates soon enough |
| 3332 | sendVoxelEditMessage(PACKET_TYPE_ERASE_VOXEL, _mouseVoxel); | 3215 | _voxelEditSender.sendVoxelEditMessage(PACKET_TYPE_ERASE_VOXEL, _mouseVoxel); |
| 3333 | AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(5000); | 3216 | AudioInjector* voxelInjector = AudioInjectionManager::injectorWithCapacity(5000); |
| 3334 | 3217 | ||
| 3335 | if (voxelInjector) { | 3218 | if (voxelInjector) { |
| @@ -3433,15 +3316,16 @@ void Application::nodeKilled(Node* node) { · 97 unmodified lines | |||
| 3433 | uint16_t nodeID = node->getNodeID(); | 3316 | uint16_t nodeID = node->getNodeID(); |
| 3434 | // see if this is the first we've heard of this node... | 3317 | // see if this is the first we've heard of this node... |
| 3435 | if (_voxelServerJurisdictions.find(nodeID) != _voxelServerJurisdictions.end()) { | 3318 | if (_voxelServerJurisdictions.find(nodeID) != _voxelServerJurisdictions.end()) { |
| 3436 | VoxelPositionSize jurisditionDetails; | 3319 | unsigned char* rootCode = _voxelServerJurisdictions[nodeID].getRootOctalCode(); |
| 3437 | jurisditionDetails = _voxelServerJurisdictions[nodeID]; | 3320 | VoxelPositionSize rootDetails; |
| 3321 | voxelDetailsForCode(rootCode, rootDetails); | ||
| 3438 | 3322 | ||
| 3439 | printf("voxel server going away...... v[%f, %f, %f, %f]\n", | 3323 | printf("voxel server going away...... v[%f, %f, %f, %f]\n", |
| 3440 | jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s); | 3324 | rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s); |
| 3441 | 3325 | ||
| 3442 | // Add the jurisditionDetails object to the list of "fade outs" | 3326 | // Add the jurisditionDetails object to the list of "fade outs" |
| 3443 | VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE); | 3327 | VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE); |
| 3444 | fade.voxelDetails = jurisditionDetails; | 3328 | fade.voxelDetails = rootDetails; |
| 3445 | const float slightly_smaller = 0.99; | 3329 | const float slightly_smaller = 0.99; |
| 3446 | fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller; | 3330 | fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller; |
| 3447 | _voxelFades.push_back(fade); | 3331 | _voxelFades.push_back(fade); |
| @@ -3462,23 +3346,28 @@ int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLeng · 14 unmodified lines | |||
| 3462 | if (voxelServer) { | 3346 | if (voxelServer) { |
| 3463 | uint16_t nodeID = voxelServer->getNodeID(); | 3347 | uint16_t nodeID = voxelServer->getNodeID(); |
| 3464 | 3348 | ||
| 3465 | VoxelPositionSize jurisditionDetails; | 3349 | VoxelPositionSize rootDetails; |
| 3466 | voxelDetailsForCode(_voxelSceneStats.getJurisdictionRoot(), jurisditionDetails); | 3350 | voxelDetailsForCode(_voxelSceneStats.getJurisdictionRoot(), rootDetails); |
| 3467 | 3351 | ||
| 3468 | // see if this is the first we've heard of this node... | 3352 | // see if this is the first we've heard of this node... |
| 3469 | if (_voxelServerJurisdictions.find(nodeID) == _voxelServerJurisdictions.end()) { | 3353 | if (_voxelServerJurisdictions.find(nodeID) == _voxelServerJurisdictions.end()) { |
| 3470 | printf("stats from new voxel server... v[%f, %f, %f, %f]\n", | 3354 | printf("stats from new voxel server... v[%f, %f, %f, %f]\n", |
| 3471 | jurisditionDetails.x, jurisditionDetails.y, jurisditionDetails.z, jurisditionDetails.s); | 3355 | rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s); |
| 3472 | 3356 | ||
| 3473 | // Add the jurisditionDetails object to the list of "fade outs" | 3357 | // Add the jurisditionDetails object to the list of "fade outs" |
| 3474 | VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE); | 3358 | VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE); |
| 3475 | fade.voxelDetails = jurisditionDetails; | 3359 | fade.voxelDetails = rootDetails; |
| 3476 | const float slightly_smaller = 0.99; | 3360 | const float slightly_smaller = 0.99; |
| 3477 | fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller; | 3361 | fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller; |
| 3478 | _voxelFades.push_back(fade); | 3362 | _voxelFades.push_back(fade); |
| 3479 | } | 3363 | } |
| 3480 | // store jurisdiction details for later use | 3364 | // store jurisdiction details for later use |
| 3481 | _voxelServerJurisdictions[nodeID] = jurisditionDetails; | 3365 | // This is bit of fiddling is because JurisdictionMap assumes it is the owner of the values used to construct it |
| 3366 | // but VoxelSceneStats thinks it's just returning a reference to it's contents. So we need to make a copy of the | ||
| 3367 | // details from the VoxelSceneStats to construct the JurisdictionMap | ||
| 3368 | JurisdictionMap jurisdictionMap; | ||
| 3369 | jurisdictionMap.copyContents(_voxelSceneStats.getJurisdictionRoot(), _voxelSceneStats.getJurisdictionEndNodes()); | ||
| 3370 | _voxelServerJurisdictions[nodeID] = jurisdictionMap; | ||
| 3482 | } | 3371 | } |
| 3483 | return statsMessageLength; | 3372 | return statsMessageLength; |
| 3484 | } | 3373 | } |
| @@ -3563,12 +3452,6 @@ void* Application::networkReceive(void* args) { · 78 unmodified lines | |||
| 3563 | 3452 | ||
| 3564 | Application* app = Application::getInstance(); | 3453 | Application* app = Application::getInstance(); |
| 3565 | while (!app->_stopNetworkReceiveThread) { | 3454 | while (!app->_stopNetworkReceiveThread) { |
| 3566 | // check to see if the UI thread asked us to kill the voxel tree. since we're the only thread allowed to do that | ||
| 3567 | if (app->_wantToKillLocalVoxels) { | ||
| 3568 | app->_voxels.killLocalVoxels(); | ||
| 3569 | app->_wantToKillLocalVoxels = false; | ||
| 3570 | } | ||
| 3571 | |||
| 3572 | if (NodeList::getInstance()->getNodeSocket()->receive(&senderAddress, app->_incomingPacket, &bytesReceived)) { | 3455 | if (NodeList::getInstance()->getNodeSocket()->receive(&senderAddress, app->_incomingPacket, &bytesReceived)) { |
| 3573 | 3456 | ||
| 3574 | app->_packetCount++; | 3457 | app->_packetCount++; |
| @@ -3592,7 +3475,7 @@ void* Application::networkReceive(void* args) { · 17 unmodified lines | |||
| 3592 | case PACKET_TYPE_VOXEL_STATS: | 3475 | case PACKET_TYPE_VOXEL_STATS: |
| 3593 | case PACKET_TYPE_ENVIRONMENT_DATA: { | 3476 | case PACKET_TYPE_ENVIRONMENT_DATA: { |
| 3594 | // add this packet to our list of voxel packets and process them on the voxel processing | 3477 | // add this packet to our list of voxel packets and process them on the voxel processing |
| 3595 | app->queueVoxelPacket(senderAddress, app->_incomingPacket, bytesReceived); | 3478 | app->_voxelProcessor.queuePacket(senderAddress, app->_incomingPacket, bytesReceived); |
| 3596 | break; | 3479 | break; |
| 3597 | } | 3480 | } |
| 3598 | case PACKET_TYPE_BULK_AVATAR_DATA: | 3481 | case PACKET_TYPE_BULK_AVATAR_DATA: |