Showing the changes to interface/src/Application.cpp (1 of 34 files). Show all
Unified · Split
| @@ -1382,6 +1382,26 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 1381 unmodified lines | |||
| 1382 | _window->activateWindow(); | 1382 | _window->activateWindow(); |
| 1383 | } | 1383 | } |
| 1384 | 1384 | ||
| 1385 | void Application::importVoxels() { | ||
| 1386 | if (!_voxelImporter) { | ||
| 1387 | _voxelImporter = new VoxelImporter(_window); | ||
| 1388 | _voxelImporter->loadSettings(_settings); | ||
| 1389 | } | ||
| 1390 | |||
| 1391 | if (!_voxelImporter->exec()) { | ||
| 1392 | qDebug() << "[DEBUG] Import succeeded." << endl; | ||
| 1393 | } else { | ||
| 1394 | qDebug() << "[DEBUG] Import failed." << endl; | ||
| 1395 | if (_sharedVoxelSystem.getTree() == _voxelImporter->getVoxelTree()) { | ||
| 1396 | _sharedVoxelSystem.killLocalVoxels(); | ||
| 1397 | _sharedVoxelSystem.changeTree(&_clipboard); | ||
| 1398 | } | ||
| 1399 | } | ||
| 1400 | |||
| 1401 | // restore the main window's active state | ||
| 1402 | _window->activateWindow(); | ||
| 1403 | } | ||
| 1404 | |||
| 1385 | void Application::cutVoxels(const VoxelDetail& sourceVoxel) { | 1405 | void Application::cutVoxels(const VoxelDetail& sourceVoxel) { |
| 1386 | copyVoxels(sourceVoxel); | 1406 | copyVoxels(sourceVoxel); |
| 1387 | deleteVoxelAt(sourceVoxel); | 1407 | deleteVoxelAt(sourceVoxel); |
| @@ -1520,8 +1540,8 @@ void Application::init() { · 132 unmodified lines | |||
| 1520 | 1540 | ||
| 1521 | // Set up VoxelSystem after loading preferences so we can get the desired max voxel count | 1541 | // Set up VoxelSystem after loading preferences so we can get the desired max voxel count |
| 1522 | _voxels.setMaxVoxels(Menu::getInstance()->getMaxVoxels()); | 1542 | _voxels.setMaxVoxels(Menu::getInstance()->getMaxVoxels()); |
| 1523 | _voxels.setUseVoxelShader(Menu::getInstance()->isOptionChecked(MenuOption::UseVoxelShader)); | 1543 | _voxels.setUseVoxelShader(false); |
| 1524 | _voxels.setVoxelsAsPoints(Menu::getInstance()->isOptionChecked(MenuOption::VoxelsAsPoints)); | 1544 | _voxels.setVoxelsAsPoints(false); |
| 1525 | _voxels.setDisableFastVoxelPipeline(false); | 1545 | _voxels.setDisableFastVoxelPipeline(false); |
| 1526 | _voxels.init(); | 1546 | _voxels.init(); |
| 1527 | 1547 | ||
| @@ -1917,7 +1937,7 @@ void Application::updateMyAvatar(float deltaTime) { · 389 unmodified lines | |||
| 1917 | // actually need to calculate the view frustum planes to send these details | 1937 | // actually need to calculate the view frustum planes to send these details |
| 1918 | // to the server. | 1938 | // to the server. |
| 1919 | loadViewFrustum(_myCamera, _viewFrustum); | 1939 | loadViewFrustum(_myCamera, _viewFrustum); |
| 1920 | 1940 | ||
| 1921 | // Update my voxel servers with my current voxel query... | 1941 | // Update my voxel servers with my current voxel query... |
| 1922 | queryOctree(NodeType::VoxelServer, PacketTypeVoxelQuery, _voxelServerJurisdictions); | 1942 | queryOctree(NodeType::VoxelServer, PacketTypeVoxelQuery, _voxelServerJurisdictions); |
| 1923 | queryOctree(NodeType::ParticleServer, PacketTypeParticleQuery, _particleServerJurisdictions); | 1943 | queryOctree(NodeType::ParticleServer, PacketTypeParticleQuery, _particleServerJurisdictions); |
| @@ -1930,26 +1950,28 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 6 unmodified lines | |||
| 1930 | return; | 1950 | return; |
| 1931 | } | 1951 | } |
| 1932 | 1952 | ||
| 1953 | //qDebug() << ">>> inside... queryOctree()... _viewFrustum.getFieldOfView()=" << _viewFrustum.getFieldOfView(); | ||
| 1954 | |||
| 1933 | bool wantExtraDebugging = getLogger()->extraDebugging(); | 1955 | bool wantExtraDebugging = getLogger()->extraDebugging(); |
| 1934 | 1956 | ||
| 1935 | // These will be the same for all servers, so we can set them up once and then reuse for each server we send to. | 1957 | // These will be the same for all servers, so we can set them up once and then reuse for each server we send to. |
| 1936 | _voxelQuery.setWantLowResMoving(!Menu::getInstance()->isOptionChecked(MenuOption::DisableLowRes)); | 1958 | _octreeQuery.setWantLowResMoving(true); |
| 1937 | _voxelQuery.setWantColor(!Menu::getInstance()->isOptionChecked(MenuOption::DisableColorVoxels)); | 1959 | _octreeQuery.setWantColor(true); |
| 1938 | _voxelQuery.setWantDelta(!Menu::getInstance()->isOptionChecked(MenuOption::DisableDeltaSending)); | 1960 | _octreeQuery.setWantDelta(true); |
| 1939 | _voxelQuery.setWantOcclusionCulling(Menu::getInstance()->isOptionChecked(MenuOption::EnableOcclusionCulling)); | 1961 | _octreeQuery.setWantOcclusionCulling(false); |
| 1940 | _voxelQuery.setWantCompression(Menu::getInstance()->isOptionChecked(MenuOption::EnableVoxelPacketCompression)); | 1962 | _octreeQuery.setWantCompression(true); |
| 1941 | 1963 | ||
| 1942 | _voxelQuery.setCameraPosition(_viewFrustum.getPosition()); | 1964 | _octreeQuery.setCameraPosition(_viewFrustum.getPosition()); |
| 1943 | _voxelQuery.setCameraOrientation(_viewFrustum.getOrientation()); | 1965 | _octreeQuery.setCameraOrientation(_viewFrustum.getOrientation()); |
| 1944 | _voxelQuery.setCameraFov(_viewFrustum.getFieldOfView()); | 1966 | _octreeQuery.setCameraFov(_viewFrustum.getFieldOfView()); |
| 1945 | _voxelQuery.setCameraAspectRatio(_viewFrustum.getAspectRatio()); | 1967 | _octreeQuery.setCameraAspectRatio(_viewFrustum.getAspectRatio()); |
| 1946 | _voxelQuery.setCameraNearClip(_viewFrustum.getNearClip()); | 1968 | _octreeQuery.setCameraNearClip(_viewFrustum.getNearClip()); |
| 1947 | _voxelQuery.setCameraFarClip(_viewFrustum.getFarClip()); | 1969 | _octreeQuery.setCameraFarClip(_viewFrustum.getFarClip()); |
| 1948 | _voxelQuery.setCameraEyeOffsetPosition(_viewFrustum.getEyeOffsetPosition()); | 1970 | _octreeQuery.setCameraEyeOffsetPosition(_viewFrustum.getEyeOffsetPosition()); |
| 1949 | _voxelQuery.setOctreeSizeScale(Menu::getInstance()->getVoxelSizeScale()); | 1971 | _octreeQuery.setOctreeSizeScale(Menu::getInstance()->getVoxelSizeScale()); |
| 1950 | _voxelQuery.setBoundaryLevelAdjust(Menu::getInstance()->getBoundaryLevelAdjust()); | 1972 | _octreeQuery.setBoundaryLevelAdjust(Menu::getInstance()->getBoundaryLevelAdjust()); |
| 1951 | 1973 | ||
| 1952 | unsigned char voxelQueryPacket[MAX_PACKET_SIZE]; | 1974 | unsigned char queryPacket[MAX_PACKET_SIZE]; |
| 1953 | 1975 | ||
| 1954 | // Iterate all of the nodes, and get a count of how many voxel servers we have... | 1976 | // Iterate all of the nodes, and get a count of how many voxel servers we have... |
| 1955 | int totalServers = 0; | 1977 | int totalServers = 0; |
| @@ -1989,7 +2011,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 33 unmodified lines | |||
| 1989 | } | 2011 | } |
| 1990 | } | 2012 | } |
| 1991 | 2013 | ||
| 1992 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { | 2014 | if (wantExtraDebugging) { |
| 1993 | qDebug("Servers: total %d, in view %d, unknown jurisdiction %d", | 2015 | qDebug("Servers: total %d, in view %d, unknown jurisdiction %d", |
| 1994 | totalServers, inViewServers, unknownJurisdictionServers); | 2016 | totalServers, inViewServers, unknownJurisdictionServers); |
| 1995 | } | 2017 | } |
| @@ -2010,7 +2032,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 14 unmodified lines | |||
| 2010 | } | 2032 | } |
| 2011 | } | 2033 | } |
| 2012 | 2034 | ||
| 2013 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { | 2035 | if (wantExtraDebugging) { |
| 2014 | qDebug("perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer); | 2036 | qDebug("perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer); |
| 2015 | } | 2037 | } |
| 2016 | 2038 | ||
| @@ -2059,7 +2081,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 42 unmodified lines | |||
| 2059 | } | 2081 | } |
| 2060 | 2082 | ||
| 2061 | if (inView) { | 2083 | if (inView) { |
| 2062 | _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS); | 2084 | _octreeQuery.setMaxOctreePacketsPerSecond(perServerPPS); |
| 2063 | } else if (unknownView) { | 2085 | } else if (unknownView) { |
| 2064 | if (wantExtraDebugging) { | 2086 | if (wantExtraDebugging) { |
| 2065 | qDebug() << "no known jurisdiction for node " << *node << ", give it budget of " | 2087 | qDebug() << "no known jurisdiction for node " << *node << ", give it budget of " |
| @@ -2070,11 +2092,11 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 4 unmodified lines | |||
| 2070 | // If there's only one server, then don't do this, and just let the normal voxel query pass through | 2092 | // If there's only one server, then don't do this, and just let the normal voxel query pass through |
| 2071 | // as expected... this way, we will actually get a valid scene if there is one to be seen | 2093 | // as expected... this way, we will actually get a valid scene if there is one to be seen |
| 2072 | if (totalServers > 1) { | 2094 | if (totalServers > 1) { |
| 2073 | _voxelQuery.setCameraPosition(glm::vec3(-0.1,-0.1,-0.1)); | 2095 | _octreeQuery.setCameraPosition(glm::vec3(-0.1,-0.1,-0.1)); |
| 2074 | const glm::quat OFF_IN_NEGATIVE_SPACE = glm::quat(-0.5, 0, -0.5, 1.0); | 2096 | const glm::quat OFF_IN_NEGATIVE_SPACE = glm::quat(-0.5, 0, -0.5, 1.0); |
| 2075 | _voxelQuery.setCameraOrientation(OFF_IN_NEGATIVE_SPACE); | 2097 | _octreeQuery.setCameraOrientation(OFF_IN_NEGATIVE_SPACE); |
| 2076 | _voxelQuery.setCameraNearClip(0.1f); | 2098 | _octreeQuery.setCameraNearClip(0.1f); |
| 2077 | _voxelQuery.setCameraFarClip(0.1f); | 2099 | _octreeQuery.setCameraFarClip(0.1f); |
| 2078 | if (wantExtraDebugging) { | 2100 | if (wantExtraDebugging) { |
| 2079 | qDebug() << "Using 'minimal' camera position for node" << *node; | 2101 | qDebug() << "Using 'minimal' camera position for node" << *node; |
| 2080 | } | 2102 | } |
| @@ -2083,23 +2105,23 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 2 unmodified lines | |||
| 2083 | qDebug() << "Using regular camera position for node" << *node; | 2105 | qDebug() << "Using regular camera position for node" << *node; |
| 2084 | } | 2106 | } |
| 2085 | } | 2107 | } |
| 2086 | _voxelQuery.setMaxOctreePacketsPerSecond(perUnknownServer); | 2108 | _octreeQuery.setMaxOctreePacketsPerSecond(perUnknownServer); |
| 2087 | } else { | 2109 | } else { |
| 2088 | _voxelQuery.setMaxOctreePacketsPerSecond(0); | 2110 | _octreeQuery.setMaxOctreePacketsPerSecond(0); |
| 2089 | } | 2111 | } |
| 2090 | // set up the packet for sending... | 2112 | // set up the packet for sending... |
| 2091 | unsigned char* endOfVoxelQueryPacket = voxelQueryPacket; | 2113 | unsigned char* endOfQueryPacket = queryPacket; |
| 2092 | 2114 | ||
| 2093 | // insert packet type/version and node UUID | 2115 | // insert packet type/version and node UUID |
| 2094 | endOfVoxelQueryPacket += populatePacketHeader(reinterpret_cast<char*>(endOfVoxelQueryPacket), packetType); | 2116 | endOfQueryPacket += populatePacketHeader(reinterpret_cast<char*>(endOfQueryPacket), packetType); |
| 2095 | 2117 | ||
| 2096 | // encode the query data... | 2118 | // encode the query data... |
| 2097 | endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket); | 2119 | endOfQueryPacket += _octreeQuery.getBroadcastData(endOfQueryPacket); |
| 2098 | 2120 | ||
| 2099 | int packetLength = endOfVoxelQueryPacket - voxelQueryPacket; | 2121 | int packetLength = endOfQueryPacket - queryPacket; |
| 2100 | 2122 | ||
| 2101 | // make sure we still have an active socket | 2123 | // make sure we still have an active socket |
| 2102 | nodeList->writeDatagram(reinterpret_cast<const char*>(voxelQueryPacket), packetLength, node); | 2124 | nodeList->writeDatagram(reinterpret_cast<const char*>(queryPacket), packetLength, node); |
| 2103 | 2125 | ||
| 2104 | // Feed number of bytes to corresponding channel of the bandwidth meter | 2126 | // Feed number of bytes to corresponding channel of the bandwidth meter |
| 2105 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength); | 2127 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength); |
| @@ -2341,14 +2363,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 235 unmodified lines | |||
| 2341 | if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { | 2363 | if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { |
| 2342 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 2364 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2343 | "Application::displaySide() ... voxels..."); | 2365 | "Application::displaySide() ... voxels..."); |
| 2344 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DontRenderVoxels)) { | 2366 | |
| 2345 | _voxels.render(); | 2367 | _voxels.render(); |
| 2346 | 2368 | ||
| 2347 | // double check that our LOD doesn't need to be auto-adjusted | 2369 | // double check that our LOD doesn't need to be auto-adjusted |
| 2348 | // only adjust if our option is set | 2370 | // adjust it unless we were asked to disable this feature |
| 2349 | if (Menu::getInstance()->isOptionChecked(MenuOption::AutoAdjustLOD)) { | 2371 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableAutoAdjustLOD)) { |
| 2350 | Menu::getInstance()->autoAdjustLOD(_fps); | 2372 | Menu::getInstance()->autoAdjustLOD(_fps); |
| 2351 | } | ||
| 2352 | } | 2373 | } |
| 2353 | } | 2374 | } |
| 2354 | 2375 | ||
| @@ -3406,7 +3427,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 1051 unmodified lines | |||
| 3406 | } | 3427 | } |
| 3407 | 3428 | ||
| 3408 | // If the voxel server is going away, remove it from our jurisdiction map so we don't send voxels to a dead server | 3429 | // If the voxel server is going away, remove it from our jurisdiction map so we don't send voxels to a dead server |
| 3409 | _voxelServerJurisdictions.erase(nodeUUID); | 3430 | _voxelServerJurisdictions.erase(_voxelServerJurisdictions.find(nodeUUID)); |
| 3410 | } | 3431 | } |
| 3411 | 3432 | ||
| 3412 | // also clean up scene stats for that server | 3433 | // also clean up scene stats for that server |
| @@ -3437,7 +3458,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 24 unmodified lines | |||
| 3437 | } | 3458 | } |
| 3438 | 3459 | ||
| 3439 | // If the voxel server is going away, remove it from our jurisdiction map so we don't send voxels to a dead server | 3460 | // If the voxel server is going away, remove it from our jurisdiction map so we don't send voxels to a dead server |
| 3440 | _particleServerJurisdictions.erase(nodeUUID); | 3461 | _particleServerJurisdictions.erase(_particleServerJurisdictions.find(nodeUUID)); |
| 3441 | } | 3462 | } |
| 3442 | 3463 | ||
| 3443 | // also clean up scene stats for that server | 3464 | // also clean up scene stats for that server |