- Timestamp:
- 07/03/07 14:29:17 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreOcclusionCullingSceneManager.h
r2360 r2502 253 253 /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer 254 254 bool mExecuteVertexProgramForAllPasses; 255 256 255 /// if hierarchical culling is currently in use 257 256 bool mIsHierarchicalCulling; … … 259 258 /// do we use preprocessed visibility 260 259 bool mViewCellsLoaded; 261 262 260 /// the view cells manager handling the preprocesor stuff 263 261 GtpVisibilityPreprocessor::ViewCellsManager *mViewCellsManager; 264 265 266 262 /// Used to assign Ogre meshes to view cell entries. 267 263 GtpVisibilityPreprocessor::ObjectContainer mObjects; 268 264 269 GtpVisibilityPreprocessor::ViewCell *mElementaryViewCell;265 /// the currently visible view cell 270 266 GtpVisibilityPreprocessor::ViewCell *mCurrentViewCell; 271 267 272 /// If view cells are used.268 /// If view cells + PVS is used for rendering. 273 269 bool mUseViewCells; 274 270 … … 276 272 bool mShowViewCells; 277 273 278 /// if the view cells are filtered 279 bool mUseVisibilityFilter; 280 274 /// if render queue should be flushed occasionally 281 275 bool mDeleteQueueAfterRendering; 282 276 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r2455 r2502 52 52 mViewCellsLoaded(false), 53 53 mUseViewCells(false), 54 mUseVisibilityFilter(false),55 54 mCurrentViewCell(NULL), 56 mElementaryViewCell(NULL),57 55 mDeleteQueueAfterRendering(true), 58 56 mNormalExecution(false), … … 113 111 { 114 112 CLEAR_CONTAINER(mObjects); 115 116 113 OGRE_DELETE(mHierarchyInterface); 117 OGRE_DELETE(mCurrentViewCell);118 119 114 OGRE_DELETE(mObjReader); 120 115 } … … 169 164 LoadScene(mFilename, mViewCellsFilename); 170 165 171 // load view cells: load later ...172 if (0) mViewCellsLoaded = LoadViewCells(mViewCellsFilename);173 174 166 if (mShowTerrain) 175 167 { … … 292 284 { 293 285 mShowTerrain = true; 294 LogManager::getSingleton().logMessage(" loading terrain");286 LogManager::getSingleton().logMessage("scene: loading terrain"); 295 287 } 296 288 else 297 289 { 298 290 mShowTerrain = false; 299 LogManager::getSingleton().logMessage(" loading geometry");291 LogManager::getSingleton().logMessage("scene: loading geometry"); 300 292 } 301 293 } … … 564 556 { 565 557 GtpVisibilityPreprocessor::ObjectPvsIterator pit = 566 558 mCurrentViewCell->GetPvs().GetIterator(); 567 559 568 560 while (pit.HasMoreEntries()) … … 587 579 //----------------------------------------------------------------------- 588 580 void OcclusionCullingSceneManager::ShowViewCellsGeometry() 589 {/* 581 { 582 #if TODO 590 583 // show only current view cell 591 584 if (!mShowViewCells) … … 607 600 (*mit).second->_updateRenderQueue(getRenderQueue()); 608 601 } 609 }*/ 602 } 603 #endif 610 604 } 611 605 //----------------------------------------------------------------------- … … 697 691 { 698 692 // show current view cell geometry 699 if (mCurrentViewCell) // && mCurrentViewCell->GetMesh())693 if (mCurrentViewCell) 700 694 { 701 695 //const bool showSingleViewCell = true; … … 882 876 mVisible.clear(); 883 877 mBoxes.clear(); 884 885 878 // clear render queue before depth pass 886 879 getRenderQueue()->clear(); … … 1122 1115 } 1123 1116 if (key == "UseViewCells") 1124 { 1125 if (!mViewCellsLoaded) 1126 { 1117 { 1118 bool useViewCells = *static_cast<const bool *>(val); 1119 1120 if (useViewCells && !mViewCellsLoaded) 1121 { 1127 1122 // try to load view cells 1128 1123 mViewCellsLoaded = LoadViewCells(mViewCellsFilename); 1129 }1130 1131 if (!mViewCellsLoaded)1132 return false;1133 1124 1125 if (!mViewCellsLoaded) 1126 // something went wrong => bail out 1127 return false; 1128 } 1129 1134 1130 // only use this option if view cells are available 1135 mUseViewCells = *static_cast<const bool *>(val); 1136 1137 // reset view cell 1138 OGRE_DELETE(mCurrentViewCell); 1139 1140 if (mUseViewCells) 1141 { 1142 mCurrentViewCell = mViewCellsManager->GenerateViewCell(); 1143 } 1144 1145 // view cell corresponding to leaf in the view cell hierarchy 1146 mElementaryViewCell = NULL; 1147 1148 // all objects are set to invisible per default 1149 SetObjectsVisible(!mUseViewCells); 1150 1131 mUseViewCells = useViewCells; 1132 1133 // reset current view cell 1134 mCurrentViewCell = NULL; 1135 1136 // if we don't use the view cells, all objects are set to invisible per default 1137 //SetObjectsVisible(!mUseViewCells); 1138 1139 // note: this sets the objects invisible which are not in the pvs ... 1151 1140 MovableObjectIterator movit = getMovableObjectIterator("Entity"); 1152 1141 while (movit.hasMoreElements()) … … 1181 1170 return true; 1182 1171 } 1183 if (key == "UseVisibilityFilter")1184 {1185 mUseVisibilityFilter = *static_cast<const bool *>(val);1186 1187 // set null => recomputation of the pvs1188 mElementaryViewCell = NULL;1189 1190 return true;1191 }1192 1172 if (key == "UseVisibilityQueries") 1193 1173 { 1194 1174 mUseVisibilityQueries = *static_cast<const bool *>(val); 1195 1196 1175 return true; 1197 1176 } … … 1199 1178 { 1200 1179 mUseFromPointQueries = *static_cast<const bool *>(val); 1201 1202 1180 return true; 1203 1181 } … … 1205 1183 { 1206 1184 mQueryMode = *static_cast<const int *>(val); 1207 1208 1185 return true; 1209 1186 } … … 1689 1666 { 1690 1667 GtpVisibilityPreprocessor::ObjectContainer::iterator it, it_end = mObjects.end(); 1691 1692 1668 for (it = mObjects.begin(); it != it_end; ++ it) 1693 { 1694 GtpVisibilityPreprocessor::Intersectable *entry = *it; 1695 1696 SetObjectVisible(entry, visible); 1697 } 1669 SetObjectVisible(*it, visible); 1698 1670 } 1699 1671 //----------------------------------------------------------------------- … … 1717 1689 mViewCellsManager = 1718 1690 GtpVisibilityPreprocessor::ViewCellsManager:: 1719 LoadViewCells(filename, mObjects, f alse, &bconverter);1691 LoadViewCells(filename, mObjects, finalizeViewCells, &bconverter); 1720 1692 1721 1693 LogManager::getSingleton().logMessage("******** view cells loaded *********"); 1722 1694 1723 1695 // objects are set to invisible initially 1724 SetObjectsVisible(false);1696 //SetObjectsVisible(false); 1725 1697 1726 1698 if (finalizeViewCells) 1727 {1728 1699 CreateViewCellsGeometry(); 1729 }1730 1700 1731 1701 return (mViewCellsManager != NULL); … … 1733 1703 //------------------------------------------------------------------------- 1734 1704 void OcclusionCullingSceneManager::ApplyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc, 1735 const bool load )1705 const bool loadObjects) 1736 1706 { 1737 // NOTE: should not encounter NULL view cell,1738 1707 // rather apply view cell representing unbounded space then 1739 1708 if (!vc) 1740 1709 { 1741 LogManager::getSingleton().logMessage(" error: should not come here");1710 LogManager::getSingleton().logMessage("no view cell or outside of view space, setting everything to invisible"); 1742 1711 // question: if no view cell, set everything visible? 1743 1712 SetObjectsVisible(false); … … 1746 1715 1747 1716 //////////// 1748 //-- set PVS of view cellto visible1717 //-- set view cell PVS to visible 1749 1718 1750 1719 GtpVisibilityPreprocessor::ObjectPvsIterator pit = vc->GetPvs().GetIterator(); … … 1753 1722 { 1754 1723 GtpVisibilityPreprocessor::Intersectable *obj = pit.Next(); 1755 1756 1724 // no associated geometry found 1757 1725 if (!obj) continue; 1758 1759 SetObjectVisible(obj, load); 1726 SetObjectVisible(obj, loadObjects); 1760 1727 } 1761 1728 } … … 1769 1736 OgreTypeConverter::ConvertFromOgre(cam->getDerivedPosition()); 1770 1737 1771 GtpVisibilityPreprocessor::ViewCell * newElementary=1738 GtpVisibilityPreprocessor::ViewCell *viewCell = 1772 1739 mViewCellsManager->GetViewCell(viewPoint); 1773 1740 1774 // elementaryview cell did not change => don't change pvs1775 if (m ElementaryViewCell == newElementary)1741 // view cell did not change => don't change pvs 1742 if (mCurrentViewCell == viewCell) 1776 1743 return; 1777 1744 1778 mElementaryViewCell = newElementary;1779 1780 1745 1781 1746 ////////////// 1782 //-- unload old pvs 1747 //-- unload old pvs and load new pvs 1783 1748 1784 1749 ApplyViewCellPvs(mCurrentViewCell, false); 1785 1750 1786 // the new view cell 1787 GtpVisibilityPreprocessor::ViewCell *viewCell; 1788 1789 if (mUseVisibilityFilter) 1790 { 1791 //////////// 1792 //-- compute new filtered cell 1793 1794 GtpVisibilityPreprocessor::PrVs prvs; 1795 mViewCellsManager->GetPrVS(viewPoint, prvs, 5); 1796 viewCell = prvs.mViewCell; 1797 } 1798 else 1799 { 1800 viewCell = newElementary; 1801 } 1802 1803 /////////////// 1804 //-- load new pvs 1805 1806 ApplyViewCellPvs(viewCell, true); 1807 1808 if (viewCell) 1809 { 1810 // store current view cell 1811 mCurrentViewCell->SetPvs(viewCell->GetPvs()); 1812 mCurrentViewCell->SetMesh(viewCell->GetMesh()); 1813 mCurrentViewCell->SetId(viewCell->GetId()); 1814 1815 // delete merge tree of filtered view cell 1816 if (mUseVisibilityFilter) 1817 mViewCellsManager->DeleteLocalMergeTree(viewCell); 1818 } 1751 mCurrentViewCell = viewCell; 1752 ApplyViewCellPvs(mCurrentViewCell, true); 1819 1753 } 1820 1754 //------------------------------------------------------------------------- … … 2089 2023 bool includeOverlays) 2090 2024 { 2091 if ( mNormalExecution)2025 if (0 && mNormalExecution) 2092 2026 { 2093 2027 TerrainSceneManager::_renderScene(camera, vp, includeOverlays); … … 2318 2252 std::stringstream d; 2319 2253 d << "Query mode: " << queryModes 2320 << " visible nodes: " << (int)visibleNodes.size()2321 << " visible geometry: " << (int)visibleGeometry.size();2254 << ", visible nodes: " << (int)visibleNodes.size() 2255 << ", visible geometry: " << (int)visibleGeometry.size(); 2322 2256 2323 2257 LogManager::getSingleton().logMessage(d.str()); … … 2545 2479 bool onlyShadowCasters) 2546 2480 { 2547 if (mNormalExecution || (!mUseVisibilityQueries == 0))2481 if (mNormalExecution || !mUseVisibilityQueries) 2548 2482 { 2549 2483 TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters); … … 2567 2501 int queryModes = 0; 2568 2502 2569 if (mQueryMode != 0)2503 if (mQueryMode != EXACT_QUERIES) 2570 2504 { 2571 2505 queryModes |= GtpVisibility::QueryManager::NODE_VISIBILITY; 2572 2506 2573 if (mQueryMode == 2) 2507 // approximate visibility not for exact queries 2508 if (mQueryMode == APPROXIMATE_QUERIES) 2574 2509 approximateVisibility = true; 2575 2510 } … … 2611 2546 } 2612 2547 2613 if ( 0)2548 if (1) 2614 2549 { 2615 2550 std::stringstream d; -
GTP/trunk/Lib/Vis/OnlineCullingCHC/src/RandomUpdateCullingManager.cpp
r2497 r2502 101 101 else 102 102 { 103 // fully visible subtree => render all in one bat hc103 // fully visible subtree => render all in one batch 104 104 if (mHierarchyInterface->IsNodeFullyVisible(node)) 105 105 { … … 124 124 mHierarchyInterface->SetNodeVisible(leaf, false); 125 125 126 // update node's visited flag 126 // update node's visited flag: this is important as we are not testing 127 // all nodes in the hierarchy in this mode 127 128 mHierarchyInterface->PullUpLastVisited(leaf, mHierarchyInterface->GetFrameId()); 128 129 const bool testGeometry =mTestGeometryForVisibleLeaves; 130 129 // issue the query 131 130 mHierarchyInterface->IssueNodeOcclusionQuery(node, mTestGeometryForVisibleLeaves); 132 131 }
Note: See TracChangeset
for help on using the changeset viewer.