Showing the changes to interface/src/VoxelSystem.cpp (1 of 27 files). Show all
Unified · Split
| @@ -66,6 +66,8 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels) : · 65 unmodified lines | ||
| 66 | 66 | _dataSourceID = UNKNOWN_NODE_ID; |
| 67 | 67 | _voxelServerCount = 0; |
| 68 | 68 | |
| 69 | + _viewFrustum = Application::getInstance()->getViewFrustum(); | |
| 70 | + | |
| 69 | 71 | connect(_tree, SIGNAL(importSize(float,float,float)), SIGNAL(importSize(float,float,float))); |
| 70 | 72 | connect(_tree, SIGNAL(importProgress(int)), SIGNAL(importProgress(int))); |
| 71 | 73 | } |
| @@ -413,7 +415,7 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) { · 341 unmodified lines | ||
| 413 | 415 | int voxelsUpdated = 0; |
| 414 | 416 | bool shouldRender = false; // assume we don't need to render it |
| 415 | 417 | // if it's colored, we might need to render it! |
| 416 | − shouldRender = node->calculateShouldRender(Application::getInstance()->getViewFrustum()); | |
| 418 | + shouldRender = node->calculateShouldRender(_viewFrustum); | |
| 417 | 419 | |
| 418 | 420 | node->setShouldRender(shouldRender); |
| 419 | 421 | // let children figure out their renderness |
| @@ -655,7 +657,7 @@ void VoxelSystem::updatePartialVBOs() { · 235 unmodified lines | ||
| 655 | 657 | } |
| 656 | 658 | |
| 657 | 659 | // if we got to the end of the array, and we're in an active dirty segment... |
| 658 | − if (inSegment) { | |
| 660 | + if (inSegment) { | |
| 659 | 661 | updateVBOSegment(segmentStart, _voxelsInReadArrays - 1); |
| 660 | 662 | inSegment = false; |
| 661 | 663 | } |
| @@ -832,10 +834,8 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, void* extraData) · 170 unmodified lines | ||
| 832 | 834 | } |
| 833 | 835 | |
| 834 | 836 | void VoxelSystem::falseColorizeInView() { |
| 835 | − ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum(); | |
| 836 | − | |
| 837 | 837 | _nodeCount = 0; |
| 838 | − _tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)viewFrustum); | |
| 838 | + _tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)_viewFrustum); | |
| 839 | 839 | qDebug("setting in view false color for %d nodes\n", _nodeCount); |
| 840 | 840 | _tree->setDirtyBit(); |
| 841 | 841 | setupNewVoxelsForDrawing(); |
| @@ -961,15 +961,13 @@ bool VoxelSystem::getDistanceFromViewRangeOperation(VoxelNode* node, void* extra · 119 unmodified lines | ||
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | void VoxelSystem::falseColorizeDistanceFromView() { |
| 964 | − ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum(); | |
| 965 | − | |
| 966 | 964 | _nodeCount = 0; |
| 967 | 965 | _maxDistance = 0.0; |
| 968 | 966 | _minDistance = FLT_MAX; |
| 969 | − _tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation, (void*) viewFrustum); | |
| 967 | + _tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation, (void*) _viewFrustum); | |
| 970 | 968 | qDebug("determining distance range for %d nodes\n", _nodeCount); |
| 971 | 969 | _nodeCount = 0; |
| 972 | − _tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation, (void*) viewFrustum); | |
| 970 | + _tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation, (void*) _viewFrustum); | |
| 973 | 971 | qDebug("setting in distance false color for %d nodes\n", _nodeCount); |
| 974 | 972 | _tree->setDirtyBit(); |
| 975 | 973 | setupNewVoxelsForDrawing(); |
| @@ -979,6 +977,7 @@ void VoxelSystem::falseColorizeDistanceFromView() { · 3 unmodified lines | ||
| 979 | 977 | class removeOutOfViewArgs { |
| 980 | 978 | public: |
| 981 | 979 | VoxelSystem* thisVoxelSystem; |
| 980 | + ViewFrustum* thisViewFrustum; | |
| 982 | 981 | VoxelNodeBag dontRecurseBag; |
| 983 | 982 | unsigned long nodesScanned; |
| 984 | 983 | unsigned long nodesRemoved; |
| @@ -988,6 +987,7 @@ public: · 3 unmodified lines | ||
| 988 | 987 | |
| 989 | 988 | removeOutOfViewArgs(VoxelSystem* voxelSystem) : |
| 990 | 989 | thisVoxelSystem(voxelSystem), |
| 990 | + thisViewFrustum(voxelSystem->getViewFrustum()), | |
| 991 | 991 | dontRecurseBag(), |
| 992 | 992 | nodesScanned(0), |
| 993 | 993 | nodesRemoved(0), |
| @@ -1020,7 +1020,7 @@ bool VoxelSystem::removeOutOfViewOperation(VoxelNode* node, void* extraData) { · 26 unmodified lines | ||
| 1020 | 1020 | for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { |
| 1021 | 1021 | VoxelNode* childNode = node->getChildAtIndex(i); |
| 1022 | 1022 | if (childNode) { |
| 1023 | − ViewFrustum::location inFrustum = childNode->inFrustum(*Application::getInstance()->getViewFrustum()); | |
| 1023 | + ViewFrustum::location inFrustum = childNode->inFrustum(*args->thisViewFrustum); | |
| 1024 | 1024 | switch (inFrustum) { |
| 1025 | 1025 | case ViewFrustum::OUTSIDE: { |
| 1026 | 1026 | args->nodesOutside++; |
| @@ -1054,9 +1054,9 @@ bool VoxelSystem::isViewChanging() { · 27 unmodified lines | ||
| 1054 | 1054 | bool result = false; // assume the best |
| 1055 | 1055 | |
| 1056 | 1056 | // If our viewFrustum has changed since our _lastKnowViewFrustum |
| 1057 | − if (!_lastKnowViewFrustum.matches(Application::getInstance()->getViewFrustum())) { | |
| 1057 | + if (!_lastKnowViewFrustum.matches(_viewFrustum)) { | |
| 1058 | 1058 | result = true; |
| 1059 | − _lastKnowViewFrustum = *Application::getInstance()->getViewFrustum(); // save last known | |
| 1059 | + _lastKnowViewFrustum = *_viewFrustum; // save last known | |
| 1060 | 1060 | } |
| 1061 | 1061 | return result; |
| 1062 | 1062 | } |
| @@ -1070,9 +1070,9 @@ bool VoxelSystem::hasViewChanged() { · 7 unmodified lines | ||
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | // If our viewFrustum has changed since our _lastKnowViewFrustum |
| 1073 | − if (!_lastStableViewFrustum.matches(Application::getInstance()->getViewFrustum())) { | |
| 1073 | + if (!_lastStableViewFrustum.matches(_viewFrustum)) { | |
| 1074 | 1074 | result = true; |
| 1075 | − _lastStableViewFrustum = *Application::getInstance()->getViewFrustum(); // save last stable | |
| 1075 | + _lastStableViewFrustum = *_viewFrustum; // save last stable | |
| 1076 | 1076 | } |
| 1077 | 1077 | return result; |
| 1078 | 1078 | } |
| @@ -1312,6 +1312,10 @@ void VoxelSystem::createSphere(float r,float xc, float yc, float zc, float s, bo · 233 unmodified lines | ||
| 1312 | 1312 | setupNewVoxelsForDrawing(); |
| 1313 | 1313 | }; |
| 1314 | 1314 | |
| 1315 | +void VoxelSystem::copySubTreeIntoNewTree(VoxelNode* startNode, VoxelSystem* destinationTree, bool rebaseToRoot) { | |
| 1316 | + _tree->copySubTreeIntoNewTree(startNode, destinationTree->_tree, rebaseToRoot); | |
| 1317 | +} | |
| 1318 | + | |
| 1315 | 1319 | void VoxelSystem::copySubTreeIntoNewTree(VoxelNode* startNode, VoxelTree* destinationTree, bool rebaseToRoot) { |
| 1316 | 1320 | _tree->copySubTreeIntoNewTree(startNode, destinationTree, rebaseToRoot); |
| 1317 | 1321 | } |
| @@ -1320,6 +1324,10 @@ void VoxelSystem::copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelNode* dest · 2 unmodified lines | ||
| 1320 | 1324 | _tree->copyFromTreeIntoSubTree(sourceTree, destinationNode); |
| 1321 | 1325 | } |
| 1322 | 1326 | |
| 1327 | +void VoxelSystem::recurseTreeWithOperation(RecurseVoxelTreeOperation operation, void* extraData) { | |
| 1328 | + _tree->recurseTreeWithOperation(operation, extraData); | |
| 1329 | +} | |
| 1330 | + | |
| 1323 | 1331 | struct FalseColorizeOccludedArgs { |
| 1324 | 1332 | ViewFrustum* viewFrustum; |
| 1325 | 1333 | CoverageMap* map; |
| @@ -1426,7 +1434,7 @@ void VoxelSystem::falseColorizeOccluded() { · 100 unmodified lines | ||
| 1426 | 1434 | myCoverageMap.erase(); |
| 1427 | 1435 | |
| 1428 | 1436 | FalseColorizeOccludedArgs args; |
| 1429 | − args.viewFrustum = Application::getInstance()->getViewFrustum(); | |
| 1437 | + args.viewFrustum = _viewFrustum; | |
| 1430 | 1438 | args.map = &myCoverageMap; |
| 1431 | 1439 | args.totalVoxels = 0; |
| 1432 | 1440 | args.coloredVoxels = 0; |
| @@ -1548,7 +1556,7 @@ void VoxelSystem::falseColorizeOccludedV2() { · 115 unmodified lines | ||
| 1548 | 1556 | VoxelProjectedPolygon::intersects_calls = 0; |
| 1549 | 1557 | |
| 1550 | 1558 | FalseColorizeOccludedArgs args; |
| 1551 | − args.viewFrustum = Application::getInstance()->getViewFrustum(); | |
| 1559 | + args.viewFrustum = _viewFrustum; | |
| 1552 | 1560 | args.mapV2 = &myCoverageMapV2; |
| 1553 | 1561 | args.totalVoxels = 0; |
| 1554 | 1562 | args.coloredVoxels = 0; |