History

Merge branch 'master' of https://github.com/highfidelity/hifi into local_voxels

Atlante45 committed 12 years ago

Commit 2ee79742 parents 11e80e0 0530a7346 files · +999 −476Browse files

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

Unified · Split

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

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