History

latest version of quadtree coverage map

ZappoMan committed 13 years ago

Commit 73ad8541 parent 850cfb910 files · +741 −41Browse files

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

Unified · Split

interface/src/VoxelSystem.cpp+145−7
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include "Log.h"
2424 #include "VoxelConstants.h"
2525 #include "CoverageMap.h"
26+#include "CoverageMapV2.h"
2627 #include "InterfaceConfig.h"
2728 #include "renderer/ProgramObject.h"
2829
@@ -1160,6 +1161,7 @@ void VoxelSystem::copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelNode* dest · 1131 unmodified lines
11601161 struct FalseColorizeOccludedArgs {
11611162 ViewFrustum* viewFrustum;
11621163 CoverageMap* map;
1164+ CoverageMapV2* mapV2;
11631165 VoxelTree* tree;
11641166 long totalVoxels;
11651167 long coloredVoxels;
@@ -1179,9 +1181,11 @@ struct FalseColorizeSubTreeOperationArgs { · 13 unmodified lines
11791181 };
11801182
11811183 bool VoxelSystem::falseColorizeSubTreeOperation(VoxelNode* node, void* extraData) {
1182− FalseColorizeSubTreeOperationArgs* args = (FalseColorizeSubTreeOperationArgs*) extraData;
1183− node->setFalseColor(args->color[0], args->color[1], args->color[2]);
1184− args->voxelsTouched++;
1184+ if (node->getShouldRender()) {
1185+ FalseColorizeSubTreeOperationArgs* args = (FalseColorizeSubTreeOperationArgs*) extraData;
1186+ node->setFalseColor(args->color[0], args->color[1], args->color[2]);
1187+ args->voxelsTouched++;
1188+ }
11851189 return true;
11861190 }
11871191
@@ -1261,12 +1265,14 @@ bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraDat · 73 unmodified lines
12611265 }
12621266 return true; // keep going!
12631267 }
1268+
12641269 void VoxelSystem::falseColorizeOccluded() {
12651270 PerformanceWarning warn(true, "falseColorizeOccluded()",true);
1266− CoverageMap map;
1271+ myCoverageMap.erase();
1272+
12671273 FalseColorizeOccludedArgs args;
12681274 args.viewFrustum = Application::getInstance()->getViewFrustum();
1269− args.map = ↦
1275+ args.map = &myCoverageMap;
12701276 args.totalVoxels = 0;
12711277 args.coloredVoxels = 0;
12721278 args.occludedVoxels = 0;
@@ -1278,19 +1284,151 @@ void VoxelSystem::falseColorizeOccluded() { · 5 unmodified lines
12781284 args.nonLeavesOutOfView = 0;
12791285 args.nonLeavesOccluded = 0;
12801286 args.tree = _tree;
1287+
1288+ VoxelProjectedPolygon::pointInside_calls = 0;
1289+ VoxelProjectedPolygon::occludes_calls = 0;
12811290
12821291 glm::vec3 position = args.viewFrustum->getPosition() * (1.0f/TREE_SCALE);
12831292
12841293 _tree->recurseTreeWithOperationDistanceSorted(falseColorizeOccludedOperation, position, (void*)&args);
12851294
1286− printLog("falseColorizeOccluded()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n",
1295+ printLog("falseColorizeOccluded()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n",
1296+ position.x, position.y,
1297+ args.totalVoxels, args.coloredVoxels, args.occludedVoxels,
1298+ args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped,
1299+ args.stagedForDeletion,
1300+ args.nonLeaves, args.nonLeavesOutOfView, args.nonLeavesOccluded,
1301+ VoxelProjectedPolygon::pointInside_calls,
1302+ VoxelProjectedPolygon::occludes_calls
1303+ );
1304+
1305+
1306+ myCoverageMap.erase();
1307+
1308+ setupNewVoxelsForDrawing();
1309+}
1310+
1311+bool VoxelSystem::falseColorizeOccludedV2Operation(VoxelNode* node, void* extraData) {
1312+
1313+ FalseColorizeOccludedArgs* args = (FalseColorizeOccludedArgs*) extraData;
1314+ args->totalVoxels++;
1315+
1316+ // if this node is staged for deletion, then just return
1317+ if (node->isStagedForDeletion()) {
1318+ args->stagedForDeletion++;
1319+ return true;
1320+ }
1321+
1322+ // If we are a parent, let's see if we're completely occluded.
1323+ if (!node->isLeaf()) {
1324+ args->nonLeaves++;
1325+
1326+ AABox voxelBox = node->getAABox();
1327+ voxelBox.scale(TREE_SCALE);
1328+ VoxelProjectedPolygon* voxelPolygon = new VoxelProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
1329+
1330+ // If we're not all in view, then ignore it, and just return. But keep searching...
1331+ if (!voxelPolygon->getAllInView()) {
1332+ args->nonLeavesOutOfView++;
1333+ delete voxelPolygon;
1334+ return true;
1335+ }
1336+
1337+ CoverageMapV2StorageResult result = args->mapV2->checkMap(voxelPolygon, false);
1338+ if (result == V2_OCCLUDED) {
1339+ args->nonLeavesOccluded++;
1340+ delete voxelPolygon;
1341+
1342+ FalseColorizeSubTreeOperationArgs subArgs;
1343+ subArgs.color[0] = 0;
1344+ subArgs.color[1] = 255;
1345+ subArgs.color[2] = 0;
1346+ subArgs.voxelsTouched = 0;
1347+
1348+ args->tree->recurseNodeWithOperation(node, falseColorizeSubTreeOperation, &subArgs );
1349+
1350+ args->subtreeVoxelsSkipped += (subArgs.voxelsTouched - 1);
1351+ args->totalVoxels += (subArgs.voxelsTouched - 1);
1352+
1353+ return false;
1354+ }
1355+
1356+ delete voxelPolygon;
1357+ return true; // keep looking...
1358+ }
1359+
1360+ if (node->isLeaf() && node->isColored() && node->getShouldRender()) {
1361+ args->coloredVoxels++;
1362+
1363+ AABox voxelBox = node->getAABox();
1364+ voxelBox.scale(TREE_SCALE);
1365+ VoxelProjectedPolygon* voxelPolygon = new VoxelProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
1366+
1367+ // If we're not all in view, then ignore it, and just return. But keep searching...
1368+ if (!voxelPolygon->getAllInView()) {
1369+ args->outOfView++;
1370+ delete voxelPolygon;
1371+ return true;
1372+ }
1373+
1374+ CoverageMapV2StorageResult result = args->mapV2->checkMap(voxelPolygon, true);
1375+ if (result == V2_OCCLUDED) {
1376+ node->setFalseColor(255, 0, 0);
1377+ args->occludedVoxels++;
1378+ } else if (result == V2_STORED) {
1379+ args->notOccludedVoxels++;
1380+ //printLog("***** falseColorizeOccludedOperation() NODE is STORED *****\n");
1381+ } else if (result == V2_DOESNT_FIT) {
1382+ //printLog("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n");
1383+ }
1384+ delete voxelPolygon; // V2 maps don't store polygons, so we're always in charge of freeing
1385+ }
1386+ return true; // keep going!
1387+}
1388+
1389+
1390+void VoxelSystem::falseColorizeOccludedV2() {
1391+ PerformanceWarning warn(true, "falseColorizeOccludedV2()",true);
1392+ myCoverageMapV2.erase();
1393+
1394+ CoverageMapV2::wantDebugging = true;
1395+
1396+ VoxelProjectedPolygon::pointInside_calls = 0;
1397+ VoxelProjectedPolygon::occludes_calls = 0;
1398+
1399+
1400+ FalseColorizeOccludedArgs args;
1401+ args.viewFrustum = Application::getInstance()->getViewFrustum();
1402+ args.mapV2 = &myCoverageMapV2;
1403+ args.totalVoxels = 0;
1404+ args.coloredVoxels = 0;
1405+ args.occludedVoxels = 0;
1406+ args.notOccludedVoxels = 0;
1407+ args.outOfView = 0;
1408+ args.subtreeVoxelsSkipped = 0;
1409+ args.nonLeaves = 0;
1410+ args.stagedForDeletion = 0;
1411+ args.nonLeavesOutOfView = 0;
1412+ args.nonLeavesOccluded = 0;
1413+ args.tree = _tree;
1414+
1415+ glm::vec3 position = args.viewFrustum->getPosition() * (1.0f/TREE_SCALE);
1416+
1417+ _tree->recurseTreeWithOperationDistanceSorted(falseColorizeOccludedV2Operation, position, (void*)&args);
1418+
1419+ printLog("falseColorizeOccludedV2()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n stagedForDeletion=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n",
12871420 position.x, position.y,
12881421 args.totalVoxels, args.coloredVoxels, args.occludedVoxels,
12891422 args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped,
12901423 args.stagedForDeletion,
1291− args.nonLeaves, args.nonLeavesOutOfView, args.nonLeavesOccluded);
1424+ args.nonLeaves, args.nonLeavesOutOfView, args.nonLeavesOccluded,
1425+ VoxelProjectedPolygon::pointInside_calls,
1426+ VoxelProjectedPolygon::occludes_calls
1427+ );
1428+ myCoverageMapV2.erase();
12921429
12931430
12941431 setupNewVoxelsForDrawing();
12951432 }
12961433
1434+

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t