History

Merge pull request #1304 from PhilipRosedale/master

Voxel drumming, search function to find leaf voxel containing a point

ZappoMan committed 12 years ago

Commit bc715082 parents eb316a4 2dfbaf613 files · +236 −192Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 13 files). Show all

Unified · Split

interface/src/VoxelSystem.cpp+32−0
@@ -1540,6 +1540,38 @@ void VoxelSystem::falseColorizeInView() { · 1539 unmodified lines
15401540 setupNewVoxelsForDrawing();
15411541 }
15421542
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+
15431575 // helper classes and args for falseColorizeBySource
15441576 class groupColor {
15451577 public: