Ignore:
Timestamp:
05/02/07 17:28:26 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
13 edited

Legend:

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

    r2332 r2342  
    400400        ViewCell::NewMail(3); 
    401401 
     402        // mail view cells which can see front object 
    402403        ViewCellContainer::const_iterator fit, fit_end = frontViewCells.end(); 
    403404 
     
    408409        } 
    409410 
     411        // mail view cells which can see back or both objects 
    410412        ViewCellContainer::const_iterator bit, bit_end = backViewCells.end(); 
    411413 
     
    429431                int vcObj; 
    430432 
    431                 float oldVcTri = vc->GetPvsCost(); 
     433                float oldVcTri = vc->GetTrianglesInPvs(); 
    432434                int oldVcObj = vc->GetEntriesInPvs(); 
    433435 
    434                 // both objects in view cell 
     436                // both objects seen from view cell 
     437                // => no reduction, but an additional pvs entry 
    435438                if (vc->Mailed(2)) 
    436439                { 
     
    438441                        vcObj = oldVcObj + 1;    
    439442                } 
     443                // only back object seen from view cell  
     444                // => reduction in triangles 
    440445                else if (vc->Mailed(1)) 
    441446                { 
     
    443448                        vcObj = oldVcObj;    
    444449                } 
    445                 else // (vc->Mailed(0)) 
     450                else // front object 
    446451                { 
    447452                        vcTri = oldVcTri - totalTri + frontTri;  
     
    449454                } 
    450455 
    451                 vc->SetPvsCost(vcTri); 
     456                vc->SetTrianglesInPvs(vcTri); 
    452457                vc->SetEntriesInPvs(vcObj); 
    453458 
     
    567572        } 
    568573 
    569         // compute e.g., new render cost decrease after this split 
     574        // compute new stats for the view cells which see this object,  
     575        // e.g. new render cost decrease after the split 
    570576        UpdateViewCells(sc); 
    571577 
     
    870876                int vcObj; 
    871877 
    872                 float oldVcTri = vc->GetPvsCost(); 
     878                float oldVcTri = vc->GetTrianglesInPvs(); 
    873879                int oldVcObj = vc->GetEntriesInPvs(); 
    874880 
     
    22282234                                                                  const bool onlyUnmailedRays)// const 
    22292235{ 
     2236        // view cells not cached 
    22302237        if (obj->GetOrCreateViewCells()->empty()) 
    22312238        { 
    2232                 //cerr << "g";//CollectViewCells: view cells empty, view cells cache not working" << endl; 
    22332239                return CollectViewCellsFromRays(obj, viewCells, useMailBoxing, setCounter, onlyUnmailedRays); 
    22342240        } 
    2235  
    2236         mCollectTimer.Entry(); 
    2237  
    2238         ViewCellContainer *objViewCells = obj->GetOrCreateViewCells(); 
    22392241 
    22402242        /////////// 
    22412243        //-- use view cells cache 
    22422244 
    2243         // fastest way: just copy to the end 
    2244         //if (!useMailBoxing)   viewCells.insert(viewCells.end(), objViewCells->begin(), objViewCells->end()); 
     2245        mCollectTimer.Entry(); 
     2246 
     2247        ViewCellContainer *objViewCells = obj->GetOrCreateViewCells(); 
    22452248 
    22462249        // loop through view cells 
    2247         // matt: probably slow to insert  view cells one by one 
     2250        // matt: probably slow to insert view cells one by one 
    22482251        ViewCellContainer::const_iterator vit, vit_end = objViewCells->end(); 
    22492252 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r2332 r2342  
    559559                 
    560560                /// Repair split queue 
    561                 cout << "repairing queue ... " << endl; 
     561                cout << "repairing object space queue ... " << endl; 
    562562                RepairQueue(dirtyList, objectSpaceQueue, true); 
    563563                cout << "repaired " << (int)dirtyList.size() << " candidates" << endl; 
    564564 
    565565                dirtyList.clear(); 
     566 
     567                /// also repair some candidates from view space queue 
     568                /*cout << "repairing view space queue ... " << endl; 
     569                CollectRandomCandidates(dirtyList); 
     570                RepairQueue(dirtyList, viewSpaceQueue, true); 
     571                cout << "repaired " << (int)dirtyList.size() << " candidates" << endl; 
     572                dirtyList.clear();*/ 
    566573                //PrintTimings(false); 
    567574        } 
     
    743750        mVspTree->PrepareConstruction(tQueue, sampleRays, *viewSpaceRays); 
    744751 
    745         ///////// 
    746         //-- new stats 
    747  
    748752        if (0) 
    749753        { 
     754                ///////// 
     755                //-- new render cost 
     756 
    750757                mHierarchyStats.mTotalCost = mVspTree->mTotalCost; 
    751758                cout << "\nreseting cost for vsp construction, new total cost: " << mHierarchyStats.mTotalCost << endl; 
     
    22782285                { 
    22792286                        ComputePvs(vc->GetPvs(), triangles, entries); 
    2280                         vc->SetPvsCost(triangles); 
     2287                        vc->SetTrianglesInPvs(triangles); 
    22812288                } 
    22822289 
     
    25022509} 
    25032510 
    2504  
    2505 } 
     2511#ifdef USE_SSE 
     2512int HierarchyManager::CastLineSegment(RayPacket &packet) 
     2513{ 
     2514        return mVspTree->TraverseRayPacket(packet, true); 
     2515} 
     2516 
     2517#endif 
     2518 
     2519} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r2332 r2342  
    321321                                                ViewCellContainer &viewcells, 
    322322                                                const bool useMailboxing = true); 
    323          
     323 
     324#ifdef USE_SSE 
     325        int CastLineSegment(RayPacket &packet); 
     326#endif 
     327 
     328 
    324329protected: 
    325330 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2307 r2342  
    229229 
    230230 
    231 bool Preprocessor::ExportBinaryObj(const string filename, SceneGraphNode *root) 
     231bool Preprocessor::ExportBinaryObj(const string &filename, SceneGraphNode *root) 
    232232{ 
    233233        ogzstream samplesOut(filename.c_str()); 
     
    266266 
    267267 
    268 bool Preprocessor::ExportObj(const string filename, const ObjectContainer &objects) 
     268bool Preprocessor::ExportObj(const string &filename, const ObjectContainer &objects) 
    269269{ 
    270270        ofstream samplesOut(filename.c_str()); 
     
    320320} 
    321321 
    322 static string ReplaceSuffix(string filename, string a, string b) 
     322static string ReplaceSuffix(const string &filename, string a, string b) 
    323323{ 
    324324        string result = filename; 
     
    381381 
    382382bool 
    383 Preprocessor::LoadScene(const string filename) 
     383Preprocessor::LoadScene(const string &filename) 
    384384{ 
    385385    // use leaf nodes of the original spatial hierarchy as occludees 
     
    533533 
    534534bool 
    535 Preprocessor::ExportPreprocessedData(const string filename) 
     535Preprocessor::ExportPreprocessedData(const string &filename) 
    536536{ 
    537537        mViewCellsManager->ExportViewCells(filename, true, mObjects); 
     
    605605 
    606606bool 
    607 Preprocessor::Export( const string filename, 
     607Preprocessor::Export( const string &filename, 
    608608                                          const bool scene, 
    609609                                          const bool kdtree 
     
    813813 
    814814 
    815 bool Preprocessor::LoadKdTree(const string filename) 
     815bool Preprocessor::LoadKdTree(const string &filename) 
    816816{ 
    817817        mKdTree = new KdTree(); 
     
    821821 
    822822 
    823 bool Preprocessor::ExportKdTree(const string filename) 
     823bool Preprocessor::ExportKdTree(const string &filename) 
    824824{ 
    825825        return mKdTree->ExportBinTree(filename.c_str()); 
     
    10341034 
    10351035 
    1036 bool Preprocessor::LoadInternKdTree( const string internKdTree) 
    1037 { 
    1038   bool mUseKdTree = true; 
    1039    
    1040   if (!mUseKdTree) { 
    1041         // create just a dummy KdTree 
    1042         mKdTree = new KdTree; 
     1036bool Preprocessor::LoadInternKdTree(const string &internKdTree) 
     1037{ 
     1038        bool mUseKdTree = true; 
     1039 
     1040        if (!mUseKdTree) { 
     1041                // create just a dummy KdTree 
     1042                mKdTree = new KdTree; 
     1043                return true; 
     1044        } 
     1045 
     1046        // always try to load the kd tree 
     1047        cout << "loading kd tree file " << internKdTree << " ... " << endl; 
     1048 
     1049        if (!LoadKdTree(internKdTree)) { 
     1050                cout << "error loading kd tree with filename "  
     1051                        << internKdTree << ", rebuilding it instead ... " << endl; 
     1052                // build new kd tree from scene geometry 
     1053                BuildKdTree(); 
     1054 
     1055                // export kd tree? 
     1056                const long startTime = GetTime(); 
     1057                cout << "exporting kd tree ... "; 
     1058 
     1059                if (!ExportKdTree(internKdTree)) 
     1060                { 
     1061                        cout << " error exporting kd tree with filename "  
     1062                                << internKdTree << endl; 
     1063                } 
     1064                else 
     1065                { 
     1066                        cout << "finished in "  
     1067                                << TimeDiff(startTime, GetTime()) * 1e-3  
     1068                                << " secs" << endl; 
     1069                } 
     1070        } 
     1071 
     1072        KdTreeStatistics(cout); 
     1073        cout << mKdTree->GetBox() << endl; 
     1074 
    10431075        return true; 
    1044   } 
    1045    
    1046   // always try to load the kd tree 
    1047   cout << "loading kd tree file " << internKdTree << " ... " << endl; 
    1048    
    1049   if (!LoadKdTree(internKdTree)) { 
    1050         cout << "error loading kd tree with filename "  
    1051                  << internKdTree << ", rebuilding it instead ... " << endl; 
    1052         // build new kd tree from scene geometry 
    1053         BuildKdTree(); 
    1054          
    1055         // export kd tree? 
    1056         const long startTime = GetTime(); 
    1057         cout << "exporting kd tree ... "; 
    1058          
    1059         if (!ExportKdTree(internKdTree)) 
    1060           { 
    1061                 cout << " error exporting kd tree with filename "  
    1062                          << internKdTree << endl; 
    1063           } 
    1064         else 
    1065           { 
    1066                 cout << "finished in "  
    1067                          << TimeDiff(startTime, GetTime()) * 1e-3  
    1068                          << " secs" << endl; 
    1069           } 
    1070   } 
    1071    
    1072   KdTreeStatistics(cout); 
    1073   cout << mKdTree->GetBox() << endl; 
    1074    
    1075   return true; 
    1076 } 
    1077  
    1078  
    1079 bool Preprocessor::InitRayCast(const string externKdTree,  
    1080                                                            const string internKdTree) 
     1076} 
     1077 
     1078 
     1079bool Preprocessor::InitRayCast(const string &externKdTree,  
     1080                                                           const string &internKdTree) 
    10811081{ 
    10821082        // always try to load the kd tree 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r2187 r2342  
    99#include "SimpleRay.h" 
    1010 
     11 
    1112namespace GtpVisibilityPreprocessor { 
    12   class PreprocessorThread; 
    13    
     13 
     14class PreprocessorThread;   
    1415class RenderSimulator; 
    1516class SceneGraph; 
     
    6061                @return true on success 
    6162        */ 
    62         virtual bool LoadScene(const string filename); 
     63        virtual bool LoadScene(const string &filename); 
    6364 
    6465        /** Export all preprocessed data in a XML format understandable by the 
     
    6768                @return true on successful export 
    6869        */ 
    69         virtual bool ExportPreprocessedData(const string filename); 
     70        virtual bool ExportPreprocessedData(const string &filename); 
    7071 
    7172        /** Build the KdTree of currently loaded occluders/occludees/viewcells. The construction 
     
    102103        /** Export preprocessor data. 
    103104        */ 
    104         bool Export(const string filename, const bool scene, const bool kdtree);   
     105        bool Export(const string &filename, const bool scene, const bool kdtree);   
    105106 
    106107        virtual void KdTreeStatistics(ostream &s); 
     
    119120        bool ExportSamples(const VssRayContainer &samples) const; 
    120121 
    121         bool LoadKdTree(const string filename); 
    122         bool ExportKdTree(const string filename); 
     122        bool LoadKdTree(const string &filename); 
     123        bool ExportKdTree(const string &filename); 
    123124 
    124125        virtual bool 
     
    150151                                                  const bool pruneInvalidRays = true); 
    151152 
    152   virtual void 
    153   CastRaysWithHwGlobalLines( 
    154                                                         SimpleRayContainer &rays, 
    155                                                         VssRayContainer &vssRays, 
    156                                                         const bool castDoubleRays, 
    157                                                         const bool pruneInvalidRays 
    158                                                         ); 
     153        virtual void 
     154                CastRaysWithHwGlobalLines( 
     155                SimpleRayContainer &rays, 
     156                VssRayContainer &vssRays, 
     157                const bool castDoubleRays, 
     158                const bool pruneInvalidRays 
     159                ); 
    159160 
    160161        /** Compute pixel error of the current PVS solution by sampling given number of viewpoints. 
     
    168169        GlRendererBuffer *GetRenderer(); 
    169170 
    170         bool InitRayCast(const string externKdTree, const string internKdTree); 
    171  
    172         bool LoadInternKdTree(const string internKdTree); 
    173  
    174         bool ExportObj(const string filename, const ObjectContainer &objects); 
     171        bool InitRayCast(const string &externKdTree, const string &internKdTree); 
     172 
     173        bool LoadInternKdTree(const string &internKdTree); 
     174 
     175        bool ExportObj(const string &filename, const ObjectContainer &objects); 
    175176 
    176177        Intersectable *GetParentObject(const int index) const; 
     
    192193 
    193194        static bool LoadObjects(const string &filename, 
    194                                                         ObjectContainer &pvsObjects,  
     195                                    ObjectContainer &pvsObjects,  
    195196                                                        const ObjectContainer &preprocessorObject); 
    196197 
    197         //////////////////////////////////////////////// 
     198 
     199        ///////////////////////// 
    198200 
    199201        /// scene graph loaded from file 
     
    223225        bool mUseGlRenderer; 
    224226        bool mUseGlDebugger; 
    225          
     227 
    226228        bool mUseHwGlobalLines; 
    227229        bool mLoadViewCells; 
     
    242244 
    243245        int mPass; 
    244   
     246 
    245247        bool mStopComputation; 
    246    
     248 
    247249        bool mExportObj; 
    248250 
     
    254256 
    255257        GlRendererBuffer *renderer; 
    256    
     258 
    257259        int mTotalSamples; 
    258260        int mTotalTime; 
     
    260262        int mSamplesPerEvaluation; 
    261263 
    262         RayCaster *mRayCaster; 
     264        RayCaster *mRayCaster; 
    263265 
    264266 
     
    266268 
    267269        bool LoadBinaryObj(const std::string &filename, 
    268                                            SceneGraphNode *root, 
     270                       SceneGraphNode *root, 
    269271                                           std::vector<FaceParentInfo> *parents); 
    270272 
    271         bool ExportBinaryObj(const std::string filename, SceneGraphNode *root); 
     273        bool ExportBinaryObj(const std::string &filename, SceneGraphNode *root); 
    272274 
    273275        void SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction) const; 
     
    276278 
    277279        virtual void EvalViewCellHistogram(); 
     280 
    278281 
    279282        ///////////////////////// 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj

    r2332 r2342  
    106106                                Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
    107107                </Configuration> 
    108          
    109108                <Configuration 
    110109                        Name="Release_Internal|Win32" 
     
    454453                        </File> 
    455454                        <File 
    456                                 RelativePath=".\HashPvs2.h"> 
    457                         </File> 
    458                         <File 
    459455                                RelativePath=".\HierarchyManager.cpp"> 
    460456                        </File> 
     
    637633                                                Outputs=""/> 
    638634                                </FileConfiguration> 
    639                          
    640635                                <FileConfiguration 
    641636                                        Name="Release_Internal|Win32"> 
     
    690685                                                Outputs=""/> 
    691686                                </FileConfiguration> 
    692                                  
    693687                                <FileConfiguration 
    694688                                        Name="Release_Internal|Win32"> 
     
    11091103                        </File> 
    11101104                        <File 
     1105                                RelativePath=".\sparsehash\src\windows\hash_fun.h"> 
     1106                        </File> 
     1107                        <File 
    11111108                                RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h"> 
    1112                         </File> 
    1113                         <File 
    1114                                 RelativePath=".\sparsehash\src\windows\hash_fun.h"> 
    11151109                        </File> 
    11161110                        <File 
  • GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj

    r2332 r2342  
    229229                                LinkIncremental="1" 
    230230                                AdditionalLibraryDirectories="..\src\GL;..\lib\release;..\..\Preprocessing\lib\release;..\..\..\..\..\..\NonGTP\Boost\lib;..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\NonGTP\Devil\lib;..\MultiLevelRayTracing\RTScene\Release;..\MultiLevelRayTracing\RTWorld\Release" 
    231                                 GenerateDebugInformation="TRUE" 
     231                                GenerateDebugInformation="FALSE" 
    232232                                SubSystem="1" 
    233233                                OptimizeReferences="2" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r2332 r2342  
    3434                                           myless<vector<ViewCell *>::value_type> > TraversalQueue; 
    3535 
    36   int ViewCell::sMailId = 10000;//2147483647; 
    37   int ViewCell::sReservedMailboxes = 1; 
    38  
     36int ViewCell::sMailId = 10000;//2147483647; 
     37int ViewCell::sReservedMailboxes = 1; 
    3938 
    4039float MergeCandidate::sRenderCostWeight = 0; 
     
    13051304        { 
    13061305                const float penalty =  
    1307                         EvalPvsPenalty(GetPvsCost(vc), lower, upper); 
     1306                        EvalPvsPenalty(GetTrianglesInPvs(vc), lower, upper); 
    13081307 
    13091308                return (mAvgRenderCost - penalty) * (mAvgRenderCost - penalty) /  
     
    13231322        if (1) 
    13241323        { 
    1325                 const float penalty = EvalPvsPenalty(GetPvsCost(vc), lower, upper); 
     1324                const float penalty = EvalPvsPenalty(GetTrianglesInPvs(vc), lower, upper); 
    13261325                return fabs(mAvgRenderCost - penalty) / (float)mNumActiveViewCells; 
    13271326        } 
     
    15151514        const float vol = box.GetVolume(); 
    15161515 
    1517         const float rootPvs = GetPvsCost(mRoot); 
     1516        const float rootPvs = GetTrianglesInPvs(mRoot); 
    15181517        const int rootEntries = GetPvsEntries(mRoot); 
    15191518         
     
    15501549                        ViewCellInterior *interior = static_cast<ViewCellInterior *>(vc); 
    15511550 
    1552                         const float parentCost = GetPvsCost(interior); 
     1551                        const float parentCost = GetTrianglesInPvs(interior); 
    15531552                        const int parentPvsEntries = GetPvsEntries(interior); 
    15541553            const float parentExpCost = (float)parentCost * interior->GetVolume(); 
     
    15661565                                ViewCell *vc = *it; 
    15671566 
    1568                                 const float pvsCost = GetPvsCost(vc); 
     1567                                const float pvsCost = GetTrianglesInPvs(vc); 
    15691568                                const int pvsEntries = GetPvsEntries(vc); 
    15701569 
     
    19531952 
    19541953 
    1955 float ViewCellsTree::GetPvsCost(ViewCell *vc) const 
     1954float ViewCellsTree::GetTrianglesInPvs(ViewCell *vc) const 
    19561955{ 
    19571956        float pvsCost = 0; 
     
    21592158 
    21602159        const float vol = mViewCellsManager->GetViewSpaceBox().GetVolume(); 
    2161         const float rootPvs = GetPvsCost(mRoot); 
     2160        const float rootPvs = GetTrianglesInPvs(mRoot); 
    21622161         
    21632162        float totalRenderCost; 
     
    21822181                        ViewCellInterior *interior = static_cast<ViewCellInterior *>(vc); 
    21832182 
    2184                         const float parentCost = GetPvsCost(interior); 
     2183                        const float parentCost = GetTrianglesInPvs(interior); 
    21852184                        const float parentExpCost = parentCost * interior->GetVolume(); 
    21862185 
     
    21962195                                ViewCell *vc = *it; 
    21972196 
    2198                                 const float pvsCost = GetPvsCost(vc); 
     2197                                const float pvsCost = GetTrianglesInPvs(vc); 
    21992198                                 
    22002199                                childExpCost += (float) pvsCost * vc->GetVolume(); 
     
    22482247                        ViewCellInterior *interior = static_cast<ViewCellInterior *>(vc); 
    22492248 
    2250                         const float parentPvsCost = GetPvsCost(interior); 
     2249                        const float parentPvsCost = GetTrianglesInPvs(interior); 
    22512250                        const int parentPvsEntries = GetPvsEntries(interior); 
    22522251            const float parentExpCost = (float)parentPvsCost * interior->GetVolume(); 
     
    22882287        ++ vcStat.viewCells; 
    22892288                 
    2290         const float pvsCost = GetPvsCost(vc); 
     2289        const float pvsCost = GetTrianglesInPvs(vc); 
    22912290 
    22922291        vcStat.pvsCost += pvsCost; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r2332 r2342  
    287287        } 
    288288 
    289         void SetPvsCost(const float c) { 
     289        void SetTrianglesInPvs(const float c) { 
    290290                mPvsCost = c; 
    291291        } 
     
    295295        } 
    296296 
    297         float GetPvsCost() const { 
     297        float GetTrianglesInPvs() const { 
    298298                return mPvsCost; 
    299299        } 
     
    508508        /** Returns pvs size (i.e. the render cost of the stored objects) 
    509509        */ 
    510         float GetPvsCost(ViewCell *vc) const; 
     510        float GetTrianglesInPvs(ViewCell *vc) const; 
    511511   
    512512        /** Returns number of entries associated with this view cell.  
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2332 r2342  
    169169        Environment::GetSingleton()->GetFloatValue("ViewCells.objectWeight", mObjectWeight); 
    170170 
    171         // mix of sampling strategies 
    172         if (1) 
     171        // choose mix of sampling strategies 
     172        if (0) 
    173173        { 
    174174                mStrategies.push_back(SamplingStrategy::SPATIAL_BOX_BASED_DISTRIBUTION); 
     
    13171317                        (*it)->UpdatePvsCost(); 
    13181318                else 
    1319                         (*it)->SetPvsCost((float)(*it)->GetFilteredPvsSize()); 
     1319                        (*it)->SetTrianglesInPvs((float)(*it)->GetFilteredPvsSize()); 
    13201320        } 
    13211321 
     
    13251325        sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 
    13261326 
    1327         maxPvs = viewCells.back()->GetPvsCost(); 
     1327        maxPvs = viewCells.back()->GetTrianglesInPvs(); 
    13281328        minVal = 0; 
    13291329 
     
    13691369 
    13701370                while ((i < (int)viewCells.size()) &&  
    1371                            (viewCells[i]->GetPvsCost() < currentPvs)) 
     1371                           (viewCells[i]->GetTrianglesInPvs() < currentPvs)) 
    13721372                { 
    13731373                        volDif += viewCells[i]->GetVolume(); 
     
    13801380                 
    13811381                //              if (0 && (i < (int)viewCells.size())) 
    1382                 //                Debug << "new pvs cost increase: " << mViewCellsTree->GetPvsCost(viewCells[i])  
     1382                //                Debug << "new pvs cost increase: " << mViewCellsTree->GetTrianglesInPvs(viewCells[i])  
    13831383                //                              << " " << currentPvs << endl; 
    13841384                 
     
    14121412        sort(viewCells.begin(), viewCells.end(), ViewCell::SmallerPvs); 
    14131413 
    1414         maxPvs = viewCells.back()->GetPvsCost(); 
     1414        maxPvs = viewCells.back()->GetTrianglesInPvs(); 
    14151415        minVal = 0; 
    14161416 
     
    14561456 
    14571457                while ((i < (int)viewCells.size()) &&  
    1458                            (viewCells[i]->GetPvsCost() < currentPvs)) 
     1458                           (viewCells[i]->GetTrianglesInPvs() < currentPvs)) 
    14591459                { 
    14601460                        volDif += viewCells[i]->GetVolume(); 
     
    14671467                 
    14681468                //              if (0 && (i < (int)viewCells.size())) 
    1469                 //                Debug << "new pvs cost increase: " << mViewCellsTree->GetPvsCost(viewCells[i])  
     1469                //                Debug << "new pvs cost increase: " << mViewCellsTree->GetTrianglesInPvs(viewCells[i])  
    14701470                //                              << " " << currentPvs << endl; 
    14711471                 
     
    24182418          ViewCell *viewcell = *it; 
    24192419          if (viewcell->GetValid()) { 
    2420                   const float pvsCost = mViewCellsTree->GetPvsCost(viewcell); 
     2420                  const float pvsCost = mViewCellsTree->GetTrianglesInPvs(viewcell); 
    24212421                  const float renderCost = pvsCost * viewcell->GetVolume() / vol; 
    24222422 
     
    29082908float ViewCellsManager::GetRendercost(ViewCell *viewCell) const 
    29092909{ 
    2910         return (float)mViewCellsTree->GetPvsCost(viewCell); 
     2910        return (float)mViewCellsTree->GetTrianglesInPvs(viewCell); 
    29112911} 
    29122912 
     
    36033603                        if (mCurrentViewCellsStats.maxPvs) 
    36043604                        { 
    3605                                 importance = (float)mViewCellsTree->GetPvsCost(vc) / 700; 
     3605                                importance = (float)mViewCellsTree->GetTrianglesInPvs(vc) / 700; 
    36063606                                                         //(float)mCurrentViewCellsStats.maxPvs; 
    36073607                        } 
     
    41054105                Exporter *exporter = Exporter::GetExporter(s); 
    41064106                 
    4107                 cout << "view cell " << idx << ": pvs cost=" << (int)mViewCellsTree->GetPvsCost(vc) << endl; 
     4107                cout << "view cell " << idx << ": pvs cost=" << (int)mViewCellsTree->GetTrianglesInPvs(vc) << endl; 
    41084108 
    41094109                if (exportRays) 
     
    54305430                Exporter *exporter = Exporter::GetExporter(s); 
    54315431                 
    5432                 const float pvsCost = mViewCellsTree->GetPvsCost(vc); 
     5432                const float pvsCost = mViewCellsTree->GetTrianglesInPvs(vc); 
    54335433                cout << "view cell " << vc->GetId() << ": pvs cost=" << pvsCost << endl; 
    54345434 
     
    64826482                Exporter *exporter = Exporter::GetExporter(s); 
    64836483                 
    6484                 cout << "view cell " << vc->GetId() << ": pvs cost=" << mViewCellsTree->GetPvsCost(vc) << endl; 
     6484                cout << "view cell " << vc->GetId() << ": pvs cost=" << mViewCellsTree->GetTrianglesInPvs(vc) << endl; 
    64856485 
    64866486                if (exportPvs) 
     
    70287028                        if (tmpRays.size() == 4) 
    70297029                        { 
     7030                                // cast packets of 4 rays 
    70307031                                RayPacket packet(tmpRays); 
    7031  
    70327032                                mHierarchyManager->CastLineSegment(packet); 
    70337033 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r2332 r2342  
    568568        else 
    569569        { 
    570                 // todo: set correct scalars 
    571                 viewCell->SetPvsCost(renderCost); 
     570                viewCell->SetTrianglesInPvs(renderCost); 
    572571                viewCell->SetEntriesInPvs(pvs); 
     572                 
    573573                //cout << "create view cell with tri=" << (int)renderCost << " pvs=" << pvs << endl;  
    574574        } 
     
    753753        RayInfoContainer::const_iterator rit, rit_end = splitCandidate.mParentData.mRays->end(); 
    754754 
    755         float frontRenderCost = 0, backRenderCost = 0, totalRenderCost = 0; 
    756755        float frontTriangles = 0, backTriangles = 0, totalTriangles = 0; 
    757         int  frontObjects = 0, backObjects = 0, totalObjects = 0; 
     756        int frontObjects = 0, backObjects = 0, totalObjects = 0; 
    758757 
    759758        Intersectable::NewMail(3); 
     
    803802        } 
    804803 
    805         totalRenderCost = mViewCellsManager->ComputeRenderCost((int)totalTriangles, totalObjects); 
    806         backRenderCost = mViewCellsManager->ComputeRenderCost((int)backTriangles, backObjects); 
    807         frontRenderCost = mViewCellsManager->ComputeRenderCost((int)frontTriangles, frontObjects); 
    808  
    809          
     804        const float totalRenderCost = mViewCellsManager->ComputeRenderCost((int)totalTriangles, totalObjects); 
     805        const float backRenderCost = mViewCellsManager->ComputeRenderCost((int)backTriangles, backObjects); 
     806        const float frontRenderCost = mViewCellsManager->ComputeRenderCost((int)frontTriangles, frontObjects); 
     807         
     808 
    810809        ///////////// 
    811810        // avg ray contri 
     
    843842        // take render cost of node into account  
    844843        // otherwise danger of being stuck in a local minimum! 
    845         const float factor = mRenderCostDecreaseWeight; 
    846  
    847         float priority = factor * renderCostDecr + (1.0f - factor) * oldRenderCost; 
     844        float priority = mRenderCostDecreaseWeight * renderCostDecr + (1.0f - mRenderCostDecreaseWeight) * oldRenderCost; 
    848845 
    849846        if (mHierarchyManager->mConsiderMemory) 
     
    854851        splitCandidate.SetPriority(priority); 
    855852 
    856         //cout << "vsp render cost decrease=" << renderCostDecr<<endl; 
     853        //cout << "vsp render cost decrease=" << renderCostDecr << endl; 
    857854        mEvalTimer.Exit(); 
    858855} 
     
    883880        splitCandidate.mBackPvs = (float)bPvsSize; 
    884881 
    885         if (0) 
    886         cout << "vsp pvs" 
    887                  << " avg ray contri: " << splitCandidate.GetAvgRayContribution() << " ratio: " << oldPvsRatio  
    888                  << " parent: " << correctedOldPvs << " " << " old vol: " << oldPvsSize 
    889                  << " frontpvs: " << fPvsSize << " corr. " << splitCandidate.mCorrectedFrontPvs  
    890                  << " backpvs: " << bPvsSize << " corr. " << splitCandidate.mCorrectedBackPvs << endl; 
    891  
    892  
     882#if TODO 
    893883        return (int)(splitCandidate.mCorrectedFrontPvs + splitCandidate.mCorrectedBackPvs - correctedOldPvs); 
     884#else 
     885        return fPvsSize + bPvsSize - oldPvsSize; 
     886#endif 
    894887} 
    895888 
     
    16331626float VspTree::EvalRenderCostDecrease(VspSubdivisionCandidate &sc, 
    16341627                                                                          float &normalizedOldRenderCost, 
    1635                                                                           const float totalPvs, 
    1636                                                                           const float pvsFront, 
    1637                                                                           const float pvsBack) const 
     1628                                                                          const float totalRenderCost, 
     1629                                                                          const float frontRenderCost, 
     1630                                                                          const float backRenderCost) const 
    16381631{ 
    16391632        const float viewSpaceVol = mBoundingBox.GetVolume(); 
     
    16431636        const float avgRaysPerObject = sc.GetAvgRaysPerObject(); 
    16441637 
    1645         ///////////////////////// 
    1646         // mark objects in the front / back / both using mailboxing 
    1647         // then count pvs sizes 
    1648  
    1649         Intersectable::NewMail(3); 
    1650         KdLeaf::NewMail(3); 
    1651      
     1638 
    16521639        AxisAlignedBox3 frontBox; 
    16531640        AxisAlignedBox3 backBox; 
     
    16671654        //-- evaluate render cost heuristics 
    16681655 
    1669         const float oldRenderCostRatio = (tData.mRenderCost > 0)? (totalPvs / tData.mRenderCost) : 1; 
     1656        // ratio of how render cost changed since last evaluation 
     1657        const float oldRenderCostRatio = (tData.mRenderCost > 0)? (totalRenderCost / tData.mRenderCost) : 1; 
    16701658        const float penaltyOld = tData.mCorrectedRenderCost * oldRenderCostRatio; 
    16711659 
    1672         sc.mCorrectedFrontRenderCost = mHierarchyManager->EvalCorrectedPvs(pvsFront, penaltyOld, avgRaysPerObject); 
    1673         sc.mCorrectedBackRenderCost = mHierarchyManager->EvalCorrectedPvs(pvsBack, penaltyOld, avgRaysPerObject); 
    1674  
    1675         sc.mFrontRenderCost = pvsFront; 
    1676         sc.mBackRenderCost = pvsBack; 
    1677  
    1678         const float oldRenderCost = pOverall * penaltyOld; 
     1660        sc.mCorrectedFrontRenderCost = mHierarchyManager->EvalCorrectedPvs(frontRenderCost, penaltyOld, avgRaysPerObject); 
     1661        sc.mCorrectedBackRenderCost = mHierarchyManager->EvalCorrectedPvs(backRenderCost, penaltyOld, avgRaysPerObject); 
     1662 
     1663        sc.mFrontRenderCost = frontRenderCost; 
     1664        sc.mBackRenderCost = backRenderCost; 
     1665 
     1666#if TODO // undersampling evalution does not work yet 
     1667 
     1668        const float oldRenderCost = penaltyOld * pOverall; 
    16791669        const float newRenderCost = sc.mCorrectedFrontRenderCost * pFront +  
    16801670                                                                sc.mCorrectedBackRenderCost * pBack; 
    16811671 
    1682         // we also return the old render cost 
     1672#else 
     1673 
     1674        const float oldRenderCost = totalRenderCost * pOverall; 
     1675        const float newRenderCost = frontRenderCost * pFront + backRenderCost * pBack; 
     1676 
     1677#endif 
     1678 
     1679        // the normalized old render cost is needed for the priority 
    16831680        normalizedOldRenderCost = oldRenderCost / viewSpaceVol; 
    16841681 
     
    32553252    leaf->SetViewCell(viewCell); 
    32563253 
    3257         viewCell->SetPvsCost((float)objects.size()); 
     3254        viewCell->SetTrianglesInPvs((float)objects.size()); 
    32583255        viewCell->SetEntriesInPvs(1); 
    32593256 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h

    r2332 r2342  
    1414#include "Timer/PerfTimer.h" 
    1515 
     16 
    1617#ifdef USE_SSE 
    1718#include <xmmintrin.h> 
    1819#endif 
    19  
    2020 
    2121 
     
    797797        float EvalRenderCostDecrease(VspSubdivisionCandidate &splitData,  
    798798                                                                 float &normalizedOldRenderCost, 
    799                                                                  const float totalPvs, 
    800                                                                  const float pvsFront, 
    801                                                                  const float pvsBack) const; 
     799                                                                 const float totalRenderCost, 
     800                                                                 const float frontRenderCost, 
     801                                                                 const float backRenderCost) const; 
    802802 
    803803        /** Collects view cells in the subtree under root. 
     
    11131113        int CompressObjects(VspLeaf *leaf); 
    11141114 
     1115 
    11151116#ifdef USE_SSE 
    1116  
    1117         struct RayPacket 
    1118         { 
    1119                 union { float mOriginX[4]; __m128 mOriginX4; }; 
    1120                 union { float mOriginY[4]; __m128 mOriginY4; }; 
    1121                 union { float mOriginZ[4]; __m128 mOriginZ4; }; 
    1122  
    1123                 union { float mTerminationX[4]; __m128 mTerminationX4; }; 
    1124                 union { float mTerminationY[4]; __m128 mTerminationY4; }; 
    1125                 union { float mTerminationZ[4]; __m128 mTerminationZ4; }; 
    1126  
    1127                 ViewCellContainer mViewCells[4]; 
    1128         }; 
    1129  
    11301117        struct PacketTraversalData 
    11311118        { 
     
    11411128                PacketTraversalData () {} 
    11421129                PacketTraversalData (VspNode *n,  
    1143                                                          const __m128 &px, const __m128 &py, const __m128 &pz,  
    1144                                                          const __m128 &maxt, 
    1145                                                          const __m128 &mask): 
     1130                        const __m128 &px, const __m128 &py, const __m128 &pz,  
     1131                        const __m128 &maxt, 
     1132                        const __m128 &mask): 
    11461133                mNode(n),  
    1147                 mExitPointX4(px), mExitPointY4(py), mExitPointZ4(pz), 
    1148                 mMaxT4(maxt), 
    1149                 mMask4(mask) 
     1134                        mExitPointX4(px), mExitPointY4(py), mExitPointZ4(pz), 
     1135                        mMaxT4(maxt), 
     1136                        mMask4(mask) 
    11501137                {} 
    11511138        }; 
    11521139 
    1153          
    1154         int TraverseRayPacket(RayPacket &rp, 
    1155                                                   const bool useMailboxing); 
     1140 
     1141        int TraverseRayPacket(RayPacket &rp, const bool useMailboxing); 
    11561142 
    11571143#endif 
     1144 
    11581145 
    11591146protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.h

    r2234 r2342  
    77#include "Containers.h" 
    88 
    9 // 
     9#ifdef USE_SSE 
     10#include <xmmintrin.h> 
     11#endif 
    1012 
    1113 
     
    1921#define ABS_CONTRIBUTION_WEIGHT 0.0f 
    2022#define VSS_STORE_VIEWCELLS 1 
    21    
     23 
     24#ifdef USE_SSE 
     25 
     26struct RayPacket 
     27{ 
     28        union { float mOriginX[4]; __m128 mOriginX4; }; 
     29        union { float mOriginY[4]; __m128 mOriginY4; }; 
     30        union { float mOriginZ[4]; __m128 mOriginZ4; }; 
     31 
     32        union { float mTerminationX[4]; __m128 mTerminationX4; }; 
     33        union { float mTerminationY[4]; __m128 mTerminationY4; }; 
     34        union { float mTerminationZ[4]; __m128 mTerminationZ4; }; 
     35 
     36        ViewCellContainer mViewCells[4]; 
     37}; 
     38 
     39 
     40#endif 
     41 
     42 
    2243class VssRay { 
    2344public: 
Note: See TracChangeset for help on using the changeset viewer.