Changeset 475


Ignore:
Timestamp:
12/21/05 20:21:30 (18 years ago)
Author:
mattausch
Message:

bsp merging possible again

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r474 r475  
    1313#;../data/vienna/vienna-plane.x3d 
    1414#       filename ../data/vienna/viewcells-25-sel.x3d 
    15         filename ../data/atlanta/atlanta2.x3d 
     15#       filename ../data/atlanta/atlanta2.x3d 
    1616#       filename ../data/soda/soda.dat 
    17 #       filename ../data/soda/soda5.dat 
     17        filename ../data/soda/soda5.dat 
    1818} 
    1919 
     
    153153         
    154154        height 5.0 
    155         maxViewCells 3000 
     155        maxViewCells 100 
    156156         
    157157        PostProcessing { 
     
    240240         
    241241        # maximal tested rays for split cost heuristics 
    242         maxTests 10000 
     242        maxTests 1000 
    243243         
    244244        # factors for evaluating split plane costs 
     
    251251        Termination { 
    252252                # parameters used for autopartition 
    253                 minRays                 10 
     253                minRays                 1 
    254254                minPolygons             -1 
    255255                maxDepth                30 
     
    258258                maxRayContribution      0.005 
    259259                maxCostRatio            0.9 
    260                 missTolerance           3 
     260                missTolerance           2 
    261261                #maxAccRayLength        100 
    262262                 
     
    282282                exportSplits true 
    283283                exportRays true 
    284                 exportGeometry true 
     284                exportGeometry false 
    285285        } 
    286286} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp

    r471 r475  
    615615        const Vector3 dir = termination - origin; 
    616616 
    617         stack<RayTraversalData > tStack; 
     617        stack<RayTraversalData> tStack; 
    618618 
    619619        Intersectable::NewMail(); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp

    r473 r475  
    2525{ 
    2626        DEL_PTR(mViewCellsManager); 
    27  
    2827        DEL_PTR(mBspTree); 
    2928        DEL_PTR(mKdTree); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Ray.cpp

    r466 r475  
    142142void 
    143143PassingRaySet::AddRay2(const Ray &ray, 
    144                                                                                         const int objects, 
    145                                                                                         const int viewcells 
    146                                                                                         ) 
     144                                          const int objects, 
     145                                          const int viewcells 
     146                                          ) 
    147147{ 
    148148  int i = GetEntryIndex(ray.GetDir()); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h

    r466 r475  
    55#include "Matrix4x4.h" 
    66#include "Vector3.h" 
     7//#include "ViewCellBsp.h" 
    78 
    89// forward declarations 
     
    6667   
    6768  vector<Intersection> intersections; 
    68   // vector<BspIntersection> bspIntersections; 
     69 // vector<BspIntersection> bspIntersections; 
    6970  vector<KdLeaf *> kdLeaves; 
    7071  vector<Intersectable *> testedObjects; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RenderSimulator.cpp

    r473 r475  
    99void SimulationStatistics::Print(ostream &app) const 
    1010{ 
    11         app << "===== Simulation statistics ===============\n"; 
     11        app << "===== Render Simulation statistics ===============\n"; 
    1212 
    1313        app << setprecision(4); 
     
    2121        app << "#AVG_RENDER_TIME ( average render time )\n" << avgRenderTime << "\n"; 
    2222 
    23         app << "#AVG_RENDER_TIME_NO_OVERHEAD ( average render time without overhead )\n" << avgRtWithoutOverhead << "\n"; 
     23        app << "#AVG_RENDER_TIME_NO_OVERHEAD ( average render time without overhead )\n"  
     24                << avgRtWithoutOverhead << "\n"; 
    2425         
    25         app << "===== END OF Simulation statistics ==========\n"; 
     26        app << "===== END OF Render Simulation statistics ==========\n"; 
    2627} 
    2728 
     
    6970                it_end = mViewCellsManager->GetViewCells().end(); 
    7071 
     72         
    7173        for (it = mViewCellsManager->GetViewCells().begin(); it != it_end; ++ it) 
    7274        { 
     
    7577                // probability of view cell 
    7678                const float pInVc = mViewCellsManager->GetProbability(vc); 
    77                                  
     79                Debug << "prop: " << pInVc << endl; 
    7880                // compute render time of PVS times probability that view point is in view cell 
    7981                const float vcCost = pInVc * mViewCellsManager->GetRendercost(vc, mObjRenderCost); 
    80          
     82                Debug << "cost: " << vcCost << " rcost: " << mViewCellsManager->GetRendercost(vc, mObjRenderCost) << endl; 
     83 
    8184                // crossing the border of a view cell is depending on the move speed 
    8285                // and the probability that a view cell border is crossed 
    8386                loadPvsOverhead += GetCrossVcProbability() * mVcOverhead; 
    8487 
     88                Debug << "crossvc: " << GetCrossVcProbability() * mVcOverhead << endl; 
    8589                //-- update statistics 
    8690                renderTime += vcCost; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssPreprocessor.cpp

    r473 r475  
    176176  if (!use2dSampling) { 
    177177        Vector3 normal; 
    178         int i = RandomValue(0, mObjects.size()-1); 
     178        int i = (int)RandomValue(0, mObjects.size()-1); 
    179179        Intersectable *object = mObjects[i]; 
    180180        object->GetRandomSurfacePoint(point, normal); 
     
    513513         
    514514        //-- several visualizations and statistics 
     515        Debug << "view cells after post processing: " << endl; 
    515516        mViewCellsManager->PrintStatistics(Debug); 
    516517         
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r473 r475  
    391391         
    392392        //-- several visualizations and statistics 
     393        Debug << "view cells after post processing: " << endl; 
    393394        mViewCellsManager->PrintStatistics(Debug); 
    394395 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r474 r475  
    742742 
    743743                if (r == mRoot) 
    744                         Debug << "BSP tree construction time spent at root: " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
     744                        Debug << "BSP tree construction time spent at root: " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 
    745745        } 
    746746 
     
    11531153                else 
    11541154                { 
    1155                         const int candidateIdx = (int)RandomValue(0, (int)data.mRays->size() - 1); 
     1155                        const int candidateIdx = (int)RandomValue(0, (Real)((int)data.mRays->size() - 1)); 
    11561156                        BoundedRay *bRay = (*data.mRays)[candidateIdx]; 
    11571157 
     
    15001500        for (int i = 0; i < limit; ++ i) 
    15011501        { 
    1502                 const int testIdx = useRand ? (int)RandomValue(0, limit - 1) : i; 
     1502                const int testIdx = useRand ? (int)RandomValue(0, (Real)(limit - 1)) : i; 
    15031503         
    15041504                BoundedRay *bRay = rays[testIdx]; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r473 r475  
    851851}; 
    852852 
    853 struct BspIntersection { 
    854   // the point of intersection 
    855   float mT; 
     853struct BspIntersection  
     854{ 
     855        // the point of intersection 
     856        float mT; 
    856857   
    857   BspLeaf *mLeaf; 
     858        BspLeaf *mLeaf; 
    858859   
    859   BspIntersection(const float t, BspLeaf *l): 
     860        BspIntersection(const float t, BspLeaf *l): 
    860861        mT(t), mLeaf(l) {} 
    861862   
    862   BspIntersection() {} 
     863        BspIntersection() {} 
    863864   
    864   bool operator<(const BspIntersection &b) const { 
    865         return mT       <b.mT; } 
     865        bool operator<(const BspIntersection &b) const  
     866        { 
     867                return mT < b.mT;  
     868        } 
     869}; 
     870 
     871struct BspRay  
     872{ 
     873        VssRay *vssRay; 
     874 
     875        std::vector<BspIntersection> intersections; 
     876 
     877        BspRay(VssRay *ray): vssRay(ray) {} 
    866878}; 
    867879 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r474 r475  
    255255                 
    256256                if (added) 
    257                         ray.mPvsContribution++; 
     257                        ++ ray.mPvsContribution; 
    258258                 
    259259                ray.mRelativePvsContribution += contribution; 
     
    312312} 
    313313 
     314void ViewCellsManager::PrintStatistics(ostream &s) const 
     315{ 
     316        s << mViewCellsStats << endl; 
     317} 
     318 
    314319/**********************************************************************/ 
    315320/*                   BspViewCellsManager implementation               */ 
     
    366371                // no view cells loaded  
    367372                mBspTree->Construct(objects, constructionRays); 
    368  
    369373                // collect final view cells 
    370374                mBspTree->CollectViewCells(mViewCells); 
     
    375379        } 
    376380 
     381        mBspTree->EvaluateViewCellsStats(mViewCellsStats); 
     382 
    377383        // destroy rays created only for construction 
    378384        CLEAR_CONTAINER(constructionRays); 
     
    434440        int pvsSize = 0; 
    435441 
    436         ViewCellsStatistics vcStats; 
    437         mBspTree->EvaluateViewCellsStats(vcStats); 
    438         Debug << "original view cell partition:\n" << vcStats << endl; 
     442        Debug << "original view cell partition:\n" << mViewCellsStats << endl; 
    439443                 
    440444        if (1) // export view cells before merge 
     
    446450                { 
    447451                        exporter->SetWireframe(); 
    448                         exporter->ExportBspLeaves(*mBspTree, vcStats.maxPvs); 
     452                        exporter->ExportBspLeaves(*mBspTree, mViewCellsStats.maxPvs); 
    449453                        //exporter->ExportBspViewCellPartition(*mBspTree, 0); 
    450454                                 
     
    463467                cout << "finished" << endl; 
    464468 
    465                 //-- render simulation 
    466                 cout << "\nevaluating bsp view cells render time before merge ... "; 
    467469                //-- render simulation after merge 
    468470                cout << "\nevaluating bsp view cells render time after merge ... "; 
     
    490492 
    491493        RayContainer::const_iterator rit, rit_end = rays.end(); 
    492         vector<Ray::BspIntersection>::const_iterator iit; 
     494        vector<BspIntersection>::const_iterator iit; 
    493495 
    494496        int limit = min((int)rays.size(), mPostProcessSamples); 
     
    527529        cout << "merged " << merged << " view cells in " 
    528530                 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 
     531 
     532        Debug << "Postprocessing: Merged " << merged << " view cells in " 
     533                  << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 
     534 
     535        //-- recount pvs 
     536        mViewCellsStats.Reset(); 
     537        mBspTree->EvaluateViewCellsStats(mViewCellsStats); 
    529538 
    530539        return merged; 
     
    640649  //-- some rays for output 
    641650  const int raysOut = min((int)sampleRays.size(), mVisualizationSamples); 
    642   Debug << "visualization using " << raysOut << " samples" << endl; 
     651 
     652  Debug << "Output view cells:" << endl; 
    643653 
    644654  if (1) 
     
    650660                  bspLeaves.push_back(mBspTree->GetRandomLeaf());        
    651661 
    652            
    653662          for (int i = 0; i < bspLeaves.size(); ++ i) 
    654663          { 
     
    876885} 
    877886 
    878 void BspViewCellsManager::PrintStatistics(ostream &s) const 
    879 { 
    880         ViewCellsStatistics vcStats; 
    881         mBspTree->EvaluateViewCellsStats(vcStats); 
    882         s << vcStats << endl; 
    883 } 
    884887 
    885888 
     
    920923        // create the view cells 
    921924        mKdTree->CreateAndCollectViewCells(mViewCells); 
     925        //mKdTree->EvaluateViewCellsStats(mViewCellsStats); 
    922926 
    923927        return 0; 
     
    11291133} 
    11301134 
    1131  
    1132 void KdViewCellsManager::PrintStatistics(ostream &s) const 
    1133 { 
    1134 } 
    1135  
    1136  
    11371135int KdViewCellsManager::CastLineSegment(const Vector3 &origin, 
    11381136                                                                                const Vector3 &termination, 
     
    11891187 
    11901188        mVspKdTree->Construct(constructionRays, sceneBbox); 
    1191          
    1192         // collect view cells 
    11931189        mVspKdTree->CollectViewCells(mViewCells); 
     1190        //mVspBspTree->EvaluateViewCellsStats(mViewCellsStats); 
    11941191 
    11951192        Debug << mVspKdTree->GetStatistics() << endl; 
     
    13121309        } 
    13131310 
    1314         // evaluate maximal pvs 
    1315         ViewCellsStatistics vcStats; 
    1316         mVspKdTree->EvaluateViewCellsStats(vcStats); 
    1317          
    13181311        //-- export final view cells 
    13191312        Exporter *exporter = Exporter::GetExporter("vspkdtree_merged.x3d");  
     
    13531346} 
    13541347 
    1355 void VspKdViewCellsManager::PrintStatistics(ostream &s) const 
    1356 { 
    1357         ViewCellsStatistics vcStats; 
    1358  
    1359         mVspKdTree->EvaluateViewCellsStats(vcStats); 
    1360         Debug << vcStats << endl; 
    1361 } 
    1362  
    13631348 
    13641349int VspKdViewCellsManager::CastLineSegment(const Vector3 &origin, 
     
    13801365} 
    13811366 
     1367VspBspViewCellsManager::~VspBspViewCellsManager() 
     1368{ 
     1369        CLEAR_CONTAINER(mBspRays); 
     1370} 
     1371 
    13821372float VspBspViewCellsManager::GetProbability(ViewCell *viewCell) 
    13831373{ 
     
    13861376} 
    13871377 
     1378float VspBspViewCellsManager::GetArea(ViewCell *viewCell) const 
     1379{ 
     1380        PolygonContainer geom; 
     1381 
     1382        // compute view cell area 
     1383        mVspBspTree->ConstructGeometry(dynamic_cast<BspViewCell *>(viewCell), geom); 
     1384         
     1385        const float area = Polygon3::GetArea(geom); 
     1386        CLEAR_CONTAINER(geom); 
     1387 
     1388        return area; 
     1389} 
    13881390 
    13891391float VspBspViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 
     
    14121414                return 0; 
    14131415 
    1414         Debug << "Constructing vsp bsp view cells" << endl; 
    1415  
    14161416        int sampleContributions = 0; 
    14171417         
     
    14231423        mVspBspTree->Construct(constructionRays); 
    14241424        mVspBspTree->CollectViewCells(mViewCells); 
     1425        mVspBspTree->EvaluateViewCellsStats(mViewCellsStats); 
    14251426         
    14261427        Debug << mVspBspTree->GetStatistics() << endl; 
     
    14331434 
    14341435 
     1436void VspBspViewCellsManager::ConstructBspRays(const VssRayContainer &rays, 
     1437                                                                                          const int numSamples) 
     1438{ 
     1439        VssRayContainer::const_iterator it, it_end = rays.end(); 
     1440 
     1441        for (it = rays.begin(); it != rays.end() && mBspRays.size() < numSamples; ++ it) 
     1442        { 
     1443                VssRay *vssRay = *it; 
     1444                BspRay *ray = new BspRay(vssRay); 
     1445 
     1446                ViewCellContainer viewCells; 
     1447 
     1448                CastLineSegment(vssRay->mTermination, vssRay->mOrigin, viewCells); 
     1449 
     1450                ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
     1451                 
     1452                for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
     1453                { 
     1454                        BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit); 
     1455                        ray->intersections.push_back(BspIntersection(0, vc->mLeaves[0])); 
     1456                } 
     1457 
     1458                mBspRays.push_back(ray); 
     1459        } 
     1460} 
     1461 
     1462 
    14351463int VspBspViewCellsManager::PostProcess(const ObjectContainer &objects,  
    14361464                                                                                const VssRayContainer &rays) 
    14371465{ 
    1438         Debug << "Post processing view cells" << endl; 
     1466        if (mBspRays.empty()) 
     1467                ConstructBspRays(rays, mConstructionSamples); 
     1468         
    14391469        if (!ViewCellsConstructed()) 
    14401470        { 
     
    14471477        int pvsSize = 0; 
    14481478 
    1449          
    1450         ViewCellsStatistics vcStats; 
    1451         mVspBspTree->EvaluateViewCellsStats(vcStats); 
    1452         Debug << "original view cell partition:\n" << vcStats << endl; 
     1479        Debug << "original view cell partition:\n" << mViewCellsStats << endl; 
    14531480                 
    14541481        if (1) // export view cells 
     
    14591486                if (exporter) 
    14601487                { 
    1461                         exporter->SetWireframe(); 
    1462                         exporter->ExportBspViewCellPartition(*mVspBspTree, vcStats.maxPvs); 
     1488                        //exporter->SetWireframe(); 
     1489                        exporter->SetFilled(); 
     1490                        exporter->ExportBspViewCellPartition(*mVspBspTree, mViewCellsStats.maxPvs); 
    14631491                                 
    14641492                        if (0) 
     
    14871515        //-- merge or subdivide view cells 
    14881516        int merged = 0; 
    1489 #if 0 
    1490  
    1491         RayContainer::const_iterator rit, rit_end = rays.end(); 
    1492         vector<Ray::BspIntersection>::const_iterator iit; 
    1493  
    1494         int limit = min((int)rays.size(), mPostProcessSamples); 
    1495  
    1496         for (int i = 0; i < limit; ++ i) 
     1517 
     1518        vector<BspIntersection>::const_iterator iit; 
     1519 
     1520        for (int i = 0; i < (int)mBspRays.size(); ++ i) 
    14971521        {   
    1498           VssRay *ray = rays[i]; 
     1522                BspRay *ray = mBspRays[i]; 
    14991523           
    1500           // traverse leaves stored in the rays and compare and merge consecutive 
    1501           // leaves (i.e., the neighbors in the tree) 
    1502           if (ray->bspIntersections.size() < 2) 
    1503                 continue; 
     1524                // traverse leaves stored in the rays and compare and merge consecutive 
     1525                // leaves (i.e., the neighbors in the tree) 
     1526                if (ray->intersections.size() < 2) 
     1527                        continue; 
    15041528           
    1505           iit = ray->bspIntersections.begin(); 
     1529                iit = ray->intersections.begin(); 
    15061530 
    15071531                BspLeaf *previousLeaf = (*iit).mLeaf; 
    15081532                ++ iit; 
    15091533                 
    1510                 for (; iit != ray->bspIntersections.end(); ++ iit) 
     1534                for (; iit != ray->intersections.end(); ++ iit) 
    15111535                { 
    15121536                        BspLeaf *leaf = (*iit).mLeaf; 
     
    15221546                } 
    15231547        } 
    1524 #endif 
     1548 
    15251549        //-- stats and visualizations 
    15261550        cout << "finished" << endl; 
     
    15281552                 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 
    15291553 
     1554        Debug << "Postprocessing: Merged " << merged << " view cells in " 
     1555                  << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl << endl; 
     1556         
     1557        // reset view cells and stats 
     1558        mViewCells.clear(); 
     1559        mVspBspTree->CollectViewCells(mViewCells); 
     1560        mViewCellsStats.Reset(); 
     1561        mVspBspTree->EvaluateViewCellsStats(mViewCellsStats); 
    15301562 
    15311563        return merged; 
     
    15441576                return; 
    15451577 
    1546         //-- recount pvs 
    1547         ViewCellsStatistics vcStats; 
    1548         mVspBspTree->EvaluateViewCellsStats(vcStats); 
    1549  
     1578        if (mBspRays.empty()) 
     1579                ConstructBspRays(sampleRays, mConstructionSamples); 
     1580         
    15501581        if (1) // export view cells 
    15511582        { 
     
    15551586                if (exporter) 
    15561587                { 
    1557                         exporter->ExportBspViewCellPartition(*mVspBspTree, vcStats.maxPvs); 
     1588                        exporter->ExportBspViewCellPartition(*mVspBspTree, mViewCellsStats.maxPvs); 
    15581589                        delete exporter; 
    15591590                } 
     
    15691600        { 
    15701601                cout << "exporting splits ... "; 
    1571                 ExportSplits(objects, sampleRays); 
     1602                ExportSplits(objects); 
    15721603                cout << "finished" << endl; 
    15731604        } 
    15741605 
    1575         ExportBspPvs(objects, sampleRays); 
    1576 } 
    1577  
    1578  
    1579 void VspBspViewCellsManager::ExportSplits(const ObjectContainer &objects, 
    1580                                                                                   const VssRayContainer &sampleRays) 
     1606        ExportBspPvs(objects); 
     1607} 
     1608 
     1609 
     1610void VspBspViewCellsManager::ExportSplits(const ObjectContainer &objects) 
    15811611{ 
    15821612        Exporter *exporter = Exporter::GetExporter("bsp_splits.x3d"); 
     
    16011631                if (0) 
    16021632                { 
    1603                   VssRayContainer outRays; 
    1604                  
    1605                         int raysSize = min((int)sampleRays.size(), mVisualizationSamples); 
     1633                        VssRayContainer outRays; 
     1634                 
     1635                        int raysSize = min((int)mBspRays.size(), mVisualizationSamples); 
    16061636 
    16071637                        for (int i = 0; i < raysSize; ++ i) 
    1608                         { 
    16091638                                // only rays piercing geometry 
    1610                           outRays.push_back(sampleRays[i]); 
    1611                         } 
    1612                          
     1639                                outRays.push_back(mBspRays[i]->vssRay); 
     1640                                                 
    16131641                        // export rays  
    16141642                        exporter->ExportRays(outRays, RgbColor(1, 1, 0)); 
     
    16221650} 
    16231651 
    1624 void VspBspViewCellsManager::ExportBspPvs(const ObjectContainer &objects, 
    1625                                                                                   const VssRayContainer &sampleRays) 
     1652void VspBspViewCellsManager::ExportBspPvs(const ObjectContainer &objects) 
    16261653{ 
    16271654        bool exportRays = false; 
     
    16361663 
    16371664        //-- some rays for output 
    1638         const int raysOut = min((int)sampleRays.size(), mVisualizationSamples); 
     1665        const int raysOut = min((int)mBspRays.size(), mVisualizationSamples); 
    16391666        cout << "visualization using " << mVisualizationSamples << " samples" << endl; 
    1640          
     1667        Debug << "\nOutput view cells: " << endl; 
     1668 
    16411669        if (1) 
    16421670        { 
     
    16521680                        cout << "creating output for view cell " << i << " ... "; 
    16531681 
    1654                         //$$JB 
    1655 #if 0 
    16561682                        // check whether we can add the current ray to the output rays 
    16571683                        for (int k = 0; k < raysOut; ++ k)  
    16581684                        { 
    1659                                 VssRay *ray = sampleRays[k]; 
    1660  
    1661                                 for     (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 
     1685                                BspRay *ray = mBspRays[k]; 
     1686 
     1687                                for     (int j = 0; j < (int)ray->intersections.size(); ++ j) 
    16621688                                { 
    1663                                         BspLeaf *leaf = ray->bspIntersections[j].mLeaf; 
     1689                                        BspLeaf *leaf = ray->intersections[j].mLeaf; 
    16641690 
    16651691                                        if (vspBspLeaves[i]->GetViewCell() == leaf->GetViewCell())  
    16661692                                        { 
    1667                                                 vcRays.push_back(ray); 
     1693                                                vcRays.push_back(ray->vssRay); 
    16681694                                        } 
    16691695                                } 
    16701696                        } 
    1671 #endif 
     1697 
    16721698                        Intersectable::NewMail(); 
    16731699 
     
    16831709                        ObjectPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 
    16841710 
    1685                         //exporter->SetWireframe(); 
    1686                         exporter->SetFilled(); 
     1711                        exporter->SetWireframe(); 
     1712                        //exporter->SetFilled(); 
    16871713 
    16881714                        Material m;//= RandomMaterial(); 
     
    17281754                                }                        
    17291755                        } 
    1730                                  
     1756                        Debug << "here1 exportgeom: " << exportGeometry << endl; 
    17311757                        // output rest of the objects 
    17321758                        if (exportGeometry) 
     
    17651791 
    17661792                        cout << "creating output for view cell " << i << " ... "; 
    1767                         //$$ JB 
    1768 #if 0 
     1793 
    17691794                        // check whether we can add the current ray to the output rays 
    17701795                        for (int k = 0; k < raysOut; ++ k)  
    17711796                        { 
    1772                           Ray *ray = sampleRays[k]; 
    1773  
    1774                                 for     (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 
     1797                                BspRay *ray = mBspRays[k]; 
     1798 
     1799                                for     (int j = 0; j < (int)ray->intersections.size(); ++ j) 
    17751800                                { 
    1776                                         BspLeaf *leaf = ray->bspIntersections[j].mLeaf; 
     1801                                        BspLeaf *leaf = ray->intersections[j].mLeaf; 
    17771802 
    17781803                                        if (vc == leaf->GetViewCell())  
    17791804                                        { 
    1780                                                 vcRays.push_back(ray); 
     1805                                                vcRays.push_back(ray->vssRay); 
    17811806                                        } 
    17821807                                } 
    17831808                        } 
    1784 #endif 
     1809 
    17851810                        //bspLeaves[j]->Mail(); 
    17861811                        char s[64]; sprintf(s, "bsp-pvs%04d.x3d", i); 
     
    18071832                         
    18081833                        Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize()  
    1809                                         << ", piercing rays=" << (int)vcRays.size() << endl; 
     1834                                  << ", piercing rays=" << (int)vcRays.size() << endl; 
    18101835 
    18111836                         
     
    18391864                } 
    18401865        } 
    1841 } 
    1842  
    1843  
    1844 void VspBspViewCellsManager::PrintStatistics(ostream &s) const 
    1845 { 
    1846         ViewCellsStatistics vcStats; 
    1847         mVspBspTree->EvaluateViewCellsStats(vcStats); 
    1848         s << vcStats << endl; 
    1849 } 
     1866 
     1867        Debug << endl; 
     1868} 
     1869 
    18501870 
    18511871bool VspBspViewCellsManager::MergeVspBspLeafViewCells(BspLeaf *front,  
     
    18591879                return false; 
    18601880 
    1861         // change view cells of all leaves associated with the 
    1862         // previous view cells 
    1863  
     1881        // change view cells of all leaves 
     1882        // associated with the previous view cells 
    18641883        BspViewCell *fVc = front->GetViewCell(); 
    18651884        BspViewCell *bVc = back->GetViewCell(); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h

    r471 r475  
    55#include "VssRay.h" 
    66#include "Containers.h" 
     7#include "ViewCell.h" 
    78 
    89class ViewCell; 
     
    2122class AxisAlignedBox3; 
    2223class BspLeaf; 
     24class ViewCellsStatistics; 
     25 
     26struct BspRay; 
    2327 
    2428/** 
     
    6266                @param contributingSamples returns the number of contributingSamples 
    6367        */ 
    64   void  ComputeSampleContributions(const VssRayContainer &rays); 
    65  
    66  
    67   /** Computes sample contribution of a simgle ray to the view cells PVS. 
    68           @param ray finds intersections with view cells and holds the contribution 
    69           @param castRay true if ray should be cast to gain the information, false if ray 
    70           is already holding the information and need not be recast. 
     68        void  ComputeSampleContributions(const VssRayContainer &rays); 
     69 
     70 
     71        /** Computes sample contribution of a simgle ray to the view cells PVS. 
     72                @param ray finds intersections with view cells and holds the contribution 
     73                @param castRay true if ray should be cast to gain the information, false if ray 
     74                is already holding the information and need not be recast. 
    7175           
    72           @returns number of sample contributions 
    73   */ 
    74   virtual void ComputeSampleContributions(VssRay &ray 
    75                                                                                   ); 
     76                @returns number of sample contributions 
     77        */ 
     78        virtual void ComputeSampleContributions(VssRay &ray); 
    7679   
    7780        /** Prints out statistics of the view cells. 
    7881        */ 
    79         virtual void PrintStatistics(ostream &s) const = 0; 
     82        virtual void PrintStatistics(ostream &s) const; 
    8083 
    8184        /** Post processes view cells givemŽa number of rays. 
    8285        */ 
    83   virtual int PostProcess(const ObjectContainer &objects,  
    84                                                   const VssRayContainer &rays) = 0; 
     86        virtual int PostProcess(const ObjectContainer &objects,  
     87                                                        const VssRayContainer &rays) = 0; 
    8588 
    8689        /** Show visualization of the view cells. 
     
    224227        float mTotalAreaValid; 
    225228        float mTotalArea; 
     229 
     230        ViewCellsStatistics mViewCellsStats; 
    226231}; 
    227232 
     
    255260        bool ViewCellsConstructed() const; 
    256261 
    257         void PrintStatistics(ostream &s) const; 
     262        //void PrintStatistics(ostream &s) const; 
    258263 
    259264        int CastLineSegment(const Vector3 &origin, 
     
    278283        /// the BSP tree. 
    279284        BspTree *mBspTree; 
    280  
     285         
     286        vector<BspRay *> mBspRays; 
    281287 
    282288private: 
    283  
    284289 
    285290        /** Exports visualization of the BSP splits. 
     
    325330        /** Prints out statistics of this approach. 
    326331        */ 
    327         virtual void PrintStatistics(ostream &s) const; 
     332        //void PrintStatistics(ostream &s) const; 
    328333 
    329334        float GetProbability(ViewCell *viewCell); 
     
    368373        bool ViewCellsConstructed() const; 
    369374 
    370         virtual void PrintStatistics(ostream &s) const; 
     375        //virtual void PrintStatistics(ostream &s) const; 
    371376 
    372377        ViewCell *GenerateViewCell(Mesh *mesh) const; 
     
    397402 
    398403        VspBspViewCellsManager(VspBspTree *tree, int constructionSamples); 
     404        ~VspBspViewCellsManager(); 
    399405 
    400406        int Construct(const ObjectContainer &objects,  
     
    415421        bool ViewCellsConstructed() const; 
    416422 
    417         void PrintStatistics(ostream &s) const; 
     423        //void PrintStatistics(ostream &s) const; 
    418424         
    419425        int CastLineSegment(const Vector3 &origin, 
     
    423429        float GetProbability(ViewCell *viewCell); 
    424430        float GetRendercost(ViewCell *viewCell, float objRendercost) const; 
    425  
     431        float GetArea(ViewCell *viewCell) const; 
    426432 
    427433protected: 
     434 
     435        /** Constructs bsp rays for post processing and visualization. 
     436        */ 
     437        void ConstructBspRays(const VssRayContainer &rays, const int numSamples); 
    428438 
    429439        /** Merges view cells front and back leaf view cell. 
     
    438448        VspBspTree *mVspBspTree; 
    439449 
     450        vector<BspRay *> mBspRays; 
    440451 
    441452private: 
     
    444455        /** Exports visualization of the BSP splits. 
    445456        */ 
    446         void ExportSplits(const ObjectContainer &objects, const VssRayContainer &sampleRays); 
     457        void ExportSplits(const ObjectContainer &objects); 
    447458 
    448459        /** Exports visualization of the BSP PVS. 
    449460        */ 
    450         void ExportBspPvs(const ObjectContainer &objects, const VssRayContainer &sampleRays); 
     461        void ExportBspPvs(const ObjectContainer &objects); 
    451462 
    452463}; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r474 r475  
    227227        long startTime = GetTime(); 
    228228 
    229         Debug << "**** Extracting polygons from rays ****\n"; 
     229        cout << "Extracting polygons from rays ..."; 
    230230 
    231231        Intersectable::NewMail(); 
     
    276276        mStat.polys = (int)polys.size(); 
    277277 
    278         Debug << "**** Finished polygon extraction ****" << endl; 
    279         Debug << (int)polys.size() << " polys extracted from " << (int)sampleRays.size() << " rays" << endl; 
    280         Debug << "extraction time: " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
     278        cout << "finished" << endl; 
     279 
     280        Debug << "\nPolygon extraction: " << (int)polys.size() << " polys extracted from "  
     281                  << (int)sampleRays.size() << " rays in " 
     282                  << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl << endl; 
    281283 
    282284        Construct(polys, rays); 
     
    321323                if (r == mRoot) 
    322324                        Debug << "VSP BSP tree construction time spent at root: "  
    323                                   << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
     325                                  << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl << endl; 
    324326        } 
    325327 
     
    336338                 (data.mPvs <= mTermMinPvs)   || 
    337339                 (data.mArea <= mTermMinArea) || 
    338                  (numLeaves >= mMaxViewCells) || 
     340                 ((mStat.nodes / 2 + 1) >= mMaxViewCells) || 
    339341                // (data.GetAvgRayContribution() >= mTermMaxRayContribution) || 
    340342                 (data.mDepth >= mTermMaxDepth)); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r474 r475  
    116116                float GetCost() const 
    117117                { 
    118 #if 0 
     118#if 1 
    119119                        return mPvs * mArea; 
    120120#endif 
    121 #if 1 
     121#if 0 
    122122                        return (float)(mPvs * (int)mRays->size()); 
    123123#endif 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp

    r474 r475  
    558558 
    559559        //-- several visualizations and statistics 
     560        Debug << "view cells after post processing: " << endl; 
    560561        mViewCellsManager->PrintStatistics(Debug); 
    561562 
     
    576577 
    577578  delete vssTree; 
    578  
     579   
    579580  return true; 
    580581} 
Note: See TracChangeset for help on using the changeset viewer.