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