Changeset 174 for trunk/VUT/Ogre
- Timestamp:
- 07/14/05 09:06:16 (20 years ago)
- Location:
- trunk/VUT/Ogre
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.