Changeset 469 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 12/16/05 18:52:33 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/Preprocessor.vcproj
r468 r469 410 410 </File> 411 411 </Filter> 412 <File 413 RelativePath=".\VTune\Preprocessor.vpj"> 414 </File> 412 415 </Files> 413 416 <Globals> -
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r465 r469 265 265 # x3d visualization of the split planes 266 266 exportSplits true 267 exportRays true 268 exportGeometry false 267 269 } 268 270 } … … 303 305 minViewCells 100 304 306 maxPvsSize 50000 307 } 308 309 310 Visualization { 311 exportRays true 312 exportGeometry false 305 313 } 306 314 } … … 366 374 # x3d visualization of the split planes 367 375 exportSplits true 368 } 369 } 376 exportRays true 377 exportGeometry false 378 } 379 } -
trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp
r463 r469 679 679 Vector3 ext = mMax - mMin; 680 680 681 return 2.0 * (ext.x * ext.y +681 return 2.0f * (ext.x * ext.y + 682 682 ext.x * ext.z + 683 683 ext.y * ext.z); … … 1056 1056 if (y < 0.0) { 1057 1057 if (y < -1.0) 1058 return c * (-2.0 + x / y); // for angle in <-PI/2, -PI/4)1058 return c * (-2.0f + x / y); // for angle in <-PI/2, -PI/4) 1059 1059 else 1060 1060 return c * (y / x); // for angle in <-PI/4 , 0> … … 1062 1062 else { 1063 1063 if (y > 1.0) 1064 return c * (2.0 - x / y); // for angle in <PI/4, PI/2>1064 return c * (2.0f - x / y); // for angle in <PI/4, PI/2> 1065 1065 else 1066 1066 return c * (y / x); // for angle in <0, PI/2> … … 1107 1107 // FATAL_ABORT; 1108 1108 //} 1109 SA +=atan22(d*b/sqrt(b*b + d*d + 1.0 )) - atan22(b*c/sqrt(b*b + c*c + 1.0))1110 - atan22(d*a/sqrt(a*a + d*d + 1.0 )) + atan22(a*c/sqrt(a*a + c*c + 1.0));1109 SA +=atan22(d*b/sqrt(b*b + d*d + 1.0f)) - atan22(b*c/sqrt(b*b + c*c + 1.0f)) 1110 - atan22(d*a/sqrt(a*a + d*d + 1.0f)) + atan22(a*c/sqrt(a*a + c*c + 1.0f)); 1111 1111 } 1112 1112 -
trunk/VUT/GtpVisibilityPreprocessor/src/Camera.h
r386 r469 24 24 mWidth = 640; 25 25 mHeight = 480; 26 mFovy = 60.0 *M_PI/180.0;26 mFovy = 60.0f*(float)M_PI/180.0f; 27 27 } 28 28 -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r465 r469 1150 1150 "10"); 1151 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1152 RegisterOption("VssPreprocessor.initialSamples", 1153 optInt, 1154 "-initial_samples=", 1155 "100000"); 1156 1157 RegisterOption("VssPreprocessor.vssSamples", 1158 optInt, 1159 "-vss_samples=", 1160 "1000000"); 1161 1161 1162 1162 RegisterOption("VssPreprocessor.vssSamplesPerPass", 1163 optInt, 1164 "-vss_samples_per_pass=", 1165 "1000"); 1166 1167 RegisterOption("VssPreprocessor.samplesPerPass", 1168 optInt, 1169 "-samples_per_pass=", 1170 "100000"); 1163 optInt, 1164 "-vss_samples_per_pass=", 1165 "1000"); 1166 1167 RegisterOption("VssPreprocessor.samplesPerPass", 1168 optInt, 1169 "-samples_per_pass=", 1170 "100000"); 1171 1171 1172 1172 1173 RegisterOption("VssPreprocessor.useImportanceSampling", 1173 1174 1175 1174 optBool, 1175 "-vss_use_importance=", 1176 "true"); 1176 1177 1177 1178 … … 1366 1367 RegisterOption("BspTree.Visualization.exportSplits", 1367 1368 optBool, 1368 "-bsp_visualization.export Splits",1369 "-bsp_visualization.export_splits", 1369 1370 "false"); 1370 1371 1371 RegisterOption("BspTree.Factor.verticalSplits", optFloat, "-bsp_factor_vertical=", "1.0"); 1372 RegisterOption("BspTree.Factor.largestPolyArea", optFloat, "-bsp_factor_largest_poly=", "1.0"); 1373 RegisterOption("BspTree.Factor.blockedRays", optFloat, "-bsp_factor_blocked=", "1.0"); 1374 RegisterOption("BspTree.Factor.leastSplits", optFloat, "-bsp_factor_least_splits=", "1.0"); 1375 RegisterOption("BspTree.Factor.balancedPolys", optFloat, "-bsp_factor_balanced_polys=", "1.0"); 1376 RegisterOption("BspTree.Factor.balancedViewCells", optFloat, "-bsp_factor_balanced_view_cells=", "1.0"); 1377 RegisterOption("BspTree.Factor.leastRaySplits", optFloat, "-bsp_factor_least_ray_splits=", "1.0"); 1378 RegisterOption("BspTree.Factor.balancedRays", optFloat, "-bsp_factor_balanced_rays=", "1.0"); 1379 RegisterOption("BspTree.Factor.pvs", optFloat, "-bsp_factor_pvs=", "1.0"); 1380 1381 /************************************************************************************/ 1382 /* Preprocessor related options */ 1383 /************************************************************************************/ 1384 1385 RegisterOption("Preprocessor.type", 1372 RegisterOption("BspTree.Visualization.exportRays", 1373 optBool, 1374 "-bsp_visualization.export_rays", 1375 "false"); 1376 1377 RegisterOption("BspTree.Visualization.exportGeometry", 1378 optBool, 1379 "-bsp_visualization.export_geometry", 1380 "false"); 1381 1382 RegisterOption("BspTree.Factor.verticalSplits", optFloat, "-bsp_factor_vertical=", "1.0"); 1383 RegisterOption("BspTree.Factor.largestPolyArea", optFloat, "-bsp_factor_largest_poly=", "1.0"); 1384 RegisterOption("BspTree.Factor.blockedRays", optFloat, "-bsp_factor_blocked=", "1.0"); 1385 RegisterOption("BspTree.Factor.leastSplits", optFloat, "-bsp_factor_least_splits=", "1.0"); 1386 RegisterOption("BspTree.Factor.balancedPolys", optFloat, "-bsp_factor_balanced_polys=", "1.0"); 1387 RegisterOption("BspTree.Factor.balancedViewCells", optFloat, "-bsp_factor_balanced_view_cells=", "1.0"); 1388 RegisterOption("BspTree.Factor.leastRaySplits", optFloat, "-bsp_factor_least_ray_splits=", "1.0"); 1389 RegisterOption("BspTree.Factor.balancedRays", optFloat, "-bsp_factor_balanced_rays=", "1.0"); 1390 RegisterOption("BspTree.Factor.pvs", optFloat, "-bsp_factor_pvs=", "1.0"); 1391 1392 /************************************************************************************/ 1393 /* Preprocessor related options */ 1394 /************************************************************************************/ 1395 1396 RegisterOption("Preprocessor.type", 1386 1397 optString, 1387 1398 "-preprocessor=", … … 1389 1400 1390 1401 1391 /**************************************************************************************/ 1392 /* View space partition KD tree related options */ 1393 /**************************************************************************************/ 1394 1395 RegisterOption("VspKdTree.Construction.samples", 1396 optInt, 1397 "-vsp_kd_construction_samples=", 1398 "100000"); 1399 1400 RegisterOption("VspKdTree.Termination.maxDepth", 1402 /**************************************************************************************/ 1403 /* View space partition KD tree related options */ 1404 /**************************************************************************************/ 1405 1406 RegisterOption("VspKdTree.Construction.samples", 1407 optInt, 1408 "-vsp_kd_construction_samples=", 1409 "100000"); 1410 1411 RegisterOption("VspKdTree.Termination.maxDepth", 1412 optInt, 1413 "vsp_term_maxdepth=", "30"); 1414 1415 RegisterOption("VspKdTree.Termination.minPvs", 1416 optInt, 1417 "vsp_minpvs=", 1418 "1"); 1419 1420 RegisterOption("VspKdTree.Termination.minRays", 1421 optInt, 1422 "vsp_term_minrays=", 1423 "10"); 1424 1425 RegisterOption("VspKdTree.Termination.minSize", 1426 optFloat, 1427 "vsp_term_minsize=", 1428 "0.001"); 1429 1430 RegisterOption("VspKdTree.Termination.maxCostRatio", 1431 optFloat, 1432 "vsp_term_maxcost=", 1433 "0.95"); 1434 1435 RegisterOption("VspKdTree.Termination.maxRayContribution", 1436 optFloat, 1437 "vsp_term_max_ray_contrib=", 1438 "0.5"); 1439 1440 RegisterOption("VspKdTree.epsilon", 1441 optFloat, 1442 "kd_eps=", 1443 "1e-6"); 1444 1445 RegisterOption("VspKdTree.ct_div_ci", 1446 optFloat, 1447 "vsp_ctdivci=", "1.0"); 1448 1449 RegisterOption("VspKdTree.splitType", 1450 optString, 1451 "split=", 1452 "queries"); 1453 1454 RegisterOption("VspKdTree.numberOfEndPointDomains", 1401 1455 optInt, 1402 "vsp_term_maxdepth=", "30"); 1403 1404 RegisterOption("VspKdTree.Termination.minPvs", 1405 optInt, 1406 "vsp_minpvs=", 1407 "1"); 1408 1409 RegisterOption("VspKdTree.Termination.minRays", 1410 optInt, 1411 "vsp_term_minrays=", 1412 "10"); 1413 1414 RegisterOption("VspKdTree.Termination.minSize", 1415 optFloat, 1416 "vsp_term_minsize=", 1417 "0.001"); 1418 1419 RegisterOption("VspKdTree.Termination.maxCostRatio", 1420 optFloat, 1421 "vsp_term_maxcost=", 1422 "0.95"); 1423 1424 RegisterOption("VspKdTree.Termination.maxRayContribution", 1425 optFloat, 1426 "vsp_term_max_ray_contrib=", 1427 "0.5"); 1428 1429 RegisterOption("VspKdTree.epsilon", 1430 optFloat, 1431 "kd_eps=", 1432 "1e-6"); 1433 1434 RegisterOption("VspKdTree.ct_div_ci", 1435 optFloat, 1436 "vsp_ctdivci=", "1.0"); 1437 1438 RegisterOption("VspKdTree.splitType", 1439 optString, 1440 "split=", 1441 "queries"); 1442 1443 RegisterOption("VspKdTree.numberOfEndPointDomains", 1444 optInt, 1445 "endpoints=", 1446 "10000"); 1447 1448 RegisterOption("VspKdTree.maxTotalMemory", 1449 optFloat, 1450 "vsp_max_total_mem=", 1451 "60.0"); 1452 1453 RegisterOption("VspKdTree.maxStaticMemory", 1454 optFloat, 1455 "vsp_max_static_mem=", 1456 "8.0"); 1457 1458 RegisterOption("VspKdTree.queryType", 1459 optString, 1460 "qtype=", 1461 "static"); 1462 1463 RegisterOption("VspKdTree.queryPosWeight", 1456 "endpoints=", 1457 "10000"); 1458 1459 RegisterOption("VspKdTree.maxTotalMemory", 1464 1460 optFloat, 1465 "qposweight=", 1461 "vsp_max_total_mem=", 1462 "60.0"); 1463 1464 RegisterOption("VspKdTree.maxStaticMemory", 1465 optFloat, 1466 "vsp_max_static_mem=", 1467 "8.0"); 1468 1469 RegisterOption("VspKdTree.queryType", 1470 optString, 1471 "qtype=", 1472 "static"); 1473 1474 RegisterOption("VspKdTree.queryPosWeight", 1475 optFloat, 1476 "vsp_kd_qposweight=", 1466 1477 "0.0"); 1467 1468 RegisterOption("VspKdTree.accessTimeThreshold", 1469 optInt, 1470 "accesstime=", 1471 "1000"); 1472 1473 RegisterOption("VspKdTree.minCollapseDepth", 1474 optInt, 1475 "vsp_min_colldepth=", 1476 "4"); 1477 1478 RegisterOption("VspKdTree.PostProcess.maxCostRatio", 1479 optFloat, 1480 "-vsp_kd_post_process_max_cost_ratio=", 1481 "1.5"); 1482 1483 RegisterOption("VspKdTree.PostProcess.minViewCells", 1484 optInt, 1485 "vsp_term_post_process_min_view_cells=", 1486 "1000"); 1487 1488 RegisterOption("VspKdTree.PostProcess.maxPvsSize", 1489 optInt, 1490 "vsp_term_post_process_max_pvs_size=", 1491 "100"); 1492 1493 /************************************************************************************/ 1494 /* VSS Preprocessor cells related options */ 1495 /************************************************************************************/ 1496 1497 RegisterOption("VssTree.maxDepth", optInt, "kd_depth=", "12"); 1498 RegisterOption("VssTree.minPvs", optInt, "kd_minpvs=", "1"); 1499 RegisterOption("VssTree.minRays", optInt, "kd_minrays=", "10"); 1500 RegisterOption("VssTree.maxCostRatio", optFloat, "maxcost=", "0.95"); 1501 RegisterOption("VssTree.maxRayContribution", optFloat, "maxraycontrib=", "0.5"); 1502 1503 RegisterOption("VssTree.epsilon", optFloat, "kd_eps=", "1e-6"); 1504 RegisterOption("VssTree.ct_div_ci", optFloat, "kd_ctdivci=", "1.0"); 1505 RegisterOption("VssTree.randomize", optBool, "randomize", "false"); 1506 RegisterOption("VssTree.splitType", optString, "split=", "queries"); 1507 RegisterOption("VssTree.splitUseOnlyDrivingAxis", optBool, "splitdriving=", "false"); 1508 RegisterOption("VssTree.useRss", optBool, "rss=", "false"); 1509 RegisterOption("VssTree.numberOfEndPointDomains", optInt, "endpoints=", "10000"); 1510 1511 RegisterOption("VssTree.minSize", optFloat, "minsize=", "0.001"); 1512 1513 RegisterOption("VssTree.maxTotalMemory", optFloat, "mem=", "60.0"); 1514 RegisterOption("VssTree.maxStaticMemory", optFloat, "statmem=", "8.0"); 1515 1516 RegisterOption("VssTree.queryType", optString, "qtype=", "static"); 1517 1518 RegisterOption("VssTree.queryPosWeight", optFloat, "qposweight=", "0.0"); 1519 RegisterOption("VssTree.useRefDirSplits", optBool, "refdir", "false"); 1520 RegisterOption("VssTree.refDirAngle", optFloat, "refangle=", "10"); 1521 RegisterOption("VssTree.refDirBoxMaxSize", optFloat, "refboxsize=", "0.1"); 1522 RegisterOption("VssTree.accessTimeThreshold", optInt, "accesstime=", "1000"); 1523 RegisterOption("VssTree.minCollapseDepth", optInt, "colldepth=", "4"); 1524 1525 RegisterOption("VssTree.interleaveDirSplits", optBool, "interleavedirsplits", "true"); 1526 RegisterOption("VssTree.dirSplitDepth", optInt, "dirsplidepth=", "10"); 1527 1528 1529 RegisterOption("RssPreprocessor.initialSamples", 1530 optInt, 1531 "-initial_samples=", 1532 "100000"); 1478 1479 RegisterOption("VspKdTree.accessTimeThreshold", 1480 optInt, 1481 "vsp_kd_accesstime=", 1482 "1000"); 1483 1484 RegisterOption("VspKdTree.minCollapseDepth", 1485 optInt, 1486 "vsp_kd_min_colldepth=", 1487 "4"); 1488 1489 RegisterOption("VspKdTree.PostProcess.maxCostRatio", 1490 optFloat, 1491 "-vsp_kd_post_process_max_cost_ratio=", 1492 "1.5"); 1493 1494 RegisterOption("VspKdTree.PostProcess.minViewCells", 1495 optInt, 1496 "vsp_kd_term_post_process_min_view_cells=", 1497 "1000"); 1498 1499 RegisterOption("VspKdTree.PostProcess.maxPvsSize", 1500 optInt, 1501 "vsp_kd_term_post_process_max_pvs_size=", 1502 "100"); 1503 1504 RegisterOption("VspKdTree.Visualization.exportRays", 1505 optBool, 1506 "-vsp_kd_visualization.export_rays", 1507 "false"); 1508 1509 RegisterOption("VspKdTree.Visualization.exportGeometry", 1510 optBool, 1511 "-vsp_kd_visualization.export_geometry", 1512 "false"); 1513 1514 1515 /************************************************************************************/ 1516 /* VSS Preprocessor cells related options */ 1517 /************************************************************************************/ 1518 1519 RegisterOption("VssTree.maxDepth", optInt, "kd_depth=", "12"); 1520 RegisterOption("VssTree.minPvs", optInt, "kd_minpvs=", "1"); 1521 RegisterOption("VssTree.minRays", optInt, "kd_minrays=", "10"); 1522 RegisterOption("VssTree.maxCostRatio", optFloat, "maxcost=", "0.95"); 1523 RegisterOption("VssTree.maxRayContribution", optFloat, "maxraycontrib=", "0.5"); 1524 1525 RegisterOption("VssTree.epsilon", optFloat, "kd_eps=", "1e-6"); 1526 RegisterOption("VssTree.ct_div_ci", optFloat, "kd_ctdivci=", "1.0"); 1527 RegisterOption("VssTree.randomize", optBool, "randomize", "false"); 1528 RegisterOption("VssTree.splitType", optString, "split=", "queries"); 1529 RegisterOption("VssTree.splitUseOnlyDrivingAxis", optBool, "splitdriving=", "false"); 1530 RegisterOption("VssTree.useRss", optBool, "rss=", "false"); 1531 RegisterOption("VssTree.numberOfEndPointDomains", optInt, "endpoints=", "10000"); 1532 1533 RegisterOption("VssTree.minSize", optFloat, "minsize=", "0.001"); 1534 1535 RegisterOption("VssTree.maxTotalMemory", optFloat, "mem=", "60.0"); 1536 RegisterOption("VssTree.maxStaticMemory", optFloat, "statmem=", "8.0"); 1537 1538 RegisterOption("VssTree.queryType", optString, "qtype=", "static"); 1539 1540 RegisterOption("VssTree.queryPosWeight", optFloat, "qposweight=", "0.0"); 1541 RegisterOption("VssTree.useRefDirSplits", optBool, "refdir", "false"); 1542 RegisterOption("VssTree.refDirAngle", optFloat, "refangle=", "10"); 1543 RegisterOption("VssTree.refDirBoxMaxSize", optFloat, "refboxsize=", "0.1"); 1544 RegisterOption("VssTree.accessTimeThreshold", optInt, "accesstime=", "1000"); 1545 RegisterOption("VssTree.minCollapseDepth", optInt, "colldepth=", "4"); 1546 1547 RegisterOption("VssTree.interleaveDirSplits", optBool, "interleavedirsplits", "true"); 1548 RegisterOption("VssTree.dirSplitDepth", optInt, "dirsplidepth=", "10"); 1549 1550 1551 RegisterOption("RssPreprocessor.initialSamples", 1552 optInt, 1553 "-initial_samples=", 1554 "100000"); 1533 1555 1534 1556 RegisterOption("RssPreprocessor.vssSamples", 1535 optInt, 1536 "-vss_samples=", 1537 "1000000"); 1538 1539 RegisterOption("RssPreprocessor.vssSamplesPerPass", 1540 optInt, 1541 "-vss_samples_per_pass=", 1542 "1000"); 1543 1544 RegisterOption("RssPreprocessor.samplesPerPass", 1545 optInt, 1546 "-samples_per_pass=", 1547 "100000"); 1548 1549 RegisterOption("RssPreprocessor.useImportanceSampling", 1550 optBool, 1551 "-vss_use_importance=", 1552 "true"); 1553 1554 RegisterOption("RssTree.maxDepth", optInt, "kd_depth=", "12"); 1555 RegisterOption("RssTree.minPvs", optInt, "kd_minpvs=", "1"); 1556 RegisterOption("RssTree.minRays", optInt, "kd_minrays=", "10"); 1557 RegisterOption("RssTree.maxCostRatio", optFloat, "maxcost=", "0.95"); 1558 RegisterOption("RssTree.maxRayContribution", optFloat, "maxraycontrib=", "0.5"); 1559 1560 RegisterOption("RssTree.epsilon", optFloat, "kd_eps=", "1e-6"); 1561 RegisterOption("RssTree.ct_div_ci", optFloat, "kd_ctdivci=", "1.0"); 1562 RegisterOption("RssTree.randomize", optBool, "randomize", "false"); 1563 RegisterOption("RssTree.splitType", optString, "split=", "queries"); 1564 RegisterOption("RssTree.splitUseOnlyDrivingAxis", optBool, "splitdriving=", "false"); 1565 1566 RegisterOption("RssTree.numberOfEndPointDomains", optInt, "endpoints=", "10000"); 1567 1568 RegisterOption("RssTree.minSize", optFloat, "minsize=", "0.001"); 1569 1570 RegisterOption("RssTree.maxTotalMemory", optFloat, "mem=", "60.0"); 1571 RegisterOption("RssTree.maxStaticMemory", optFloat, "statmem=", "8.0"); 1572 1573 RegisterOption("RssTree.queryType", optString, "qtype=", "static"); 1574 1575 RegisterOption("RssTree.queryPosWeight", optFloat, "qposweight=", "0.0"); 1576 RegisterOption("RssTree.useRefDirSplits", optBool, "refdir", "false"); 1577 RegisterOption("RssTree.refDirAngle", optFloat, "refangle=", "10"); 1578 RegisterOption("RssTree.refDirBoxMaxSize", optFloat, "refboxsize=", "0.1"); 1579 RegisterOption("RssTree.accessTimeThreshold", optInt, "accesstime=", "1000"); 1580 RegisterOption("RssTree.minCollapseDepth", optInt, "colldepth=", "4"); 1581 1582 RegisterOption("RssTree.interleaveDirSplits", optBool, "interleavedirsplits", "true"); 1583 RegisterOption("RssTree.dirSplitDepth", optInt, "dirsplidepth=", "10"); 1584 1585 RegisterOption("RssPreprocessor.Export.pvs", optBool, "rss_export_pvs", "false"); 1586 RegisterOption("RssPreprocessor.Export.rssTree", optBool, "rss_export_rss_tree", "false"); 1587 RegisterOption("RssPreprocessor.Export.rays", optBool, "rss_export_rays", "false"); 1588 RegisterOption("RssPreprocessor.Export.numRays", optInt, "rss_export_num_rays=", "5000"); 1589 RegisterOption("RssPreprocessor.useViewcells", optBool, "rss_use_viewcells", "false"); 1590 RegisterOption("RssPreprocessor.updateSubdivision", optBool, "rss_update_subdivision", "false"); 1591 1592 1593 /************************************************************************************/ 1594 /* View space partition BSP tree related options */ 1595 /************************************************************************************/ 1596 1597 1598 RegisterOption("VspBspTree.Termination.minPolygons", 1599 optInt, 1600 "-vsp_bsp_term_min_polygons=", 1601 "5"); 1602 1603 RegisterOption("VspBspTree.Termination.minPvs", 1604 optInt, 1605 "-vsp_bsp_term_min_pvs=", 1606 "20"); 1607 1608 RegisterOption("VspBspTree.Termination.minArea", 1609 optFloat, 1610 "-vsp_bsp_term_min_area=", 1611 "0.001"); 1612 1613 RegisterOption("VspBspTree.Termination.maxRayContribution", 1614 optFloat, 1615 "-vsp_bsp_term_ray_contribution=", 1616 "0.005"); 1617 1618 RegisterOption("VspBspTree.Termination.minAccRayLenght", 1619 optFloat, 1620 "-vsp_bsp_term_min_acc_ray_length=", 1621 "50"); 1622 1623 RegisterOption("VspBspTree.Termination.minRays", 1624 optInt, 1625 "-vsp_bsp_term_min_rays=", 1626 "-1"); 1627 1628 RegisterOption("VspBspTree.Termination.ct_div_ci", 1629 optFloat, 1630 "-vsp_bsp_term_ct_div_ci=", 1631 "0.0"); 1632 1633 RegisterOption("VspBspTree.Termination.maxDepth", 1634 optInt, 1635 "-vsp_bsp_term_max_depth=", 1636 "100"); 1637 1638 RegisterOption("VspBspTree.Termination.AxisAligned.maxCostRatio", 1639 optFloat, 1640 "-vsp_bsp_term_axis_aligned_max_cost_ratio=", 1641 "1.5"); 1642 1643 1644 RegisterOption("VspBspTree.Termination.AxisAligned.ct_div_ci", 1645 optFloat, 1646 "-vsp_bsp_term_axis_aligned_ct_div_ci=", 1647 "0.5"); 1648 1649 RegisterOption("VspBspTree.AxisAligned.splitBorder", 1650 optFloat, 1651 "-vsp_bsp__axis_aligned_split_border=", 1652 "0.1"); 1653 1654 RegisterOption("VspBspTree.Termination.AxisAligned.minPolys", 1655 optInt, 1656 "-vsp_bsp_term_axis_aligned_max_polygons=", 1657 "50"); 1658 1659 RegisterOption("VspBspTree.Termination.AxisAligned.minObjects", 1660 optInt, 1661 "-vsp_bsp_term_min_objects=", 1662 "3"); 1663 1664 RegisterOption("VspBspTree.Termination.AxisAligned.minRays", 1665 optInt, 1666 "-vsp_bsp_term_axis_aligned_min_rays=", 1667 "-1"); 1668 1669 RegisterOption("VspBspTree.splitPlaneStrategy", 1670 optString, 1671 "-vsp_bsp_split_method=", 1672 "leastSplits"); 1673 1674 RegisterOption("VspBspTree.maxPolyCandidates", 1675 optInt, 1676 "-vsp_bsp_max_poly_candidates=", 1677 "20"); 1678 1679 RegisterOption("VspBspTree.maxRayCandidates", 1680 optInt, 1681 "-vsp_bsp_max_plane_candidates=", 1682 "20"); 1683 1684 RegisterOption("VspBspTree.maxTests", 1685 optInt, 1686 "-vsp_bsp_max_tests=", 1687 "5000"); 1688 1689 RegisterOption("VspBspTree.Visualization.exportSplits", 1690 optBool, 1691 "-vsp_bsp_visualization.exportSplits", 1692 "false"); 1693 1694 RegisterOption("VspBspTree.Construction.samples", 1695 optInt, 1696 "-bsp_construction_samples=", 1697 "100000"); 1698 1699 RegisterOption("VspBspTree.Construction.epsilon", 1700 optFloat, 1701 "-vsp_bsp_construction_side_tolerance=", 1702 "0.002"); 1703 1704 RegisterOption("VspBspTree.Factor.leastRaySplits", optFloat, "-vsp_bsp_factor_least_ray_splits=", "1.0"); 1705 RegisterOption("VspBspTree.Factor.balancedRays", optFloat, "-vsp_bsp_factor_balanced_rays=", "1.0"); 1706 RegisterOption("VspBspTree.Factor.pvs", optFloat, "-vsp_bsp_factor_pvs=", "1.0"); 1707 1708 ////////////////////////////////////////////////////////////////////////////////// 1557 optInt, 1558 "-vss_samples=", 1559 "1000000"); 1560 1561 RegisterOption("RssPreprocessor.vssSamplesPerPass", 1562 optInt, 1563 "-vss_samples_per_pass=", 1564 "1000"); 1565 1566 RegisterOption("RssPreprocessor.samplesPerPass", 1567 optInt, 1568 "-samples_per_pass=", 1569 "100000"); 1570 1571 RegisterOption("RssPreprocessor.useImportanceSampling", 1572 optBool, 1573 "-vss_use_importance=", 1574 "true"); 1575 1576 RegisterOption("RssTree.maxDepth", optInt, "kd_depth=", "12"); 1577 RegisterOption("RssTree.minPvs", optInt, "kd_minpvs=", "1"); 1578 RegisterOption("RssTree.minRays", optInt, "kd_minrays=", "10"); 1579 RegisterOption("RssTree.maxCostRatio", optFloat, "maxcost=", "0.95"); 1580 RegisterOption("RssTree.maxRayContribution", optFloat, "maxraycontrib=", "0.5"); 1581 1582 RegisterOption("RssTree.epsilon", optFloat, "kd_eps=", "1e-6"); 1583 RegisterOption("RssTree.ct_div_ci", optFloat, "kd_ctdivci=", "1.0"); 1584 RegisterOption("RssTree.randomize", optBool, "randomize", "false"); 1585 RegisterOption("RssTree.splitType", optString, "split=", "queries"); 1586 RegisterOption("RssTree.splitUseOnlyDrivingAxis", optBool, "splitdriving=", "false"); 1587 1588 RegisterOption("RssTree.numberOfEndPointDomains", optInt, "endpoints=", "10000"); 1589 1590 RegisterOption("RssTree.minSize", optFloat, "minsize=", "0.001"); 1591 1592 RegisterOption("RssTree.maxTotalMemory", optFloat, "mem=", "60.0"); 1593 RegisterOption("RssTree.maxStaticMemory", optFloat, "statmem=", "8.0"); 1594 1595 RegisterOption("RssTree.queryType", optString, "qtype=", "static"); 1596 1597 RegisterOption("RssTree.queryPosWeight", optFloat, "qposweight=", "0.0"); 1598 RegisterOption("RssTree.useRefDirSplits", optBool, "refdir", "false"); 1599 RegisterOption("RssTree.refDirAngle", optFloat, "refangle=", "10"); 1600 RegisterOption("RssTree.refDirBoxMaxSize", optFloat, "refboxsize=", "0.1"); 1601 RegisterOption("RssTree.accessTimeThreshold", optInt, "accesstime=", "1000"); 1602 RegisterOption("RssTree.minCollapseDepth", optInt, "colldepth=", "4"); 1603 1604 RegisterOption("RssTree.interleaveDirSplits", optBool, "interleavedirsplits", "true"); 1605 RegisterOption("RssTree.dirSplitDepth", optInt, "dirsplidepth=", "10"); 1606 1607 RegisterOption("RssPreprocessor.Export.pvs", optBool, "rss_export_pvs", "false"); 1608 RegisterOption("RssPreprocessor.Export.rssTree", optBool, "rss_export_rss_tree", "false"); 1609 RegisterOption("RssPreprocessor.Export.rays", optBool, "rss_export_rays", "false"); 1610 RegisterOption("RssPreprocessor.Export.numRays", optInt, "rss_export_num_rays=", "5000"); 1611 RegisterOption("RssPreprocessor.useViewcells", optBool, "rss_use_viewcells", "false"); 1612 RegisterOption("RssPreprocessor.updateSubdivision", optBool, "rss_update_subdivision", "false"); 1613 1614 1615 /************************************************************************************/ 1616 /* View space partition BSP tree related options */ 1617 /************************************************************************************/ 1618 1619 1620 RegisterOption("VspBspTree.Termination.minPolygons", 1621 optInt, 1622 "-vsp_bsp_term_min_polygons=", 1623 "5"); 1624 1625 RegisterOption("VspBspTree.Termination.minPvs", 1626 optInt, 1627 "-vsp_bsp_term_min_pvs=", 1628 "20"); 1629 1630 RegisterOption("VspBspTree.Termination.minArea", 1631 optFloat, 1632 "-vsp_bsp_term_min_area=", 1633 "0.001"); 1634 1635 RegisterOption("VspBspTree.Termination.maxRayContribution", 1636 optFloat, 1637 "-vsp_bsp_term_ray_contribution=", 1638 "0.005"); 1639 1640 RegisterOption("VspBspTree.Termination.minAccRayLenght", 1641 optFloat, 1642 "-vsp_bsp_term_min_acc_ray_length=", 1643 "50"); 1644 1645 RegisterOption("VspBspTree.Termination.minRays", 1646 optInt, 1647 "-vsp_bsp_term_min_rays=", 1648 "-1"); 1649 1650 RegisterOption("VspBspTree.Termination.ct_div_ci", 1651 optFloat, 1652 "-vsp_bsp_term_ct_div_ci=", 1653 "0.0"); 1654 1655 RegisterOption("VspBspTree.Termination.maxDepth", 1656 optInt, 1657 "-vsp_bsp_term_max_depth=", 1658 "100"); 1659 1660 RegisterOption("VspBspTree.Termination.AxisAligned.maxCostRatio", 1661 optFloat, 1662 "-vsp_bsp_term_axis_aligned_max_cost_ratio=", 1663 "1.5"); 1664 1665 1666 RegisterOption("VspBspTree.Termination.AxisAligned.ct_div_ci", 1667 optFloat, 1668 "-vsp_bsp_term_axis_aligned_ct_div_ci=", 1669 "0.5"); 1670 1671 RegisterOption("VspBspTree.AxisAligned.splitBorder", 1672 optFloat, 1673 "-vsp_bsp__axis_aligned_split_border=", 1674 "0.1"); 1675 1676 RegisterOption("VspBspTree.Termination.AxisAligned.minPolys", 1677 optInt, 1678 "-vsp_bsp_term_axis_aligned_max_polygons=", 1679 "50"); 1680 1681 RegisterOption("VspBspTree.Termination.AxisAligned.minObjects", 1682 optInt, 1683 "-vsp_bsp_term_min_objects=", 1684 "3"); 1685 1686 RegisterOption("VspBspTree.Termination.AxisAligned.minRays", 1687 optInt, 1688 "-vsp_bsp_term_axis_aligned_min_rays=", 1689 "-1"); 1690 1691 RegisterOption("VspBspTree.splitPlaneStrategy", 1692 optString, 1693 "-vsp_bsp_split_method=", 1694 "leastSplits"); 1695 1696 RegisterOption("VspBspTree.maxPolyCandidates", 1697 optInt, 1698 "-vsp_bsp_max_poly_candidates=", 1699 "20"); 1700 1701 RegisterOption("VspBspTree.maxRayCandidates", 1702 optInt, 1703 "-vsp_bsp_max_plane_candidates=", 1704 "20"); 1705 1706 RegisterOption("VspBspTree.maxTests", 1707 optInt, 1708 "-vsp_bsp_max_tests=", 1709 "5000"); 1710 1711 RegisterOption("VspBspTree.Visualization.exportSplits", 1712 optBool, 1713 "-vsp_bsp_visualization.exportSplits", 1714 "false"); 1715 1716 RegisterOption("VspBspTree.Construction.samples", 1717 optInt, 1718 "-bsp_construction_samples=", 1719 "100000"); 1720 1721 RegisterOption("VspBspTree.Construction.epsilon", 1722 optFloat, 1723 "-vsp_bsp_construction_side_tolerance=", 1724 "0.002"); 1725 1726 RegisterOption("VspBspTree.Visualization.exportSplits", 1727 optBool, 1728 "-vsp_bsp_visualization.export_splits", 1729 "false"); 1730 RegisterOption("BspTree.Visualization.exportRays", 1731 optBool, 1732 "-vsp_bsp_visualization.export_rays", 1733 "false"); 1734 1735 RegisterOption("VspBspTree.Visualization.exportGeometry", 1736 optBool, 1737 "-vsp_bsp_visualization.export_geometry", 1738 "false"); 1739 1740 RegisterOption("VspBspTree.Factor.leastRaySplits", optFloat, "-vsp_bsp_factor_least_ray_splits=", "1.0"); 1741 RegisterOption("VspBspTree.Factor.balancedRays", optFloat, "-vsp_bsp_factor_balanced_rays=", "1.0"); 1742 RegisterOption("VspBspTree.Factor.pvs", optFloat, "-vsp_bsp_factor_pvs=", "1.0"); 1743 1744 ////////////////////////////////////////////////////////////////////////////////// 1709 1745 } 1710 1746 -
trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp
r466 r469 5 5 #include "Mesh.h" 6 6 #include "KdTree.h" 7 7 #include "ViewCell.h" 8 8 9 9 int KdNode::mailID = 1; … … 209 209 210 210 if (TerminationCriteriaMet(leaf)) 211 212 211 return leaf; 212 213 213 float position; 214 214 … … 277 277 back->mObjects.push_back(*mi); 278 278 279 mStat.objectRefs -= leaf->mObjects.size();279 mStat.objectRefs -= (int)leaf->mObjects.size(); 280 280 mStat.objectRefs += objectsBack + objectsFront; 281 281 } … … 362 362 363 363 if ( (int)(leaf->mObjects.size()) > mStat.maxObjectRefs) 364 mStat.maxObjectRefs = leaf->mObjects.size();364 mStat.maxObjectRefs = (int)leaf->mObjects.size(); 365 365 366 366 } … … 376 376 splitCandidates->clear(); 377 377 378 int requestedSize = 2* node->mObjects.size();378 int requestedSize = 2*(int)node->mObjects.size(); 379 379 // creates a sorted split candidates array 380 380 if (splitCandidates->capacity() > 500000 && … … 438 438 float intersectionsRight = totalIntersections; 439 439 440 int objectsLeft = 0, objectsRight = node->mObjects.size();440 int objectsLeft = 0, objectsRight = (int)node->mObjects.size(); 441 441 442 442 float minBox = box.Min(axis); … … 447 447 float maxBand = minBox + (1.0f - mSplitBorder)*(maxBox - minBox); 448 448 449 float minSum = 1e20 ;449 float minSum = 1e20f; 450 450 451 451 for(ci = splitCandidates->begin(); … … 606 606 } 607 607 608 int KdTree::CastLineSegment(const Vector3 &origin, 609 const Vector3 &termination, 610 vector<ViewCell *> &viewcells) 611 { 612 int hits = 0; 613 614 float mint = 0.0f, maxt = 1.0f; 615 const Vector3 dir = termination - origin; 616 617 stack<RayTraversalData > tStack; 618 619 Intersectable::NewMail(); 620 621 //maxt += Limits::Threshold; 622 623 Vector3 entp = origin; 624 Vector3 extp = termination; 625 626 KdNode *node = mRoot; 627 KdNode *farChild; 628 629 float position; 630 int axis; 631 632 while (1) 633 { 634 if (!node->IsLeaf()) 635 { 636 KdInterior *in = dynamic_cast<KdInterior *>(node); 637 position = in->mPosition; 638 axis = in->mAxis; 639 640 if (entp[axis] <= position) 641 { 642 if (extp[axis] <= position) 643 { 644 node = in->mBack; 645 // cases N1,N2,N3,P5,Z2,Z3 646 continue; 647 } 648 else 649 { 650 // case N4 651 node = in->mBack; 652 farChild = in->mFront; 653 } 654 } 655 else 656 { 657 if (position <= extp[axis]) 658 { 659 node = in->mFront; 660 // cases P1,P2,P3,N5,Z1 661 continue; 662 } 663 else 664 { 665 node = in->mFront; 666 farChild = in->mBack; 667 // case P4 668 } 669 } 670 671 // $$ modification 3.5.2004 - hints from Kamil Ghais 672 // case N4 or P4 673 float tdist = (position - origin[axis]) / dir[axis]; 674 //tStack.push(RayTraversalData(farChild, extp, maxt)); //TODO 675 extp = origin + dir * tdist; 676 maxt = tdist; 677 } 678 else 679 { 680 // compute intersection with all objects in this leaf 681 KdLeaf *leaf = dynamic_cast<KdLeaf *>(node); 682 683 // add view cell to intersections 684 ViewCell *vc = leaf->mViewCell; 685 686 if (!vc->Mailed()) 687 { 688 vc->Mail(); 689 viewcells.push_back(vc); 690 ++ hits; 691 } 692 693 // get the next node from the stack 694 if (tStack.empty()) 695 break; 696 697 entp = extp; 698 mint = maxt; 699 700 RayTraversalData &s = tStack.top(); 701 node = s.mNode; 702 extp = s.mExitPoint; 703 maxt = s.mMaxT; 704 tStack.pop(); 705 } 706 } 707 708 return hits; 709 } 710 711 608 712 void 609 713 KdTree::CollectObjects(KdNode *n, ObjectContainer &objects) … … 706 810 } 707 811 708 return neighbors.size();812 return (int)neighbors.size(); 709 813 } 710 814 … … 768 872 } 769 873 874 void 875 KdTree::CreateAndCollectViewCells(ViewCellContainer &vc) const 876 { 877 stack<KdNode *> nodeStack; 878 nodeStack.push(mRoot); 879 880 while (!nodeStack.empty()) { 881 KdNode *node = nodeStack.top(); 882 nodeStack.pop(); 883 if (node->IsLeaf()) { 884 KdLeaf *leaf = (KdLeaf *)node; 885 // kdtree used as view cell container => create view cell 886 leaf->mViewCell = new KdViewCell(); 887 vc.push_back(leaf->mViewCell); 888 } else { 889 KdInterior *interior = (KdInterior *)node; 890 nodeStack.push(interior->mBack); 891 nodeStack.push(interior->mFront); 892 } 893 } 894 } 770 895 771 896 int -
trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.h
r407 r469 9 9 #include "Ray.h" 10 10 #include "Pvs.h" 11 11 #include "Viewcell.h" 12 12 13 13 class KdNode; … … 15 15 class KdInterior; 16 16 class Intersectable; 17 17 //class KdViewCell; 18 18 19 19 // -------------------------------------------------------------- … … 157 157 class KdLeaf : public KdNode { 158 158 public: 159 KdLeaf(KdInterior *parent, const int objects):KdNode(parent) { 159 KdLeaf(KdInterior *parent, const int objects): 160 KdNode(parent), mViewCell(NULL) { 160 161 mObjects.reserve(objects); 161 162 } 162 163 163 void AddPassingRay(const Ray &ray, 164 const int contributions) { 164 void AddPassingRay(const Ray &ray, const int contributions) { 165 165 mPassingRays.AddRay(ray, contributions); 166 166 // Debug << "adding passing ray" << endl; … … 169 169 170 170 void AddPassingRay2(const Ray &ray, 171 172 173 171 const int objects, 172 const int viewcells 173 ) { 174 174 mPassingRays.AddRay2(ray, objects, viewcells); 175 175 // Debug << "adding passing ray" << endl; … … 183 183 ObjectContainer mObjects; 184 184 185 /** pointers to viewcells contained in this node */186 // ViewCellContainer mViewCells;187 188 185 /** Ray set description of the rays passing through this node */ 189 186 PassingRaySet mPassingRays; … … 192 189 KdPvs mKdPvs; 193 190 194 /** PVS consisting of visible objects */ 195 ViewCellPvs mPvs; 191 /** pointer to view cell. 192 */ 193 KdViewCell *mViewCell; 196 194 }; 197 195 … … 287 285 ); 288 286 287 288 /** Casts line segment into tree. 289 @returns intersected view cells. 290 */ 291 int CastLineSegment(const Vector3 &origin, 292 const Vector3 &termination, 293 vector<ViewCell *> &viewcells); 294 295 289 296 const KdTreeStatistics &GetStatistics() const { 290 297 return mStat; … … 297 304 CollectLeaves(vector<KdLeaf *> &leaves); 298 305 306 /** If the kd tree is used as view cell container, this 307 methods creates the view cells. 308 @returns the newly created view cells in a view cell container 309 */ 310 void 311 CreateAndCollectViewCells(ViewCellContainer &viewCells) const; 312 299 313 AxisAlignedBox3 GetBox(const KdNode *node) const { 300 314 KdInterior *parent = node->mParent; … … 315 329 KdNode * 316 330 FindRandomNeighbor(KdNode *n, 317 318 331 bool onlyUnmailed 332 ); 319 333 320 334 KdNode * -
trunk/VUT/GtpVisibilityPreprocessor/src/Mesh.cpp
r444 r469 234 234 235 235 236 int size = face->mVertexIndices.size();236 int size = (int)face->mVertexIndices.size(); 237 237 238 238 mVertices[face->mVertexIndices[size - 1]]. … … 430 430 Mesh::AddTriangle(const Triangle3 &triangle) 431 431 { 432 int index = mVertices.size();432 int index = (int)mVertices.size(); 433 433 434 434 for (int i=0; i < 3; i++) { … … 442 442 Mesh::AddRectangle(const Rectangle3 &rect) 443 443 { 444 int index = mVertices.size();444 int index = (int)mVertices.size(); 445 445 446 446 for (int i=0; i < 4; i++) { -
trunk/VUT/GtpVisibilityPreprocessor/src/MeshKdTree.cpp
r376 r469 181 181 mSplitCandidates->clear(); 182 182 183 int requestedSize = 2* node->mFaces.size();183 int requestedSize = 2*(int)node->mFaces.size(); 184 184 // creates a sorted split candidates array 185 185 if (mSplitCandidates->capacity() > 500000 && … … 232 232 // C = ct_div_ci + (ol + or)/queries 233 233 234 int objectsLeft = 0, objectsRight = node->mFaces.size();234 int objectsLeft = 0, objectsRight = (int)node->mFaces.size(); 235 235 236 236 float minBox = box.Min(axis); … … 241 241 float maxBand = minBox + (1.0f - mSplitBorder)*(maxBox - minBox); 242 242 243 float minSum = 1e20 ;243 float minSum = 1e20f; 244 244 vector<SortableEntry>::const_iterator ci; 245 245 -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r463 r469 10 10 #include "VspBspTree.h" 11 11 #include "VspKdTree.h" 12 #include "RenderSimulator.h" 12 13 13 14 Preprocessor::Preprocessor(): … … 37 38 38 39 while(1) { 39 int npos = str.find(';', pos);40 int npos = (int)str.find(';', pos); 40 41 41 42 if (npos < 0 || npos - pos < 1) … … 175 176 int constructionSamples = 0; 176 177 178 float objRenderCost = 0, vcOverhead = 0, moveSpeed = 0; 179 180 environment->GetFloatValue("Simulation.objRenderCost",objRenderCost); 181 environment->GetFloatValue("Simulation.vcOverhead", vcOverhead); 182 environment->GetFloatValue("Simulation.moveSpeed", moveSpeed); 183 184 mRenderSimulator = new RenderSimulator(objRenderCost, vcOverhead, moveSpeed); 185 177 186 if (strcmp(viewCellsStr, "kdTree") == 0) 178 187 { -
trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.cpp
r311 r469 1 1 #include <iostream> 2 2 #include "Pvs.h" 3 4 using namespace std;5 6 7 3 8 4 int -
trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h
r466 r469 3 3 4 4 #include <map> 5 #include <vector> 5 6 6 7 class KdNode; … … 18 19 }; 19 20 20 //typedef std::map<T *, PvsData<T>, LtSample<T>> PvsMap<T>; 21 /** Information stored with a PVS entry. Consists of the number 22 the object was seen from the view cell. 23 */ 21 24 22 25 template<typename T> … … 27 30 }; 28 31 32 /** Template class representing the Potentially Visible Set (PVS) 33 mainly from a view cell, but also e.g., from objects. 34 */ 29 35 template<typename T> 30 36 class Pvs 31 37 { 32 38 public: 33 Pvs(): mSamples(0),mEntries() {}39 Pvs(): /*mSamples(0), */mEntries() {} 34 40 35 int mSamples;41 //int mSamples; 36 42 43 /** Compresses PVS lossless or lossy. 44 */ 37 45 int Compress() {return 0;} 38 46 int GetSize() const {return (int)mEntries.size();} 39 bool Empty() const {return mEntries.size() == 0;} 47 bool Empty() const {return mEntries.empty();} 48 40 49 /** Merges pvs of a and pvs of b into this pvs. 41 50 */ 42 51 void Merge(const Pvs<T> &a, const Pvs<T> &b); 52 43 53 /** Difference of pvs to pvs b. 44 54 @returns number of different entries. … … 46 56 int Diff(const Pvs<T> &b); 47 57 58 /** Finds sample in PVS. 59 @returns sample if found, NULL otherwise. 60 */ 48 61 PvsData<T> *Find(T sample); 62 63 /** Adds sample to PVS. 64 @contribution contribution of sample (0 or 1) 65 @returns true if sample was not already in PVS. 66 */ 49 67 bool AddSample(T sample, float &contribution); 68 69 /** Adds sample to PVS. 70 @returns contribution of sample (0 or 1) 71 */ 50 72 int AddSample(T sample); 51 73 74 /** Returns PVS data, i.e., how often it was seen from the view cell, 75 and the object itsef. 76 */ 52 77 void GetData(const int index, T &entry, PvsData<T> &data); 78 79 /** Collects the PVS entries and returns them in the vector. 80 */ 81 void CollectEntries(std::vector<T> &entries); 82 83 /// Map of PVS entries 53 84 std::map<T, PvsData<T>, LtSample<T> > mEntries; 54 85 }; … … 138 169 } 139 170 171 template <typename T> 172 void Pvs<T>::CollectEntries(std::vector<T> &entries) 173 { 174 PvsMap<T>::const_iterator it, it_end = mEntries.end(); 175 176 // output PVS of view cell 177 for (it = mEntries.begin(); it != it_end; ++ it) 178 entries.push_back((*it)->first); 179 } 180 140 181 /** Class instantiating the Pvs template for kd tree nodes. 141 182 */ … … 146 187 147 188 typedef std::map<KdNode *, PvsData<KdNode *>, LtSample<KdNode *> > KdPvsMap; 148 typedef std::map<ViewCellKdNode *, PvsData<ViewCellKdNode *>, LtSample<ViewCellKdNode *> > ViewCellKdPvsMap; 149 typedef std::map<Intersectable *, PvsData<Intersectable *>, LtSample<Intersectable *> > ViewCellPvsMap; 150 typedef PvsData<Intersectable *> ViewCellPvsData; 189 typedef std::map<Intersectable *, PvsData<Intersectable *>, LtSample<Intersectable *> > ObjectPvsMap; 190 typedef PvsData<Intersectable *> ObjectPvsData; 151 191 typedef PvsData<KdNode *> KdPvsData; 152 typedef Pvs<ViewCellKdNode *> ViewCellKdPvs; 153 typedef Pvs<Intersectable *> ViewCellPvs;192 193 typedef Pvs<Intersectable *> ObjectPvs; 154 194 155 195 -
trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp
r468 r469 412 412 box->Enlarge(box->Size()*Vector3(-s)); 413 413 // Vector3 translation = Vector3(-olds*0.2f, 0, 0); 414 Vector3 translation = Vector3(-0.05 *olds, 0, 0);414 Vector3 translation = Vector3(-0.05f*olds, 0, 0); 415 415 box->SetMin(box->Min() + translation); 416 416 box->SetMax(box->Max() + translation); 417 417 418 box->SetMin(1, m + bsize*0.1 );419 box->SetMax(1, m + bsize*0.6 );418 box->SetMin(1, m + bsize*0.1f); 419 box->SetMax(1, m + bsize*0.6f); 420 420 421 421 … … 425 425 float m = box->Min(1); 426 426 float bsize = box->Size(1); 427 box->SetMin(1, m + bsize*0.2 );428 box->SetMax(1, m + bsize*0.3 );427 box->SetMin(1, m + bsize*0.2f); 428 box->SetMax(1, m + bsize*0.3f); 429 429 } 430 430 … … 489 489 490 490 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 491 cout << "#totalRayStackSize=" << mVssRays.size() << endl <<flush;491 cout << "#totalRayStackSize=" << (int)mVssRays.size() << endl <<flush; 492 492 493 493 -
trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.h
r466 r469 327 327 virtual void Print(ostream &s) const { 328 328 s<< 329 "L: rays="<< rays.size()<<329 "L: rays="<<(int)rays.size()<< 330 330 " pvs="<<mPvsSize<<" pEntropy="<<mPvsEntropy<<" lEntropy="<<mRayLengthEntropy<<endl; 331 331 }; -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r468 r469 75 75 { 76 76 // cast ray to KD tree to find intersection with other objects 77 mKdTree->CastRay(ray); 78 VssRay vssRay(ray); 79 mViewCellsManager->ComputeSampleContributions(vssRay); 80 return vssRay.mPvsContribution; 77 mKdTree->CastRay(ray); 78 VssRay vssRay(ray); 79 80 mViewCellsManager->ComputeSampleContributions(vssRay); 81 82 return vssRay.mPvsContribution; 81 83 } 82 84 … … 149 151 // pickup a random face of each mesh 150 152 Mesh *mesh = mi->GetMesh(); 151 int face = RandomValue(0, mesh->mFaces.size()-1);153 int face = (int)Random((int)mesh->mFaces.size()); 152 154 153 155 Polygon3 poly(mesh->mFaces[face], mesh); 154 poly.Scale(1.001 );156 poly.Scale(1.001f); 155 157 // now extend a random edge of the face 156 int edge = Random Value(0, poly.mVertices.size()-1);157 float t = RandomValue(0.0f, 1.0f);158 int edge = Random((int)poly.mVertices.size()); 159 float t = RandomValue(0.0f, 1.0f); 158 160 Vector3 target = t*poly.mVertices[edge] + (1.0f-t)*poly.mVertices[(edge + 1)% 159 161 poly.mVertices.size()]; … … 190 192 Debug << "Finding random neighbour" << endl; 191 193 for (int tries = 0; tries < 10; tries++) { 192 int index = Random Value(0, pvsSize - 1);194 int index = Random(pvsSize); 193 195 KdPvsData data; 194 196 KdNode *node; -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h
r466 r469 75 75 int &contributingSamples); 76 76 77 /** Adds objects samples to kd and bsp view cells.78 */79 int AddObjectSamples(Intersectable *obj, const Ray &ray);80 81 77 /** 82 78 Returns random node as target for the current sample ray. -
trunk/VUT/GtpVisibilityPreprocessor/src/Statistics.h
r374 r469 34 34 35 35 float Time() const { 36 return TimeDiff(startTime, stopTime);36 return (float)TimeDiff(startTime, stopTime); 37 37 } 38 38 }; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp
r463 r469 15 15 } 16 16 17 const ViewCellPvs &ViewCell::GetPvs() const17 const ObjectPvs &ViewCell::GetPvs() const 18 18 { 19 19 return mPvs; 20 20 } 21 21 22 ViewCellPvs &ViewCell::GetPvs()22 ObjectPvs &ViewCell::GetPvs() 23 23 { 24 24 return mPvs; … … 33 33 { 34 34 mPassingRays.AddRay(ray, contributions); 35 } 36 37 float ViewCell::GetVolume() const 38 { 39 return mVolume; 40 } 41 42 void ViewCell::SetVolume(float volume) 43 { 44 mVolume = volume; 35 45 } 36 46 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h
r463 r469 7 7 #include "Statistics.h" 8 8 //namespace GtpVisibilityPreprocessor { 9 9 10 struct Triangle3; 11 10 12 class BspInterior; 11 13 class BspPvs; 12 struct Triangle3;13 14 class BspLeaf; 14 15 class VspKdTree; 15 16 class VspKdLeaf; 16 17 class KdLeaf; 17 18 18 19 /** … … 28 29 ViewCell(Mesh *mesh); 29 30 30 31 /** Default destructor. 32 */ 31 33 virtual ~ViewCell() {} 32 34 /** Returns Pvs. 33 35 */ 34 const ViewCellPvs &GetPvs() const;35 ViewCellPvs &GetPvs();36 const ObjectPvs &GetPvs() const; 37 ObjectPvs &GetPvs(); 36 38 37 39 int Type() const; … … 41 43 void AddPassingRay(const Ray &ray, const int contributions); 42 44 45 /** Returns volume of the view cell. 46 */ 47 virtual float GetVolume() const; 48 49 /** Sets volume of the view cell. 50 */ 51 void SetVolume(float size); 43 52 44 53 /// Ray set description of the rays passing through this node. … … 51 60 52 61 /// the potentially visible objects 53 ViewCellPvs mPvs; 62 ObjectPvs mPvs; 63 64 float mVolume; 54 65 }; 55 66 56 class BspViewCell: public ViewCell 67 /** 68 View cell belonging to a hierarchy. 69 */ 70 template<typename T> 71 class HierarchyViewCell: public ViewCell 72 { 73 public: 74 HierarchyViewCell<T>(): mLeaves(0) {} 75 HierarchyViewCell<T>(Mesh *mesh): 76 ViewCell(mesh), mLeaves(0) {} 77 78 /// Leaves of the hierarchy which are part of this view cell. 79 std::vector<T> mLeaves; 80 }; 81 82 typedef HierarchyViewCell<BspLeaf *> BspViewCell; 83 typedef HierarchyViewCell<KdLeaf *> KdViewCell; 84 typedef HierarchyViewCell<VspKdLeaf *> VspKdViewCell; 85 86 /*class BspViewCell: public ViewCell 57 87 { 58 88 public: 59 89 BspViewCell(): mBspLeaves(0) {} 60 90 BspViewCell(Mesh *mesh): 61 ViewCell(mesh), mBspLeaves(0) {}91 ViewCell(mesh), mBspLeaves(0) {} 62 92 63 /// Leaves which holdthis view cell.64 vector<BspLeaf *> mBspLeaves;93 /// Leaves of the hierarchy which are part of this view cell. 94 std::vector<BspLeaf *> mBspLeaves; 65 95 }; 66 67 class VspKdViewCell: public ViewCell96 */ 97 /*class VspKdViewCell: public ViewCell 68 98 { 69 99 public: 70 VspKdViewCell(): m VspKdLeaves(0) {}100 VspKdViewCell(): mLeaves(0) {} 71 101 VspKdViewCell(Mesh *mesh): 72 ViewCell(mesh), mVspKdLeaves(0) {}102 ViewCell(mesh), mLeaves(0) {} 73 103 74 float GetSize() {return mSize;} 75 void SetSize(float size) {mSize = size;} 76 77 /// Leaves which hold this view cell. 78 vector<VspKdLeaf *> mVspKdLeaves; 79 80 protected: 81 float mSize; 104 /// Leaves of the hierarchy which are part of this view cell. 105 std::vector<VspKdLeaf *> mLeaves; 82 106 }; 83 107 */ 84 108 class ViewCellsStatistics: public StatisticsBase 85 109 { -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r468 r469 776 776 777 777 leaf->SetViewCell(viewCell); 778 viewCell->m BspLeaves.push_back(leaf);778 viewCell->mLeaves.push_back(leaf); 779 779 780 780 //-- add pvs … … 2036 2036 vcStat.minPvs = pvsSize; 2037 2037 2038 if ((int)viewCell->m BspLeaves.size() > vcStat.maxLeaves)2039 vcStat.maxLeaves = (int)viewCell->m BspLeaves.size();2038 if ((int)viewCell->mLeaves.size() > vcStat.maxLeaves) 2039 vcStat.maxLeaves = (int)viewCell->mLeaves.size(); 2040 2040 } 2041 2041 } … … 2176 2176 void BspTree::ConstructGeometry(BspViewCell *vc, PolygonContainer &cell) const 2177 2177 { 2178 vector<BspLeaf *> leaves = vc->m BspLeaves;2178 vector<BspLeaf *> leaves = vc->mLeaves; 2179 2179 2180 2180 vector<BspLeaf *>::const_iterator it, it_end = leaves.end(); -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r466 r469 8 8 #include "Statistics.h" 9 9 #include "VssRay.h" 10 10 #include "ViewCell.h" 11 11 12 12 class ViewCell; 13 class BspViewCell;13 //class BspViewCell; 14 14 class Plane3; 15 15 class BspTree; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r468 r469 40 40 { 41 41 DEL_PTR(mRenderSimulator); 42 } 43 44 void ViewCellsManager::InitRenderSimulator() 45 { 46 float objRenderCost = 0, vcOverhead = 0, moveSpeed = 0; 47 48 environment->GetFloatValue("Simulation.objRenderCost",objRenderCost); 49 environment->GetFloatValue("Simulation.vcOverhead", vcOverhead); 50 environment->GetFloatValue("Simulation.moveSpeed", moveSpeed); 51 52 mRenderSimulator->SetObjectRenderCost(objRenderCost); 53 mRenderSimulator->SetVcOverhead(vcOverhead); 54 mRenderSimulator->SetMoveSpeed(moveSpeed); 42 43 CLEAR_CONTAINER(mViewCells); 55 44 } 56 45 … … 67 56 } 68 57 69 void 70 ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays 71 ) 72 { 73 // view cells not yet constructed 74 if (!ViewCellsConstructed()) 75 return; 58 void ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays) 59 { 60 // view cells not yet constructed 61 if (!ViewCellsConstructed()) 62 return; 76 63 77 VssRayContainer::const_iterator it, it_end = rays.end(); 78 for (it = rays.begin(); it != it_end; ++ it) { 79 ComputeSampleContributions(*(*it)); 80 } 64 VssRayContainer::const_iterator it, it_end = rays.end(); 65 66 for (it = rays.begin(); it != it_end; ++ it) 67 { 68 ComputeSampleContributions(*(*it)); 69 } 81 70 } 82 71 … … 271 260 272 261 262 void ViewCellsManager::GetRaySets(const VssRayContainer &sourceRays, 263 VssRayContainer &constructionRays, 264 VssRayContainer &savedRays) const 265 { 266 const int limit = min (mConstructionSamples, (int)sourceRays.size()); 267 268 VssRayContainer::const_iterator it, it_end = sourceRays.end(); 269 270 for (it = sourceRays.begin(); it != it_end; ++ it) 271 { 272 if (Random((int)constructionRays.size()) > limit) 273 constructionRays.push_back(*it); 274 else 275 savedRays.push_back(*it); 276 } 277 } 278 273 279 /**********************************************************************/ 274 280 /* BspViewCellsManager implementation */ 275 281 /**********************************************************************/ 276 282 277 BspViewCellsManager::BspViewCellsManager(BspTree *bspTree, int constructionSamples): 283 BspViewCellsManager::BspViewCellsManager(BspTree *bspTree, 284 int constructionSamples): 278 285 ViewCellsManager(constructionSamples), 279 286 mBspTree(bspTree) … … 281 288 } 282 289 283 284 BspViewCellsManager::~BspViewCellsManager()285 {286 ViewCellContainer vc;287 mBspTree->CollectViewCells(vc);288 289 CLEAR_CONTAINER(vc);290 }291 290 292 291 bool BspViewCellsManager::ViewCellsConstructed() const … … 310 309 int sampleContributions = 0; 311 310 312 RayContainer sampleRays;313 314 int limit = min (mConstructionSamples, (int)rays.size());315 316 311 // construct view cells using the collected samples 317 Debug << "construcing bsp view cells from " 318 << limit << " samples " << endl; 319 320 for (int i = 0; i < limit; ++ i) 321 sampleRays.push_back(new Ray(*rays[i])); 322 323 if (mViewCells.empty()) { // no view cells loaded 324 mBspTree->Construct(objects, sampleRays); 325 mBspTree->CollectViewCells(mViewCells); 326 } else 327 mBspTree->Construct(mViewCells); 328 329 312 RayContainer constructionRays; 313 VssRayContainer savedRays; 314 315 const int limit = min(mConstructionSamples, (int)rays.size()); 316 317 VssRayContainer::const_iterator it, it_end = rays.end(); 318 319 for (it = rays.begin(); it != it_end; ++ it) 320 { 321 if (Random((int)constructionRays.size()) > limit) 322 constructionRays.push_back(new Ray(*(*it))); 323 else 324 savedRays.push_back(*it); 325 } 326 327 if (mViewCells.empty()) 328 { 329 // no view cells loaded 330 mBspTree->Construct(objects, constructionRays); 331 332 // collect final view cells 333 mBspTree->CollectViewCells(mViewCells); 334 } 335 else 336 { 337 mBspTree->Construct(mViewCells); 338 } 339 340 // destroy rays created only for construction 341 CLEAR_CONTAINER(constructionRays); 342 330 343 Debug << mBspTree->GetStatistics() << endl; 331 344 345 // recast rest of the rays 346 ComputeSampleContributions(savedRays); 347 332 348 return sampleContributions; 333 349 } 334 350 335 351 336 float BspViewCellsManager::GetProbability(ViewCell *viewCell) 352 float BspViewCellsManager::GetProbability(ViewCell *viewCell) const 337 353 { 338 354 PolygonContainer geom; … … 350 366 351 367 352 float BspViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) 368 float BspViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 353 369 { 354 370 return viewCell->GetPvs().GetSize() * objRendercost; … … 367 383 const VssRayContainer &rays) 368 384 { 369 385 if (!ViewCellsConstructed()) 370 386 { 371 387 Debug << "view cells not constructed" << endl; … … 484 500 const VssRayContainer &sampleRays) 485 501 { 486 487 return;502 if (!ViewCellsConstructed()) 503 return; 488 504 489 490 491 505 //-- recount pvs 506 ViewCellsStatistics vcStats; 507 mBspTree->EvaluateViewCellsStats(vcStats); 492 508 493 494 { 495 496 509 if (1) // export view cells 510 { 511 cout << "exporting view cells after merge ... "; 512 Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d"); 497 513 498 514 if (exporter) 499 515 { 500 501 502 516 exporter->ExportBspViewCellPartition(*mBspTree, vcStats.maxPvs); 517 //exporter->ExportBspViewCellPartition(*mBspTree, 0); 518 delete exporter; 503 519 } 504 520 505 521 cout << "finished" << endl; 506 522 } 507 523 508 509 510 524 //-- visualization of the BSP splits 525 bool exportSplits = false; 526 environment->GetBoolValue("BspTree.Visualization.exportSplits", exportSplits); 511 527 512 513 { 514 515 516 528 if (exportSplits) 529 { 530 cout << "exporting splits ... "; 531 ExportSplits(objects, sampleRays); 532 cout << "finished" << endl; 517 533 } 518 534 519 535 ExportBspPvs(objects, sampleRays); 520 536 } 521 537 … … 546 562 exporter->ResetForcedMaterial(); 547 563 564 bool exportRays = false; 565 bool exportGeometry = false; 566 567 environment->GetBoolValue("BspViewCellsManager.Visualization.exportRays", exportRays); 568 environment->GetBoolValue("BspViewCellsManager.Visualization.exportGeometry", exportGeometry); 569 548 570 // export rays 549 if ( 0)571 if (exportRays) 550 572 { 551 573 VssRayContainer outRays; 552 574 553 int raysSize = min((int)sampleRays.size(), mVisualizationSamples); 554 555 for (int i = 0; i < raysSize; ++ i) 575 int raysSize = min((int)sampleRays.size(), mVisualizationSamples); 576 for (int i = 0; i < raysSize; ++ i) 556 577 { 557 558 outRays.push_back(sampleRays[i]);578 // only rays piercing geometry 579 outRays.push_back(sampleRays[i]); 559 580 } 560 561 562 581 582 // export rays 583 exporter->ExportRays(outRays, RgbColor(1, 1, 0)); 563 584 } 564 585 565 if ( 0)566 586 if (exportGeometry) 587 exporter->ExportGeometry(objects); 567 588 568 589 delete exporter; … … 581 602 Debug << "visualization using " << raysOut << " samples" << endl; 582 603 583 //$$ JB584 #if 0585 586 604 if (1) 587 605 { 588 606 //-- some random view cells and rays for output 589 607 vector<BspLeaf *> bspLeaves; 590 608 591 609 for (int i = 0; i < leafOut; ++ i) 592 bspLeaves.push_back(mBspTree->GetRandomLeaf());610 bspLeaves.push_back(mBspTree->GetRandomLeaf()); 593 611 594 612 595 613 for (int i = 0; i < bspLeaves.size(); ++ i) 596 614 { 597 615 BspLeaf *leaf = bspLeaves[i]; 598 599 616 RayContainer vcRays; 600 617 601 618 cout << "creating output for view cell " << i << " ... "; 602 619 620 // TODO matt 603 621 // check whether we can add the current ray to the output rays 604 for (int k = 0; k < raysOut; ++ k)605 622 /*for (int k = 0; k < raysOut; ++ k) 623 { 606 624 Ray *ray = sampleRays[k]; 607 625 608 for 609 626 for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 627 { 610 628 BspLeaf *leaf2 = ray->bspIntersections[j].mLeaf; 611 629 612 630 if (leaf->GetViewCell() == leaf2->GetViewCell()) 613 631 { 614 632 vcRays.push_back(ray); 615 616 617 }633 } 634 } 635 }*/ 618 636 619 637 Intersectable::NewMail(); … … 635 653 636 654 if (vc->GetMesh()) 637 exporter->ExportViewCell(vc);655 exporter->ExportViewCell(vc); 638 656 else 639 657 { 640 658 PolygonContainer vcGeom; 641 659 // export view cell geometry 642 660 mBspTree->ConstructGeometry(vc, vcGeom); 643 661 exporter->ExportPolygons(vcGeom); 644 645 }646 662 CLEAR_CONTAINER(vcGeom); 663 } 664 647 665 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 648 666 << ", piercing rays=" << (int)vcRays.size() << endl; 649 667 650 668 // export rays piercing this view cell 651 exporter->ExportRays(vcRays, 1000, RgbColor(0, 1, 0));669 //exporter->ExportRays(vcRays, 1000, RgbColor(0, 1, 0)); 652 670 653 671 m.mDiffuseColor = RgbColor(1, 0, 0); … … 657 675 exporter->SetFilled(); 658 676 659 ViewCellPvsMap::iterator it, it_end = vc->GetPvs().mEntries.end();677 ObjectPvsMap::iterator it, it_end = vc->GetPvs().mEntries.end(); 660 678 // output PVS of view cell 661 679 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 662 680 { 663 681 Intersectable *intersect = (*it).first; 664 682 if (!intersect->Mailed()) 665 683 { 666 684 exporter->ExportIntersectable(intersect); 667 685 intersect->Mail(); 668 669 686 } 687 } 670 688 671 689 DEL_PTR(exporter); 672 690 cout << "finished" << endl; 673 674 691 } 692 } 675 693 else 676 694 { 677 695 ViewCellContainer viewCells; 678 696 RayContainer vcRays; … … 681 699 stable_sort(viewCells.begin(), viewCells.end(), vc_gt); 682 700 683 int limit = min(leafOut, (int)viewCells.size());701 const int limit = min(leafOut, (int)viewCells.size()); 684 702 685 703 for (int i = 0; i < limit; ++ i) 686 704 { 687 705 cout << "creating output for view cell " << i << " ... "; 688 706 689 Intersectable::NewMail(); 690 BspViewCell *vc = dynamic_cast<BspViewCell *>(viewCells[i]); 691 692 cout << "creating output for view cell " << i << " ... "; 693 // check whether we can add the current ray to the output rays 694 for (int k = 0; k < raysOut; ++ k) 695 { 696 Ray *ray = sampleRays[k]; 697 698 for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 699 { 700 BspLeaf *leaf = ray->bspIntersections[j].mLeaf; 701 702 if (vc == leaf->GetViewCell()) 703 { 704 vcRays.push_back(ray); 705 } 706 } 707 } 708 709 //bspLeaves[j]->Mail(); 710 char s[64]; sprintf(s, "bsp-pvs%04d.x3d", i); 711 712 Exporter *exporter = Exporter::GetExporter(s); 713 714 exporter->SetWireframe(); 715 716 Material m;//= RandomMaterial(); 717 m.mDiffuseColor = RgbColor(0, 1, 0); 718 exporter->SetForcedMaterial(m); 719 720 if (vc->GetMesh()) 721 exporter->ExportViewCell(vc); 722 else 723 { 724 PolygonContainer cell; 725 // export view cell 726 mBspTree->ConstructGeometry(vc, cell); 727 exporter->ExportPolygons(cell); 728 CLEAR_CONTAINER(cell); 729 } 730 731 732 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 733 << ", piercing rays=" << (int)vcRays.size() << endl; 734 735 736 // export rays piercing this view cell 737 exporter->ExportRays(vcRays, 1000, RgbColor(0, 1, 0)); 738 739 m.mDiffuseColor = RgbColor(1, 0, 0); 740 exporter->SetForcedMaterial(m); 741 742 ViewCellPvsMap::const_iterator it, 743 it_end = vc->GetPvs().mEntries.end(); 744 745 // output PVS of view cell 746 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 747 { 748 Intersectable *intersect = (*it).first; 749 if (!intersect->Mailed()) 750 { 751 Material m = RandomMaterial(); 752 753 exporter->SetForcedMaterial(m); 754 755 exporter->ExportIntersectable(intersect); 756 intersect->Mail(); 757 } 758 } 707 Intersectable::NewMail(); 708 BspViewCell *vc = dynamic_cast<BspViewCell *>(viewCells[i]); 709 710 cout << "creating output for view cell " << i << " ... "; 711 712 // TODO matt 713 // check whether we can add the current ray to the output rays 714 /*for (int k = 0; k < raysOut; ++ k) 715 { 716 Ray *ray = sampleRays[k]; 717 718 for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 719 { 720 BspLeaf *leaf = ray->bspIntersections[j].mLeaf; 721 722 if (vc == leaf->GetViewCell()) 723 vcRays.push_back(ray); 724 } 725 }*/ 726 727 //bspLeaves[j]->Mail(); 728 char s[64]; sprintf(s, "bsp-pvs%04d.x3d", i); 729 730 Exporter *exporter = Exporter::GetExporter(s); 731 exporter->SetWireframe(); 732 733 Material m;//= RandomMaterial(); 734 m.mDiffuseColor = RgbColor(0, 1, 0); 735 exporter->SetForcedMaterial(m); 736 737 if (vc->GetMesh()) 738 exporter->ExportViewCell(vc); 739 else 740 { 741 PolygonContainer cell; 742 // export view cell 743 mBspTree->ConstructGeometry(vc, cell); 744 exporter->ExportPolygons(cell); 745 CLEAR_CONTAINER(cell); 746 } 747 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 748 << ", piercing rays=" << (int)vcRays.size() << endl; 749 750 // export rays piercing this view cell 751 exporter->ExportRays(vcRays, 1000, RgbColor(0, 1, 0)); 752 753 m.mDiffuseColor = RgbColor(1, 0, 0); 754 exporter->SetForcedMaterial(m); 755 756 ObjectPvsMap::const_iterator it, it_end = vc->GetPvs().mEntries.end(); 757 758 // output PVS of view cell 759 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 760 { 761 Intersectable *intersect = (*it).first; 762 763 if (!intersect->Mailed()) 764 { 765 Material m = RandomMaterial(); 766 exporter->SetForcedMaterial(m); 767 768 exporter->ExportIntersectable(intersect); 769 770 intersect->Mail(); 771 } 772 } 759 773 760 DEL_PTR(exporter); 761 cout << "finished" << endl; 762 } 763 } 764 #endif 774 DEL_PTR(exporter); 775 cout << "finished" << endl; 776 } 777 } 765 778 } 766 779 … … 778 791 BspViewCell *bVc = back->GetViewCell(); 779 792 780 vector<BspLeaf *> fLeaves = fVc->m BspLeaves;781 vector<BspLeaf *> bLeaves = bVc->m BspLeaves;793 vector<BspLeaf *> fLeaves = fVc->mLeaves; 794 vector<BspLeaf *> bLeaves = bVc->mLeaves; 782 795 783 796 vector<BspLeaf *>::const_iterator it; … … 786 799 { 787 800 (*it)->SetViewCell(viewCell); 788 viewCell->m BspLeaves.push_back(*it);801 viewCell->mLeaves.push_back(*it); 789 802 } 790 803 for (it = bLeaves.begin(); it != bLeaves.end(); ++ it) 791 804 { 792 805 (*it)->SetViewCell(viewCell); 793 viewCell->m BspLeaves.push_back(*it);806 viewCell->mLeaves.push_back(*it); 794 807 } 795 808 … … 836 849 837 850 KdViewCellsManager::KdViewCellsManager(KdTree *kdTree): 838 ViewCellsManager(), 839 mKdTree(kdTree), 840 mKdPvsDepth(100) 841 { 842 } 843 844 float KdViewCellsManager::GetProbability(ViewCell *viewCell) 845 { 846 return 0; 847 } 848 849 850 float KdViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) 851 { 852 return 0; 851 ViewCellsManager(), mKdTree(kdTree), mKdPvsDepth(100) 852 { 853 } 854 855 float KdViewCellsManager::GetProbability(ViewCell *viewCell) const 856 { 857 KdViewCell *vc = dynamic_cast<KdViewCell *>(viewCell); 858 859 AxisAlignedBox3 box = mKdTree->GetBox(vc->mLeaves[0]); 860 861 return box.SurfaceArea(); 862 } 863 864 865 float KdViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 866 { 867 return viewCell->GetPvs().GetSize() * objRendercost; 853 868 } 854 869 … … 861 876 return 0; 862 877 863 Debug << "Constructing bsp view cells" << endl;864 865 878 mKdTree->Construct(); 879 880 // create the view cells 881 mKdTree->CreateAndCollectViewCells(mViewCells); 866 882 867 883 return 0; … … 885 901 return; 886 902 903 // using view cells instead of the kd PVS of objects 904 const bool useViewCells = true; 905 bool exportRays = false; 906 907 int limit = min(mVisualizationSamples, (int)sampleRays.size()); 887 908 const int pvsOut = min((int)objects.size(), 10); 888 889 int limit = min(mVisualizationSamples, (int)sampleRays.size());890 891 909 VssRayContainer *rays = new VssRayContainer[pvsOut]; 892 910 893 for (int i = 0; i < limit; ++ i) 894 { 895 VssRay *ray = sampleRays[i]; 896 897 // check whether we can add this to the rays 898 for (int j = 0; j < pvsOut; j++) 911 //$$ JB 912 //#if 0 913 914 if (useViewCells) 915 { 916 const int leafOut = 10; 917 918 ViewCell::NewMail(); 919 920 //-- some rays for output 921 const int raysOut = min((int)sampleRays.size(), mVisualizationSamples); 922 Debug << "visualization using " << raysOut << " samples" << endl; 923 924 //-- some random view cells and rays for output 925 vector<KdLeaf *> kdLeaves; 926 927 for (int i = 0; i < leafOut; ++ i) 928 kdLeaves.push_back(dynamic_cast<KdLeaf *>(mKdTree->GetRandomLeaf())); 929 930 for (int i = 0; i < kdLeaves.size(); ++ i) 899 931 { 900 if (objects[j] == ray->mTerminationObject) 932 KdLeaf *leaf = kdLeaves[i]; 933 RayContainer vcRays; 934 935 cout << "creating output for view cell " << i << " ... "; 936 937 // check whether we can add the current ray to the output rays 938 /*for (int k = 0; k < raysOut; ++ k) 901 939 { 902 rays[j].push_back(ray); 940 Ray *ray = sampleRays[k]; 941 942 for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 943 { 944 BspLeaf *leaf2 = ray->bspIntersections[j].mLeaf; 945 946 if (leaf->GetViewCell() == leaf2->GetViewCell()) 947 { 948 vcRays.push_back(ray); 949 } 950 } 951 }*/ 952 953 Intersectable::NewMail(); 954 955 ViewCell *vc = leaf->mViewCell; 956 957 //bspLeaves[j]->Mail(); 958 char s[64]; sprintf(s, "kd-pvs%04d.x3d", i); 959 960 Exporter *exporter = Exporter::GetExporter(s); 961 exporter->SetFilled(); 962 963 exporter->SetWireframe(); 964 //exporter->SetFilled(); 965 966 Material m;//= RandomMaterial(); 967 m.mDiffuseColor = RgbColor(1, 1, 0); 968 exporter->SetForcedMaterial(m); 969 970 AxisAlignedBox3 box = mKdTree->GetBox(leaf); 971 exporter->ExportBox(box); 972 973 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 974 << ", piercing rays=" << (int)vcRays.size() << endl; 975 976 // export rays piercing this view cell 977 exporter->ExportRays(vcRays, 1000, RgbColor(0, 1, 0)); 978 979 m.mDiffuseColor = RgbColor(1, 0, 0); 980 exporter->SetForcedMaterial(m); 981 982 // exporter->SetWireframe(); 983 exporter->SetFilled(); 984 985 ObjectPvsMap::iterator it, it_end = vc->GetPvs().mEntries.end(); 986 // output PVS of view cell 987 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 988 { 989 Intersectable *intersect = (*it).first; 990 if (!intersect->Mailed()) 991 { 992 exporter->ExportIntersectable(intersect); 993 intersect->Mail(); 994 } 995 } 996 997 DEL_PTR(exporter); 998 cout << "finished" << endl; 999 } 1000 1001 DEL_PTR(rays); 1002 } 1003 else // using kd PVS of objects 1004 { 1005 for (int i = 0; i < limit; ++ i) 1006 { 1007 VssRay *ray = sampleRays[i]; 1008 1009 // check whether we can add this to the rays 1010 for (int j = 0; j < pvsOut; j++) 1011 { 1012 if (objects[j] == ray->mTerminationObject) 1013 { 1014 rays[j].push_back(ray); 1015 } 903 1016 } 904 1017 } 905 } 906 907 908 bool exportRays = false; 909 if (exportRays) { 910 Exporter *exporter = NULL; 911 exporter = Exporter::GetExporter("sample-rays.x3d"); 912 exporter->SetWireframe(); 913 exporter->ExportKdTree(*mKdTree); 914 915 for (i=0; i < pvsOut; i++) 916 exporter->ExportRays(rays[i], RgbColor(1, 0, 0)); 917 exporter->SetFilled(); 918 919 delete exporter; 920 } 921 922 for (int k=0; k < pvsOut; k++) 923 { 924 Intersectable *object = objects[k]; 925 char s[64]; 926 sprintf(s, "sample-pvs%04d.x3d", k); 927 928 Exporter *exporter = Exporter::GetExporter(s); 929 exporter->SetWireframe(); 930 931 KdPvsMap::iterator i = object->mKdPvs.mEntries.begin(); 932 Intersectable::NewMail(); 933 934 // avoid adding the object to the list 935 object->Mail(); 936 ObjectContainer visibleObjects; 937 938 for (; i != object->mKdPvs.mEntries.end(); i++) 1018 1019 if (exportRays) 939 1020 { 940 KdNode *node = (*i).first; 941 exporter->ExportBox(mKdTree->GetBox(node)); 942 mKdTree->CollectObjects(node, visibleObjects); 1021 Exporter *exporter = NULL; 1022 exporter = Exporter::GetExporter("sample-rays.x3d"); 1023 exporter->SetWireframe(); 1024 exporter->ExportKdTree(*mKdTree); 1025 1026 for (i=0; i < pvsOut; i++) 1027 exporter->ExportRays(rays[i], RgbColor(1, 0, 0)); 1028 1029 exporter->SetFilled(); 1030 1031 delete exporter; 943 1032 } 944 1033 945 exporter->ExportRays(rays[k], RgbColor(0, 1, 0)); 946 exporter->SetFilled(); 947 948 for (int j = 0; j < visibleObjects.size(); j++) 949 exporter->ExportIntersectable(visibleObjects[j]); 950 951 Material m; 952 m.mDiffuseColor = RgbColor(1, 0, 0); 953 exporter->SetForcedMaterial(m); 954 exporter->ExportIntersectable(object); 955 956 delete exporter; 957 } 958 DEL_PTR(rays); 959 } 1034 for (int k=0; k < pvsOut; k++) 1035 { 1036 Intersectable *object = objects[k]; 1037 char s[64]; 1038 sprintf(s, "sample-pvs%04d.x3d", k); 1039 1040 Exporter *exporter = Exporter::GetExporter(s); 1041 exporter->SetWireframe(); 1042 1043 KdPvsMap::iterator i = object->mKdPvs.mEntries.begin(); 1044 Intersectable::NewMail(); 1045 1046 // avoid adding the object to the list 1047 object->Mail(); 1048 ObjectContainer visibleObjects; 1049 1050 for (; i != object->mKdPvs.mEntries.end(); i++) 1051 { 1052 KdNode *node = (*i).first; 1053 exporter->ExportBox(mKdTree->GetBox(node)); 1054 1055 mKdTree->CollectObjects(node, visibleObjects); 1056 } 1057 1058 exporter->ExportRays(rays[k], RgbColor(0, 1, 0)); 1059 exporter->SetFilled(); 1060 1061 for (int j = 0; j < visibleObjects.size(); j++) 1062 exporter->ExportIntersectable(visibleObjects[j]); 1063 1064 Material m; 1065 m.mDiffuseColor = RgbColor(1, 0, 0); 1066 exporter->SetForcedMaterial(m); 1067 exporter->ExportIntersectable(object); 1068 1069 delete exporter; 1070 } 1071 } 1072 } 1073 960 1074 961 1075 int KdViewCellsManager::GetType() const … … 981 1095 982 1096 983 int 984 KdViewCellsManager::CastLineSegment(const Vector3 &origin, 985 const Vector3 &termination, 986 ViewCellContainer &viewcells 987 ) 988 { 989 990 return 0; 991 } 1097 int KdViewCellsManager::CastLineSegment(const Vector3 &origin, 1098 const Vector3 &termination, 1099 ViewCellContainer &viewcells) 1100 { 1101 return mKdTree->CastLineSegment(origin, termination, viewcells); 1102 } 1103 1104 992 1105 993 1106 /**********************************************************************/ … … 1003 1116 } 1004 1117 1005 float VspKdViewCellsManager::GetProbability(ViewCell *viewCell) 1006 { 1007 /*AxisAlignedBox3 box = mKdTree->GetBox(*it);1118 float VspKdViewCellsManager::GetProbability(ViewCell *viewCell) const 1119 { 1120 /* AxisAlignedBox3 box = mKdTree->GetBox(*it); 1008 1121 1009 1122 // volume or area substitutes for view point probability … … 1011 1124 return box.GetVolume(); 1012 1125 else 1013 return box.SurfaceArea();*/ 1014 1015 return dynamic_cast<VspKdViewCell *>(viewCell)->GetSize(); 1016 } 1017 1018 1019 float VspKdViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) 1020 { 1021 return 0;//leaf->mKdPvs.GetSize() * objRendercost; 1022 } 1023 1024 VspKdViewCellsManager::~VspKdViewCellsManager() 1025 { 1026 ViewCellContainer vc; 1027 mVspKdTree->CollectViewCells(vc); 1028 1029 CLEAR_CONTAINER(vc); 1126 return box.SurfaceArea(); 1127 */ 1128 return dynamic_cast<VspKdViewCell *>(viewCell)->GetVolume(); 1129 } 1130 1131 1132 float VspKdViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 1133 { 1134 return viewCell->GetPvs().GetSize() * objRendercost; 1030 1135 } 1031 1136 … … 1039 1144 return 0; 1040 1145 1041 VssRayContainer sampleRays; 1042 1043 int limit = min (mConstructionSamples, (int)rays.size()); 1044 1045 for (int i = 0; i < limit; ++ i) 1046 sampleRays.push_back(rays[i]); 1047 1048 Debug << "constructing vsp kd tree using " << (int)sampleRays.size() << " samples" << endl; 1049 mVspKdTree->Construct(rays, sceneBbox); 1146 VssRayContainer constructionRays; 1147 VssRayContainer savedRays; 1148 1149 GetRaySets(rays, constructionRays, savedRays); 1150 1151 Debug << "constructing vsp kd tree using " 1152 << (int)constructionRays.size() << " samples" << endl; 1153 1154 mVspKdTree->Construct(constructionRays, sceneBbox); 1155 1156 // collect view cells 1157 mVspKdTree->CollectViewCells(mViewCells); 1050 1158 1051 1159 Debug << mVspKdTree->GetStatistics() << endl; 1052 1160 1053 return 0; 1161 // finally merge kd leaf building blocks to view cells 1162 const int merged = mVspKdTree->MergeLeaves(); 1163 1164 // recast rest of rays 1165 ComputeSampleContributions(savedRays); 1166 1167 return merged; 1054 1168 } 1055 1169 … … 1071 1185 return 0; 1072 1186 1073 return mVspKdTree->MergeLeaves();1187 return 0; 1074 1188 } 1075 1189 … … 1077 1191 const VssRayContainer &sampleRays) 1078 1192 { 1193 bool exportRays = false; 1194 bool exportGeometry = false; 1195 1196 environment->GetBoolValue("BspViewCellsManager.Visualization.exportRays", exportRays); 1197 environment->GetBoolValue("BspViewCellsManager.Visualization.exportGeometry", exportGeometry); 1198 1079 1199 if (!ViewCellsConstructed()) 1080 1200 return; 1081 1082 bool exportRays = true;1083 1201 1084 1202 //-- export tree leaves … … 1173 1291 exporter->ExportGeometry(objects); 1174 1292 } 1293 1175 1294 if (exportRays) 1176 1295 { … … 1207 1326 1208 1327 1209 int 1210 VspKdViewCellsManager::CastLineSegment(const Vector3 &origin, 1211 const Vector3 &termination, 1212 ViewCellContainer &viewcells 1213 ) 1214 { 1215 1216 return 0; 1328 int VspKdViewCellsManager::CastLineSegment(const Vector3 &origin, 1329 const Vector3 &termination, 1330 ViewCellContainer &viewcells) 1331 { 1332 return mVspKdTree->CastLineSegment(origin, termination, viewcells); 1217 1333 } 1218 1334 … … 1228 1344 } 1229 1345 1230 float VspBspViewCellsManager::GetProbability(ViewCell *viewCell) 1346 float VspBspViewCellsManager::GetProbability(ViewCell *viewCell) const 1231 1347 { 1232 1348 PolygonContainer geom; … … 1244 1360 1245 1361 1246 float VspBspViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) 1362 float VspBspViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 1247 1363 { 1248 1364 return viewCell->GetPvs().GetSize() * objRendercost; 1249 1365 } 1250 1366 1251 VspBspViewCellsManager::~VspBspViewCellsManager()1252 {1253 ViewCellContainer vc;1254 mVspBspTree->CollectViewCells(vc);1255 1256 CLEAR_CONTAINER(vc);1257 }1258 1367 1259 1368 bool VspBspViewCellsManager::ViewCellsConstructed() const … … 1280 1389 int sampleContributions = 0; 1281 1390 1282 VssRayContainer sampleRays; 1283 1284 int limit = min (mConstructionSamples, (int)rays.size()); 1285 1286 for (int i = 0; i < limit; ++ i) 1287 sampleRays.push_back(rays[i]); 1288 1289 mVspBspTree->Construct(sampleRays); 1391 VssRayContainer constructionRays; 1392 VssRayContainer savedRays; 1393 1394 GetRaySets(rays, constructionRays, savedRays); 1395 1396 mVspBspTree->Construct(constructionRays); 1290 1397 mVspBspTree->CollectViewCells(mViewCells); 1291 1398 1292 1399 Debug << mVspBspTree->GetStatistics() << endl; 1400 1401 // recast rest of rays 1402 ComputeSampleContributions(savedRays); 1293 1403 1294 1404 return sampleContributions; … … 1488 1598 const VssRayContainer &sampleRays) 1489 1599 { 1600 bool exportRays = false; 1601 bool exportGeometry = false; 1602 1603 environment->GetBoolValue("BspViewCellsManager.Visualization.exportRays", exportRays); 1604 environment->GetBoolValue("BspViewCellsManager.Visualization.exportGeometry", exportGeometry); 1605 1490 1606 const int leafOut = 10; 1491 1607 … … 1506 1622 for (int i = 0; i < (int)vspBspLeaves.size(); ++ i) 1507 1623 { 1508 1509 1510 1511 1624 VssRayContainer vcRays; 1625 cout << "creating output for view cell " << i << " ... "; 1626 1627 //$$JB 1512 1628 #if 0 1513 1629 // check whether we can add the current ray to the output rays 1514 1630 for (int k = 0; k < raysOut; ++ k) 1515 1631 { 1516 1632 VssRay *ray = sampleRays[k]; 1517 1633 1518 1634 for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) … … 1539 1655 exporter->SetFilled(); 1540 1656 1541 ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin();1657 ObjectPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 1542 1658 1543 1659 exporter->SetWireframe(); … … 1564 1680 1565 1681 // export rays piercing this view cell 1566 exporter->ExportRays(vcRays, RgbColor(1, 0, 0)); 1567 exporter->ExportRays(vspBspLeaves[i]->mVssRays, RgbColor(1, 1, 1)); 1568 1682 if (exportRays) 1683 { 1684 //exporter->ExportRays(vcRays, RgbColor(1, 0, 0)); 1685 exporter->ExportRays(vspBspLeaves[i]->mVssRays, RgbColor(1, 1, 1)); 1686 } 1687 1569 1688 m.mDiffuseColor = RgbColor(0, 1, 1); 1570 1689 exporter->SetForcedMaterial(m); 1571 1690 1572 exporter->SetWireframe();1573 //exporter->SetFilled();1691 //exporter->SetWireframe(); 1692 exporter->SetFilled(); 1574 1693 1575 1694 // output PVS of view cell … … 1585 1704 1586 1705 // output rest of the objects 1587 if ( 0)1706 if (exportGeometry) 1588 1707 { 1589 1708 Material m;//= RandomMaterial(); … … 1671 1790 exporter->SetForcedMaterial(m); 1672 1791 1673 ViewCellPvsMap::const_iterator it,1792 ObjectPvsMap::const_iterator it, 1674 1793 it_end = vc->GetPvs().mEntries.end(); 1675 1794 … … 1720 1839 BspViewCell *bVc = back->GetViewCell(); 1721 1840 1722 vector<BspLeaf *> fLeaves = fVc->m BspLeaves;1723 vector<BspLeaf *> bLeaves = bVc->m BspLeaves;1841 vector<BspLeaf *> fLeaves = fVc->mLeaves; 1842 vector<BspLeaf *> bLeaves = bVc->mLeaves; 1724 1843 1725 1844 vector<BspLeaf *>::const_iterator it; … … 1728 1847 { 1729 1848 (*it)->SetViewCell(viewCell); 1730 viewCell->m BspLeaves.push_back(*it);1849 viewCell->mLeaves.push_back(*it); 1731 1850 } 1732 1851 for (it = bLeaves.begin(); it != bLeaves.end(); ++ it) 1733 1852 { 1734 1853 (*it)->SetViewCell(viewCell); 1735 viewCell->m BspLeaves.push_back(*it);1854 viewCell->mLeaves.push_back(*it); 1736 1855 } 1737 1856 … … 1768 1887 1769 1888 1770 int 1771 VspBspViewCellsManager::CastLineSegment(const Vector3 &origin, 1772 const Vector3 &termination, 1773 ViewCellContainer &viewcells 1774 ) 1775 { 1776 return mVspBspTree->CastLineSegment(origin, termination, viewcells); 1777 } 1889 int VspBspViewCellsManager::CastLineSegment(const Vector3 &origin, 1890 const Vector3 &termination, 1891 ViewCellContainer &viewcells) 1892 { 1893 return mVspBspTree->CastLineSegment(origin, termination, viewcells); 1894 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r468 r469 172 172 /** Returns probability that view point lies in one view cell. 173 173 */ 174 virtual float GetProbability(ViewCell *viewCell) = 0;174 virtual float GetProbability(ViewCell *viewCell) const = 0; 175 175 176 176 /** Returns render cost of a single view cell given the render cost of an object. 177 177 */ 178 virtual float GetRendercost(ViewCell *viewCell, float objRendercost) = 0;178 virtual float GetRendercost(ViewCell *viewCell, float objRendercost) const = 0; 179 179 180 180 /** Returns vector of loaded / generated view cells. … … 182 182 ViewCellContainer &GetViewCells(); 183 183 184 /** Helper function used to split ray set into one used for view cell 185 construction and one cast after construction. 186 */ 187 void GetRaySets(const VssRayContainer &sourceRays, 188 VssRayContainer &constructionRays, 189 VssRayContainer &savedRays) const; 190 184 191 protected: 185 186 187 /** Initialises the render time simulator. 188 */ 189 void InitRenderSimulator(); 190 ///////////////////// 191 192 192 193 193 /// the view cell corresponding to unbounded space 194 194 ViewCell *mUnbounded; … … 198 198 199 199 /// Loaded view cells 200 200 ViewCellContainer mViewCells; 201 201 202 202 /// maximum number of samples taken for construction of the view cells … … 242 242 void PrintStatistics(ostream &s) const; 243 243 244 ~BspViewCellsManager();245 246 244 int CastLineSegment(const Vector3 &origin, 247 245 const Vector3 &termination, 248 246 ViewCellContainer &viewcells); 249 247 250 float GetProbability(ViewCell *viewCell) ;251 float GetRendercost(ViewCell *viewCell, float objRendercost) ;248 float GetProbability(ViewCell *viewCell) const; 249 float GetRendercost(ViewCell *viewCell, float objRendercost) const; 252 250 253 251 protected: … … 312 310 virtual void PrintStatistics(ostream &s) const; 313 311 314 float GetProbability(ViewCell *viewCell) ;315 float GetRendercost(ViewCell *viewCell, float objRendercost) ;312 float GetProbability(ViewCell *viewCell) const; 313 float GetRendercost(ViewCell *viewCell, float objRendercost) const; 316 314 317 315 protected: … … 338 336 VspKdViewCellsManager(VspKdTree *vspKdTree, int constructionSamples); 339 337 340 ~VspKdViewCellsManager();341 342 338 int Construct(const ObjectContainer &objects, 343 339 const VssRayContainer &rays, … … 364 360 ViewCellContainer &viewcells); 365 361 366 float GetProbability(ViewCell *viewCell) ;367 float GetRendercost(ViewCell *viewCell, float objRendercost) ;362 float GetProbability(ViewCell *viewCell) const; 363 float GetRendercost(ViewCell *viewCell, float objRendercost) const; 368 364 369 365 protected: … … 385 381 VspBspViewCellsManager(VspBspTree *tree, int constructionSamples); 386 382 387 ~VspBspViewCellsManager();388 389 383 int Construct(const ObjectContainer &objects, 390 384 const VssRayContainer &rays, … … 410 404 ViewCellContainer &viewcells); 411 405 412 float GetProbability(ViewCell *viewCell) ;413 float GetRendercost(ViewCell *viewCell, float objRendercost) ;406 float GetProbability(ViewCell *viewCell) const; 407 float GetRendercost(ViewCell *viewCell, float objRendercost) const; 414 408 415 409 -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r466 r469 324 324 325 325 leaf->SetViewCell(viewCell); 326 viewCell->m BspLeaves.push_back(leaf);326 viewCell->mLeaves.push_back(leaf); 327 327 328 328 //-- add pvs … … 1262 1262 stat.minPvs = pvsSize; 1263 1263 1264 if ((int)viewCell->m BspLeaves.size() > stat.maxLeaves)1265 stat.maxLeaves = (int)viewCell->m BspLeaves.size();1264 if ((int)viewCell->mLeaves.size() > stat.maxLeaves) 1265 stat.maxLeaves = (int)viewCell->mLeaves.size(); 1266 1266 } 1267 1267 } … … 1461 1461 void VspBspTree::ConstructGeometry(BspViewCell *vc, PolygonContainer &vcGeom) const 1462 1462 { 1463 vector<BspLeaf *> leaves = vc->m BspLeaves;1463 vector<BspLeaf *> leaves = vc->mLeaves; 1464 1464 1465 1465 vector<BspLeaf *>::const_iterator it, it_end = leaves.end(); … … 1712 1712 1713 1713 1714 int 1715 VspBspTree::CastLineSegment(const Vector3 &origin, 1716 const Vector3 &termination, 1717 vector<ViewCell *> &viewcells 1718 ) 1719 { 1720 int hits = 0; 1721 stack<BspRayTraversalData> tStack; 1714 int VspBspTree::CastLineSegment(const Vector3 &origin, 1715 const Vector3 &termination, 1716 vector<ViewCell *> &viewcells) 1717 { 1718 int hits = 0; 1719 stack<BspRayTraversalData> tStack; 1722 1720 1723 1721 float mint = 0.0f, maxt = 1.0f; 1724 1722 1725 1723 Intersectable::NewMail(); 1726 1724 1727 1728 1725 Vector3 entp = origin; 1726 Vector3 extp = termination; 1729 1727 1730 1731 1728 BspNode *node = mRoot; 1729 BspNode *farChild = NULL; 1732 1730 1733 while (1) { 1734 if (!node->IsLeaf()) { 1735 BspInterior *in = dynamic_cast<BspInterior *>(node); 1731 while (1) 1732 { 1733 if (!node->IsLeaf()) 1734 { 1735 BspInterior *in = dynamic_cast<BspInterior *>(node); 1736 1736 1737 1738 1739 1737 Plane3 splitPlane = in->GetPlane(); 1738 const int entSide = splitPlane.Side(entp); 1739 const int extSide = splitPlane.Side(extp); 1740 1740 1741 if (entSide < 0) {1742 node = in->GetBack();1743 1744 if(extSide <= 0) // plane does not split ray => no far child1745 continue;1746 1747 farChild = in->GetFront(); // plane splits ray1748 1749 } else1750 if (entSide > 0){1751 1741 if (entSide < 0) 1742 { 1743 node = in->GetBack(); 1744 1745 if(extSide <= 0) // plane does not split ray => no far child 1746 continue; 1747 1748 farChild = in->GetFront(); // plane splits ray 1749 } else if (entSide > 0) 1750 { 1751 node = in->GetFront(); 1752 1752 1753 1754 continue;1753 if (extSide >= 0) // plane does not split ray => no far child 1754 continue; 1755 1755 1756 1757 }1758 else // ray and plane are coincident1759 1760 // WHAT TO DO IN THIS CASE ?1761 //break;1762 node = in->GetFront();1763 continue;1764 1756 farChild = in->GetBack(); // plane splits ray 1757 } 1758 else // ray and plane are coincident 1759 { 1760 // WHAT TO DO IN THIS CASE ? 1761 //break; 1762 node = in->GetFront(); 1763 continue; 1764 } 1765 1765 1766 1767 1766 // push data for far child 1767 tStack.push(BspRayTraversalData(farChild, extp, maxt)); 1768 1768 1769 1770 1771 1772 1769 // find intersection of ray segment with plane 1770 float t; 1771 extp = splitPlane.FindIntersection(origin, extp, &t); 1772 maxt *= t; 1773 1773 1774 } else { 1775 // reached leaf => intersection with view cell 1776 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 1774 } else 1775 { 1776 // reached leaf => intersection with view cell 1777 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 1777 1778 1778 if (!leaf->GetViewCell()->Mailed()) { 1779 viewcells.push_back(leaf->GetViewCell()); 1780 leaf->GetViewCell()->Mail(); 1781 hits++; 1782 } 1779 if (!leaf->GetViewCell()->Mailed()) 1780 { 1781 viewcells.push_back(leaf->GetViewCell()); 1782 leaf->GetViewCell()->Mail(); 1783 ++ hits; 1784 } 1783 1785 1784 1785 1786 break;1786 //-- fetch the next far child from the stack 1787 if (tStack.empty()) 1788 break; 1787 1789 1788 1789 1790 entp = extp; 1791 mint = maxt; // NOTE: need this? 1790 1792 1791 BspRayTraversalData &s = tStack.top(); 1793 1794 BspRayTraversalData &s = tStack.top(); 1795 1796 node = s.mNode; 1797 extp = s.mExitPoint; 1798 maxt = s.mMaxT; 1792 1799 1793 node = s.mNode; 1794 extp = s.mExitPoint; 1795 maxt = s.mMaxT; 1796 1797 tStack.pop(); 1798 } 1799 } 1800 return hits; 1801 } 1800 tStack.pop(); 1801 } 1802 } 1803 return hits; 1804 } -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r466 r469 10 10 #include "RayInfo.h" 11 11 #include "ViewCellBsp.h" 12 #include "ViewCell.h" 12 13 13 14 class ViewCell; 14 class BspViewCell;15 //class BspViewCell; 15 16 class Plane3; 16 17 class VspBspTree; -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r468 r469 25 25 #include "Ray.h" 26 26 #include "RayInfo.h" 27 #include "ViewCell.h"28 27 #include "ViewCellsManager.h" 29 28 #include "ViewCellBsp.h" … … 1914 1913 Intersectable::NewMail(); 1915 1914 1916 //if (!mBox.GetMinMaxT(ray, &mint, &maxt)) return 0;1917 1918 if (mint < 0)1919 mint = 0;1920 1921 maxt += Limits::Threshold;1922 1923 1915 Vector3 entp = origin; 1924 1916 Vector3 extp = termination; … … 1985 1977 vc->Mail(); 1986 1978 viewcells.push_back(vc); 1979 ++ hits; 1987 1980 } 1988 1981 … … 2013 2006 leaf->SetViewCell(vc); 2014 2007 2015 vc->Set Size(GetBBox(leaf).GetVolume());2016 vc->m VspKdLeaves.push_back(leaf);2008 vc->SetVolume(GetBBox(leaf).GetVolume()); 2009 vc->mLeaves.push_back(leaf); 2017 2010 2018 2011 for (it = leaf->GetRays().begin(); it != it_end; ++ it) … … 2067 2060 vcStat.minPvs = pvsSize; 2068 2061 2069 if ((int)viewCell->m VspKdLeaves.size() > vcStat.maxLeaves)2070 vcStat.maxLeaves = (int)viewCell->m VspKdLeaves.size();2062 if ((int)viewCell->mLeaves.size() > vcStat.maxLeaves) 2063 vcStat.maxLeaves = (int)viewCell->mLeaves.size(); 2071 2064 } 2072 2065 } … … 2096 2089 2097 2090 // set new size of view cell 2098 vc->Set Size(fVc->GetSize() + bVc->GetSize());2099 2100 vector<VspKdLeaf *> fLeaves = fVc->m VspKdLeaves;2101 vector<VspKdLeaf *> bLeaves = bVc->m VspKdLeaves;2091 vc->SetVolume(fVc->GetVolume() + bVc->GetVolume()); 2092 2093 vector<VspKdLeaf *> fLeaves = fVc->mLeaves; 2094 vector<VspKdLeaf *> bLeaves = bVc->mLeaves; 2102 2095 2103 2096 vector<VspKdLeaf *>::const_iterator it; … … 2107 2100 { 2108 2101 (*it)->SetViewCell(vc); 2109 vc->m VspKdLeaves.push_back(*it);2102 vc->mLeaves.push_back(*it); 2110 2103 } 2111 2104 … … 2113 2106 { 2114 2107 (*it)->SetViewCell(vc); 2115 vc->m VspKdLeaves.push_back(*it);2108 vc->mLeaves.push_back(*it); 2116 2109 } 2117 2110 … … 2136 2129 2137 2130 int vcSize = (int)leaves.size(); 2131 int savedVcSize = vcSize; 2138 2132 2139 2133 VspKdLeaf::NewMail(); … … 2208 2202 ValidateViewCellLeaves(); 2209 2203 2210 2204 Debug << "merged " << merged << " of " << savedVcSize << " leaves" << endl; 2205 2206 //TODO: should return sample contributions 2211 2207 return merged; 2212 2208 } … … 2235 2231 { 2236 2232 Debug << "jhere2" << endl; 2237 viewCell->m VspKdLeaves.clear();2233 viewCell->mLeaves.clear(); 2238 2234 viewCell->Mail(); 2239 2235 } 2240 2236 2241 viewCell->m VspKdLeaves.push_back(leaf);2237 viewCell->mLeaves.push_back(leaf); 2242 2238 } 2243 2239 else … … 2318 2314 //-- to new rendering cost (size of merged view cell times pvs size) 2319 2315 const float oldCost = 2320 (float)vc1->GetPvs().GetSize() * vc1->Get Size() +2321 (float)vc2->GetPvs().GetSize() * vc2->Get Size();2316 (float)vc1->GetPvs().GetSize() * vc1->GetVolume() + 2317 (float)vc2->GetPvs().GetSize() * vc2->GetVolume(); 2322 2318 2323 2319 const float newCost = 2324 (float)vcPvs * (vc1->Get Size() + vc2->GetSize());2320 (float)vcPvs * (vc1->GetVolume() + vc2->GetVolume()); 2325 2321 2326 2322 mMergeCost = newCost - oldCost; -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.h
r468 r469 33 33 #include "RayInfo.h" 34 34 #include "Containers.h" 35 #include "ViewCell.h" 35 36 36 37 class VspKdLeaf; 37 38 class ViewCellsManager; 38 class VspKdViewCell;39 39 class ViewCellsStatistics; 40 40 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r468 r469 370 370 371 371 // sample city like heights 372 box->SetMin(1, box->Min(1) + box->Size(1)*0.2 );373 box->SetMax(1, box->Min(1) + box->Size(1)*0.3 );372 box->SetMin(1, box->Min(1) + box->Size(1)*0.2f); 373 box->SetMax(1, box->Min(1) + box->Size(1)*0.3f); 374 374 } 375 375 … … 439 439 440 440 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 441 cout << "#totalRayStackSize=" << mVssRays.size() << endl <<flush;441 cout << "#totalRayStackSize=" << (int)mVssRays.size() << endl <<flush; 442 442 443 443 //int numExportRays = 10000; -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.h
r439 r469 95 95 96 96 void CastRay(const BspTree &tree, const VssRay & vssRay); 97 98 int AddObjectSamples(Intersectable *obj, const Ray &ray);99 97 }; 100 98 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssTree.cpp
r466 r469 972 972 973 973 if ( (int)(leaf->rays.size()) > stat.maxRayRefs) 974 stat.maxRayRefs = leaf->rays.size();974 stat.maxRayRefs = (int)leaf->rays.size(); 975 975 976 976 } … … 1128 1128 1129 1129 // update stats 1130 stat.rayRefs -= leaf->rays.size();1130 stat.rayRefs -= (int)leaf->rays.size(); 1131 1131 stat.rayRefs += raysBack + raysFront; 1132 1132 … … 1717 1717 SimpleRayContainer &rays) 1718 1718 { 1719 int nrays = leaf->rays.size();1719 int nrays = (int)leaf->rays.size(); 1720 1720 for (int i=0; i < numberOfRays; i++) { 1721 1721 // pickup 3 random rays … … 1733 1733 leaf->rays[r3].GetMaxT())); 1734 1734 1735 const float overlap = 0.1 ;1735 const float overlap = 0.1f; 1736 1736 1737 1737 Vector3 origin, direction; … … 1789 1789 VssTreeLeaf *leaf = leaves[i]; 1790 1790 float c = leaf->GetImportance(); 1791 int num = ( c*ratioPerLeaf + 0.5);1791 int num = (int)(c*ratioPerLeaf + 0.5f); 1792 1792 GenerateLeafRays(leaf, num, rays); 1793 1793 } 1794 1794 1795 return rays.size();1795 return (int)rays.size(); 1796 1796 } 1797 1797 -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r465 r469 698 698 bool X3dExporter::ExportVspKdTreeViewCell(const VspKdTree &tree, const VspKdViewCell &vc) 699 699 { 700 vector<VspKdLeaf *>::const_iterator it, it_end = vc.m VspKdLeaves.end();701 702 for (it = vc.m VspKdLeaves.begin(); it != it_end; ++ it)700 vector<VspKdLeaf *>::const_iterator it, it_end = vc.mLeaves.end(); 701 702 for (it = vc.mLeaves.begin(); it != it_end; ++ it) 703 703 ExportBox(tree.GetBBox(*it)); 704 704 -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.h
r462 r469 11 11 #include "Containers.h" 12 12 #include "VssRay.h" 13 #include "ViewCell.h" 13 14 14 15 class SceneGraphNode; … … 21 22 class VspBspTree; 22 23 class BspNode; 23 class VspKdViewCell;24 //class VspKdViewCell; 24 25 25 26 -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dParser.cpp
r439 r469 170 170 char *endptr; 171 171 while(1) { 172 float x = strtod(ptr, &endptr);172 float x = (float)strtod(ptr, &endptr); 173 173 if (ptr == endptr) 174 174 break; 175 175 ptr = endptr; 176 float y = strtod(ptr, &endptr);176 float y = (float)strtod(ptr, &endptr); 177 177 if (ptr == endptr) 178 178 break; 179 179 ptr = endptr; 180 float z = strtod(ptr, &endptr);180 float z = (float)strtod(ptr, &endptr); 181 181 if (ptr == endptr) 182 182 break; … … 477 477 while (1) 478 478 { 479 float x = strtod(ptr, &endptr);479 float x = (float)strtod(ptr, &endptr); 480 480 481 481 if (ptr == endptr) … … 483 483 ptr = endptr; 484 484 485 float y = (float) strtod(ptr, &endptr);485 float y = (float)(float)strtod(ptr, &endptr); 486 486 487 487 … … 490 490 ptr = endptr; 491 491 492 float z = (float) strtod(ptr, &endptr);492 float z = (float)(float)strtod(ptr, &endptr); 493 493 494 494 if (ptr == endptr)
Note: See TracChangeset
for help on using the changeset viewer.