Changeset 1297


Ignore:
Timestamp:
08/30/06 04:39:53 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
16 edited

Legend:

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

    r1294 r1297  
    2626static float debugVol = 0; 
    2727 
    28 int BvhNode::sMailId = 2147483647; 
     28int BvhNode::sMailId = 10000;//2147483647; 
    2929int BvhNode::sReservedMailboxes = 1; 
    3030 
     
    4444/***************************************************************/ 
    4545 
    46 BvhNode::BvhNode(): mParent(NULL) 
     46BvhNode::BvhNode(): mParent(NULL), mMailbox(0) 
    4747{ 
    4848} 
    4949 
    5050BvhNode::BvhNode(const AxisAlignedBox3 &bbox): 
    51 mParent(NULL), mBoundingBox(bbox) 
     51mParent(NULL), mBoundingBox(bbox), mMailbox(0) 
    5252{ 
    5353} 
     
    5555 
    5656BvhNode::BvhNode(const AxisAlignedBox3 &bbox, BvhInterior *parent): 
    57 mBoundingBox(bbox), mParent(parent) 
     57mBoundingBox(bbox), mParent(parent), mMailbox(0) 
    5858{ 
    5959} 
     
    217217 
    218218        //-- factors for bsp tree split plane heuristics 
    219         Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.ct_div_ci", mCtDivCi); 
    220  
    221         //-- partition criteria 
    222         Environment::GetSingleton()->GetFloatValue("BvHierarchy.Construction.epsilon", mEpsilon); 
    223219 
    224220        // if only the driving axis is used for axis aligned split 
     
    227223        Environment::GetSingleton()->GetBoolValue("BvHierarchy.useCostHeuristics", mUseCostHeuristics); 
    228224 
    229  
    230225        char subdivisionStatsLog[100]; 
    231226        Environment::GetSingleton()->GetStringValue("BvHierarchy.subdivisionStats", subdivisionStatsLog); 
    232227        mSubdivisionStats.open(subdivisionStatsLog); 
    233228 
    234         Environment::GetSingleton()->GetFloatValue("BvHierarchy.Construction.splitBorder", mSplitBorder); 
    235229        Environment::GetSingleton()->GetFloatValue( 
    236230                "BvHierarchy.Construction.renderCostDecreaseWeight", mRenderCostDecreaseWeight); 
     
    240234 
    241235        Debug << "******* Bvh hierarchy options ******** " << endl; 
    242  
    243236    Debug << "max depth: " << mTermMaxDepth << endl; 
    244237        Debug << "min probabiliy: " << mTermMinProbability<< endl; 
     
    247240        Debug << "miss tolerance: " << mTermMissTolerance << endl; 
    248241        Debug << "max leaves: " << mTermMaxLeaves << endl; 
    249  
    250242        Debug << "randomize: " << randomize << endl; 
    251  
    252243        Debug << "min global cost ratio: " << mTermMinGlobalCostRatio << endl; 
    253244        Debug << "global cost miss tolerance: " << mTermGlobalCostMissTolerance << endl; 
     
    387378                EvalSubdivisionCandidate(*frontCandidate); 
    388379                EvalSubdivisionCandidate(*backCandidate); 
     380         
     381                // cross reference 
     382                tFrontData.mNode->SetSubdivisionCandidate(frontCandidate);  
     383                tBackData.mNode->SetSubdivisionCandidate(backCandidate); 
    389384 
    390385                tQueue.Push(frontCandidate); 
     
    397392 
    398393        //-- terminate traversal 
    399         if (newNode->IsLeaf()) 
    400         { 
     394    if (newNode->IsLeaf()) 
     395        { 
     396                //-- store additional info 
    401397                EvaluateLeafStats(tData); 
    402398         
    403                 const bool mStoreRays= true; 
    404  
    405                 //-- store additional info 
     399                const bool mStoreRays = true; 
    406400                if (mStoreRays) 
    407401                { 
     
    429423 
    430424        // cost ratio violated? 
    431         const bool maxCostRatioViolated = ratio < mTermMaxCostRatio; 
     425        const bool maxCostRatioViolated = mTermMaxCostRatio < ratio; 
    432426 
    433427        splitCandidate.mMaxCostMisses = maxCostRatioViolated ?  
    434                 splitCandidate.mParentData.mMaxCostMisses :  
    435                 splitCandidate.mParentData.mMaxCostMisses + 1; 
     428                splitCandidate.mParentData.mMaxCostMisses + 1 : 
     429                splitCandidate.mParentData.mMaxCostMisses; 
    436430 
    437431        const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 
     
    451445        splitCandidate.SetRenderCostDecrease(renderCostDecr); 
    452446 
    453 #if 1 
     447#if 0 
    454448        const float priority = (float)-splitCandidate.mParentData.mDepth; 
    455449#else    
     
    520514 
    521515 
     516#if 0 
    522517float BvHierarchy::EvalLocalObjectPartition(const BvhTraversalData &tData, 
    523518                                                                                        const int axis, 
     
    535530        { 
    536531                Intersectable *obj = *oit; 
    537                 AxisAlignedBox3 box = obj->GetBox(); 
     532                const AxisAlignedBox3 box = obj->GetBox(); 
    538533 
    539534                const float objMid = (box.Max(axis) + box.Min(axis)) * 0.5f; 
     
    553548        return ratio; 
    554549} 
     550 
     551#else 
     552 
     553float BvHierarchy::EvalLocalObjectPartition(const BvhTraversalData &tData, 
     554                                                                                        const int axis, 
     555                                                                                        ObjectContainer &objectsFront, 
     556                                                                                        ObjectContainer &objectsBack) 
     557{ 
     558        SortSubdivisionCandidates(tData, axis); 
     559         
     560        vector<SortableEntry>::const_iterator cit, cit_end = mSubdivisionCandidates->end(); 
     561 
     562        int i = 0; 
     563        const int border = (int)tData.mNode->mObjects.size() / 2; 
     564 
     565    for (cit = mSubdivisionCandidates->begin(); cit != cit_end; ++ cit, ++ i) 
     566        { 
     567                Intersectable *obj = (*cit).mObject; 
     568 
     569                // object mailed => belongs to back objects 
     570                if (i < border)  
     571                        objectsBack.push_back(obj); 
     572                else 
     573                        objectsFront.push_back(obj); 
     574        } 
     575 
     576        const float oldRenderCost = tData.mProbability * (float)tData.mNode->mObjects.size(); 
     577        const float newRenderCost =  
     578                EvalRenderCost(tData, objectsFront, objectsBack); 
     579 
     580        const float ratio = newRenderCost / oldRenderCost; 
     581        return ratio; 
     582} 
     583#endif 
    555584 
    556585 
     
    719748        // mail view cells on the left side 
    720749        ViewCell::NewMail(); 
    721          
    722750        // mail the objects on the left side 
    723751        Intersectable::NewMail(); 
     
    762790                        // => add volume to left node 
    763791                        volLeft += vol; 
    764                         //volRight -= vol; 
    765792                } 
    766793 
     
    815842                { 
    816843                        if (mUseCostHeuristics) 
    817                         { 
     844                        {cout << "h"; 
    818845                                //-- partition objects using heuristics 
    819846                                nCostRatio[axis] = 
     
    825852                        } 
    826853                        else 
    827                         { 
     854                        {cout << "m"; 
    828855                                nCostRatio[axis] = 
    829856                                        EvalLocalObjectPartition( 
     
    10721099        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    10731100 
     1101        Debug << "collecting " << (int)viewCells.size() << " dirty candidates" << endl; 
    10741102        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
    10751103        { 
    10761104                VspViewCell *vc = dynamic_cast<VspViewCell *>(*vit); 
    1077  
    10781105                VspLeaf *leaf = vc->mLeaf; 
     1106                SubdivisionCandidate *candidate = leaf->GetSubdivisionCandidate(); 
     1107                 
    10791108                dirtyList.push_back(leaf->GetSubdivisionCandidate()); 
    10801109        } 
     
    11081137{ 
    11091138        // rather use the simple version 
    1110         if (object->mBvhLeaf) 
    1111         { 
    1112                 return object->mBvhLeaf; 
    1113         } 
    1114  
     1139        if (!object) return NULL; 
     1140        return object->mBvhLeaf; 
     1141         
    11151142        /////////////////////////////////////// 
    11161143        // start from root of tree 
     1144         
    11171145        if (node == NULL) 
    1118         { 
    11191146                node = mRoot; 
    1120         } 
    1121  
     1147         
    11221148        vector<BvhLeaf *> leaves; 
    11231149 
     
    11821208 
    11831209 
    1184 /* 
    1185 int BvHierarchy::UpdateViewCellsPvs(BvhLeaf *leaf,  
    1186                                                                 const RayInfoContainer &rays) const 
    1187  
    1188 { 
    1189         MailablePvsData::NewMail(); 
    1190          
    1191         ViewCellContainer touchedViewCells; 
    1192         CollectTouchedViewCells(rays, touchedViewCells); 
    1193  
    1194         ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 
    1195  
    1196         for (oit = leaf->mObjects.begin(); oit < oit_end; ++ oit) 
    1197         { 
    1198                 Intersectable *obj = *oit; 
    1199                 ViewCellContainer::const_iterator vit, vit_end = touchedViewCells.end(); 
    1200  
    1201                 // traverse through view cells and classify them according 
    1202                 // to them being seen from to back / front / front and back node 
    1203                 for (vit = touchedViewCells.begin(); vit != vit_end; ++ vit) 
    1204                 { 
    1205                         ViewCell *vc = *vit; 
    1206                         float contri; 
    1207                         AddViewCellToObjectPvs(obj, vc, contri, true); 
    1208                 } 
    1209         } 
    1210  
    1211         return 0; 
    1212 } 
    1213  
    1214  
    1215 int BvHierarchy::RemoveParentViewCellsPvs(BvhLeaf *leaf,  
    1216                                                                           const RayInfoContainer &rays 
    1217                                                                           ) const 
    1218  
    1219 { 
    1220         MailablePvsData::NewMail(); 
    1221          
    1222         ViewCellContainer touchedViewCells; 
    1223         CollectTouchedViewCells(rays, touchedViewCells); 
    1224  
    1225         ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 
    1226  
    1227         for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 
    1228         { 
    1229                 Intersectable *obj = *oit; 
    1230  
    1231                 // traverse through view cells and classify them according 
    1232                 // to them being seen from to back / front / front and back node 
    1233         ViewCellContainer::const_iterator vit, vit_end = touchedViewCells.end(); 
    1234  
    1235                 for (vit = touchedViewCells.begin(); vit != vit_end; ++ vit) 
    1236                 { 
    1237                         ViewCell *vc = *vit; 
    1238                          
    1239                         MailablePvsData *vdata = obj->mViewCellPvs.Find(vc); 
    1240  
    1241                         if (vdata && !vdata->Mailed()) 
    1242                         { 
    1243                                 vdata->Mail(); 
    1244                                 obj->mViewCellPvs.RemoveSample(vc, 1); 
    1245                         } 
    1246                 } 
    1247         } 
    1248  
    1249         return 0; 
    1250 } 
    1251 */ 
    1252  
    12531210bool BvHierarchy::Export(OUT_STREAM &stream) 
    12541211{ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1294 r1297  
    3535class VspTree; 
    3636class ViewCellsContainer; 
     37class BvhSubdivisionCandidate; 
     38 
    3739 
    3840/** View space partition statistics. 
     
    4547        // number of splits 
    4648        int splits; 
    47          
    4849        // maximal reached depth 
    4950        int maxDepth; 
    5051        // minimal depth 
    5152        int minDepth; 
    52          
    5353        // max depth nodes 
    5454        int maxDepthNodes; 
     
    123123        enum {Interior, Leaf}; 
    124124 
    125         BvhNode::BvhNode(); 
     125        BvhNode(); 
    126126        BvhNode(const AxisAlignedBox3 &bbox); 
    127127        BvhNode(const AxisAlignedBox3 &bbox, BvhInterior *parent); 
     
    183183        /// the bounding box of the node 
    184184        AxisAlignedBox3 mBoundingBox; 
    185  
    186185        /// parent of this node 
    187186        BvhInterior *mParent; 
     
    246245        bool IsLeaf() const; 
    247246         
    248         SubdivisionCandidate *GetSubdivisionCandidate() const  
     247        SubdivisionCandidate *GetSubdivisionCandidate()// const 
    249248        {  
    250249                return mSubdivisionCandidate;  
    251250        } 
    252251 
     252        void SetSubdivisionCandidate(SubdivisionCandidate *candidate) 
     253        {  
     254                mSubdivisionCandidate = candidate;  
     255        } 
     256 
    253257public: 
    254258 
    255259        /// Rays piercing this leaf. 
    256260        VssRayContainer mVssRays; 
    257          
    258261        /// objects 
    259262        ObjectContainer mObjects; 
    260  
    261263        /// universal counter 
    262264        int mCounter; 
    263  
    264265 
    265266protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1294 r1297  
    23162316 
    23172317 
    2318 /***********************************************************************/ 
    2319 /*            Bounding Volume Hierarchy related options                */ 
    2320 /***********************************************************************/ 
     2318/**********************************************************************/ 
     2319/*            Bounding Volume Hierarchy related options               */ 
     2320/**********************************************************************/ 
    23212321 
    23222322        RegisterOption("BvHierarchy.Construction.randomize", 
     
    23652365                                        "4"); 
    23662366 
    2367         RegisterOption("BvHierarchy.Termination.ct_div_ci", 
    2368                                         optFloat, 
    2369                                         "bvh_term_ct_div_ci=", 
    2370                                         "0"); 
    2371          
    2372         RegisterOption("BvHierarchy.Construction.epsilon", 
    2373                                    optFloat, 
    2374                                    "bvh_construction_epsilon=", 
    2375                                    "0.00001"); 
    2376          
    23772367        // if only the driving axis is used for axis aligned split 
    23782368        RegisterOption("BvHierarchy.splitUseOnlyDrivingAxis",  
     
    23952385                                        "bvh_subdivision_stats=", 
    23962386                                        "bvhSubdivisionStats.log"); 
    2397  
    2398         RegisterOption("BvHierarchy.Construction.splitBorder", 
    2399                                         optFloat, 
    2400                                         "bvh_construction_split_border=", 
    2401                                         "0.01"); 
    24022387 
    24032388        RegisterOption("BvHierarchy.Construction.renderCostDecreaseWeight", 
  • GTP/trunk/Lib/Vis/Preprocessing/src/FlexibleHeap.h

    r1233 r1297  
    214214 
    215215        Swap(i, (int)mBuffer.size() - 1); 
    216  
     216         
    217217        mBuffer.pop_back(); 
    218218        t->NotInHeap(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1295 r1297  
    163163                        osc = mOspTree->PrepareConstruction(sampleRays, objects, objectSpaceRays); 
    164164                        mTQueue.Push(osc); 
    165                 } 
    166                 break; 
     165                        break; 
     166                } 
    167167        case BV_BASED_OBJ_SUBDIV: 
    168168                { 
     
    176176                        osc = mBvHierarchy->PrepareConstruction(sampleRays, objects); 
    177177                        mTQueue.Push(osc); 
    178                 } 
    179                 break; 
     178                        break; 
     179                } 
    180180        default: 
    181181                break; 
     
    183183 
    184184        mTotalCost = (float)objects.size(); 
    185         Debug << " setting total cost to " << mTotalCost << endl; 
     185        Debug << "setting total cost to " << mTotalCost << endl; 
    186186} 
    187187 
     
    273273        const long startTime = GetTime();        
    274274         
    275         const bool repairQueue = true; 
    276  
     275        const bool repairQueue = false; 
    277276        // process object space candidates 
    278277        RunConstruction(repairQueue); 
     
    306305 
    307306        const long startTime = GetTime(); 
     307 
    308308        const bool repairQueue = false; 
     309        // process object space candidates 
     310        RunConstruction(repairQueue); 
    309311 
    310312        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     
    340342        const long startTime = GetTime(); 
    341343                 
     344        const bool repairQueue = false; 
     345        // process object space candidates 
     346        RunConstruction(repairQueue); 
     347 
    342348        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    343  
    344349        mOspTree->mOspStats.Stop(); 
    345350 
     
    348353 
    349354        const float rc = mOspTree->EvalRenderCost(sampleRays); 
    350  
    351355        Debug << "My render cost evalulation: " << rc << endl; 
    352356} 
     
    472476void HierarchyManager::CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList) 
    473477{        
    474         Debug << "here65" << endl; 
    475478        // we have either a object space or view space split 
    476479        if (mCurrentCandidate->Type() == SubdivisionCandidate::VIEW_SPACE) 
    477480        { 
    478                 Debug << "collected view space candidate" << endl; 
    479481                CollectViewSpaceDirtyList(dirtyList); 
    480482        } 
    481483        else // object space split 
    482484        {        
    483                 Debug << "collecting object space candidate" << endl; 
    484485                CollectObjectSpaceDirtyList(dirtyList); 
    485486        } 
     
    515516        for (sit = dirtyList.begin(); sit != sit_end; ++ sit) 
    516517        { 
    517                 Debug << "here4423" << endl; 
    518518                SubdivisionCandidate* sc = *sit; 
    519  
     519                // erase from queue 
    520520                mTQueue.Erase(sc); 
    521  
    522521                // reevaluate 
    523522                sc->EvalPriority(); 
    524  
    525523                // reinsert 
    526524                mTQueue.Push(sc); 
     
    668666        mVspTree->mVspStats.Start(); 
    669667 
    670         int i = 0; 
    671  
    672668        // all objects can be seen from everywhere 
    673669        mTotalCost = (float)dynamic_cast<VspTree::VspSubdivisionCandidate *>(vsc)->mParentData.mPvs; 
    674670 
    675671        const bool repairQueue = false; 
    676  
    677672        // process view space candidates 
    678673        RunConstruction(repairQueue); 
     
    705700                break; 
    706701        } 
    707  
    708         // process object space candidates 
    709         RunConstruction(repairQueue); 
    710 } 
    711  
    712  
    713 } 
     702} 
     703 
     704 
     705} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp

    r1292 r1297  
    99bool MeshDebug = false; 
    1010 
    11 int Intersectable::sMailId = 2147483647; 
     11int Intersectable::sMailId = 1;//2147483647; 
    1212int Intersectable::sReservedMailboxes = 1; 
    1313 
  • GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp

    r1294 r1297  
    643643        float sum = (float)totalVol * sizeBox; 
    644644 
    645         Debug << "here82 render cost: " << renderCost / viewSpaceVol << endl; 
     645        Debug << "total render cost: " << renderCost / viewSpaceVol << endl; 
    646646 
    647647        ///////////////////////////////// 
     
    690690                { 
    691691                        float currentPos; 
    692                         Debug << "here29 : " << minRenderCost / viewSpaceVol << endl; 
     692                        Debug << "current min: " << minRenderCost / viewSpaceVol << endl; 
    693693 
    694694                        // HACK: current positition is BETWEEN visibility events 
     
    895895        } 
    896896 
    897         Debug << "here32 " << (int)touchedViewCells.size() << endl; 
    898897        return renderCost; 
    899898} 
     
    13861385                        if (!vdata) 
    13871386                        { 
    1388                                 Debug << "here86 error!!"<<endl; 
     1387                                Debug << "error!!" << endl; 
    13891388                                continue; 
    13901389                        } 
     
    17931792                } 
    17941793        } 
    1795         Debug << "here65 " << (int)touchedObjects.size() << endl; 
     1794        Debug << "touched view cells: " << (int)touchedObjects.size() << endl; 
    17961795        ObjectContainer::const_iterator it, it_end = touchedObjects.end(); 
    17971796        for (it = touchedObjects.begin(); it != it_end; ++ it) 
    17981797        { 
    1799                 Debug << "\nhere94 obj: " << (*it) << " size: " << (*it)->mViewCellPvs.GetSize() << endl << endl; 
     1798                Debug << "\nobj: " << (*it) << " vc pvs size: " << (*it)->mViewCellPvs.GetSize() << endl << endl; 
    18001799                ViewCellPvsMap::const_iterator mit, mit_end = (*it)->mViewCellPvs.mEntries.end(); 
    18011800 
    18021801                for (mit = (*it)->mViewCellPvs.mEntries.begin(); mit != mit_end; ++ mit) 
    18031802                { 
    1804                         Debug << "newsumpdf: " << (*mit).second.mSumPdf << endl; 
     1803                        Debug << "new sumpdf: " << (*mit).second.mSumPdf << endl; 
    18051804                } 
    18061805        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r1292 r1297  
    695695           
    696696          CastRays(rays, tmpVssRays); 
    697           castRays += rays.size(); 
     697          castRays += (int)rays.size(); 
    698698#if ADD_RAYS_IN_PLACE  
    699699          contributions[0] = mViewCellsManager->ComputeSampleContributions(tmpVssRays, true, false); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r1280 r1297  
    103103        mPreprocessor.mViewCellsManager->GetViewPoint(origin); 
    104104 
    105         const float alpha = RandomValue(0.0f, 2.0f * M_PI); 
    106         const float beta = RandomValue(-M_PI * 0.5f, M_PI * 0.5f); 
     105        const float alpha = RandomValue(0.0f, 2.0f * (float)M_PI); 
     106        const float beta = RandomValue((float)-M_PI * 0.5f, (float)M_PI * 0.5f); 
    107107         
    108108        direction = VssRay::GetDirection(alpha, beta); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h

    r1259 r1297  
    4646        } 
    4747 
     48        /** Position in queue. 
     49        */ 
     50        int GetPosition() const 
     51        { 
     52                return mPosition; 
     53        } 
     54 
    4855protected: 
    4956 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1287 r1297  
    3232                                           myless<vector<ViewCell *>::value_type> > TraversalQueue; 
    3333 
    34 int ViewCell::sMailId = 2147483647; 
     34int ViewCell::sMailId = 1;//2147483647; 
    3535int ViewCell::sReservedMailboxes = 1; 
    3636 
     
    112112mEntriesInPvs(0), 
    113113mPvsSizeValid(false) 
     114//mMailbox(0) 
    114115{ 
    115116} 
     
    124125mPvsSize(0), 
    125126mPvsSizeValid(false) 
     127//mMailbox(0) 
    126128{ 
    127129} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r1286 r1297  
    233233 
    234234        //////////////////////////////////////////// 
    235         //      mailing stuff 
     235        //-- mailing stuff 
    236236 
    237237 
     
    255255        static int sMailId; 
    256256        static int sReservedMailboxes; 
    257  
     257        //int mMailbox; 
    258258         
    259259protected: 
     
    261261        /// parent view cell in the view cell hierarchy 
    262262        ViewCellInterior *mParent; 
    263  
    264263        /// the potentially visible objects 
    265264        ObjectPvs mPvs; 
    266265        /// the volume of this view cell 
    267266        float mVolume; 
     267         
    268268        float mArea; 
    269269        /// the cost that were paid for merging this view cells from two others. 
     
    271271        /// if the view cell is valid view space 
    272272        bool mValid; 
    273  
    274273        /// color used for consistent visualization 
    275274        RgbColor mColor; 
    276  
    277275        /// store pvs size, used for evaluation purpose when pvss are stored only in the leaves 
    278276        int mPvsSize; 
     277 
    279278        /** stores number of entries in pvs 
    280279            this variable has the same value as mPvsSize for object pvs,  
     
    283282        int mEntriesInPvs; 
    284283 
    285         /// if the pvs size scalar (+ entries into pvs) 
    286         /// is up to date and corresponding to the real pvs size 
     284        /** if the pvs size scalar (+ entries into pvs) 
     285                is up to date and corresponding to the real pvs size 
     286        */ 
    287287        bool mPvsSizeValid; 
     288 
    288289}; 
    289290 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r1294 r1297  
    164164                        mHierarchyManager->mOspTree->mRoot, *mObjects); 
    165165        } 
    166         else 
    167                 cout << "here209" << endl; 
    168  
    169166} 
    170167 
     
    12371234        for (int i = 0; i < len; ++ i)  
    12381235        { 
    1239                 cout << "here5" << endl; 
    12401236                string attrName(StrX(attributes.getName(i)).LocalForm()); 
    12411237                StrX attrValue(attributes.getValue(i)); 
     
    12561252        if (mCurrentBvhNode) // replace NULL child of parent with current node 
    12571253        { 
    1258                 cout << "here8" << endl; 
    12591254                BvhInterior *parent = dynamic_cast<BvhInterior *>(mCurrentBvhNode); 
    12601255                parent->ReplaceChildLink(NULL, interior); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1294 r1297  
    535535                ); 
    536536 
    537         if (0 && localTerminationCriteriaMet) 
     537        if (1 && localTerminationCriteriaMet) 
    538538        { 
    539539                Debug << "********local termination *********" << endl; 
     
    628628{ 
    629629        // todo remove dynamic cast 
    630         VspSubdivisionCandidate *sc = dynamic_cast<VspSubdivisionCandidate *>(splitCandidate); 
     630        VspSubdivisionCandidate *sc =  
     631                dynamic_cast<VspSubdivisionCandidate *>(splitCandidate); 
    631632        VspTraversalData &tData = sc->mParentData; 
    632633 
    633634        VspNode *newNode = tData.mNode; 
    634  
    635635 
    636636        if (!LocalTerminationCriteriaMet(tData) && !globalCriteriaMet) 
    637637        {        
     638                //-- continue subdivision 
    638639                VspTraversalData tFrontData; 
    639640                VspTraversalData tBackData; 
    640  
    641                 //-- continue subdivision 
    642641                 
    643642                // create new interior node and two leaf node 
    644643                const AxisAlignedPlane splitPlane = sc->mSplitPlane; 
     644                const int maxCostMisses = sc->mMaxCostMisses; 
     645 
    645646                newNode = SubdivideNode(splitPlane, tData, tFrontData, tBackData); 
    646647         
    647                 const int maxCostMisses = sc->mMaxCostMisses; 
    648  
    649  
    650648                // how often was max cost ratio missed in this branch? 
    651649                tFrontData.mMaxCostMisses = maxCostMisses; 
     
    666664                EvalSubdivisionCandidate(*backCandidate); 
    667665 
     666                // cross reference 
     667                tFrontData.mNode->SetSubdivisionCandidate(frontCandidate);  
     668                tBackData.mNode->SetSubdivisionCandidate(backCandidate); 
     669 
    668670                tQueue.Push(frontCandidate); 
    669671                tQueue.Push(backCandidate); 
    670672                 
    671                 // delete old view cell 
    672                 delete tData.mNode->mViewCell; 
    673  
    674673                // delete old leaf node 
    675674                //DEL_PTR(tData.mNode); 
     
    689688#if 0 
    690689                //-- store pvs optained from rays 
    691  
    692690                AddSamplesToPvs(leaf, *tData.mRays, sampCon, conSamp); 
    693691 
     
    734732                                                                                 backProb); 
    735733 
    736         const bool success = ratio < mTermMaxCostRatio; 
     734        const bool maxCostRatioViolated = mTermMaxCostRatio < ratio; 
    737735 
    738736        // max cost threshold violated? 
    739737        splitCandidate.mMaxCostMisses =  
    740                 success ? splitCandidate.mParentData.mMaxCostMisses : splitCandidate.mParentData.mMaxCostMisses + 1; 
     738                maxCostRatioViolated  ?  
     739                        splitCandidate.mParentData.mMaxCostMisses + 1: 
     740                        splitCandidate.mParentData.mMaxCostMisses; 
    741741         
    742742        float oldRenderCost; 
     
    749749        splitCandidate.SetRenderCostDecrease(renderCostDecr); 
    750750 
    751 #if 1 
     751#if 0 
    752752        const float priority = (float)-splitCandidate.mParentData.mDepth; 
    753753#else    
     
    783783                          *frontData.mRays, 
    784784                          *backData.mRays); 
    785          
    786         //Debug << "f: " << frontData.mRays->size() << " b: " << backData.mRays->size() << "d: " << tData.mRays->size() << endl; 
    787785 
    788786        //-- compute pvs 
     
    790788        backData.mPvs = EvalPvsSize(*backData.mRays); 
    791789 
     790        Debug << "f pvs: " << frontData.mPvs << " b pvs: " << backData.mPvs << " pvs " << tData.mPvs << endl; 
     791 
    792792        // split front and back node geometry and compute area 
    793         tData.mBoundingBox.Split(splitPlane.mAxis, splitPlane.mPosition,  
    794                                                          frontData.mBoundingBox, backData.mBoundingBox); 
    795  
     793        tData.mBoundingBox.Split(splitPlane.mAxis,  
     794                                                         splitPlane.mPosition,  
     795                                                         frontData.mBoundingBox,  
     796                                                         backData.mBoundingBox); 
    796797 
    797798        frontData.mProbability = frontData.mBoundingBox.GetVolume(); 
    798799        backData.mProbability = tData.mProbability - frontData.mProbability; 
    799800 
    800          
     801 
    801802    /////////////////////////////////////////// 
    802803        // subdivide further 
     
    805806        if (tData.mDepth > mVspStats.maxDepth) 
    806807        { 
    807                 Debug << "max depth increases to " << tData.mDepth << " at " << mVspStats.Leaves() << " leaves" << endl; 
     808                Debug << "max depth increases to " << tData.mDepth  
     809                          << " at " << mVspStats.Leaves() << " leaves" << endl; 
    808810                mVspStats.maxDepth = tData.mDepth; 
    809811        } 
     
    10541056        Intersectable::NewMail(); 
    10551057        KdNode::NewMail(); 
    1056         BvhNode::NewMail(); 
     1058        BvhLeaf::NewMail(); 
    10571059 
    10581060        int pvsSize = 0; 
     
    13661368        float totalPvs = 0; 
    13671369 
    1368         // probability that view point lies in back / front node 
    1369         float pOverall = data.mProbability; 
    1370         float pFront = 0; 
    1371         float pBack = 0; 
    1372  
    13731370        const float viewSpaceVol = mBoundingBox.GetVolume(); 
    13741371 
     
    13761373        Intersectable::NewMail(3); 
    13771374        KdLeaf::NewMail(3); 
     1375        //for (int i=0;i<25;++i) BvhLeaf::NewMail(); 
    13781376        BvhLeaf::NewMail(3); 
    13791377 
     
    13941392                // evaluate contribution of ray endpoint to front and back pvs 
    13951393                // with respect to the classification 
    1396                 UpdateContributionsToPvs(*ray, true, cf, pvsFront, pvsBack, totalPvs); 
     1394                //Debug << "mail1:  " << BvhLeaf::sMailId << endl; 
     1395                UpdateContributionsToPvs(*ray, true, cf, pvsFront, pvsBack, totalPvs);   
     1396                //Debug << "mail2:  " << BvhLeaf::sMailId << endl; 
    13971397                UpdateContributionsToPvs(*ray, false, cf, pvsFront, pvsBack, totalPvs); 
     1398                //Debug << "mail3:  " << BvhLeaf::sMailId << endl; 
    13981399        } 
    13991400 
     
    14041405        data.mBoundingBox.Split(candidatePlane.mAxis, candidatePlane.mPosition, frontBox, backBox); 
    14051406 
    1406         pFront = frontBox.GetVolume(); 
    1407         pBack = pOverall - pFront;       
     1407        // probability that view point lies in back / front node 
     1408        float pOverall = data.mProbability; 
     1409        float pFront = pFront = frontBox.GetVolume(); 
     1410        float pBack = pOverall - pFront; 
     1411 
    14081412 
    14091413        //-- pvs rendering heuristics 
    1410  
    14111414        const int lowerPvsLimit = mViewCellsManager->GetMinPvsSize(); 
    14121415        const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); 
     
    14491452        // create unique ids for pvs heuristics 
    14501453        Intersectable::NewMail(3); 
     1454        BvhLeaf::NewMail(3); 
     1455        KdLeaf::NewMail(3); 
    14511456 
    14521457        const int pvsSize = data.mPvs; 
     
    15631568                { 
    15641569                        frontPvs += renderCost; 
    1565                  
     1570         
    15661571                        // already in back pvs => in both pvss 
    15671572                        if (leaf->Mailed(1)) 
     
    15801585                        // already in front pvs => in both pvss 
    15811586                        if (leaf->Mailed()) 
     1587                        { 
    15821588                                leaf->Mail(2); 
     1589                        } 
    15831590                        else 
    15841591                                leaf->Mail(1); 
     
    20612068        Intersectable::NewMail(); 
    20622069        KdNode::NewMail(); 
    2063         BvhNode::NewMail(); 
     2070        BvhLeaf::NewMail(); 
    20642071 
    20652072        RayInfoContainer::const_iterator rit, rit_end = rays.end(); 
     
    26272634        Debug <<  "rays size: " << (int)rays.size() << endl; 
    26282635 
    2629  
    26302636        //-- prepare view space partition 
    26312637        const float prop = mBoundingBox.GetVolume(); 
     
    26422648                 
    26432649#if WORK_WITH_VIEWCELL_PVS 
    2644          
    26452650        // add first view cell to all the objects view cell pvs 
    26462651        ObjectPvsMap::const_iterator oit,  
     
    29512956                        BvhLeaf *bvhleaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 
    29522957 
    2953                         if (bvhleaf && !bvhleaf->Mailed()) 
     2958                        if (!bvhleaf->Mailed()) 
    29542959                        { 
    29552960                                bvhleaf->Mail(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h

    r1294 r1297  
    3737class KdTreeStatistics; 
    3838class SubdivisionCandidate; 
    39  
     39class VspSubdivisionCandidate; 
    4040 
    4141/** View space partition statistics. 
     
    161161        */ 
    162162        virtual bool IsRoot() const; 
    163  
    164163        /** Returns parent node. 
    165164        */ 
    166165        VspInterior *GetParent(); 
    167  
    168166        /** Sets parent node. 
    169167        */ 
    170168        void SetParent(VspInterior *parent); 
    171  
    172169        /** Returns true if this node is a sibling of node n. 
    173170        */ 
    174171        bool IsSibling(VspNode *n) const; 
    175  
    176172        /** returns depth of the node. 
    177173        */ 
    178174        int GetDepth() const; 
    179  
    180175        /** returns true if the whole subtree is valid 
    181176        */ 
     
    297292        */ 
    298293        ViewCellLeaf *GetViewCell() const; 
    299  
    300294        /** Sets pointer to view cell. 
    301295        */ 
    302296        void SetViewCell(ViewCellLeaf *viewCell); 
    303297 
    304         SubdivisionCandidate *GetSubdivisionCandidate() const  
     298        SubdivisionCandidate *GetSubdivisionCandidate() 
    305299        {  
    306300                return mSubdivisionCandidate;  
    307301        } 
    308302 
     303        void SetSubdivisionCandidate(SubdivisionCandidate *candidate) 
     304        {  
     305                mSubdivisionCandidate = candidate;  
     306        } 
     307 
     308 
    309309public: 
    310310 
    311311        /// Rays piercing this leaf. 
    312312        VssRayContainer mVssRays; 
    313          
    314313        /// leaf pvs 
    315314        ObjectPvs *mPvs; 
    316  
    317315        /// Probability that the view point lies in this leaf 
    318316        float mProbability; 
     
    322320        /// pointer to a split plane candidate splitting this leaf 
    323321        SubdivisionCandidate *mSubdivisionCandidate; 
    324  
    325322        /// if NULL this does not correspond to feasible viewcell 
    326323        ViewCellLeaf *mViewCell; 
     
    400397                { 
    401398                        DEL_PTR(mRays); 
    402                         DEL_PTR(mNode); 
     399 
     400                        if (mNode) 
     401                        { 
     402                                // delete old view cell 
     403                                delete mNode->GetViewCell(); 
     404                                delete mNode; 
     405                                mNode = NULL; 
     406                        } 
    403407                } 
    404408 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssTree.cpp

    r1233 r1297  
    543543        float sum = pvsBack*(position - minBox) + pvsFront*(maxBox - position); 
    544544        float newCost = ct_div_ci + sum/sizeBox; 
    545         float oldCost = pvsSize; 
     545        float oldCost = (float)pvsSize; 
    546546        ratio = newCost/oldCost; 
     547 
    547548  } else { 
    548549        // importance based cost 
     
    559560#else 
    560561#if 1 
    561         float newCost = raysBack*pvsBack  + raysFront*pvsFront; 
     562        float newCost = float(raysBack*pvsBack  + raysFront*pvsFront); 
    562563        float oldCost = (float)leaf->rays.size()*pvsSize; 
    563564        ratio = newCost/oldCost; 
     
    807808  float maxBand = minBox + 0.9*(maxBox - minBox); 
    808809         
    809   float minRatio = 1e20; 
     810  float minRatio = 1e20f; 
    810811         
    811812  Intersectable::NewMail(); 
     
    16631664          VssTreeLeaf *leaf = (VssTreeLeaf *)node; 
    16641665          float c = leaf->GetImportance(); 
    1665           int num = (c*ratioPerLeaf + 0.5); 
     1666          int num = (c*ratioPerLeaf + 0.5f); 
    16661667          //                    cout<<num<<" "; 
    16671668 
     
    17201721{ 
    17211722  int nrays = (int)leaf->rays.size(); 
    1722   for (int i=0; i < numberOfRays; i++) { 
     1723  for (int i = 0; i < numberOfRays; ++ i) { 
    17231724        // pickup 3 random rays 
    1724         int r1 = (int)RandomValue(0, nrays-1); 
    1725         int r2 = (int)RandomValue(0, nrays-1); 
    1726         int r3 = (int)RandomValue(0, nrays-1); 
     1725        int r1 = (int)RandomValue(0, (float)(nrays-1)); 
     1726        int r2 = (int)RandomValue(0, (float)(nrays-1)); 
     1727        int r3 = (int)RandomValue(0, (float)(nrays-1)); 
    17271728                 
    17281729        Vector3 o1 = leaf->rays[r1].Extrap(RandomValue(leaf->rays[r1].GetMinT(),  
Note: See TracChangeset for help on using the changeset viewer.