History

Moved Menu::shouldRenderMesh() to LODManager

Atlante45 committed 11 years ago

Commit 3fbc8c51 parent a9047b79 files · +54 −51Browse files

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

Unified · Split

interface/src/Menu.cpp+0−39
@@ -1388,45 +1388,6 @@ void Menu::octreeStatsDetails() { · 1387 unmodified lines
1388 _octreeStatsDialog->raise();1388 _octreeStatsDialog->raise();
1389}1389}
1390 1390
1391// TODO: This is essentially the same logic used to render octree cells, but since models are more detailed then octree cells
1392// I've added a voxelToModelRatio that adjusts how much closer to a model you have to be to see it.
1393bool Menu::shouldRenderMesh(float largestDimension, float distanceToCamera) {
1394 const float octreeToMeshRatio = 4.0f; // must be this many times closer to a mesh than a voxel to see it.
1395 float octreeSizeScale = getOctreeSizeScale();
1396 int boundaryLevelAdjust = getBoundaryLevelAdjust();
1397 float maxScale = (float)TREE_SCALE;
1398 float visibleDistanceAtMaxScale = boundaryDistanceForRenderLevel(boundaryLevelAdjust, octreeSizeScale) / octreeToMeshRatio;
1399
1400 if (_shouldRenderTableNeedsRebuilding) {
1401 _shouldRenderTable.clear();
1402
1403 float SMALLEST_SCALE_IN_TABLE = 0.001f; // 1mm is plenty small
1404 float scale = maxScale;
1405 float visibleDistanceAtScale = visibleDistanceAtMaxScale;
1406
1407 while (scale > SMALLEST_SCALE_IN_TABLE) {
1408 scale /= 2.0f;
1409 visibleDistanceAtScale /= 2.0f;
1410 _shouldRenderTable[scale] = visibleDistanceAtScale;
1411 }
1412 _shouldRenderTableNeedsRebuilding = false;
1413 }
1414
1415 float closestScale = maxScale;
1416 float visibleDistanceAtClosestScale = visibleDistanceAtMaxScale;
1417 QMap<float, float>::const_iterator lowerBound = _shouldRenderTable.lowerBound(largestDimension);
1418 if (lowerBound != _shouldRenderTable.constEnd()) {
1419 closestScale = lowerBound.key();
1420 visibleDistanceAtClosestScale = lowerBound.value();
1421 }
1422
1423 if (closestScale < largestDimension) {
1424 visibleDistanceAtClosestScale *= 2.0f;
1425 }
1426
1427 return (distanceToCamera <= visibleDistanceAtClosestScale);
1428}
1429
1430void Menu::cachesSizeDialog() {1391void Menu::cachesSizeDialog() {
1431 qDebug() << "Caches size:" << _cachesSizeDialog.isNull();1392 qDebug() << "Caches size:" << _cachesSizeDialog.isNull();
1432 if (!_cachesSizeDialog) {1393 if (!_cachesSizeDialog) {