- Timestamp:
- 03/02/07 13:13:24 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r2176 r2183 25 25 #include "ObjReader.h" 26 26 #include "OgreOcclusionQueriesQueryManager.h" 27 #include "VisibilityInfo.h" 28 #include "Preprocessor.h" 27 29 28 30 … … 706 708 707 709 // standard rendering in first pass 708 if (!mNormalExecution && mUseDepthPass) 710 // hierarchical culling interleaves identification 711 // and rendering of objects in _renderVisibibleObjects 712 713 // for the shadow pass we use only standard rendering 714 // because shadows have low occlusion anyway 715 if ((mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 716 mIlluminationStage == IRS_RENDER_TO_TEXTURE) || 717 mNormalExecution) 718 { 719 OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 720 } 721 else if (mUseDepthPass) 709 722 { 710 723 RenderDepthPass(); 711 724 } 712 else 713 { 714 // hierarchical culling interleaves identification 715 // and rendering of objects in _renderVisibibleObjects 716 717 // for the shadow pass we use only standard rendering 718 // because shadows have low occlusion anyway 719 if ((mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && 720 mIlluminationStage == IRS_RENDER_TO_TEXTURE) || 721 mNormalExecution) 722 { 723 OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 724 } 725 726 // only shadow casters will be rendered in shadow texture pass 727 //if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 728 } 725 726 // only shadow casters will be rendered in shadow texture pass 727 //if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 729 728 } 730 729 //----------------------------------------------------------------------- … … 1087 1086 return false; 1088 1087 1089 const bool fromPoint = true;1088 const bool fromPoint = false; 1090 1089 const bool nodeVisibility = true; 1091 1090 … … 1397 1396 1398 1397 // possible two cameras (one for culling, one for rendering) 1399 mHierarchyInterface->InitTraversal( mCameraInProgress,1398 mHierarchyInterface->InitTraversal(cam, 1400 1399 mCullCamera ? getCamera("CullCamera") : NULL, 1401 1400 mLeavePassesInQueue); … … 2311 2310 } 2312 2311 //----------------------------------------------------------------------- 2312 void OcclusionCullingSceneManager::AddVisibleMeshGeometryToQueue(const GtpVisibility::MeshInfoContainer &visibleGeometry, 2313 Camera *cam) 2314 { 2315 GtpVisibility::MeshInfoContainer::const_iterator geomIt, geomIt_end = visibleGeometry.end(); 2316 2317 for (geomIt = visibleGeometry.begin(); geomIt != geomIt_end; ++geomIt) 2318 { 2319 MovableObject *mo = (*geomIt).GetSource(); 2320 2321 // add if not 0 2322 if (!(*geomIt).GetVisiblePixels()) 2323 continue; 2324 2325 mo->_notifyCurrentCamera(cam); 2326 2327 if (mo->isVisible()) 2328 { 2329 mo->_updateRenderQueue(getRenderQueue()); 2330 } 2331 } 2332 } 2333 //----------------------------------------------------------------------- 2334 void OcclusionCullingSceneManager::AddVisibleNodeGeometryToQueue(const GtpVisibility::NodeInfoContainer &visibleNodes, 2335 Camera *cam) 2336 { 2337 //////////////// 2338 //-- apply queries on node level 2339 2340 GtpVisibility::NodeInfoContainer::const_iterator nodesIt, nodesIt_end = visibleNodes.end(); 2341 2342 for (nodesIt = visibleNodes.begin(); nodesIt != nodesIt_end; ++ nodesIt) 2343 { 2344 if (!(*nodesIt).GetVisiblePixels()) 2345 continue; 2346 2347 Octree *octree = static_cast<Octree *>((*nodesIt).GetSource()); 2348 2349 NodeList::iterator nIt, nIt_end = octree->mNodes.end(); 2350 2351 for (nIt = octree->mNodes.begin(); nIt != nIt_end; ++ nIt) 2352 { 2353 (*nIt)->_addToRenderQueue(cam, getRenderQueue(), false); 2354 } 2355 } 2356 } 2357 //----------------------------------------------------------------------- 2358 void OcclusionCullingSceneManager::_findVisibleObjects(Camera* cam, 2359 bool onlyShadowCasters) 2360 { 2361 // lists only used for visualization 2362 mVisible.clear(); 2363 mBoxes.clear(); 2364 2365 const bool fromPoint = false; 2366 const bool nodeVisibility = false; 2367 2368 const int itemBufferMode = 0; 2369 const bool relativeVisibility = false; 2370 2371 int queryModes = 0; 2372 2373 if (nodeVisibility) 2374 queryModes |= GtpVisibility::QueryManager::NODE_VISIBILITY; 2375 else 2376 queryModes |= GtpVisibility::QueryManager::GEOMETRY_VISIBILITY; 2377 2378 OcclusionQueriesQueryManager *queryManager = 2379 new OcclusionQueriesQueryManager(mHierarchyInterface, 2380 mCurrentViewport, 2381 queryModes, 2382 itemBufferMode); 2383 2384 mVisibilityManager->SetQueryManager(queryManager); 2385 2386 GtpVisibility::NodeInfoContainer visibleNodes; 2387 GtpVisibility::MeshInfoContainer visibleGeometry; 2388 GtpVisibility::PatchInfoContainer visiblePatches; 2389 2390 if (fromPoint) 2391 { 2392 queryManager->ComputeFromPointVisibility(cam->getDerivedPosition(), 2393 &visibleNodes, 2394 &visibleGeometry, 2395 &visiblePatches, 2396 relativeVisibility); 2397 } 2398 else 2399 { 2400 queryManager->ComputeCameraVisibility(*cam, 2401 &visibleNodes, 2402 &visibleGeometry, 2403 &visiblePatches, 2404 relativeVisibility); 2405 } 2406 2407 if (0) 2408 { 2409 std::stringstream d; 2410 d << "Query mode: " << queryModes 2411 << " visible nodes: " << (int)visibleNodes.size() 2412 << " visible geometry: " << (int)visibleGeometry.size(); 2413 2414 LogManager::getSingleton().logMessage(d.str()); 2415 } 2416 2417 /////////////////////// 2418 //-- put items in render queue 2419 ////////// 2420 2421 //getRenderQueue()->clear(); 2422 2423 ////////////////////// 2424 //-- apply queries on geometry level 2425 2426 if (!nodeVisibility) 2427 { 2428 AddVisibleMeshGeometryToQueue(visibleGeometry, cam); 2429 } 2430 else 2431 { 2432 AddVisibleNodeGeometryToQueue(visibleNodes, cam); 2433 } 2434 2435 delete queryManager; 2436 } 2437 2438 //----------------------------------------------------------------------- 2313 2439 void OcclusionCullingSceneManagerFactory::destroyInstance(SceneManager* instance) 2314 2440 {
Note: See TracChangeset
for help on using the changeset viewer.