Changeset 2292


Ignore:
Timestamp:
03/26/07 18:49:17 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/OnlineCullingCHC
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchyInterface.h

    r2280 r2292  
    9595 
    9696        void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const {} 
    97         void TraverseNode2(GtpVisibility::HierarchyNode *node) {} 
     97         
    9898        bool IsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const { return false;} 
     99         
    99100        GtpVisibility::HierarchyNode *GetRandomLeaf(GtpVisibility::HierarchyNode *root) { return NULL;} 
     101 
     102        void CollectLeaves(GtpVisibility::HierarchyNode *root,  
     103                                           GtpVisibility::HierarchyNodeContainer &nodes) {}; 
     104 
     105        void RenderNodeRecursive(GtpVisibility::HierarchyNode *node) {}; 
    100106}; 
    101107 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchySceneNode.h

    r2280 r2292  
    2323                  SceneNode(creator) {}; 
    2424 
    25                 BvHierarchySceneNode(SceneManager *creator, const String& name): 
     25                  BvHierarchySceneNode(SceneManager *creator, const String& name): 
    2626                  SceneNode(creator, name) {}; 
    2727 
    28                 ~BvHierarchySceneNode() {}; 
     28                  ~BvHierarchySceneNode() {}; 
    2929 
    30                 // gather info for kd-tree creation 
    31                 virtual void computeScene(BvhPlaneEventList& events, AxisAlignedBox& aabb, int& nObjects, bool includeChildren = true); 
     30                  // gather info for kd-tree creation 
     31                  virtual void computeScene(BvhPlaneEventList& events, AxisAlignedBox& aabb,  
     32                          int& nObjects,  
     33                          bool includeChildren = true); 
    3234 
    33                 // add all contained objects to render queue 
    34                 virtual void queueObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters); 
     35                  // add all contained objects to render queue 
     36                  virtual void queueObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters); 
    3537 
    36                 // place all entities in geometry queue (for CHC) 
    37                 virtual void getGeometryList(GeometryVector *geometryList); 
     38                  // place all entities in geometry queue (for CHC) 
     39                  virtual void getGeometryList(GeometryVector *geometryList); 
    3840 
    39                 // return a bounding box enclosing all objects 
    40                 virtual AxisAlignedBox getBoundingBox(void) const; 
     41                  // return a bounding box enclosing all objects 
     42                  virtual AxisAlignedBox getBoundingBox(void) const; 
    4143 
    42                 // DEBUG 
    43                 String dumpToString(void); 
     44                  // DEBUG 
     45                  String dumpToString(void); 
     46 
    4447        protected: 
    4548                virtual void _updateBounds(void); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeHierarchyInterface.h

    r2280 r2292  
    9696        void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const {} 
    9797 
    98         void TraverseNode2(GtpVisibility::HierarchyNode *node) {} 
    99  
    10098        GtpVisibility::HierarchyNode *GetRandomLeaf(GtpVisibility::HierarchyNode *root) { return NULL;} 
    10199 
    102100        bool IsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const { return false;} 
    103101 
     102        void CollectLeaves(GtpVisibility::HierarchyNode *root,  
     103                                           GtpVisibility::HierarchyNodeContainer &nodes) {}; 
     104 
     105        void RenderNodeRecursive(GtpVisibility::HierarchyNode *node) {}; 
    104106}; 
    105107 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOctreeHierarchyInterface.h

    r2280 r2292  
    5454        void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const; 
    5555 
    56         void TraverseNode2(GtpVisibility::HierarchyNode *node); 
    57  
    5856        GtpVisibility::HierarchyNode *GetRandomLeaf(GtpVisibility::HierarchyNode *node); 
    5957 
     
    6260        void RenderNodeRecursive(GtpVisibility::HierarchyNode *node); 
    6361 
     62        void CollectLeaves(GtpVisibility::HierarchyNode *root,  
     63                                           GtpVisibility::HierarchyNodeContainer &nodes); 
    6464 
    6565protected: 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreSceneNodeHierarchyInterface.h

    r2280 r2292  
    4747 
    4848        void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const {} 
    49         void TraverseNode2(GtpVisibility::HierarchyNode *node) {} 
     49 
    5050        GtpVisibility::HierarchyNode *GetRandomLeaf(GtpVisibility::HierarchyNode *root) { return NULL;} 
     51 
    5152        bool IsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const { return false;} 
    5253 
     54        void CollectLeaves(GtpVisibility::HierarchyNode *root, GtpVisibility::HierarchyNodeContainer &nodes) {}; 
    5355}; 
    5456 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp

    r2287 r2292  
    11#include "OgreOctreeHierarchyInterface.h" 
    2 //#include "OgreVisibilityOctreeSceneManager.h" 
    32#include <OgreOctree.h> 
    43#include <OgreLogManager.h> 
     
    7069                int z = i & 1; 
    7170         
    72                 //std::stringstream d; d << x << " " << y << " " << z; 
    73                 //Ogre::LogManager::getSingleton().logMessage(d.str()); 
    74  
    7571                if ((child = octree->mChildren[x][y][z]) != NULL) 
    7672                { 
     
    7874                } 
    7975        } 
    80  
    81         //std::stringstream str; str << "nodes: " << nodes.size(); 
    82         //Ogre::LogManager::getSingleton().logMessage(str.str()); 
    8376 
    8477        if (nodes.empty()) 
     
    8780        int r = (int)(((float)rand() / RAND_MAX) * ((float)nodes.size() - 0.5f)); 
    8881 
    89         //std::stringstream str2; 
    90         //str2 << "rand: " << r; 
    91         //Ogre::LogManager::getSingleton().logMessage(str2.str()); 
    92  
    9382        return GetRandomLeaf(nodes[r]); 
    94         // assume that at least one child is not NULL ... 
    95         /*while (!child) 
    96         { 
    97                 int mask = (int) (rand() * 8.0f); 
    98                 child = octree->mChildren[(mask & 4) / 4][(mask & 2) / 2][mask & 1]; 
    99         } 
    100  
    101         return GetRandomLeaf(child);*/ 
    102 } 
    103 //----------------------------------------------------------------------- 
    104 void OctreeHierarchyInterface::TraverseNode2(GtpVisibility::HierarchyNode *node) 
    105 { 
    106         ++ mNumTraversedNodes; 
    107  
    108         Octree *octree = static_cast<Octree *>(node); 
    109  
    110         // if we come across some renderable geometry => render it 
    111         //if (!octree->mNodes.empty()) 
    112         //{ 
    113                 RenderNodeRecursive(node); 
    114         //} 
    115  
    116 /* 
    117                 // render everything from here 
    118                 if (octree->isOctreeFullyVisible()) 
    119                 {                
    120                         RenderNodeRecursive(node); 
    121                         return; 
    122                 } 
    123  
    124                 RenderNode(node); 
    125         } 
    126                  
    127         // if not all subtrees are empty 
    128         if (!IsLeaf(node)) 
    129         { 
    130                 Octree *nextChild; 
    131  
    132                 if ((nextChild = octree->mChildren[0][0][0]) != NULL) 
    133                         mDistanceQueue->push(nextChild); 
    134                 if ((nextChild = octree->mChildren[0][0][1]) != NULL) 
    135                         mDistanceQueue->push(nextChild); 
    136                 if ((nextChild = octree->mChildren[0][1][0]) != NULL) 
    137                         mDistanceQueue->push(nextChild); 
    138                 if ((nextChild = octree->mChildren[0][1][1]) != NULL) 
    139                 mDistanceQueue->push(nextChild); 
    140                 if ((nextChild = octree->mChildren[1][0][0]) != NULL) 
    141                         mDistanceQueue->push(nextChild); 
    142                 if ((nextChild = octree->mChildren[1][0][1]) != NULL) 
    143                         mDistanceQueue->push(nextChild); 
    144                 if ((nextChild = octree->mChildren[1][1][0]) != NULL) 
    145                         mDistanceQueue->push(nextChild); 
    146                 if ((nextChild = octree->mChildren[1][1][1]) != NULL) 
    147                         mDistanceQueue->push(nextChild); 
    148         } 
    149         */ 
    15083} 
    15184//----------------------------------------------------------------------- 
     
    168101        const Vector3 bmax = static_cast<Octree *>(node)->mBox.getMaximum(); 
    169102 
    170         const Vector3 pos = (bmax - bmin) * 0.5 + bmin; 
    171          
    172 /*      std::stringstream d;  
    173         d << "a: " << (mCameraPosition - pos).squaredLength()  
    174           << " b: " << (mCullCamera->getDerivedPosition() - pos).squaredLength(); 
    175         LogManager::getSingleton().logMessage(d.str());*/ 
     103        const Vector3 pos = (bmax - bmin) * 0.5f + bmin; 
     104         
    176105        return (mCameraPosition - pos).squaredLength(); 
    177106} 
     
    206135} 
    207136//----------------------------------------------------------------------- 
    208 void OctreeHierarchyInterface::DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const 
     137/*void OctreeHierarchyInterface::PullUpFullVisibility(GtpVisibility::HierarchyNode *node) const 
    209138{                
    210         Octree *octant = static_cast<Octree *>(node); 
    211  
    212         // leaf node: terminate recursion 
    213         if (IsLeaf(node)) 
    214         { 
    215                 octant->setOctreeFullyVisible(octant->isOctreeVisible()); 
    216                          
    217                 return; 
    218         } 
    219  
    220         octant->setOctreeFullyVisible(true); 
    221          
    222         Octree *nextChild; 
    223          
     139#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
     140        Octree *octant = static_cast<Octree *>(node); 
     141 
    224142        for (int i = 0; i < 8; ++ i) 
    225143        { 
     
    228146                int z = i & 1; 
    229147                 
    230                         if ((nextChild = octant->mChildren[x][y][z]) != NULL) 
     148                if ((nextChild = octant->mChildren[x][y][z]) != NULL) 
    231149                { 
    232150                        DetermineFullVisibility(nextChild); 
     
    236154                } 
    237155        } 
     156 
     157        while (octant && !octant->isOctreeVisible()) 
     158        { 
     159                octant->setOctreeVisible(true); 
     160                octant = octant->getParent(); 
     161        } 
     162#endif 
     163}*/ 
     164//----------------------------------------------------------------------- 
     165void OctreeHierarchyInterface::DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const 
     166{                
     167        Octree *octant = static_cast<Octree *>(node); 
     168 
     169        // leaf node: terminate recursion 
     170        if (IsLeaf(node)) 
     171        { 
     172                octant->setOctreeFullyVisible(octant->isOctreeVisible());        
     173                return; 
     174        } 
     175 
     176        octant->setOctreeFullyVisible(true); 
     177         
     178        Octree *nextChild; 
     179         
     180        for (int i = 0; i < 8; ++ i) 
     181        { 
     182                int x = (i & 4) / 4; 
     183                int y = (i & 2) / 2; 
     184                int z = i & 1; 
     185                 
     186                if ((nextChild = octant->mChildren[x][y][z]) != NULL) 
     187                { 
     188                        DetermineFullVisibility(nextChild); 
     189                        // this leaf is not fully visible => break 
     190                        if (!nextChild->isOctreeFullyVisible()) 
     191                                octant->setOctreeFullyVisible(false); 
     192                } 
     193        } 
    238194} 
    239195//----------------------------------------------------------------------- 
     
    264220        Octree *octant = static_cast<Octree *>(node); 
    265221 
    266         if (1)//octant->lastRendered() != mFrameId) 
     222        if (octant->lastRendered() != mFrameId) 
    267223        { 
    268224                octant->setLastRendered(mFrameId); 
     
    351307        } 
    352308} 
     309//----------------------------------------------------------------------- 
     310void OctreeHierarchyInterface::CollectLeaves(GtpVisibility::HierarchyNode *root,  
     311                                                                                         GtpVisibility::HierarchyNodeContainer &nodes) 
     312{ 
     313        std::stack<GtpVisibility::HierarchyNode *> tStack; 
     314        tStack.push(root); 
     315 
     316        Octree *child; 
     317 
     318        while (!tStack.empty()) 
     319        { 
     320                GtpVisibility::HierarchyNode *node = tStack.top(); 
     321                tStack.pop(); 
     322 
     323                if (IsLeaf(node)) 
     324                { 
     325                        nodes.push_back(node); 
     326                } 
     327                else 
     328                { 
     329                        Octree *octree = static_cast<Octree *>(node); 
     330                         
     331                        for (int i = 0; i < 8; ++ i) 
     332                        { 
     333                                int x = (i & 4) / 4; 
     334                                int y = (i & 2) / 2; 
     335                                int z = i & 1; 
     336         
     337                                if ((child = octree->mChildren[x][y][z]) != NULL) 
     338                                { 
     339                                        tStack.push(child); 
     340                                } 
     341                        } 
     342                } 
     343        } 
     344} 
    353345 
    354346 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj

    r2280 r2292  
    322322                                AdditionalLibraryDirectories="&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\Release&quot;;&quot;$(OGRE_PATH)\OgreMain\lib\Release&quot;;&quot;$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib&quot;;..\..\GtpVisibility\lib\Release;..\..\lib\Release;..\lib\Release;&quot;$(OGRE_PATH)\Dependencies\lib\Release&quot;;..\..\..\Preprocessing\lib\Release;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\..\Preprocessing\src\GL;&quot;$(CG_LIB_PATH)&quot;;..\..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\Lib\Vis\Preprocessing\MultiLevelRayTracing\RTWorld\Release;..\..\..\..\..\Lib\Vis\Preprocessing\MultiLevelRayTracing\RTScene\Release;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\lib\Release;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\ObjReader\lib\Release" 
    323323                                ModuleDefinitionFile="..\misc\OgreVisibilitySceneManager.def" 
    324                                 GenerateDebugInformation="FALSE" 
     324                                GenerateDebugInformation="TRUE" 
    325325                                SubSystem="2" 
    326326                                OptimizeReferences="2" 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/include/HierarchyInterface.h

    r2280 r2292  
    1919typedef std::queue<PendingQuery> PendingQueue; 
    2020 
     21typedef std::vector<HierarchyNode *> HierarchyNodeContainer; 
    2122 
    22 /**     Class which implements a hierarchy interface for a scene hierarchy. It has to be implemented 
    23         for any rendering engine to use the CHC algorithm. 
     23 
     24/**     Class which implements an interface for the operations on a hierarchy 
     25        of a scene.  
     26        It has to be implemented for any rendering engine to use the CHC algorithm. 
    2427*/ 
    2528class HierarchyInterface 
     
    153156        virtual void DetermineFullVisibility(GtpVisibility::HierarchyNode *node) const = 0; 
    154157 
    155         virtual void TraverseNode2(GtpVisibility::HierarchyNode *node) = 0; 
    156  
    157158        virtual HierarchyNode *GetRandomLeaf(HierarchyNode *root) = 0; 
    158159        virtual bool IsNodeFullyVisible(GtpVisibility::HierarchyNode *node) const = 0; 
     160 
     161        virtual void CollectLeaves(HierarchyNode *root, HierarchyNodeContainer &nodes) = 0; 
     162 
     163        virtual void RenderNodeRecursive(HierarchyNode *node) = 0; 
    159164 
    160165protected: 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/CoherentHierarchicalCullingManager.cpp

    r2289 r2292  
    1111        SetAssumedVisibility(0); 
    1212        // initialise random generator in case we use assumed visibility 
    13         srand(time(NULL)); 
     13        //srand(time(NULL)); 
    1414} 
    1515//----------------------------------------------------------------------- 
     
    1919        SetAssumedVisibility(assumedVisibility); 
    2020        // initialise random generator in case we use assumed visibility 
    21         srand(time(NULL)); 
     21        //srand(time(NULL)); 
    2222} 
    2323//----------------------------------------------------------------------- 
    2424void CoherentHierarchicalCullingManager::RenderScene() 
    2525{ 
    26         CullingLogManager::GetSingleton()->LogMessage("chc"); 
     26        if (0) CullingLogManager::GetSingleton()->LogMessage("chc"); 
    2727        QueryQueue queryQueue; 
    2828        unsigned int visiblePixels = 0; 
     
    158158inline void CoherentHierarchicalCullingManager::SkipQuery(HierarchyNode *node) const 
    159159{ 
    160         // -- set node to be visible in this frame, then traverse it 
     160        //-- set node to be visible in this frame, then traverse it 
    161161        mHierarchyInterface->SetLastVisited(node, mHierarchyInterface->GetFrameId()); 
    162162         
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/FrustumCullingManager.cpp

    r2289 r2292  
    88void FrustumCullingManager::RenderScene() 
    99{        
    10         CullingLogManager::GetSingleton()->LogMessage("vfc"); 
     10        if (0) CullingLogManager::GetSingleton()->LogMessage("vfc"); 
    1111 
    1212        while (!mHierarchyInterface->GetQueue()->empty()) 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp

    r2289 r2292  
    22#include <time.h> 
    33#include "CullingLogManager.h" 
     4#include <vector> 
     5//#include <iostream> 
     6#include <sstream> 
     7 
     8 
     9using namespace std; 
    410 
    511 
     
    1218        SetAssumedVisibility(0); 
    1319        // initialise random generator in case we use assumed visibility 
    14         srand(time(NULL)); 
     20        //srand(time(NULL)); 
    1521 
    1622        mRandomCandidates = R_CANDIDATES; 
     
    2228        SetAssumedVisibility(assumedVisibility); 
    2329        // initialise random generator in case we use assumed visibility 
    24         srand(time(NULL)); 
     30        //srand(time(NULL)); 
    2531 
    2632        mRandomCandidates = R_CANDIDATES; 
     
    2935void RandomUpdateCullingManager::RenderScene() 
    3036{ 
    31         CullingLogManager::GetSingleton()->LogMessage("ruc"); 
     37        if (0) CullingLogManager::GetSingleton()->LogMessage("ruc"); 
    3238 
    3339        QueryQueue queryQueue; 
     
    3743        //-- PART 1: process finished occlusion queries 
    3844 
    39         // update the fully visible classifications 
    40         mHierarchyInterface->DetermineFullVisibility(mHierarchyInterface->GetHierarchyRoot()); 
    41  
    42         //mHierarchyInterface->TraverseNode2(mHierarchyInterface->GetHierarchyRoot()); 
    43          
    44 #if 1 
    4545        while (!mHierarchyInterface->GetQueue()->empty() || !queryQueue.empty()) 
    4646        { 
     
    121121                                if (mHierarchyInterface->IsNodeFullyVisible(node)) 
    122122                                { 
     123#if 1 
    123124                                        // node fully visible => test only random leaves 
    124125                                        for (int i = 0; i < mRandomCandidates; ++ i) 
     
    138139                                                        mHierarchyInterface->IssueNodeOcclusionQuery(node))); 
    139140                                        } 
    140  
    141                                         mHierarchyInterface->TraverseNode2(node); 
     141#else 
     142                                        // test all leaves for visibility changes 
     143                                        HierarchyNodeContainer mynodes; 
     144                                        mHierarchyInterface->CollectLeaves(node, mynodes); 
     145 
     146                                        HierarchyNodeContainer::const_iterator nit, nit_end = mynodes.end(); 
     147 
     148                                        for (nit = mynodes.begin(); nit != nit_end; ++ nit) 
     149                                        { 
     150                                                HierarchyNode *leaf = *nit; 
     151                                                mHierarchyInterface->SetNodeVisible(leaf, false); 
     152 
     153                                                // update node's visited flag 
     154                                                mHierarchyInterface->SetLastVisited(leaf, mHierarchyInterface->GetFrameId()); 
     155 
     156                                                queryQueue.push(QueryPair(leaf,  
     157                                                        mHierarchyInterface->IssueNodeOcclusionQuery(node))); 
     158                                        } 
     159#endif 
     160                                        mHierarchyInterface->RenderNodeRecursive(node); 
    142161 
    143162                                        continue; 
     
    173192                } 
    174193        } 
    175 #endif 
     194 
    176195        //while (!mHierarchyInterface->GetQueue()->empty()) 
    177196        //      mHierarchyInterface->GetQueue()->pop(); 
    178          
     197 
     198        // update the fully visible classifications 
     199        // TODO: this should be done during traversal! 
     200        mHierarchyInterface->DetermineFullVisibility(mHierarchyInterface->GetHierarchyRoot()); 
    179201} 
    180202//----------------------------------------------------------------------- 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/src/StopAndWaitCullingManager.cpp

    r2289 r2292  
    77void StopAndWaitCullingManager::RenderScene() 
    88{ 
    9         CullingLogManager::GetSingleton()->LogMessage("swc"); 
     9        if (0) CullingLogManager::GetSingleton()->LogMessage("swc"); 
    1010 
    1111        while (!mHierarchyInterface->GetQueue()->empty()) 
Note: See TracChangeset for help on using the changeset viewer.