Changeset 1314


Ignore:
Timestamp:
09/03/06 03:13:29 (18 years ago)
Author:
mattausch
Message:

started osp mesh construction for obj files. Introduced new primitive faceintersectable

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
9 edited

Legend:

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

    r1313 r1314  
    619619        float volBack = volLeft; 
    620620        float volFront = volRight; 
    621  
    622621        float newRenderCost = nTotalObjects * totalVol; 
    623622 
     623#ifdef _DEBUG 
     624        const int leaves = mBvhStats.Leaves(); 
     625        const bool printStats = ((axis == 0) && (leaves > 0) && (leaves < 90)); 
     626         
     627        ofstream sumStats; 
     628        ofstream vollStats; 
     629        ofstream volrStats; 
     630 
     631        if (printStats) 
     632        { 
     633                char str[64];    
     634                sprintf(str, "tmp/bvh_heur_sum-%04d.log", leaves); 
     635                sumStats.open(str); 
     636                sprintf(str, "tmp/bvh_heur_voll-%04d.log", leaves); 
     637                vollStats.open(str); 
     638                sprintf(str, "tmp/bvh_heur_volr-%04d.log", leaves); 
     639                volrStats.open(str); 
     640        } 
     641#endif 
    624642 
    625643        ///////////////////////////// 
     
    647665                                                  volRight * (float)nObjectsRight; 
    648666 
     667#ifdef _DEBUG 
     668                 
     669                if (printStats) 
     670                { 
     671                        sumStats 
     672                                << "#Position\n" << nObjectsRight << endl 
     673                                << "#Sum\n" << sum / viewSpaceVol << endl 
     674                                << "#Vol\n" << (volLeft +  volRight) / viewSpaceVol << endl; 
     675 
     676                        vollStats 
     677                                << "#Position\n" << nObjectsRight << endl 
     678                                << "#Vol\n" << volLeft / viewSpaceVol << endl; 
     679 
     680                        volrStats 
     681                                << "#Position\n" << nObjectsRight << endl 
     682                                << "#Vol\n" << volRight / viewSpaceVol << endl; 
     683                } 
     684#endif 
     685 
    649686                if (sum < newRenderCost) 
    650687                { 
     
    675712        const float ratio = newRenderCost / oldRenderCost; 
    676713 
     714#ifdef _DEBUG 
    677715        Debug << "\n§§§§ eval local cost §§§§" << endl 
    678716                  << "back pvs: " << (int)objectsBack.size() << " front pvs: " << (int)objectsFront.size() << " total pvs: " << nTotalObjects << endl  
     
    680718                  << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl 
    681719                  << "render cost decrease: " << oldRenderCost / viewSpaceVol - newRenderCost / viewSpaceVol << endl; 
     720#endif 
    682721 
    683722        return ratio; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1311 r1314  
    24262426                                        "0"); 
    24272427 
    2428  
    24292428        RegisterOption("Hierarchy.Construction.minDepthForOsp", 
    24302429                                        optInt, 
     
    24322431                                        "-1"); 
    24332432 
     2433        RegisterOption("Hierarchy.Construction.repairQueue", 
     2434                                        optBool, 
     2435                                        "hierarchy_construction_repair_queue=", 
     2436                                        "true"); 
    24342437 
    24352438        ////////////////////////////////////////////////////////////////////////////////// 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1313 r1314  
    105105                "Hierarchy.Construction.minDepthForOsp", mMinDepthForObjectSpaceSubdivion); 
    106106         
     107        Environment::GetSingleton()->GetBoolValue( 
     108                "Hierarchy.Construction.repairQueue", mRepairQueue); 
     109 
    107110        Debug << "******** Hierachy Manager Parameters ***********" << endl; 
    108111        Debug << "max leaves: " << mTermMaxLeaves << endl; 
    109112        Debug << "min global cost ratio: " << mTermMinGlobalCostRatio << endl; 
    110113        Debug << "global cost miss tolerance: " << mTermGlobalCostMissTolerance << endl; 
     114        Debug << "construction type: " << mConstructionType << endl; 
     115        Debug << "min depth for object space subdivision: " << mMinDepthForObjectSpaceSubdivion << endl; 
     116        Debug << "repair queue: " << mRepairQueue << endl; 
    111117} 
    112118 
     
    343349        PrepareViewSpaceSubdivision(sampleRays, objects, forcedViewSpace); 
    344350 
    345         //const bool repairQueue = false; 
    346         const bool repairQueue = true; 
    347 cout << "here55 " << mVspTree->mVspStats.maxDepth << " (" << mMinDepthForObjectSpaceSubdivion << ") " << endl; 
    348351        // start object space subdivision immediately? 
    349352        if (StartObjectSpaceSubdivision()) 
     
    379382                        // reevaluate candidates affected by the split for view space splits,  
    380383                        // this would be object space splits and other way round 
    381                         if (repairQueue) RepairQueue(); 
     384                        if (mRepairQueue) RepairQueue(); 
    382385                } 
    383386 
     
    386389                if (StartObjectSpaceSubdivision()) 
    387390                { 
     391                        mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType; 
     392 
     393                        cout << "starting object space subdivision at maximal view space subdivison depth " << mVspTree->mVspStats.maxDepth << " (" << mMinDepthForObjectSpaceSubdivion << ") " << endl; 
     394                        PrepareObjectSpaceSubdivision(sampleRays, objects); 
     395 
    388396                        cout << "reseting queue ... "; 
    389397                        ResetQueue(); 
    390398                        cout << "finished" << endl; 
    391  
    392                         cout << "starting object space subdivision at maximal view space subdivison depth " << mVspTree->mVspStats.maxDepth << " (" << mMinDepthForObjectSpaceSubdivion << ") " << endl; 
    393                                                  
    394                         mObjectSpaceSubdivisionType = savedObjectSpaceSubdivisionType; 
    395                         PrepareObjectSpaceSubdivision(sampleRays, objects); 
    396399                } 
    397400 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1313 r1314  
    292292        int mTermMaxLeaves; 
    293293        ofstream mSubdivisionStats; 
     294 
     295        bool mRepairQueue; 
    294296}; 
    295297 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r1293 r1314  
    6363                 OGRE_MESH_INSTANCE, 
    6464                 KD_INTERSECTABLE, 
    65                  BVH_INTERSECTABLE 
     65                 BVH_INTERSECTABLE, 
     66                 FACE_INTERSECTABLE 
    6667                }; 
    6768   
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdIntersectable.h

    r1233 r1314  
    1111class KdNode; 
    1212class BvhNode; 
     13struct Face; 
     14 
    1315 
    1416/** 
     
    5759        T *mItem; 
    5860}; 
     61 
    5962 
    6063template<typename T> 
     
    161164}; 
    162165 
     166class FaceIntersectable: public IntersectableWrapper<Face> 
     167{ 
     168public: 
     169        FaceIntersectable(Face *item): 
     170        IntersectableWrapper<Face>(item) {} 
     171 
     172        int Type() const 
     173        { 
     174                return Intersectable::FACE_INTERSECTABLE; 
     175        } 
     176}; 
     177 
     178 
    163179} 
    164180 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp

    r1292 r1314  
    1313#include "Environment.h" 
    1414#include "ResourceManager.h" 
    15  
     15#include "KdIntersectable.h" 
    1616 
    1717 
     
    9393 
    9494                        // correct face index (nust be relative to start of verices) 
    95                         (*vit) = distance(hashTable.begin(), hit); 
     95                        (*vit) = (int)distance(hashTable.begin(), hit); 
    9696                        //Debug << "new idx: " << (*vit) << endl; 
    9797                } 
     
    185185                                Face *face = LoadFace(str, vertices, hashTable); 
    186186                                if (!face) break; 
    187                                  
     187#if 1 
    188188                                faces.push_back(face); 
    189  
    190189                                if (faces.size() >= nMaxFaces) 
    191190                                { 
     
    197196                                         
    198197                                        if (parents)  
    199                                           { 
    200198                                                AssociateFacesWithInstance(mi, *parents); 
    201                                           } 
    202                                          
     199                                                                                 
    203200                                        // reset tables 
    204201                                        hashTable.clear(); 
    205202                                        faces.clear(); 
    206203                                } 
     204#else 
     205                                root->mGeometry.push_back(new FaceIntersectable(face)); 
     206                                hashTable.clear(); 
     207#endif 
    207208                                break; 
    208                         }      // end face 
     209                        }   // end face 
    209210                default: 
    210211                        break; 
    211212                } 
    212  
    213213        } 
    214214 
    215215        // there could be faces remaining 
    216         if (1 && !faces.empty()) 
     216        if (!faces.empty()) 
    217217        {        
    218218                Mesh *mesh = CreateMesh(faces, hashTable); 
     
    222222                 
    223223                if (parents)  
    224                 { 
    225224                        AssociateFacesWithInstance(mi, *parents); 
    226                 } 
    227  
     225                 
    228226                root->mGeometry.push_back(mi);   
    229227        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1313 r1314  
    973973        mLocalSubdivisionCandidates->clear(); 
    974974 
    975         int requestedSize = 2 * (int)(rays.size()); 
     975        const int requestedSize = 2 * (int)(rays.size()); 
    976976 
    977977        // creates a sorted split candidates array 
     
    992992        { 
    993993                const bool positive = (*rit).mRay->HasPosDir(axis); 
    994                                  
     994                const bool delayMinEvent = false; 
     995 
     996                // origin point 
    995997                pos = (*rit).ExtrapOrigin(axis); 
    996                  
    997                 mLocalSubdivisionCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax,  
    998                                                                         pos, (*rit).mRay)); 
    999  
     998                const int oType = positive ? SortableEntry::ERayMin : SortableEntry::ERayMax; 
     999 
     1000                if (delayMinEvent && oType == SortableEntry::ERayMin) 
     1001                        pos += mEpsilon; // for walls 
     1002 
     1003                mLocalSubdivisionCandidates->push_back(SortableEntry(oType, pos, (*rit).mRay)); 
     1004 
     1005                // termination point 
    10001006                pos = (*rit).ExtrapTermination(axis); 
    1001  
    1002                 mLocalSubdivisionCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin,  
    1003                                                                         pos, (*rit).mRay)); 
     1007                const int tType = positive ? SortableEntry::ERayMax : SortableEntry::ERayMin; 
     1008 
     1009                if (delayMinEvent && tType == SortableEntry::ERayMin) 
     1010                        pos += mEpsilon; // for walls 
     1011 
     1012                mLocalSubdivisionCandidates->push_back(SortableEntry(tType, pos, (*rit).mRay)); 
    10041013        } 
    10051014 
     
    12061215        vector<SortableEntry>::const_iterator ci, ci_end = mLocalSubdivisionCandidates->end(); 
    12071216 
     1217#ifdef _DEBUG 
     1218        const float volRatio = tData.mBoundingBox.GetVolume() / (sizeBox * mBoundingBox.GetVolume()); 
     1219        const int leaves = mVspStats.Leaves(); 
     1220        const bool printStats = ((axis == 0) && (leaves > 0) && (leaves < 90)); 
     1221         
     1222        ofstream sumStats; 
     1223        ofstream pvslStats; 
     1224        ofstream pvsrStats; 
     1225 
     1226        if (printStats) 
     1227        { 
     1228                char str[64];  
     1229                 
     1230                sprintf(str, "tmp/vsp_heur_sum-%04d.log", leaves); 
     1231                sumStats.open(str); 
     1232                sprintf(str, "tmp/vsp_heur_pvsl-%04d.log", leaves); 
     1233                pvslStats.open(str); 
     1234                sprintf(str, "tmp/vsp_heur_pvsr-%04d.log", leaves); 
     1235                pvsrStats.open(str); 
     1236        } 
     1237 
     1238#endif 
    12081239        for (ci = mLocalSubdivisionCandidates->begin(); ci != ci_end; ++ ci) 
    12091240        { 
     
    12241255                        sum = pvsl * ((*ci).value - minBox) + pvsr * (maxBox - (*ci).value); 
    12251256                         
     1257#ifdef _DEBUG 
     1258                        if (printStats) 
     1259                        { 
     1260                                sumStats 
     1261                                        << "#Position\n" << currentPos << endl 
     1262                                        << "#Sum\n" << sum * volRatio << endl 
     1263                                        << "#Pvs\n" << pvsl + pvsr << endl; 
     1264 
     1265                                pvslStats 
     1266                                        << "#Position\n" << currentPos << endl 
     1267                                        << "#Pvsl\n" << pvsl << endl; 
     1268 
     1269                                pvsrStats 
     1270                                        << "#Position\n" << currentPos << endl 
     1271                                        << "#Pvsr\n" << pvsr << endl; 
     1272                        } 
     1273#endif 
    12261274 
    12271275                        if (sum < minSum) 
     
    12601308        } 
    12611309         
    1262         const float volRatio = tData.mBoundingBox.GetVolume() / (sizeBox * mBoundingBox.GetVolume()); 
    1263  
     1310#ifdef _DEBUG 
    12641311        Debug << "\n§§§§ eval local cost §§§§" << endl 
    12651312                  << "back pvs: " << penaltyBack << " front pvs: " << penaltyFront << " total pvs: " << penaltyOld << endl  
     
    12671314                  << "old rc: " << oldRenderCost * volRatio << " new rc: " << newRenderCost * volRatio << endl 
    12681315                  << "render cost decrease: " << oldRenderCost * volRatio - newRenderCost * volRatio << endl; 
    1269  
     1316#endif 
    12701317        return ratio; 
    12711318} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h

    r1305 r1314  
    657657                } 
    658658                 
    659                 friend bool operator<(const SortableEntry &a, const SortableEntry &b) 
    660                 { 
    661                         return a.value < b.value; 
     659                friend inline bool operator<(const SortableEntry &a, const SortableEntry &b) 
     660                {       // prefer max event 
     661                        //if (EpsilonEqual(a.value, b.value, 0.0001f)) 
     662                        //      return (a.type == ERayMax); 
     663 
     664                        return (a.value < b.value); 
    662665                } 
    663666        }; 
Note: See TracChangeset for help on using the changeset viewer.