Voxel drumming, search function to find leaf voxel containing a point
Showing the changes to interface/src/VoxelSystem.cpp (1 of 13 files). Show all
Unified · Split
| @@ -1540,6 +1540,38 @@ void VoxelSystem::falseColorizeInView() { · 1539 unmodified lines | ||
| 1540 | 1540 | setupNewVoxelsForDrawing(); |
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | +class NodeAndPoint { | |
| 1544 | +public: | |
| 1545 | + VoxelNode* node; | |
| 1546 | + glm::vec3 point; | |
| 1547 | +}; | |
| 1548 | + | |
| 1549 | +// Find the smallest colored voxel enclosing a point (if there is one) | |
| 1550 | +bool VoxelSystem::getVoxelEnclosingOperation(VoxelNode* node, void* extraData) { | |
| 1551 | + NodeAndPoint* nodeAndPoint = (NodeAndPoint*) extraData; | |
| 1552 | + AABox voxelBox = node->getAABox(); | |
| 1553 | + if (voxelBox.contains(nodeAndPoint->point)) { | |
| 1554 | + if (node->isColored() && node->isLeaf()) { | |
| 1555 | + // we've reached a solid leaf containing the point, return the node. | |
| 1556 | + nodeAndPoint->node = node; | |
| 1557 | + return false; | |
| 1558 | + } | |
| 1559 | + } else { | |
| 1560 | + // The point is not inside this voxel, so stop recursing. | |
| 1561 | + return false; | |
| 1562 | + } | |
| 1563 | + return true; // keep looking | |
| 1564 | +} | |
| 1565 | + | |
| 1566 | +VoxelNode* VoxelSystem::getVoxelEnclosing(const glm::vec3& point) { | |
| 1567 | + NodeAndPoint nodeAndPoint; | |
| 1568 | + nodeAndPoint.point = point; | |
| 1569 | + nodeAndPoint.node = NULL; | |
| 1570 | + _tree->recurseTreeWithOperation(getVoxelEnclosingOperation, (void*) &nodeAndPoint); | |
| 1571 | + return nodeAndPoint.node; | |
| 1572 | +} | |
| 1573 | + | |
| 1574 | + | |
| 1543 | 1575 | // helper classes and args for falseColorizeBySource |
| 1544 | 1576 | class groupColor { |
| 1545 | 1577 | public: |