Changeset 151
- Timestamp:
- 07/04/05 01:33:11 (20 years ago)
- Location:
- trunk/VUT/work
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
r147 r151 9 9 #include "OgreVisibilityTerrainSceneManager.h" 10 10 #include "VisibilityInfo.h" 11 11 #include "OgreItemBufferQueryManager.h"; 12 12 // output file for frame info 13 13 const char* frames_out_filename = "frame.out"; … … 82 82 mSunLight(sunLight), 83 83 mShiftPressed(false), 84 mShowQueryStats(false) 84 mShowQueryStats(false), 85 mQueryManager(NULL), 86 mVisibilityManager(NULL) 85 87 { 86 88 //mInputDevice = PlatformManager::getSingleton().createInputReader(); … … 164 166 mSceneMgr->setOption("PrepareVisualization", &mShowVisualization); 165 167 166 // TODO: change this (does not work with other scene manager plugins)167 mVisibilityManager = dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr)->168 GetVisibilityManager();169 170 dynamic_cast<PlatformQueryManager *>(mVisibilityManager->GetQueryManager())->171 SetViewport(mWindow->getViewport(0));172 173 168 // reset statistics 174 169 resetStats(); … … 179 174 delete mRayQueryExecutor; 180 175 delete mEventProcessor; 176 177 if (mQueryManager) 178 { 179 delete mQueryManager; 180 mQueryManager = NULL; 181 } 181 182 } 182 183 //----------------------------------------------------------------------- … … 361 362 void TerrainFrameListener::ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility) 362 363 { 364 // TODO: change this (does not work with other scene manager plugins) 365 VisibilityTerrainSceneManager *sm = dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr); 366 367 //mQueryManager = new ItemBufferQueryManager(sm->GetHierarchyInterface(), mWindow->getViewport(0)); 368 mQueryManager = new PlatformQueryManager(sm->GetHierarchyInterface(), mWindow->getViewport(0)); 369 370 sm->GetVisibilityManager()->SetQueryManager(mQueryManager); 371 363 372 InfoContainer<GtpVisibility::NodeInfo> visibleNodes; 364 373 InfoContainer<GtpVisibility::MeshInfo> visibleGeometry; … … 366 375 if (fromPoint) 367 376 { 368 m VisibilityManager->GetQueryManager()->377 mQueryManager-> 369 378 ComputeFromPointVisibility(mCamNode->getPosition(), &visibleNodes, 370 379 &visibleGeometry, relativeVisibility); … … 372 381 else 373 382 { 374 m VisibilityManager->GetQueryManager()->ComputeCameraVisibility(*mCamera,383 mQueryManager->ComputeCameraVisibility(*mCamera, 375 384 &visibleNodes, &visibleGeometry, relativeVisibility); 376 385 } … … 378 387 float averageNodeVis = 0; 379 388 float averageGeometryVis = 0; 389 int geomSize = 0; 390 int nodesSize = 0; 380 391 381 392 InfoContainer<GtpVisibility::MeshInfo>::iterator geomIt, geomIt_end = visibleGeometry.end(); … … 383 394 for (geomIt = visibleGeometry.begin(); geomIt != geomIt_end; ++geomIt) 384 395 { 385 float vis = relativeVisibility ? 386 (*geomIt).ComputeRelativeVisibility() : (float)(*geomIt).GetVisiblePixels(); 396 // add if not 0 397 if ((*geomIt).GetVisiblePixels()) 398 { 399 float vis = relativeVisibility ? 400 (*geomIt).ComputeRelativeVisibility() : (float)(*geomIt).GetVisiblePixels(); 401 402 averageGeometryVis += vis; 403 ++geomSize; 404 405 std::stringstream d; d << "Geometry visibility: " << vis; 406 LogManager::getSingleton().logMessage(d.str()); 407 } 408 } 409 410 InfoContainer<GtpVisibility::NodeInfo>::iterator nodesIt, nodesIt_end = visibleNodes.end(); 411 412 for (nodesIt = visibleNodes.begin(); nodesIt != nodesIt_end; ++nodesIt) 413 { 414 // add if not 0 415 if ((*nodesIt).GetVisiblePixels()) 416 { 417 float vis = relativeVisibility ? 418 (*nodesIt).ComputeRelativeVisibility() : (float)(*nodesIt).GetVisiblePixels(); 387 419 388 averageGeometryVis += vis; 389 390 std::stringstream d; d << "Geometry visibility: " << vis; 391 LogManager::getSingleton().logMessage(d.str()); 392 } 393 394 InfoContainer<GtpVisibility::NodeInfo>::iterator nodesIt, nodesIt_end = visibleNodes.end(); 395 396 for (nodesIt = visibleNodes.begin(); nodesIt != nodesIt_end; ++nodesIt) 397 { 398 float vis = relativeVisibility ? 399 (*nodesIt).ComputeRelativeVisibility() : (float)(*nodesIt).GetVisiblePixels(); 400 401 averageNodeVis += vis; 402 403 std::stringstream d; d << "Node visibility: " << vis; 404 LogManager::getSingleton().logMessage(d.str()); 405 } 406 407 if (visibleNodes.size()) 408 averageNodeVis /= (float)visibleNodes.size(); 409 if (visibleGeometry.size()) 410 averageGeometryVis /= (float)visibleGeometry.size(); 420 averageNodeVis += vis; 421 ++nodesSize; 422 423 std::stringstream d; d << "Node visibility: " << vis; 424 LogManager::getSingleton().logMessage(d.str()); 425 } 426 } 427 428 if (nodesSize) 429 averageNodeVis /= (float)nodesSize; 430 if (geomSize) 431 averageGeometryVis /= (float)geomSize; 411 432 412 433 char str[100]; … … 445 466 mShowQueryStats = true; 446 467 } 468 469 delete mQueryManager; 447 470 } 448 471 //----------------------------------------------------------------------- -
trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
r147 r151 11 11 #include "VisibilityManager.h" 12 12 #include "OgreTerrainContentGenerator.h" 13 #include "OgrePlatformQueryManager.h" 13 14 14 15 using namespace Ogre; … … 233 234 unsigned long mFrameCount; 234 235 //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 236 PlatformQueryManager *mQueryManager; 235 237 }; 236 238
Note: See TracChangeset
for help on using the changeset viewer.