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
7474 _readRenderFullVBO = true;
7575 _tree = new VoxelTree();
7676
77− _tree->rootNode->setVoxelSystem(this);
77+ _tree->getRoot()->setVoxelSystem(this);
7878 pthread_mutex_init(&_bufferWriteLock, NULL);
7979 pthread_mutex_init(&_treeLock, NULL);
8080 pthread_mutex_init(&_freeIndexLock, NULL);
8181
82− VoxelNode::addDeleteHook(this);
83− VoxelNode::addUpdateHook(this);
82+ VoxelTreeElement::addDeleteHook(this);
83+ VoxelTreeElement::addUpdateHook(this);
8484 _abandonedVBOSlots = 0;
8585 _falseColorizeBySource = false;
8686 _dataSourceUUID = QUuid();
@@ -113,13 +113,14 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels) · 26 unmodified lines
113113 _treeIsBusy = false;
114114 }
115115
116−void VoxelSystem::voxelDeleted(VoxelNode* node) {
117− if (node->getVoxelSystem() == this) {
116+void VoxelSystem::elementDeleted(OctreeElement* element) {
117+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
118+ if (voxel->getVoxelSystem() == this) {
118119 if (_voxelsInWriteArrays != 0) {
119− forceRemoveNodeFromArrays(node);
120+ forceRemoveNodeFromArrays(voxel);
120121 } else {
121122 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");
123124 }
124125 }
125126 }
@@ -132,50 +133,51 @@ void VoxelSystem::setDisableFastVoxelPipeline(bool disableFastVoxelPipeline) { · 6 unmodified lines
132133 setupNewVoxelsForDrawing();
133134 }
134135
135−void VoxelSystem::voxelUpdated(VoxelNode* node) {
136+void VoxelSystem::elementUpdated(OctreeElement* element) {
137+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
136138 // If we're in SetupNewVoxelsForDrawing() or _writeRenderFullVBO then bail..
137139 if (!_useFastVoxelPipeline || _inSetupNewVoxelsForDrawing || _writeRenderFullVBO) {
138140 return;
139141 }
140142
141− if (node->getVoxelSystem() == this) {
143+ if (voxel->getVoxelSystem() == this) {
142144 bool shouldRender = false; // assume we don't need to render it
143145 // if it's colored, we might need to render it!
144146 float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();
145147 int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
146− shouldRender = node->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);
148+ shouldRender = voxel->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);
147149
148− if (node->getShouldRender() != shouldRender) {
149− node->setShouldRender(shouldRender);
150+ if (voxel->getShouldRender() != shouldRender) {
151+ voxel->setShouldRender(shouldRender);
150152 }
151153
152− if (!node->isLeaf()) {
154+ if (!voxel->isLeaf()) {
153155
154156 // As we check our children, see if any of them went from shouldRender to NOT shouldRender
155157 // then we probably dropped LOD and if we don't have color, we want to average our children
156158 // for a new color.
157159 int childrenGotHiddenCount = 0;
158160 for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
159− VoxelNode* childNode = node->getChildAtIndex(i);
160− if (childNode) {
161− bool wasShouldRender = childNode->getShouldRender();
162− bool isShouldRender = childNode->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);
161+ VoxelTreeElement* childVoxel = voxel->getChildAtIndex(i);
162+ if (childVoxel) {
163+ bool wasShouldRender = childVoxel->getShouldRender();
164+ bool isShouldRender = childVoxel->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);
163165 if (wasShouldRender && !isShouldRender) {
164166 childrenGotHiddenCount++;
165167 }
166168 }
167169 }
168170 if (childrenGotHiddenCount > 0) {
169− node->setColorFromAverageOfChildren();
171+ voxel->calculateAverageFromChildren();
170172 }
171173 }
172174
173175 const bool REUSE_INDEX = true;
174176 const bool DONT_FORCE_REDRAW = false;
175− updateNodeInArrays(node, REUSE_INDEX, DONT_FORCE_REDRAW);
177+ updateNodeInArrays(voxel, REUSE_INDEX, DONT_FORCE_REDRAW);
176178 _voxelsUpdated++;
177179
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.
179181
180182 setupNewVoxelsForDrawingSingleNode();
181183 }
@@ -199,7 +201,7 @@ glBufferIndex VoxelSystem::getNextBufferIndex() { · 17 unmodified lines
199201 return output;
200202 }
201203
202−// Release responsibility of the buffer/vbo index from the VoxelNode, and makes the index available for some other node to use
204+// Release responsibility of the buffer/vbo index from the VoxelTreeElement, and makes the index available for some other node to use
203205 // 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
204206 // will be "invisible"
205207 void VoxelSystem::freeBufferIndex(glBufferIndex index) {
@@ -260,8 +262,8 @@ VoxelSystem::~VoxelSystem() { · 54 unmodified lines
260262 pthread_mutex_destroy(&_treeLock);
261263 pthread_mutex_destroy(&_freeIndexLock);
262264
263− VoxelNode::removeDeleteHook(this);
264− VoxelNode::removeUpdateHook(this);
265+ VoxelTreeElement::removeDeleteHook(this);
266+ VoxelTreeElement::removeUpdateHook(this);
265267 }
266268
267269 void VoxelSystem::setMaxVoxels(int maxVoxels) {
@@ -534,13 +536,8 @@ void VoxelSystem::initVoxelMemory() { · 266 unmodified lines
534536 pthread_mutex_unlock(&_bufferWriteLock);
535537 }
536538
537−void VoxelSystem::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) {
538− _tree->loadVoxelsFile(fileName, wantColorRandomizer);
539− setupNewVoxelsForDrawing();
540−}
541−
542−void VoxelSystem::writeToSVOFile(const char* filename, VoxelNode* node) const {
543− _tree->writeToSVOFile(filename, node);
539+void VoxelSystem::writeToSVOFile(const char* filename, VoxelTreeElement* element) const {
540+ _tree->writeToSVOFile(filename, element);
544541 }
545542
546543 bool VoxelSystem::readFromSVOFile(const char* filename) {
@@ -567,30 +564,6 @@ bool VoxelSystem::readFromSchematicFile(const char* filename) { · 20 unmodified lines
567564 return result;
568565 }
569566
570−long int VoxelSystem::getVoxelsCreated() {
571− return _tree->voxelsCreated;
572−}
573−
574−float VoxelSystem::getVoxelsCreatedPerSecondAverage() {
575− return (1 / _tree->voxelsCreatedStats.getEventDeltaAverage());
576−}
577−
578−long int VoxelSystem::getVoxelsColored() {
579− return _tree->voxelsColored;
580−}
581−
582−float VoxelSystem::getVoxelsColoredPerSecondAverage() {
583− return (1 / _tree->voxelsColoredStats.getEventDeltaAverage());
584−}
585−
586−long int VoxelSystem::getVoxelsBytesRead() {
587− return _tree->voxelsBytesRead;
588−}
589−
590−float VoxelSystem::getVoxelsBytesReadPerSecondAverage() {
591− return _tree->voxelsBytesReadStats.getAverageSampleValuePerSecond();
592−}
593−
594567 int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
595568
596569 unsigned char command = *sourceBuffer;
@@ -702,7 +675,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() { · 105 unmodified lines
702675 if (_writeRenderFullVBO) {
703676 clearFreeBufferIndexes();
704677 }
705− _voxelsUpdated = newTreeToArrays(_tree->rootNode);
678+ _voxelsUpdated = newTreeToArrays(_tree->getRoot());
706679 _tree->clearDirtyBit(); // after we pull the trees into the array, we can consider the tree clean
707680
708681 if (_writeRenderFullVBO) {
@@ -955,56 +928,56 @@ void VoxelSystem::copyWrittenDataToReadArrays(bool fullVBOs) { · 246 unmodified lines
955928 }
956929 }
957930
958−int VoxelSystem::newTreeToArrays(VoxelNode* node) {
931+int VoxelSystem::newTreeToArrays(VoxelTreeElement* voxel) {
959932 int voxelsUpdated = 0;
960933 bool shouldRender = false; // assume we don't need to render it
961934 // if it's colored, we might need to render it!
962935 float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();;
963936 int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
964− shouldRender = node->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);
937+ shouldRender = voxel->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);
965938
966− node->setShouldRender(shouldRender);
939+ voxel->setShouldRender(shouldRender);
967940 // let children figure out their renderness
968− if (!node->isLeaf()) {
941+ if (!voxel->isLeaf()) {
969942
970943 // As we check our children, see if any of them went from shouldRender to NOT shouldRender
971944 // then we probably dropped LOD and if we don't have color, we want to average our children
972945 // for a new color.
973946 int childrenGotHiddenCount = 0;
974947 for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
975− VoxelNode* childNode = node->getChildAtIndex(i);
976− if (childNode) {
977− bool wasShouldRender = childNode->getShouldRender();
978− voxelsUpdated += newTreeToArrays(childNode);
979− bool isShouldRender = childNode->getShouldRender();
948+ VoxelTreeElement* childVoxel = voxel->getChildAtIndex(i);
949+ if (childVoxel) {
950+ bool wasShouldRender = childVoxel->getShouldRender();
951+ voxelsUpdated += newTreeToArrays(childVoxel);
952+ bool isShouldRender = childVoxel->getShouldRender();
980953 if (wasShouldRender && !isShouldRender) {
981954 childrenGotHiddenCount++;
982955 }
983956 }
984957 }
985958 if (childrenGotHiddenCount > 0) {
986− node->setColorFromAverageOfChildren();
959+ voxel->calculateAverageFromChildren();
987960 }
988961 }
989962 if (_writeRenderFullVBO) {
990963 const bool DONT_REUSE_INDEX = false;
991964 const bool FORCE_REDRAW = true;
992− voxelsUpdated += updateNodeInArrays(node, DONT_REUSE_INDEX, FORCE_REDRAW);
965+ voxelsUpdated += updateNodeInArrays(voxel, DONT_REUSE_INDEX, FORCE_REDRAW);
993966 } else {
994967 const bool REUSE_INDEX = true;
995968 const bool DONT_FORCE_REDRAW = false;
996− voxelsUpdated += updateNodeInArrays(node, REUSE_INDEX, DONT_FORCE_REDRAW);
969+ voxelsUpdated += updateNodeInArrays(voxel, REUSE_INDEX, DONT_FORCE_REDRAW);
997970 }
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.
999972
1000973 return voxelsUpdated;
1001974 }
1002975
1003−// called as response to voxelDeleted() in fast pipeline case. The node
976+// called as response to elementDeleted() in fast pipeline case. The node
1004977 // is being deleted, but it's state is such that it thinks it should render
1005978 // and therefore we can't use the normal render calculations. This method
1006979 // will forcibly remove it from the VBOs because we know better!!!
1007−int VoxelSystem::forceRemoveNodeFromArrays(VoxelNode* node) {
980+int VoxelSystem::forceRemoveNodeFromArrays(VoxelTreeElement* node) {
1008981
1009982 if (!_initialized) {
1010983 return 0;
@@ -1021,7 +994,7 @@ int VoxelSystem::forceRemoveNodeFromArrays(VoxelNode* node) { · 10 unmodified lines
1021994 return 0; // not-updated
1022995 }
1023996
1024−int VoxelSystem::updateNodeInArrays(VoxelNode* node, bool reuseIndex, bool forceDraw) {
997+int VoxelSystem::updateNodeInArrays(VoxelTreeElement* node, bool reuseIndex, bool forceDraw) {
1025998 // If we've run out of room, then just bail...
1026999 if (_voxelsInWriteArrays >= _maxVoxels && (_freeIndexes.size() == 0)) {
10271000 // 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
11291102 initVoxelMemory();
11301103
11311104 // our own _removedVoxels doesn't need to be notified of voxel deletes
1132− VoxelNode::removeDeleteHook(&_removedVoxels);
1105+ VoxelTreeElement::removeDeleteHook(&_removedVoxels);
11331106 }
11341107
11351108 void VoxelSystem::changeTree(VoxelTree* newTree) {
@@ -1137,7 +1110,7 @@ void VoxelSystem::changeTree(VoxelTree* newTree) { · 1 unmodified line
11371110
11381111 _tree = newTree;
11391112 _tree->setDirtyBit();
1140− _tree->rootNode->setVoxelSystem(this);
1113+ _tree->getRoot()->setVoxelSystem(this);
11411114
11421115 connect(_tree, SIGNAL(importSize(float,float,float)), SIGNAL(importSize(float,float,float)));
11431116 connect(_tree, SIGNAL(importProgress(int)), SIGNAL(importProgress(int)));
@@ -1457,7 +1430,7 @@ int VoxelSystem::_nodeCount = 0; · 313 unmodified lines
14571430
14581431 void VoxelSystem::killLocalVoxels() {
14591432 lockTree();
1460− _tree->eraseAllVoxels();
1433+ _tree->eraseAllOctreeElements();
14611434 unlockTree();
14621435 clearFreeBufferIndexes();
14631436 _voxelsInReadArrays = 0; // do we need to do this?
@@ -1469,9 +1442,10 @@ void VoxelSystem::redrawInViewVoxels() { · 5 unmodified lines
14691442 }
14701443
14711444
1472−bool VoxelSystem::clearAllNodesBufferIndexOperation(VoxelNode* node, void* extraData) {
1445+bool VoxelSystem::clearAllNodesBufferIndexOperation(OctreeElement* element, void* extraData) {
14731446 _nodeCount++;
1474− node->setBufferIndex(GLBUFFER_INDEX_UNKNOWN);
1447+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
1448+ voxel->setBufferIndex(GLBUFFER_INDEX_UNKNOWN);
14751449 return true;
14761450 }
14771451
@@ -1485,7 +1459,7 @@ void VoxelSystem::clearAllNodesBufferIndex() { · 7 unmodified lines
14851459 }
14861460 }
14871461
1488−bool VoxelSystem::forceRedrawEntireTreeOperation(VoxelNode* node, void* extraData) {
1462+bool VoxelSystem::forceRedrawEntireTreeOperation(OctreeElement* node, void* extraData) {
14891463 _nodeCount++;
14901464 node->setDirtyBit();
14911465 return true;
@@ -1499,11 +1473,12 @@ void VoxelSystem::forceRedrawEntireTree() { · 7 unmodified lines
14991473 setupNewVoxelsForDrawing();
15001474 }
15011475
1502−bool VoxelSystem::randomColorOperation(VoxelNode* node, void* extraData) {
1476+bool VoxelSystem::randomColorOperation(OctreeElement* element, void* extraData) {
1477+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
15031478 _nodeCount++;
1504− if (node->isColored()) {
1479+ if (voxel->isColored()) {
15051480 nodeColor newColor = { 255, randomColorValue(150), randomColorValue(150), 1 };
1506− node->setColor(newColor);
1481+ voxel->setColor(newColor);
15071482 }
15081483 return true;
15091484 }
@@ -1516,10 +1491,11 @@ void VoxelSystem::randomizeVoxelColors() { · 6 unmodified lines
15161491 setupNewVoxelsForDrawing();
15171492 }
15181493
1519−bool VoxelSystem::falseColorizeRandomOperation(VoxelNode* node, void* extraData) {
1494+bool VoxelSystem::falseColorizeRandomOperation(OctreeElement* element, void* extraData) {
1495+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
15201496 _nodeCount++;
15211497 // always false colorize
1522− node->setFalseColor(255, randomColorValue(150), randomColorValue(150));
1498+ voxel->setFalseColor(255, randomColorValue(150), randomColorValue(150));
15231499 return true; // keep going!
15241500 }
15251501
@@ -1531,9 +1507,10 @@ void VoxelSystem::falseColorizeRandom() { · 5 unmodified lines
15311507 setupNewVoxelsForDrawing();
15321508 }
15331509
1534−bool VoxelSystem::trueColorizeOperation(VoxelNode* node, void* extraData) {
1510+bool VoxelSystem::trueColorizeOperation(OctreeElement* element, void* extraData) {
1511+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
15351512 _nodeCount++;
1536− node->setFalseColored(false);
1513+ voxel->setFalseColored(false);
15371514 return true;
15381515 }
15391516
@@ -1547,13 +1524,14 @@ void VoxelSystem::trueColorize() { · 7 unmodified lines
15471524 }
15481525
15491526 // Will false colorize voxels that are not in view
1550−bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData) {
1527+bool VoxelSystem::falseColorizeInViewOperation(OctreeElement* element, void* extraData) {
1528+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
15511529 const ViewFrustum* viewFrustum = (const ViewFrustum*) extraData;
15521530 _nodeCount++;
1553− if (node->isColored()) {
1554− if (!node->isInView(*viewFrustum)) {
1531+ if (voxel->isColored()) {
1532+ if (!voxel->isInView(*viewFrustum)) {
15551533 // Out of view voxels are colored RED
1556− node->setFalseColor(255, 0, 0);
1534+ voxel->setFalseColor(255, 0, 0);
15571535 }
15581536 }
15591537 return true; // keep going!
@@ -1584,13 +1562,14 @@ public: · 24 unmodified lines
15841562 };
15851563
15861564 // Will false colorize voxels that are not in view
1587−bool VoxelSystem::falseColorizeBySourceOperation(VoxelNode* node, void* extraData) {
1565+bool VoxelSystem::falseColorizeBySourceOperation(OctreeElement* element, void* extraData) {
1566+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
15881567 colorizeBySourceArgs* args = (colorizeBySourceArgs*)extraData;
15891568 _nodeCount++;
1590− if (node->isColored()) {
1569+ if (voxel->isColored()) {
15911570 // pick a color based on the source - we want each source to be obviously different
1592− uint16_t nodeIDKey = node->getSourceUUIDKey();
1593− node->setFalseColor(args->colors[nodeIDKey].red, args->colors[nodeIDKey].green, args->colors[nodeIDKey].blue);
1571+ uint16_t nodeIDKey = voxel->getSourceUUIDKey();
1572+ voxel->setFalseColor(args->colors[nodeIDKey].red, args->colors[nodeIDKey].green, args->colors[nodeIDKey].blue);
15941573 }
15951574 return true; // keep going!
15961575 }
@@ -1614,7 +1593,7 @@ void VoxelSystem::falseColorizeBySource() { · 17 unmodified lines
16141593 NodeList* nodeList = NodeList::getInstance();
16151594 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
16161595 if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
1617− uint16_t nodeID = VoxelNode::getSourceNodeUUIDKey(node->getUUID());
1596+ uint16_t nodeID = VoxelTreeElement::getSourceNodeUUIDKey(node->getUUID());
16181597 int groupColor = voxelServerCount % NUMBER_OF_COLOR_GROUPS;
16191598 args.colors[nodeID] = groupColors[groupColor];
16201599
@@ -1639,10 +1618,11 @@ void VoxelSystem::falseColorizeBySource() { · 18 unmodified lines
16391618 }
16401619
16411620 // Will false colorize voxels based on distance from view
1642−bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, void* extraData) {
1621+bool VoxelSystem::falseColorizeDistanceFromViewOperation(OctreeElement* element, void* extraData) {
1622+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
16431623 ViewFrustum* viewFrustum = (ViewFrustum*) extraData;
1644− if (node->isColored()) {
1645− float distance = node->distanceToCamera(*viewFrustum);
1624+ if (voxel->isColored()) {
1625+ float distance = voxel->distanceToCamera(*viewFrustum);
16461626 _nodeCount++;
16471627 float distanceRatio = (_minDistance == _maxDistance) ? 1 : (distance - _minDistance) / (_maxDistance - _minDistance);
16481628
@@ -1651,7 +1631,7 @@ bool VoxelSystem::falseColorizeDistanceFromViewOperation(VoxelNode* node, void* · 2 unmodified lines
16511631 const unsigned char colorBands = 16;
16521632 const unsigned char gradientOver = 128;
16531633 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);
16551635 }
16561636 return true; // keep going!
16571637 }
@@ -1662,11 +1642,12 @@ float VoxelSystem::_minDistance = FLT_MAX; · 4 unmodified lines
16621642 // Helper function will get the distance from view range, would be nice if you could just keep track
16631643 // of this as voxels are created and/or colored... seems like some transform math could do that so
16641644 // we wouldn't need to do two passes of the tree
1665−bool VoxelSystem::getDistanceFromViewRangeOperation(VoxelNode* node, void* extraData) {
1645+bool VoxelSystem::getDistanceFromViewRangeOperation(OctreeElement* element, void* extraData) {
1646+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
16661647 ViewFrustum* viewFrustum = (ViewFrustum*) extraData;
16671648 // only do this for truly colored voxels...
1668− if (node->isColored()) {
1669− float distance = node->distanceToCamera(*viewFrustum);
1649+ if (voxel->isColored()) {
1650+ float distance = voxel->distanceToCamera(*viewFrustum);
16701651 // calculate the range of distances
16711652 if (distance > _maxDistance) {
16721653 _maxDistance = distance;
@@ -1695,16 +1676,16 @@ void VoxelSystem::falseColorizeDistanceFromView() { · 22 unmodified lines
16951676 // combines the removeOutOfView args into a single class
16961677 class removeOutOfViewArgs {
16971678 public:
1698− VoxelSystem* thisVoxelSystem;
1699− ViewFrustum thisViewFrustum;
1700− VoxelNodeBag dontRecurseBag;
1679+ VoxelSystem* thisVoxelSystem;
1680+ ViewFrustum thisViewFrustum;
1681+ OctreeElementBag dontRecurseBag;
17011682 unsigned long nodesScanned;
17021683 unsigned long nodesRemoved;
17031684 unsigned long nodesInside;
17041685 unsigned long nodesIntersect;
17051686 unsigned long nodesOutside;
1706− VoxelNode* insideRoot;
1707− VoxelNode* outsideRoot;
1687+ VoxelTreeElement* insideRoot;
1688+ VoxelTreeElement* outsideRoot;
17081689
17091690 removeOutOfViewArgs(VoxelSystem* voxelSystem, bool widenViewFrustum = true) :
17101691 thisVoxelSystem(voxelSystem),
@@ -1734,14 +1715,15 @@ void VoxelSystem::cancelImport() { · 23 unmodified lines
17341715
17351716 // "Remove" voxels from the tree that are not in view. We don't actually delete them,
17361717 // we remove them from the tree and place them into a holding area for later deletion
1737−bool VoxelSystem::removeOutOfViewOperation(VoxelNode* node, void* extraData) {
1718+bool VoxelSystem::removeOutOfViewOperation(OctreeElement* element, void* extraData) {
1719+ VoxelTreeElement* voxel = (VoxelTreeElement*) element;
17381720 removeOutOfViewArgs* args = (removeOutOfViewArgs*)extraData;
17391721
17401722 // If our node was previously added to the don't recurse bag, then return false to
17411723 // stop the further recursion. This means that the whole node and it's children are
17421724 // known to be in view, so don't recurse them
1743− if (args->dontRecurseBag.contains(node)) {
1744− args->dontRecurseBag.remove(node);
1725+ if (args->dontRecurseBag.contains(voxel)) {
1726+ args->dontRecurseBag.remove(voxel);
17451727 return false; // stop recursion
17461728 }
17471729
@@ -1749,14 +1731,14 @@ bool VoxelSystem::removeOutOfViewOperation(VoxelNode* node, void* extraData) { · 1 unmodified line
17491731 args->nodesScanned++;
17501732 // Need to operate on our child nodes, so we can remove them
17511733 for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
1752− VoxelNode* childNode = node->getChildAtIndex(i);
1734+ VoxelTreeElement* childNode = voxel->getChildAtIndex(i);
17531735 if (childNode) {
17541736 ViewFrustum::location inFrustum = childNode->inFrustum(args->thisViewFrustum);
17551737 switch (inFrustum) {
17561738 case ViewFrustum::OUTSIDE: {
17571739 args->nodesOutside++;
17581740 args->nodesRemoved++;
1759− node->removeChildAtIndex(i);
1741+ voxel->removeChildAtIndex(i);
17601742 thisVoxelSystem->_removedVoxels.insert(childNode);
17611743 // by removing the child, it will not get recursed!
17621744 } break;
@@ -1850,24 +1832,25 @@ void VoxelSystem::showAllLocalVoxels() { · 87 unmodified lines
18501832 }
18511833 }
18521834
1853−bool VoxelSystem::showAllLocalVoxelsOperation(VoxelNode* node, void* extraData) {
1835+bool VoxelSystem::showAllLocalVoxelsOperation(OctreeElement* element, void* extraData) {
1836+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
18541837 showAllLocalVoxelsArgs* args = (showAllLocalVoxelsArgs*)extraData;
18551838
18561839 args->nodesScanned++;
18571840
18581841 float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();;
18591842 int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
1860− bool shouldRender = node->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale, boundaryLevelAdjust);
1861− node->setShouldRender(shouldRender);
1843+ bool shouldRender = voxel->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale, boundaryLevelAdjust);
1844+ voxel->setShouldRender(shouldRender);
18621845
18631846 if (shouldRender) {
18641847 bool falseColorize = false;
18651848 if (falseColorize) {
1866− node->setFalseColor(0,0,255); // false colorize
1849+ voxel->setFalseColor(0,0,255); // false colorize
18671850 }
18681851 // These are both needed to force redraw...
1869− node->setDirtyBit();
1870− node->markWithChangedTime();
1852+ voxel->setDirtyBit();
1853+ voxel->markWithChangedTime();
18711854 }
18721855
18731856 return true; // keep recursing!
@@ -1991,7 +1974,8 @@ void VoxelSystem::hideOutOfView(bool forceFullFrustum) { · 117 unmodified lines
19911974 _inhideOutOfView = false;
19921975 }
19931976
1994−bool VoxelSystem::hideAllSubTreeOperation(VoxelNode* node, void* extraData) {
1977+bool VoxelSystem::hideAllSubTreeOperation(OctreeElement* element, void* extraData) {
1978+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
19951979 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;
19961980
19971981 // 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
20001984 ViewFrustum::location inLastCulledFrustum;
20011985
20021986 if (args->culledOnce && args->wantDeltaFrustums) {
2003− inLastCulledFrustum = node->inFrustum(args->lastViewFrustum);
1987+ inLastCulledFrustum = voxel->inFrustum(args->lastViewFrustum);
20041988
20051989 // if this node is fully OUTSIDE our last culled view frustum, then we don't need to recurse further
20061990 if (inLastCulledFrustum == ViewFrustum::OUTSIDE) {
@@ -2010,14 +1994,14 @@ bool VoxelSystem::hideAllSubTreeOperation(VoxelNode* node, void* extraData) { · 3 unmodified lines
20101994 }
20111995
20121996 args->nodesOutside++;
2013− if (node->isKnownBufferIndex()) {
1997+ if (voxel->isKnownBufferIndex()) {
20141998 args->nodesRemoved++;
20151999 bool falseColorize = false;
20162000 if (falseColorize) {
2017− node->setFalseColor(255,0,0); // false colorize
2001+ voxel->setFalseColor(255,0,0); // false colorize
20182002 } else {
20192003 VoxelSystem* thisVoxelSystem = args->thisVoxelSystem;
2020− thisVoxelSystem->_voxelsUpdated += thisVoxelSystem->forceRemoveNodeFromArrays(node);
2004+ thisVoxelSystem->_voxelsUpdated += thisVoxelSystem->forceRemoveNodeFromArrays(voxel);
20212005 thisVoxelSystem->setupNewVoxelsForDrawingSingleNode();
20222006 }
20232007
@@ -2026,7 +2010,8 @@ bool VoxelSystem::hideAllSubTreeOperation(VoxelNode* node, void* extraData) { · 2 unmodified lines
20262010 return true;
20272011 }
20282012
2029−bool VoxelSystem::showAllSubTreeOperation(VoxelNode* node, void* extraData) {
2013+bool VoxelSystem::showAllSubTreeOperation(OctreeElement* element, void* extraData) {
2014+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
20302015 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;
20312016
20322017 // 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
20352020 ViewFrustum::location inLastCulledFrustum;
20362021
20372022 if (args->culledOnce && args->wantDeltaFrustums) {
2038− inLastCulledFrustum = node->inFrustum(args->lastViewFrustum);
2023+ inLastCulledFrustum = voxel->inFrustum(args->lastViewFrustum);
20392024
20402025 // if this node is fully inside our last culled view frustum, then we don't need to recurse further
20412026 if (inLastCulledFrustum == ViewFrustum::INSIDE) {
@@ -2048,17 +2033,17 @@ bool VoxelSystem::showAllSubTreeOperation(VoxelNode* node, void* extraData) { · 6 unmodified lines
20482033
20492034 float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();
20502035 int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
2051− bool shouldRender = node->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale, boundaryLevelAdjust);
2052− node->setShouldRender(shouldRender);
2036+ bool shouldRender = voxel->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale, boundaryLevelAdjust);
2037+ voxel->setShouldRender(shouldRender);
20532038
2054− if (shouldRender && !node->isKnownBufferIndex()) {
2039+ if (shouldRender && !voxel->isKnownBufferIndex()) {
20552040 bool falseColorize = false;
20562041 if (falseColorize) {
2057− node->setFalseColor(0,0,255); // false colorize
2042+ voxel->setFalseColor(0,0,255); // false colorize
20582043 }
20592044 // These are both needed to force redraw...
2060− node->setDirtyBit();
2061− node->markWithChangedTime();
2045+ voxel->setDirtyBit();
2046+ voxel->markWithChangedTime();
20622047 }
20632048
20642049 return true; // keep recursing!
@@ -2067,12 +2052,13 @@ bool VoxelSystem::showAllSubTreeOperation(VoxelNode* node, void* extraData) { · 2 unmodified lines
20672052 // "hide" voxels in the VBOs that are still in the tree that but not in view.
20682053 // We don't remove them from the tree, we don't delete them, we do remove them
20692054 // from the VBOs and mark them as such in the tree.
2070−bool VoxelSystem::hideOutOfViewOperation(VoxelNode* node, void* extraData) {
2055+bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData) {
2056+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
20712057 hideOutOfViewArgs* args = (hideOutOfViewArgs*)extraData;
20722058
20732059 // If we're still recursing the tree using this operator, then we don't know if we're inside or outside...
20742060 // 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);
20762062
20772063 // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine
20782064 // 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
20802066 ViewFrustum::location inLastCulledFrustum;
20812067
20822068 if (args->culledOnce && args->wantDeltaFrustums) {
2083− inLastCulledFrustum = node->inFrustum(args->lastViewFrustum);
2069+ inLastCulledFrustum = voxel->inFrustum(args->lastViewFrustum);
20842070 }
20852071
20862072 // ok, now do some processing for this node...
@@ -2099,7 +2085,7 @@ bool VoxelSystem::hideOutOfViewOperation(VoxelNode* node, void* extraData) { · 12 unmodified lines
20992085 // if this node is fully OUTSIDE the view, but previously intersected and/or was inside the last view, then
21002086 // we need to hide it. Additionally we know that ALL of it's children are also fully OUTSIDE so we can recurse
21012087 // the children and simply mark them as hidden
2102− args->tree->recurseNodeWithOperation(node, hideAllSubTreeOperation, args );
2088+ args->tree->recurseNodeWithOperation(voxel, hideAllSubTreeOperation, args );
21032089
21042090 return false;
21052091
@@ -2118,7 +2104,7 @@ bool VoxelSystem::hideOutOfViewOperation(VoxelNode* node, void* extraData) { · 12 unmodified lines
21182104 // if this node is fully INSIDE the view, but previously INTERSECTED and/or was OUTSIDE the last view, then
21192105 // we need to show it. Additionally we know that ALL of it's children are also fully INSIDE so we can recurse
21202106 // 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);
21222108
21232109 return false;
21242110 } break;
@@ -2138,8 +2124,8 @@ bool VoxelSystem::hideOutOfViewOperation(VoxelNode* node, void* extraData) { · 13 unmodified lines
21382124 // if the child node INTERSECTs the view, then we want to check to see if it thinks it should render
21392125 // if it should render but is missing it's VBO index, then we want to flip it on, and we can stop recursing from
21402126 // here because we know will block any children anyway
2141− if (node->getShouldRender() && !node->isKnownBufferIndex()) {
2142− node->setDirtyBit(); // will this make it draw?
2127+ if (voxel->getShouldRender() && !voxel->isKnownBufferIndex()) {
2128+ voxel->setDirtyBit(); // will this make it draw?
21432129 return false;
21442130 }
21452131
@@ -2159,18 +2145,19 @@ bool VoxelSystem::hideOutOfViewOperation(VoxelNode* node, void* extraData) { · 13 unmodified lines
21592145 bool VoxelSystem::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
21602146 VoxelDetail& detail, float& distance, BoxFace& face) {
21612147 lockTree();
2162− VoxelNode* node;
2163− if (!_tree->findRayIntersection(origin, direction, node, distance, face)) {
2148+ OctreeElement* element;
2149+ if (!_tree->findRayIntersection(origin, direction, element, distance, face)) {
21642150 unlockTree();
21652151 return false;
21662152 }
2167− detail.x = node->getCorner().x;
2168− detail.y = node->getCorner().y;
2169− detail.z = node->getCorner().z;
2170− detail.s = node->getScale();
2171− detail.red = node->getColor()[0];
2172− detail.green = node->getColor()[1];
2173− detail.blue = node->getColor()[2];
2153+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2154+ detail.x = voxel->getCorner().x;
2155+ detail.y = voxel->getCorner().y;
2156+ detail.z = voxel->getCorner().z;
2157+ detail.s = voxel->getScale();
2158+ detail.red = voxel->getColor()[0];
2159+ detail.green = voxel->getColor()[1];
2160+ detail.blue = voxel->getColor()[2];
21742161 unlockTree();
21752162 return true;
21762163 }
@@ -2198,14 +2185,15 @@ public: · 21 unmodified lines
21982185 bool colorThis;
21992186 };
22002187
2201−bool VoxelSystem::falseColorizeRandomEveryOtherOperation(VoxelNode* node, void* extraData) {
2188+bool VoxelSystem::falseColorizeRandomEveryOtherOperation(OctreeElement* element, void* extraData) {
2189+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
22022190 falseColorizeRandomEveryOtherArgs* args = (falseColorizeRandomEveryOtherArgs*)extraData;
22032191 args->totalNodes++;
2204− if (node->isColored()) {
2192+ if (voxel->isColored()) {
22052193 args->colorableNodes++;
22062194 if (args->colorThis) {
22072195 args->coloredNodes++;
2208− node->setFalseColor(255, randomColorValue(150), randomColorValue(150));
2196+ voxel->setFalseColor(255, randomColorValue(150), randomColorValue(150));
22092197 }
22102198 args->colorThis = !args->colorThis;
22112199 }
@@ -2257,42 +2245,43 @@ public: · 45 unmodified lines
22572245 bool* hasIndexFound;
22582246 };
22592247
2260−bool VoxelSystem::collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* extraData) {
2248+bool VoxelSystem::collectStatsForTreesAndVBOsOperation(OctreeElement* element, void* extraData) {
2249+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
22612250
22622251 collectStatsForTreesAndVBOsArgs* args = (collectStatsForTreesAndVBOsArgs*)extraData;
22632252 args->totalNodes++;
22642253
2265− if (node->isLeaf()) {
2254+ if (voxel->isLeaf()) {
22662255 args->leafNodes++;
22672256 }
22682257
2269− if (node->isColored()) {
2258+ if (voxel->isColored()) {
22702259 args->coloredNodes++;
22712260 }
22722261
2273− if (node->getShouldRender()) {
2262+ if (voxel->getShouldRender()) {
22742263 args->shouldRenderNodes++;
22752264 }
22762265
2277− if (node->isDirty()) {
2266+ if (voxel->isDirty()) {
22782267 args->dirtyNodes++;
22792268 }
22802269
2281− if (node->isKnownBufferIndex()) {
2270+ if (voxel->isKnownBufferIndex()) {
22822271 args->nodesInVBO++;
2283− unsigned long nodeIndex = node->getBufferIndex();
2272+ unsigned long nodeIndex = voxel->getBufferIndex();
22842273
22852274 const bool extraDebugging = false; // enable for extra debugging
22862275 if (extraDebugging) {
22872276 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(),
2289− nodeIndex, debug::valueOf(node->isDirty()), debug::valueOf(node->getShouldRender()));
2277+ voxel->getCorner().x, voxel->getCorner().y, voxel->getCorner().z, voxel->getScale(),
2278+ nodeIndex, debug::valueOf(voxel->isDirty()), debug::valueOf(voxel->getShouldRender()));
22902279 }
22912280
22922281 if (args->hasIndexFound[nodeIndex]) {
22932282 args->duplicateVBOIndex++;
22942283 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()));
22962285 } else {
22972286 args->hasIndexFound[nodeIndex] = true;
22982287 }
@@ -2301,7 +2290,7 @@ bool VoxelSystem::collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* ex · 2 unmodified lines
23012290 }
23022291
23032292 // if it's in VBO but not-shouldRender, track that also...
2304− if (!node->getShouldRender()) {
2293+ if (!voxel->getShouldRender()) {
23052294 args->nodesInVBONotShouldRender++;
23062295 }
23072296 }
@@ -2368,7 +2357,7 @@ void VoxelSystem::deleteVoxelAt(float x, float y, float z, float s) { · 60 unmodified lines
23682357
23692358 };
23702359
2371−VoxelNode* VoxelSystem::getVoxelAt(float x, float y, float z, float s) const {
2360+VoxelTreeElement* VoxelSystem::getVoxelAt(float x, float y, float z, float s) const {
23722361 return _tree->getVoxelAt(x, y, z, s);
23732362 };
23742363
@@ -2394,20 +2383,20 @@ void VoxelSystem::createSphere(float r,float xc, float yc, float zc, float s, bo · 19 unmodified lines
23942383 setupNewVoxelsForDrawing();
23952384 };
23962385
2397−void VoxelSystem::copySubTreeIntoNewTree(VoxelNode* startNode, VoxelSystem* destination, bool rebaseToRoot) {
2386+void VoxelSystem::copySubTreeIntoNewTree(VoxelTreeElement* startNode, VoxelSystem* destination, bool rebaseToRoot) {
23982387 _tree->copySubTreeIntoNewTree(startNode, destination->_tree, rebaseToRoot);
23992388 destination->setupNewVoxelsForDrawing();
24002389 }
24012390
2402−void VoxelSystem::copySubTreeIntoNewTree(VoxelNode* startNode, VoxelTree* destination, bool rebaseToRoot) {
2391+void VoxelSystem::copySubTreeIntoNewTree(VoxelTreeElement* startNode, VoxelTree* destination, bool rebaseToRoot) {
24032392 _tree->copySubTreeIntoNewTree(startNode, destination, rebaseToRoot);
24042393 }
24052394
2406−void VoxelSystem::copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelNode* destinationNode) {
2395+void VoxelSystem::copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelTreeElement* destinationNode) {
24072396 _tree->copyFromTreeIntoSubTree(sourceTree, destinationNode);
24082397 }
24092398
2410−void VoxelSystem::recurseTreeWithOperation(RecurseVoxelTreeOperation operation, void* extraData) {
2399+void VoxelSystem::recurseTreeWithOperation(RecurseOctreeOperation operation, void* extraData) {
24112400 _tree->recurseTreeWithOperation(operation, extraData);
24122401 }
24132402
@@ -2432,27 +2421,29 @@ struct FalseColorizeSubTreeOperationArgs { · 18 unmodified lines
24322421 long voxelsTouched;
24332422 };
24342423
2435−bool VoxelSystem::falseColorizeSubTreeOperation(VoxelNode* node, void* extraData) {
2436− if (node->getShouldRender()) {
2424+bool VoxelSystem::falseColorizeSubTreeOperation(OctreeElement* element, void* extraData) {
2425+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
2426+ if (voxel->getShouldRender()) {
24372427 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]);
24392429 args->voxelsTouched++;
24402430 }
24412431 return true;
24422432 }
24432433
2444−bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraData) {
2434+bool VoxelSystem::falseColorizeOccludedOperation(OctreeElement* element, void* extraData) {
2435+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
24452436
24462437 FalseColorizeOccludedArgs* args = (FalseColorizeOccludedArgs*) extraData;
24472438 args->totalVoxels++;
24482439
24492440 // If we are a parent, let's see if we're completely occluded.
2450− if (!node->isLeaf()) {
2441+ if (!voxel->isLeaf()) {
24512442 args->nonLeaves++;
24522443
2453− AABox voxelBox = node->getAABox();
2444+ AABox voxelBox = voxel->getAABox();
24542445 voxelBox.scale(TREE_SCALE);
2455− VoxelProjectedPolygon* voxelPolygon = new VoxelProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
2446+ OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
24562447
24572448 // If we're not all in view, then ignore it, and just return. But keep searching...
24582449 if (!voxelPolygon->getAllInView()) {
@@ -2472,7 +2463,7 @@ bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraDat · 13 unmodified lines
24722463 subArgs.color[2] = 0;
24732464 subArgs.voxelsTouched = 0;
24742465
2475− args->tree->recurseNodeWithOperation(node, falseColorizeSubTreeOperation, &subArgs );
2466+ args->tree->recurseNodeWithOperation(voxel, falseColorizeSubTreeOperation, &subArgs );
24762467
24772468 args->subtreeVoxelsSkipped += (subArgs.voxelsTouched - 1);
24782469 args->totalVoxels += (subArgs.voxelsTouched - 1);
@@ -2484,12 +2475,12 @@ bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraDat · 5 unmodified lines
24842475 return true; // keep looking...
24852476 }
24862477
2487− if (node->isLeaf() && node->isColored() && node->getShouldRender()) {
2478+ if (voxel->isLeaf() && voxel->isColored() && voxel->getShouldRender()) {
24882479 args->coloredVoxels++;
24892480
2490− AABox voxelBox = node->getAABox();
2481+ AABox voxelBox = voxel->getAABox();
24912482 voxelBox.scale(TREE_SCALE);
2492− VoxelProjectedPolygon* voxelPolygon = new VoxelProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
2483+ OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
24932484
24942485 // If we're not all in view, then ignore it, and just return. But keep searching...
24952486 if (!voxelPolygon->getAllInView()) {
@@ -2500,7 +2491,7 @@ bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraDat · 4 unmodified lines
25002491
25012492 CoverageMapStorageResult result = args->map->checkMap(voxelPolygon, true);
25022493 if (result == OCCLUDED) {
2503− node->setFalseColor(255, 0, 0);
2494+ voxel->setFalseColor(255, 0, 0);
25042495 args->occludedVoxels++;
25052496 } else if (result == STORED) {
25062497 args->notOccludedVoxels++;
@@ -2530,9 +2521,9 @@ void VoxelSystem::falseColorizeOccluded() { · 23 unmodified lines
25302521 args.nonLeavesOccluded = 0;
25312522 args.tree = _tree;
25322523
2533− VoxelProjectedPolygon::pointInside_calls = 0;
2534− VoxelProjectedPolygon::occludes_calls = 0;
2535− VoxelProjectedPolygon::intersects_calls = 0;
2524+ OctreeProjectedPolygon::pointInside_calls = 0;
2525+ OctreeProjectedPolygon::occludes_calls = 0;
2526+ OctreeProjectedPolygon::intersects_calls = 0;
25362527
25372528 glm::vec3 position = args.viewFrustum->getPosition() * (1.0f/TREE_SCALE);
25382529
@@ -2543,9 +2534,9 @@ void VoxelSystem::falseColorizeOccluded() { · 4 unmodified lines
25432534 args.totalVoxels, args.coloredVoxels, args.occludedVoxels,
25442535 args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped,
25452536 args.nonLeaves, args.nonLeavesOutOfView, args.nonLeavesOccluded,
2546− VoxelProjectedPolygon::pointInside_calls,
2547− VoxelProjectedPolygon::occludes_calls,
2548− VoxelProjectedPolygon::intersects_calls
2537+ OctreeProjectedPolygon::pointInside_calls,
2538+ OctreeProjectedPolygon::occludes_calls,
2539+ OctreeProjectedPolygon::intersects_calls
25492540 );
25502541
25512542
@@ -2555,18 +2546,19 @@ void VoxelSystem::falseColorizeOccluded() { · 3 unmodified lines
25552546 setupNewVoxelsForDrawing();
25562547 }
25572548
2558−bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraData) {
2549+bool VoxelSystem::falseColorizeOccludedV2Operation(OctreeElement* element, void* extraData) {
2550+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
25592551
25602552 FalseColorizeOccludedArgs* args = (FalseColorizeOccludedArgs*) extraData;
25612553 args->totalVoxels++;
25622554
25632555 // If we are a parent, let's see if we're completely occluded.
2564− if (!node->isLeaf()) {
2556+ if (!voxel->isLeaf()) {
25652557 args->nonLeaves++;
25662558
2567− AABox voxelBox = node->getAABox();
2559+ AABox voxelBox = voxel->getAABox();
25682560 voxelBox.scale(TREE_SCALE);
2569− VoxelProjectedPolygon* voxelPolygon = new VoxelProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
2561+ OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
25702562
25712563 // If we're not all in view, then ignore it, and just return. But keep searching...
25722564 if (!voxelPolygon->getAllInView()) {
@@ -2586,7 +2578,7 @@ bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraD · 13 unmodified lines
25862578 subArgs.color[2] = 0;
25872579 subArgs.voxelsTouched = 0;
25882580
2589− args->tree->recurseNodeWithOperation(node, falseColorizeSubTreeOperation, &subArgs );
2581+ args->tree->recurseNodeWithOperation(voxel, falseColorizeSubTreeOperation, &subArgs );
25902582
25912583 args->subtreeVoxelsSkipped += (subArgs.voxelsTouched - 1);
25922584 args->totalVoxels += (subArgs.voxelsTouched - 1);
@@ -2598,12 +2590,12 @@ bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraD · 5 unmodified lines
25982590 return true; // keep looking...
25992591 }
26002592
2601− if (node->isLeaf() && node->isColored() && node->getShouldRender()) {
2593+ if (voxel->isLeaf() && voxel->isColored() && voxel->getShouldRender()) {
26022594 args->coloredVoxels++;
26032595
2604− AABox voxelBox = node->getAABox();
2596+ AABox voxelBox = voxel->getAABox();
26052597 voxelBox.scale(TREE_SCALE);
2606− VoxelProjectedPolygon* voxelPolygon = new VoxelProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
2598+ OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
26072599
26082600 // If we're not all in view, then ignore it, and just return. But keep searching...
26092601 if (!voxelPolygon->getAllInView()) {
@@ -2614,7 +2606,7 @@ bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraD · 4 unmodified lines
26142606
26152607 CoverageMapV2StorageResult result = args->mapV2->checkMap(voxelPolygon, true);
26162608 if (result == V2_OCCLUDED) {
2617− node->setFalseColor(255, 0, 0);
2609+ voxel->setFalseColor(255, 0, 0);
26182610 args->occludedVoxels++;
26192611 } else if (result == V2_STORED) {
26202612 args->notOccludedVoxels++;
@@ -2634,9 +2626,9 @@ void VoxelSystem::falseColorizeOccludedV2() { · 13 unmodified lines
26342626
26352627 CoverageMapV2::wantDebugging = true;
26362628
2637− VoxelProjectedPolygon::pointInside_calls = 0;
2638− VoxelProjectedPolygon::occludes_calls = 0;
2639− VoxelProjectedPolygon::intersects_calls = 0;
2629+ OctreeProjectedPolygon::pointInside_calls = 0;
2630+ OctreeProjectedPolygon::occludes_calls = 0;
2631+ OctreeProjectedPolygon::intersects_calls = 0;
26402632
26412633 FalseColorizeOccludedArgs args;
26422634 args.viewFrustum = _viewFrustum;
@@ -2661,9 +2653,9 @@ void VoxelSystem::falseColorizeOccludedV2() { · 18 unmodified lines
26612653 args.totalVoxels, args.coloredVoxels, args.occludedVoxels,
26622654 args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped,
26632655 args.nonLeaves, args.nonLeavesOutOfView, args.nonLeavesOccluded,
2664− VoxelProjectedPolygon::pointInside_calls,
2665− VoxelProjectedPolygon::occludes_calls,
2666− VoxelProjectedPolygon::intersects_calls
2656+ OctreeProjectedPolygon::pointInside_calls,
2657+ OctreeProjectedPolygon::occludes_calls,
2658+ OctreeProjectedPolygon::intersects_calls
26672659 );
26682660 //myCoverageMapV2.erase();
26692661 _tree->setDirtyBit();
@@ -2677,13 +2669,14 @@ void VoxelSystem::nodeAdded(Node* node) { · 7 unmodified lines
26772669 }
26782670 }
26792671
2680−bool VoxelSystem::killSourceVoxelsOperation(VoxelNode* node, void* extraData) {
2672+bool VoxelSystem::killSourceVoxelsOperation(OctreeElement* element, void* extraData) {
2673+ VoxelTreeElement* voxel = (VoxelTreeElement*)element;
26812674 QUuid killedNodeID = *(QUuid*)extraData;
26822675 for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
2683− VoxelNode* childNode = node->getChildAtIndex(i);
2676+ VoxelTreeElement* childNode = voxel->getChildAtIndex(i);
26842677 if (childNode) {
26852678 if (childNode->matchesSourceUUID(killedNodeID)) {
2686− node->safeDeepDeleteChildAtIndex(i);
2679+ voxel->safeDeepDeleteChildAtIndex(i);
26872680 }
26882681 }
26892682 }