Changeset 1159


Ignore:
Timestamp:
07/26/06 16:02:21 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj

    r1002 r1159  
    109109                                LinkIncremental="1" 
    110110                                SuppressStartupBanner="TRUE" 
    111                                 AdditionalLibraryDirectories=""$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)";"$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib";"..\..\GtpVisibility\lib\$(ConfigurationName)";"..\..\lib\$(ConfigurationName)";"..\lib\$(ConfigurationName)";"$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)";..\..\..\..\..\..\..\NonGTP\Zlib\lib;"..\..\..\Preprocessing\lib\$(ConfigurationName)";..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;"$(QTDIR)\lib";..\..\..\Preprocessing\src\GL;"$(CG_LIB_PATH)"" 
     111                                AdditionalLibraryDirectories=""$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)";"$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib";"..\..\GtpVisibility\lib\$(ConfigurationName)";"..\..\lib\$(ConfigurationName)";"..\lib\$(ConfigurationName)";"$(OGRE_PATH)\Dependencies\lib\$(ConfigurationName)";"..\..\..\Preprocessing\lib\$(ConfigurationName)";..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;"$(QTDIR)\lib";..\..\..\Preprocessing\src\GL;"$(CG_LIB_PATH)";..\..\..\..\..\..\..\NonGTP\Zlib\lib" 
    112112                                ModuleDefinitionFile="..\misc\OgreVisibilitySceneManager.def" 
    113113                                GenerateDebugInformation="TRUE" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1149 r1159  
    14941494                "0"); 
    14951495 
     1496        RegisterOption("ViewCells.storeKdPvs", 
     1497                optBool,  
     1498                "view_cells_store_kd_pvs=",  
     1499                "false"); 
     1500         
    14961501 
    14971502        /************************************************************************************/ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/PreprocessorThread.cpp

    r1154 r1159  
    1 //#include <QApplication> 
    21#include "PreprocessorThread.h" 
    32 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp

    r1112 r1159  
    8282        VssRay vssRay(ray); 
    8383 
    84         mViewCellsManager->ComputeSampleContributions(vssRay, true, false); 
     84        mViewCellsManager->ComputeSampleContribution(vssRay, true, false); 
    8585         
    8686        return vssRay.mPvsContribution; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1155 r1159  
    2020#include "KdIntersectable.h" 
    2121 
     22// should not count origin object for sampling because it disturbs heuristics 
     23#define COUNT_ORIGIN_OBJECTS 0 
    2224 
    2325namespace GtpVisibilityPreprocessor { 
     
    103105        Environment::GetSingleton()->GetBoolValue("ViewCells.exportPvs", mExportPvs); 
    104106         
     107        Environment::GetSingleton()->GetBoolValue("ViewCells.storeKdPvs", mStoreKdPvs); 
     108 
    105109 
    106110        char buf[100]; 
     
    217221        Debug << "export pvs for view cells: " << mExportPvs << endl; 
    218222         
    219          
     223        Debug << "store kd pvs: " << mStoreKdPvs << endl; 
     224 
    220225        Debug << endl; 
    221226} 
     
    13761381  for (it = rays.begin(); it != it_end; ++ it)  
    13771382  { 
    1378           sum += ComputeSampleContributions(*(*it), addRays, storeViewCells); 
     1383          sum += ComputeSampleContribution(*(*it), addRays, storeViewCells); 
    13791384  } 
    13801385 
     
    18421847 
    18431848 
    1844 float ViewCellsManager::ComputeSampleContributions(VssRay &ray, 
    1845                                                                                                    const bool addRays, 
    1846                                                                                                    const bool storeViewCells) 
     1849float ViewCellsManager::ComputeSampleContribution(VssRay &ray, 
     1850                                                                                                  const bool addRays, 
     1851                                                                                                  const bool storeViewCells) 
    18471852{ 
    18481853        ViewCellContainer viewcells; 
     
    18931898                        // made in one direction!!! 
    18941899                        // the other contributions of this sample will be counted for the oposite ray! 
    1895 #if 0 
     1900#if COUNT_ORIGIN_OBJECTS 
    18961901                        if (ray.mOriginObject &&  
    18971902                                viewcell->GetPvs().GetSampleContribution(ray.mOriginObject, 
     
    19171922                                // if ray not outside of view space 
    19181923 
    1919                                 // add kd cell 
     1924                                // add new object to the pvs 
    19201925                                if (ray.mTerminationObject) 
    19211926                                { 
    1922                                         if (!mStoreKdPvs) 
    1923                                         { 
    1924                                                 viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 
    1925                                         } 
    1926                                         else 
    1927                                         { 
    1928                                                 // todo 
    1929                                                 //viewcell->GetPvs().AddSample(ray.mTerminationNode, ray.mPdf); 
    1930                                         } 
    1931                                 } 
    1932                                  
    1933 #if 0 
     1927                                        viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 
     1928                                }                                
     1929#if COUNT_ORIGIN_OBJECTS 
    19341930                                 if (ray.mOriginObject) 
     1931                                 { 
    19351932                                         viewcell->GetPvs().AddSample(ray.mOriginObject, ray.mPdf); 
     1933                                 } 
    19361934#endif 
    19371935                        } 
     
    57145712         
    57155713 
     5714float VspOspViewCellsManager::ComputeSampleContribution(VssRay &ray, 
     5715                                                                                                                const bool addRays, 
     5716                                                                                                                const bool storeViewCells) 
     5717{ 
     5718        ViewCellContainer viewcells; 
     5719 
     5720        ray.mPvsContribution = 0; 
     5721        ray.mRelativePvsContribution = 0.0f; 
     5722 
     5723        static Ray hray; 
     5724        hray.Init(ray); 
     5725        //hray.mFlags |= Ray::CULL_BACKFACES; 
     5726        //Ray hray(ray); 
     5727 
     5728        float tmin = 0, tmax = 1.0; 
     5729 
     5730        if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 
     5731                return 0; 
     5732 
     5733        Vector3 origin = hray.Extrap(tmin); 
     5734        Vector3 termination = hray.Extrap(tmax); 
     5735 
     5736        // traverse the view space subdivision 
     5737        CastLineSegment(origin, termination, viewcells); 
     5738 
     5739        if (storeViewCells) 
     5740        {       // copy viewcells memory efficiently 
     5741                ray.mViewCells.reserve(viewcells.size()); 
     5742                ray.mViewCells = viewcells; 
     5743        } 
     5744 
     5745        ViewCellContainer::const_iterator it = viewcells.begin(); 
     5746 
     5747        for (; it != viewcells.end(); ++ it)  
     5748        { 
     5749                ViewCell *viewcell = *it; 
     5750 
     5751                if (viewcell->GetValid()) 
     5752                { 
     5753                        // if ray not outside of view space 
     5754                        float contribution; 
     5755 
     5756                        if (ray.mTerminationObject)  
     5757                        { 
     5758                                if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 
     5759                                        ray.mPdf, contribution)) 
     5760                                { 
     5761                                        ++ ray.mPvsContribution; 
     5762                                } 
     5763 
     5764                                ray.mRelativePvsContribution += contribution; 
     5765                        } 
     5766 
     5767                        // for directional sampling it is important to count only contributions 
     5768                        // made in one direction!!! 
     5769                        // the other contributions of this sample will be counted for the oposite ray! 
     5770#if COUNT_ORIGIN_OBJECTS 
     5771                        if (ray.mOriginObject &&  
     5772                                viewcell->GetPvs().GetSampleContribution(ray.mOriginObject, 
     5773                                                                                                                 ray.mPdf, 
     5774                                                                                                                 contribution)) 
     5775                        { 
     5776                                ++ ray.mPvsContribution; 
     5777                                ray.mRelativePvsContribution += contribution; 
     5778                        } 
     5779#endif 
     5780                } 
     5781        } 
     5782 
     5783        // if addrays is true, sampled entities are stored in the pvs 
     5784        if (addRays) 
     5785        { 
     5786                for (it = viewcells.begin(); it != viewcells.end(); ++ it)  
     5787                { 
     5788                        ViewCell *viewcell = *it; 
     5789             
     5790                        if (viewcell->GetValid()) 
     5791                        { 
     5792                                // if ray not outside of view space 
     5793 
     5794                                // add kd cell 
     5795                                if (ray.mTerminationObject) 
     5796                                { 
     5797                                        if (!mStoreKdPvs) 
     5798                                        { 
     5799                                                viewcell->GetPvs().AddSample(ray.mTerminationObject, ray.mPdf); 
     5800                                        } 
     5801                                        else 
     5802                                        { 
     5803                                                /// get current leaf the point 
     5804                                                KdLeaf *leaf = mOspTree->GetLeaf(ray.mTermination); 
     5805 
     5806                                                KdIntersectable *entry = mOspTree->GetOrCreateKdIntersectable(leaf); 
     5807 
     5808                                                viewcell->GetPvs().AddSample(entry, ray.mPdf); 
     5809                                        } 
     5810                                } 
     5811                                 
     5812#if COUNT_ORIGIN_OBJECTS 
     5813                                 if (ray.mOriginObject) 
     5814                                         viewcell->GetPvs().AddSample(ray.mOriginObject, ray.mPdf); 
     5815#endif 
     5816                        } 
     5817                } 
     5818        } 
     5819 
     5820        return ray.mRelativePvsContribution; 
     5821} 
     5822 
     5823 
    57165824void VspOspViewCellsManager::PrepareLoadedViewCells() 
    57175825{ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1155 r1159  
    116116                @returns number of sample contributions 
    117117        */ 
    118         virtual float ComputeSampleContributions(VssRay &ray,  
    119                                                                                          const bool addRays, 
    120                                                                                          const bool storeViewCells); 
     118        virtual float ComputeSampleContribution(VssRay &ray,  
     119                                                                                        const bool addRays, 
     120                                                                                        const bool storeViewCells); 
    121121 
    122122        virtual void AddSampleContributions(VssRay &ray); 
     
    10121012        void Finalize(ViewCell *viewCell, const bool createMesh); 
    10131013 
     1014        /** Stores sample contribution for kd cells or objects. 
     1015        */ 
     1016        virtual float ComputeSampleContribution(VssRay &ray,  
     1017                                                                                        const bool addRays, 
     1018                                                                                        const bool storeViewCells); 
    10141019 
    10151020protected: 
    1016  
    10171021         
    10181022        /** Exports view cell geometry. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h

    r1149 r1159  
    13901390        int ComputePvsSize(const ObjectContainer &objects) const; 
    13911391 
    1392         KdLeaf *GetLeaf(const Vector3 &pt, KdNode *node) const; 
     1392        /** Returns kd leaf the point pt lies in, starting from root. 
     1393        */ 
     1394        KdLeaf *GetLeaf(const Vector3 &pt, KdNode *root = NULL) const; 
    13931395 
    13941396 
Note: See TracChangeset for help on using the changeset viewer.