Changeset 469


Ignore:
Timestamp:
12/16/05 18:52:33 (18 years ago)
Author:
mattausch
Message:

updated view cells, view cell manager. changed rendersimulator

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/Preprocessor.vcproj

    r468 r469  
    410410                        </File> 
    411411                </Filter> 
     412                <File 
     413                        RelativePath=".\VTune\Preprocessor.vpj"> 
     414                </File> 
    412415        </Files> 
    413416        <Globals> 
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r465 r469  
    265265                # x3d visualization of the split planes 
    266266                exportSplits true 
     267                exportRays true 
     268                exportGeometry false 
    267269        } 
    268270} 
     
    303305                minViewCells 100 
    304306                maxPvsSize   50000 
     307        } 
     308         
     309         
     310        Visualization { 
     311                exportRays true 
     312                exportGeometry false 
    305313        } 
    306314} 
     
    366374                # x3d visualization of the split planes 
    367375                exportSplits true 
    368         } 
    369 } 
     376                exportRays true 
     377                exportGeometry false 
     378        } 
     379} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp

    r463 r469  
    679679  Vector3 ext = mMax - mMin; 
    680680  
    681   return 2.0 * (ext.x * ext.y + 
     681  return 2.0f * (ext.x * ext.y + 
    682682                ext.x * ext.z + 
    683683                ext.y * ext.z); 
     
    10561056  if (y < 0.0) { 
    10571057    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) 
    10591059    else 
    10601060      return c * (y / x); // for angle in <-PI/4 , 0> 
     
    10621062  else { 
    10631063    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> 
    10651065    else 
    10661066      return c * (y / x); // for angle in <0, PI/2> 
     
    11071107    //  FATAL_ABORT; 
    11081108    //} 
    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)); 
    11111111  } 
    11121112 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Camera.h

    r386 r469  
    2424    mWidth = 640; 
    2525    mHeight = 480; 
    26     mFovy = 60.0*M_PI/180.0; 
     26    mFovy = 60.0f*(float)M_PI/180.0f; 
    2727  } 
    2828   
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r465 r469  
    11501150                 "10"); 
    11511151 
    1152         RegisterOption("VssPreprocessor.initialSamples", 
    1153                                                                 optInt, 
    1154                                                                 "-initial_samples=", 
    1155                                                                 "100000"); 
    1156  
    1157         RegisterOption("VssPreprocessor.vssSamples", 
    1158                                                                 optInt, 
    1159                                                                 "-vss_samples=", 
    1160                                                                 "1000000"); 
     1152  RegisterOption("VssPreprocessor.initialSamples", 
     1153          optInt, 
     1154          "-initial_samples=", 
     1155          "100000"); 
     1156 
     1157  RegisterOption("VssPreprocessor.vssSamples", 
     1158          optInt, 
     1159          "-vss_samples=", 
     1160          "1000000"); 
    11611161         
    11621162  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 
    11711172 
    11721173  RegisterOption("VssPreprocessor.useImportanceSampling", 
    1173                                                                 optBool, 
    1174                                                                 "-vss_use_importance=", 
    1175                                                                 "true"); 
     1174          optBool, 
     1175          "-vss_use_importance=", 
     1176          "true"); 
    11761177 
    11771178 
     
    13661367  RegisterOption("BspTree.Visualization.exportSplits", 
    13671368          optBool, 
    1368           "-bsp_visualization.exportSplits", 
     1369          "-bsp_visualization.export_splits", 
    13691370          "false"); 
    13701371 
    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", 
    13861397                                 optString, 
    13871398                                 "-preprocessor=", 
     
    13891400 
    13901401 
    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",  
    14011455                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",  
    14641460                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=",  
    14661477                "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"); 
    15331555 
    15341556        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        ////////////////////////////////////////////////////////////////////////////////// 
    17091745} 
    17101746 
  • trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp

    r466 r469  
    55#include "Mesh.h" 
    66#include "KdTree.h" 
    7  
     7#include "ViewCell.h" 
    88 
    99int KdNode::mailID = 1; 
     
    209209   
    210210  if (TerminationCriteriaMet(leaf)) 
    211     return leaf; 
    212    
     211          return leaf; 
     212 
    213213  float position; 
    214214   
     
    277277      back->mObjects.push_back(*mi); 
    278278     
    279     mStat.objectRefs -= leaf->mObjects.size(); 
     279    mStat.objectRefs -= (int)leaf->mObjects.size(); 
    280280    mStat.objectRefs += objectsBack + objectsFront; 
    281281  } 
     
    362362   
    363363  if ( (int)(leaf->mObjects.size()) > mStat.maxObjectRefs) 
    364     mStat.maxObjectRefs = leaf->mObjects.size(); 
     364    mStat.maxObjectRefs = (int)leaf->mObjects.size(); 
    365365   
    366366} 
     
    376376  splitCandidates->clear(); 
    377377   
    378   int requestedSize = 2*node->mObjects.size(); 
     378  int requestedSize = 2*(int)node->mObjects.size(); 
    379379  // creates a sorted split candidates array 
    380380  if (splitCandidates->capacity() > 500000 && 
     
    438438  float intersectionsRight = totalIntersections; 
    439439         
    440   int objectsLeft = 0, objectsRight = node->mObjects.size(); 
     440  int objectsLeft = 0, objectsRight = (int)node->mObjects.size(); 
    441441   
    442442  float minBox = box.Min(axis); 
     
    447447  float maxBand = minBox + (1.0f - mSplitBorder)*(maxBox - minBox); 
    448448   
    449   float minSum = 1e20; 
     449  float minSum = 1e20f; 
    450450   
    451451  for(ci = splitCandidates->begin(); 
     
    606606} 
    607607 
     608int 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 
    608712void 
    609713KdTree::CollectObjects(KdNode *n, ObjectContainer &objects) 
     
    706810  } 
    707811   
    708   return neighbors.size(); 
     812  return (int)neighbors.size(); 
    709813} 
    710814 
     
    768872} 
    769873 
     874void 
     875KdTree::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} 
    770895 
    771896int 
  • trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.h

    r407 r469  
    99#include "Ray.h" 
    1010#include "Pvs.h" 
    11  
     11#include "Viewcell.h" 
    1212   
    1313class KdNode; 
     
    1515class KdInterior; 
    1616class Intersectable; 
    17  
     17//class KdViewCell; 
    1818 
    1919// -------------------------------------------------------------- 
     
    157157class KdLeaf : public KdNode { 
    158158public: 
    159   KdLeaf(KdInterior *parent, const int objects):KdNode(parent) { 
     159  KdLeaf(KdInterior *parent, const int objects): 
     160          KdNode(parent), mViewCell(NULL) { 
    160161    mObjects.reserve(objects); 
    161162  } 
    162163   
    163   void AddPassingRay(const Ray &ray, 
    164                                                                                  const int contributions) { 
     164  void AddPassingRay(const Ray &ray, const int contributions) { 
    165165    mPassingRays.AddRay(ray, contributions); 
    166166                //              Debug << "adding passing ray" << endl; 
     
    169169         
    170170        void AddPassingRay2(const Ray &ray, 
    171                                                                                         const int objects, 
    172                                                                                         const int viewcells 
    173                                                                                         ) { 
     171                                                const int objects, 
     172                                                const int viewcells 
     173                                                ) { 
    174174    mPassingRays.AddRay2(ray, objects, viewcells); 
    175175                //              Debug << "adding passing ray" << endl; 
     
    183183  ObjectContainer mObjects; 
    184184   
    185   /** pointers to viewcells contained in this node */ 
    186   //  ViewCellContainer mViewCells; 
    187  
    188185  /** Ray set description of the rays passing through this node */ 
    189186  PassingRaySet mPassingRays; 
     
    192189  KdPvs mKdPvs; 
    193190         
    194         /** PVS consisting of visible objects */ 
    195   ViewCellPvs mPvs; 
     191  /** pointer to view cell. 
     192  */ 
     193  KdViewCell *mViewCell; 
    196194}; 
    197195 
     
    287285          ); 
    288286 
     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 
    289296  const KdTreeStatistics &GetStatistics() const { 
    290297    return mStat; 
     
    297304  CollectLeaves(vector<KdLeaf *> &leaves); 
    298305         
     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 
    299313  AxisAlignedBox3 GetBox(const KdNode *node) const { 
    300314    KdInterior *parent = node->mParent; 
     
    315329  KdNode * 
    316330  FindRandomNeighbor(KdNode *n, 
    317                                                                                 bool onlyUnmailed 
    318                                                                                 ); 
     331                                        bool onlyUnmailed 
     332                                        ); 
    319333   
    320334  KdNode * 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Mesh.cpp

    r444 r469  
    234234 
    235235 
    236   int size = face->mVertexIndices.size(); 
     236  int size = (int)face->mVertexIndices.size(); 
    237237 
    238238  mVertices[face->mVertexIndices[size - 1]]. 
     
    430430Mesh::AddTriangle(const Triangle3 &triangle) 
    431431{ 
    432   int index = mVertices.size(); 
     432  int index = (int)mVertices.size(); 
    433433 
    434434  for (int i=0; i < 3; i++) { 
     
    442442Mesh::AddRectangle(const Rectangle3 &rect) 
    443443{ 
    444   int index = mVertices.size(); 
     444  int index = (int)mVertices.size(); 
    445445 
    446446  for (int i=0; i < 4; i++) { 
  • trunk/VUT/GtpVisibilityPreprocessor/src/MeshKdTree.cpp

    r376 r469  
    181181  mSplitCandidates->clear(); 
    182182   
    183   int requestedSize = 2*node->mFaces.size(); 
     183  int requestedSize = 2*(int)node->mFaces.size(); 
    184184  // creates a sorted split candidates array 
    185185  if (mSplitCandidates->capacity() > 500000 && 
     
    232232  // C = ct_div_ci  + (ol + or)/queries 
    233233 
    234   int objectsLeft = 0, objectsRight = node->mFaces.size(); 
     234  int objectsLeft = 0, objectsRight = (int)node->mFaces.size(); 
    235235   
    236236  float minBox = box.Min(axis); 
     
    241241  float maxBand = minBox + (1.0f - mSplitBorder)*(maxBox - minBox); 
    242242   
    243   float minSum = 1e20; 
     243  float minSum = 1e20f; 
    244244  vector<SortableEntry>::const_iterator ci; 
    245245 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp

    r463 r469  
    1010#include "VspBspTree.h" 
    1111#include "VspKdTree.h" 
     12#include "RenderSimulator.h" 
    1213 
    1314Preprocessor::Preprocessor(): 
     
    3738 
    3839        while(1) { 
    39                 int npos = str.find(';', pos); 
     40                int npos = (int)str.find(';', pos); 
    4041                 
    4142                if (npos < 0 || npos - pos < 1) 
     
    175176        int constructionSamples = 0; 
    176177 
     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         
    177186        if (strcmp(viewCellsStr, "kdTree") == 0) 
    178187        { 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.cpp

    r311 r469  
    11#include <iostream> 
    22#include "Pvs.h" 
    3  
    4 using namespace std; 
    5  
    6  
    73 
    84int 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h

    r466 r469  
    33 
    44#include <map> 
     5#include <vector> 
    56 
    67class KdNode; 
     
    1819}; 
    1920 
    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*/ 
    2124 
    2225template<typename T>  
     
    2730}; 
    2831 
     32/** Template class representing the Potentially Visible Set (PVS)  
     33        mainly from a view cell, but also e.g., from objects. 
     34*/ 
    2935template<typename T> 
    3036class Pvs 
    3137{ 
    3238public: 
    33   Pvs(): mSamples(0), mEntries() {} 
     39  Pvs(): /*mSamples(0), */mEntries() {} 
    3440   
    35   int mSamples; 
     41  //int mSamples; 
    3642   
     43  /** Compresses PVS lossless or lossy. 
     44  */ 
    3745  int Compress() {return 0;} 
    3846  int GetSize() const {return (int)mEntries.size();} 
    39   bool Empty() const {return mEntries.size() == 0;} 
     47  bool Empty() const {return mEntries.empty();} 
     48   
    4049  /** Merges pvs of a and pvs of b into this pvs. 
    4150   */ 
    4251  void Merge(const Pvs<T> &a, const Pvs<T> &b); 
     52   
    4353  /** Difference of pvs to pvs b. 
    4454          @returns number of different entries. 
     
    4656  int Diff(const Pvs<T> &b); 
    4757   
     58  /** Finds sample in PVS. 
     59          @returns sample if found, NULL otherwise. 
     60  */ 
    4861  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  */ 
    4967  bool AddSample(T sample, float &contribution); 
     68 
     69  /** Adds sample to PVS. 
     70          @returns contribution of sample (0 or 1) 
     71  */ 
    5072  int AddSample(T sample); 
    5173 
     74  /** Returns PVS data, i.e., how often it was seen from the view cell,  
     75          and the object itsef. 
     76  */ 
    5277  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 
    5384  std::map<T, PvsData<T>, LtSample<T> > mEntries; 
    5485}; 
     
    138169} 
    139170 
     171template <typename T> 
     172void 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 
    140181/** Class instantiating the Pvs template for kd tree nodes. 
    141182*/ 
     
    146187 
    147188typedef 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; 
     189typedef std::map<Intersectable *, PvsData<Intersectable *>, LtSample<Intersectable *> > ObjectPvsMap; 
     190typedef PvsData<Intersectable *> ObjectPvsData; 
    151191typedef PvsData<KdNode *> KdPvsData; 
    152 typedef Pvs<ViewCellKdNode *> ViewCellKdPvs; 
    153 typedef Pvs<Intersectable *> ViewCellPvs; 
     192 
     193typedef Pvs<Intersectable *> ObjectPvs; 
    154194 
    155195 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp

    r468 r469  
    412412        box->Enlarge(box->Size()*Vector3(-s)); 
    413413        //      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); 
    415415        box->SetMin(box->Min() + translation); 
    416416        box->SetMax(box->Max() + translation); 
    417417 
    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); 
    420420 
    421421         
     
    425425        float m = box->Min(1); 
    426426        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); 
    429429  } 
    430430 
     
    489489   
    490490  cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
    491   cout << "#totalRayStackSize=" << mVssRays.size() << endl <<flush; 
     491  cout << "#totalRayStackSize=" << (int)mVssRays.size() << endl <<flush; 
    492492   
    493493 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.h

    r466 r469  
    327327  virtual void Print(ostream &s) const { 
    328328    s<< 
    329           "L: rays="<<rays.size()<< 
     329          "L: rays="<<(int)rays.size()<< 
    330330          " pvs="<<mPvsSize<<" pEntropy="<<mPvsEntropy<<" lEntropy="<<mRayLengthEntropy<<endl; 
    331331  }; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r468 r469  
    7575{ 
    7676        // 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; 
    8183} 
    8284 
     
    149151                // pickup a random face of each mesh  
    150152                Mesh *mesh = mi->GetMesh(); 
    151                 int face = RandomValue(0, mesh->mFaces.size()-1); 
     153                int face = (int)Random((int)mesh->mFaces.size()); 
    152154                 
    153155                Polygon3 poly(mesh->mFaces[face], mesh); 
    154                 poly.Scale(1.001); 
     156                poly.Scale(1.001f); 
    155157                // now extend a random edge of the face 
    156                 int edge = RandomValue(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); 
    158160                Vector3 target = t*poly.mVertices[edge] + (1.0f-t)*poly.mVertices[(edge + 1)% 
    159161                        poly.mVertices.size()]; 
     
    190192                Debug << "Finding random neighbour" << endl;     
    191193                for (int tries = 0; tries < 10; tries++) { 
    192                         int index = RandomValue(0, pvsSize - 1); 
     194                        int index = Random(pvsSize); 
    193195                        KdPvsData data; 
    194196                        KdNode *node; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h

    r466 r469  
    7575                                                  int &contributingSamples); 
    7676 
    77         /** Adds objects samples to kd and bsp view cells. 
    78         */ 
    79         int AddObjectSamples(Intersectable *obj, const Ray &ray); 
    80  
    8177        /** 
    8278                Returns random node as target for the current sample ray. 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Statistics.h

    r374 r469  
    3434 
    3535  float Time() const { 
    36     return TimeDiff(startTime, stopTime); 
     36    return (float)TimeDiff(startTime, stopTime); 
    3737  } 
    3838}; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp

    r463 r469  
    1515} 
    1616 
    17 const ViewCellPvs &ViewCell::GetPvs() const 
     17const ObjectPvs &ViewCell::GetPvs() const 
    1818{ 
    1919        return mPvs; 
    2020} 
    2121 
    22 ViewCellPvs &ViewCell::GetPvs() 
     22ObjectPvs &ViewCell::GetPvs() 
    2323{ 
    2424        return mPvs; 
     
    3333{ 
    3434        mPassingRays.AddRay(ray, contributions); 
     35} 
     36 
     37float ViewCell::GetVolume() const 
     38{ 
     39        return mVolume; 
     40} 
     41 
     42void ViewCell::SetVolume(float volume)  
     43{ 
     44        mVolume = volume; 
    3545} 
    3646 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h

    r463 r469  
    77#include "Statistics.h" 
    88//namespace GtpVisibilityPreprocessor { 
    9    
     9 
     10struct Triangle3; 
     11 
    1012class BspInterior; 
    1113class BspPvs; 
    12 struct Triangle3; 
    1314class BspLeaf; 
    1415class VspKdTree; 
    1516class VspKdLeaf; 
    16  
     17class KdLeaf; 
    1718 
    1819/** 
     
    2829        ViewCell(Mesh *mesh); 
    2930 
    30  
     31        /** Default destructor. 
     32        */ 
    3133        virtual ~ViewCell() {} 
    3234        /** Returns Pvs.  
    3335        */ 
    34         const ViewCellPvs &GetPvs() const; 
    35         ViewCellPvs &GetPvs(); 
     36        const ObjectPvs &GetPvs() const; 
     37        ObjectPvs &GetPvs(); 
    3638 
    3739        int Type() const; 
     
    4143        void AddPassingRay(const Ray &ray, const int contributions);     
    4244 
     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); 
    4352 
    4453        /// Ray set description of the rays passing through this node.   
     
    5160 
    5261        /// the potentially visible objects 
    53         ViewCellPvs mPvs; 
     62        ObjectPvs mPvs; 
     63 
     64        float mVolume; 
    5465}; 
    5566 
    56 class BspViewCell: public ViewCell 
     67/** 
     68        View cell belonging to a hierarchy. 
     69*/ 
     70template<typename T> 
     71class HierarchyViewCell: public ViewCell 
     72{ 
     73public: 
     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 
     82typedef HierarchyViewCell<BspLeaf *> BspViewCell; 
     83typedef HierarchyViewCell<KdLeaf *> KdViewCell; 
     84typedef HierarchyViewCell<VspKdLeaf *> VspKdViewCell; 
     85 
     86/*class BspViewCell: public ViewCell 
    5787{ 
    5888public: 
    5989        BspViewCell(): mBspLeaves(0) {} 
    6090        BspViewCell(Mesh *mesh):  
    61         ViewCell(mesh), mBspLeaves(0) {} 
     91                ViewCell(mesh), mBspLeaves(0) {} 
    6292 
    63         /// Leaves which hold this view cell. 
    64         vector<BspLeaf *> mBspLeaves; 
     93        /// Leaves of the hierarchy which are part of this view cell. 
     94        std::vector<BspLeaf *> mBspLeaves; 
    6595}; 
    66  
    67 class VspKdViewCell: public ViewCell 
     96*/ 
     97/*class VspKdViewCell: public ViewCell 
    6898{ 
    6999public: 
    70         VspKdViewCell(): mVspKdLeaves(0) {} 
     100        VspKdViewCell(): mLeaves(0) {} 
    71101        VspKdViewCell(Mesh *mesh):  
    72         ViewCell(mesh), mVspKdLeaves(0) {} 
     102                ViewCell(mesh), mLeaves(0) {} 
    73103 
    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; 
    82106}; 
    83  
     107*/ 
    84108class ViewCellsStatistics: public StatisticsBase 
    85109{ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r468 r469  
    776776 
    777777                leaf->SetViewCell(viewCell); 
    778                 viewCell->mBspLeaves.push_back(leaf); 
     778                viewCell->mLeaves.push_back(leaf); 
    779779 
    780780                //-- add pvs 
     
    20362036                                        vcStat.minPvs = pvsSize; 
    20372037 
    2038                                 if ((int)viewCell->mBspLeaves.size() > vcStat.maxLeaves) 
    2039                                         vcStat.maxLeaves = (int)viewCell->mBspLeaves.size();             
     2038                                if ((int)viewCell->mLeaves.size() > vcStat.maxLeaves) 
     2039                                        vcStat.maxLeaves = (int)viewCell->mLeaves.size();                
    20402040                        } 
    20412041                } 
     
    21762176void BspTree::ConstructGeometry(BspViewCell *vc, PolygonContainer &cell) const 
    21772177{ 
    2178         vector<BspLeaf *> leaves = vc->mBspLeaves; 
     2178        vector<BspLeaf *> leaves = vc->mLeaves; 
    21792179 
    21802180        vector<BspLeaf *>::const_iterator it, it_end = leaves.end(); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r466 r469  
    88#include "Statistics.h" 
    99#include "VssRay.h" 
    10  
     10#include "ViewCell.h" 
    1111 
    1212class ViewCell; 
    13 class BspViewCell; 
     13//class BspViewCell; 
    1414class Plane3; 
    1515class BspTree;   
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r468 r469  
    4040{ 
    4141        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); 
    5544} 
    5645 
     
    6756} 
    6857 
    69 void 
    70 ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays 
    71                                                                                          ) 
    72 { 
    73   // view cells not yet constructed 
    74   if (!ViewCellsConstructed()) 
    75         return; 
     58void ViewCellsManager::ComputeSampleContributions(const VssRayContainer &rays) 
     59{ 
     60        // view cells not yet constructed 
     61        if (!ViewCellsConstructed()) 
     62                return; 
    7663   
    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        } 
    8170} 
    8271 
     
    271260 
    272261 
     262void 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 
    273279/**********************************************************************/ 
    274280/*                   BspViewCellsManager implementation               */ 
    275281/**********************************************************************/ 
    276282 
    277 BspViewCellsManager::BspViewCellsManager(BspTree *bspTree, int constructionSamples): 
     283BspViewCellsManager::BspViewCellsManager(BspTree *bspTree,  
     284                                                                                 int constructionSamples): 
    278285ViewCellsManager(constructionSamples),  
    279286mBspTree(bspTree) 
     
    281288} 
    282289 
    283  
    284 BspViewCellsManager::~BspViewCellsManager() 
    285 { 
    286         ViewCellContainer vc; 
    287         mBspTree->CollectViewCells(vc); 
    288  
    289         CLEAR_CONTAINER(vc); 
    290 } 
    291290 
    292291bool BspViewCellsManager::ViewCellsConstructed() const 
     
    310309        int sampleContributions = 0; 
    311310         
    312         RayContainer sampleRays; 
    313  
    314         int limit = min (mConstructionSamples, (int)rays.size()); 
    315  
    316311        // 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 
    330343        Debug << mBspTree->GetStatistics() << endl; 
    331344         
     345        // recast rest of the rays 
     346        ComputeSampleContributions(savedRays); 
     347 
    332348        return sampleContributions; 
    333349} 
    334350 
    335351 
    336 float BspViewCellsManager::GetProbability(ViewCell *viewCell) 
     352float BspViewCellsManager::GetProbability(ViewCell *viewCell) const 
    337353{ 
    338354        PolygonContainer geom; 
     
    350366 
    351367 
    352 float BspViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) 
     368float BspViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 
    353369{ 
    354370        return viewCell->GetPvs().GetSize() * objRendercost; 
     
    367383                                                                         const VssRayContainer &rays) 
    368384{ 
    369   if (!ViewCellsConstructed()) 
     385        if (!ViewCellsConstructed()) 
    370386        { 
    371387                Debug << "view cells not constructed" << endl; 
     
    484500                                                                        const VssRayContainer &sampleRays) 
    485501{ 
    486   if (!ViewCellsConstructed()) 
    487         return; 
     502        if (!ViewCellsConstructed()) 
     503                return; 
    488504   
    489   //-- recount pvs 
    490   ViewCellsStatistics vcStats; 
    491   mBspTree->EvaluateViewCellsStats(vcStats); 
     505        //-- recount pvs 
     506        ViewCellsStatistics vcStats; 
     507        mBspTree->EvaluateViewCellsStats(vcStats); 
    492508   
    493   if (1) // export view cells 
    494         { 
    495           cout << "exporting view cells after merge ... "; 
    496           Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d"); 
     509        if (1) // export view cells 
     510        { 
     511                cout << "exporting view cells after merge ... "; 
     512                Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d"); 
    497513           
    498           if (exporter) 
     514                if (exporter) 
    499515                { 
    500                   exporter->ExportBspViewCellPartition(*mBspTree, vcStats.maxPvs); 
    501                   //exporter->ExportBspViewCellPartition(*mBspTree, 0); 
    502                   delete exporter; 
     516                        exporter->ExportBspViewCellPartition(*mBspTree, vcStats.maxPvs); 
     517                        //exporter->ExportBspViewCellPartition(*mBspTree, 0); 
     518                        delete exporter; 
    503519                } 
    504520           
    505           cout << "finished" << endl; 
     521                cout << "finished" << endl; 
    506522        }        
    507523   
    508   //-- visualization of the BSP splits 
    509   bool exportSplits = false; 
    510   environment->GetBoolValue("BspTree.Visualization.exportSplits", exportSplits); 
     524        //-- visualization of the BSP splits 
     525        bool exportSplits = false; 
     526        environment->GetBoolValue("BspTree.Visualization.exportSplits", exportSplits); 
    511527   
    512   if (exportSplits) 
    513         { 
    514           cout << "exporting splits ... "; 
    515           ExportSplits(objects, sampleRays); 
    516           cout << "finished" << endl; 
     528        if (exportSplits) 
     529        { 
     530                cout << "exporting splits ... "; 
     531                ExportSplits(objects, sampleRays); 
     532                cout << "finished" << endl; 
    517533        } 
    518534   
    519   ExportBspPvs(objects, sampleRays); 
     535        ExportBspPvs(objects, sampleRays); 
    520536} 
    521537 
     
    546562                exporter->ResetForcedMaterial(); 
    547563                 
     564                bool exportRays = false; 
     565                bool exportGeometry = false; 
     566 
     567                environment->GetBoolValue("BspViewCellsManager.Visualization.exportRays", exportRays); 
     568                environment->GetBoolValue("BspViewCellsManager.Visualization.exportGeometry", exportGeometry); 
     569 
    548570                // export rays 
    549                 if (0) 
     571                if (exportRays) 
    550572                { 
    551                   VssRayContainer outRays; 
     573                        VssRayContainer outRays; 
    552574                   
    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) 
    556577                        { 
    557                           // only rays piercing geometry 
    558                           outRays.push_back(sampleRays[i]); 
     578                                // only rays piercing geometry 
     579                                outRays.push_back(sampleRays[i]);                        
    559580                        } 
    560                    
    561                   // export rays  
    562                   exporter->ExportRays(outRays, RgbColor(1, 1, 0)); 
     581                         
     582                        // export rays  
     583                        exporter->ExportRays(outRays, RgbColor(1, 1, 0)); 
    563584                } 
    564585                 
    565                 if (0) 
    566                   exporter->ExportGeometry(objects); 
     586                if (exportGeometry) 
     587                        exporter->ExportGeometry(objects); 
    567588                 
    568589                delete exporter; 
     
    581602  Debug << "visualization using " << raysOut << " samples" << endl; 
    582603 
    583   //$$ JB 
    584 #if 0 
    585  
    586604  if (1) 
    587         { 
     605  { 
    588606          //-- some random view cells and rays for output 
    589607          vector<BspLeaf *> bspLeaves; 
    590608           
    591609          for (int i = 0; i < leafOut; ++ i) 
    592                 bspLeaves.push_back(mBspTree->GetRandomLeaf());  
     610                  bspLeaves.push_back(mBspTree->GetRandomLeaf());        
    593611 
    594612           
    595613          for (int i = 0; i < bspLeaves.size(); ++ i) 
    596                 { 
     614          { 
    597615                  BspLeaf *leaf = bspLeaves[i]; 
    598                    
    599616                  RayContainer vcRays; 
    600617                   
    601618                  cout << "creating output for view cell " << i << " ... "; 
    602619                   
     620                  // TODO matt 
    603621                  // 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                  { 
    606624                          Ray *ray = sampleRays[k]; 
    607625                           
    608                           for   (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 
    609                                 { 
     626                          for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 
     627                          { 
    610628                                  BspLeaf *leaf2 = ray->bspIntersections[j].mLeaf; 
    611629                                   
    612630                                  if (leaf->GetViewCell() == leaf2->GetViewCell())  
    613                                         { 
     631                                  { 
    614632                                          vcRays.push_back(ray); 
    615                                         } 
    616                                 } 
    617                         } 
     633                                  } 
     634                          } 
     635                  }*/ 
    618636                   
    619637                  Intersectable::NewMail(); 
     
    635653                   
    636654                  if (vc->GetMesh()) 
    637                         exporter->ExportViewCell(vc); 
     655                          exporter->ExportViewCell(vc); 
    638656                  else 
    639                         { 
     657                  { 
    640658                          PolygonContainer vcGeom; 
    641659                          // export view cell geometry 
    642660                          mBspTree->ConstructGeometry(vc, vcGeom); 
    643661                          exporter->ExportPolygons(vcGeom); 
    644                                 CLEAR_CONTAINER(vcGeom); 
    645                         } 
    646                    
     662                          CLEAR_CONTAINER(vcGeom); 
     663                  }                
     664 
    647665                  Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize()  
    648666                                << ", piercing rays=" << (int)vcRays.size() << endl; 
    649667                   
    650668                  // export rays piercing this view cell 
    651                   exporter->ExportRays(vcRays, 1000, RgbColor(0, 1, 0));         
     669                  //exporter->ExportRays(vcRays, 1000, RgbColor(0, 1, 0));       
    652670                   
    653671                  m.mDiffuseColor = RgbColor(1, 0, 0); 
     
    657675                  exporter->SetFilled(); 
    658676                   
    659                   ViewCellPvsMap::iterator it, it_end = vc->GetPvs().mEntries.end(); 
     677                  ObjectPvsMap::iterator it, it_end = vc->GetPvs().mEntries.end(); 
    660678                  // output PVS of view cell 
    661679                  for (it = vc->GetPvs().mEntries.begin(); it !=  it_end; ++ it)  
    662                         { 
     680                  { 
    663681                          Intersectable *intersect = (*it).first; 
    664682                          if (!intersect->Mailed()) 
    665                                 { 
     683                          { 
    666684                                  exporter->ExportIntersectable(intersect); 
    667685                                  intersect->Mail(); 
    668                                 }                        
    669                         } 
     686                          }                      
     687                  } 
    670688                   
    671689                  DEL_PTR(exporter); 
    672690                  cout << "finished" << endl; 
    673                 } 
    674         } 
     691          } 
     692  } 
    675693  else 
    676         { 
     694  { 
    677695          ViewCellContainer viewCells; 
    678696          RayContainer vcRays; 
     
    681699          stable_sort(viewCells.begin(), viewCells.end(), vc_gt); 
    682700           
    683           int limit = min(leafOut, (int)viewCells.size());  
     701          const int limit = min(leafOut, (int)viewCells.size());  
    684702           
    685703          for (int i = 0; i < limit; ++ i) 
    686                 { 
     704          { 
    687705                  cout << "creating output for view cell " << i << " ... "; 
    688706                         
    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                  } 
    759773                                 
    760                         DEL_PTR(exporter); 
    761                         cout << "finished" << endl; 
    762                 } 
    763         } 
    764 #endif 
     774                  DEL_PTR(exporter); 
     775                  cout << "finished" << endl; 
     776          } 
     777  } 
    765778} 
    766779 
     
    778791        BspViewCell *bVc = back->GetViewCell(); 
    779792 
    780         vector<BspLeaf *> fLeaves = fVc->mBspLeaves; 
    781         vector<BspLeaf *> bLeaves = bVc->mBspLeaves; 
     793        vector<BspLeaf *> fLeaves = fVc->mLeaves; 
     794        vector<BspLeaf *> bLeaves = bVc->mLeaves; 
    782795 
    783796        vector<BspLeaf *>::const_iterator it; 
     
    786799        { 
    787800                (*it)->SetViewCell(viewCell); 
    788                 viewCell->mBspLeaves.push_back(*it); 
     801                viewCell->mLeaves.push_back(*it); 
    789802        } 
    790803        for (it = bLeaves.begin(); it != bLeaves.end(); ++ it) 
    791804        { 
    792805                (*it)->SetViewCell(viewCell); 
    793                 viewCell->mBspLeaves.push_back(*it); 
     806                viewCell->mLeaves.push_back(*it); 
    794807        } 
    795808         
     
    836849 
    837850KdViewCellsManager::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; 
     851ViewCellsManager(), mKdTree(kdTree), mKdPvsDepth(100) 
     852{ 
     853} 
     854 
     855float 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 
     865float KdViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 
     866{ 
     867        return viewCell->GetPvs().GetSize() * objRendercost; 
    853868} 
    854869 
     
    861876                return 0; 
    862877 
    863         Debug << "Constructing bsp view cells" << endl; 
    864          
    865878        mKdTree->Construct(); 
     879 
     880        // create the view cells 
     881        mKdTree->CreateAndCollectViewCells(mViewCells); 
    866882 
    867883        return 0; 
     
    885901                return; 
    886902 
     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()); 
    887908        const int pvsOut = min((int)objects.size(), 10); 
    888  
    889         int limit = min(mVisualizationSamples, (int)sampleRays.size()); 
    890  
    891909        VssRayContainer *rays = new VssRayContainer[pvsOut]; 
    892910 
    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) 
    899931                { 
    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)  
    901939                        { 
    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                                } 
    9031016                        } 
    9041017                } 
    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)  
    9391020                { 
    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; 
    9431032                } 
    9441033 
    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 
    9601074 
    9611075int KdViewCellsManager::GetType() const 
     
    9811095 
    9821096 
    983 int 
    984 KdViewCellsManager::CastLineSegment(const Vector3 &origin, 
    985                                                                         const Vector3 &termination, 
    986                                                                         ViewCellContainer &viewcells 
    987                                                                         ) 
    988 { 
    989  
    990   return 0; 
    991 } 
     1097int KdViewCellsManager::CastLineSegment(const Vector3 &origin, 
     1098                                                                                const Vector3 &termination, 
     1099                                                                                ViewCellContainer &viewcells) 
     1100{ 
     1101        return mKdTree->CastLineSegment(origin, termination, viewcells); 
     1102} 
     1103 
     1104 
    9921105 
    9931106/**********************************************************************/ 
     
    10031116} 
    10041117 
    1005 float VspKdViewCellsManager::GetProbability(ViewCell *viewCell) 
    1006 { 
    1007         /*AxisAlignedBox3 box = mKdTree->GetBox(*it); 
     1118float VspKdViewCellsManager::GetProbability(ViewCell *viewCell) const 
     1119{ 
     1120/*      AxisAlignedBox3 box = mKdTree->GetBox(*it); 
    10081121                         
    10091122        // volume or area substitutes for view point probability 
     
    10111124                return box.GetVolume();  
    10121125        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 
     1132float VspKdViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 
     1133{ 
     1134        return viewCell->GetPvs().GetSize() * objRendercost; 
    10301135} 
    10311136 
     
    10391144                return 0; 
    10401145                 
    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); 
    10501158 
    10511159        Debug << mVspKdTree->GetStatistics() << endl; 
    10521160 
    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; 
    10541168} 
    10551169 
     
    10711185                return 0; 
    10721186 
    1073         return mVspKdTree->MergeLeaves(); 
     1187        return 0; 
    10741188} 
    10751189 
     
    10771191                                                                          const VssRayContainer &sampleRays) 
    10781192{ 
     1193        bool exportRays = false; 
     1194        bool exportGeometry = false; 
     1195 
     1196        environment->GetBoolValue("BspViewCellsManager.Visualization.exportRays", exportRays); 
     1197        environment->GetBoolValue("BspViewCellsManager.Visualization.exportGeometry", exportGeometry); 
     1198 
    10791199        if (!ViewCellsConstructed()) 
    10801200                return; 
    1081  
    1082         bool exportRays = true; 
    10831201 
    10841202        //-- export tree leaves 
     
    11731291                exporter->ExportGeometry(objects); 
    11741292        } 
     1293 
    11751294        if (exportRays)  
    11761295        { 
     
    12071326 
    12081327 
    1209 int 
    1210 VspKdViewCellsManager::CastLineSegment(const Vector3 &origin, 
    1211                                                                            const Vector3 &termination, 
    1212                                                                            ViewCellContainer &viewcells 
    1213                                                                            ) 
    1214 { 
    1215    
    1216   return 0; 
     1328int VspKdViewCellsManager::CastLineSegment(const Vector3 &origin, 
     1329                                                                                   const Vector3 &termination, 
     1330                                                                                   ViewCellContainer &viewcells) 
     1331{ 
     1332        return mVspKdTree->CastLineSegment(origin, termination, viewcells); 
    12171333} 
    12181334 
     
    12281344} 
    12291345 
    1230 float VspBspViewCellsManager::GetProbability(ViewCell *viewCell) 
     1346float VspBspViewCellsManager::GetProbability(ViewCell *viewCell) const 
    12311347{ 
    12321348        PolygonContainer geom; 
     
    12441360 
    12451361 
    1246 float VspBspViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) 
     1362float VspBspViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 
    12471363{ 
    12481364        return viewCell->GetPvs().GetSize() * objRendercost; 
    12491365} 
    12501366 
    1251 VspBspViewCellsManager::~VspBspViewCellsManager() 
    1252 { 
    1253         ViewCellContainer vc; 
    1254         mVspBspTree->CollectViewCells(vc); 
    1255  
    1256         CLEAR_CONTAINER(vc); 
    1257 } 
    12581367 
    12591368bool VspBspViewCellsManager::ViewCellsConstructed() const 
     
    12801389        int sampleContributions = 0; 
    12811390         
    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); 
    12901397        mVspBspTree->CollectViewCells(mViewCells); 
    12911398         
    12921399        Debug << mVspBspTree->GetStatistics() << endl; 
     1400         
     1401        // recast rest of rays 
     1402        ComputeSampleContributions(savedRays); 
    12931403 
    12941404        return sampleContributions; 
     
    14881598                                                                                  const VssRayContainer &sampleRays) 
    14891599{ 
     1600        bool exportRays = false; 
     1601        bool exportGeometry = false; 
     1602 
     1603        environment->GetBoolValue("BspViewCellsManager.Visualization.exportRays", exportRays); 
     1604        environment->GetBoolValue("BspViewCellsManager.Visualization.exportGeometry", exportGeometry); 
     1605 
    14901606        const int leafOut = 10; 
    14911607         
     
    15061622                for (int i = 0; i < (int)vspBspLeaves.size(); ++ i) 
    15071623                { 
    1508                   VssRayContainer vcRays; 
    1509                   cout << "creating output for view cell " << i << " ... "; 
    1510  
    1511                   //$$JB 
     1624                        VssRayContainer vcRays; 
     1625                        cout << "creating output for view cell " << i << " ... "; 
     1626 
     1627                        //$$JB 
    15121628#if 0 
    15131629                        // check whether we can add the current ray to the output rays 
    15141630                        for (int k = 0; k < raysOut; ++ k)  
    15151631                        { 
    1516                           VssRay *ray = sampleRays[k]; 
     1632                                VssRay *ray = sampleRays[k]; 
    15171633 
    15181634                                for     (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 
     
    15391655                        exporter->SetFilled(); 
    15401656 
    1541                         ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 
     1657                        ObjectPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 
    15421658 
    15431659                        exporter->SetWireframe(); 
     
    15641680 
    15651681                        // 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 
    15691688                        m.mDiffuseColor = RgbColor(0, 1, 1); 
    15701689                        exporter->SetForcedMaterial(m); 
    15711690 
    1572                         exporter->SetWireframe(); 
    1573                         //exporter->SetFilled(); 
     1691                        //exporter->SetWireframe(); 
     1692                        exporter->SetFilled(); 
    15741693 
    15751694                        // output PVS of view cell 
     
    15851704                                 
    15861705                        // output rest of the objects 
    1587                         if (0) 
     1706                        if (exportGeometry) 
    15881707                        { 
    15891708                                Material m;//= RandomMaterial(); 
     
    16711790                        exporter->SetForcedMaterial(m); 
    16721791 
    1673                         ViewCellPvsMap::const_iterator it, 
     1792                        ObjectPvsMap::const_iterator it, 
    16741793                                it_end = vc->GetPvs().mEntries.end(); 
    16751794 
     
    17201839        BspViewCell *bVc = back->GetViewCell(); 
    17211840 
    1722         vector<BspLeaf *> fLeaves = fVc->mBspLeaves; 
    1723         vector<BspLeaf *> bLeaves = bVc->mBspLeaves; 
     1841        vector<BspLeaf *> fLeaves = fVc->mLeaves; 
     1842        vector<BspLeaf *> bLeaves = bVc->mLeaves; 
    17241843 
    17251844        vector<BspLeaf *>::const_iterator it; 
     
    17281847        { 
    17291848                (*it)->SetViewCell(viewCell); 
    1730                 viewCell->mBspLeaves.push_back(*it); 
     1849                viewCell->mLeaves.push_back(*it); 
    17311850        } 
    17321851        for (it = bLeaves.begin(); it != bLeaves.end(); ++ it) 
    17331852        { 
    17341853                (*it)->SetViewCell(viewCell); 
    1735                 viewCell->mBspLeaves.push_back(*it); 
     1854                viewCell->mLeaves.push_back(*it); 
    17361855        } 
    17371856         
     
    17681887 
    17691888 
    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 } 
     1889int 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  
    172172  /** Returns probability that view point lies in one view cell. 
    173173  */ 
    174   virtual float GetProbability(ViewCell *viewCell) = 0; 
     174  virtual float GetProbability(ViewCell *viewCell) const = 0; 
    175175 
    176176  /** Returns render cost of a single view cell given the render cost of an object. 
    177177  */ 
    178   virtual float GetRendercost(ViewCell *viewCell, float objRendercost) = 0; 
     178  virtual float GetRendercost(ViewCell *viewCell, float objRendercost) const = 0; 
    179179 
    180180  /** Returns vector of loaded / generated view cells. 
     
    182182  ViewCellContainer &GetViewCells(); 
    183183 
     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 
    184191protected: 
    185          
    186  
    187         /** Initialises the render time simulator. 
    188         */ 
    189         void InitRenderSimulator(); 
    190         ///////////////////// 
    191  
    192          
     192                 
    193193        /// the view cell corresponding to unbounded space 
    194194        ViewCell *mUnbounded; 
     
    198198 
    199199        /// Loaded view cells 
    200   ViewCellContainer mViewCells; 
     200        ViewCellContainer mViewCells; 
    201201 
    202202        /// maximum number of samples taken for construction of the view cells 
     
    242242        void PrintStatistics(ostream &s) const; 
    243243 
    244         ~BspViewCellsManager(); 
    245  
    246244        int CastLineSegment(const Vector3 &origin, 
    247245                                                const Vector3 &termination, 
    248246                                                ViewCellContainer &viewcells); 
    249247         
    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; 
    252250 
    253251protected: 
     
    312310        virtual void PrintStatistics(ostream &s) const; 
    313311 
    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; 
    316314 
    317315protected: 
     
    338336        VspKdViewCellsManager(VspKdTree *vspKdTree, int constructionSamples); 
    339337 
    340         ~VspKdViewCellsManager(); 
    341  
    342338        int Construct(const ObjectContainer &objects,  
    343339                                  const VssRayContainer &rays, 
     
    364360                                                ViewCellContainer &viewcells); 
    365361 
    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; 
    368364 
    369365protected: 
     
    385381        VspBspViewCellsManager(VspBspTree *tree, int constructionSamples); 
    386382 
    387         ~VspBspViewCellsManager(); 
    388  
    389383        int Construct(const ObjectContainer &objects,  
    390384                                  const VssRayContainer &rays, 
     
    410404                                                ViewCellContainer &viewcells); 
    411405 
    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; 
    414408 
    415409 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r466 r469  
    324324                 
    325325                leaf->SetViewCell(viewCell); 
    326                 viewCell->mBspLeaves.push_back(leaf); 
     326                viewCell->mLeaves.push_back(leaf); 
    327327 
    328328                //-- add pvs 
     
    12621262                                        stat.minPvs = pvsSize; 
    12631263 
    1264                                 if ((int)viewCell->mBspLeaves.size() > stat.maxLeaves) 
    1265                                         stat.maxLeaves = (int)viewCell->mBspLeaves.size();               
     1264                                if ((int)viewCell->mLeaves.size() > stat.maxLeaves) 
     1265                                        stat.maxLeaves = (int)viewCell->mLeaves.size();          
    12661266                        } 
    12671267                } 
     
    14611461void VspBspTree::ConstructGeometry(BspViewCell *vc, PolygonContainer &vcGeom) const 
    14621462{ 
    1463         vector<BspLeaf *> leaves = vc->mBspLeaves; 
     1463        vector<BspLeaf *> leaves = vc->mLeaves; 
    14641464 
    14651465        vector<BspLeaf *>::const_iterator it, it_end = leaves.end(); 
     
    17121712 
    17131713 
    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; 
     1714int VspBspTree::CastLineSegment(const Vector3 &origin, 
     1715                                                                const Vector3 &termination, 
     1716                                                                vector<ViewCell *> &viewcells) 
     1717{ 
     1718        int hits = 0; 
     1719        stack<BspRayTraversalData> tStack; 
    17221720   
    1723   float mint = 0.0f, maxt = 1.0f; 
     1721        float mint = 0.0f, maxt = 1.0f; 
    17241722   
    1725   Intersectable::NewMail(); 
     1723        Intersectable::NewMail(); 
    17261724   
    1727   Vector3 entp = origin; 
    1728   Vector3 extp = termination; 
     1725        Vector3 entp = origin; 
     1726        Vector3 extp = termination; 
    17291727   
    1730   BspNode *node = mRoot; 
    1731   BspNode *farChild = NULL; 
     1728        BspNode *node = mRoot; 
     1729        BspNode *farChild = NULL; 
    17321730   
    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); 
    17361736           
    1737           Plane3 splitPlane = in->GetPlane(); 
    1738           const int entSide = splitPlane.Side(entp); 
    1739           const int extSide = splitPlane.Side(extp); 
     1737                        Plane3 splitPlane = in->GetPlane(); 
     1738                        const int entSide = splitPlane.Side(entp); 
     1739                        const int extSide = splitPlane.Side(extp); 
    17401740           
    1741           if (entSide < 0) { 
    1742                 node = in->GetBack(); 
    1743                  
    1744                 if(extSide <= 0) // plane does not split ray => no far child 
    1745                   continue; 
    1746                  
    1747                 farChild = in->GetFront(); // plane splits ray 
    1748                  
    1749           } else 
    1750                 if (entSide > 0) { 
    1751                   node = in->GetFront(); 
     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(); 
    17521752                   
    1753                   if (extSide >= 0) // plane does not split ray => no far child 
    1754                         continue; 
     1753                                if (extSide >= 0) // plane does not split ray => no far child 
     1754                                        continue; 
    17551755                   
    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                   } 
     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                        } 
    17651765           
    1766           // push data for far child 
    1767           tStack.push(BspRayTraversalData(farChild, extp, maxt)); 
     1766                        // push data for far child 
     1767                        tStack.push(BspRayTraversalData(farChild, extp, maxt)); 
    17681768           
    1769           // find intersection of ray segment with plane 
    1770           float t; 
    1771           extp = splitPlane.FindIntersection(origin, extp, &t); 
    1772           maxt *= t; 
     1769                        // find intersection of ray segment with plane 
     1770                        float t; 
     1771                        extp = splitPlane.FindIntersection(origin, extp, &t); 
     1772                        maxt *= t; 
    17731773           
    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); 
    17771778           
    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                        } 
    17831785           
    1784           //-- fetch the next far child from the stack 
    1785           if (tStack.empty()) 
    1786                 break; 
     1786                        //-- fetch the next far child from the stack 
     1787                        if (tStack.empty()) 
     1788                                break; 
    17871789       
    1788           entp = extp; 
    1789           mint = maxt; // NOTE: need this? 
     1790                        entp = extp; 
     1791                        mint = maxt; // NOTE: need this? 
    17901792           
    1791           BspRayTraversalData &s = tStack.top(); 
     1793                         
     1794                        BspRayTraversalData &s = tStack.top(); 
     1795             
     1796                        node = s.mNode; 
     1797                        extp = s.mExitPoint; 
     1798                        maxt = s.mMaxT; 
    17921799           
    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  
    1010#include "RayInfo.h" 
    1111#include "ViewCellBsp.h" 
     12#include "ViewCell.h" 
    1213 
    1314class ViewCell; 
    14 class BspViewCell; 
     15//class BspViewCell; 
    1516class Plane3; 
    1617class VspBspTree;   
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp

    r468 r469  
    2525#include "Ray.h" 
    2626#include "RayInfo.h" 
    27 #include "ViewCell.h" 
    2827#include "ViewCellsManager.h" 
    2928#include "ViewCellBsp.h" 
     
    19141913        Intersectable::NewMail(); 
    19151914 
    1916         //if (!mBox.GetMinMaxT(ray, &mint, &maxt)) return 0; 
    1917  
    1918         if (mint < 0) 
    1919                 mint = 0; 
    1920  
    1921         maxt += Limits::Threshold; 
    1922  
    19231915        Vector3 entp = origin; 
    19241916        Vector3 extp = termination; 
     
    19851977                                vc->Mail(); 
    19861978                                viewcells.push_back(vc); 
     1979                                ++ hits; 
    19871980                        } 
    19881981 
     
    20132006        leaf->SetViewCell(vc); 
    20142007 
    2015         vc->SetSize(GetBBox(leaf).GetVolume()); 
    2016         vc->mVspKdLeaves.push_back(leaf); 
     2008        vc->SetVolume(GetBBox(leaf).GetVolume()); 
     2009        vc->mLeaves.push_back(leaf); 
    20172010 
    20182011        for (it = leaf->GetRays().begin(); it != it_end; ++ it) 
     
    20672060                                        vcStat.minPvs = pvsSize; 
    20682061 
    2069                                 if ((int)viewCell->mVspKdLeaves.size() > vcStat.maxLeaves) 
    2070                                         vcStat.maxLeaves = (int)viewCell->mVspKdLeaves.size(); 
     2062                                if ((int)viewCell->mLeaves.size() > vcStat.maxLeaves) 
     2063                                        vcStat.maxLeaves = (int)viewCell->mLeaves.size(); 
    20712064                        } 
    20722065                } 
     
    20962089 
    20972090        // set new size of view cell 
    2098         vc->SetSize(fVc->GetSize() + bVc->GetSize()); 
    2099  
    2100         vector<VspKdLeaf *> fLeaves = fVc->mVspKdLeaves; 
    2101         vector<VspKdLeaf *> bLeaves = bVc->mVspKdLeaves; 
     2091        vc->SetVolume(fVc->GetVolume() + bVc->GetVolume()); 
     2092 
     2093        vector<VspKdLeaf *> fLeaves = fVc->mLeaves; 
     2094        vector<VspKdLeaf *> bLeaves = bVc->mLeaves; 
    21022095 
    21032096        vector<VspKdLeaf *>::const_iterator it; 
     
    21072100        { 
    21082101                (*it)->SetViewCell(vc); 
    2109                 vc->mVspKdLeaves.push_back(*it); 
     2102                vc->mLeaves.push_back(*it); 
    21102103        } 
    21112104 
     
    21132106        { 
    21142107                (*it)->SetViewCell(vc); 
    2115                 vc->mVspKdLeaves.push_back(*it); 
     2108                vc->mLeaves.push_back(*it); 
    21162109        } 
    21172110 
     
    21362129 
    21372130        int vcSize = (int)leaves.size(); 
     2131        int savedVcSize = vcSize; 
    21382132 
    21392133        VspKdLeaf::NewMail(); 
     
    22082202        ValidateViewCellLeaves(); 
    22092203 
    2210  
     2204        Debug << "merged " << merged << " of " << savedVcSize << " leaves" << endl; 
     2205 
     2206        //TODO: should return sample contributions 
    22112207        return merged; 
    22122208} 
     
    22352231                        { 
    22362232                                Debug << "jhere2" << endl; 
    2237                                 viewCell->mVspKdLeaves.clear(); 
     2233                                viewCell->mLeaves.clear(); 
    22382234                                viewCell->Mail(); 
    22392235                        } 
    22402236 
    2241                         viewCell->mVspKdLeaves.push_back(leaf); 
     2237                        viewCell->mLeaves.push_back(leaf); 
    22422238                } 
    22432239                else 
     
    23182314        //-- to new rendering cost (size of merged view cell times pvs size) 
    23192315        const float oldCost = 
    2320                 (float)vc1->GetPvs().GetSize() * vc1->GetSize() + 
    2321                 (float)vc2->GetPvs().GetSize() * vc2->GetSize(); 
     2316                (float)vc1->GetPvs().GetSize() * vc1->GetVolume() + 
     2317                (float)vc2->GetPvs().GetSize() * vc2->GetVolume(); 
    23222318 
    23232319        const float newCost = 
    2324                 (float)vcPvs * (vc1->GetSize() + vc2->GetSize()); 
     2320                (float)vcPvs * (vc1->GetVolume() + vc2->GetVolume()); 
    23252321 
    23262322        mMergeCost = newCost - oldCost; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.h

    r468 r469  
    3333#include "RayInfo.h" 
    3434#include "Containers.h" 
     35#include "ViewCell.h" 
    3536 
    3637class VspKdLeaf; 
    3738class ViewCellsManager; 
    38 class VspKdViewCell; 
    3939class ViewCellsStatistics; 
    4040 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp

    r468 r469  
    370370 
    371371        // 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); 
    374374  } 
    375375 
     
    439439 
    440440  cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
    441   cout << "#totalRayStackSize=" << mVssRays.size() << endl <<flush; 
     441  cout << "#totalRayStackSize=" << (int)mVssRays.size() << endl <<flush; 
    442442 
    443443  //int numExportRays = 10000; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.h

    r439 r469  
    9595   
    9696  void CastRay(const BspTree &tree, const VssRay & vssRay); 
    97          
    98   int AddObjectSamples(Intersectable *obj, const Ray &ray); 
    9997}; 
    10098 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssTree.cpp

    r466 r469  
    972972 
    973973  if ( (int)(leaf->rays.size()) > stat.maxRayRefs) 
    974     stat.maxRayRefs = leaf->rays.size(); 
     974    stat.maxRayRefs = (int)leaf->rays.size(); 
    975975 
    976976} 
     
    11281128   
    11291129  // update stats 
    1130   stat.rayRefs -= leaf->rays.size(); 
     1130  stat.rayRefs -= (int)leaf->rays.size(); 
    11311131  stat.rayRefs += raysBack + raysFront; 
    11321132 
     
    17171717                                                  SimpleRayContainer &rays) 
    17181718{ 
    1719   int nrays = leaf->rays.size(); 
     1719  int nrays = (int)leaf->rays.size(); 
    17201720  for (int i=0; i < numberOfRays; i++) { 
    17211721        // pickup 3 random rays 
     
    17331733                                                                                                   leaf->rays[r3].GetMaxT())); 
    17341734 
    1735         const float overlap = 0.1; 
     1735        const float overlap = 0.1f; 
    17361736                 
    17371737        Vector3 origin, direction; 
     
    17891789          VssTreeLeaf *leaf = leaves[i]; 
    17901790          float c = leaf->GetImportance(); 
    1791           int num = (c*ratioPerLeaf + 0.5); 
     1791          int num = (int)(c*ratioPerLeaf + 0.5f); 
    17921792          GenerateLeafRays(leaf, num, rays); 
    17931793        } 
    17941794 
    1795   return rays.size(); 
     1795  return (int)rays.size(); 
    17961796} 
    17971797 
  • trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp

    r465 r469  
    698698bool X3dExporter::ExportVspKdTreeViewCell(const VspKdTree &tree, const VspKdViewCell &vc) 
    699699{ 
    700         vector<VspKdLeaf *>::const_iterator it, it_end = vc.mVspKdLeaves.end(); 
    701  
    702         for (it = vc.mVspKdLeaves.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) 
    703703                ExportBox(tree.GetBBox(*it)); 
    704704 
  • trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.h

    r462 r469  
    1111#include "Containers.h" 
    1212#include "VssRay.h" 
     13#include "ViewCell.h" 
    1314 
    1415class SceneGraphNode; 
     
    2122class VspBspTree; 
    2223class BspNode; 
    23 class VspKdViewCell; 
     24//class VspKdViewCell; 
    2425 
    2526 
  • trunk/VUT/GtpVisibilityPreprocessor/src/X3dParser.cpp

    r439 r469  
    170170      char *endptr; 
    171171      while(1) { 
    172         float x = strtod(ptr, &endptr); 
     172        float x = (float)strtod(ptr, &endptr); 
    173173        if (ptr == endptr) 
    174174          break; 
    175175        ptr = endptr; 
    176         float y = strtod(ptr, &endptr); 
     176        float y = (float)strtod(ptr, &endptr); 
    177177        if (ptr == endptr) 
    178178          break; 
    179179        ptr = endptr; 
    180         float z = strtod(ptr, &endptr); 
     180        float z = (float)strtod(ptr, &endptr); 
    181181        if (ptr == endptr) 
    182182          break; 
     
    477477                        while (1)  
    478478                        { 
    479                                 float x = strtod(ptr, &endptr); 
     479                                float x = (float)strtod(ptr, &endptr); 
    480480                 
    481481                                if (ptr == endptr) 
     
    483483                                ptr = endptr; 
    484484                                 
    485                                 float y = (float)strtod(ptr, &endptr); 
     485                                float y = (float)(float)strtod(ptr, &endptr); 
    486486 
    487487                                 
     
    490490                                ptr = endptr; 
    491491 
    492                                 float z = (float)strtod(ptr, &endptr); 
     492                                float z = (float)(float)strtod(ptr, &endptr); 
    493493 
    494494                                if (ptr == endptr) 
Note: See TracChangeset for help on using the changeset viewer.