- Timestamp:
- 07/14/05 09:06:16 (19 years ago)
- Location:
- trunk/VUT
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/include/DummyQueryManager.h
r159 r174 16 16 */ 17 17 DummyQueryManager( HierarchyInterface *hierarchyInterface ): 18 QueryManager(hierarchyInterface ) {}18 QueryManager(hierarchyInterface, 0) {} 19 19 20 20 /** -
trunk/VUT/GtpVisibility/include/HierarchyInterface.h
r171 r174 126 126 /** Returns vector of previously rendered hierarchy nodes. 127 127 */ 128 std::vector<HierarchyNode *> *Get RenderedNodes();128 std::vector<HierarchyNode *> *GetVisibleNodes(); 129 129 /** Returns vector of previoulsy rendered geometry. 130 130 */ … … 182 182 HierarchyNode *mSavedNode; 183 183 /// list of rendered hierarchy nodes (e.g., useful for exact visibility queries) 184 std::vector<HierarchyNode *> m RenderedNodes;184 std::vector<HierarchyNode *> mVisibleNodes; 185 185 }; 186 186 } // namespace GtpVisibility -
trunk/VUT/GtpVisibility/include/QueryManager.h
r159 r174 27 27 on different hierarchy types, while reusing the implementation of the query methods. 28 28 */ 29 QueryManager(HierarchyInterface *hierarchyInterface );29 QueryManager(HierarchyInterface *hierarchyInterface, int queryModes); 30 30 31 31 /** … … 90 90 void SetHierarchyInterface(HierarchyInterface *hierarchyInterface); 91 91 92 enum {PATCH_VISIBILITY = 2, 93 GEOMETRY_VISIBILITY = 4, 94 NODE_VISIBILITY = 8}; 95 92 96 protected: 93 HierarchyInterface *mHierarchyInterface;94 97 98 HierarchyInterface *mHierarchyInterface; 99 int mQueryModes; 95 100 }; 96 101 -
trunk/VUT/GtpVisibility/src/HierarchyInterface.cpp
r158 r174 30 30 mCurrentTestIdx = 0; 31 31 mNumTraversedNodes = 0; 32 m RenderedNodes.clear();32 mVisibleNodes.clear(); 33 33 34 34 mDistanceQueue->push(mHierarchyRoot); … … 63 63 unsigned int HierarchyInterface::GetNumRenderedNodes() 64 64 { 65 return (unsigned int)m RenderedNodes.size();65 return (unsigned int)mVisibleNodes.size(); 66 66 } 67 67 //----------------------------------------------------------------------- … … 71 71 } 72 72 //----------------------------------------------------------------------- 73 std::vector<HierarchyNode *> *HierarchyInterface::Get RenderedNodes()73 std::vector<HierarchyNode *> *HierarchyInterface::GetVisibleNodes() 74 74 { 75 return &m RenderedNodes;75 return &mVisibleNodes; 76 76 } 77 77 } // namespace GtpVisibility -
trunk/VUT/GtpVisibility/src/QueryManager.cpp
r130 r174 4 4 namespace GtpVisibility { 5 5 6 QueryManager::QueryManager(HierarchyInterface *hierarchyInterface) 7 :mHierarchyInterface(hierarchyInterface) 6 QueryManager::QueryManager(HierarchyInterface *hierarchyInterface, int queryModes): 7 mHierarchyInterface(hierarchyInterface), 8 mQueryModes(queryModes) 8 9 { 9 10 } -
trunk/VUT/Ogre/include/OgreOcclusionQueriesQueryManager.h
r173 r174 15 15 on different hierarchy types, while reusing the implementation of the query methods. 16 16 */ 17 OcclusionQueriesQueryManager(PlatformHierarchyInterface *hierarchyInterface, 18 Viewport *vp, 19 bool renderPatches, 20 bool useItemBufferForGeometry); 17 OcclusionQueriesQueryManager(PlatformHierarchyInterface *hierarchyInterface, Viewport *vp, 18 int queryModes, int itemBufferMode); 21 19 22 20 void ComputeCameraVisibility(const Camera &camera, … … 70 68 void RemoveDuplicatePatches(InfoContainer<GtpVisibility::PatchInfo> *visiblePatches); 71 69 72 bool mUseItemBuffer; 70 /** Returns the patches of the geometry of a given node. 71 @param node the node containing the patches 72 @param patchList the patches are returned in this list 73 */ 74 virtual void GetNodePatchList(GtpVisibility::HierarchyNode *node, 75 GtpVisibility::PatchList *patchList); 76 77 int mItemBufferMode; 73 78 }; 74 79 -
trunk/VUT/Ogre/include/OgreOctreeHierarchyInterface.h
r158 r174 48 48 49 49 void GetNodeGeometryList(GtpVisibility::HierarchyNode *node, 50 GtpVisibility::GeometryList *geometryList,51 bool includeChildren);52 50 GtpVisibility::GeometryList *geometryList, 51 bool includeChildren); 52 53 53 protected: 54 54 /** Returns pointer to the bounding box of the node. -
trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
r156 r174 106 106 bool IsBoundingBoxQuery(); 107 107 108 GtpVisibility::OcclusionQuery *IssueOcclusionQuery(GtpVisibility::Patch *patch); 108 109 109 110 protected: … … 111 112 */ 112 113 void RenderGeometry(GtpVisibility::Mesh *geom); 114 115 /** Renders a patch 116 */ 117 void RenderPatch(GtpVisibility::Patch *patch); 113 118 114 119 /** Materials for visualizing frustum and query culled nodes. -
trunk/VUT/Ogre/include/OgrePlatformQueryManager.h
r173 r174 18 18 */ 19 19 PlatformQueryManager(PlatformHierarchyInterface *hierarchyInterface, 20 Viewport *vp, 21 bool renderPatches); 20 Viewport *vp, int queryModes); 22 21 23 22 /** … … 42 41 */ 43 42 void SetViewport(Viewport *vp); 44 43 45 44 protected: 46 45 … … 53 52 54 53 Viewport *mViewport; 54 55 55 bool mWasInitialised; 56 bool mRenderPatches;57 56 }; 58 57 -
trunk/VUT/Ogre/src/OgreOcclusionQueriesQueryManager.cpp
r173 r174 47 47 PlatformHierarchyInterface *hierarchyInterface, 48 48 Viewport *vp, 49 bool renderPatches,50 bool useItemBufferForGeometry):51 PlatformQueryManager(hierarchyInterface, vp, renderPatches),52 m UseItemBuffer(useItemBufferForGeometry)49 int queryModes, 50 int itemBufferMode): 51 PlatformQueryManager(hierarchyInterface, vp, queryModes), 52 mItemBufferMode(itemBufferMode) 53 53 { 54 54 } … … 60 60 bool relativeVisibility) 61 61 { 62 62 // we need access to the scene manager and the rendersystem 63 63 PlatformHierarchyInterface *pfHierarchyInterface = 64 64 dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface); … … 68 68 69 69 //-- render scene with item buffer (i.e., objects with their id as color codes) 70 if (mUseItemBuffer) 71 { 70 if ((mItemBufferMode && mQueryModes) != 0) 71 { 72 int savedQueryModes = mQueryModes; 73 mQueryModes = mItemBufferMode; 74 72 75 PlatformQueryManager::ComputeCameraVisibility(camera, visibleNodes, 73 76 visibleGeometry, visiblePatches, relativeVisibility); 74 77 78 // overlays cause false visibility 75 79 mViewport->setOverlaysEnabled(false); 80 mQueryModes = savedQueryModes; 76 81 } 77 82 else … … 93 98 GtpVisibility::QueryList queryList[2]; 94 99 95 // rendered hierarchy nodes from previous render 96 GtpVisibility::HierarchyNodeList *nodeList = mHierarchyInterface->GetRenderedNodes(); 97 GtpVisibility::HierarchyNodeList::iterator nodeIt, nodeIt_end = nodeList->end(); 100 // rendered visibile hierarchy nodes from previous rendering 101 GtpVisibility::HierarchyNodeList *visNodes = mHierarchyInterface->GetVisibleNodes(); 102 GtpVisibility::HierarchyNodeList::iterator visNodesIt, visNodesIt_end = visNodes->end(); 103 104 GtpVisibility::HierarchyNodeList nodeList; 105 106 if (mQueryModes && NODE_VISIBILITY) 107 { 108 for (visNodesIt = visNodes->begin(); visNodesIt != visNodesIt_end; ++visNodesIt) 109 { 110 nodeList.push_back((*visNodesIt)); 111 } 112 } 113 114 GtpVisibility::HierarchyNodeList::iterator nodeIt, nodeIt_end = nodeList.end(); 98 115 99 116 // vector for storing entities of meshes 100 117 GtpVisibility::GeometryList geometryList; 101 118 102 // store geometry of the hierarchy node in a geometry list (only once!) 103 for (nodeIt = nodeList->begin(); nodeIt != nodeIt_end; ++nodeIt) 104 { 105 mHierarchyInterface->GetNodeGeometryList(*nodeIt, &geometryList, false); 106 } 107 119 // store geometry of the hierarchy nodes in a geometry list 120 if (mQueryModes && GEOMETRY_VISIBILITY) 121 { 122 for (visNodesIt = visNodes->begin(); visNodesIt != visNodesIt_end; ++visNodesIt) 123 { 124 mHierarchyInterface->GetNodeGeometryList(*visNodesIt, &geometryList, false); 125 } 126 } 127 108 128 // geometry list iterator 109 129 GtpVisibility::GeometryList::iterator geometryIt, geometryIt_end = geometryList.end(); … … 111 131 // vector for storing subentities of meshes 112 132 GtpVisibility::PatchList patchList; 133 134 // store patchges of the geometries in a patch list 135 if (mQueryModes && PATCH_VISIBILITY) 136 { 137 for (visNodesIt = visNodes->begin(); visNodesIt != visNodesIt_end; ++visNodesIt) 138 { 139 GetNodePatchList(*visNodesIt, &patchList); 140 } 141 } 142 113 143 GtpVisibility::PatchList::iterator patchIt, patchIt_end = patchList.end(); 114 144 … … 133 163 { 134 164 //-- queries for hierarchy nodes 135 for (nodeIt = nodeList ->begin(); nodeIt != nodeIt_end; ++nodeIt)165 for (nodeIt = nodeList.begin(); nodeIt != nodeIt_end; ++nodeIt) 136 166 { 137 167 // TODO: DELETE QUERIES FROM PREVIOUS RENDER … … 140 170 141 171 //-- queries for geometry: if item buffer, capture only projected visibility 142 for (geometryIt = geometryList.begin(); geometryIt != geometryIt_end; ++geometryIt) 143 { 144 queryList[i].push_back(mHierarchyInterface->IssueOcclusionQuery(*geometryIt)); 172 if ((mItemBufferMode != GEOMETRY_VISIBILITY) || (i == 1)) 173 { 174 for (geometryIt = geometryList.begin(); geometryIt != geometryIt_end; ++geometryIt) 175 { 176 queryList[i].push_back(mHierarchyInterface->IssueOcclusionQuery(*geometryIt)); 177 } 145 178 } 146 179 147 180 //-- queries for patches: if item buffer, capture only projected visibility 148 if ( !(mUseItemBuffer && (i == 0)))181 if ((mItemBufferMode != PATCH_VISIBILITY) || (i == 1)) 149 182 { 150 183 for (patchIt = patchList.begin(); patchIt != patchIt_end; ++patchIt) … … 162 195 GtpVisibility::QueryList::iterator projQueryIt = queryList[1].begin(); 163 196 164 CollectNodeVisibility(visQueryIt, projQueryIt, nodeList, visibleNodes, relativeVisibility); 165 166 if (mUseItemBuffer) 167 { 168 if (relativeVisibility) 169 { 170 CollectRelativePatchVisibilityForItemBuffer(projQueryIt, &patchList, visiblePatches); 171 } 172 } 197 // collect occlusion queries for hierarchy nodes 198 CollectNodeVisibility(visQueryIt, projQueryIt, &nodeList, visibleNodes, relativeVisibility); 199 200 201 202 // collect occlusion queries for geometry 203 if ((mItemBufferMode == GEOMETRY_VISIBILITY) && relativeVisibility) 204 { 205 // if visibility was established using the item buffer, 206 // the array is organized different (e.g., ordered by id, all possible objects) 207 CollectRelativeGeometryVisibilityForItemBuffer(projQueryIt, &geometryList, visibleGeometry); 208 } 209 else 210 { 211 CollectGeometryVisibility(visQueryIt, projQueryIt, &geometryList, visibleGeometry, 212 relativeVisibility); 213 } 214 215 216 // collect occlusion queries for patches 217 if ((mItemBufferMode == PATCH_VISIBILITY) && relativeVisibility) 218 { 219 CollectRelativePatchVisibilityForItemBuffer(projQueryIt, &patchList, visiblePatches); 220 } 173 221 else 174 222 { 175 223 CollectPatchVisibility(visQueryIt, projQueryIt, &patchList, visiblePatches, relativeVisibility); 176 224 } 177 178 CollectGeometryVisibility(visQueryIt, projQueryIt, &geometryList, visibleGeometry, relativeVisibility); 225 179 226 180 227 //-- reset options … … 201 248 RemoveDuplicateNodes(visibleNodes); 202 249 203 if ( !mUseItemBuffer)250 if (mItemBufferMode != GEOMETRY_VISIBILITY) 204 251 { 205 252 RemoveDuplicateGeometry(visibleGeometry); 253 } 254 255 if (mItemBufferMode != PATCH_VISIBILITY) 256 { 257 RemoveDuplicatePatches(visiblePatches); 206 258 } 207 259 } … … 442 494 patchinfo_eq), visiblePatches->end()); 443 495 } 496 //----------------------------------------------------------------------- 497 void OcclusionQueriesQueryManager::GetNodePatchList(GtpVisibility::HierarchyNode *node, 498 GtpVisibility::PatchList *patchList) 499 { 500 GtpVisibility::GeometryList geomList; 501 mHierarchyInterface->GetNodeGeometryList(node, &geomList, false); 502 503 // geometry list iterator 504 GtpVisibility::GeometryList::iterator geomIt, geomIt_end = geomList.end(); 505 506 for (geomIt = geomList.begin(); geomIt != geomIt_end; ++geomIt) 507 { 508 for (int i = 0; i < (int)(*geomIt)->getNumSubEntities(); ++i) 509 { 510 patchList->push_back((*geomIt)->getSubEntity(i)); 511 } 512 } 513 } 514 444 515 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r159 r174 103 103 octant, mOnlyShadowCasters, mLeavePassesInQueue); 104 104 105 m RenderedNodes.push_back(node);105 mVisibleNodes.push_back(node); 106 106 } 107 107 #endif … … 167 167 } 168 168 } 169 169 170 } // namespace Ogre -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r159 r174 201 201 //----------------------------------------------------------------------- 202 202 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery( 203 GtpVisibility::Patch *patch) 204 { 205 // get next available test id 206 GtpVisibility::OcclusionQuery *query = GetNextOcclusionQuery(); 207 208 //-- the actual query test 209 query->BeginQuery(); 210 211 RenderPatch(patch); 212 213 query->EndQuery(); 214 215 return query; 216 } 217 //----------------------------------------------------------------------- 218 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery( 203 219 GtpVisibility::Mesh *mesh) 204 220 { … … 269 285 } 270 286 //----------------------------------------------------------------------- 287 void PlatformHierarchyInterface::RenderPatch(GtpVisibility::Patch *patch) 288 { 289 Pass *pass = patch->getTechnique()->getPass(0); 290 mSceneManager->setPass(pass); 291 mSceneManager->renderSingleObject(patch, pass, false); 292 } 293 //----------------------------------------------------------------------- 271 294 SceneManager *PlatformHierarchyInterface::GetSceneManager() 272 295 { … … 278 301 return mRenderSystem; 279 302 } 303 280 304 } // namespace Ogre -
trunk/VUT/Ogre/src/OgrePlatformQueryManager.cpp
r173 r174 12 12 //----------------------------------------------------------------------- 13 13 PlatformQueryManager::PlatformQueryManager(PlatformHierarchyInterface *hierarchyInterface, 14 Viewport *vp, bool renderPatches):15 QueryManager(hierarchyInterface ),14 Viewport *vp, int queryModes): 15 QueryManager(hierarchyInterface, queryModes), 16 16 mViewport(vp), 17 mWasInitialised(false), 18 mRenderPatches(renderPatches) 17 mWasInitialised(false) 19 18 { 20 19 } … … 147 146 uchar *buf = mViewport->getTarget()->getBufferContents(dimx, dimy); 148 147 149 int n = mRenderPatches ?150 (int)visiblePatches->size() : (int)visibleGeometry->size();151 152 148 //std::stringstream d; d << "dimx: " << dimx << ", dimy: " << dimy; LogManager::getSingleton().logMessage(d.str()); 153 149 … … 163 159 164 160 // if valid id <= add visibility (id values start at 1) 165 if ( (id > 0) && (id < n))166 { 167 if ( mRenderPatches)168 { 161 if (mQueryModes == PATCH_VISIBILITY) 162 { 163 if ((id > 0) && (id < (int)visiblePatches->size())) 164 { 169 165 ((*visiblePatches)[id]).AddVisibility(1, 0); 170 166 } 171 else 167 } 168 else if (mQueryModes == GEOMETRY_VISIBILITY) 169 { 170 if ((id > 0) && (id < (int)visibleGeometry->size())) 172 171 { 173 172 ((*visibleGeometry)[id]).AddVisibility(1, 0); … … 213 212 SubEntity *subEnt = ent->getSubEntity(i); 214 213 215 if (m RenderPatches)214 if (mQueryModes == PATCH_VISIBILITY) 216 215 { 217 216 ++ id; … … 223 222 } 224 223 225 if ( !mRenderPatches)224 if (mQueryModes == GEOMETRY_VISIBILITY) 226 225 { 227 226 visibleGeometry->push_back(GtpVisibility::MeshInfo(ent, 0, 0)); -
trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
r158 r174 45 45 { 46 46 sceneNode->setLastRendered(sceneNode->lastVisited()); 47 m RenderedNodes.push_back(node);47 mVisibleNodes.push_back(node); 48 48 49 49 mSceneManager->_renderSceneNode(mCamera, sceneNode, mLeavePassesInQueue); -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r164 r174 737 737 738 738 }// for each priority 739 }740 */741 /*//-----------------------------------------------------------------------742 Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName,743 const String& meshName)744 {745 Entity *ent = SceneManager::createEntity(entityName, meshName);746 747 for (int i = 0; i < (int)ent->getNumSubEntities(); ++i)748 {749 ent->getSubEntity(i)->setId(mCurrentEntityId);750 }751 752 // increase counter of entity id values753 ++ mCurrentEntityId;754 755 return ent;756 739 }*/ 757 740 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r166 r174 14 14 15 15 //----------------------------------------------------------------------- 16 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( GtpVisibility::17 16 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 17 GtpVisibility::VisibilityManager *visManager): 18 18 mVisibilityManager(visManager), 19 19 mShowVisualization(false), … … 752 752 { 753 753 ent->getSubEntity(i)->setId(mCurrentEntityId); 754 //ent->getSubEntity(i)->setId((41 << 16) + (4 << 8) + 60);755 //ent->getSubEntity(i)->setId((2 << 16) + (4 << 8) + 60);756 754 } 757 755 -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r173 r174 126 126 mDelayedQueriesIssued(0.0), 127 127 mDelayedTraversedNodes(0.0), 128 mUseItemBuffer(false),129 mRenderPatchesForItemBuffer(false),130 128 mCurrentObjectType(0), 131 129 mApplication(app), 132 130 mUseAnimation(false), 133 mDeleteObjects(false) 131 mDeleteObjects(false), 132 mUseItemBuffer(false), 133 mItemBufferMode(GtpVisibility::QueryManager::PATCH_VISIBILITY) 134 134 { 135 135 //mInputDevice = PlatformManager::getSingleton().createInputReader(); … … 424 424 dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr); 425 425 426 int itemBufferMode = useItemBuffer ? mItemBufferMode : 0; 427 428 int queryModes = GtpVisibility::QueryManager::PATCH_VISIBILITY; 429 queryModes |= GtpVisibility::QueryManager::GEOMETRY_VISIBILITY; 430 queryModes |= GtpVisibility::QueryManager::NODE_VISIBILITY; 431 426 432 mQueryManager = new OcclusionQueriesQueryManager(sm->GetHierarchyInterface(), 427 mWindow->getViewport(0), true, useItemBuffer); 433 mWindow->getViewport(0), queryModes, useItemBuffer); 434 428 435 //mQueryManager = new PlatformQueryManager(sm->GetHierarchyInterface(), mWindow->getViewport(0), false); 429 436 … … 1011 1018 1012 1019 case KC_C: 1013 mRenderPatchesForItemBuffer = !mRenderPatchesForItemBuffer; 1020 1021 if (mItemBufferMode != GtpVisibility::QueryManager::GEOMETRY_VISIBILITY) 1022 mItemBufferMode = GtpVisibility::QueryManager::GEOMETRY_VISIBILITY; 1023 else 1024 mItemBufferMode = GtpVisibility::QueryManager::PATCH_VISIBILITY; 1025 1014 1026 break; 1015 1027 -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r173 r174 224 224 bool mUseItemBuffer; 225 225 bool mUseAnimation; 226 bool mRenderPatchesForItemBuffer; 226 227 int mItemBufferMode; 227 228 228 229 Real mVizCameraHeight;
Note: See TracChangeset
for help on using the changeset viewer.