Ignore:
Timestamp:
11/09/05 01:54:05 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h

    r372 r392  
    114114 
    115115  /// the view cell corresponding to unbounded space 
    116   ViewCell mUnbounded; 
     116  BspViewCell mUnbounded; 
    117117}; 
    118118 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Ray.h

    r374 r392  
    4141 
    4242    Intersection(const float t, 
    43                                                                 Intersectable *object, 
    44                                                                 const int face):mT(t), mObject(object), mFace(face) {} 
     43                                Intersectable *object, 
     44                                const int face):mT(t), mObject(object), mFace(face) {} 
    4545                 
    4646    Intersection() {} 
     
    112112  // Inititalize the ray again when already constructed 
    113113  void Init(const Vector3 &wherefrom, 
    114                                                 const Vector3 &whichdir, 
    115                                                 const int _type,  
    116                                                 bool dirNormalized = false) { 
     114                        const Vector3 &whichdir, 
     115                        const int _type,  
     116                        bool dirNormalized = false) { 
    117117    loc = wherefrom; 
    118118    dir = (dirNormalized || _type == LINE_SEGMENT) ? whichdir: Normalize(whichdir) ; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r391 r392  
    569569                } 
    570570 
    571                 cout << "starting post processing using " << (int)mSampleRays.size() << " samples ... "; 
     571                cout << "starting post processing using " << mPostProcessSamples << " samples ... "; 
    572572                 
    573573                long startTime = GetTime(); 
     
    690690} 
    691691 
    692 void SamplingPreprocessor::ProcessBspViewCells(Ray &ray, 
    693                                                                                            Intersectable *object, 
    694                                                                                            int faceIndex, 
     692void SamplingPreprocessor::ProcessBspViewCells(const Ray &ray, 
     693                                               Intersectable *object, 
     694                                                                                           const int faceIndex, 
    695695                                                                                           int &contributingSamples, 
    696696                                                                                           int &sampleContributions) 
     
    702702                        ((int)mSampleRays.size() < mBspConstructionSamples)) 
    703703                { 
    704                         // also add origin to sample in order to extract it as input polygons 
    705704                        MeshInstance *mi = dynamic_cast<MeshInstance *>(object); 
    706                         ray.sourceObject = Ray::Intersection(0.0, mi, faceIndex); 
    707                                                          
    708                         mSampleRays.push_back(new Ray(ray)); 
     705                         
     706                        Ray *sRay = new Ray(ray); 
     707                        mSampleRays.push_back(sRay); 
     708                 
     709                        // also add origin to sample 
     710                        sRay->sourceObject = Ray::Intersection(0.0, object, faceIndex); 
    709711                } 
    710712                else 
    711713                { 
    712                         // construct BSP tree using the samples 
     714                        // construct BSP tree using the collected samples 
    713715                        cout << "building bsp tree from " << (int)mSampleRays.size() << " samples " << endl; 
    714716                        BuildBspTree(); 
     
    910912                        exporter->SetForcedMaterial(m); 
    911913 
    912                         exporter->SetWireframe(); 
     914                        //exporter->SetWireframe(); 
    913915 
    914916                        // output PVS of view cell 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h

    r390 r392  
    7575                @param sampleContributions contribution of the samples 
    7676        */ 
    77         void ProcessBspViewCells(Ray &ray, 
     77        void ProcessBspViewCells(const Ray &ray, 
    7878                                                         Intersectable *object, 
    79                                                          int faceIndex, 
     79                                                         const int faceIndex, 
    8080                                                         int &contributingSamples, 
    8181                                                         int &sampleContributions); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r391 r392  
    253253} 
    254254 
    255 void BspLeaf::GenerateViewCell(const BoundedRayContainer &rays,  
    256                                                            int &sampleContributions, 
    257                                                            int &contributingSamples) 
     255void BspLeaf::AddToPvs(const BoundedRayContainer &rays,  
     256                                           int &sampleContributions, 
     257                                           int &contributingSamples) 
    258258{ 
    259259        sampleContributions = 0; 
    260260        contributingSamples = 0; 
    261  
    262         mViewCell = dynamic_cast<BspViewCell *>(ViewCell::Generate()); 
    263         mViewCell->mBspLeaves.push_back(this); 
    264261 
    265262    BoundedRayContainer::const_iterator it, it_end = rays.end(); 
     
    273270                if (!ray->intersections.empty()) 
    274271                {        
    275             contribution += mViewCell->GetPvs().AddSample(ray->intersections[0].mObject); 
    276                 } 
    277  
    278                 contribution += mViewCell->GetPvs().AddSample(ray->sourceObject.mObject); 
     272            //contribution += mViewCell->GetPvs().AddSample(ray->intersections[0].mObject); 
     273                } 
     274 
     275                //contribution += mViewCell->GetPvs().AddSample(ray->sourceObject.mObject); 
    279276 
    280277                if (contribution > 0) 
     
    294291/****************************************************************/ 
    295292 
    296 BspTree::BspTree(ViewCell *viewCell):  
     293BspTree::BspTree(BspViewCell *viewCell):  
    297294mRootCell(viewCell), mRoot(NULL), mGenerateViewCells(false), 
    298295mStorePiercingRays(true) 
     
    707704                BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); 
    708705         
     706                BspViewCell *viewCell; 
     707 
    709708                // generate new view cell for each leaf 
    710709                if (mGenerateViewCells) 
    711710                { 
    712                         int conSamp, sampCon; 
    713                         leaf->GenerateViewCell(*tData.mRays, conSamp, sampCon); 
     711                        viewCell = dynamic_cast<BspViewCell *>(ViewCell::Generate()); 
     712                } 
     713                else 
     714                { 
     715                        // add view cell to leaf 
     716                        viewCell = dynamic_cast<BspViewCell *>(tData.mViewCell); 
     717                } 
     718 
     719                leaf->SetViewCell(viewCell); 
     720                viewCell->mBspLeaves.push_back(leaf); 
     721 
     722                //-- add pvs 
     723                if (viewCell != mRootCell) 
     724                { 
     725                        int conSamp = 0, sampCon = 0; 
     726                        leaf->AddToPvs(*tData.mRays, conSamp, sampCon); 
    714727                         
    715728                        mStat.contributingSamples += conSamp; 
    716729                        mStat.sampleContributions += sampCon; 
    717                 } 
    718                 else 
    719                 { 
    720                         // add view cell to leaf 
    721                         leaf->SetViewCell(dynamic_cast<BspViewCell *>(tData.mViewCell)); 
    722                         leaf->mViewCell->mBspLeaves.push_back(leaf); 
    723730                } 
    724731 
     
    13341341 
    13351342                if (1) // use front and back cell areas to approximate volume 
    1336                 { 
    1337                         //-- compute area 
    1338                  
     1343                {        
    13391344                        // construct child geometry with regard to the candidate split plane 
    13401345                        frontData.mCell = cell.ConstructChild(*this, candidatePlane, true); 
    13411346                        backData.mCell = cell.ConstructChild(*this, candidatePlane, false); 
    13421347 
    1343                         frontData.mArea = frontData.mCell->GetArea(); 
    1344                         backData.mArea = backData.mCell->GetArea(); 
    1345  
    1346                         pFront = frontData.mArea; 
    1347                         pBack = backData.mArea; 
     1348                        pFront = frontData.mArea = frontData.mCell->GetArea(); 
     1349                        pBack = backData.mArea = backData.mCell->GetArea(); 
    13481350 
    13491351                        pOverall = area; 
     
    14091411 
    14101412        if ((sSplitPlaneStrategy & PVS) && area && pvs) 
    1411                 val += sPvsFactor * (frontData.mPvs * pFront + (backData.mPvs * pBack)) /       (pOverall * (float)pvs * 2); 
    1412  
    1413         Debug << "pvs: " << pvs << " totalArea: " << area  
     1413                val += sPvsFactor * (frontData.mPvs * pFront + (backData.mPvs * pBack)) / 
     1414                           (pOverall * (float)pvs * 2); 
     1415 
     1416        Debug << "totalpvs: " << pvs << " ptotal: " << pOverall 
    14141417                  << " frontpvs: " << frontData.mPvs << " pFront: " << pFront  
    14151418                  << " backpvs: " << backData.mPvs << " pBack: " << pBack  
     
    24862489        if (!planePoly) 
    24872490        { 
    2488                 Debug << "returning 'same' geometry " << mPolys.size(); 
    24892491                //geometry is not changed at all, hence just copy polygons 
    24902492                PolygonContainer::const_iterator it, it_end = mPolys.end(); 
     2493 
    24912494                for (it = mPolys.begin(); it != it_end; ++ it) 
    24922495                        childCell->mPolys.push_back(new Polygon3((*it)->mVertices)); 
     
    25132516                                                 
    25142517                                        poly->Split(splitPlane, *frontPoly, *backPoly, splitPts); 
     2518 
    25152519                                        DEL_PTR(poly); 
    25162520 
     
    25542558        childCell->mSides.push_back(side); 
    25552559 
    2556         Debug << "returning new geometry " << mPolys.size(); 
    2557  
     2560        Debug << "returning new geometry " << mPolys.size() << " CHILD: " << childCell->mPolys.size() << endl; 
     2561 
     2562        Debug << "old area " << this->GetArea() << " new: " << childCell->GetArea() << endl; 
    25582563        return childCell; 
    25592564} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r390 r392  
    315315        void SetViewCell(BspViewCell *viewCell); 
    316316 
    317         /** Generates new view cell and adds rays to the PVS. 
     317        /** Adds rays to the PVS. 
    318318                @param sampleContributions the number contributions of the sampels 
    319319                @param contributingSampels the number of contributing rays 
    320320                 
    321321        */ 
    322         void GenerateViewCell(const BoundedRayContainer &rays,  
    323                                               int &sampleContributions, 
    324                                                   int &contributingSamples); 
     322        void AddToPvs(const BoundedRayContainer &rays, int &sampleContributions, 
     323                                  int &contributingSamples); 
    325324 
    326325protected: 
     
    392391                @param viewCell view cell corresponding to unbounded space 
    393392        */  
    394         BspTree(ViewCell *viewCell); 
     393        BspTree(BspViewCell *viewCell); 
    395394 
    396395        ~BspTree(); 
     
    771770 
    772771        /// view cell corresponding to unbounded space 
    773         ViewCell *mRootCell; 
     772        BspViewCell *mRootCell; 
    774773 
    775774        /// should view cells be stored or generated in the leaves? 
Note: See TracChangeset for help on using the changeset viewer.