Changeset 1744


Ignore:
Timestamp:
11/13/06 21:25:40 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env

    r1455 r1744  
    1 ############################################################################# 
     1############################################################################## 
    22# ERS default configuration file 
    33# Jiri Bittner 2003 
     
    55 
    66Scene { 
     7 
    78#       filename glasgow1.x3d 
    89#       filename vienna.x3d 
    910#       filename ../data/vienna/vienna-simple.x3d 
    1011#       filename ../data/vienna/vienna-buildings.x3d 
    11         filename ../data/vienna/city1500_flat_1.x3d 
    12 #       filename ../data/vienna/vienna-roads.x3d 
    13 #       filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roads.x3d;../data/vienna/vienna-roofs.x3d 
    14 #filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d 
    15 #filename ../data/vienna/city1500_flat_1.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d 
    16 #filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d;../data/vienna/vienna-plane.x3d 
    17 #filename ../data/vienna/city1500_flat_1.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d;../data/vienna/vienna-plane.x3d 
     12#       filename ../data/vienna/vienna-roofs.x3d 
     13#       filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d 
     14#       filename ../data/vienna/vienna-buildings_vienna-roofs_vienna-roads_vienna-plane_cropped.obj 
     15        filename ../data/vienna/vienna_cropped.obj 
     16#;../data/vienna/vienna-plane.x3d 
     17#       filename ../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d;../data/vienna/vienna-plane.x3d 
    1818#       filename ../data/vienna/viewcells-25-sel.x3d 
    1919#       filename ../data/atlanta/atlanta2.x3d 
    2020#       filename ../data/soda/soda.dat 
    2121#       filename ../data/soda/soda5.dat 
    22 } 
     22#       filename ../data/artificial/cube_test.x3d 
     23#       filename ../data/grandcanyon1_RotXmin90.obj 
     24#       filename ../data/CityModel.obj 
     25#       filename ../data/arena/arena-low-lods.obj 
     26} 
     27 
    2328 
    2429Preprocessor { 
    25         # stored sample rays 
    26         samplesFilename rays.out 
    2730        useGlRenderer false 
    28 #       type sampling 
    2931        type vss 
    30 #       type rss 
    3132        detectEmptyViewSpace true 
    32         loadMeshes true 
    33         applyVisibilityFilter true 
    34         applyVisibilitySpatialFilter true 
    35 } 
     33        loadMeshes false 
     34        # internal raycaster 
     35        rayCastMethod 0 
     36        # intel raycaster 
     37        #rayCastMethod 1 
     38        exportVisibility false 
     39        loadKdTree false 
     40        exportKdTree false  
     41#       exportObj true 
     42} 
     43 
    3644 
    3745VssPreprocessor { 
    38         samplesPerPass  100000 
    3946        initialSamples 0 
    4047        vssSamples 0 
    41         vssSamplesPerPass 500000 
    4248        useImportanceSampling true 
    4349        loadInitialSamples  false 
    4450        storeInitialSamples false 
    45         useViewSpaceBox false 
    46 #       testBeamSampling true 
    47 } 
    48  
    49  
    50 SamplingPreprocessor { 
    51         totalSamples 500000 
    52         samplesPerPass  3 
    5351} 
    5452 
     
    5856        epsilon         1e-6 
    5957         
    60         maxDepth        40 
     58        maxDepth        2 
    6159        minPvs          30 
    6260        minRays         800 
     
    7472         
    7573        interleaveDirSplits     true 
    76     dirSplitDepth 0 
     74        dirSplitDepth 0 
    7775         
    7876        numberOfEndPointDomains 10000 
     
    8381} 
    8482 
    85 RssPreprocessor { 
    86         samplesPerPass  100000 
    87         #initialSamples 500000 
    88         #vssSamples 10000000 
    89         #for view cell construction 
    90         initialSamples 0 
    91         vssSamples 0 
    92         vssSamplesPerPass 500000 
    93         useImportanceSampling true 
    94  
    95         directionalSampling true 
    96         objectBasedSampling false 
    97  
    98         Export { 
    99                 pvs false 
    100                 rssTree false 
    101                 rays true 
    102                 numRays 5000 
    103         } 
    104  
    105         useViewcells true 
    106         updateSubdivision true 
    107         loadInitialSamples false 
    108         storeInitialSamples false 
    109 } 
    110  
    111  
    112 RssTree { 
    113  
    114         epsilon         1e-6 
    115  
    116         maxDepth        40 
    117         minPvs          3 
    118         minRays         30 
    119         minSize         0.001 
    120         maxCostRatio 1.0 
    121         maxRayContribution 0.5 
    122         maxRays         1000000 
    123         maxTotalMemory  200 
    124         maxStaticMemory 100 
    125  
    126 #       splitType regular 
    127 #       splitType heuristic 
    128         splitType hybrid 
    129         splitUseOnlyDrivingAxis true 
    130         importanceBasedCost false 
    131  
    132         interleaveDirSplits     true 
    133     dirSplitDepth 0 
    134  
    135         numberOfEndPointDomains 10000 
    136         ct_div_ci       0.0 
    137         randomize       false 
    138  
    139         refDirBoxMaxSize        0.1 
    140 } 
    14183 
    14284Limits { 
    143  
    14485       threshold        1e-6 
    14586       small            1e-6 
     
    14788} 
    14889 
     90 
    14991Unigraphics { 
    150                 meshGrouping 1 
    151 } 
     92        meshGrouping 1 
     93} 
     94 
    15295 
    15396KdTree { 
    15497        sahUseFaces true 
     98 
     99        Termination { 
     100                minCost 0 
     101                maxDepth 20 
     102                 
     103                maxCostRatio 1.5 
     104                ct_div_ci 0.5 
     105        } 
     106 
     107#       splitMethod spatialMedian 
     108        splitMethod SAH 
     109        splitBorder 0.01 
     110} 
     111 
     112MeshKdTree { 
    155113        Termination { 
    156114                minCost 1 
     
    165123} 
    166124 
    167 MeshKdTree { 
    168         Termination { 
    169                 minCost 1 
    170                 maxDepth 18 
    171                 maxCostRatio 0.9 
    172                 ct_div_ci 0.5 
    173         } 
    174  
    175 #       splitMethod spatialMedian 
    176         splitMethod SAH 
    177         splitBorder 0.01 
    178 } 
    179  
    180  
    181125 
    182126ViewCells { 
    183         # samples used for view cell construction 
     127         
     128        # samples used for view cell construction  
     129        # (after the sampling used for the hierarchy) 
    184130        Construction { 
    185131                samples 0 
    186                 samplesPerPass 1500000 
    187         } 
    188  
    189         #number of active view cells 
    190         active 200000 
     132                samplesPerPass 1000000 
     133        } 
     134 
     135        # number of active view cells 
     136        active 50000 
    191137        maxStaticMemory 40 
    192138 
     
    194140        loadFromFile false 
    195141 
    196         #type kdTree 
    197         #type vspKdTree 
    198         #type bspTree 
    199         type vspBspTree 
    200         #type sceneDependent 
    201          
    202         height 5.0 
    203         maxViewCells 3000 
    204  
     142        exportPvs false 
     143 
     144        # type of view cells 
     145        type vspOspTree 
     146         
    205147        #percentage of total visible objects where pvs is considered invalid 
    206148        maxPvsRatio 1.0 
     
    208150        processOnlyValidViewCells false 
    209151 
    210         #stats viewCellStats.log 
    211  
     152        #samplingType object_directional 
    212153        #samplingType directional 
    213154        samplingType box 
     155        #samplingType reverse_object 
     156        #samplingType object 
    214157 
    215158        PostProcess { 
    216159                # how much samples are used for post processing 
    217160                samples 0 
    218                 renderCostWeight 1.0 
    219                 maxCostRatio 0.1 
    220                 minViewCells 1 
    221                 avgCostMaxDeviation 0.01 
    222161                maxMergesPerPass 5000 
    223162                useRaysForMerge false 
     163                refine false 
    224164                compress false 
    225                 merge true 
     165                merge false 
    226166        } 
    227167 
    228168        Visualization { 
    229169                # how much samples we use for visualization 
    230                 samples 0 
    231                 #colorCode PVS 
    232                 #colorCode MergedLeaves 
    233                 #colorCode MergedTreeDiff 
    234                 colorCode Random 
    235                 exportRays false 
     170                samples 200 
     171                exportRays true 
    236172                exportGeometry true 
    237173                exportMergedViewCells false 
    238174                useClipPlane true 
    239175                clipPlaneAxis 1 
    240                 clipPlanePos  0.3 
     176                clipPlanePos 0.3 
     177                maxOutput 2 
    241178        } 
    242179 
    243180        showVisualization true 
     181        #showVisualization false 
    244182        evaluateViewCells false 
    245183         
    246184        Evaluation { 
    247                 samplesPerPass 1000000 
    248                 samples 1000000 
     185                samples         80000000 
     186                samplesForStats 80000000 
     187                samplesPerPass  2000000 
     188 
     189                stepSize        500 
     190 
     191                #samplingType object_directional 
     192                #samplingType reverse_object 
     193                #samplingType object 
     194                samplingType box 
     195 
    249196                statsPrefix ../scripts/viewCells 
    250                 #samplingType directional 
    251                 samplingType box 
    252                 histogram true 
    253                 histoStepSize 5000 
    254         } 
    255  
    256 #       filename ../data/atlanta/atlanta_viewcells_large.x3d 
    257 #       filename ../data/vienna/viewcells-25-sel.x3d 
    258 #       filename ../data/vienna/viewcells-25.x3d 
    259 #       filename ../data/vienna/viewcells-large-sel.x3d 
    260         filename ../data/vienna/vienna-visibility.xml.zip 
    261 #       filename ../scripts/vienna-visibility.xml.zip 
    262 } 
    263  
    264  
    265 Simulation { 
    266         objRenderCost 1.0 
    267         vcOverhead 1.0 
    268         # always between 0 and 1 
    269         moveSpeed 0.0001 
    270 } 
    271  
    272  
    273 VspBspTree { 
     197        } 
     198} 
     199 
     200 
     201################################ 
     202# 
     203# View space partitioning kd tree 
     204# 
     205 
     206VspTree { 
    274207        Construction { 
    275                 samples 500000 
    276                 epsilon 0.0000001 
    277                 randomize false 
    278                 renderCostWeight 1.0 
    279         } 
    280  
    281  
    282         # random polygon       = 1 
    283         # axis aligned         = 2 
    284         # least ray splits     = 256 
    285         # balanced rays        = 512 
    286         # pvs                  = 1024 
    287          
    288         splitPlaneStrategy 1026 
    289          
    290         # maximal candidates for split planes 
    291         maxPolyCandidates 0 
    292  
    293         usePolygonSplitIfAvailable false 
    294  
    295         # maximal tested rays for split cost heuristics 
    296         maxTests 10000 
    297          
    298         maxTotalMemory  50 
    299         maxStaticMemory 50 
    300  
    301         subdivisionStats ../subdivisionStats.log 
    302  
    303         # factors for evaluating split plane costs 
    304         Factor { 
    305                 leastRaySplits 1.0 
    306                 balancedRays 1.0 
    307                 pvs 1.0 
    308         } 
    309          
    310         Termination { 
    311                 # parameters used for autopartition 
    312                 minRays                 -15 
    313                 minPolygons             -1 
    314                 maxDepth                25 
    315                 minPvs                  0 
    316                 minProbability          0.000001 
    317                 maxRayContribution      1 
    318                 maxCostRatio            0.9 
    319                 missTolerance           6 
    320                 globalCostMissTolerance 4 
    321                 #minGlobalCostRatio      0.0000001 
    322                 minGlobalCostRatio      0.0001 
    323                 maxViewCells            5000 
    324          
    325  
    326                 # used for pvs criterium 
    327                 ct_div_ci 0.0 
    328                  
    329                 AxisAligned { 
    330                         minRays                 50000 
    331                         maxRayContribution      9.9 
    332                 } 
    333         } 
    334          
    335         useSplitCostQueue true 
    336         useCostHeuristics false 
    337  
     208                renderCostDecreaseWeight 1.0 
     209        } 
     210 
     211        Termination { 
     212                minPvs 0 
     213                maxViewCells 500000 
     214        } 
     215 
     216        useCostHeuristics true 
    338217        splitUseOnlyDrivingAxis false 
    339         simulateOctree false 
    340         useRandomAxis false 
    341         usePolygonSplitIfAvailable false 
    342         nodePriorityQueueType 0 
    343  
    344         Visualization { 
    345                 # x3d visualization of the split planes 
    346                 exportSplits false 
    347         } 
    348 } 
    349  
    350 BspTree { 
     218 
     219        # maximum number of tests per node 
     220        maxTests 50000 
     221} 
     222 
     223 
     224########################## 
     225# 
     226# The bounding volume hierarchy 
     227# 
     228 
     229BvHierarchy { 
     230 
     231        Construction {           
     232                renderCostDecreaseWeight 1.0 
     233        } 
     234 
     235        Termination { 
     236                maxLeaves 50000000 
     237        } 
     238 
     239        minRaysForVisibility 15 
     240 
     241        # use only surface area heuristic        
     242        useCostHeuristics true 
     243        useSah false 
     244 
     245        splitUseOnlyDrivingAxis false 
     246 
     247        maxTests 50000 
     248} 
     249 
     250 
     251############################################################### 
     252# 
     253# Manages the construction of view space and object space partition 
     254# 
     255 
     256Hierarchy { 
     257        # the type of object space partition: view space is always vsp (=kd) partition 
     258        type bvh 
     259         
    351260        Construction { 
    352                 samples 100000 
    353                 epsilon 0.005 
    354         } 
    355  
    356  
    357         # random polygon       = 1 
    358         # axis aligned         = 2 
    359         # least splits         = 4 
    360         # balanced polygons    = 8 
    361         # balanced view cells  = 16 
    362         # largest polygon area = 32 
    363         # vertical axis        = 64 
    364         # blocked rays         = 128 
    365         # least ray splits     = 256 
    366         # balanced rays        = 512 
    367         # pvs                  = 1024 
    368  
    369         # least splits + balanced polygons 
    370         #splitPlaneStrategy 12 
    371          
    372         #axis aligned + vertical axis 
    373         #splitPlaneStrategy 66 
    374          
    375         # axis aligned + balanced view cells 
    376         # splitPlaneStrategy 18 
    377          
    378         # largest polygon area 
    379         #splitPlaneStrategy 32 
    380          
    381         # axus aligned + balanced polygons 
    382         #splitPlaneStrategy 72 
    383          
    384         # axis aligned + blocked rays 
    385         #splitPlaneStrategy 130 
    386          
    387         #splitPlaneStrategy 384 
    388         #splitPlaneStrategy 130 
    389          
    390         splitPlaneStrategy 32 
    391          
    392         maxPolyCandidates 100 
    393         maxRayCandidates 0 
    394          
    395         maxTests 10000 
    396          
    397         subdivisionStats ../subDivisionStats.log 
    398  
    399         # factors for evaluating split plane costs 
    400         Factor { 
    401                 verticalSplits 1.0 
    402                 largestPolyArea 1.0 
    403                 blockedRays 1.0 
    404                 leastRaySplits 1.0 
    405                 balancedRays 1.0 
    406                 pvs 1.0 
    407                 leastSplits 1.0 
    408                 balancedPolys 1.0 
    409                 balancedViewCells 1.0 
    410         } 
    411          
    412         Termination { 
    413                 # parameters used for autopartition 
    414                 minRays -1 
    415                 minPolygons 0 
    416                 maxDepth 30 
    417                 minPvs -1 
    418                 minProbability 0.00001 
    419                 maxRayContribution 9999 
    420                 maxViewCells 50000 
    421  
    422                 # used for pvs criterium 
    423                 ct_div_ci 0.0 
    424          
    425                 maxCostRatio 0.9 
    426                  
    427                 # axis aligned splits 
    428                 AxisAligned { 
    429                         minPolys 5000 
    430                         minRays 500 
    431                         minObjects 10 
    432                         ct_div_ci 0.5 
    433                 } 
    434         } 
    435          
    436         AxisAligned { 
    437                 splitBorder 0.01 
    438         } 
    439          
    440          
    441         Visualization { 
    442                 # x3d visualization of the split planes 
    443                 exportSplits false 
    444         } 
    445 } 
     261 
     262                samples 3000000 
     263 
     264                # type 0 = sequential computation, 1 = interleaved, 2 = gradient 
     265                type 2 
     266 
     267                ############################### 
     268                # only for interleaved method 
     269 
     270                # minimal steps of same type for gradient method 
     271                minStepsOfSameType 100 
     272                # maximum steps of same type for gradient method 
     273                maxStepsOfSameType 900 
     274 
     275                # maximum number of repair steps per gradient step 
     276                maxRepairs 1000 
     277        } 
     278 
     279        Termination { 
     280                # maximal number of leaves 
     281                maxLeaves 100000 
     282                # maximal memory in MB 
     283                maxMemory 20 
     284                # minimum ratio of global cost decrease 
     285                minGlobalCostRatio -1 
     286        } 
     287} 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.sh

    r1456 r1744  
    11#!/bin/sh 
    22 
    3 PROGRAM=../bin/release/Preprocessor.exe 
    4 #PROGRAM=../bin/Debug/Preprocessor.exe 
     3# add bin to path 
     4export PATH=../bin:$PATH 
    55 
    6 if [ $# -ne 3 ] 
    7 then 
    8     echo "Usage:" 
    9         echo "preprocess_visibility scene_file.x3d viewcells_file.xml number_of_viewcells" 
    10     exit 
    11 fi 
     6#TARGET=debug 
     7TARGET=release 
    128 
     9PROGRAM=../bin/$TARGET/Preprocessor.exe 
    1310 
    14  
    15 SCENE=$1 
    16 VIEWCELLS=$2 
    17 NUM_VIEWCELLS=$3 
    18 NUM_SAMPLE_RAYS=500000 
    19  
    20 LOG_PREFIX=generate_viewcells 
    21  
     11SCENE=vienna_cropped 
     12LOG_PREFIX=../scripts/$SCENE 
    2213ENVIRONMENT=generate_viewcells.env 
    2314 
     15echo "starting $TARGET mode for $SCENE scene" 
    2416 
    25 ############################################### 
     17############################################################################ 
    2618 
    27 METHOD=avs 
    28 echo "$SCENE $METHOD" 
     19 METHOD=gradient 
     20 echo "$SCENE $METHOD" 
    2921 
    30 $PROGRAM $ENVIRONMENT \ 
    31 -scene_filename=$SCENE \ 
    32 -view_cells_type=vspBspTree \ 
    33 -view_cells_construction_samples=0 \ 
    34 -vsp_bsp_construction_samples=$NUM_SAMPLE_RAYS \ 
    35 -vsp_bsp_term_max_view_cells=$NUM_VIEWCELLS \ 
    36 -view_cells_evaluation_stats_prefix=$LOG_PREFIX-$METHOD \ 
    37 -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
    38 -vsp_bsp_subdivision_stats=$LOG_PREFIX-$METHOD-subdivisionStats.log \ 
    39 -view_cells_post_process_merge=false \ 
    40 -view_cells_active=$NUM_VIEWCELLS \ 
    41 -view_cells_filename=$VIEWCELLS \ 
    42 -view_cells_export_pvs=true \ 
    43 -view_cells_export_bounding_boxes=true \ 
    44 -vsp_bsp_term_min_pvs=0 \ 
    45 -view_cells_evaluate=false \ 
    46 -vsp_bsp_use_cost_heuristics=true \ 
    47 -vsp_bsp_max_poly_candidates=0 \ 
    48 -vsp_bsp_use_split_cost_queue=true \ 
    49 -view_cells_show_visualization=true \ 
    50 -view_cells_construction_samples=0 \ 
    51 -view_cells_evaluation_samples=2000000 \ 
    52 -view_cells_evaluation_samples_per_pass=1000000 
    53  
    54  
    55 mv debug.log $LOG_PREFIX-$METHOD-debug.log 
    56 mv merged_view_cells.wrl $LOG_PREFIX-$METHOD-merged_view_cells.wrl 
    57 mv merged_view_cells_pvs.wrl $LOG_PREFIX-$METHOD-merged_view_cells_pvs.wrl 
    58 #mv final_view_cells.x3d $LOG_PREFIX-$METHOD-final_view_cells.x3d 
     22 $PROGRAM $ENVIRONMENT \ 
     23 -view_cells_filename=$LOG_PREFIX-$METHOD-viewcells.xml.gz \ 
     24  -view_cells_merge_stats=$LOG_PREFIX-$METHOD-mergeStats.log \ 
     25  -vsp_subdivision_stats=$LOG_PREFIX-$METHOD-vsp-subdivisionStats.log \ 
     26  -bvh_subdivision_stats=$LOG_PREFIX-$METHOD-bvh-subdivisionStats.log \ 
     27  -hierarchy_subdivision_stats=$LOG_PREFIX-$METHOD-hierarchy-subdivisionStats.log \ 
     28  -hierarchy_construction_type=2 \ 
     29  -hierarchy_construction_consider_memory=true 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1737 r1744  
    294294        //mMemoryConst = (float)(sizeof(VspLeaf) + sizeof(VspViewCell)); 
    295295        //mMemoryConst = (float)sizeof(BvhLeaf); 
    296 mMemoryConst = (float)sizeof(ObjectContainer); 
    297         cout << "bvh memcost: " << mMemoryConst << endl; 
     296        mMemoryConst = (float)sizeof(ObjectContainer); 
     297 
     298        /*cout << "bvh memcost: " << mMemoryConst << endl; 
    298299        cout << "triangle: " << sizeof(TriangleIntersectable) << endl; 
    299300        cout << "triangle: " << sizeof(Intersectable) << endl; 
     
    301302        cout << "triangle: " << sizeof(float) << endl; 
    302303        cout << "triangle: " << sizeof(int) << endl; 
    303  
     304*/ 
    304305    mUseBboxAreaForSah = true; 
    305306 
     
    327328        Debug << "minimal rays for visibility: " << mMinRaysForVisibility << endl; 
    328329        Debug << "bvh mem const: " << mMemoryConst << endl; 
    329  
     330cout << "here10 " << mRenderCostDecreaseWeight << endl; 
    330331        Debug << endl; 
    331332} 
     
    509510                EvaluateLeafStats(tData); 
    510511         
    511                 const bool mStoreRays = true; 
    512                 if (mStoreRays) 
    513                 { 
    514                         BvhLeaf *leaf = dynamic_cast<BvhLeaf *>(currentNode); 
    515                 //      CollectRays(leaf->mObjects, leaf->mVssRays); 
    516                 } 
    517                  
    518                 ////////////////////////////////////// 
    519                  
    520512                // this leaf is no candidate for splitting anymore 
    521513                // => detach subdivision candidate 
     
    598590                { 
    599591                        priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
    600                         if (mHierarchyManager->mConsiderMemory2) 
     592                        if (mHierarchyManager->mConsiderMemory) 
    601593                        { 
    602594                                priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mMemoryConst); 
     
    605597                else 
    606598                { 
    607                         if (!mHierarchyManager->mConsiderMemory2) 
     599                        if (!mHierarchyManager->mConsiderMemory) 
    608600                        { 
    609601                                priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
     
    619611        } 
    620612 
     613        //splitCandidate.SetOldCost(oldRenderCost); 
    621614        // compute global decrease in render cost 
    622615        splitCandidate.SetPriority(priority); 
     
    13561349         
    13571350        VssRayContainer rays; 
    1358         rays.reserve(tData.mNumRays); 
     1351        // maximal 2 objects share the same ray 
     1352        rays.reserve(tData.mNumRays * 2); 
    13591353        CollectRays(tData.mNode->mObjects, rays); 
    13601354 
    1361         const float prop = (float)mMaxTests / (float)tData.mNumRays; 
     1355        const float prop = (float)mMaxTests / ((float)tData.mNumRays + Limits::Small); 
    13621356 
    13631357        VssRay::NewMail(); 
    13641358 
     1359        //cout << "here7 " << tData.mNumRays << " " << rays.size() << endl; 
     1360        //cout << "here5 prop: " << prop << " " << mMaxTests << " " << tData.mNumRays << endl; 
    13651361        // only use a subset of the rays 
    13661362        VssRayContainer::const_iterator rit, rit_end = rays.end(); 
    13671363 
     1364        int nRays = 0; 
     1365 
    13681366        for (rit = rays.begin(); rit != rit_end; ++ rit) 
    13691367        { 
    1370                 if ((mMaxTests >= tData.mNumRays) || (Random(1.0f) < prop)) 
     1368                if ((mMaxTests >= (int)rays.size()) || (Random(1.0f) < prop)) 
    13711369                { 
    13721370                        (*rit)->Mail(); 
    1373                 } 
    1374         } 
    1375          
     1371                        ++ nRays; 
     1372                } 
     1373        } 
     1374         
     1375        //cout << "here99 " << nRays << " obj " << tData.mNode->mObjects.size() << endl; 
    13761376        // collect and mark the view cells as belonging to front pvs 
    13771377        ViewCellContainer viewCells; 
    13781378        CollectViewCells(tData.mNode->mObjects, viewCells, true, true); 
    1379                          
     1379         
    13801380        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    13811381        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
     
    14881488                                if (useVisibilityBasedHeuristics) 
    14891489                                { 
    1490                                         //cout << "v rays: " << tData.mNumRays << " " << endl; 
    14911490                                        /////////// 
    14921491                                        //-- heuristics using objects weighted by view cells volume 
     
    14981497                                } 
    14991498                                else 
    1500                                 {       //cout << "e rays: " << tData.mNumRays << " "; 
     1499                                {        
    15011500                                        ////////////////// 
    15021501                                        //-- view cells not constructed yet     => use surface area heuristic                    
     
    17101709 
    17111710 
    1712 void BvHierarchy::CollectViewCells(const ObjectContainer &objects,  
    1713                                                                    ViewCellContainer &viewCells, 
    1714                                                                    const bool setCounter, 
    1715                                                                    const bool onlyMailedRays) const 
     1711int BvHierarchy::CollectViewCells(const ObjectContainer &objects,  
     1712                                                                  ViewCellContainer &viewCells, 
     1713                                                                  const bool setCounter, 
     1714                                                                  const bool onlyMailedRays) const 
    17161715{ 
    17171716        ViewCell::NewMail(); 
    17181717        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
    17191718 
     1719        int numRays = 0; 
    17201720        // loop through all object and collect view cell pvs of this node 
    17211721        for (oit = objects.begin(); oit != oit_end; ++ oit) 
    17221722        { 
    17231723                // always use only mailed objects 
    1724                 CollectViewCells(*oit, viewCells, true, setCounter, onlyMailedRays); 
    1725         } 
    1726 } 
    1727  
    1728  
    1729 void BvHierarchy::CollectViewCells(Intersectable *obj,  
    1730                                                                    ViewCellContainer &viewCells, 
    1731                                                                    const bool useMailBoxing, 
    1732                                                                    const bool setCounter, 
    1733                                                                    const bool onlyMailedRays) const 
     1724                numRays += CollectViewCells(*oit, viewCells, true, setCounter, onlyMailedRays); 
     1725        } 
     1726        //cout << "here4 " << numRays << " boj: " << objects.size() << " " << onlyMailedRays << endl; 
     1727 
     1728        return numRays; 
     1729} 
     1730 
     1731 
     1732int BvHierarchy::CollectViewCells(Intersectable *obj,  
     1733                                                                  ViewCellContainer &viewCells, 
     1734                                                                  const bool useMailBoxing, 
     1735                                                                  const bool setCounter, 
     1736                                                                  const bool onlyMailedRays) const 
    17341737{ 
    17351738        VssRayContainer::const_iterator rit, rit_end = obj->GetOrCreateRays()->end(); 
     1739 
     1740        int numRays = 0; 
    17361741 
    17371742        for (rit = obj->GetOrCreateRays()->begin(); rit < rit_end; ++ rit) 
     
    17421747                        continue; 
    17431748 
    1744                 ray->Mail(); 
     1749                //ray->Mail(); 
     1750                ++ numRays; 
    17451751 
    17461752                ViewCellContainer tmpViewCells; 
     
    17741780                } 
    17751781        } 
     1782 
     1783        return numRays; 
    17761784} 
    17771785 
     
    18331841        ViewCellContainer viewCells; 
    18341842        ViewCell::NewMail(); 
    1835         CollectViewCells(node->mObjects, viewCells, true, false); 
    1836  
     1843        int numRays = CollectViewCells(node->mObjects, viewCells, true, false); 
     1844 
     1845        //cout << "here6 " << numRays << endl; 
    18371846        if (0) cout << "collected " << (int)viewCells.size() << " dirty candidates" << endl; 
    18381847         
     
    20152024 
    20162025        ViewCellContainer viewCells; 
    2017         // here we have to account for all view cells that can  
     2026         
     2027        // we have to account for all view cells that can  
    20182028        // be seen from the objects 
    2019         CollectViewCells(objects, viewCells, false, false); 
     2029        int numRays = CollectViewCells(objects, viewCells, false, false); 
    20202030 
    20212031        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1732 r1744  
    781781        /** Collect view cells which see this bvh leaf. 
    782782        */ 
    783         void CollectViewCells(const ObjectContainer &objects,  
    784                                                   ViewCellContainer &viewCells, 
    785                                                   const bool setCounter, 
    786                                                   const bool onlyMailedRays) const; 
     783        int CollectViewCells(const ObjectContainer &objects,  
     784                                                 ViewCellContainer &viewCells, 
     785                                                 const bool setCounter, 
     786                                                 const bool onlyUnmailedRays) const; 
    787787 
    788788        /** Counts the view cells of this object. note: only 
     
    797797        /** Collects view cells which see an object. 
    798798        */ 
    799         void CollectViewCells(Intersectable *object,  
    800                                                   ViewCellContainer &viewCells,  
    801                                                   const bool useMailBoxing, 
    802                                                   const bool setCounter, 
    803                                                   const bool onlyMailedRays) const; 
     799        int CollectViewCells(Intersectable *object,  
     800                                                 ViewCellContainer &viewCells,  
     801                                                 const bool useMailBoxing, 
     802                                                 const bool setCounter, 
     803                                                 const bool onlyUnmailedRays) const; 
    804804 
    805805        /** Evaluates increase in pvs size. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1727 r1744  
    25422542                                        optBool, 
    25432543                                        "hierarchy_construction_consider_memory=", 
    2544                                         "false"); 
    2545  
    2546         RegisterOption("Hierarchy.Construction.considerMemory2", 
    2547                                         optBool, 
    2548                                         "hierarchy_construction_consider_memory2=", 
    2549                                         "false"); 
     2544                                        "true"); 
    25502545 
    25512546        RegisterOption("Hierarchy.Construction.repairQueue", 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1743 r1744  
    9191                << "#FullMem\n" << mFullMemory << endl 
    9292                << "#RenderCostDecrease\n" << mRenderCostDecrease << endl 
     93                << "#Priority\n" << mPriority << endl 
    9394                << "#FpsPerMb\n" << FpsPerMb() << endl 
    9495                << endl; 
     
    142143        Environment::GetSingleton()->GetBoolValue( 
    143144                "Hierarchy.Construction.considerMemory", mConsiderMemory); 
    144  
    145         Environment::GetSingleton()->GetBoolValue( 
    146                 "Hierarchy.Construction.considerMemory2", mConsiderMemory2); 
    147145 
    148146        Environment::GetSingleton()->GetFloatValue( 
     
    166164        Debug << "maximal allowed memory: " << mTermMaxMemory << endl; 
    167165        Debug << "consider memory: " << mConsiderMemory << endl; 
    168         Debug << "consider memory2: " << mConsiderMemory << endl; 
    169166        Debug << "min steps of same kind: " << mMinStepsOfSameType << endl; 
    170167        Debug << "max steps of same kind: " << mMaxStepsOfSameType << endl; 
     
    266263{ 
    267264        SubdivisionCandidate *splitCandidate = splitQueue.Top(); 
    268  
    269         if (splitCandidate->IsDirty()) 
    270                 splitCandidate->EvalCandidate(); 
    271  
    272265        splitQueue.Pop(); 
    273266 
     
    287280                 
    288281        HierarchySubdivisionStats stats; 
     282 
    289283        stats.mNumSplits = mHierarchyStats.Leaves(); 
    290284        stats.mTotalRenderCost = mHierarchyStats.mTotalCost; 
     
    295289        stats.mViewSpaceSplits = mVspTree->mVspStats.Leaves(); 
    296290        stats.mObjectSpaceSplits = GetObjectSpaceSubdivisionLeaves(); 
    297          
     291        stats.mRenderCostDecrease = mHierarchyStats.mRenderCostDecrease; 
     292        stats.mPriority = mPriority; 
     293 
    298294        stats.Print(mSubdivisionStats); 
    299295} 
     
    740736        const bool success = sc->Apply(splitQueue, terminationCriteriaMet); 
    741737 
     738        if (sc->IsDirty()) 
     739                cout << "*******************************error!" << endl; 
     740 
    742741        if (!success) // split was not taken 
    743742        { 
     743                cout << "x"; 
    744744                return false; 
    745745        } 
    746746 
     747        //cout << "priority: " << sc->GetPriority() << " rc decr: " << sc->GetRenderCostDecrease() << " | "; 
    747748        /////////////// 
    748749        //-- split was successful => update stats and queue 
     
    750751    // cost ratio of cost decrease / totalCost 
    751752        const float costRatio = sc->GetRenderCostDecrease() / mHierarchyStats.mTotalCost; 
    752         //Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 
     753        //cout << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 
    753754         
    754755        if (costRatio < mTermMinGlobalCostRatio) 
     
    772773        mHierarchyStats.mMemory += (float)ObjectPvs::GetEntrySizeByte() * pvsEntriesIncr; 
    773774        mHierarchyStats.mRenderCostDecrease = sc->GetRenderCostDecrease(); 
     775         
     776        mPriority = sc->GetPriority(); 
    774777 
    775778        static float memoryCount = 0; 
     
    13911394        { 
    13921395                SubdivisionCandidate *candidate = NextSubdivisionCandidate(splitQueue); 
    1393                  // reevaluate local split plane and priority 
     1396                 
     1397                // reevaluate local split plane and priority 
    13941398                candidate->EvalCandidate(recomputeSplitPlane); 
    13951399                cout << "."; 
     
    19241928        subStats.mViewSpaceSplits = 0; 
    19251929        subStats.mObjectSpaceSplits = 0; 
    1926          
     1930        subStats.mRenderCostDecrease = 0; 
    19271931        subStats.Print(stats); 
    19281932 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1743 r1744  
    128128        int mObjectSpaceSplits; 
    129129 
     130        float mPriority; 
    130131 
    131132        float VspOspRatio() const { return (float)mViewSpaceSplits / (float)mObjectSpaceSplits; } 
     
    145146                mViewSpaceSplits = 0; 
    146147                mObjectSpaceSplits = 0; 
     148                mPriority = 0; 
    147149        } 
    148150 
     
    287289        inline bool ConsiderMemory() const { return mConsiderMemory; } 
    288290        //inline float GetMemoryConst() const { return mMemoryConst; } 
    289  
    290291         
    291292        void EvaluateSubdivision(const VssRayContainer &sampleRays,                                                                                       
     
    625626        bool mConsiderMemory; 
    626627 
    627         bool mConsiderMemory2; 
    628  
    629628        int mMaxRepairs; 
    630629 
     
    633632        friend OspTree; 
    634633        friend BvHierarchy; 
     634 
     635        float mPriority; 
     636 
    635637        friend ViewCellsParseHandlers; 
    636638 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r1742 r1744  
    121121 
    122122 
    123 /*template<typename T, typename S> 
    124 class PvsIterator 
    125 { 
    126         Next(PvsEntry<T, S>) 
    127 private: 
    128         typename vector<PvsEntry<T, S> >::iterator mItCurrent; 
    129         typename vector<PvsEntry<T, S> >::iterator mItEnd; 
    130 };*/ 
    131  
    132  
    133123template<typename T, typename S> 
    134124class PvsIterator 
     
    147137        } 
    148138 
    149         PvsEntry<T, S> Next() 
     139        const PvsEntry<T, S> &Next() 
    150140        { 
    151141                return *(mItCurrent ++); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1743 r1744  
    4242// HACK 
    4343const static bool SAMPLE_AFTER_SUBDIVISION = true; 
    44 const static bool CLAMP_TO_BOX = false; 
    45 //const static bool CLAMP_TO_BOX = true; 
     44//const static bool CLAMP_TO_BOX = false; 
     45const static bool CLAMP_TO_BOX = true; 
    4646 
    4747 
     
    119119 
    120120         
    121         ObjectPvs pvs1, pvs2, mergedPvs; 
     121        /*ObjectPvs pvs1, pvs2, mergedPvs; 
    122122 
    123123        pvs1.AddSample((Intersectable *)1, 1); 
     
    172172                cout << (int)entry.mObject << " " << entry.mData.mSumPdf << " x "; 
    173173        } 
    174  
     174*/ 
    175175        // sampling type for view cells construction samples 
    176176        if (strcmp(buf, "object") == 0) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1738 r1744  
    462462        Environment::GetSingleton()->GetIntValue("VspTree.maxTests", mMaxTests); 
    463463 
    464         Environment::GetSingleton()-> 
    465                 GetFloatValue("VspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
     464        Environment::GetSingleton()->GetFloatValue("VspTree.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
    466465         
    467466        // if only the driving axis is used for axis aligned split 
     
    505504 
    506505        Debug << "vsp mem const: " << mMemoryConst << endl; 
    507  
     506cout << "here11 " << mRenderCostDecreaseWeight << endl; 
    508507        Debug << endl; 
    509508} 
     
    852851        { 
    853852                priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
    854                 if (mHierarchyManager->mConsiderMemory2) 
     853                if (mHierarchyManager->mConsiderMemory) 
    855854                { 
    856855                        priority /= ((float)splitCandidate.GetPvsEntriesIncr() + mMemoryConst); 
     
    859858        else 
    860859        { 
    861                 if (!mHierarchyManager->mConsiderMemory2) 
     860                if (!mHierarchyManager->mConsiderMemory) 
    862861                { 
    863862                        priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
Note: See TracChangeset for help on using the changeset viewer.