Showing the changes to interface/src/VoxelSystem.cpp (1 of 2 files). Show all
Unified · Split
| @@ -1542,15 +1542,17 @@ bool VoxelSystem::inspectForInteriorOcclusionsOperation(OctreeElement* element, · 1541 unmodified lines | |||
| 1542 | exteriorOcclusionsB; | 1542 | exteriorOcclusionsB; |
| 1543 | 1543 | ||
| 1544 | // Determine which face of each sibling is occluded. | 1544 | // Determine which face of each sibling is occluded. |
| 1545 | // Note the intentionally crossed indicies. It is necessary because | 1545 | |
| 1546 | // the _sOctantIndexToBitMask is a partition occupancy mask. For | 1546 | // The _sOctantIndexToBitMask is a partition occupancy mask. For |
| 1547 | // example, if the near-left-top (NLT) and near-left-bottom (NLB) child voxels | 1547 | // example, if the near-left-top (NLT) and near-left-bottom (NLB) child voxels |
| 1548 | // exist, the shared partition is top-bottom (TB), and thus the occluded | 1548 | // exist, the shared partition is top-bottom (TB), and thus the occluded |
| 1549 | // shared face of the NLT voxel is its bottom face. | 1549 | // shared face of the NLT voxel is its bottom face. |
| 1550 | occludedSharedFace[i] |= (partitionB & _sOctantIndexToBitMask[j]); | 1550 | occludedSharedFace[i] |= (partitionB & _sOctantIndexToBitMask[i]); |
| 1551 | occludedSharedFace[j] |= (partitionA & _sOctantIndexToBitMask[i]); | 1551 | occludedSharedFace[j] |= (partitionA & _sOctantIndexToBitMask[j]); |
| 1552 | } | 1552 | } |
| 1553 | } | 1553 | } |
| 1554 | // Exchange bit pairs, left to right, vice versa, etc. | ||
| 1555 | occludedSharedFace[i] = _sSwizzledOcclusionBits[occludedSharedFace[i]]; | ||
| 1554 | // Combine this voxel's interior excluded shared face only to those children which are coincident | 1556 | // Combine this voxel's interior excluded shared face only to those children which are coincident |
| 1555 | // with the excluded face. | 1557 | // with the excluded face. |
| 1556 | occludedSharedFace[i] |= (voxel->getInteriorOcclusions() & _sOctantIndexToBitMask[i]); | 1558 | occludedSharedFace[i] |= (voxel->getInteriorOcclusions() & _sOctantIndexToBitMask[i]); |
| @@ -1669,16 +1671,10 @@ void VoxelSystem::cullSharedFaces() { · 112 unmodified lines | |||
| 1669 | _useVoxelShader = false; | 1671 | _useVoxelShader = false; |
| 1670 | _usePrimitiveRenderer = true; | 1672 | _usePrimitiveRenderer = true; |
| 1671 | clearAllNodesBufferIndex(); | 1673 | clearAllNodesBufferIndex(); |
| 1672 | if (_renderer) { | ||
| 1673 | _renderer->release(); | ||
| 1674 | } | ||
| 1675 | inspectForOcclusions(); | 1674 | inspectForOcclusions(); |
| 1676 | } else { | 1675 | } else { |
| 1677 | _usePrimitiveRenderer = false; | 1676 | _usePrimitiveRenderer = false; |
| 1678 | clearAllNodesBufferIndex(); | 1677 | clearAllNodesBufferIndex(); |
| 1679 | if (_renderer) { | ||
| 1680 | _renderer->release(); | ||
| 1681 | } | ||
| 1682 | clearAllOcclusions(); | 1678 | clearAllOcclusions(); |
| 1683 | } | 1679 | } |
| 1684 | } | 1680 | } |
| @@ -1693,6 +1689,9 @@ void VoxelSystem::showCulledSharedFaces() { · 8 unmodified lines | |||
| 1693 | } | 1689 | } |
| 1694 | _tree->unlock(); | 1690 | _tree->unlock(); |
| 1695 | if (Menu::getInstance()->isOptionChecked(MenuOption::CullSharedFaces)) { | 1691 | if (Menu::getInstance()->isOptionChecked(MenuOption::CullSharedFaces)) { |
| 1692 | if (_renderer) { | ||
| 1693 | _renderer->release(); | ||
| 1694 | } | ||
| 1696 | _writeRenderFullVBO = true; | 1695 | _writeRenderFullVBO = true; |
| 1697 | _tree->setDirtyBit(); | 1696 | _tree->setDirtyBit(); |
| 1698 | setupNewVoxelsForDrawing(); | 1697 | setupNewVoxelsForDrawing(); |
| @@ -1711,6 +1710,10 @@ void VoxelSystem::clearAllOcclusions() { · 12 unmodified lines | |||
| 1711 | PerformanceWarning warn(showDebugDetails, "clearAllOcclusions()"); | 1710 | PerformanceWarning warn(showDebugDetails, "clearAllOcclusions()"); |
| 1712 | 1711 | ||
| 1713 | _tree->lockForRead(); | 1712 | _tree->lockForRead(); |
| 1713 | if (_renderer) { | ||
| 1714 | _renderer->release(); | ||
| 1715 | } | ||
| 1716 | |||
| 1714 | _tree->recurseTreeWithOperation(clearAllOcclusionsOperation); | 1717 | _tree->recurseTreeWithOperation(clearAllOcclusionsOperation); |
| 1715 | _tree->unlock(); | 1718 | _tree->unlock(); |
| 1716 | 1719 | ||
| @@ -1736,15 +1739,19 @@ void VoxelSystem::inspectForOcclusions() { · 19 unmodified lines | |||
| 1736 | PerformanceWarning warn(showDebugDetails, "inspectForOcclusions()"); | 1739 | PerformanceWarning warn(showDebugDetails, "inspectForOcclusions()"); |
| 1737 | 1740 | ||
| 1738 | _tree->lockForRead(); | 1741 | _tree->lockForRead(); |
| 1742 | if (_renderer) { | ||
| 1743 | _renderer->release(); | ||
| 1744 | } | ||
| 1745 | |||
| 1739 | _tree->recurseTreeWithPostOperation(inspectForExteriorOcclusionsOperation); | 1746 | _tree->recurseTreeWithPostOperation(inspectForExteriorOcclusionsOperation); |
| 1740 | _nodeCount = 0; | 1747 | _nodeCount = 0; |
| 1741 | _tree->recurseTreeWithOperation(inspectForInteriorOcclusionsOperation); | 1748 | _tree->recurseTreeWithOperation(inspectForInteriorOcclusionsOperation); |
| 1742 | _tree->unlock(); | 1749 | _tree->unlock(); |
| 1743 | 1750 | ||
| 1744 | if (showDebugDetails) { | 1751 | if (showDebugDetails) { |
| 1745 | qDebug("inspecting all occlusions of %d nodes", _nodeCount); | 1752 | qDebug("inspecting all occlusions of %d nodes", _nodeCount); |
| 1746 | } | 1753 | } |
| 1747 | _writeRenderFullVBO = true; | 1754 | _writeRenderFullVBO = true; |
| 1748 | _tree->setDirtyBit(); | 1755 | _tree->setDirtyBit(); |
| 1749 | setupNewVoxelsForDrawing(); | 1756 | setupNewVoxelsForDrawing(); |
| 1750 | _inOcclusions = false; | 1757 | _inOcclusions = false; |
| @@ -3127,6 +3134,74 @@ unsigned long VoxelSystem::getVoxelMemoryUsageGPU() { · 1376 unmodified lines | |||
| 3127 | return (_initialMemoryUsageGPU - currentFreeMemory); | 3134 | return (_initialMemoryUsageGPU - currentFreeMemory); |
| 3128 | } | 3135 | } |
| 3129 | 3136 | ||
| 3137 | // Swizzle value of bit pairs of the value of index | ||
| 3138 | unsigned short VoxelSystem::_sSwizzledOcclusionBits[64] = { | ||
| 3139 | 0x0000, // 00000000 | ||
| 3140 | 0x0002, // 00000001 | ||
| 3141 | 0x0001, // 00000010 | ||
| 3142 | 0x0003, // 00000011 | ||
| 3143 | 0x0008, // 00000100 | ||
| 3144 | 0x000a, // 00000101 | ||
| 3145 | 0x0009, // 00000110 | ||
| 3146 | 0x000b, // 00000111 | ||
| 3147 | 0x0004, // 00001000 | ||
| 3148 | 0x0006, // 00001001 | ||
| 3149 | 0x0005, // 00001010 | ||
| 3150 | 0x0007, // 00001011 | ||
| 3151 | 0x000c, // 00001100 | ||
| 3152 | 0x000e, // 00001101 | ||
| 3153 | 0x000d, // 00001110 | ||
| 3154 | 0x000f, // 00001111 | ||
| 3155 | 0x0020, // 00010000 | ||
| 3156 | 0x0022, // 00010001 | ||
| 3157 | 0x0021, // 00010010 | ||
| 3158 | 0x0023, // 00010011 | ||
| 3159 | 0x0028, // 00010100 | ||
| 3160 | 0x002a, // 00010101 | ||
| 3161 | 0x0029, // 00010110 | ||
| 3162 | 0x002b, // 00010111 | ||
| 3163 | 0x0024, // 00011000 | ||
| 3164 | 0x0026, // 00011001 | ||
| 3165 | 0x0025, // 00011010 | ||
| 3166 | 0x0027, // 00011011 | ||
| 3167 | 0x002c, // 00011100 | ||
| 3168 | 0x002e, // 00011101 | ||
| 3169 | 0x002d, // 00011110 | ||
| 3170 | 0x002f, // 00011111 | ||
| 3171 | 0x0010, // 00100000 | ||
| 3172 | 0x0012, // 00100001 | ||
| 3173 | 0x0011, // 00100010 | ||
| 3174 | 0x0013, // 00100011 | ||
| 3175 | 0x0018, // 00100100 | ||
| 3176 | 0x001a, // 00100101 | ||
| 3177 | 0x0019, // 00100110 | ||
| 3178 | 0x001b, // 00100111 | ||
| 3179 | 0x0014, // 00101000 | ||
| 3180 | 0x0016, // 00101001 | ||
| 3181 | 0x0015, // 00101010 | ||
| 3182 | 0x0017, // 00101011 | ||
| 3183 | 0x001c, // 00101100 | ||
| 3184 | 0x001e, // 00101101 | ||
| 3185 | 0x001d, // 00101110 | ||
| 3186 | 0x001f, // 00101111 | ||
| 3187 | 0x0030, // 00110000 | ||
| 3188 | 0x0032, // 00110001 | ||
| 3189 | 0x0031, // 00110010 | ||
| 3190 | 0x0033, // 00110011 | ||
| 3191 | 0x0038, // 00110100 | ||
| 3192 | 0x003a, // 00110101 | ||
| 3193 | 0x0039, // 00110110 | ||
| 3194 | 0x003b, // 00110111 | ||
| 3195 | 0x0034, // 00111000 | ||
| 3196 | 0x0036, // 00111001 | ||
| 3197 | 0x0035, // 00111010 | ||
| 3198 | 0x0037, // 00111011 | ||
| 3199 | 0x003c, // 00111100 | ||
| 3200 | 0x003e, // 00111101 | ||
| 3201 | 0x003d, // 00111110 | ||
| 3202 | 0x003f, // 00111111 | ||
| 3203 | }; | ||
| 3204 | |||
| 3130 | // Octant bitmask array indexed by octant. The mask value indicates the octant's halfspace partitioning. The index | 3205 | // Octant bitmask array indexed by octant. The mask value indicates the octant's halfspace partitioning. The index |
| 3131 | // value corresponds to the voxel's octal code derived in "pointToVoxel" in SharedUtil.cpp, which, BTW, does *not* | 3206 | // value corresponds to the voxel's octal code derived in "pointToVoxel" in SharedUtil.cpp, which, BTW, does *not* |
| 3132 | // correspond to the "ChildIndex" enum value in OctreeElement.h | 3207 | // correspond to the "ChildIndex" enum value in OctreeElement.h |