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
1567 setupNewVoxelsForDrawing();1567 setupNewVoxelsForDrawing();
1568}1568}
1569 1569
1570class NodeAndPoint {
1571public:
1572 VoxelNode* node;
1573 glm::vec3 point;
1574};
1575
1576// Find the smallest colored voxel enclosing a point (if there is one)
1577bool 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
1593VoxelNode* 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 falseColorizeBySource1602// helper classes and args for falseColorizeBySource
1571class groupColor {1603class groupColor {
1572public:1604public: