Changeset 1293


Ignore:
Timestamp:
08/29/06 09:52:56 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/GtpVisibility.sln

    r1264 r1293  
    3232                {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} = {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} 
    3333                {101A7691-74F3-48B4-96A3-CF35578F5900} = {101A7691-74F3-48B4-96A3-CF35578F5900} 
     34                {7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D} 
    3435        EndProjectSection 
    3536EndProject 
     
    3738        ProjectSection(ProjectDependencies) = postProject 
    3839                {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} = {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} 
     40                {7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D} 
    3941        EndProjectSection 
    4042EndProject 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1291 r1293  
    639639 
    640640        Debug << "\n§§§§ eval local cost §§§§" << endl 
    641                   << "back pvs: " << (int)objectsBack.size() << " front pvs: " << objectsFront.size() << " total pvs: " << nTotalObjects << endl  
     641                  << "back pvs: " << (int)objectsBack.size() << " front pvs: " << (int)objectsFront.size() << " total pvs: " << nTotalObjects << endl  
    642642                  << "back p: " << volBack / viewSpaceVol << " front p " << volFront / viewSpaceVol << " p: " << totalVol / viewSpaceVol << endl 
    643643                  << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl 
     
    814814                { 
    815815                        if (mUseCostHeuristics) 
    816                         {cout << "a"; 
     816                        { 
    817817                                //-- partition objects using heuristics 
    818818                                nCostRatio[axis] = 
     
    824824                        } 
    825825                        else 
    826                         {cout << "b"; 
     826                        { 
    827827                                nCostRatio[axis] = 
    828828                                        EvalLocalObjectPartition( 
     
    849849        backObjects = nBackObjects[bestAxis]; 
    850850 
    851         Debug << "val: " << nCostRatio[bestAxis] << " axis: " << bestAxis << endl; 
     851        //Debug << "val: " << nCostRatio[bestAxis] << " axis: " << bestAxis << endl; 
    852852        return nCostRatio[bestAxis]; 
    853853} 
     
    11071107{ 
    11081108        // rather use the simple version 
    1109         return object->mBvhLeaf; 
     1109        if (object->mBvhLeaf) 
     1110        { 
     1111                return object->mBvhLeaf; 
     1112        } 
    11101113 
    11111114        /////////////////////////////////////// 
     
    11331136 
    11341137                        if (IsObjectInLeaf(leaf, object)) 
     1138                        { 
    11351139                                return leaf; 
     1140                        } 
    11361141                }  
    11371142                else     
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1288 r1293  
    24502450                                        "1000"); 
    24512451         
     2452        RegisterOption("Hierarchy.Construction.type", 
     2453                                        optInt, 
     2454                                        "hierarchy_construction_type=", 
     2455                                        "0"); 
     2456 
     2457 
    24522458        ////////////////////////////////////////////////////////////////////////////////// 
    24532459} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp

    r1287 r1293  
    117117        white.mDiffuseColor.g = 1; 
    118118        white.mDiffuseColor.b = 1; 
    119         int objSize = 0; 
    120  
     119         
    121120        for (it = leaves.begin(); it != it_end; ++ it) 
    122121        { 
     
    146145                        SetFilled(); 
    147146                        ExportGeometry(leaf->mObjects); 
    148                         objSize += leaf->mObjects.size(); 
    149147                } 
    150148        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1291 r1293  
    9696                "Hierarchy.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 
    9797 
     98        Environment::GetSingleton()->GetIntValue( 
     99                "Hierarchy.Construction.type", mConstructionType); 
     100 
    98101        //Debug << "max depth: " << mTermMaxDepth << endl; 
    99102        Debug << "min global cost ratio: " << mTermMinGlobalCostRatio << endl; 
     
    144147        SubdivisionCandidate *vsc =  
    145148                mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, viewSpaceRays); 
     149 
    146150        mTQueue.Push(vsc); 
    147151 
    148         SubdivisionCandidate *osc =  
    149                 mOspTree->PrepareConstruction(sampleRays, objects, objectSpaceRays); 
    150  
    151         mTQueue.Push(osc); 
     152    SubdivisionCandidate *osc; 
     153 
     154        switch (mObjectSpaceSubdivisonType) 
     155        { 
     156        case KD_BASED_OBJ_SUBDIV: 
     157                osc = mOspTree->PrepareConstruction(sampleRays, objects, objectSpaceRays); 
     158                mTQueue.Push(osc); 
     159                break; 
     160        case BV_BASED_OBJ_SUBDIV: 
     161                osc = mBvHierarchy->PrepareConstruction(sampleRays, objects); 
     162                mTQueue.Push(osc); 
     163                break; 
     164        default: 
     165                break; 
     166        } 
    152167} 
    153168 
     
    204219 
    205220void HierarchyManager::Construct(const VssRayContainer &sampleRays, 
    206                                                                  const ObjectContainer &objects, 
    207                                                                  AxisAlignedBox3 *forcedViewSpace) 
     221                                                                const ObjectContainer &objects, 
     222                                                                AxisAlignedBox3 *forcedViewSpace) 
     223{ 
     224        switch (mConstructionType) 
     225        { 
     226        case 0:  
     227                ConstructSequential(sampleRays, objects, forcedViewSpace); 
     228                break; 
     229        case 1: 
     230                ConstructInterleaved(sampleRays, objects, forcedViewSpace); 
     231                break; 
     232        default: 
     233                break; 
     234        } 
     235} 
     236 
     237 
     238void HierarchyManager::ConstructInterleaved(const VssRayContainer &sampleRays, 
     239                                                                                        const ObjectContainer &objects, 
     240                                                                                        AxisAlignedBox3 *forcedViewSpace) 
    208241{ 
    209242        RayInfoContainer *objectSpaceRays = new RayInfoContainer(); 
     
    211244 
    212245        // prepare vsp and osp trees for traversal 
    213         PrepareConstruction(sampleRays, objects, forcedViewSpace, *viewSpaceRays, *objectSpaceRays); 
    214  
    215         mVspTree->mVspStats.Reset(); 
    216         mVspTree->mVspStats.Start(); 
    217          
     246        PrepareConstruction(sampleRays,  
     247                                                objects,  
     248                                                forcedViewSpace,  
     249                                                *viewSpaceRays,  
     250                                                *objectSpaceRays); 
     251 
    218252        mHierarchyStats.Reset(); 
    219253        mHierarchyStats.Start(); 
     
    232266bool HierarchyManager::ApplySubdivisionCandidate(SubdivisionCandidate *sc) 
    233267{ 
    234         const bool globalTerminationCriteriaMet =  
    235                         GlobalTerminationCriteriaMet(sc); 
     268        const bool globalTerminationCriteriaMet = GlobalTerminationCriteriaMet(sc); 
    236269 
    237270        const bool vspSplit = (sc->Type() == SubdivisionCandidate::VIEW_SPACE); 
     
    297330                        if (repair) RepairQueue(); 
    298331 
    299                         cout << "candidate: " << splitCandidate->Type() << ", priority: " << splitCandidate->GetPriority() << endl; 
     332                        cout << "candidate: " << splitCandidate->Type() << ", priority: "  
     333                                 << splitCandidate->GetPriority() << endl; 
    300334                } 
    301335 
     
    305339 
    306340 
    307 void HierarchyManager::Construct3(const VssRayContainer &sampleRays, 
    308                                                                   const ObjectContainer &objects, 
    309                                                                   AxisAlignedBox3 *forcedViewSpace) 
    310 { 
    311         // construct only view space partition 
    312         // object kd tree is taken for osp 
    313  
    314         mVspTree->mVspStats.Reset(); 
    315         mVspTree->mVspStats.Start(); 
    316  
    317         RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 
    318          
    319         SubdivisionCandidate *sc =  
    320                 mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays); 
    321  
    322         mTQueue.Push(sc); 
    323  
    324         cout << "starting vsp construction ... " << endl; 
    325  
    326         long startTime = GetTime(); 
    327  
    328         RunConstruction(false); 
    329  
    330         cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 
    331         mVspTree->mVspStats.Stop(); 
    332 } 
    333  
    334  
    335341bool HierarchyManager::FinishedConstruction() const 
    336342{ 
     
    339345 
    340346 
    341 void HierarchyManager::CollectObjectSpaceDirtyList(SubdivisionCandidateContainer &dirtyList) 
     347void HierarchyManager::CollectObjectSpaceDirtyList( 
     348        SubdivisionCandidateContainer &dirtyList) 
    342349{ 
    343350        switch (mObjectSpaceSubdivisonType) 
     
    535542                         
    536543        exporter->SetWireframe(); 
    537         const int maxPvs = 0;//mOspTree.GetStatistics().maxPvs; 
    538  
    539544        exporter->ExportOspTree(*mOspTree, 0); 
    540545} 
    541546 
    542547 
    543 void HierarchyManager::Construct2(const VssRayContainer &sampleRays, 
    544                                                                   const ObjectContainer &objects, 
    545                                                                   AxisAlignedBox3 *forcedViewSpace) 
     548void HierarchyManager::ConstructSequential(const VssRayContainer &sampleRays, 
     549                                                                                   const ObjectContainer &objects, 
     550                                                                                   AxisAlignedBox3 *forcedViewSpace) 
    546551{ 
    547552        // rays clipped in view space and in object space 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1288 r1293  
    150150        ~HierarchyManager(); 
    151151 
     152        void Construct( 
     153                const VssRayContainer &sampleRays, 
     154                const ObjectContainer &objects, 
     155                AxisAlignedBox3 *forcedViewSpace); 
     156 
    152157        /** Constructs the view space and object space subdivision from a given set of rays 
    153158                and a set of objects. 
     
    155160                @param objects the set of objects 
    156161        */ 
    157         void Construct(const VssRayContainer &sampleRays, 
    158                                    const ObjectContainer &objects, 
    159                                    AxisAlignedBox3 *forcedViewSpace); 
    160  
    161         /** Constructs first view cells, then object space partition. 
    162         */ 
    163         void Construct2(const VssRayContainer &sampleRays, 
    164                                         const ObjectContainer &objects, 
    165                                         AxisAlignedBox3 *forcedViewSpace); 
    166  
    167         /** Constructs only vsp tree. 
    168         */ 
    169         void Construct3(const VssRayContainer &sampleRays, 
    170                                         const ObjectContainer &objects, 
    171                                         AxisAlignedBox3 *forcedViewSpace); 
     162        void ConstructInterleaved( 
     163                const VssRayContainer &sampleRays, 
     164                const ObjectContainer &objects, 
     165                AxisAlignedBox3 *forcedViewSpace); 
     166 
     167        /** Constructs first view space hierarchy, then object space hierarchy. 
     168        */ 
     169        void ConstructSequential( 
     170                const VssRayContainer &sampleRays, 
     171                const ObjectContainer &objects, 
     172                AxisAlignedBox3 *forcedViewSpace); 
    172173 
    173174        enum  
     
    266267protected: 
    267268 
     269        int mConstructionType; 
    268270        int mObjectSpaceSubdivisonType; 
    269271 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r1281 r1293  
    6666                }; 
    6767   
    68   Intersectable(): mMailbox(0), mReferences(0) {} 
     68  Intersectable(): mMailbox(0), mReferences(0), mBvhLeaf(0) {} 
    6969 
    7070        void SetId(const int id) { mId = id; } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1292 r1293  
    483483                Debug << "hierarchy manager: osp" << endl; 
    484484                // HACK for testing if per kd evaluation works!! 
    485                 const bool ishack = true; 
     485                const bool ishack = false; 
    486486                if (ishack) 
    487487                        hierarchyManager = new HierarchyManager(mVspTree, mKdTree); 
     
    852852        VssRay *vssRay  = NULL; 
    853853        int hits = 0; 
    854  
     854        int hittriangle; 
    855855        Vector3 pointA, pointB; 
    856856        Vector3 normalA, normalB; 
     
    858858        float dist; 
    859859         
    860         int hittriangle; 
    861860        double normal[3]; 
     861#ifdef GTP_INTERNAL 
    862862        hittriangle = mlrtaIntersectAS(&viewPoint.x, 
    863863                                                                   &direction.x, 
    864864                                                                   normal, 
    865865                                                                   dist); 
     866#else 
     867        hittriangle = -1; 
     868#endif 
    866869        if (hittriangle !=-1 ) { 
    867870          if (hittriangle >= mFaceParents.size()) 
    868                 cerr<<"Warning: traingle index out of range! "<<hittriangle<<endl; 
     871                cerr<<"Warning: triangle index out of range! "<<hittriangle<<endl; 
    869872          else { 
    870873                objectA = mFaceParents[hittriangle].mObject; 
     
    879882 
    880883        Vector3 dir = -direction; 
     884#ifdef GTP_INTERNAL 
    881885        hittriangle = mlrtaIntersectAS(&viewPoint.x, 
    882886                                                                   &dir.x, 
    883887                                                                   normal, 
    884888                                                                   dist); 
     889#else 
     890        hittriangle = -1; 
     891#endif 
     892 
    885893        if (hittriangle !=-1 ) { 
    886894          if (hittriangle >= mFaceParents.size()) 
     
    13251333          int hittriangle; 
    13261334          double n[3]; 
     1335 
     1336#ifdef GTP_INTERNAL 
    13271337          hittriangle = mlrtaIntersectAS(&viewPoint.x, 
    13281338                                                                         &direction.x, 
    13291339                                                                         n, 
    13301340                                                                         dist); 
     1341 
     1342#else 
     1343        hittriangle = -1; 
     1344#endif 
     1345 
    13311346          if (hittriangle !=-1 ) { 
    13321347                if (hittriangle >= mFaceParents.size()) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp

    r1291 r1293  
    154154                                        KdIntersectable *kdObj = dynamic_cast<KdIntersectable *>(obj); 
    155155                                        pvs += CountNewObjectsInKdNode(kdObj);   
    156                                         cout << "z"; 
    157156                                        break; 
    158157                                } 
    159158                        case Intersectable::BVH_INTERSECTABLE: 
    160159                                { 
    161                                         cout << "x"; 
    162160                                        BvhIntersectable *bvhObj = dynamic_cast<BvhIntersectable *>(obj); 
    163161                                        pvs += CountNewObjectsInBvhNode(bvhObj); 
    164162                                        break; 
    165163                                } 
    166                         default:cout << "y"; 
     164                        default: 
    167165                                ++ pvs; 
    168166                                break; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1291 r1293  
    48054805        Debug << "saved rays: " << (int)savedRays.size() << endl; 
    48064806 
    4807         //mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox); 
    4808         mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox); 
     4807        mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox); 
    48094808 
    48104809        VssRayContainer::const_iterator vit, vit_end = constructionRays.end(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1292 r1293  
    26282628        Debug <<  "rays size: " << (int)rays.size() << endl; 
    26292629 
     2630 
    26302631        //-- prepare view space partition 
    26312632 
     
    29302931                        BvhLeaf *bvhleaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 
    29312932 
    2932                         if (!bvhleaf->Mailed()) 
     2933                        if (bvhleaf && !bvhleaf->Mailed()) 
    29332934                        { 
    29342935                                bvhleaf->Mail(); 
Note: See TracChangeset for help on using the changeset viewer.