Showing the changes to interface/src/VoxelSystem.cpp (1 of 5 files). Show all
Unified · Split
| @@ -1050,15 +1050,13 @@ int VoxelSystem::updateNodeInArrays(VoxelTreeElement* node, bool reuseIndex, boo · 1049 unmodified lines | ||
| 1050 | 1050 | if (primitiveIndex) { |
| 1051 | 1051 | _renderer->remove(primitiveIndex); |
| 1052 | 1052 | node->setPrimitiveIndex(0); |
| 1053 | − } | |
| 1054 | − else { | |
| 1053 | + } else { | |
| 1055 | 1054 | node->setVoxelSystem(this); |
| 1056 | 1055 | } |
| 1057 | 1056 | inspectForInteriorOcclusionsOperation(node, 0); |
| 1058 | 1057 | |
| 1059 | − if (node->getInteriorOcclusions() != OctreeElement::HalfSpace::All) | |
| 1060 | − { | |
| 1061 | − Cube *cube = new Cube( | |
| 1058 | + if (node->getInteriorOcclusions() != OctreeElement::HalfSpace::All) { | |
| 1059 | + Cube* cube = new Cube( | |
| 1062 | 1060 | startVertex.x, startVertex.y, startVertex.z, voxelScale, |
| 1063 | 1061 | color[RED_INDEX], color[GREEN_INDEX], color[BLUE_INDEX], |
| 1064 | 1062 | node->getInteriorOcclusions()); |
| @@ -1067,8 +1065,7 @@ int VoxelSystem::updateNodeInArrays(VoxelTreeElement* node, bool reuseIndex, boo · 2 unmodified lines | ||
| 1067 | 1065 | node->setPrimitiveIndex(primitiveIndex); |
| 1068 | 1066 | } |
| 1069 | 1067 | } |
| 1070 | − } | |
| 1071 | − else { | |
| 1068 | + } else { | |
| 1072 | 1069 | glBufferIndex nodeIndex = GLBUFFER_INDEX_UNKNOWN; |
| 1073 | 1070 | if (reuseIndex && node->isKnownBufferIndex()) { |
| 1074 | 1071 | nodeIndex = node->getBufferIndex(); |
| @@ -1531,12 +1528,12 @@ bool VoxelSystem::inspectForInteriorOcclusionsOperation(OctreeElement* element, · 456 unmodified lines | ||
| 1531 | 1528 | } |
| 1532 | 1529 | |
| 1533 | 1530 | // Bit mask of occluded shared faces indexed by child |
| 1534 | − unsigned char occludedSharedFace[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; | |
| 1531 | + unsigned char occludedSharedFace[NUMBER_OF_CHILDREN] = { 0, 0, 0, 0, 0, 0, 0, 0 }; | |
| 1535 | 1532 | |
| 1536 | 1533 | // Traverse all pair combinations of children |
| 1537 | 1534 | for (int i = NUMBER_OF_CHILDREN; --i >= 0; ) { |
| 1538 | 1535 | |
| 1539 | − VoxelTreeElement *childA = voxel->getChildAtIndex(i); | |
| 1536 | + VoxelTreeElement* childA = voxel->getChildAtIndex(i); | |
| 1540 | 1537 | if (childA) { |
| 1541 | 1538 | |
| 1542 | 1539 | // Get the child A's occluding faces, for a leaf that will be |
| @@ -1551,7 +1548,7 @@ bool VoxelSystem::inspectForInteriorOcclusionsOperation(OctreeElement* element, · 8 unmodified lines | ||
| 1551 | 1548 | |
| 1552 | 1549 | for (int j = i; --j >= 0; ) { |
| 1553 | 1550 | |
| 1554 | − VoxelTreeElement *childB = voxel->getChildAtIndex(j); | |
| 1551 | + VoxelTreeElement* childB = voxel->getChildAtIndex(j); | |
| 1555 | 1552 | if (childB) { |
| 1556 | 1553 | |
| 1557 | 1554 | // Get child B's occluding faces |
| @@ -1564,22 +1561,22 @@ bool VoxelSystem::inspectForInteriorOcclusionsOperation(OctreeElement* element, · 6 unmodified lines | ||
| 1564 | 1561 | |
| 1565 | 1562 | // Determine the shared halfspace partition between siblings A and B, |
| 1566 | 1563 | // i.e., near/far, left/right, or top/bottom |
| 1567 | − unsigned char partition = octantIndexToSharedBitMask[i][j] & | |
| 1564 | + unsigned char partition = _sOctantIndexToSharedBitMask[i][j] & | |
| 1568 | 1565 | exteriorOcclusionsA & exteriorOcclusionsB; |
| 1569 | 1566 | |
| 1570 | − // Determine which face of each sibling is occluded. | |
| 1567 | + // Determine which face of each sibling is occluded. | |
| 1571 | 1568 | // Note the intentionally crossed indicies. It is necessary because |
| 1572 | − // the octantIndexToBitMask is a partition occupancy mask. For | |
| 1569 | + // the _sOctantIndexToBitMask is a partition occupancy mask. For | |
| 1573 | 1570 | // example, if the near-left-top (NLT) and near-left-bottom (NLB) child voxels |
| 1574 | 1571 | // exist, the shared partition is top-bottom (TB), and thus the occluded |
| 1575 | 1572 | // shared face of the NLT voxel is its bottom face. |
| 1576 | − occludedSharedFace[i] |= (partition & octantIndexToBitMask[j]); | |
| 1577 | − occludedSharedFace[j] |= (partition & octantIndexToBitMask[i]); | |
| 1573 | + occludedSharedFace[i] |= (partition & _sOctantIndexToBitMask[j]); | |
| 1574 | + occludedSharedFace[j] |= (partition & _sOctantIndexToBitMask[i]); | |
| 1578 | 1575 | } |
| 1579 | 1576 | } |
| 1580 | 1577 | // Combine this voxel's interior excluded shared face only to those children which are coincident |
| 1581 | 1578 | // with the excluded face. |
| 1582 | − occludedSharedFace[i] |= (voxel->getInteriorOcclusions() & octantIndexToBitMask[i]); | |
| 1579 | + occludedSharedFace[i] |= (voxel->getInteriorOcclusions() & _sOctantIndexToBitMask[i]); | |
| 1583 | 1580 | |
| 1584 | 1581 | // Inform the child |
| 1585 | 1582 | childA->setInteriorOcclusions(occludedSharedFace[i]); |
| @@ -1610,13 +1607,13 @@ bool VoxelSystem::inspectForExteriorOcclusionsOperation(OctreeElement* element, · 24 unmodified lines | ||
| 1610 | 1607 | // Traverse all children |
| 1611 | 1608 | for (int i = NUMBER_OF_CHILDREN; --i >= 0; ) { |
| 1612 | 1609 | |
| 1613 | − VoxelTreeElement *child = voxel->getChildAtIndex(i); | |
| 1610 | + VoxelTreeElement* child = voxel->getChildAtIndex(i); | |
| 1614 | 1611 | if (child) { |
| 1615 | 1612 | // Get the child's occluding faces, for a leaf, that will be |
| 1616 | 1613 | // all six voxel faces, and for a non leaf, that will be |
| 1617 | 1614 | // all faces which are completely covered by four child octants. |
| 1618 | 1615 | unsigned char exteriorOcclusionsOfChild = child->getExteriorOcclusions(); |
| 1619 | − exteriorOcclusionsOfChild &= octantIndexToBitMask[i]; | |
| 1616 | + exteriorOcclusionsOfChild &= _sOctantIndexToBitMask[i]; | |
| 1620 | 1617 | |
| 1621 | 1618 | for (int j = 6; --j >= 0; ) { |
| 1622 | 1619 | |
| @@ -1656,9 +1653,7 @@ bool VoxelSystem::inspectForExteriorOcclusionsOperation(OctreeElement* element, · 33 unmodified lines | ||
| 1656 | 1653 | // occupied. Hence, the subtree from this node could be |
| 1657 | 1654 | // pruned and replaced by a leaf voxel, if the visible |
| 1658 | 1655 | // properties of the children are the same |
| 1659 | − } | |
| 1660 | − else | |
| 1661 | − if (exteriorOcclusions) { | |
| 1656 | + } else if (exteriorOcclusions) { | |
| 1662 | 1657 | //const glm::vec3& v = voxel->getCorner(); |
| 1663 | 1658 | //float s = voxel->getScale(); |
| 1664 | 1659 | |
| @@ -1682,8 +1677,7 @@ bool VoxelSystem::clearOcclusionsOperation(OctreeElement* element, void* extraDa · 17 unmodified lines | ||
| 1682 | 1677 | // And the sibling occluders |
| 1683 | 1678 | voxel->setInteriorOcclusions(0); |
| 1684 | 1679 | rc = false; |
| 1685 | − } | |
| 1686 | − else { | |
| 1680 | + } else { | |
| 1687 | 1681 | voxel->setExteriorOcclusions(0); |
| 1688 | 1682 | voxel->setInteriorOcclusions(0); |
| 1689 | 1683 | rc = true; |
| @@ -1711,8 +1705,7 @@ void VoxelSystem::cullSharedFaces() { · 21 unmodified lines | ||
| 1711 | 1705 | _tree->recurseTreeWithOperation(inspectForInteriorOcclusionsOperation); |
| 1712 | 1706 | unlockTree(); |
| 1713 | 1707 | qDebug("culling shared faces in %d nodes", _nodeCount); |
| 1714 | − } | |
| 1715 | − else { | |
| 1708 | + } else { | |
| 1716 | 1709 | cleanupVoxelMemory(); |
| 1717 | 1710 | _usePrimitiveRenderer = false; |
| 1718 | 1711 | initVoxelMemory(); |
| @@ -3112,7 +3105,7 @@ void VoxelSystem::beginLoadingLocalVoxelCache() { · 1393 unmodified lines | ||
| 3112 | 3105 | // Octant bitmask array indexed by octant. The mask value indicates the octant's halfspace partitioning. The index |
| 3113 | 3106 | // value corresponds to the voxel's octal code derived in "pointToVoxel" in SharedUtil.cpp, which, BTW, does *not* |
| 3114 | 3107 | // correspond to the "ChildIndex" enum value in OctreeElement.h |
| 3115 | −unsigned char VoxelSystem::octantIndexToBitMask[8] = { | |
| 3108 | +unsigned char VoxelSystem::_sOctantIndexToBitMask[8] = { | |
| 3116 | 3109 | OctreeElement::HalfSpace::Bottom | OctreeElement::HalfSpace::Left | OctreeElement::HalfSpace::Near, |
| 3117 | 3110 | OctreeElement::HalfSpace::Bottom | OctreeElement::HalfSpace::Left | OctreeElement::HalfSpace::Far, |
| 3118 | 3111 | OctreeElement::HalfSpace::Top | OctreeElement::HalfSpace::Left | OctreeElement::HalfSpace::Near, |
| @@ -3125,7 +3118,7 @@ unsigned char VoxelSystem::octantIndexToBitMask[8] = { · 6 unmodified lines | ||
| 3125 | 3118 | |
| 3126 | 3119 | // Two dimensional array map indexed by octant row and column. The mask value |
| 3127 | 3120 | // indicates the two faces shared by the octants |
| 3128 | −unsigned char VoxelSystem::octantIndexToSharedBitMask[8][8] = { | |
| 3121 | +unsigned char VoxelSystem::_sOctantIndexToSharedBitMask[8][8] = { | |
| 3129 | 3122 | { // Index 0: Bottom-Left-Near |
| 3130 | 3123 | 0, // Bottom-Left-Near |
| 3131 | 3124 | OctreeElement::HalfSpace::Near | OctreeElement::HalfSpace::Far, // Bottom-Left-Far |