History

Added drum sounds and voxel collision detection

Philip Rosedale committed 12 years ago

Commit 8fdd78d1 parent a84e97c8 files · +153 −85Browse files

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

Unified · Split

interface/src/VoxelSystem.cpp+32−0
@@ -1567,6 +1567,38 @@ void VoxelSystem::falseColorizeInView() { · 1566 unmodified lines
15671567 setupNewVoxelsForDrawing();
15681568 }
15691569
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+
15701602 // helper classes and args for falseColorizeBySource
15711603 class groupColor {
15721604 public: