Changeset 1584


Ignore:
Timestamp:
10/08/06 23:29:21 (18 years ago)
Author:
bittner
Message:

functional ray casting - fixed computeinvdir issue

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp

    r1583 r1584  
    2929{ 
    3030  //cout << "internal ray" << endl; 
     31  static Ray ray; 
    3132  int hits = 0; 
    32   static Ray ray; 
    3333  Intersection hitA(simpleRay.mOrigin), hitB(simpleRay.mOrigin); 
     34   
     35  // inside test for bounding box 
     36  // enlarge box slightly so the view point fits for sure 
     37  //  AxisAlignedBox3 sbox = box; 
     38  //  sbox.Enlarge(Vector3(-Limits::Small)); 
     39  // $$ JB moved here from Validate routine 
     40  if (!box.IsInside(simpleRay.mOrigin)) { 
     41        return 0; 
     42  } 
    3443   
    3544  mPreprocessor.SetupRay(ray, simpleRay.mOrigin, simpleRay.mDirection); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r1583 r1584  
    192192      int objectsBack, objectsFront; 
    193193      float costRatio; 
    194       bool mOnlyDrivingAxis = false; 
     194      bool mOnlyDrivingAxis = true; 
    195195 
    196196          if (mOnlyDrivingAxis) { 
     
    608608  float mint = 0; 
    609609 
    610   ray.ComputeInvertedDir(); 
     610  //  ray.ComputeInvertedDir(); 
    611611 
    612612  Intersectable::NewMail(); 
     
    617617  if (mint < 0) 
    618618    mint = 0; 
     619 
    619620   
    620621  maxt += Limits::Threshold; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1582 r1584  
    2525 
    2626#define DEBUG_RAYCAST 0 
     27#define SHOW_RAYCAST_TIMING 1 
    2728 
    2829 
     
    882883                { 
    883884                        mRayCaster->CastRays16( 
    884                                 i, 
    885                                 rays,                            
    886                                 vssRays, 
    887                                 mViewCellsManager->GetViewSpaceBox(), 
    888                                 castDoubleRays, 
    889                                 pruneInvalidRays); 
     885                                                                   i, 
     886                                                                   rays,                                 
     887                                                                   vssRays, 
     888                                                                   mViewCellsManager->GetViewSpaceBox(), 
     889                                                                   castDoubleRays, 
     890                                                                   pruneInvalidRays); 
    890891                        i += 16; 
    891892                } 
    892893                else  
    893                 { 
     894                  { 
    894895                        mRayCaster->CastRay( 
    895                                 rays[i], 
    896                                 vssRays, 
    897                                 mViewCellsManager->GetViewSpaceBox(), 
    898                                 castDoubleRays, 
    899                                 pruneInvalidRays); 
     896                                                                rays[i], 
     897                                                                vssRays, 
     898                                                                mViewCellsManager->GetViewSpaceBox(), 
     899                                                                castDoubleRays, 
     900                                                                pruneInvalidRays); 
    900901                        i ++; 
    901                 } 
    902         } 
    903  
    904         if (i % 10000 == 0) 
    905                 cout<<"."; 
    906  
    907 #if DEBUB_RAYCAST 
     902                  } 
     903                if (i % 10000 == 0) 
     904                  cout<<"."; 
     905        } 
     906         
     907 
    908908        long t2 = GetTime(); 
     909 
     910#if SHOW_RAYCAST_TIMING 
    909911        if (castDoubleRays) 
    910912                cout << 2 * rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl; 
     
    956958        // do not store anything else then intersections at the ray 
    957959        ray.Init(point, direction, Ray::LOCAL_RAY); 
    958 } 
    959  
    960  
    961 } 
     960         
     961} 
     962 
     963 
     964} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.cpp

    r1581 r1584  
    12471247          RenderRays(rays); 
    12481248        } 
    1249          
     1249 
     1250        if (mShowRenderCost)  
     1251          RenderRenderCost(); 
    12501252  } 
    12511253  mFrame++; 
     
    14071409} 
    14081410 
    1409  
    1410 void 
    1411 QtGlRendererWidget::RenderInfo() 
    1412 { 
    1413   QString s; 
    1414   int vc = 0; 
    1415   if (mViewCellsManager) 
    1416         vc = mViewCellsManager->GetViewCells().size(); 
    1417   int filter = 0; 
    1418   if (mViewCellsManager) 
    1419         filter = mViewCellsManager->GetMaxFilterSize(); 
    1420  
    1421   s.sprintf("frame:%04d viewpoint:(%4.1f,%4.1f,%4.1f) dir:(%4.1f,%4.1f,%4.1f) viewcells:%04d filter:%04d pvs:%04d error:%5.5f\%", 
    1422                         mFrame, 
    1423                         mViewPoint.x, 
    1424                         mViewPoint.y, 
    1425                         mViewPoint.z, 
    1426                         mViewDirection.x, 
    1427                         mViewDirection.y, 
    1428                         mViewDirection.z, 
    1429                         vc, 
    1430  
    1431                         filter, 
    1432                         mPvsSize, 
    1433                         mRenderError*100.0f 
    1434                         ); 
    1435    
    1436   glColor3f(0.0f,0.0f,0.0f); 
    1437   renderText(0,20,s); 
    1438    
    1439   if (mShowRenderCost) { 
     1411void 
     1412QtGlRendererWidget::RenderRenderCost() 
     1413{ 
    14401414        static vector<float> costFunction; 
    14411415        static float maxCost = -1; 
     
    15311505 
    15321506        } 
    1533   } 
     1507   
     1508 
     1509 
     1510} 
     1511 
     1512void 
     1513QtGlRendererWidget::RenderInfo() 
     1514{ 
     1515  QString s; 
     1516  int vc = 0; 
     1517  if (mViewCellsManager) 
     1518        vc = mViewCellsManager->GetViewCells().size(); 
     1519  int filter = 0; 
     1520  if (mViewCellsManager) 
     1521        filter = mViewCellsManager->GetMaxFilterSize(); 
     1522 
     1523  s.sprintf("frame:%04d viewpoint:(%4.1f,%4.1f,%4.1f) dir:(%4.1f,%4.1f,%4.1f) viewcells:%04d filter:%04d pvs:%04d error:%5.5f\%", 
     1524                        mFrame, 
     1525                        mViewPoint.x, 
     1526                        mViewPoint.y, 
     1527                        mViewPoint.z, 
     1528                        mViewDirection.x, 
     1529                        mViewDirection.y, 
     1530                        mViewDirection.z, 
     1531                        vc, 
     1532 
     1533                        filter, 
     1534                        mPvsSize, 
     1535                        mRenderError*100.0f 
     1536                        ); 
     1537   
     1538  glColor3f(0.0f,0.0f,0.0f); 
     1539  renderText(0,20,s); 
     1540   
    15341541} 
    15351542 
     
    17291736  connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowViewCells(bool))); 
    17301737 
    1731   cb = new QCheckBox("Show render cost", hbox); 
     1738  cb = new QCheckBox("Render cost curve", hbox); 
    17321739  hlayout->addWidget(cb); 
    17331740  cb->setChecked(false); 
    17341741  connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowRenderCost(bool))); 
    17351742 
    1736   cb = new QCheckBox("Show pvs sizes", hbox); 
     1743  cb = new QCheckBox("Show render cost", hbox); 
    17371744  hlayout->addWidget(cb); 
    17381745  cb->setChecked(false); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.h

    r1581 r1584  
    208208  QtGlRendererWidget() {}; 
    209209 
     210  void 
     211  RenderRenderCost(); 
     212 
    210213  virtual void SetupCamera(); 
    211214  // setup a transformation for manipulator 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Ray.cpp

    r1583 r1584  
    2929   
    3030  // apply the standard precomputation 
    31   Precompute(); 
     31  //Precompute(); 
     32  // $$ JB precomputation will be applied only when the origin/dir valueas are set 
     33  SetId(); 
    3234} 
    3335 
     
    3638{ 
    3739  // initialize inverted dir 
    38   invDir.SetValue(0.0, 0.0, 0.0); 
    39    
     40  //  invDir.SetValue(0.0, 0.0, 0.0); 
    4041  SetId(); 
     42  ComputeInvertedDir(); 
    4143} 
    4244 
     
    8385Ray::ComputeInvertedDir() const 
    8486{ 
    85   if ( (invDir.x != 0.0) || 
    86        (invDir.y != 0.0) || 
    87        (invDir.z != 0.0) ) 
    88     return; // has been already precomputed 
     87  //  if ( (invDir.x != 0.0) || 
     88  //       (invDir.y != 0.0) || 
     89  //       (invDir.z != 0.0) ) 
     90  //    return; // has been already precomputed 
    8991 
    9092  const float eps = 1e-6f; 
     
    240242  if (vssRay.mTerminationObject) 
    241243        intersections.push_back(Intersection(len, -vssRay.GetDir(), vssRay.mTerminationObject, 0)); 
     244 
    242245   
    243246  Precompute(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Ray.h

    r1528 r1584  
    131131    depth = 0; 
    132132    Init(); 
     133        Precompute(); 
    133134  } 
    134135 
     
    231232                                        Vector3 &extP) const; 
    232233 
     234  Vector3 GetInvDir() const { return invDir; } 
     235   
    233236private: 
    234237  Vector3 loc, dir;             // Describes ray origin and vector 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp

    r1583 r1584  
    1010#define DEBUG_RAYCAST 0 
    1111 
     12#define EXACT_BOX_CLIPPING 1 
    1213 
    1314RayCaster::RayCaster(const Preprocessor &preprocessor): 
     
    4344                                                        Intersection &hit) 
    4445{ 
    45         if (!hit.mObject)  
    46         { 
    47                 // compute intersection with the scene bounding box 
    48                 static Ray ray; 
    49                 mPreprocessor.SetupRay(ray, origin, direction); 
    50  
    51                 float tmin, tmax; 
    52                 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && (tmin < tmax)) 
    53                 { 
    54                         hit.mPoint = ray.Extrap(tmax); 
    55                 } 
    56                 else 
    57                 { 
    58                         return false; 
    59                 }                
    60         }  
    61         else if (mPreprocessor.mDetectEmptyViewSpace) 
    62         { 
    63                 if (DotProd(hit.mNormal, direction) >= 0)  
    64                 {        
    65                         hit.mObject = NULL; 
    66                         return false; 
    67                 } 
     46        if (!hit.mObject)  { 
     47          // compute intersection with the scene bounding box 
     48#if EXACT_BOX_CLIPPING 
     49          static Ray ray; 
     50          mPreprocessor.SetupRay(ray, origin, direction); 
     51           
     52          float tmin, tmax; 
     53          if (box.ComputeMinMaxT(ray, &tmin, &tmax) && (tmin < tmax)) { 
     54                hit.mPoint = ray.Extrap(tmax); 
     55          } 
     56          else { 
     57                //              cout<<" invalid hp "<<tmin<<" "<<tmax<<endl; 
     58                //              cout<<" box "<<box<<endl; 
     59                //              cout<<" origin "<<origin<<endl; 
     60                //              cout<<" direction "<<direction<<endl; 
     61                //              cout<< "inv dir"<<ray.GetInvDir()<<endl; 
     62                return false; 
     63          } 
     64#else 
     65          hit.mPoint = origin + direction*Magnitude(box.Diagonal()); 
     66#endif 
    6867        } 
    69  
     68        else if (mPreprocessor.mDetectEmptyViewSpace) { 
     69          if (DotProd(hit.mNormal, direction) >= 0) {    
     70                hit.mObject = NULL; 
     71                return false; 
     72          } 
     73        } 
     74         
    7075        return true; 
    7176} 
     
    8893        if (pruneInvalidRays) 
    8994        { 
    90                 if (!hitA.mObject && !hitB.mObject) 
    91                 { 
    92                         return 0; 
    93                 } 
     95          if (!hitA.mObject && !hitB.mObject) { 
     96                return 0; 
     97          } 
     98           
     99        } 
    94100         
    95                 // inside test for bounding box 
    96                 // enlarge box slightly so the view point fits for sure 
    97                 AxisAlignedBox3 sbox = box; 
    98                 sbox.Enlarge(Vector3(-Limits::Small)); 
    99  
    100                 if (!sbox.IsInside(simpleRay.mOrigin)) 
    101                 { 
    102                         return 0; 
    103                 } 
    104         } 
    105  
    106101        const bool validA =  
    107                 ValidateRay(simpleRay.mOrigin, simpleRay.mDirection, box, hitA); 
     102          ValidateRay(simpleRay.mOrigin, simpleRay.mDirection, box, hitA); 
     103         
    108104        if (!validA && pruneInvalidRays) 
    109         { 
     105          { 
    110106                return 0; 
    111         } 
    112  
     107          } 
     108         
    113109        const bool validB = castDoubleRay &&  
    114                 ValidateRay(simpleRay.mOrigin, -simpleRay.mDirection, box, hitB); 
    115  
     110          ValidateRay(simpleRay.mOrigin, -simpleRay.mDirection, box, hitB); 
     111         
    116112        if (!validB && pruneInvalidRays) 
    117         { 
     113          { 
    118114                return 0; 
    119115        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1582 r1584  
    623623                        // create the meshes and compute volumes 
    624624                        vm->FinalizeViewCells(true); 
    625                         vm->mViewCellsTree->AssignRandomColors(); 
     625                        //                      vm->mViewCellsTree->AssignRandomColors(); 
    626626                } 
    627627 
     
    15211521        } 
    15221522 
     1523        mViewCellsTree->AssignRandomColors(); 
     1524 
    15231525        mTotalAreaValid = false; 
    15241526} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/default.env

    r1583 r1584  
    77 
    88#filename ../data/City4M/City4M.obj 
    9 # filename ../data/CityModel/CityModel.obj 
     9#filename ../data/CityModel/CityModel.obj 
    1010# filename ../data/GrandCanyon/grandcanyon1_RotXmin90.obj 
    1111# filename ../data/glasgow/glasgow1.x3d 
    1212#       filename vienna.x3d 
    13 # filename ../data/vienna/vienna-simple.x3d 
     13filename ../data/vienna/vienna-simple.x3d 
    1414# filename ../data/vienna/vienna-buildings.x3d 
    1515# filename ../data/vienna/city1500_flat_1.x3d 
    16 #filename ../data/vienna/vienna-buildings.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 
    1717#;../data/vienna/vienna-plane.x3d;../data/vienna/vienna-roads.x3d 
    1818# filename ../data/vienna/viewcells-25-sel.x3d 
    1919#filename ../data/atlanta/atlanta2.x3d 
    20 filename ../data/soda/soda.dat 
     20#filename ../data/soda/soda.dat 
    2121#filename ../data/test1/test2.x3d 
    2222#filename ../data/soda/soda5.dat 
     
    5353        visibilityFilterWidth   0.01 
    5454        visibilityFile visibility.xml 
    55         loadMeshes false 
     55        loadMeshes true 
    5656        loadKdTree      false 
    5757        exportKdTree false 
     
    5959 
    6060ObjParser { 
    61         meshGrouping 500 
     61        meshGrouping 1 
    6262} 
    6363 
     
    142142        sahUseFaces false 
    143143        Termination { 
    144                 minCost 1 
     144                minCost 0.95 
    145145                maxDepth 30 
    146146                maxCostRatio 1.0 
    147147                ct_div_ci 0.5 
    148                 maxNodes 200000 
    149  
     148                maxNodes 100000 
     149#200000 
    150150#500000  
    151151        } 
     
    173173 
    174174 
     175 
     176 
    175177ViewCells { 
    176178        # samples used for view cell construction 
    177179        Construction { 
    178                 samples 100000 
    179                 samplesPerPass 100000 
    180         } 
    181  
    182         Filter { 
    183                 maxSize 5 
    184                 width  0.02 
     180                samples 0 
     181                samplesPerPass 1500000 
    185182        } 
    186183 
    187184        #number of active view cells 
    188185        active 5000 
    189         maxStaticMemory 200 
     186        maxViewCells 5000 
     187 
     188        maxStaticMemory 40 
    190189 
    191190        exportToFile true 
    192         loadFromFile true 
    193          
     191        loadFromFile false 
     192 
    194193        #type kdTree 
    195194        #type vspKdTree 
    196195        #type bspTree 
    197196        type vspBspTree 
    198         #type vspOspTree 
    199197        #type sceneDependent 
    200198         
    201199        height 5.0 
    202         maxViewCells 5000 
    203200 
    204201        #percentage of total visible objects where pvs is considered invalid 
    205202        maxPvsRatio 1.0 
    206203                 
    207         pruneEmptyViewCells false 
    208204        processOnlyValidViewCells false 
    209205 
    210206        #stats viewCellStats.log 
    211207 
    212         samplingType directional 
    213         #samplingType box 
     208        #samplingType directional 
     209        samplingType box 
    214210 
    215211        PostProcess { 
    216212                # how much samples are used for post processing 
    217                 samples 100000 
     213                samples 0 
    218214                renderCostWeight 1.0 
    219215                maxCostRatio 0.1 
     
    222218                maxMergesPerPass 5000 
    223219                useRaysForMerge false 
    224                 refine false 
    225220                compress false 
    226                 merge false 
     221                merge true 
    227222        } 
    228223 
    229224        Visualization { 
    230225                # how much samples we use for visualization 
    231                 samples 100000 
     226                samples 0 
    232227                #colorCode PVS 
    233228                #colorCode MergedLeaves 
     
    235230                colorCode Random 
    236231                exportRays false 
    237                 exportGeometry false 
     232                exportGeometry true 
    238233                exportMergedViewCells false 
    239234                useClipPlane true 
    240235                clipPlaneAxis 1 
    241         } 
    242  
    243         showVisualization false  
     236                clipPlanePos  0.3 
     237        } 
     238 
     239        showVisualization true 
    244240        evaluateViewCells false 
    245241         
    246242        Evaluation { 
    247                 samplesPerPass 500 
    248                 samples 1000 
     243                samplesPerPass 1000000 
     244                samples 1000000 
    249245                statsPrefix ../scripts/viewCells 
     246                #samplingType directional 
     247                samplingType box 
     248                histogram true 
     249                histoStepSize 5000 
    250250        } 
    251251 
     
    259259#       filename ../data/soda/soda5-viewcells.xml 
    260260#       filename ../scripts/viewcells_atlanta.xml 
    261         filename ../data/soda/soda-viewcells-5000.xml 
     261#       filename ../data/soda/soda-viewcells-5000.xml 
    262262#       filename ../data/test1/test-viewcells.xml 
    263263 
     
    268268 
    269269 
    270 #       filename ../data/vienna/vsposp-seq-viewCells.xml.gz 
     270        filename ../data/vienna/vsposp-seq-viewCells.xml.gz 
    271271 
    272272#       filename ../data/atlanta/viewcells_atlanta3.xml 
     
    291291 
    292292 
    293  
    294293VspBspTree { 
    295294        Construction { 
    296                 samples 800000 
    297                 epsilon 0.0005 
     295                samples 500000 
     296                epsilon 0.0000001 
    298297                randomize false 
    299298                renderCostWeight 1.0 
     
    310309         
    311310        # maximal candidates for split planes 
    312         maxPolyCandidates 150 
     311        maxPolyCandidates 0 
    313312 
    314313        usePolygonSplitIfAvailable false 
     
    334333                minPolygons             -1 
    335334                maxDepth                25 
    336                 minPvs                  -15 
    337                 minProbability          0.00000001 
    338                 maxRayContribution      1.8 
    339                 maxCostRatio            1.8 
     335                minPvs                  0 
     336                minProbability          0.000001 
     337                maxRayContribution      1 
     338                maxCostRatio            0.9 
    340339                missTolerance           6 
    341340                globalCostMissTolerance 4 
    342                 minGlobalCostRatio      0.0000001 
    343 #               minGlobalCostRatio      0.0001 
    344 # $$MAXVIEWCELLS 
     341                #minGlobalCostRatio      0.0000001 
     342                minGlobalCostRatio      0.0001 
     343# $$ MAX         
    345344                maxViewCells            5000 
    346345         
     
    356355         
    357356        useSplitCostQueue true 
    358         useCostHeuristics true 
     357        useCostHeuristics false 
    359358 
    360359        splitUseOnlyDrivingAxis false 
     
    362361        useRandomAxis false 
    363362        usePolygonSplitIfAvailable false 
    364         useBreathFirstSplits false 
     363        nodePriorityQueueType 0 
    365364 
    366365        Visualization { 
     
    370369} 
    371370 
     371BspTree { 
     372        Construction { 
     373                samples 100000 
     374                epsilon 0.005 
     375        } 
     376 
     377 
     378        # random polygon       = 1 
     379        # axis aligned         = 2 
     380        # least splits         = 4 
     381        # balanced polygons    = 8 
     382        # balanced view cells  = 16 
     383        # largest polygon area = 32 
     384        # vertical axis        = 64 
     385        # blocked rays         = 128 
     386        # least ray splits     = 256 
     387        # balanced rays        = 512 
     388        # pvs                  = 1024 
     389 
     390        # least splits + balanced polygons 
     391        #splitPlaneStrategy 12 
     392         
     393        #axis aligned + vertical axis 
     394        #splitPlaneStrategy 66 
     395         
     396        # axis aligned + balanced view cells 
     397        # splitPlaneStrategy 18 
     398         
     399        # largest polygon area 
     400        #splitPlaneStrategy 32 
     401         
     402        # axus aligned + balanced polygons 
     403        #splitPlaneStrategy 72 
     404         
     405        # axis aligned + blocked rays 
     406        #splitPlaneStrategy 130 
     407         
     408        #splitPlaneStrategy 384 
     409        #splitPlaneStrategy 130 
     410         
     411        splitPlaneStrategy 32 
     412         
     413        maxPolyCandidates 100 
     414        maxRayCandidates 0 
     415         
     416        maxTests 10000 
     417         
     418        subdivisionStats ../subDivisionStats.log 
     419 
     420        # factors for evaluating split plane costs 
     421        Factor { 
     422                verticalSplits 1.0 
     423                largestPolyArea 1.0 
     424                blockedRays 1.0 
     425                leastRaySplits 1.0 
     426                balancedRays 1.0 
     427                pvs 1.0 
     428                leastSplits 1.0 
     429                balancedPolys 1.0 
     430                balancedViewCells 1.0 
     431        } 
     432         
     433        Termination { 
     434                # parameters used for autopartition 
     435                minRays -1 
     436                minPolygons 0 
     437                maxDepth 30 
     438                minPvs -1 
     439                minProbability 0.00001 
     440                maxRayContribution 9999 
     441                maxViewCells 50000 
     442 
     443                # used for pvs criterium 
     444                ct_div_ci 0.0 
     445         
     446                maxCostRatio 0.9 
     447                 
     448                # axis aligned splits 
     449                AxisAligned { 
     450                        minPolys 5000 
     451                        minRays 500 
     452                        minObjects 10 
     453                        ct_div_ci 0.5 
     454                } 
     455        } 
     456         
     457        AxisAligned { 
     458                splitBorder 0.01 
     459        } 
     460         
     461         
     462        Visualization { 
     463                # x3d visualization of the split planes 
     464                exportSplits false 
     465        } 
     466} 
     467 
Note: See TracChangeset for help on using the changeset viewer.