History

first cut at splitting out octree base classes

ZappoMan committed 12 years ago

Commit 9faef651 parent 44f92fb87 files · +7633 −4859Browse files

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

Unified · Split

interface/src/VoxelSystem.cpp+193−200
@@ -74,13 +74,13 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels) · 73 unmodified lines
74 _readRenderFullVBO = true;74 _readRenderFullVBO = true;
75 _tree = new VoxelTree();75 _tree = new VoxelTree();
76 76
77 _tree->rootNode->setVoxelSystem(this);77 _tree->getRoot()->setVoxelSystem(this);
78 pthread_mutex_init(&_bufferWriteLock, NULL);78 pthread_mutex_init(&_bufferWriteLock, NULL);
79 pthread_mutex_init(&_treeLock, NULL);79 pthread_mutex_init(&_treeLock, NULL);
80 pthread_mutex_init(&_freeIndexLock, NULL);80 pthread_mutex_init(&_freeIndexLock, NULL);
81 81
82 VoxelNode::addDeleteHook(this);82 VoxelTreeElement::addDeleteHook(this);
83 VoxelNode::addUpdateHook(this);83 VoxelTreeElement::addUpdateHook(this);
84 _abandonedVBOSlots = 0;84 _abandonedVBOSlots = 0;
85 _falseColorizeBySource = false;85 _falseColorizeBySource = false;
86 _dataSourceUUID = QUuid();86 _dataSourceUUID = QUuid();
@@ -113,13 +113,14 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels) · 26 unmodified lines
113 _treeIsBusy = false;113 _treeIsBusy = false;
114}114}
115 115
116void VoxelSystem::voxelDeleted(VoxelNode* node) {116void VoxelSystem::elementDeleted(OctreeElement* element) {
117 if (node->getVoxelSystem() == this) {117 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
118 if (voxel->getVoxelSystem() == this) {
118 if (_voxelsInWriteArrays != 0) {119 if (_voxelsInWriteArrays != 0) {
119 forceRemoveNodeFromArrays(node);120 forceRemoveNodeFromArrays(voxel);
120 } else {121 } else {
121 if (Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings)) {122 if (Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings)) {
122 printf("VoxelSystem::voxelDeleted() while _voxelsInWriteArrays==0, is that expected? \n");123 printf("VoxelSystem::elementDeleted() while _voxelsInWriteArrays==0, is that expected? \n");
123 }124 }
124 }125 }
125 }126 }
@@ -132,50 +133,51 @@ void VoxelSystem::setDisableFastVoxelPipeline(bool disableFastVoxelPipeline) { · 6 unmodified lines
132 setupNewVoxelsForDrawing();133 setupNewVoxelsForDrawing();
133}134}
134 135
135void VoxelSystem::voxelUpdated(VoxelNode* node) {136void VoxelSystem::elementUpdated(OctreeElement* element) {
137 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
136 // If we're in SetupNewVoxelsForDrawing() or _writeRenderFullVBO then bail..138 // If we're in SetupNewVoxelsForDrawing() or _writeRenderFullVBO then bail..
137 if (!_useFastVoxelPipeline || _inSetupNewVoxelsForDrawing || _writeRenderFullVBO) {139 if (!_useFastVoxelPipeline || _inSetupNewVoxelsForDrawing || _writeRenderFullVBO) {
138 return;140 return;
139 }141 }
140 142
141 if (node->getVoxelSystem() == this) {143 if (voxel->getVoxelSystem() == this) {
142 bool shouldRender = false; // assume we don't need to render it144 bool shouldRender = false; // assume we don't need to render it
143 // if it's colored, we might need to render it!145 // if it's colored, we might need to render it!
144 float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();146 float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();
145 int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();147 int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
146 shouldRender = node->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);148 shouldRender = voxel->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);
147 149
148 if (node->getShouldRender() != shouldRender) {150 if (voxel->getShouldRender() != shouldRender) {
149 node->setShouldRender(shouldRender);151 voxel->setShouldRender(shouldRender);
150 }152 }
151 153
152 if (!node->isLeaf()) {154 if (!voxel->isLeaf()) {
153 155
154 // As we check our children, see if any of them went from shouldRender to NOT shouldRender156 // As we check our children, see if any of them went from shouldRender to NOT shouldRender
155 // then we probably dropped LOD and if we don't have color, we want to average our children 157 // then we probably dropped LOD and if we don't have color, we want to average our children
156 // for a new color.158 // for a new color.
157 int childrenGotHiddenCount = 0;159 int childrenGotHiddenCount = 0;
158 for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {160 for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
159 VoxelNode* childNode = node->getChildAtIndex(i);161 VoxelTreeElement* childVoxel = voxel->getChildAtIndex(i);
160 if (childNode) {162 if (childVoxel) {
161 bool wasShouldRender = childNode->getShouldRender();163 bool wasShouldRender = childVoxel->getShouldRender();
162 bool isShouldRender = childNode->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);164 bool isShouldRender = childVoxel->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);
163 if (wasShouldRender && !isShouldRender) {165 if (wasShouldRender && !isShouldRender) {
164 childrenGotHiddenCount++;166 childrenGotHiddenCount++;
165 }167 }
166 }168 }
167 }169 }
168 if (childrenGotHiddenCount > 0) {170 if (childrenGotHiddenCount > 0) {
169 node->setColorFromAverageOfChildren();171 voxel->calculateAverageFromChildren();
170 }172 }
171 }173 }
172 174
173 const bool REUSE_INDEX = true;175 const bool REUSE_INDEX = true;
174 const bool DONT_FORCE_REDRAW = false;176 const bool DONT_FORCE_REDRAW = false;
175 updateNodeInArrays(node, REUSE_INDEX, DONT_FORCE_REDRAW);177 updateNodeInArrays(voxel, REUSE_INDEX, DONT_FORCE_REDRAW);
176 _voxelsUpdated++;178 _voxelsUpdated++;
177 179
178 node->clearDirtyBit(); // clear the dirty bit, do this before we potentially delete things.180 voxel->clearDirtyBit(); // clear the dirty bit, do this before we potentially delete things.
179 181
180 setupNewVoxelsForDrawingSingleNode();182 setupNewVoxelsForDrawingSingleNode();
181 }183 }
@@ -199,7 +201,7 @@ glBufferIndex VoxelSystem::getNextBufferIndex() { · 17 unmodified lines
199 return output;201 return output;
200}202}
201 203
202// Release responsibility of the buffer/vbo index from the VoxelNode, and makes the index available for some other node to use204// Release responsibility of the buffer/vbo index from the VoxelTreeElement, and makes the index available for some other node to use
203// will also "clean up" the index data for the buffer/vbo slot, so that if it's in the middle of the draw range, the triangles205// will also "clean up" the index data for the buffer/vbo slot, so that if it's in the middle of the draw range, the triangles
204// will be "invisible"206// will be "invisible"
205void VoxelSystem::freeBufferIndex(glBufferIndex index) {207void VoxelSystem::freeBufferIndex(glBufferIndex index) {
@@ -260,8 +262,8 @@ VoxelSystem::~VoxelSystem() { · 54 unmodified lines
260 pthread_mutex_destroy(&_treeLock);262 pthread_mutex_destroy(&_treeLock);
261 pthread_mutex_destroy(&_freeIndexLock);263 pthread_mutex_destroy(&_freeIndexLock);
262 264
263 VoxelNode::removeDeleteHook(this);265 VoxelTreeElement::removeDeleteHook(this);
264 VoxelNode::removeUpdateHook(this);266 VoxelTreeElement::removeUpdateHook(this);
265}267}
266 268
267void VoxelSystem::setMaxVoxels(int maxVoxels) {269void VoxelSystem::setMaxVoxels(int maxVoxels) {
@@ -534,13 +536,8 @@ void VoxelSystem::initVoxelMemory() { · 266 unmodified lines
534 pthread_mutex_unlock(&_bufferWriteLock);536 pthread_mutex_unlock(&_bufferWriteLock);
535}537}
536 538
537void VoxelSystem::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) {539void VoxelSystem::writeToSVOFile(const char* filename, VoxelTreeElement* element) const {
538 _tree->loadVoxelsFile(fileName, wantColorRandomizer);540 _tree->writeToSVOFile(filename, element);
539 setupNewVoxelsForDrawing();
540}
541
542void VoxelSystem::writeToSVOFile(const char* filename, VoxelNode* node) const {
543 _tree->writeToSVOFile(filename, node);
544}541}
545 542
546bool VoxelSystem::readFromSVOFile(const char* filename) {543bool VoxelSystem::readFromSVOFile(const char* filename) {
@@ -567,30 +564,6 @@ bool VoxelSystem::readFromSchematicFile(const char* filename) { · 20 unmodified lines
567 return result;564 return result;
568}565}
569 566
570long int VoxelSystem::getVoxelsCreated() {
571 return _tree->voxelsCreated;
572}
573
574float VoxelSystem::getVoxelsCreatedPerSecondAverage() {
575 return (1 / _tree->voxelsCreatedStats.getEventDeltaAverage());
576}
577
578long int VoxelSystem::getVoxelsColored() {
579 return _tree->voxelsColored;
580}
581
582float VoxelSystem::getVoxelsColoredPerSecondAverage() {
583 return (1 / _tree->voxelsColoredStats.getEventDeltaAverage());
584}
585
586long int VoxelSystem::getVoxelsBytesRead() {
587 return _tree->voxelsBytesRead;
588}
589
590float VoxelSystem::getVoxelsBytesReadPerSecondAverage() {
591 return _tree->voxelsBytesReadStats.getAverageSampleValuePerSecond();
592}
593
594int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {567int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
595 568
596 unsigned char command = *sourceBuffer;569 unsigned char command = *sourceBuffer;
@@ -702,7 +675,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() { · 105 unmodified lines
702 if (_writeRenderFullVBO) {675 if (_writeRenderFullVBO) {
703 clearFreeBufferIndexes();676 clearFreeBufferIndexes();
704 }677 }
705 _voxelsUpdated = newTreeToArrays(_tree->rootNode);678 _voxelsUpdated = newTreeToArrays(_tree->getRoot());
706 _tree->clearDirtyBit(); // after we pull the trees into the array, we can consider the tree clean679 _tree->clearDirtyBit(); // after we pull the trees into the array, we can consider the tree clean
707 680
708 if (_writeRenderFullVBO) {681 if (_writeRenderFullVBO) {
@@ -955,56 +928,56 @@ void VoxelSystem::copyWrittenDataToReadArrays(bool fullVBOs) { · 246 unmodified lines
955 }928 }
956}929}
957 930
958int VoxelSystem::newTreeToArrays(VoxelNode* node) {931int VoxelSystem::newTreeToArrays(VoxelTreeElement* voxel) {
959 int voxelsUpdated = 0;932 int voxelsUpdated = 0;
960 bool shouldRender = false; // assume we don't need to render it933 bool shouldRender = false; // assume we don't need to render it
961 // if it's colored, we might need to render it!934 // if it's colored, we might need to render it!
962 float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();;935 float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();;
963 int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();936 int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
964 shouldRender = node->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);937 shouldRender = voxel->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);
965 938
966 node->setShouldRender(shouldRender);939 voxel->setShouldRender(shouldRender);
967 // let children figure out their renderness940 // let children figure out their renderness
968 if (!node->isLeaf()) {941 if (!voxel->isLeaf()) {
969 942
970 // As we check our children, see if any of them went from shouldRender to NOT shouldRender943 // As we check our children, see if any of them went from shouldRender to NOT shouldRender
971 // then we probably dropped LOD and if we don't have color, we want to average our children 944 // then we probably dropped LOD and if we don't have color, we want to average our children
972 // for a new color.945 // for a new color.
973 int childrenGotHiddenCount = 0;946 int childrenGotHiddenCount = 0;
974 for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {947 for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
975 VoxelNode* childNode = node->getChildAtIndex(i);948 VoxelTreeElement* childVoxel = voxel->getChildAtIndex(i);
976 if (childNode) {949 if (childVoxel) {
977 bool wasShouldRender = childNode->getShouldRender();950 bool wasShouldRender = childVoxel->getShouldRender();
978 voxelsUpdated += newTreeToArrays(childNode);951 voxelsUpdated += newTreeToArrays(childVoxel);
979 bool isShouldRender = childNode->getShouldRender();952 bool isShouldRender = childVoxel->getShouldRender();
980 if (wasShouldRender && !isShouldRender) {953 if (wasShouldRender && !isShouldRender) {
981 childrenGotHiddenCount++;954 childrenGotHiddenCount++;
982 }955 }
983 }956 }
984 }957 }
985 if (childrenGotHiddenCount > 0) {958 if (childrenGotHiddenCount > 0) {
986 node->setColorFromAverageOfChildren();959 voxel->calculateAverageFromChildren();
987 }960 }
988 }961 }
989 if (_writeRenderFullVBO) {962 if (_writeRenderFullVBO) {
990 const bool DONT_REUSE_INDEX = false;963 const bool DONT_REUSE_INDEX = false;
991 const bool FORCE_REDRAW = true;964 const bool FORCE_REDRAW = true;
992 voxelsUpdated += updateNodeInArrays(node, DONT_REUSE_INDEX, FORCE_REDRAW);965 voxelsUpdated += updateNodeInArrays(voxel, DONT_REUSE_INDEX, FORCE_REDRAW);
993 } else {966 } else {
994 const bool REUSE_INDEX = true;967 const bool REUSE_INDEX = true;
995 const bool DONT_FORCE_REDRAW = false;968 const bool DONT_FORCE_REDRAW = false;
996 voxelsUpdated += updateNodeInArrays(node, REUSE_INDEX, DONT_FORCE_REDRAW);969 voxelsUpdated += updateNodeInArrays(voxel, REUSE_INDEX, DONT_FORCE_REDRAW);
997 }970 }
998 node->clearDirtyBit(); // clear the dirty bit, do this before we potentially delete things.971 voxel->clearDirtyBit(); // clear the dirty bit, do this before we potentially delete things.
999 972
1000 return voxelsUpdated;973 return voxelsUpdated;
1001}974}
1002 975
1003// called as response to voxelDeleted() in fast pipeline case. The node976// called as response to elementDeleted() in fast pipeline case. The node
1004// is being deleted, but it's state is such that it thinks it should render977// is being deleted, but it's state is such that it thinks it should render
1005// and therefore we can't use the normal render calculations. This method978// and therefore we can't use the normal render calculations. This method
1006// will forcibly remove it from the VBOs because we know better!!!979// will forcibly remove it from the VBOs because we know better!!!
1007int VoxelSystem::forceRemoveNodeFromArrays(VoxelNode* node) {980int VoxelSystem::forceRemoveNodeFromArrays(VoxelTreeElement* node) {
1008 981
1009 if (!_initialized) {982 if (!_initialized) {
1010 return 0;983 return 0;
@@ -1021,7 +994,7 @@ int VoxelSystem::forceRemoveNodeFromArrays(VoxelNode* node) { · 10 unmodified lines
1021 return 0; // not-updated994 return 0; // not-updated
1022}995}
1023 996
1024int VoxelSystem::updateNodeInArrays(VoxelNode* node, bool reuseIndex, bool forceDraw) {997int VoxelSystem::updateNodeInArrays(VoxelTreeElement* node, bool reuseIndex, bool forceDraw) {
1025 // If we've run out of room, then just bail...998 // If we've run out of room, then just bail...
1026 if (_voxelsInWriteArrays >= _maxVoxels && (_freeIndexes.size() == 0)) {999 if (_voxelsInWriteArrays >= _maxVoxels && (_freeIndexes.size() == 0)) {
1027 // We need to think about what else we can do in this case. This basically means that all of our available1000 // We need to think about what else we can do in this case. This basically means that all of our available
@@ -1129,7 +1102,7 @@ void VoxelSystem::init() { · 101 unmodified lines
1129 initVoxelMemory();1102 initVoxelMemory();
1130 1103
1131 // our own _removedVoxels doesn't need to be notified of voxel deletes1104 // our own _removedVoxels doesn't need to be notified of voxel deletes
1132 VoxelNode::removeDeleteHook(&_removedVoxels);1105 VoxelTreeElement::removeDeleteHook(&_removedVoxels);
1133}1106}
1134 1107
1135void VoxelSystem::changeTree(VoxelTree* newTree) {1108void VoxelSystem::changeTree(VoxelTree* newTree) {
@@ -1137,7 +1110,7 @@ void VoxelSystem::changeTree(VoxelTree* newTree) { · 1 unmodified line
1137 1110
1138 _tree = newTree;1111 _tree = newTree;
1139 _tree->setDirtyBit();1112 _tree->setDirtyBit();
1140 _tree->rootNode->setVoxelSystem(this);1113 _tree->getRoot()->setVoxelSystem(this);
1141 1114
1142 connect(_tree, SIGNAL(importSize(float,float,float)), SIGNAL(importSize(float,float,float)));1115 connect(_tree, SIGNAL(importSize(float,float,float)), SIGNAL(importSize(float,float,float)));
1143 connect(_tree, SIGNAL(importProgress(int)), SIGNAL(importProgress(int)));1116 connect(_tree, SIGNAL(importProgress(int)), SIGNAL(importProgress(int)));
@@ -1457,7 +1430,7 @@ int VoxelSystem::_nodeCount = 0; · 313 unmodified lines
1457 1430
1458void VoxelSystem::killLocalVoxels() {1431void VoxelSystem::killLocalVoxels() {
1459 lockTree();1432 lockTree();
1460 _tree->eraseAllVoxels();1433 _tree->eraseAllOctreeElements();
1461 unlockTree();1434 unlockTree();
1462 clearFreeBufferIndexes(); 1435 clearFreeBufferIndexes();
1463 _voxelsInReadArrays = 0; // do we need to do this?1436 _voxelsInReadArrays = 0; // do we need to do this?
@@ -1469,9 +1442,10 @@ void VoxelSystem::redrawInViewVoxels() { · 5 unmodified lines
1469}1442}
1470 1443
1471 1444
1472bool VoxelSystem::clearAllNodesBufferIndexOperation(VoxelNode* node, void* extraData) {1445bool VoxelSystem::clearAllNodesBufferIndexOperation(OctreeElement* element, void* extraData) {
1473 _nodeCount++;1446 _nodeCount++;
1474 node->setBufferIndex(GLBUFFER_INDEX_UNKNOWN);1447 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
1448 voxel->setBufferIndex(GLBUFFER_INDEX_UNKNOWN);
1475 return true;1449 return true;
1476}1450}
1477 1451
@@ -1485,7 +1459,7 @@ void VoxelSystem::clearAllNodesBufferIndex() { · 7 unmodified lines
1485 }1459 }
1486}1460}
1487 1461
1488bool VoxelSystem::forceRedrawEntireTreeOperation(VoxelNode* node, void* extraData) {1462bool VoxelSystem::forceRedrawEntireTreeOperation(OctreeElement* node, void* extraData) {
1489 _nodeCount++;1463 _nodeCount++;
1490 node->setDirtyBit();1464 node->setDirtyBit();
1491 return true;1465 return true;
@@ -1499,11 +1473,12 @@ void VoxelSystem::forceRedrawEntireTree() { · 7 unmodified lines
1499 setupNewVoxelsForDrawing();1473 setupNewVoxelsForDrawing();
1500}1474}
1501 1475
1502bool VoxelSystem::randomColorOperation(VoxelNode* node, void* extraData) {1476bool VoxelSystem::randomColorOperation(OctreeElement* element, void* extraData) {
1477 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
1503 _nodeCount++;1478 _nodeCount++;
1504 if (node->isColored()) {1479 if (voxel->isColored()) {
1505 nodeColor newColor = { 255, randomColorValue(150), randomColorValue(150), 1 };1480 nodeColor newColor = { 255, randomColorValue(150), randomColorValue(150), 1 };
1506 node->setColor(newColor);1481 voxel->setColor(newColor);
1507 }1482 }
1508 return true;1483 return true;
1509}1484}
@@ -1516,10 +1491,11 @@ void VoxelSystem::randomizeVoxelColors() { · 6 unmodified lines
1516 setupNewVoxelsForDrawing();1491 setupNewVoxelsForDrawing();
1517}1492}
1518 1493
1519bool VoxelSystem::falseColorizeRandomOperation(VoxelNode* node, void* extraData) {1494bool VoxelSystem::falseColorizeRandomOperation(OctreeElement* element, void* extraData) {
1495 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
1520 _nodeCount++;1496 _nodeCount++;
1521 // always false colorize1497 // always false colorize
1522 node->setFalseColor(255, randomColorValue(150), randomColorValue(150));1498 voxel->setFalseColor(255, randomColorValue(150), randomColorValue(150));
1523 return true; // keep going!1499 return true; // keep going!
1524}1500}
1525 1501
@@ -1531,9 +1507,10 @@ void VoxelSystem::falseColorizeRandom() { · 5 unmodified lines
1531 setupNewVoxelsForDrawing();1507 setupNewVoxelsForDrawing();
1532}1508}
1533 1509
1534bool VoxelSystem::trueColorizeOperation(VoxelNode* node, void* extraData) {1510bool VoxelSystem::trueColorizeOperation(OctreeElement* element, void* extraData) {
1511 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
1535 _nodeCount++;1512 _nodeCount++;
1536 node->setFalseColored(false);1513 voxel->setFalseColored(false);
1537 return true;1514 return true;
1538}1515}
1539 1516
@@ -1547,13 +1524,14 @@ void VoxelSystem::trueColorize() { · 7 unmodified lines
1547}1524}
1548 1525
1549// Will false colorize voxels that are not in view1526// Will false colorize voxels that are not in view
1550bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData) {1527bool VoxelSystem::falseColorizeInViewOperation(OctreeElement* element, void* extraData) {
1528 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
1551 const ViewFrustum* viewFrustum = (const ViewFrustum*) extraData;1529 const ViewFrustum* viewFrustum = (const ViewFrustum*) extraData;
1552 _nodeCount++;1530 _nodeCount++;
1553 if (node->isColored()) {1531 if (voxel->isColored()) {
1554 if (!node->isInView(*viewFrustum)) {1532 if (!voxel->isInView(*viewFrustum)) {
1555 // Out of view voxels are colored RED1533 // Out of view voxels are colored RED
1556 node->setFalseColor(255, 0, 0);1534 voxel->setFalseColor(255, 0, 0);
1557 }1535 }
1558 }1536 }
1559 return true; // keep going!1537 return true; // keep going!
@@ -1584,13 +1562,14 @@ public: · 24 unmodified lines
1584};1562};
1585 1563
1586// Will false colorize voxels that are not in view1564// Will false colorize voxels that are not in view
1587bool VoxelSystem::falseColorizeBySourceOperation(VoxelNode* node, void* extraData) {1565bool VoxelSystem::falseColorizeBySourceOperation(OctreeElement* element, void* extraData) {
1566 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
1588 colorizeBySourceArgs* args = (colorizeBySourceArgs*)extraData;1567 colorizeBySourceArgs* args = (colorizeBySourceArgs*)extraData;
1589 _nodeCount++;1568 _nodeCount++;
1590 if (node->isColored()) {1569 if (voxel->isColored()) {
1591 // pick a color based on the source - we want each source to be obviously different1570 // pick a color based on the source - we want each source to be obviously different
1592 uint16_t nodeIDKey = node->getSourceUUIDKey();1571 uint16_t nodeIDKey = voxel->getSourceUUIDKey();
1593 node->setFalseColor(args->colors[nodeIDKey].red, args->colors[nodeIDKey].green, args->colors[nodeIDKey].blue);1572 voxel->setFalseColor(args->colors[nodeIDKey].red, args->colors[nodeIDKey].green, args->colors[nodeIDKey].blue);
1594 }1573 }
1595 return true; // keep going!1574 return true; // keep going!
1596}1575}
@@ -1614,7 +1593,7 @@ void VoxelSystem::falseColorizeBySource() { · 17 unmodified lines
1614 NodeList* nodeList = NodeList::getInstance();1593 NodeList* nodeList = NodeList::getInstance();
1615 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {1594 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
1616 if (node->getType() == NODE_TYPE_VOXEL_SERVER) {1595 if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
1617 uint16_t nodeID = VoxelNode::getSourceNodeUUIDKey(node->getUUID());1596 uint16_t nodeID = VoxelTreeElement::getSourceNodeUUIDKey(node->getUUID());
1618 int groupColor = voxelServerCount % NUMBER_OF_COLOR_GROUPS;1597 int groupColor = voxelServerCount % NUMBER_OF_COLOR_GROUPS;
1619 args.colors[nodeID] = groupColors[groupColor];1598 args.colors[nodeID] = groupColors[groupColor];
1620 1599
@@ -1639,10 +1618,11 @@ void VoxelSystem::falseColorizeBySource() { · 18 unmodified lines
1639}1618}
1640 1619
1641// Will false colorize voxels based on distance from view1620// Will false colorize voxels based on distance from view
1642bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, void* extraData) {1621bool VoxelSystem::falseColorizeDistanceFromViewOperation(OctreeElement* element, void* extraData) {
1622 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
1643 ViewFrustum* viewFrustum = (ViewFrustum*) extraData;1623 ViewFrustum* viewFrustum = (ViewFrustum*) extraData;
1644 if (node->isColored()) {1624 if (voxel->isColored()) {
1645 float distance = node->distanceToCamera(*viewFrustum);1625 float distance = voxel->distanceToCamera(*viewFrustum);
1646 _nodeCount++;1626 _nodeCount++;
1647 float distanceRatio = (_minDistance == _maxDistance) ? 1 : (distance - _minDistance) / (_maxDistance - _minDistance);1627 float distanceRatio = (_minDistance == _maxDistance) ? 1 : (distance - _minDistance) / (_maxDistance - _minDistance);
1648 1628
@@ -1651,7 +1631,7 @@ bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, void* · 2 unmodified lines
1651 const unsigned char colorBands = 16;1631 const unsigned char colorBands = 16;
1652 const unsigned char gradientOver = 128;1632 const unsigned char gradientOver = 128;
1653 unsigned char colorBand = (colorBands * distanceRatio);1633 unsigned char colorBand = (colorBands * distanceRatio);
1654 node->setFalseColor((colorBand * (gradientOver / colorBands)) + (maxColor - gradientOver), 0, 0);1634 voxel->setFalseColor((colorBand * (gradientOver / colorBands)) + (maxColor - gradientOver), 0, 0);
1655 }1635 }
1656 return true; // keep going!1636 return true; // keep going!
1657}1637}
@@ -1662,11 +1642,12 @@ float VoxelSystem::_minDistance = FLT_MAX; · 4 unmodified lines
1662// Helper function will get the distance from view range, would be nice if you could just keep track1642// Helper function will get the distance from view range, would be nice if you could just keep track
1663// of this as voxels are created and/or colored... seems like some transform math could do that so1643// of this as voxels are created and/or colored... seems like some transform math could do that so
1664// we wouldn't need to do two passes of the tree1644// we wouldn't need to do two passes of the tree
1665bool VoxelSystem::getDistanceFromViewRangeOperation(VoxelNode* node, void* extraData) {1645bool VoxelSystem::getDistanceFromViewRangeOperation(OctreeElement* element, void* extraData) {
1646 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
1666 ViewFrustum* viewFrustum = (ViewFrustum*) extraData;1647 ViewFrustum* viewFrustum = (ViewFrustum*) extraData;
1667 // only do this for truly colored voxels...1648 // only do this for truly colored voxels...
1668 if (node->isColored()) {1649 if (voxel->isColored()) {
1669 float distance = node->distanceToCamera(*viewFrustum);1650 float distance = voxel->distanceToCamera(*viewFrustum);
1670 // calculate the range of distances1651 // calculate the range of distances
1671 if (distance > _maxDistance) {1652 if (distance > _maxDistance) {
1672 _maxDistance = distance;1653 _maxDistance = distance;
@@ -1695,16 +1676,16 @@ void VoxelSystem::falseColorizeDistanceFromView() { · 22 unmodified lines
1695// combines the removeOutOfView args into a single class1676// combines the removeOutOfView args into a single class
1696class removeOutOfViewArgs {1677class removeOutOfViewArgs {
1697public:1678public:
1698 VoxelSystem* thisVoxelSystem;1679 VoxelSystem* thisVoxelSystem;
1699 ViewFrustum thisViewFrustum;1680 ViewFrustum thisViewFrustum;
1700 VoxelNodeBag dontRecurseBag;1681 OctreeElementBag dontRecurseBag;
1701 unsigned long nodesScanned;1682 unsigned long nodesScanned;
1702 unsigned long nodesRemoved;1683 unsigned long nodesRemoved;
1703 unsigned long nodesInside;1684 unsigned long nodesInside;
1704 unsigned long nodesIntersect;1685 unsigned long nodesIntersect;
1705 unsigned long nodesOutside;1686 unsigned long nodesOutside;
1706 VoxelNode* insideRoot;1687 VoxelTreeElement* insideRoot;
1707 VoxelNode* outsideRoot;1688 VoxelTreeElement* outsideRoot;
1708 1689
1709 removeOutOfViewArgs(VoxelSystem* voxelSystem, bool widenViewFrustum = true) :1690 removeOutOfViewArgs(VoxelSystem* voxelSystem, bool widenViewFrustum = true) :
1710 thisVoxelSystem(voxelSystem),1691 thisVoxelSystem(voxelSystem),
@@ -1734,14 +1715,15 @@ void VoxelSystem::cancelImport() { · 23 unmodified lines
1734 1715
1735// "Remove" voxels from the tree that are not in view. We don't actually delete them,1716// "Remove" voxels from the tree that are not in view. We don't actually delete them,
1736// we remove them from the tree and place them into a holding area for later deletion1717// we remove them from the tree and place them into a holding area for later deletion
1737bool VoxelSystem::removeOutOfViewOperation(VoxelNode* node, void* extraData) {1718bool VoxelSystem::removeOutOfViewOperation(OctreeElement* element, void* extraData) {
1719 VoxelTreeElement* voxel = (VoxelTreeElement*) element;
1738 removeOutOfViewArgs* args = (removeOutOfViewArgs*)extraData;1720 removeOutOfViewArgs* args = (removeOutOfViewArgs*)extraData;
1739 1721
1740 // If our node was previously added to the don't recurse bag, then return false to1722 // If our node was previously added to the don't recurse bag, then return false to
1741 // stop the further recursion. This means that the whole node and it's children are1723 // stop the further recursion. This means that the whole node and it's children are
1742 // known to be in view, so don't recurse them1724 // known to be in view, so don't recurse them
1743 if (args->dontRecurseBag.contains(node)) {1725 if (args->dontRecurseBag.contains(voxel)) {
1744 args->dontRecurseBag.remove(node);1726 args->dontRecurseBag.remove(voxel);
1745 return false; // stop recursion1727 return false; // stop recursion
1746 }1728 }
1747 1729
@@ -1749,14 +1731,14 @@ bool VoxelSystem::removeOutOfViewOperation(VoxelNode* node, void* extraData) { · 1 unmodified line
1749 args->nodesScanned++;1731 args->nodesScanned++;
1750 // Need to operate on our child nodes, so we can remove them1732 // Need to operate on our child nodes, so we can remove them
1751 for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {1733 for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
1752 VoxelNode* childNode = node->getChildAtIndex(i);1734 VoxelTreeElement* childNode = voxel->getChildAtIndex(i);
1753 if (childNode) {1735 if (childNode) {
1754 ViewFrustum::location inFrustum = childNode->inFrustum(args->thisViewFrustum);1736 ViewFrustum::location inFrustum = childNode->inFrustum(args->thisViewFrustum);
1755 switch (inFrustum) {1737 switch (inFrustum) {
1756 case ViewFrustum::OUTSIDE: {1738 case ViewFrustum::OUTSIDE: {
1757 args->nodesOutside++;1739 args->nodesOutside++;
1758 args->nodesRemoved++;1740 args->nodesRemoved++;
1759 node->removeChildAtIndex(i);1741 voxel->removeChildAtIndex(i);
1760 thisVoxelSystem->_removedVoxels.insert(childNode);1742 thisVoxelSystem->_removedVoxels.insert(childNode);
1761 // by removing the child, it will not get recursed!1743 // by removing the child, it will not get recursed!
1762 } break;1744 } break;
@@ -1850,24 +1832,25 @@ void VoxelSystem::showAllLocalVoxels() { · 87 unmodified lines
1850 }1832 }
1851}1833}
1852 1834
1853bool VoxelSystem::showAllLocalVoxelsOperation(VoxelNode* node, void* extraData) {1835bool VoxelSystem::showAllLocalVoxelsOperation(OctreeElement* element, void* extraData) {
1836 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
1854 showAllLocalVoxelsArgs* args = (showAllLocalVoxelsArgs*)extraData;1837 showAllLocalVoxelsArgs* args = (showAllLocalVoxelsArgs*)extraData;
1855 1838
1856 args->nodesScanned++;1839 args->nodesScanned++;
1857 1840
1858 float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();;1841 float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();;
1859 int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();1842 int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
1860 bool shouldRender = node->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale, boundaryLevelAdjust);1843 bool shouldRender = voxel->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale, boundaryLevelAdjust);
1861 node->setShouldRender(shouldRender);1844 voxel->setShouldRender(shouldRender);
1862 1845
1863 if (shouldRender) {1846 if (shouldRender) {
1864 bool falseColorize = false;1847 bool falseColorize = false;
1865 if (falseColorize) {1848 if (falseColorize) {
1866 node->setFalseColor(0,0,255); // false colorize1849 voxel->setFalseColor(0,0,255); // false colorize
1867 }1850 }
1868 // These are both needed to force redraw...1851 // These are both needed to force redraw...
1869 node->setDirtyBit();1852 voxel->setDirtyBit();
1870 node->markWithChangedTime();1853 voxel->markWithChangedTime();
1871 }1854 }
1872 1855
1873 return true; // keep recursing!1856 return true; // keep recursing!
@@ -1991,7 +1974,8 @@ void VoxelSystem::hideOutOfView(bool forceFullFrustum) { · 117 unmodified lines
1991 _inhideOutOfView = false;1974 _inhideOutOfView = false;
1992}1975}
1993 1976
1994bool VoxelSystem::hideAllSubTreeOperation(VoxelNode* node, void* extraData) {1977bool VoxelSystem::hideAllSubTreeOperation(OctreeElement* element, void* extraData) {
1978 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
1995 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;1979 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;
1996 1980
1997 // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine1981 // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine
@@ -2000,7 +1984,7 @@ bool VoxelSystem::hideAllSubTreeOperation(VoxelNode* node, void* extraData) { · 2 unmodified lines
2000 ViewFrustum::location inLastCulledFrustum;1984 ViewFrustum::location inLastCulledFrustum;
2001 1985
2002 if (args->culledOnce && args->wantDeltaFrustums) {1986 if (args->culledOnce && args->wantDeltaFrustums) {
2003 inLastCulledFrustum = node->inFrustum(args->lastViewFrustum);1987 inLastCulledFrustum = voxel->inFrustum(args->lastViewFrustum);
2004 1988
2005 // if this node is fully OUTSIDE our last culled view frustum, then we don't need to recurse further1989 // if this node is fully OUTSIDE our last culled view frustum, then we don't need to recurse further
2006 if (inLastCulledFrustum == ViewFrustum::OUTSIDE) {1990 if (inLastCulledFrustum == ViewFrustum::OUTSIDE) {
@@ -2010,14 +1994,14 @@ bool VoxelSystem::hideAllSubTreeOperation(VoxelNode* node, void* extraData) { · 3 unmodified lines
2010 }1994 }
2011 1995
2012 args->nodesOutside++;1996 args->nodesOutside++;
2013 if (node->isKnownBufferIndex()) {1997 if (voxel->isKnownBufferIndex()) {
2014 args->nodesRemoved++;1998 args->nodesRemoved++;
2015 bool falseColorize = false;1999 bool falseColorize = false;
2016 if (falseColorize) {2000 if (falseColorize) {
2017 node->setFalseColor(255,0,0); // false colorize2001 voxel->setFalseColor(255,0,0); // false colorize
2018 } else {2002 } else {
2019 VoxelSystem* thisVoxelSystem = args->thisVoxelSystem;2003 VoxelSystem* thisVoxelSystem = args->thisVoxelSystem;
2020 thisVoxelSystem->_voxelsUpdated += thisVoxelSystem->forceRemoveNodeFromArrays(node);2004 thisVoxelSystem->_voxelsUpdated += thisVoxelSystem->forceRemoveNodeFromArrays(voxel);
2021 thisVoxelSystem->setupNewVoxelsForDrawingSingleNode();2005 thisVoxelSystem->setupNewVoxelsForDrawingSingleNode();
2022 }2006 }
2023 2007
@@ -2026,7 +2010,8 @@ bool VoxelSystem::hideAllSubTreeOperation(VoxelNode* node, void* extraData) { · 2 unmodified lines
2026 return true;2010 return true;
2027}2011}
2028 2012
2029bool VoxelSystem::showAllSubTreeOperation(VoxelNode* node, void* extraData) {2013bool VoxelSystem::showAllSubTreeOperation(OctreeElement* element, void* extraData) {
2014 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2030 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;2015 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;
2031 2016
2032 // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine2017 // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine
@@ -2035,7 +2020,7 @@ bool VoxelSystem::showAllSubTreeOperation(VoxelNode* node, void* extraData) { · 2 unmodified lines
2035 ViewFrustum::location inLastCulledFrustum;2020 ViewFrustum::location inLastCulledFrustum;
2036 2021
2037 if (args->culledOnce && args->wantDeltaFrustums) {2022 if (args->culledOnce && args->wantDeltaFrustums) {
2038 inLastCulledFrustum = node->inFrustum(args->lastViewFrustum);2023 inLastCulledFrustum = voxel->inFrustum(args->lastViewFrustum);
2039 2024
2040 // if this node is fully inside our last culled view frustum, then we don't need to recurse further2025 // if this node is fully inside our last culled view frustum, then we don't need to recurse further
2041 if (inLastCulledFrustum == ViewFrustum::INSIDE) {2026 if (inLastCulledFrustum == ViewFrustum::INSIDE) {
@@ -2048,17 +2033,17 @@ bool VoxelSystem::showAllSubTreeOperation(VoxelNode* node, void* extraData) { · 6 unmodified lines
2048 2033
2049 float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();2034 float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();
2050 int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();2035 int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
2051 bool shouldRender = node->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale, boundaryLevelAdjust);2036 bool shouldRender = voxel->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale, boundaryLevelAdjust);
2052 node->setShouldRender(shouldRender);2037 voxel->setShouldRender(shouldRender);
2053 2038
2054 if (shouldRender && !node->isKnownBufferIndex()) {2039 if (shouldRender && !voxel->isKnownBufferIndex()) {
2055 bool falseColorize = false;2040 bool falseColorize = false;
2056 if (falseColorize) {2041 if (falseColorize) {
2057 node->setFalseColor(0,0,255); // false colorize2042 voxel->setFalseColor(0,0,255); // false colorize
2058 }2043 }
2059 // These are both needed to force redraw...2044 // These are both needed to force redraw...
2060 node->setDirtyBit();2045 voxel->setDirtyBit();
2061 node->markWithChangedTime();2046 voxel->markWithChangedTime();
2062 }2047 }
2063 2048
2064 return true; // keep recursing!2049 return true; // keep recursing!
@@ -2067,12 +2052,13 @@ bool VoxelSystem::showAllSubTreeOperation(VoxelNode* node, void* extraData) { · 2 unmodified lines
2067// "hide" voxels in the VBOs that are still in the tree that but not in view. 2052// "hide" voxels in the VBOs that are still in the tree that but not in view.
2068// We don't remove them from the tree, we don't delete them, we do remove them2053// We don't remove them from the tree, we don't delete them, we do remove them
2069// from the VBOs and mark them as such in the tree.2054// from the VBOs and mark them as such in the tree.
2070bool VoxelSystem::hideOutOfViewOperation(VoxelNode* node, void* extraData) {2055bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData) {
2056 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2071 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;2057 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;
2072 2058
2073 // If we're still recursing the tree using this operator, then we don't know if we're inside or outside... 2059 // If we're still recursing the tree using this operator, then we don't know if we're inside or outside...
2074 // so before we move forward we need to determine our frustum location2060 // so before we move forward we need to determine our frustum location
2075 ViewFrustum::location inFrustum = node->inFrustum(args->thisViewFrustum);2061 ViewFrustum::location inFrustum = voxel->inFrustum(args->thisViewFrustum);
2076 2062
2077 // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine2063 // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine
2078 // how to proceed. If we've never culled, then we just consider all these voxels to be UNKNOWN so that we will not2064 // how to proceed. If we've never culled, then we just consider all these voxels to be UNKNOWN so that we will not
@@ -2080,7 +2066,7 @@ bool VoxelSystem::hideOutOfViewOperation(VoxelNode* node, void* extraData) { · 1 unmodified line
2080 ViewFrustum::location inLastCulledFrustum;2066 ViewFrustum::location inLastCulledFrustum;
2081 2067
2082 if (args->culledOnce && args->wantDeltaFrustums) {2068 if (args->culledOnce && args->wantDeltaFrustums) {
2083 inLastCulledFrustum = node->inFrustum(args->lastViewFrustum);2069 inLastCulledFrustum = voxel->inFrustum(args->lastViewFrustum);
2084 }2070 }
2085 2071
2086 // ok, now do some processing for this node...2072 // ok, now do some processing for this node...
@@ -2099,7 +2085,7 @@ bool VoxelSystem::hideOutOfViewOperation(VoxelNode* node, void* extraData) { · 12 unmodified lines
2099 // if this node is fully OUTSIDE the view, but previously intersected and/or was inside the last view, then2085 // if this node is fully OUTSIDE the view, but previously intersected and/or was inside the last view, then
2100 // we need to hide it. Additionally we know that ALL of it's children are also fully OUTSIDE so we can recurse 2086 // we need to hide it. Additionally we know that ALL of it's children are also fully OUTSIDE so we can recurse
2101 // the children and simply mark them as hidden2087 // the children and simply mark them as hidden
2102 args->tree->recurseNodeWithOperation(node, hideAllSubTreeOperation, args );2088 args->tree->recurseNodeWithOperation(voxel, hideAllSubTreeOperation, args );
2103 2089
2104 return false;2090 return false;
2105 2091
@@ -2118,7 +2104,7 @@ bool VoxelSystem::hideOutOfViewOperation(VoxelNode* node, void* extraData) { · 12 unmodified lines
2118 // if this node is fully INSIDE the view, but previously INTERSECTED and/or was OUTSIDE the last view, then2104 // if this node is fully INSIDE the view, but previously INTERSECTED and/or was OUTSIDE the last view, then
2119 // we need to show it. Additionally we know that ALL of it's children are also fully INSIDE so we can recurse 2105 // we need to show it. Additionally we know that ALL of it's children are also fully INSIDE so we can recurse
2120 // the children and simply mark them as visible (as appropriate based on LOD)2106 // the children and simply mark them as visible (as appropriate based on LOD)
2121 args->tree->recurseNodeWithOperation(node, showAllSubTreeOperation, args);2107 args->tree->recurseNodeWithOperation(voxel, showAllSubTreeOperation, args);
2122 2108
2123 return false; 2109 return false;
2124 } break;2110 } break;
@@ -2138,8 +2124,8 @@ bool VoxelSystem::hideOutOfViewOperation(VoxelNode* node, void* extraData) { · 13 unmodified lines
2138 // if the child node INTERSECTs the view, then we want to check to see if it thinks it should render2124 // if the child node INTERSECTs the view, then we want to check to see if it thinks it should render
2139 // if it should render but is missing it's VBO index, then we want to flip it on, and we can stop recursing from 2125 // if it should render but is missing it's VBO index, then we want to flip it on, and we can stop recursing from
2140 // here because we know will block any children anyway2126 // here because we know will block any children anyway
2141 if (node->getShouldRender() && !node->isKnownBufferIndex()) {2127 if (voxel->getShouldRender() && !voxel->isKnownBufferIndex()) {
2142 node->setDirtyBit(); // will this make it draw?2128 voxel->setDirtyBit(); // will this make it draw?
2143 return false;2129 return false;
2144 }2130 }
2145 2131
@@ -2159,18 +2145,19 @@ bool VoxelSystem::hideOutOfViewOperation(VoxelNode* node, void* extraData) { · 13 unmodified lines
2159bool VoxelSystem::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,2145bool VoxelSystem::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
2160 VoxelDetail& detail, float& distance, BoxFace& face) {2146 VoxelDetail& detail, float& distance, BoxFace& face) {
2161 lockTree(); 2147 lockTree();
2162 VoxelNode* node;2148 OctreeElement* element;
2163 if (!_tree->findRayIntersection(origin, direction, node, distance, face)) {2149 if (!_tree->findRayIntersection(origin, direction, element, distance, face)) {
2164 unlockTree();2150 unlockTree();
2165 return false;2151 return false;
2166 }2152 }
2167 detail.x = node->getCorner().x;2153 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2168 detail.y = node->getCorner().y;2154 detail.x = voxel->getCorner().x;
2169 detail.z = node->getCorner().z;2155 detail.y = voxel->getCorner().y;
2170 detail.s = node->getScale();2156 detail.z = voxel->getCorner().z;
2171 detail.red = node->getColor()[0];2157 detail.s = voxel->getScale();
2172 detail.green = node->getColor()[1];2158 detail.red = voxel->getColor()[0];
2173 detail.blue = node->getColor()[2];2159 detail.green = voxel->getColor()[1];
2160 detail.blue = voxel->getColor()[2];
2174 unlockTree();2161 unlockTree();
2175 return true;2162 return true;
2176}2163}
@@ -2198,14 +2185,15 @@ public: · 21 unmodified lines
2198 bool colorThis;2185 bool colorThis;
2199};2186};
2200 2187
2201bool VoxelSystem::falseColorizeRandomEveryOtherOperation(VoxelNode* node, void* extraData) {2188bool VoxelSystem::falseColorizeRandomEveryOtherOperation(OctreeElement* element, void* extraData) {
2189 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2202 falseColorizeRandomEveryOtherArgs* args = (falseColorizeRandomEveryOtherArgs*)extraData;2190 falseColorizeRandomEveryOtherArgs* args = (falseColorizeRandomEveryOtherArgs*)extraData;
2203 args->totalNodes++;2191 args->totalNodes++;
2204 if (node->isColored()) {2192 if (voxel->isColored()) {
2205 args->colorableNodes++;2193 args->colorableNodes++;
2206 if (args->colorThis) {2194 if (args->colorThis) {
2207 args->coloredNodes++;2195 args->coloredNodes++;
2208 node->setFalseColor(255, randomColorValue(150), randomColorValue(150));2196 voxel->setFalseColor(255, randomColorValue(150), randomColorValue(150));
2209 }2197 }
2210 args->colorThis = !args->colorThis;2198 args->colorThis = !args->colorThis;
2211 }2199 }
@@ -2257,42 +2245,43 @@ public: · 45 unmodified lines
2257 bool* hasIndexFound;2245 bool* hasIndexFound;
2258};2246};
2259 2247
2260bool VoxelSystem::collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* extraData) {2248bool VoxelSystem::collectStatsForTreesAndVBOsOperation(OctreeElement* element, void* extraData) {
2249 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2261 2250
2262 collectStatsForTreesAndVBOsArgs* args = (collectStatsForTreesAndVBOsArgs*)extraData;2251 collectStatsForTreesAndVBOsArgs* args = (collectStatsForTreesAndVBOsArgs*)extraData;
2263 args->totalNodes++;2252 args->totalNodes++;
2264 2253
2265 if (node->isLeaf()) {2254 if (voxel->isLeaf()) {
2266 args->leafNodes++;2255 args->leafNodes++;
2267 }2256 }
2268 2257
2269 if (node->isColored()) {2258 if (voxel->isColored()) {
2270 args->coloredNodes++;2259 args->coloredNodes++;
2271 }2260 }
2272 2261
2273 if (node->getShouldRender()) {2262 if (voxel->getShouldRender()) {
2274 args->shouldRenderNodes++;2263 args->shouldRenderNodes++;
2275 }2264 }
2276 2265
2277 if (node->isDirty()) {2266 if (voxel->isDirty()) {
2278 args->dirtyNodes++;2267 args->dirtyNodes++;
2279 }2268 }
2280 2269
2281 if (node->isKnownBufferIndex()) {2270 if (voxel->isKnownBufferIndex()) {
2282 args->nodesInVBO++;2271 args->nodesInVBO++;
2283 unsigned long nodeIndex = node->getBufferIndex();2272 unsigned long nodeIndex = voxel->getBufferIndex();
2284 2273
2285 const bool extraDebugging = false; // enable for extra debugging2274 const bool extraDebugging = false; // enable for extra debugging
2286 if (extraDebugging) {2275 if (extraDebugging) {
2287 qDebug("node In VBO... [%f,%f,%f] %f ... index=%ld, isDirty=%s, shouldRender=%s \n", 2276 qDebug("node In VBO... [%f,%f,%f] %f ... index=%ld, isDirty=%s, shouldRender=%s \n",
2288 node->getCorner().x, node->getCorner().y, node->getCorner().z, node->getScale(), 2277 voxel->getCorner().x, voxel->getCorner().y, voxel->getCorner().z, voxel->getScale(),
2289 nodeIndex, debug::valueOf(node->isDirty()), debug::valueOf(node->getShouldRender()));2278 nodeIndex, debug::valueOf(voxel->isDirty()), debug::valueOf(voxel->getShouldRender()));
2290 }2279 }
2291 2280
2292 if (args->hasIndexFound[nodeIndex]) {2281 if (args->hasIndexFound[nodeIndex]) {
2293 args->duplicateVBOIndex++;2282 args->duplicateVBOIndex++;
2294 qDebug("duplicateVBO found... index=%ld, isDirty=%s, shouldRender=%s \n", nodeIndex, 2283 qDebug("duplicateVBO found... index=%ld, isDirty=%s, shouldRender=%s \n", nodeIndex,
2295 debug::valueOf(node->isDirty()), debug::valueOf(node->getShouldRender()));2284 debug::valueOf(voxel->isDirty()), debug::valueOf(voxel->getShouldRender()));
2296 } else {2285 } else {
2297 args->hasIndexFound[nodeIndex] = true;2286 args->hasIndexFound[nodeIndex] = true;
2298 }2287 }
@@ -2301,7 +2290,7 @@ bool VoxelSystem::collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* ex · 2 unmodified lines
2301 }2290 }
2302 2291
2303 // if it's in VBO but not-shouldRender, track that also...2292 // if it's in VBO but not-shouldRender, track that also...
2304 if (!node->getShouldRender()) {2293 if (!voxel->getShouldRender()) {
2305 args->nodesInVBONotShouldRender++;2294 args->nodesInVBONotShouldRender++;
2306 }2295 }
2307 }2296 }
@@ -2368,7 +2357,7 @@ void VoxelSystem::deleteVoxelAt(float x, float y, float z, float s) { · 60 unmodified lines
2368 2357
2369};2358};
2370 2359
2371VoxelNode* VoxelSystem::getVoxelAt(float x, float y, float z, float s) const { 2360VoxelTreeElement* VoxelSystem::getVoxelAt(float x, float y, float z, float s) const {
2372 return _tree->getVoxelAt(x, y, z, s); 2361 return _tree->getVoxelAt(x, y, z, s);
2373};2362};
2374 2363
@@ -2394,20 +2383,20 @@ void VoxelSystem::createSphere(float r,float xc, float yc, float zc, float s, bo · 19 unmodified lines
2394 setupNewVoxelsForDrawing(); 2383 setupNewVoxelsForDrawing();
2395};2384};
2396 2385
2397void VoxelSystem::copySubTreeIntoNewTree(VoxelNode* startNode, VoxelSystem* destination, bool rebaseToRoot) {2386void VoxelSystem::copySubTreeIntoNewTree(VoxelTreeElement* startNode, VoxelSystem* destination, bool rebaseToRoot) {
2398 _tree->copySubTreeIntoNewTree(startNode, destination->_tree, rebaseToRoot);2387 _tree->copySubTreeIntoNewTree(startNode, destination->_tree, rebaseToRoot);
2399 destination->setupNewVoxelsForDrawing();2388 destination->setupNewVoxelsForDrawing();
2400}2389}
2401 2390
2402void VoxelSystem::copySubTreeIntoNewTree(VoxelNode* startNode, VoxelTree* destination, bool rebaseToRoot) {2391void VoxelSystem::copySubTreeIntoNewTree(VoxelTreeElement* startNode, VoxelTree* destination, bool rebaseToRoot) {
2403 _tree->copySubTreeIntoNewTree(startNode, destination, rebaseToRoot);2392 _tree->copySubTreeIntoNewTree(startNode, destination, rebaseToRoot);
2404}2393}
2405 2394
2406void VoxelSystem::copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelNode* destinationNode) {2395void VoxelSystem::copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelTreeElement* destinationNode) {
2407 _tree->copyFromTreeIntoSubTree(sourceTree, destinationNode);2396 _tree->copyFromTreeIntoSubTree(sourceTree, destinationNode);
2408}2397}
2409 2398
2410void VoxelSystem::recurseTreeWithOperation(RecurseVoxelTreeOperation operation, void* extraData) {2399void VoxelSystem::recurseTreeWithOperation(RecurseOctreeOperation operation, void* extraData) {
2411 _tree->recurseTreeWithOperation(operation, extraData);2400 _tree->recurseTreeWithOperation(operation, extraData);
2412}2401}
2413 2402
@@ -2432,27 +2421,29 @@ struct FalseColorizeSubTreeOperationArgs { · 18 unmodified lines
2432 long voxelsTouched;2421 long voxelsTouched;
2433};2422};
2434 2423
2435bool VoxelSystem::falseColorizeSubTreeOperation(VoxelNode* node, void* extraData) {2424bool VoxelSystem::falseColorizeSubTreeOperation(OctreeElement* element, void* extraData) {
2436 if (node->getShouldRender()) {2425 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2426 if (voxel->getShouldRender()) {
2437 FalseColorizeSubTreeOperationArgs* args = (FalseColorizeSubTreeOperationArgs*) extraData;2427 FalseColorizeSubTreeOperationArgs* args = (FalseColorizeSubTreeOperationArgs*) extraData;
2438 node->setFalseColor(args->color[0], args->color[1], args->color[2]);2428 voxel->setFalseColor(args->color[0], args->color[1], args->color[2]);
2439 args->voxelsTouched++;2429 args->voxelsTouched++;
2440 }2430 }
2441 return true; 2431 return true;
2442}2432}
2443 2433
2444bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraData) {2434bool VoxelSystem::falseColorizeOccludedOperation(OctreeElement* element, void* extraData) {
2435 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2445 2436
2446 FalseColorizeOccludedArgs* args = (FalseColorizeOccludedArgs*) extraData;2437 FalseColorizeOccludedArgs* args = (FalseColorizeOccludedArgs*) extraData;
2447 args->totalVoxels++;2438 args->totalVoxels++;
2448 2439
2449 // If we are a parent, let's see if we're completely occluded.2440 // If we are a parent, let's see if we're completely occluded.
2450 if (!node->isLeaf()) {2441 if (!voxel->isLeaf()) {
2451 args->nonLeaves++;2442 args->nonLeaves++;
2452 2443
2453 AABox voxelBox = node->getAABox();2444 AABox voxelBox = voxel->getAABox();
2454 voxelBox.scale(TREE_SCALE);2445 voxelBox.scale(TREE_SCALE);
2455 VoxelProjectedPolygon* voxelPolygon = new VoxelProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));2446 OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
2456 2447
2457 // If we're not all in view, then ignore it, and just return. But keep searching...2448 // If we're not all in view, then ignore it, and just return. But keep searching...
2458 if (!voxelPolygon->getAllInView()) {2449 if (!voxelPolygon->getAllInView()) {
@@ -2472,7 +2463,7 @@ bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraDat · 13 unmodified lines
2472 subArgs.color[2] = 0;2463 subArgs.color[2] = 0;
2473 subArgs.voxelsTouched = 0;2464 subArgs.voxelsTouched = 0;
2474 2465
2475 args->tree->recurseNodeWithOperation(node, falseColorizeSubTreeOperation, &subArgs );2466 args->tree->recurseNodeWithOperation(voxel, falseColorizeSubTreeOperation, &subArgs );
2476 2467
2477 args->subtreeVoxelsSkipped += (subArgs.voxelsTouched - 1);2468 args->subtreeVoxelsSkipped += (subArgs.voxelsTouched - 1);
2478 args->totalVoxels += (subArgs.voxelsTouched - 1);2469 args->totalVoxels += (subArgs.voxelsTouched - 1);
@@ -2484,12 +2475,12 @@ bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraDat · 5 unmodified lines
2484 return true; // keep looking...2475 return true; // keep looking...
2485 }2476 }
2486 2477
2487 if (node->isLeaf() && node->isColored() && node->getShouldRender()) {2478 if (voxel->isLeaf() && voxel->isColored() && voxel->getShouldRender()) {
2488 args->coloredVoxels++;2479 args->coloredVoxels++;
2489 2480
2490 AABox voxelBox = node->getAABox();2481 AABox voxelBox = voxel->getAABox();
2491 voxelBox.scale(TREE_SCALE);2482 voxelBox.scale(TREE_SCALE);
2492 VoxelProjectedPolygon* voxelPolygon = new VoxelProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));2483 OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
2493 2484
2494 // If we're not all in view, then ignore it, and just return. But keep searching...2485 // If we're not all in view, then ignore it, and just return. But keep searching...
2495 if (!voxelPolygon->getAllInView()) {2486 if (!voxelPolygon->getAllInView()) {
@@ -2500,7 +2491,7 @@ bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraDat · 4 unmodified lines
2500 2491
2501 CoverageMapStorageResult result = args->map->checkMap(voxelPolygon, true);2492 CoverageMapStorageResult result = args->map->checkMap(voxelPolygon, true);
2502 if (result == OCCLUDED) {2493 if (result == OCCLUDED) {
2503 node->setFalseColor(255, 0, 0);2494 voxel->setFalseColor(255, 0, 0);
2504 args->occludedVoxels++;2495 args->occludedVoxels++;
2505 } else if (result == STORED) {2496 } else if (result == STORED) {
2506 args->notOccludedVoxels++;2497 args->notOccludedVoxels++;
@@ -2530,9 +2521,9 @@ void VoxelSystem::falseColorizeOccluded() { · 23 unmodified lines
2530 args.nonLeavesOccluded = 0;2521 args.nonLeavesOccluded = 0;
2531 args.tree = _tree;2522 args.tree = _tree;
2532 2523
2533 VoxelProjectedPolygon::pointInside_calls = 0;2524 OctreeProjectedPolygon::pointInside_calls = 0;
2534 VoxelProjectedPolygon::occludes_calls = 0;2525 OctreeProjectedPolygon::occludes_calls = 0;
2535 VoxelProjectedPolygon::intersects_calls = 0;2526 OctreeProjectedPolygon::intersects_calls = 0;
2536 2527
2537 glm::vec3 position = args.viewFrustum->getPosition() * (1.0f/TREE_SCALE);2528 glm::vec3 position = args.viewFrustum->getPosition() * (1.0f/TREE_SCALE);
2538 2529
@@ -2543,9 +2534,9 @@ void VoxelSystem::falseColorizeOccluded() { · 4 unmodified lines
2543 args.totalVoxels, args.coloredVoxels, args.occludedVoxels, 2534 args.totalVoxels, args.coloredVoxels, args.occludedVoxels,
2544 args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped, 2535 args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped,
2545 args.nonLeaves, args.nonLeavesOutOfView, args.nonLeavesOccluded,2536 args.nonLeaves, args.nonLeavesOutOfView, args.nonLeavesOccluded,
2546 VoxelProjectedPolygon::pointInside_calls,2537 OctreeProjectedPolygon::pointInside_calls,
2547 VoxelProjectedPolygon::occludes_calls,2538 OctreeProjectedPolygon::occludes_calls,
2548 VoxelProjectedPolygon::intersects_calls2539 OctreeProjectedPolygon::intersects_calls
2549 );2540 );
2550 2541
2551 2542
@@ -2555,18 +2546,19 @@ void VoxelSystem::falseColorizeOccluded() { · 3 unmodified lines
2555 setupNewVoxelsForDrawing();2546 setupNewVoxelsForDrawing();
2556}2547}
2557 2548
2558bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraData) {2549bool VoxelSystem::falseColorizeOccludedV2Operation(OctreeElement* element, void* extraData) {
2550 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2559 2551
2560 FalseColorizeOccludedArgs* args = (FalseColorizeOccludedArgs*) extraData;2552 FalseColorizeOccludedArgs* args = (FalseColorizeOccludedArgs*) extraData;
2561 args->totalVoxels++;2553 args->totalVoxels++;
2562 2554
2563 // If we are a parent, let's see if we're completely occluded.2555 // If we are a parent, let's see if we're completely occluded.
2564 if (!node->isLeaf()) {2556 if (!voxel->isLeaf()) {
2565 args->nonLeaves++;2557 args->nonLeaves++;
2566 2558
2567 AABox voxelBox = node->getAABox();2559 AABox voxelBox = voxel->getAABox();
2568 voxelBox.scale(TREE_SCALE);2560 voxelBox.scale(TREE_SCALE);
2569 VoxelProjectedPolygon* voxelPolygon = new VoxelProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));2561 OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
2570 2562
2571 // If we're not all in view, then ignore it, and just return. But keep searching...2563 // If we're not all in view, then ignore it, and just return. But keep searching...
2572 if (!voxelPolygon->getAllInView()) {2564 if (!voxelPolygon->getAllInView()) {
@@ -2586,7 +2578,7 @@ bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraD · 13 unmodified lines
2586 subArgs.color[2] = 0;2578 subArgs.color[2] = 0;
2587 subArgs.voxelsTouched = 0;2579 subArgs.voxelsTouched = 0;
2588 2580
2589 args->tree->recurseNodeWithOperation(node, falseColorizeSubTreeOperation, &subArgs );2581 args->tree->recurseNodeWithOperation(voxel, falseColorizeSubTreeOperation, &subArgs );
2590 2582
2591 args->subtreeVoxelsSkipped += (subArgs.voxelsTouched - 1);2583 args->subtreeVoxelsSkipped += (subArgs.voxelsTouched - 1);
2592 args->totalVoxels += (subArgs.voxelsTouched - 1);2584 args->totalVoxels += (subArgs.voxelsTouched - 1);
@@ -2598,12 +2590,12 @@ bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraD · 5 unmodified lines
2598 return true; // keep looking...2590 return true; // keep looking...
2599 }2591 }
2600 2592
2601 if (node->isLeaf() && node->isColored() && node->getShouldRender()) {2593 if (voxel->isLeaf() && voxel->isColored() && voxel->getShouldRender()) {
2602 args->coloredVoxels++;2594 args->coloredVoxels++;
2603 2595
2604 AABox voxelBox = node->getAABox();2596 AABox voxelBox = voxel->getAABox();
2605 voxelBox.scale(TREE_SCALE);2597 voxelBox.scale(TREE_SCALE);
2606 VoxelProjectedPolygon* voxelPolygon = new VoxelProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));2598 OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
2607 2599
2608 // If we're not all in view, then ignore it, and just return. But keep searching...2600 // If we're not all in view, then ignore it, and just return. But keep searching...
2609 if (!voxelPolygon->getAllInView()) {2601 if (!voxelPolygon->getAllInView()) {
@@ -2614,7 +2606,7 @@ bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraD · 4 unmodified lines
2614 2606
2615 CoverageMapV2StorageResult result = args->mapV2->checkMap(voxelPolygon, true);2607 CoverageMapV2StorageResult result = args->mapV2->checkMap(voxelPolygon, true);
2616 if (result == V2_OCCLUDED) {2608 if (result == V2_OCCLUDED) {
2617 node->setFalseColor(255, 0, 0);2609 voxel->setFalseColor(255, 0, 0);
2618 args->occludedVoxels++;2610 args->occludedVoxels++;
2619 } else if (result == V2_STORED) {2611 } else if (result == V2_STORED) {
2620 args->notOccludedVoxels++;2612 args->notOccludedVoxels++;
@@ -2634,9 +2626,9 @@ void VoxelSystem::falseColorizeOccludedV2() { · 13 unmodified lines
2634 2626
2635 CoverageMapV2::wantDebugging = true;2627 CoverageMapV2::wantDebugging = true;
2636 2628
2637 VoxelProjectedPolygon::pointInside_calls = 0;2629 OctreeProjectedPolygon::pointInside_calls = 0;
2638 VoxelProjectedPolygon::occludes_calls = 0;2630 OctreeProjectedPolygon::occludes_calls = 0;
2639 VoxelProjectedPolygon::intersects_calls = 0;2631 OctreeProjectedPolygon::intersects_calls = 0;
2640 2632
2641 FalseColorizeOccludedArgs args;2633 FalseColorizeOccludedArgs args;
2642 args.viewFrustum = _viewFrustum;2634 args.viewFrustum = _viewFrustum;
@@ -2661,9 +2653,9 @@ void VoxelSystem::falseColorizeOccludedV2() { · 18 unmodified lines
2661 args.totalVoxels, args.coloredVoxels, args.occludedVoxels, 2653 args.totalVoxels, args.coloredVoxels, args.occludedVoxels,
2662 args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped, 2654 args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped,
2663 args.nonLeaves, args.nonLeavesOutOfView, args.nonLeavesOccluded,2655 args.nonLeaves, args.nonLeavesOutOfView, args.nonLeavesOccluded,
2664 VoxelProjectedPolygon::pointInside_calls,2656 OctreeProjectedPolygon::pointInside_calls,
2665 VoxelProjectedPolygon::occludes_calls,2657 OctreeProjectedPolygon::occludes_calls,
2666 VoxelProjectedPolygon::intersects_calls2658 OctreeProjectedPolygon::intersects_calls
2667 );2659 );
2668 //myCoverageMapV2.erase();2660 //myCoverageMapV2.erase();
2669 _tree->setDirtyBit();2661 _tree->setDirtyBit();
@@ -2677,13 +2669,14 @@ void VoxelSystem::nodeAdded(Node* node) { · 7 unmodified lines
2677 }2669 }
2678}2670}
2679 2671
2680bool VoxelSystem::killSourceVoxelsOperation(VoxelNode* node, void* extraData) {2672bool VoxelSystem::killSourceVoxelsOperation(OctreeElement* element, void* extraData) {
2673 VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2681 QUuid killedNodeID = *(QUuid*)extraData;2674 QUuid killedNodeID = *(QUuid*)extraData;
2682 for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {2675 for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
2683 VoxelNode* childNode = node->getChildAtIndex(i);2676 VoxelTreeElement* childNode = voxel->getChildAtIndex(i);
2684 if (childNode) {2677 if (childNode) {
2685 if (childNode->matchesSourceUUID(killedNodeID)) {2678 if (childNode->matchesSourceUUID(killedNodeID)) {
2686 node->safeDeepDeleteChildAtIndex(i);2679 voxel->safeDeepDeleteChildAtIndex(i);
2687 }2680 }
2688 }2681 }
2689 }2682 }