Changeset 612


Ignore:
Timestamp:
02/12/06 21:45:02 (18 years ago)
Author:
mattausch
Message:

really last checkin before svn change

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
6 edited

Legend:

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

    r607 r612  
    2525        type vss 
    2626#       type rss 
    27         detectEmptyViewSpace false 
     27        detectEmptyViewSpace true 
    2828} 
    2929 
     
    3636        loadInitialSamples  false 
    3737        storeInitialSamples false 
    38         useViewSpaceBox false 
     38        useViewSpaceBox true 
    3939#       testBeamSampling true 
    4040} 
     
    176176        # samples used for view cell construction 
    177177        Construction { 
    178                 samples 2000000 
     178                samples 0 
    179179                samplesPerPass 500000 
    180180        } 
    181181 
    182182        #number of active view cells 
    183         active 2048 
     183        active 2096 
    184184        maxStaticMemory 40 
    185185 
    186         exportToFile true 
     186        exportToFile false 
    187187        loadFromFile false 
    188188 
     
    210210                minViewCells 1 
    211211                avgCostMaxDeviation 0.01 
    212                 maxMergesPerPass 500 
     212                maxMergesPerPass 5000 
    213213                useRaysForMerge false 
    214214                refine false 
    215                 compress false 
     215                compress true 
    216216                merge true 
    217217        } 
     
    288288VspBspTree { 
    289289        Construction { 
    290                 samples 500000 
     290                samples 300000 
    291291                epsilon 0.005 
    292292                randomize false 
     
    301301        # pvs                  = 1024 
    302302         
    303         splitPlaneStrategy 1026 
     303        splitPlaneStrategy 1024 
    304304         
    305305        # maximal candidates for split planes 
    306         maxPolyCandidates 200 
    307  
    308          
     306        maxPolyCandidates 0 
     307 
     308        usePolygonSplitIfAvailable false 
    309309        # maximal tested rays for split cost heuristics 
    310310        maxTests 10000 
     
    320320        } 
    321321         
    322         usePolygonSplitIfAvailable 0 
    323  
    324322        Termination { 
    325323                # parameters used for autopartition 
    326                 minRays                 500 
     324                minRays                 -15 
    327325                minPolygons             -1 
    328326                maxDepth                25 
    329                 minPvs                  -1 
    330                 minProbability          0.0000001 
    331                 maxRayContribution      0.3 
    332                 maxCostRatio            0.9 
    333                 missTolerance           3 
    334                  
    335                 maxViewCells            30000 
     327                minPvs                  -15 
     328                minProbability          0.00000001 
     329                maxRayContribution      1.8 
     330                maxCostRatio            1.8 
     331                missTolerance           6 
     332                 
     333                maxViewCells            150000 
    336334                 
    337335                # used for pvs criterium 
     
    339337                 
    340338                AxisAligned { 
    341                         minRays                 900000 
     339                        minRays                 50000 
    342340                        maxRayContribution      9.9 
    343341                } 
    344342        } 
    345343         
     344        useCostHeuristics false 
    346345        splitUseOnlyDrivingAxis false 
    347346         
     
    414413        Termination { 
    415414                # parameters used for autopartition 
    416                 minRays -1 
    417                 minPolygons 1 
     415                minRays 10 
     416                minPolygons -1 
    418417                maxDepth 30 
    419418                minPvs -1 
     
    421420                maxRayContribution 9999 
    422421                #maxAccRayLength 100 
    423                 maxViewCells    5000 
     422                maxViewCells    50000 
    424423 
    425424                # used for pvs criterium 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r611 r612  
    18561856                "1.5"); 
    18571857 
     1858        RegisterOption("VspBspTree.useCostHeuristics", 
     1859                optBool, 
     1860                "-vsp_bsp_use_cost_heuristics=", 
     1861                "false"); 
     1862 
    18581863        RegisterOption("VspBspTree.Termination.maxViewCells", 
    18591864                optInt, 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp

    r610 r612  
    1818{ 
    1919public: 
    20          
    2120        //bool operator() (HierarchyNode *v1, HierarchyNode *v2) const 
    2221        bool operator() (T v1, T v2) const 
     
    508507                   << "#TotalPvs\n" << totalPvs << endl 
    509508                   << "#PvsSizeDecrease\n0" << endl 
    510                    << "#Volume\n" << endl 
    511                    << "#Siblings\n" << mergeStats.siblings << endl; 
     509                   << "#Volume\n0" << endl 
     510                   //<< "#Siblings\n" << mergeStats.siblings << endl 
     511                   << endl; 
    512512 
    513513        //-- use priority queue to merge leaf pairs 
    514514// HACK 
     515 
    515516        //const float maxAvgCost = 350; 
    516517        while (!mMergeQueue.empty())//NumActiveViewCells > mMergeMinViewCells)) 
     
    549550                                ResetMergeQueue(); 
    550551 
    551                          
    552552                        Debug << "Values after reset: "   
    553553                                  << " erc: " << mExpectedCost  
     
    562562 
    563563 
    564          
    565564                MergeCandidate mc = mMergeQueue.top(); 
    566565                mMergeQueue.pop(); 
     
    604603                        mergedVc->SetMergeCost(totalRenderCost); 
    605604 
    606                         if (mViewCellsManager->EqualToSpatialNode(mergedVc)) 
    607                                 ++ mergeStats.siblings; 
     605                        //if (mViewCellsManager->EqualToSpatialNode(mergedVc)) 
     606                        //      ++ mergeStats.siblings; 
    608607                        mergedVc->SetCost(realExpectedCost); 
    609608 
     
    616615                                        << "#Pass\n" << pass << endl 
    617616                                        << "#Merged\n" << mergeStats.merged << endl  
    618                                         << "#Viewcells\n" << realNumActiveViewCells << endl  
     617                                        << "#ViewCells\n" << realNumActiveViewCells << endl  
    619618                    << "#RenderCostIncrease\n" << renderCostIncr << endl 
    620619                                        << "#TotalRenderCost\n" << totalRenderCost << endl 
     
    625624                                        << "#TotalPvs\n" << totalPvs << endl 
    626625                                        << "#PvsSizeDecrease\n" << -pvsDiff << endl 
    627                                         << "#Volume\n" << mergedVc->GetVolume() << endl; 
     626                                        << "#Volume\n" << mergedVc->GetVolume() << endl 
     627                                        << endl; 
     628                                 
    628629                        } 
    629630                } 
     
    638639                        } 
    639640                } 
     641                 
    640642        } 
    641643 
     
    659661                Debug << "creating root of view cell hierarchy for "  
    660662                          << (int)activeViewCells.size() << " view cells" << endl; 
    661                 /*for (int i = 0;  i < activeViewCells.size(); ++ i){ 
    662                         Debug << "parent " << activeViewCells[i]->GetParent() << endl; 
    663                         Debug << "viewcell " << activeViewCells[i] << endl; 
    664                 }*/ 
     663                 
    665664                ViewCellInterior *root = mViewCellsManager->MergeViewCells(activeViewCells); 
    666665                root->SetMergeCost(totalRenderCost); 
     
    668667                root->SetCost(0.0f); 
    669668                 
     669                mStats  
     670                        << "#Pass\n" << pass << endl 
     671                        << "#Merged\n" << mergeStats.merged << endl  
     672                        << "#ViewCells\n" << realNumActiveViewCells << endl  
     673            << "#RenderCostIncrease\n" << 0 << endl // TODO 
     674                        << "#TotalRenderCost\n" << totalRenderCost << endl 
     675                        << "#CurrentPvs\n" << root->GetPvs().GetSize() << endl 
     676            << "#ExpectedCost\n" << realExpectedCost << endl 
     677                        << "#AvgRenderCost\n" << realAvgRenderCost << endl 
     678                        << "#Deviation\n" << mDeviation << endl 
     679                        << "#TotalPvs\n" << totalPvs << endl 
     680                        << "#PvsSizeDecrease\n" << 0 << endl // TODO 
     681                        << "#Volume\n" << root->GetVolume() << endl 
     682                        << endl; 
     683 
    670684                mRoot = root; 
    671685        } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp

    r610 r612  
    1616#include "RssPreprocessor.h" 
    1717 
    18 #define SAMPLE_AFTER_SUBDIVISION 1 
     18#define SAMPLE_AFTER_SUBDIVISION 0 
    1919 
    2020 
     
    25022502        Debug << "\nView cells after construction:\n" << mViewCellsStats << endl; 
    25032503 
    2504         if (1) // export initial view cells 
     2504        if (0) // export initial view cells 
    25052505        { 
    25062506                cout << "exporting initial view cells (=leaves) ... "; 
     
    25802580         
    25812581        //BspLeaf::NewMail(); 
    2582         if (1) // export merged view cells 
     2582        if (0) // export merged view cells 
    25832583        { 
    25842584                mColorCode = 0; 
     
    26172617        } 
    26182618 
    2619         if (1) // export merged view cells 
     2619        if (0) // export merged view cells using pvs coding 
    26202620        { 
    26212621                mColorCode = 1; 
     
    29092909 
    29102910         
    2911         if (1) // export view cells 
    2912         {// hack pvs 
     2911        if (0) // export view cells 
     2912        {       // hack pvs 
    29132913                int savedColorCode = mColorCode; 
    29142914                mColorCode = 1; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r611 r612  
    124124        mSubdivisionStats.open("subdivisionStats.log"); 
    125125 
     126        environment->GetBoolValue("VspBspTree.useCostHeuristics", mUseCostHeuristics); 
     127 
    126128 
    127129        //-- debug output 
     
    393395 
    394396 
    395 // return memory usage in MB 
     397// TODO: return memory usage in MB 
    396398float VspBspTree::GetMemUsage(/*const VspBspTraversalQueue &tstack*/) const 
    397399{ 
     
    454456 
    455457        long startTime = GetTime();      
     458        int nLeaves = 0; 
     459        int nViewCells = 0; 
    456460 
    457461        // used for intermediate time measurements and progress 
     
    460464        mOutOfMemory = false; 
    461465 
    462         int nleaves = 500; 
    463  
     466        mCreatedViewCells = 0; 
     467         
    464468        while (!tQueue.empty()) 
    465469        { 
     
    485489                                  << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
    486490 
    487                 if (mBspStats.Leaves() >= nleaves) 
    488                 { 
    489                         nleaves += 500; 
    490                                  
     491                if (mBspStats.Leaves() == nLeaves) 
     492                { 
     493                        nLeaves += 500; 
     494 
    491495                        cout << "leaves=" << mBspStats.Leaves() << endl; 
    492496                        Debug << "needed " 
    493497                                  << TimeDiff(interTime, GetTime())*1e-3  
    494                                   << " secs to create 500 leaves" << endl; 
     498                                  << " secs to create 500 view cells" << endl; 
    495499                        interTime = GetTime(); 
     500                } 
     501 
     502                if (mCreatedViewCells == nViewCells) 
     503                { 
     504                        nViewCells += 500; 
     505 
     506                        cout << "generated " << mCreatedViewCells << " viewcells" << endl; 
    496507                } 
    497508        } 
     
    530541                VspBspTraversalData tFrontData; 
    531542                VspBspTraversalData tBackData; 
     543 
    532544#if OCTREE_HACK 
    533545                //Debug << "new axis:" << (tData.mAxis + 1) % 3 << endl; 
    534  
    535546                tFrontData.mAxis = (tData.mAxis + 1) % 3; 
    536547                tBackData.mAxis = (tData.mAxis + 1) % 3; 
     
    593604                                leaf->mVssRays.push_back((*it).mRay); 
    594605                } 
     606 
    595607                // should I check here? 
    596608                if (0 && !mViewCellsManager->CheckValidity(viewCell, 0, mViewCellsManager->GetMaxPvsSize())) 
     
    634646        int maxCostMisses = tData.mMaxCostMisses; 
    635647 
     648        int splitAxis; 
     649 
    636650        const bool success =  
    637                 SelectPlane(splitPlane, leaf, tData, frontData, backData); 
     651                SelectPlane(splitPlane, leaf, tData, frontData, backData, splitAxis); 
    638652 
    639653        if (!success) 
     
    648662                } 
    649663        } 
     664 
     665        //! error also computed if cost ratio is missed 
     666        if (splitAxis < 3) 
     667                ++ mBspStats.splits[splitAxis]; 
     668        else 
     669                ++ mBspStats.polySplits; 
    650670 
    651671        mBspStats.nodes += 2; 
     
    792812        // creates a sorted split candidates array 
    793813        if (mSplitCandidates->capacity() > 500000 && 
    794                 requestedSize < (int)(mSplitCandidates->capacity()/10) ) 
     814                requestedSize < (int)(mSplitCandidates->capacity()  / 10) ) 
    795815        { 
    796816        delete mSplitCandidates; 
     
    801821 
    802822        // insert all queries 
    803         for(RayInfoContainer::const_iterator ri = rays.begin(); ri < rays.end(); ++ ri) 
    804         { 
    805                 bool positive = (*ri).mRay->HasPosDir(axis); 
     823        for (RayInfoContainer::const_iterator ri = rays.begin(); ri < rays.end(); ++ ri) 
     824        { 
     825                const bool positive = (*ri).mRay->HasPosDir(axis); 
    806826                mSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax, 
    807827                                                                                                  (*ri).ExtrapOrigin(axis), (*ri).mRay)); 
     
    821841                                          float &position) 
    822842{ 
    823         int raysBack; 
    824         int raysFront; 
    825         int pvsBack; 
    826         int pvsFront; 
    827  
    828843        SortSplitCandidates(rays, axis); 
    829844 
     
    832847        // C = ct_div_ci  + (ql*rl + qr*rr)/queries 
    833848 
    834         int rl = 0, rr = (int)rays.size(); 
    835         int pl = 0, pr = pvsSize; 
     849        int pvsl = 0, pvsr = pvsSize; 
     850 
     851        int pvsBack = pvsl; 
     852        int pvsFront = pvsr; 
    836853 
    837854        float minBox = box.Min(axis); 
     
    839856        float sizeBox = maxBox - minBox; 
    840857 
    841         float minBand = minBox + 0.1f*(maxBox - minBox); 
    842         float maxBand = minBox + 0.9f*(maxBox - minBox); 
    843  
    844         float sum = rr*sizeBox; 
     858        float minBand = minBox + 0.1f * (maxBox - minBox); 
     859        float maxBand = minBox + 0.9f * (maxBox - minBox); 
     860 
     861        float sum = (float)pvsSize * sizeBox; 
    845862        float minSum = 1e20f; 
    846863 
    847864        Intersectable::NewMail(); 
    848865 
    849         // set all object as belonging to the fron pvs 
    850         for(RayInfoContainer::const_iterator ri = rays.begin(); ri != rays.end(); ++ ri) 
    851         { 
    852                 if ((*ri).mRay->IsActive()) 
    853                 { 
    854                         Intersectable *object = (*ri).mRay->mTerminationObject; 
    855  
    856                         if (object) 
    857                         { 
    858                                 if (!object->Mailed()) 
    859                                 { 
    860                                         object->Mail(); 
    861                                         object->mCounter = 1; 
    862                                 } 
    863                                 else 
    864                                         ++ object->mCounter; 
     866        RayInfoContainer::const_iterator ri, ri_end = rays.end(); 
     867 
     868        // set all object as belonging to the front pvs 
     869        for(ri = rays.begin(); ri != ri_end; ++ ri) 
     870        { 
     871                Intersectable *oObject = (*ri).mRay->mOriginObject; 
     872                Intersectable *tObject = (*ri).mRay->mTerminationObject; 
     873 
     874                if (oObject) 
     875                { 
     876                        if (!oObject->Mailed()) 
     877                        { 
     878                                oObject->Mail(); 
     879                                oObject->mCounter = 1; 
     880                        } 
     881                        else 
     882                        { 
     883                                ++ oObject->mCounter; 
     884                        } 
     885                } 
     886                if (tObject) 
     887                { 
     888                        if (!tObject->Mailed()) 
     889                        { 
     890                                tObject->Mail(); 
     891                                tObject->mCounter = 1; 
     892                        } 
     893                        else 
     894                        { 
     895                                ++ tObject->mCounter; 
    865896                        } 
    866897                } 
     
    869900        Intersectable::NewMail(); 
    870901 
    871         for (vector<SortableEntry>::const_iterator ci = mSplitCandidates->begin(); 
    872                 ci < mSplitCandidates->end(); ++ ci) 
     902        vector<SortableEntry>::const_iterator ci, ci_end = mSplitCandidates->end(); 
     903 
     904        for (ci = mSplitCandidates->begin(); ci < ci_end; ++ ci) 
    873905        { 
    874906                VssRay *ray; 
     907                ray = (*ci).ray; 
     908                 
     909                Intersectable *oObject = ray->mOriginObject; 
     910                Intersectable *tObject = ray->mTerminationObject; 
     911                 
    875912 
    876913                switch ((*ci).type) 
     
    878915                        case SortableEntry::ERayMin: 
    879916                                { 
    880                                         ++ rl; 
    881                                         ray = (VssRay *) (*ci).ray; 
    882  
    883                                         Intersectable *object = ray->mTerminationObject; 
    884  
    885                                         if (object && !object->Mailed()) 
     917                                        if (oObject && !oObject->Mailed()) 
    886918                                        { 
    887                                                 object->Mail(); 
    888                                                 ++ pl; 
     919                                                oObject->Mail(); 
     920                                                ++ pvsl; 
     921                                        } 
     922                                        if (tObject && !tObject->Mailed()) 
     923                                        { 
     924                                                tObject->Mail(); 
     925                                                ++ pvsl; 
    889926                                        } 
    890927                                        break; 
     
    892929                        case SortableEntry::ERayMax: 
    893930                                { 
    894                                         -- rr; 
    895                                         ray = (VssRay *) (*ci).ray; 
    896  
    897                                         Intersectable *object = ray->mTerminationObject; 
    898  
    899                                         if (object) 
     931                                        if (oObject) 
    900932                                        { 
    901                                                 if (-- object->mCounter == 0) 
    902                                                         -- pr; 
     933                                                if (-- oObject->mCounter == 0) 
     934                                                        -- pvsr; 
     935                                        } 
     936 
     937                                        if (tObject) 
     938                                        { 
     939                                                if (-- tObject->mCounter == 0) 
     940                                                        -- pvsr; 
    903941                                        } 
    904942 
     
    910948                if ((*ci).value > minBand && (*ci).value < maxBand) 
    911949                { 
    912                         sum = pl*((*ci).value - minBox) + pr*(maxBox - (*ci).value); 
     950                        sum = pvsl * ((*ci).value - minBox) + pvsr * (maxBox - (*ci).value); 
    913951 
    914952                        //  cout<<"pos="<<(*ci).value<<"\t q=("<<ql<<","<<qr<<")\t r=("<<rl<<","<<rr<<")"<<endl; 
     
    920958                                position = (*ci).value; 
    921959 
    922                                 raysBack = rl; 
    923                                 raysFront = rr; 
    924  
    925                                 pvsBack = pl; 
    926                                 pvsFront = pr; 
    927  
    928                         } 
    929                 } 
    930         } 
    931  
    932         float oldCost = (float)pvsSize; 
    933         float newCost = mCtDivCi + minSum / sizeBox; 
    934         float ratio = newCost / oldCost; 
     960                                pvsBack = pvsl; 
     961                                pvsFront = pvsr; 
     962                        } 
     963                } 
     964        } 
     965 
     966        // -- compute cost 
     967 
     968        const int lowerPvsLimit = mViewCellsManager->GetMinPvsSize(); 
     969        const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); 
     970 
     971        const float pOverall = sizeBox; 
     972 
     973        const float pBack = position - minBox; 
     974        const float pFront = maxBox - position; 
     975         
     976        const float penaltyOld = EvalPvsPenalty(pvsSize, lowerPvsLimit, upperPvsLimit); 
     977    const float penaltyFront = EvalPvsPenalty(pvsFront, lowerPvsLimit, upperPvsLimit); 
     978        const float penaltyBack = EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); 
     979         
     980        const float oldRenderCost = penaltyOld * pOverall; 
     981        const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 
     982 
     983        float ratio = mPvsFactor * newRenderCost / (oldRenderCost + Limits::Small); 
    935984 
    936985        //Debug << "costRatio=" << ratio << " pos=" << position << " t=" << (position - minBox) / (maxBox - minBox) 
     
    950999                                                                                 const bool useKdSplit) 
    9511000{ 
    952         const bool useCostHeuristics = false; 
    953  
    954         //-- regular split 
    9551001        float nPosition[3]; 
    9561002        float nCostRatio[3]; 
     
    9601006        BspNodeGeometry *nFrontGeom[3]; 
    9611007        BspNodeGeometry *nBackGeom[3]; 
     1008 
     1009        for (int i = 0; i < 3; ++ i) 
     1010        { 
     1011                nFrontGeom[i] = NULL; 
     1012                nBackGeom[i] = NULL; 
     1013        } 
    9621014 
    9631015        int bestAxis = -1; 
     
    9901042        for (axis = 0; axis < 3; ++ axis) 
    9911043        { 
    992                 nFrontGeom[axis] = new BspNodeGeometry(); 
    993                 nBackGeom[axis] = new BspNodeGeometry(); 
    994  
    9951044                if (!mOnlyDrivingAxis || (axis == sAxis)) 
    9961045                { 
    997                         if (!useCostHeuristics) 
    998                         { 
     1046                        if (!mUseCostHeuristics) 
     1047                        { 
     1048                                nFrontGeom[axis] = new BspNodeGeometry(); 
     1049                                nBackGeom[axis] = new BspNodeGeometry(); 
     1050 
    9991051                                nPosition[axis] = (box.Min()[axis] + box.Max()[axis]) * 0.5f; 
    10001052                                Vector3 normal(0,0,0); normal[axis] = 1.0f; 
     
    10421094                                bestAxis = axis; 
    10431095                        } 
    1044  
    10451096                        else if (nCostRatio[axis] < nCostRatio[bestAxis]) 
    10461097                        { 
     
    10611112 
    10621113        // and delete other geometry 
    1063         delete nFrontGeom[(bestAxis + 1) % 3]; 
    1064         delete nBackGeom[(bestAxis + 2) % 3]; 
     1114        DEL_PTR(nFrontGeom[(bestAxis + 1) % 3]); 
     1115        DEL_PTR(nBackGeom[(bestAxis + 2) % 3]); 
    10651116 
    10661117        //-- split plane 
     
    10761127                                                         VspBspTraversalData &data, 
    10771128                                                         VspBspTraversalData &frontData, 
    1078                                                          VspBspTraversalData &backData) 
     1129                                                         VspBspTraversalData &backData, 
     1130                                                         int &splitAxis) 
    10791131{ 
    10801132        // simplest strategy: just take next polygon 
     
    11501202        float pFront, pBack; 
    11511203 
    1152         candidateCost = SelectAxisAlignedPlane(plane, data, axis, 
    1153                                                                                    &fGeom, &bGeom,  
    1154                                                                                    pFront, pBack, 
     1204        candidateCost = SelectAxisAlignedPlane(plane,  
     1205                                                                                   data,  
     1206                                                                                   axis, 
     1207                                                                                   &fGeom,  
     1208                                                                                   &bGeom,  
     1209                                                                                   pFront,  
     1210                                                                                   pBack, 
    11551211                                                                                   data.mIsKdNode);       
    11561212 
    1157         bool isAxisAlignedSplit = false; 
     1213        splitAxis = 3; 
    11581214 
    11591215        if (candidateCost < lowestCost) 
     
    11611217                bestPlane = plane; 
    11621218                lowestCost = candidateCost; 
    1163  
     1219                splitAxis = axis; 
    11641220                // assign already computed values 
    11651221                // we can do this because we always save the 
    11661222                // computed values from the axis aligned splits          
    1167                 frontData.mGeometry = fGeom; 
    1168                 backData.mGeometry = bGeom; 
    1169          
    1170                 frontData.mProbability = pFront; 
    1171                 backData.mProbability = pBack; 
    1172                  
    1173                 //! error also computed if cost ratio is missed 
    1174                 ++ mBspStats.splits[axis]; 
    1175                 isAxisAlignedSplit = true; 
     1223                if (fGeom && bGeom) 
     1224                { 
     1225                        frontData.mGeometry = fGeom; 
     1226                        backData.mGeometry = bGeom; 
     1227         
     1228                        frontData.mProbability = pFront; 
     1229                        backData.mProbability = pBack; 
     1230                } 
    11761231        } 
    11771232        else 
     
    11811236        } 
    11821237 
    1183         frontData.mIsKdNode = backData.mIsKdNode = (data.mIsKdNode && isAxisAlignedSplit); 
     1238        frontData.mIsKdNode = backData.mIsKdNode =  
     1239                (data.mIsKdNode && splitAxis < 3); 
    11841240 
    11851241#ifdef _DEBUG 
     
    14011457                const float penaltyBack = EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); 
    14021458                         
    1403                 const float oldRenderCost = pOverall * (float)penaltyOld + Limits::Small; 
     1459                const float oldRenderCost = pOverall * penaltyOld; 
    14041460                const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 
    14051461 
     
    14201476                                fabs(penaltyFront - expectedCost) + fabs(penaltyBack - expectedCost); 
    14211477 
    1422                         const float oldDeviation = penaltyOld + Limits::Small; 
     1478                        const float oldDeviation = penaltyOld; 
    14231479 
    14241480                        newCost = mRenderCostWeight * newRenderCost + (1.0f - mRenderCostWeight) * newDeviation; 
     
    14261482                } 
    14271483 
    1428                 cost += mPvsFactor * newCost / oldCost; 
     1484                cost += mPvsFactor * newCost / (oldCost + Limits::Small); 
    14291485                 
    14301486        } 
     
    16561712        mBspStats.accumDepth += data.mDepth; 
    16571713 
     1714        ++ mCreatedViewCells; 
    16581715#ifdef _DEBUG 
    16591716        Debug << "BSP stats: " 
     
    16661723#endif 
    16671724} 
     1725 
    16681726 
    16691727int VspBspTree::CastRay(Ray &ray) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h

    r611 r612  
    127127                float GetCost() const 
    128128                { 
    129 #if 0 
     129#if 1 
    130130                        return mPvs * mProbability; 
    131131#endif 
    132 #if 1 
     132#if 0 
    133133                        return (float) (-mDepth); // for regular grid 
    134134#endif 
     
    398398                                         VspBspTraversalData &data, 
    399399                                         VspBspTraversalData &frontData, 
    400                                          VspBspTraversalData &backData); 
     400                                         VspBspTraversalData &backData, 
     401                                         int &splitAxis); 
    401402         
    402403        /** Strategies where the effect of the split plane is tested 
     
    627628        /// box around the whole view domain 
    628629        AxisAlignedBox3 mBox; 
     630 
     631        bool mUseCostHeuristics; 
    629632 
    630633        /// minimal number of rays before subdivision termination 
     
    721724        int mTimeStamp; 
    722725 
     726        int mCreatedViewCells; 
     727 
    723728private: 
    724729 
Note: See TracChangeset for help on using the changeset viewer.