Showing the changes to interface/src/VoxelSystem.cpp (1 of 2 files). Show all
Unified · Split
| @@ -60,6 +60,7 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels) · 59 unmodified lines | ||
| 60 | 60 | _treeScale(treeScale), |
| 61 | 61 | _maxVoxels(maxVoxels), |
| 62 | 62 | _initialized(false), |
| 63 | + _inInspectForOcclusions(false), | |
| 63 | 64 | _showCulledSharedFaces(false), |
| 64 | 65 | _usePrimitiveRenderer(false), |
| 65 | 66 | _renderer(0) { |
| @@ -1028,7 +1029,6 @@ int VoxelSystem::updateNodeInArrays(VoxelTreeElement* node, bool reuseIndex, boo · 962 unmodified lines | ||
| 1028 | 1029 | } else { |
| 1029 | 1030 | node->setVoxelSystem(this); |
| 1030 | 1031 | } |
| 1031 | − inspectForInteriorOcclusionsOperation(node, 0); | |
| 1032 | 1032 | unsigned char occlusions; |
| 1033 | 1033 | if (_showCulledSharedFaces) { |
| 1034 | 1034 | occlusions = ~node->getInteriorOcclusions(); |
| @@ -1675,15 +1675,7 @@ void VoxelSystem::cullSharedFaces() { · 640 unmodified lines | ||
| 1675 | 1675 | _usePrimitiveRenderer = true; |
| 1676 | 1676 | _renderer->release(); |
| 1677 | 1677 | clearAllNodesBufferIndex(); |
| 1678 | − lockTree(); | |
| 1679 | − _tree->recurseTreeWithPostOperation(inspectForExteriorOcclusionsOperation); | |
| 1680 | − _tree->recurseTreeWithPostOperation(inspectForExteriorOcclusionsOperation); | |
| 1681 | − unlockTree(); | |
| 1682 | − | |
| 1683 | − _nodeCount = 0; | |
| 1684 | − lockTree(); | |
| 1685 | − _tree->recurseTreeWithOperation(inspectForInteriorOcclusionsOperation); | |
| 1686 | − unlockTree(); | |
| 1678 | + inspectForOcclusions(); | |
| 1687 | 1679 | qDebug("culling shared faces in %d nodes", _nodeCount); |
| 1688 | 1680 | } else { |
| 1689 | 1681 | _usePrimitiveRenderer = false; |
| @@ -1710,8 +1702,30 @@ void VoxelSystem::showCulledSharedFaces() { · 20 unmodified lines | ||
| 1710 | 1702 | _showCulledSharedFaces = false; |
| 1711 | 1703 | } |
| 1712 | 1704 | if (Menu::getInstance()->isOptionChecked(MenuOption::CullSharedFaces)) { |
| 1713 | − cullSharedFaces(); | |
| 1705 | + _writeRenderFullVBO = true; | |
| 1706 | + _tree->setDirtyBit(); | |
| 1707 | + setupNewVoxelsForDrawing(); | |
| 1708 | + } | |
| 1709 | +} | |
| 1710 | + | |
| 1711 | +void VoxelSystem::inspectForOcclusions() { | |
| 1712 | + | |
| 1713 | + // don't re-enter... | |
| 1714 | + if (_inInspectForOcclusions) { | |
| 1715 | + return; | |
| 1714 | 1716 | } |
| 1717 | + | |
| 1718 | + _inInspectForOcclusions = true; | |
| 1719 | + | |
| 1720 | + bool showDebugDetails = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 1721 | + PerformanceWarning warn(showDebugDetails, "inspectForOcclusions()"); | |
| 1722 | + | |
| 1723 | + lockTree(); | |
| 1724 | + _tree->recurseTreeWithPostOperation(inspectForExteriorOcclusionsOperation); | |
| 1725 | + _tree->recurseTreeWithOperation(inspectForInteriorOcclusionsOperation); | |
| 1726 | + unlockTree(); | |
| 1727 | + | |
| 1728 | + _inInspectForOcclusions = false; | |
| 1715 | 1729 | } |
| 1716 | 1730 | |
| 1717 | 1731 | bool VoxelSystem::forceRedrawEntireTreeOperation(OctreeElement* element, void* extraData) { |
| @@ -2338,11 +2352,12 @@ bool VoxelSystem::showAllSubTreeOperation(OctreeElement* element, void* extraDat · 620 unmodified lines | ||
| 2338 | 2352 | voxel->setDirtyBit(); |
| 2339 | 2353 | voxel->markWithChangedTime(); |
| 2340 | 2354 | // and this? |
| 2341 | − { | |
| 2342 | − VoxelSystem* thisVoxelSystem = args->thisVoxelSystem; | |
| 2343 | − thisVoxelSystem->_voxelsUpdated += thisVoxelSystem->updateNodeInArrays(voxel, true, true); | |
| 2344 | − thisVoxelSystem->setupNewVoxelsForDrawingSingleNode(); | |
| 2345 | − } | |
| 2355 | +// no, not needed, because markWithChangedTime notifies hooks, which calls elementUpdated, which calls updateNodeInArrays | |
| 2356 | +// { | |
| 2357 | +// VoxelSystem* thisVoxelSystem = args->thisVoxelSystem; | |
| 2358 | +// thisVoxelSystem->_voxelsUpdated += thisVoxelSystem->updateNodeInArrays(voxel, true, true); | |
| 2359 | +// thisVoxelSystem->setupNewVoxelsForDrawingSingleNode(); | |
| 2360 | +// } | |
| 2346 | 2361 | args->nodesShown++; |
| 2347 | 2362 | } |
| 2348 | 2363 | |
| @@ -2386,7 +2401,6 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData · 37 unmodified lines | ||
| 2386 | 2401 | // we need to hide it. Additionally we know that ALL of it's children are also fully OUTSIDE so we can recurse |
| 2387 | 2402 | // the children and simply mark them as hidden |
| 2388 | 2403 | args->tree->recurseNodeWithOperation(voxel, hideAllSubTreeOperation, args ); |
| 2389 | − | |
| 2390 | 2404 | return false; |
| 2391 | 2405 | |
| 2392 | 2406 | } break; |
| @@ -2576,25 +2590,29 @@ bool VoxelSystem::collectStatsForTreesAndVBOsOperation(OctreeElement* element, v · 183 unmodified lines | ||
| 2576 | 2590 | } |
| 2577 | 2591 | |
| 2578 | 2592 | unsigned long nodeIndex = 0; |
| 2579 | − if (voxel->isKnownBufferIndex()) { | |
| 2580 | − args->nodesInVBO++; | |
| 2581 | − nodeIndex = voxel->getBufferIndex(); | |
| 2582 | − } | |
| 2583 | − | |
| 2584 | 2593 | if (voxel->getPrimitiveIndex()) { |
| 2585 | 2594 | args->nodesInPrimitiveRenderer++; |
| 2586 | 2595 | nodeIndex = voxel->getPrimitiveIndex(); |
| 2587 | − } | |
| 2588 | − | |
| 2589 | − if (voxel->isKnownBufferIndex() || (voxel->getPrimitiveIndex() != 0)) { | |
| 2590 | 2596 | |
| 2591 | 2597 | const bool extraDebugging = false; // enable for extra debugging |
| 2592 | 2598 | if (extraDebugging) { |
| 2593 | − qDebug("node In VBO... [%f,%f,%f] %f ... index=%ld, isDirty=%s, shouldRender=%s, culledFaces=0x%02x \n", | |
| 2599 | + qDebug("node In Renderer... [%f,%f,%f] %f ... index=%ld, isDirty=%s, shouldRender=%s, culledFaces=0x%02x \n", | |
| 2594 | 2600 | voxel->getCorner().x, voxel->getCorner().y, voxel->getCorner().z, voxel->getScale(), |
| 2595 | 2601 | nodeIndex, debug::valueOf(voxel->isDirty()), debug::valueOf(voxel->getShouldRender()), |
| 2596 | 2602 | voxel->getInteriorOcclusions()); |
| 2597 | 2603 | } |
| 2604 | + } | |
| 2605 | + | |
| 2606 | + if (voxel->isKnownBufferIndex()) { | |
| 2607 | + args->nodesInVBO++; | |
| 2608 | + nodeIndex = voxel->getBufferIndex(); | |
| 2609 | + | |
| 2610 | + const bool extraDebugging = false; // enable for extra debugging | |
| 2611 | + if (extraDebugging) { | |
| 2612 | + qDebug("node In VBO... [%f,%f,%f] %f ... index=%ld, isDirty=%s, shouldRender=%s \n", | |
| 2613 | + voxel->getCorner().x, voxel->getCorner().y, voxel->getCorner().z, voxel->getScale(), | |
| 2614 | + nodeIndex, debug::valueOf(voxel->isDirty()), debug::valueOf(voxel->getShouldRender())); | |
| 2615 | + } | |
| 2598 | 2616 | |
| 2599 | 2617 | if (args->hasIndexFound[nodeIndex]) { |
| 2600 | 2618 | args->duplicateVBOIndex++; |