History

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

ZappoMan committed 12 years ago

Commit fc507852 parents d886f4c a46610a102 files · +2684 −3930Browse files

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

Unified · Split

interface/src/Menu.cpp+88−16
@@ -122,7 +122,8 @@ Menu::Menu() : · 121 unmodified lines
122 _hasLoginDialogDisplayed(false),122 _hasLoginDialogDisplayed(false),
123 _snapshotsLocation(),123 _snapshotsLocation(),
124 _scriptsLocation(),124 _scriptsLocation(),
125 _walletPrivateKey()125 _walletPrivateKey(),
126 _shouldRenderTableNeedsRebuilding(true)
126{127{
127 Application *appInstance = Application::getInstance();128 Application *appInstance = Application::getInstance();
128 129
@@ -158,7 +159,7 @@ Menu::Menu() : · 29 unmodified lines
158 addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScriptURL,159 addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScriptURL,
159 Qt::CTRL | Qt::SHIFT | Qt::Key_O, appInstance, SLOT(loadScriptURLDialog()));160 Qt::CTRL | Qt::SHIFT | Qt::Key_O, appInstance, SLOT(loadScriptURLDialog()));
160 addActionToQMenuAndActionHash(fileMenu, MenuOption::StopAllScripts, 0, appInstance, SLOT(stopAllScripts()));161 addActionToQMenuAndActionHash(fileMenu, MenuOption::StopAllScripts, 0, appInstance, SLOT(stopAllScripts()));
161 addActionToQMenuAndActionHash(fileMenu, MenuOption::ReloadAllScripts, Qt::CTRL | Qt::SHIFT | Qt::Key_R,162 addActionToQMenuAndActionHash(fileMenu, MenuOption::ReloadAllScripts, Qt::CTRL | Qt::Key_R,
162 appInstance, SLOT(reloadAllScripts()));163 appInstance, SLOT(reloadAllScripts()));
163 addActionToQMenuAndActionHash(fileMenu, MenuOption::RunningScripts, Qt::CTRL | Qt::Key_J,164 addActionToQMenuAndActionHash(fileMenu, MenuOption::RunningScripts, Qt::CTRL | Qt::Key_J,
164 appInstance, SLOT(toggleRunningScriptsWidget()));165 appInstance, SLOT(toggleRunningScriptsWidget()));
@@ -246,10 +247,16 @@ Menu::Menu() : · 81 unmodified lines
246#endif247#endif
247 248
248 addActionToQMenuAndActionHash(toolsMenu,249 addActionToQMenuAndActionHash(toolsMenu,
249 MenuOption::Console,250 MenuOption::Console,
250 Qt::CTRL | Qt::ALT | Qt::Key_J,251 Qt::CTRL | Qt::ALT | Qt::Key_J,
251 this,252 this,
252 SLOT(toggleConsole()));253 SLOT(toggleConsole()));
254
255 addActionToQMenuAndActionHash(toolsMenu,
256 MenuOption::ResetSensors,
257 Qt::Key_Apostrophe,
258 appInstance,
259 SLOT(resetSensors()));
253 260
254 QMenu* avatarMenu = addMenu("Avatar");261 QMenu* avatarMenu = addMenu("Avatar");
255 262
@@ -365,7 +372,15 @@ Menu::Menu() : · 109 unmodified lines
365 shadowGroup->addAction(addCheckableActionToQMenuAndActionHash(shadowMenu, MenuOption::SimpleShadows, 0, false));372 shadowGroup->addAction(addCheckableActionToQMenuAndActionHash(shadowMenu, MenuOption::SimpleShadows, 0, false));
366 shadowGroup->addAction(addCheckableActionToQMenuAndActionHash(shadowMenu, MenuOption::CascadedShadows, 0, false));373 shadowGroup->addAction(addCheckableActionToQMenuAndActionHash(shadowMenu, MenuOption::CascadedShadows, 0, false));
367 374
368 375 QMenu* resolutionMenu = renderOptionsMenu->addMenu(MenuOption::RenderResolution);
376 QActionGroup* resolutionGroup = new QActionGroup(resolutionMenu);
377 resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionOne, 0, false));
378 resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionTwoThird, 0, false));
379 resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionHalf, 0, false));
380 resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionThird, 0, true));
381 resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionQuarter, 0, false));
382 connect(resolutionMenu, SIGNAL(triggered(QAction*)), this, SLOT(changeRenderResolution(QAction*)));
383
369 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Stars, Qt::Key_Asterisk, true);384 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Stars, Qt::Key_Asterisk, true);
370 addCheckableActionToQMenuAndActionHash(renderOptionsMenu,385 addCheckableActionToQMenuAndActionHash(renderOptionsMenu,
371 MenuOption::Voxels,386 MenuOption::Voxels,
@@ -374,11 +389,7 @@ Menu::Menu() : · 2 unmodified lines
374 appInstance,389 appInstance,
375 SLOT(setRenderVoxels(bool)));390 SLOT(setRenderVoxels(bool)));
376 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::EnableGlowEffect, 0, true);391 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::EnableGlowEffect, 0, true);
377 addActionToQMenuAndActionHash(renderOptionsMenu,392
378 MenuOption::GlowMode,
379 0,
380 appInstance->getGlowEffect(),
381 SLOT(cycleRenderMode()));
382 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Wireframe, Qt::ALT | Qt::Key_W, false);393 addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Wireframe, Qt::ALT | Qt::Key_W, false);
383 addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools()));394 addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools()));
384 395
@@ -391,10 +402,6 @@ Menu::Menu() : · 6 unmodified lines
391 appInstance->getFaceshift(),402 appInstance->getFaceshift(),
392 SLOT(setTCPEnabled(bool)));403 SLOT(setTCPEnabled(bool)));
393#endif404#endif
394#ifdef HAVE_FACEPLUS
395 addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::Faceplus, 0, true,
396 appInstance->getFaceplus(), SLOT(updateEnabled()));
397#endif
398#ifdef HAVE_VISAGE405#ifdef HAVE_VISAGE
399 addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::Visage, 0, false,406 addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::Visage, 0, false,
400 appInstance->getVisage(), SLOT(updateEnabled()));407 appInstance->getVisage(), SLOT(updateEnabled()));
@@ -410,6 +417,10 @@ Menu::Menu() : · 9 unmodified lines
410 addCheckableActionToQMenuAndActionHash(modelDebugMenu, MenuOption::DisplayModelBounds, 0, false);417 addCheckableActionToQMenuAndActionHash(modelDebugMenu, MenuOption::DisplayModelBounds, 0, false);
411 addCheckableActionToQMenuAndActionHash(modelDebugMenu, MenuOption::DisplayModelElementProxy, 0, false);418 addCheckableActionToQMenuAndActionHash(modelDebugMenu, MenuOption::DisplayModelElementProxy, 0, false);
412 addCheckableActionToQMenuAndActionHash(modelDebugMenu, MenuOption::DisplayModelElementChildProxies, 0, false);419 addCheckableActionToQMenuAndActionHash(modelDebugMenu, MenuOption::DisplayModelElementChildProxies, 0, false);
420 QMenu* modelCullingMenu = modelDebugMenu->addMenu("Culling");
421 addCheckableActionToQMenuAndActionHash(modelCullingMenu, MenuOption::DontCullOutOfViewMeshParts, 0, false);
422 addCheckableActionToQMenuAndActionHash(modelCullingMenu, MenuOption::DontCullTooSmallMeshParts, 0, false);
423 addCheckableActionToQMenuAndActionHash(modelCullingMenu, MenuOption::DontReduceMaterialSwitches, 0, false);
413 424
414 QMenu* voxelOptionsMenu = developerMenu->addMenu("Voxels");425 QMenu* voxelOptionsMenu = developerMenu->addMenu("Voxels");
415 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::VoxelTextures);426 addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::VoxelTextures);
@@ -1219,6 +1230,23 @@ void Menu::muteEnvironment() { · 803 unmodified lines
1219 free(packet);1230 free(packet);
1220}1231}
1221 1232
1233void Menu::changeRenderResolution(QAction* action) {
1234 QString text = action->text();
1235 if (text == MenuOption::RenderResolutionOne) {
1236 Application::getInstance()->setRenderResolutionScale(1.f);
1237 } else if (text == MenuOption::RenderResolutionTwoThird) {
1238 Application::getInstance()->setRenderResolutionScale(0.666f);
1239 } else if (text == MenuOption::RenderResolutionHalf) {
1240 Application::getInstance()->setRenderResolutionScale(0.5f);
1241 } else if (text == MenuOption::RenderResolutionThird) {
1242 Application::getInstance()->setRenderResolutionScale(0.333f);
1243 } else if (text == MenuOption::RenderResolutionQuarter) {
1244 Application::getInstance()->setRenderResolutionScale(0.25f);
1245 } else {
1246 Application::getInstance()->setRenderResolutionScale(1.f);
1247 }
1248}
1249
1222void Menu::displayNameLocationResponse(const QString& errorString) {1250void Menu::displayNameLocationResponse(const QString& errorString) {
1223 1251
1224 if (!errorString.isEmpty()) {1252 if (!errorString.isEmpty()) {
@@ -1517,6 +1545,7 @@ void Menu::autoAdjustLOD(float currentFPS) { · 292 unmodified lines
1517 && _voxelSizeScale > ADJUST_LOD_MIN_SIZE_SCALE) {1545 && _voxelSizeScale > ADJUST_LOD_MIN_SIZE_SCALE) {
1518 1546
1519 _voxelSizeScale *= ADJUST_LOD_DOWN_BY;1547 _voxelSizeScale *= ADJUST_LOD_DOWN_BY;
1548
1520 if (_voxelSizeScale < ADJUST_LOD_MIN_SIZE_SCALE) {1549 if (_voxelSizeScale < ADJUST_LOD_MIN_SIZE_SCALE) {
1521 _voxelSizeScale = ADJUST_LOD_MIN_SIZE_SCALE;1550 _voxelSizeScale = ADJUST_LOD_MIN_SIZE_SCALE;
1522 }1551 }
@@ -1539,6 +1568,7 @@ void Menu::autoAdjustLOD(float currentFPS) { · 16 unmodified lines
1539 }1568 }
1540 1569
1541 if (changed) {1570 if (changed) {
1571 _shouldRenderTableNeedsRebuilding = true;
1542 if (_lodToolsDialog) {1572 if (_lodToolsDialog) {
1543 _lodToolsDialog->reloadSliders();1573 _lodToolsDialog->reloadSliders();
1544 }1574 }
@@ -1553,14 +1583,56 @@ void Menu::resetLODAdjust() { · 8 unmodified lines
1553 1583
1554void Menu::setVoxelSizeScale(float sizeScale) {1584void Menu::setVoxelSizeScale(float sizeScale) {
1555 _voxelSizeScale = sizeScale;1585 _voxelSizeScale = sizeScale;
1586 _shouldRenderTableNeedsRebuilding = true;
1556 bumpSettings();1587 bumpSettings();
1557}1588}
1558 1589
1559void Menu::setBoundaryLevelAdjust(int boundaryLevelAdjust) {1590void Menu::setBoundaryLevelAdjust(int boundaryLevelAdjust) {
1560 _boundaryLevelAdjust = boundaryLevelAdjust;1591 _boundaryLevelAdjust = boundaryLevelAdjust;
1592 _shouldRenderTableNeedsRebuilding = true;
1561 bumpSettings();1593 bumpSettings();
1562}1594}
1563 1595
1596// TODO: This is essentially the same logic used to render voxels, but since models are more detailed then voxels
1597// I've added a voxelToModelRatio that adjusts how much closer to a model you have to be to see it.
1598bool Menu::shouldRenderMesh(float largestDimension, float distanceToCamera) {
1599 const float voxelToMeshRatio = 4.0f; // must be this many times closer to a mesh than a voxel to see it.
1600 float voxelSizeScale = getVoxelSizeScale();
1601 int boundaryLevelAdjust = getBoundaryLevelAdjust();
1602 float maxScale = (float)TREE_SCALE;
1603 float visibleDistanceAtMaxScale = boundaryDistanceForRenderLevel(boundaryLevelAdjust, voxelSizeScale) / voxelToMeshRatio;
1604
1605 if (_shouldRenderTableNeedsRebuilding) {
1606 _shouldRenderTable.clear();
1607
1608 float SMALLEST_SCALE_IN_TABLE = 0.001f; // 1mm is plenty small
1609 float scale = maxScale;
1610 float visibleDistanceAtScale = visibleDistanceAtMaxScale;
1611
1612 while (scale > SMALLEST_SCALE_IN_TABLE) {
1613 scale /= 2.0f;
1614 visibleDistanceAtScale /= 2.0f;
1615 _shouldRenderTable[scale] = visibleDistanceAtScale;
1616 }
1617 _shouldRenderTableNeedsRebuilding = false;
1618 }
1619
1620 float closestScale = maxScale;
1621 float visibleDistanceAtClosestScale = visibleDistanceAtMaxScale;
1622 QMap<float, float>::const_iterator lowerBound = _shouldRenderTable.lowerBound(largestDimension);
1623 if (lowerBound != _shouldRenderTable.constEnd()) {
1624 closestScale = lowerBound.key();
1625 visibleDistanceAtClosestScale = lowerBound.value();
1626 }
1627
1628 if (closestScale < largestDimension) {
1629 visibleDistanceAtClosestScale *= 2.0f;
1630 }
1631
1632 return (distanceToCamera <= visibleDistanceAtClosestScale);
1633}
1634
1635
1564void Menu::lodTools() {1636void Menu::lodTools() {
1565 if (!_lodToolsDialog) {1637 if (!_lodToolsDialog) {
1566 _lodToolsDialog = new LodToolsDialog(Application::getInstance()->getGLWidget());1638 _lodToolsDialog = new LodToolsDialog(Application::getInstance()->getGLWidget());