Changeset 726 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Timestamp:
- 04/04/06 23:55:38 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgrePlatformHierarchyInterface.h
r187 r726 153 153 std::vector<PlatformOcclusionQuery *> mOcclusionQueries; 154 154 155 Vector3 mCameraPosition; 155 156 bool mOnlyShadowCasters; 156 157 int mLeavePassesInQueue; -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreVisibilityTerrainSceneManager.h
r347 r726 11 11 #include "OgrePlatformQueryManager.h" 12 12 #include "VisibilityManager.h" 13 14 13 15 14 namespace Ogre { … … 56 55 virtual void renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs, 57 56 bool doLightIteration, const LightList* manualLightList = 0); 58 59 57 /** Writes out stats into the Ogre log file. 60 58 */ 61 59 void WriteLog(); 62 60 63 /** Override pass so we can dothe z-fail pass.61 /** We override this because we want to include the z-fail pass. 64 62 */ 65 63 Pass* setPass(Pass* pass); 66 67 64 /** Override from SceneManager so we can skip all but first pass for depth pass. 68 65 */ 69 66 bool validatePassForRendering(Pass* pass); 70 67 /** This function renders renderables using false color ids. 68 */ 71 69 void RenderItemBuffer(RenderPriorityGroup* pGroup); 70 /** Renders a single object using false color id. 71 */ 72 72 void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass); 73 /** Overritten from scene manager to include the false color id rendering of the 74 scene objects. 75 */ 73 76 void renderQueueGroupObjects(RenderQueueGroup* pGroup); 74 77 … … 89 92 void endFrame(); 90 93 94 /** Override this because we must handle shadows differently. 95 */ 91 96 void renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup); 97 /** Override this because we must handle shadows differently. 98 */ 92 99 void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup); 93 94 /** Override standard function so octree boxes are always of equal side length.95 This has advantages for CHC, because terrain tiles are in different octree nodes96 and can be culled.97 */98 void setWorldGeometry( const String& filename );99 100 100 101 protected: … … 161 162 162 163 bool mIsHierarchicalCulling; 164 165 std::ofstream mDummyLog; 163 166 }; 164 167 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj
r722 r726 94 94 BufferSecurityCheck="FALSE" 95 95 EnableFunctionLevelLinking="TRUE" 96 RuntimeTypeInfo=" TRUE"96 RuntimeTypeInfo="FALSE" 97 97 UsePrecompiledHeader="0" 98 98 WarningLevel="3" … … 227 227 RelativePath="..\include\OgreVisibilitySceneManager.h"> 228 228 </File> 229 <File 230 RelativePath="..\include\VspBspTree.h"> 231 </File> 229 232 </Filter> 230 233 <Filter -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r720 r726 380 380 381 381 getRenderQueue()->clear(); // finally clear render queue 382 OGRE_DELETE(mRenderQueue); // HACK: should be cleared before ...382 OGRE_DELETE(mRenderQueue); // HACK: should be cleared before ... 383 383 WriteLog(); // write out stats 384 384 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp
r645 r726 27 27 // we need access to the scene manager and the rendersystem 28 28 PlatformHierarchyInterface *pfHierarchyInterface = 29 dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface); 29 //dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface); 30 static_cast<PlatformHierarchyInterface *>(mHierarchyInterface); 30 31 31 32 // disable overlays, reset them later -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOctreeHierarchyInterface.cpp
r722 r726 21 21 22 22 // if we come across some renderable geometry => render it 23 if ( octree->mNodes.size() > 0)23 if (!octree->mNodes.empty()) 24 24 { 25 25 RenderNode(node); 26 26 } 27 27 28 // if (octree->numNodes() > (int)octree->mNodes.size()) //if not all subtrees are empty28 // if not all subtrees are empty 29 29 if (!IsLeaf(node)) 30 30 { 31 for(int i=0; i<8; ++i) 32 { 33 Octree *nextChild = 34 octree->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1]; 35 36 if (nextChild) 37 { 38 mDistanceQueue->push(nextChild); 39 } 40 } 31 Octree *nextChild; 32 33 if ((nextChild = octree->mChildren[0][0][0]) != NULL) 34 mDistanceQueue->push(nextChild); 35 if ((nextChild = octree->mChildren[0][0][1]) != NULL) 36 mDistanceQueue->push(nextChild); 37 if ((nextChild = octree->mChildren[0][1][0]) != NULL) 38 mDistanceQueue->push(nextChild); 39 if ((nextChild = octree->mChildren[0][1][1]) != NULL) 40 mDistanceQueue->push(nextChild); 41 if ((nextChild = octree->mChildren[1][0][0]) != NULL) 42 mDistanceQueue->push(nextChild); 43 if ((nextChild = octree->mChildren[1][0][1]) != NULL) 44 mDistanceQueue->push(nextChild); 45 if ((nextChild = octree->mChildren[1][1][0]) != NULL) 46 mDistanceQueue->push(nextChild); 47 if ((nextChild = octree->mChildren[1][1][1]) != NULL) 48 mDistanceQueue->push(nextChild); 41 49 } 42 50 } … … 56 64 float OctreeHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 57 65 { 58 LogManager::getSingleton().logMessage("here4"); 66 const Vector3 bmin = static_cast<Octree *>(node)->mBox.getMinimum(); 67 const Vector3 bmax = static_cast<Octree *>(node)->mBox.getMaximum(); 59 68 60 const AxisAlignedBox &box = static_cast<Octree *>(node)->mBox; 61 const Vector3 pos = ((box.getMaximum() - box.getMinimum()) * 0.5) + box.getMinimum(); 69 const Vector3 pos = (bmax - bmin) * 0.5 + bmin; 62 70 63 return (mC ullCamera->getDerivedPosition()- pos).squaredLength();71 return (mCameraPosition - pos).squaredLength(); 64 72 } 65 73 //----------------------------------------------------------------------- … … 101 109 { 102 110 octant->setLastRendered(mFrameId); 103 104 dynamic_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera, 105 octant, mOnlyShadowCasters, mLeavePassesInQueue); 111 OctreeSceneManager *ocm = 112 //dynamic_cast<OctreeSceneManager *>(mSceneManager); 113 static_cast<OctreeSceneManager *>(mSceneManager); 114 ocm->_renderOctant(mCamera, octant, mOnlyShadowCasters, mLeavePassesInQueue); 106 115 107 116 mVisibleNodes.push_back(node); … … 155 164 } 156 165 157 dynamic_cast<OctreeSceneManager *>(mSceneManager)->getBoxes()->push_back(box); 166 //dynamic_cast<OctreeSceneManager *>(mSceneManager)->getBoxes()->push_back(box); 167 static_cast<OctreeSceneManager *>(mSceneManager)->getBoxes()->push_back(box); 158 168 } 159 169 //----------------------------------------------------------------------- 160 void OctreeHierarchyInterface::GetNodeGeometryList(GtpVisibility::HierarchyNode *node, 161 GtpVisibility::GeometryVector *geometryList,162 bool includeChildren)170 void OctreeHierarchyInterface::GetNodeGeometryList(GtpVisibility::HierarchyNode *node, 171 GtpVisibility::GeometryVector *geometryList, 172 bool includeChildren) 163 173 { 164 174 NodeList::const_iterator nodeIt, nodeIt_end; -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformHierarchyInterface.cpp
r316 r726 11 11 12 12 //----------------------------------------------------------------------- 13 PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys): 14 mSceneManager(sm), mRenderSystem(rsys), mSolidBoundingBox(NULL), mCamera(NULL), 15 mCullCamera(NULL), mOnlyShadowCasters(false), mLeavePassesInQueue(0), 16 mIsBoundingBoxQuery(false) 13 PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, 14 RenderSystem *rsys): 15 mSceneManager(sm), 16 mRenderSystem(rsys), 17 mSolidBoundingBox(NULL), 18 mCamera(NULL), 19 mCullCamera(NULL), 20 mOnlyShadowCasters(false), 21 mLeavePassesInQueue(0), 22 mIsBoundingBoxQuery(false), 23 mCameraPosition(Vector3(0, 0, 0)) 17 24 { 18 25 } … … 131 138 mCullCamera = cullCam ? cullCam : cam; 132 139 140 mCameraPosition = mCullCamera->getDerivedPosition(); 133 141 // create materials for node visualization 134 142 CreateNodeVizMaterials(); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgrePlatformQueryManager.cpp
r316 r726 31 31 bool relativeVisibility) 32 32 { 33 SceneManager *sm = dynamic_cast<PlatformHierarchyInterface *> 33 SceneManager *sm = //dynamic_cast<PlatformHierarchyInterface *> 34 static_cast<PlatformHierarchyInterface *> 34 35 (mHierarchyInterface)->GetSceneManager(); 35 36 … … 93 94 // we need access to the scene manager and the rendersystem 94 95 PlatformHierarchyInterface *pfHierarchyInterface = 95 dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface); 96 //dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface); 97 static_cast<PlatformHierarchyInterface *>(mHierarchyInterface); 96 98 97 99 SceneManager *sm = pfHierarchyInterface->GetSceneManager(); … … 189 191 190 192 SceneManager *sm = 191 dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->GetSceneManager(); 193 //dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->GetSceneManager(); 194 static_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->GetSceneManager(); 192 195 193 196 SceneManager::EntityIterator it = sm->getEntityIterator(); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityOctreeSceneManager.cpp
r720 r726 24 24 mLeavePassesInQueue(0), 25 25 mDelayRenderTransparents(true), 26 //mDelayRenderTransparents(false),27 //mUseDepthPass(true),28 26 mUseDepthPass(false), 29 27 mIsDepthPassPhase(false), 30 28 mUseItemBuffer(false), 31 //mUseItemBuffer(true),32 29 mIsItemBufferPhase(false), 33 30 mCurrentEntityId(1), -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityTerrainSceneManager.cpp
r720 r726 10 10 #include <OgreSubEntity.h> 11 11 12 // HACK 13 const static DEBUG_CHC = false; 12 13 // normal terrain rendering 14 const static NORMAL_RENDER_HACK = false; 14 15 15 16 namespace Ogre { … … 17 18 //----------------------------------------------------------------------- 18 19 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 19 GtpVisibility::VisibilityManager *visManager): 20 GtpVisibility::VisibilityManager *visManager): 21 TerrainSceneManager(), 20 22 mVisibilityManager(visManager), 21 23 mShowVisualization(false), … … 28 30 mIsDepthPassPhase(false), 29 31 mUseItemBuffer(false), 30 //mUseItemBuffer(true),31 32 mIsItemBufferPhase(false), 32 33 mCurrentEntityId(1), … … 101 102 //mItemBufferPass->setAmbient(1, 1, 0); 102 103 } 103 //-------------------------------------------------------------------------104 void VisibilityTerrainSceneManager::setWorldGeometry( const String& filename )105 {106 // Clear out any existing world resources (if not default)107 if (ResourceGroupManager::getSingleton().getWorldResourceGroupName() !=108 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME)109 {110 ResourceGroupManager::getSingleton().clearResourceGroup(111 ResourceGroupManager::getSingleton().getWorldResourceGroupName());112 }113 114 mTerrainPages.clear();115 116 // Load the configuration117 loadConfig(filename);118 119 // Resize the octree, allow for 1 page for now120 float max_x = mOptions.scale.x * mOptions.pageSize;121 float max_y = mOptions.scale.y;122 float max_z = mOptions.scale.z * mOptions.pageSize;123 124 float maxAxis = std::max(max_x, max_y);125 maxAxis = std::max(maxAxis, max_z);126 resize(AxisAlignedBox(0, 0, 0, maxAxis, maxAxis, maxAxis));127 128 setupTerrainMaterial();129 setupTerrainPages();130 }131 132 104 //----------------------------------------------------------------------- 133 105 void VisibilityTerrainSceneManager::PrepareVisualization(Camera *cam) … … 146 118 // ignore 147 119 } 120 // add bounding boxes of rendered objects 148 121 for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 149 122 { 150 123 getRenderQueue()->addRenderable(*it); 151 124 } 125 152 126 if (mRenderNodesForViz || mRenderNodesContentForViz) 153 127 { … … 182 156 Pass *VisibilityTerrainSceneManager::setPass(Pass* pass) 183 157 { 158 if (NORMAL_RENDER_HACK) 159 { 160 return SceneManager::setPass(pass); 161 } 162 184 163 // TODO: setting vertex program is not efficient 185 164 //Pass *usedPass = ((mIsDepthPassPhase && !pass->hasVertexProgram()) ? mDepthPass : pass); 186 165 187 166 // set depth fill pass if we currently do not make an aabb occlusion query 188 const bool useDepthPass = 1 &&167 const bool useDepthPass = 189 168 (mIsDepthPassPhase && !mHierarchyInterface->IsBoundingBoxQuery()); 190 169 … … 196 175 // set illumination stage to NONE so no shadow material is used 197 176 // for depth pass or for occlusion query 198 if (1 && 199 (mIsDepthPassPhase || mHierarchyInterface->IsBoundingBoxQuery())) 177 if (mIsDepthPassPhase || mHierarchyInterface->IsBoundingBoxQuery()) 200 178 { 201 179 mIlluminationStage = IRS_NONE; … … 203 181 204 182 // --- set vertex program of current pass in order to set correct depth 205 if (mExecuteVertexProgramForAllPasses 206 && mIsDepthPassPhase207 &&pass->hasVertexProgram())183 if (mExecuteVertexProgramForAllPasses && 184 mIsDepthPassPhase && 185 pass->hasVertexProgram()) 208 186 { 209 187 // add vertex program of current pass to depth pass … … 254 232 bool onlyShadowCasters) 255 233 { 234 if (NORMAL_RENDER_HACK) 235 { 236 TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 237 return; 238 } 239 256 240 //-- show visible scene nodes and octree bounding boxes from last frame 257 241 if (mShowVisualization) … … 273 257 274 258 // only shadow casters will be rendered in shadow texture pass 275 if (0) 276 mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 259 if (0) mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 277 260 } 278 261 … … 285 268 void VisibilityTerrainSceneManager::_renderVisibleObjects() 286 269 { 270 if (NORMAL_RENDER_HACK) 271 { 272 TerrainSceneManager::_renderVisibleObjects(); 273 274 return; 275 } 276 287 277 InitDepthPass(); // create material for depth pass 288 278 InitItemBufferPass(); // create material for item buffer pass … … 309 299 } 310 300 else //-- the hierarchical culling algorithm 311 { 301 { 302 // from TerrainSceneManager 303 mDestRenderSystem -> setLightingEnabled(false); 304 312 305 // don't render backgrounds for item buffer 313 306 if (mUseItemBuffer) … … 327 320 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 328 321 329 TerrainSceneManager::_renderVisibleObjects();322 OctreeSceneManager::_renderVisibleObjects(); 330 323 ///////////////////////////////////////////////// 331 324 … … 356 349 mVisibilityManager->ApplyVisibilityCulling(); 357 350 358 // delete remaining renderables from queue (all not in mLeavePassesInQueue) 351 // delete remaining renderables from queue: 352 // all which are not in mLeavePassesInQueue) 359 353 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 360 354 _deleteRenderedQueueGroups(mLeavePassesInQueue); … … 367 361 mLeavePassesInQueue = 0; 368 362 369 363 #if 1 370 364 // add visible nodes found by the visibility culling algorithm 371 #if 1372 365 if (mUseDepthPass) 373 366 { 374 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++ it) 367 NodeList::const_iterator it, it_end = mVisible.end(); 368 369 //getRenderQueue()->clear(); 370 for (it = mVisible.begin(); it != it_end; ++ it) 375 371 { 376 372 (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); … … 382 378 clearSpecialCaseRenderQueues(); 383 379 384 if (!DEBUG_CHC) 385 TerrainSceneManager::_renderVisibleObjects(); 380 OctreeSceneManager::_renderVisibleObjects(); 386 381 } 387 382 … … 394 389 395 390 getRenderQueue()->clear(); // finally clear render queue 396 OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared...397 398 //WriteLog(); // write out stats391 if (0) OGRE_DELETE(mRenderQueue); // HACK: should rather only be cleared ... 392 393 if (0) WriteLog(); // write out stats 399 394 } 400 395 … … 402 397 void VisibilityTerrainSceneManager::_updateSceneGraph(Camera* cam) 403 398 { 399 if (NORMAL_RENDER_HACK) 400 { 401 TerrainSceneManager::_updateSceneGraph(cam); 402 return; 403 } 404 404 405 mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface); 405 406 mHierarchyInterface->SetRenderSystem(mDestRenderSystem); … … 531 532 } 532 533 //----------------------------------------------------------------------- 533 GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::getVisibilityManager( void)534 GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::getVisibilityManager() 534 535 { 535 536 return mVisibilityManager; … … 549 550 << "Query culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumQueryCulledNodes() << ", " 550 551 << "Frustum culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumFrustumCulledNodes() << ", " 551 << "Queries issued: " << mVisibilityManager->GetCullingManager()->GetNumQueriesIssued() << "\n"; 552 << "Queries issued: " << mVisibilityManager->GetCullingManager()->GetNumQueriesIssued() << ", " 553 << "Found objects: " << (int)mVisible.size() << "\n"; 552 554 553 555 LogManager::getSingleton().logMessage(d.str()); … … 560 562 { 561 563 // for correct rendering, transparents must be rendered after hierarchical culling 562 if (1 && !mSkipTransparents) 563 { 564 OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList); 564 // => do nothing 565 if (NORMAL_RENDER_HACK || !mSkipTransparents) 566 { 567 SceneManager::renderObjects(objs, doLightIteration, manualLightList); 565 568 } 566 569 } 567 570 //----------------------------------------------------------------------- 568 571 bool VisibilityTerrainSceneManager::validatePassForRendering(Pass* pass) 569 { 572 { 573 if (NORMAL_RENDER_HACK) 574 { 575 return SceneManager::validatePassForRendering(pass); 576 } 577 570 578 // skip all but first pass if we are doing the depth pass 571 579 if ((mIsDepthPassPhase || mIsItemBufferPhase) && (pass->getIndex() > 0)) … … 584 592 void VisibilityTerrainSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 585 593 { 586 if ( !mIsItemBufferPhase)587 { 588 TerrainSceneManager::renderQueueGroupObjects(pGroup);594 if (NORMAL_RENDER_HACK || !mIsItemBufferPhase) 595 { 596 SceneManager::renderQueueGroupObjects(pGroup); 589 597 return; 590 598 } … … 616 624 continue; 617 625 618 // Render only first pass 626 // Render only first pass of renderable as false color 619 627 if (ipass->first->getIndex() > 0) 620 628 continue; … … 627 635 for (irend = rendList->begin(); irend != irendend; ++irend) 628 636 { 629 std::stringstream d; d << "itembuffer, pass name: " << 637 if (0) 638 { 639 std::stringstream d; d << "itembuffer, pass name: " << 630 640 ipass->first->getParent()->getParent()->getName(); 631 632 //LogManager::getSingleton().logMessage(d.str());641 LogManager::getSingleton().logMessage(d.str()); 642 } 633 643 634 644 RenderSingleObjectForItemBuffer(*irend, ipass->first); … … 636 646 } 637 647 638 // -- TRANSPARENT LOOP: must be handled differently648 //-- TRANSPARENT LOOP: must be handled differently from solids 639 649 640 650 // transparents are treated either as solids or completely discarded … … 729 739 mLeavePassesInQueue = 0; 730 740 731 if (! DEBUG_CHC && !mUseDepthPass && !mUseItemBuffer)741 if (!mUseDepthPass && !mUseItemBuffer) 732 742 { 733 743 if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) … … 760 770 // skip rendering transparents during the hierarchical culling 761 771 // (because they will be rendered afterwards) 762 mSkipTransparents = !DEBUG_CHC &&772 mSkipTransparents = 763 773 (mIsDepthPassPhase || (mLeavePassesInQueue & RenderPriorityGroup::TRANSPARENT_PASSES)); 764 774 … … 800 810 } 801 811 //----------------------------------------------------------------------- 802 void VisibilityTerrainSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 812 void VisibilityTerrainSceneManager::renderAdditiveStencilShadowedQueueGroupObjects( 813 RenderQueueGroup* pGroup) 803 814 { 804 815 // only render solid passes during hierarchical culling … … 832 843 } 833 844 //----------------------------------------------------------------------- 834 void VisibilityTerrainSceneManager::renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 845 void VisibilityTerrainSceneManager::renderModulativeStencilShadowedQueueGroupObjects( 846 RenderQueueGroup* pGroup) 835 847 { 836 848 if (mIsHierarchicalCulling)
Note: See TracChangeset
for help on using the changeset viewer.