Changeset 1181


Ignore:
Timestamp:
08/03/06 15:38:53 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
4 edited

Legend:

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

    r1144 r1181  
    5757                { 
    5858                        mForcedMaterial.mDiffuseColor.b = 1.0f; 
    59                         const float importance = (float)ospTree.ComputePvsSize(leaf->mObjects) / (float)maxPvs; 
     59                        const float importance = (float)leaf->mObjects.size() / (float)maxPvs; 
    6060 
    6161                        mForcedMaterial.mDiffuseColor.r = importance; 
     
    7272        return true; 
    7373} 
     74 
    7475 
    7576void Exporter::ExportKdIntersectable(const KdIntersectable &kdObj) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp

    r1180 r1181  
    812812 
    813813        //-- compute pvs 
    814         frontData.mPvs = ComputePvsSize(*frontData.mRays); 
    815         backData.mPvs = ComputePvsSize(*backData.mRays); 
     814        frontData.mPvs = EvalPvsSize(*frontData.mRays); 
     815        backData.mPvs = EvalPvsSize(*backData.mRays); 
    816816 
    817817        // split front and back node geometry and compute area 
     
    22712271 
    22722272 
    2273 int VspTree::ComputePvsSize(const RayInfoContainer &rays) const 
     2273int VspTree::EvalPvsSize(const RayInfoContainer &rays) const 
    22742274{ 
    22752275        int pvsSize = 0; 
     
    23022302                } 
    23032303        } 
    2304         else 
     2304        else // compute pvs from kd nodes 
    23052305        { 
    23062306                KdNode::NewMail(); 
     
    30473047                // initialise leaf references of objects 
    30483048                if (parent->IsRoot()) 
     3049                { 
    30493050                        object->mReferences = 1; 
     3051                } 
    30503052 
    30513053                // remove parent ref 
     
    30693071 
    30703072        mOspStats.objectRefs -= (int)objects.size(); 
    3071         mOspStats.objectRefs += (int)back.size() + (int)front.size(); 
     3073        mOspStats.objectRefs += (int)(back.size() + front.size()); 
    30723074} 
    30733075 
     
    31043106        frontData.mDepth = backData.mDepth = tData.mDepth + 1; 
    31053107                 
    3106         // TODO matt: compute pvs 
    3107         frontData.mPvs = 999999; // ComputePvsSize(*frontData.mRays); 
    3108         backData.mPvs = 9999999; //ComputePvsSize(*backData.mRays); 
    3109  
    3110         frontData.mProbability = frontData.mBoundingBox.GetVolume(); 
    3111  
    3112          
    31133108        //-- subdivide rays 
    31143109        frontData.mRays = new RayInfoContainer(); 
     
    31393134        } 
    31403135 
     3136        // TODO matt: compute pvs 
     3137        frontData.mPvs = objectsFront; 
     3138        backData.mPvs = objectsBack; 
     3139 
    31413140        KdLeaf *back = new KdLeaf(node, objectsBack); 
    31423141        KdLeaf *front = new KdLeaf(node, objectsFront); 
     
    31663165    ProcessMultipleRefs(back); 
    31673166 
     3167        frontData.mNode = front; 
    31683168        backData.mNode = back; 
    3169         frontData.mNode = front; 
     3169 
     3170 
     3171        // compute probability, i.e., volume of seen view cells 
     3172        frontData.mProbability = EvalViewCellsVolume(front, *frontData.mRays); 
     3173        backData.mProbability =  EvalViewCellsVolume(back, *backData.mRays); 
     3174 
    31703175 
    31713176        //delete leaf; 
     
    34463451                         
    34473452                        // HACK: current positition is BETWEEN visibility events 
    3448                         if (1 && ((ci + 1) != ci_end)) 
     3453                        if (1 && ((*ci).mType == SortableEntry::BOX_INTERSECT) && ((ci + 1) != ci_end)) 
    34493454                                currentPos = ((*ci).mPos + (*(ci + 1)).mPos) * 0.5f; 
    34503455                        else 
    34513456                                currentPos = (*ci).mPos;                         
    34523457 
    3453                         if ((totalVol - voll - volr - debugVol) / viewSpaceVol > 0.0001) 
     3458                        /*if ((totalVol - voll - volr - debugVol) / viewSpaceVol > 0.0001) 
    34543459                                Debug << "front and back volume: " << (totalVol - voll - volr) / viewSpaceVol << " error: " << (totalVol - voll - volr - debugVol) / viewSpaceVol << endl; 
    3455                         /*      Debug << "pos: " << currentPos  
     3460                                Debug << "pos: " << currentPos  
    34563461                                 << "\t (pvsl: " << pvsl << ", pvsr: " << pvsr << ")" 
    34573462                                 << "\t (voll: " << voll << ", volr: " << volr << ")" 
     
    39613966 
    39623967        KdLeaf *leaf = tData.mNode; 
    3963         int totalPvs = (int)leaf->mObjects.size(); 
    3964  
     3968        const int totalPvs = (int)leaf->mObjects.size(); 
     3969         
    39653970        ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 
    39663971 
     
    39733978                Intersectable *obj = *oit; 
    39743979                const AxisAlignedBox3 box = obj->GetBox(); 
    3975  
    3976                 //cout << "totalpvs " << totalPvs << endl; 
    39773980 
    39783981                // test if box falls in left / right child node 
     
    40154018                        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    40164019 
    4017                         // mail view cell 
     4020                        // traverse through view cells and classify them according 
     4021                        // to them being seen from to back / front / front and back node 
    40184022                        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    40194023                        { 
     
    40244028                                        collectedViewCells.push_back(vc); 
    40254029 
     4030                                // classify / mail the view cell 
    40264031                                MailViewCell(*vit, classification);      
    40274032                        } 
     
    40294034        } 
    40304035 
     4036 
     4037        // evaluate view cells volume contribution with respect to the mail box classification 
    40314038        ViewCellContainer::const_iterator vit, vit_end = collectedViewCells.end(); 
    40324039 
    4033         // evaluate view cells volume contribution with respect to mail box 
    40344040        for (vit = collectedViewCells.begin(); vit != vit_end; ++ vit) 
    40354041        { 
    40364042                AddViewCellVolumeContri(*vit, pFront, pBack, pFrontAndBack); 
    40374043        } 
     4044 
    40384045 
    40394046        // these are non-overlapping sets 
    40404047        pOverall = pFront + pBack + pFrontAndBack; 
    40414048 
     4049 
    40424050        //-- pvs rendering heuristics 
     4051 
    40434052        const float oldRenderCost = pOverall * totalPvs; 
     4053         
     4054        // sum up the terms:  
     4055        // the view cells seeing 
     4056        // a) the left node are weighted by the #left node objects 
     4057        // b) the right node are weighted by the #right node objects 
     4058        // c) both nodes are weighted by the #parent node objects 
    40444059        const float newRenderCost = pvsFront * pFront + pvsBack * pBack + totalPvs * pFrontAndBack; 
    40454060 
     
    40504065                  << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl  
    40514066                  << "back p: " << pBack / viewSpaceVol << " front p " << pFront / viewSpaceVol  
    4052                   << " front and back p " << pFrontAndBack / viewSpaceVol << " p: " << pOverall / viewSpaceVol << endl 
     4067                  << " front and back p " << pFrontAndBack / viewSpaceVol << " p: " << tData.mProbability / viewSpaceVol << endl 
    40534068                  << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl 
    40544069                  << "render cost decrease: " << renderCostDecrease << endl; 
     4070                   
     4071        //if ((((pOverall - tData.mProbability) / viewSpaceVol) > 0.00001)) 
     4072        //      Debug << "ERROR!!"<<endl; 
    40554073 
    40564074        normalizedOldRenderCost = oldRenderCost / viewSpaceVol; 
    40574075 
    4058         if (oldRenderCost < newRenderCost * 0.99) 
    4059                 Debug << "\nwarning2!!:\n" << "old rc: " << oldRenderCost * viewSpaceVol << " new rc: " << newRenderCost * viewSpaceVol << endl; 
    4060          
     4076                 
    40614077        return renderCostDecrease; 
    40624078} 
     
    42244240                dirtyList.push_back(leaf->GetSplitCandidate()); 
    42254241        } 
    4226 } 
    4227  
    4228  
    4229 int OspTree::ComputePvsSize(const ObjectContainer &objects) const 
    4230 { 
    4231         int pvsSize = 0; 
    4232  
    4233         ObjectContainer::const_iterator oit, oit_end = objects.end(); 
    4234  
    4235         for (oit = objects.begin(); oit != oit_end; ++ oit) 
    4236         { 
    4237                 pvsSize += (*oit)->mViewCellPvs.GetSize(); 
    4238         } 
    4239  
    4240         return pvsSize; 
    42414242} 
    42424243 
     
    44864487{ 
    44874488        if (vc->Mailed()) 
     4489        { 
    44884490                frontVol += vc->GetVolume(); 
     4491        } 
    44894492        else if (vc->Mailed(1)) 
     4493        { 
    44904494                backVol += vc->GetVolume(); 
     4495        } 
    44914496        else if (vc->Mailed(2)) 
     4497        { 
    44924498                frontAndBackVol += vc->GetVolume(); 
    4493 } 
    4494  
    4495  
    4496 float OspTree::EvalViewCellsVolume(const RayInfoContainer &rays) const 
     4499        } 
     4500} 
     4501 
     4502 
     4503float OspTree::EvalViewCellsVolume(KdLeaf *leaf, const RayInfoContainer &rays) const 
    44974504{ 
    44984505        float vol = 0; 
     
    45054512                VssRay *ray = (*rit).mRay; 
    45064513 
    4507                 if (!ray->mTerminationObject && !ray->mOriginObject) 
     4514                // process ray if the hit point with termination / origin object  
     4515                // is inside this kd leaf 
     4516                if (!((ray->mOriginObject && (GetLeaf(ray->mOrigin, ray->mOriginNode) == leaf)) || 
     4517                          (ray->mTerminationObject && (GetLeaf(ray->mTermination, ray->mTerminationNode) == leaf)))) 
    45084518                        continue; 
    45094519                 
     
    45744584        mVspTree.PreprocessRays(sampleRays, rays); 
    45754585 
    4576         const int pvsSize = mVspTree.ComputePvsSize(rays); 
     4586        const int pvsSize = mVspTree.EvalPvsSize(rays); 
    45774587         
    45784588        Debug <<  "pvs size: " << (int)pvsSize << endl; 
     
    46474657        mOspTree.mRoot = kdleaf; 
    46484658         
    4649         // add first candidate for view space partition 
    4650  
    4651         // TODO matt: this is something different than pvs size. 
    4652         const int pvsSize = mOspTree.ComputePvsSize(objects); 
    4653         const float prop = mOspTree.mBoundingBox.GetVolume(); 
     4659        const float prop = mOspTree.EvalViewCellsVolume(kdleaf, rays); 
     4660 
     4661        //-- add first candidate for view space partition 
    46544662 
    46554663        // first osp traversal data 
     
    46574665                                                                        0, 
    46584666                                                                        &rays, 
    4659                                                                         pvsSize, 
     4667                                                                        (int)objects.size(), 
    46604668                                                                        prop, 
    46614669                                                                        mOspTree.mBoundingBox); 
     
    46684676        mOspTree.EvalSplitCandidate(*oSplitCandidate); 
    46694677 
    4670         const float vol = mOspTree.EvalViewCellsVolume(rays); 
    4671  
    4672         mOspTree.mTotalCost = (float)objects.size() * vol; 
     4678        mOspTree.mTotalCost = (float)objects.size() * prop / mVspTree.GetBoundingBox().GetVolume(); 
    46734679        mOspTree.EvalSubdivisionStats(*oSplitCandidate); 
    46744680 
     
    47804786             
    47814787                mTotalCost -= splitCandidate->GetRenderCostDecrease(); 
     4788 
    47824789                // cost ratio of cost decrease / totalCost 
    47834790                const float costRatio = splitCandidate->GetRenderCostDecrease() / mTotalCost; 
     
    47854792                if (costRatio < mTermMinGlobalCostRatio) 
    47864793                        ++ mGlobalCostMisses; 
    4787  
    4788                 /*               
    4789                 cout << "nodes: " << ++ numNodes << endl; 
     4794         
    47904795                Debug << "\n**********" << endl 
    47914796                          << "total cost: " << mTotalCost << " render cost decr: "  
    47924797                          << splitCandidate->GetRenderCostDecrease()  
    47934798                          << " cost ratio: " << costRatio << endl << endl; 
    4794 */ 
     4799 
    47954800                //-- subdivide leaf node 
    47964801 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h

    r1180 r1181  
    918918                                                         float maxBand); 
    919919 
     920        /** Evaluate pvs size associated with the rays. 
     921        */ 
     922        int EvalPvsSize(const RayInfoContainer &rays) const; 
     923 
    920924        /** Computes pvs increase with respect to the previous pvs for heuristics. 
    921925        */ 
     
    991995                float &totalPvs) const; 
    992996 
    993  
    994         /** Computes PVS size induced by the rays. 
    995         */ 
    996         int ComputePvsSize(const RayInfoContainer &rays) const; 
    997          
    998997        /** Collects pvs from rays. 
    999998        */ 
     
    10561055        /** Rays will be clipped to the bounding box. 
    10571056        */ 
    1058         void PreprocessRays(const VssRayContainer &sampleRays, 
    1059                 RayInfoContainer &rays); 
     1057        void PreprocessRays(const VssRayContainer &sampleRays, RayInfoContainer &rays); 
    10601058 
    10611059        /** Evaluate subdivision statistics. 
     
    14061404 
    14071405 
    1408         /** Compute "pvs size" of this object container 
    1409                 @note not really pvs size just weighted sum of object taking their 
    1410                 appearances in pvss into account 
    1411         */ 
    1412         int ComputePvsSize(const ObjectContainer &objects) const; 
    1413  
    14141406        /** Returns kd leaf the point pt lies in, starting from root. 
    14151407        */ 
     
    14171409 
    14181410 
    1419         /// pointer to the hierarchy of view cells 
    1420         ViewCellsTree *mViewCellsTree; 
     1411        ViewCellsTree *GetViewCellsTree() const { return mViewCellsTree; } 
     1412 
     1413        void SetViewCellsTree(ViewCellsTree *vt) { mViewCellsTree = vt; } 
    14211414 
    14221415 
     
    17041697                float &volRight); 
    17051698 
    1706         float EvalViewCellsVolume(const RayInfoContainer &rays) const; 
     1699        float EvalViewCellsVolume(KdLeaf *leaf, const RayInfoContainer &rays) const; 
    17071700 
    17081701 
    17091702protected: 
     1703 
     1704        /// pointer to the hierarchy of view cells 
     1705        ViewCellsTree *mViewCellsTree; 
    17101706 
    17111707        VspTree *mVspTree; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r1154 r1181  
    179179        if (preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger) 
    180180        { 
    181                 cout << "here99" << endl;  
    182181                // create and run the preprocessor application in a parallel thread 
    183                 pt.InitThread();        cout << "here77" << endl;  
     182                pt.InitThread(); 
    184183                //pt.RunThread(); 
    185184 
    186                 cout << "here51" << endl;  
    187185                // display the render widget 
    188186                DisplayWidget(); 
     
    193191                pt.Main(); 
    194192        } 
    195         cout << "here39" << endl;  
     193         
    196194        Cleanup(); 
    197195 
Note: See TracChangeset for help on using the changeset viewer.