Showing the changes to interface/src/Menu.cpp (1 of 102 files). Show all
Unified · Split
| @@ -122,7 +122,8 @@ Menu::Menu() : · 121 unmodified lines | ||
| 122 | 122 | _hasLoginDialogDisplayed(false), |
| 123 | 123 | _snapshotsLocation(), |
| 124 | 124 | _scriptsLocation(), |
| 125 | − _walletPrivateKey() | |
| 125 | + _walletPrivateKey(), | |
| 126 | + _shouldRenderTableNeedsRebuilding(true) | |
| 126 | 127 | { |
| 127 | 128 | Application *appInstance = Application::getInstance(); |
| 128 | 129 | |
| @@ -158,7 +159,7 @@ Menu::Menu() : · 29 unmodified lines | ||
| 158 | 159 | addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScriptURL, |
| 159 | 160 | Qt::CTRL | Qt::SHIFT | Qt::Key_O, appInstance, SLOT(loadScriptURLDialog())); |
| 160 | 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 | 163 | appInstance, SLOT(reloadAllScripts())); |
| 163 | 164 | addActionToQMenuAndActionHash(fileMenu, MenuOption::RunningScripts, Qt::CTRL | Qt::Key_J, |
| 164 | 165 | appInstance, SLOT(toggleRunningScriptsWidget())); |
| @@ -246,10 +247,16 @@ Menu::Menu() : · 81 unmodified lines | ||
| 246 | 247 | #endif |
| 247 | 248 | |
| 248 | 249 | addActionToQMenuAndActionHash(toolsMenu, |
| 249 | − MenuOption::Console, | |
| 250 | − Qt::CTRL | Qt::ALT | Qt::Key_J, | |
| 251 | − this, | |
| 252 | − SLOT(toggleConsole())); | |
| 250 | + MenuOption::Console, | |
| 251 | + Qt::CTRL | Qt::ALT | Qt::Key_J, | |
| 252 | + this, | |
| 253 | + SLOT(toggleConsole())); | |
| 254 | + | |
| 255 | + addActionToQMenuAndActionHash(toolsMenu, | |
| 256 | + MenuOption::ResetSensors, | |
| 257 | + Qt::Key_Apostrophe, | |
| 258 | + appInstance, | |
| 259 | + SLOT(resetSensors())); | |
| 253 | 260 | |
| 254 | 261 | QMenu* avatarMenu = addMenu("Avatar"); |
| 255 | 262 | |
| @@ -365,7 +372,15 @@ Menu::Menu() : · 109 unmodified lines | ||
| 365 | 372 | shadowGroup->addAction(addCheckableActionToQMenuAndActionHash(shadowMenu, MenuOption::SimpleShadows, 0, false)); |
| 366 | 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 | 384 | addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Stars, Qt::Key_Asterisk, true); |
| 370 | 385 | addCheckableActionToQMenuAndActionHash(renderOptionsMenu, |
| 371 | 386 | MenuOption::Voxels, |
| @@ -374,11 +389,7 @@ Menu::Menu() : · 2 unmodified lines | ||
| 374 | 389 | appInstance, |
| 375 | 390 | SLOT(setRenderVoxels(bool))); |
| 376 | 391 | addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::EnableGlowEffect, 0, true); |
| 377 | − addActionToQMenuAndActionHash(renderOptionsMenu, | |
| 378 | − MenuOption::GlowMode, | |
| 379 | − 0, | |
| 380 | − appInstance->getGlowEffect(), | |
| 381 | − SLOT(cycleRenderMode())); | |
| 392 | + | |
| 382 | 393 | addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Wireframe, Qt::ALT | Qt::Key_W, false); |
| 383 | 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 | 402 | appInstance->getFaceshift(), |
| 392 | 403 | SLOT(setTCPEnabled(bool))); |
| 393 | 404 | #endif |
| 394 | −#ifdef HAVE_FACEPLUS | |
| 395 | − addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::Faceplus, 0, true, | |
| 396 | − appInstance->getFaceplus(), SLOT(updateEnabled())); | |
| 397 | −#endif | |
| 398 | 405 | #ifdef HAVE_VISAGE |
| 399 | 406 | addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::Visage, 0, false, |
| 400 | 407 | appInstance->getVisage(), SLOT(updateEnabled())); |
| @@ -410,6 +417,10 @@ Menu::Menu() : · 9 unmodified lines | ||
| 410 | 417 | addCheckableActionToQMenuAndActionHash(modelDebugMenu, MenuOption::DisplayModelBounds, 0, false); |
| 411 | 418 | addCheckableActionToQMenuAndActionHash(modelDebugMenu, MenuOption::DisplayModelElementProxy, 0, false); |
| 412 | 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 | 425 | QMenu* voxelOptionsMenu = developerMenu->addMenu("Voxels"); |
| 415 | 426 | addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::VoxelTextures); |
| @@ -1219,6 +1230,23 @@ void Menu::muteEnvironment() { · 803 unmodified lines | ||
| 1219 | 1230 | free(packet); |
| 1220 | 1231 | } |
| 1221 | 1232 | |
| 1233 | +void 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 | + | |
| 1222 | 1250 | void Menu::displayNameLocationResponse(const QString& errorString) { |
| 1223 | 1251 | |
| 1224 | 1252 | if (!errorString.isEmpty()) { |
| @@ -1517,6 +1545,7 @@ void Menu::autoAdjustLOD(float currentFPS) { · 292 unmodified lines | ||
| 1517 | 1545 | && _voxelSizeScale > ADJUST_LOD_MIN_SIZE_SCALE) { |
| 1518 | 1546 | |
| 1519 | 1547 | _voxelSizeScale *= ADJUST_LOD_DOWN_BY; |
| 1548 | + | |
| 1520 | 1549 | if (_voxelSizeScale < ADJUST_LOD_MIN_SIZE_SCALE) { |
| 1521 | 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 | 1570 | if (changed) { |
| 1571 | + _shouldRenderTableNeedsRebuilding = true; | |
| 1542 | 1572 | if (_lodToolsDialog) { |
| 1543 | 1573 | _lodToolsDialog->reloadSliders(); |
| 1544 | 1574 | } |
| @@ -1553,14 +1583,56 @@ void Menu::resetLODAdjust() { · 8 unmodified lines | ||
| 1553 | 1583 | |
| 1554 | 1584 | void Menu::setVoxelSizeScale(float sizeScale) { |
| 1555 | 1585 | _voxelSizeScale = sizeScale; |
| 1586 | + _shouldRenderTableNeedsRebuilding = true; | |
| 1556 | 1587 | bumpSettings(); |
| 1557 | 1588 | } |
| 1558 | 1589 | |
| 1559 | 1590 | void Menu::setBoundaryLevelAdjust(int boundaryLevelAdjust) { |
| 1560 | 1591 | _boundaryLevelAdjust = boundaryLevelAdjust; |
| 1592 | + _shouldRenderTableNeedsRebuilding = true; | |
| 1561 | 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. | |
| 1598 | +bool 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 | + | |
| 1564 | 1636 | void Menu::lodTools() { |
| 1565 | 1637 | if (!_lodToolsDialog) { |
| 1566 | 1638 | _lodToolsDialog = new LodToolsDialog(Application::getInstance()->getGLWidget()); |