Showing the changes to interface/src/VoxelSystem.cpp (1 of 8 files). Show all
Unified · Split
| @@ -1567,6 +1567,38 @@ void VoxelSystem::falseColorizeInView() { · 1566 unmodified lines | |||
| 1567 | setupNewVoxelsForDrawing(); | 1567 | setupNewVoxelsForDrawing(); |
| 1568 | } | 1568 | } |
| 1569 | 1569 | ||
| 1570 | class NodeAndPoint { | ||
| 1571 | public: | ||
| 1572 | VoxelNode* node; | ||
| 1573 | glm::vec3 point; | ||
| 1574 | }; | ||
| 1575 | |||
| 1576 | // Find the smallest colored voxel enclosing a point (if there is one) | ||
| 1577 | bool VoxelSystem::getVoxelEnclosingOperation(VoxelNode* node, void* extraData) { | ||
| 1578 | NodeAndPoint* nodeAndPoint = (NodeAndPoint*) extraData; | ||
| 1579 | AABox voxelBox = node->getAABox(); | ||
| 1580 | if (voxelBox.contains(nodeAndPoint->point)) { | ||
| 1581 | if (node->isColored() && node->isLeaf()) { | ||
| 1582 | // we've reached a solid leaf containing the point, return the node. | ||
| 1583 | nodeAndPoint->node = node; | ||
| 1584 | return false; | ||
| 1585 | } | ||
| 1586 | } else { | ||
| 1587 | // The point is not inside this voxel, so stop recursing. | ||
| 1588 | return false; | ||
| 1589 | } | ||
| 1590 | return true; // keep looking | ||
| 1591 | } | ||
| 1592 | |||
| 1593 | VoxelNode* VoxelSystem::getVoxelEnclosing(const glm::vec3& point) { | ||
| 1594 | NodeAndPoint nodeAndPoint; | ||
| 1595 | nodeAndPoint.point = point; | ||
| 1596 | nodeAndPoint.node = NULL; | ||
| 1597 | _tree->recurseTreeWithOperation(getVoxelEnclosingOperation, (void*) &nodeAndPoint); | ||
| 1598 | return nodeAndPoint.node; | ||
| 1599 | } | ||
| 1600 | |||
| 1601 | |||
| 1570 | // helper classes and args for falseColorizeBySource | 1602 | // helper classes and args for falseColorizeBySource |
| 1571 | class groupColor { | 1603 | class groupColor { |
| 1572 | public: | 1604 | public: |