- Timestamp:
- 03/06/06 09:17:09 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj
r672 r675 150 150 Filter=""> 151 151 <File 152 RelativePath="..\include\OgreOcclusionCullingSceneManager.h"> 153 </File> 154 <File 152 155 RelativePath="..\include\OgreOctreeHierarchyInterface.h"> 153 156 </File> … … 167 170 <File 168 171 RelativePath="..\src\OgreBspHierarchyInterface.cpp"> 172 </File> 173 <File 174 RelativePath="..\src\OgreOcclusionCullingSceneManager.cpp"> 169 175 </File> 170 176 <File -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilityTerrainSceneManager.cpp
r347 r675 1 #include "Ogre VisibilityTerrainSceneManager.h"1 #include "OgreOcclusionCullingSceneManager.h" 2 2 #include "OgreVisibilityOptionsManager.h" 3 3 #include <OgreMath.h> … … 14 14 15 15 //----------------------------------------------------------------------- 16 VisibilityTerrainSceneManager::VisibilityTerrainSceneManager(16 OcclusionCullingSceneManager::OcclusionCullingSceneManager( 17 17 GtpVisibility::VisibilityManager *visManager): 18 18 mVisibilityManager(visManager), … … 45 45 } 46 46 //----------------------------------------------------------------------- 47 void VisibilityTerrainSceneManager::InitDepthPass()47 void OcclusionCullingSceneManager::InitDepthPass() 48 48 { 49 49 MaterialPtr depthMat = MaterialManager::getSingleton().getByName("Visibility/DepthPass"); … … 66 66 } 67 67 //----------------------------------------------------------------------- 68 VisibilityTerrainSceneManager::~VisibilityTerrainSceneManager()68 OcclusionCullingSceneManager::~OcclusionCullingSceneManager() 69 69 { 70 70 OGRE_DELETE(mHierarchyInterface); 71 71 } 72 72 //----------------------------------------------------------------------- 73 void VisibilityTerrainSceneManager::InitItemBufferPass()73 void OcclusionCullingSceneManager::InitItemBufferPass() 74 74 { 75 75 MaterialPtr itemBufferMat = MaterialManager::getSingleton(). … … 95 95 } 96 96 //------------------------------------------------------------------------- 97 void VisibilityTerrainSceneManager::setWorldGeometry( const String& filename )97 void OcclusionCullingSceneManager::setWorldGeometry( const String& filename ) 98 98 { 99 99 // Clear out any existing world resources (if not default) … … 124 124 125 125 //----------------------------------------------------------------------- 126 void VisibilityTerrainSceneManager::PrepareVisualization(Camera *cam)126 void OcclusionCullingSceneManager::PrepareVisualization(Camera *cam) 127 127 { 128 128 // add player camera for visualization purpose … … 173 173 } 174 174 //----------------------------------------------------------------------- 175 Pass * VisibilityTerrainSceneManager::setPass(Pass* pass)175 Pass *OcclusionCullingSceneManager::setPass(Pass* pass) 176 176 { 177 177 // TODO: setting vertex program is not efficient … … 236 236 } 237 237 //----------------------------------------------------------------------- 238 void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam,238 void OcclusionCullingSceneManager::_findVisibleObjects(Camera* cam, 239 239 bool onlyShadowCasters) 240 240 { … … 266 266 } 267 267 //----------------------------------------------------------------------- 268 void VisibilityTerrainSceneManager::_renderVisibleObjects()268 void OcclusionCullingSceneManager::_renderVisibleObjects() 269 269 { 270 270 … … 354 354 if (mUseDepthPass) 355 355 { 356 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++ it)356 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++ it) 357 357 { 358 358 (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); … … 381 381 382 382 //----------------------------------------------------------------------- 383 void VisibilityTerrainSceneManager::_updateSceneGraph(Camera* cam)383 void OcclusionCullingSceneManager::_updateSceneGraph(Camera* cam) 384 384 { 385 385 mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface); … … 389 389 } 390 390 //----------------------------------------------------------------------- 391 bool VisibilityTerrainSceneManager::setOption(const String & key, const void * val)391 bool OcclusionCullingSceneManager::setOption(const String & key, const void * val) 392 392 { 393 393 if (key == "UseDepthPass") … … 482 482 } 483 483 //----------------------------------------------------------------------- 484 bool VisibilityTerrainSceneManager::getOption(const String & key, void *val)484 bool OcclusionCullingSceneManager::getOption(const String & key, void *val) 485 485 { 486 486 if (key == "NumHierarchyNodes") … … 494 494 } 495 495 //----------------------------------------------------------------------- 496 bool VisibilityTerrainSceneManager::getOptionValues(const String & key,496 bool OcclusionCullingSceneManager::getOptionValues(const String & key, 497 497 StringVector &refValueList) 498 498 { … … 500 500 } 501 501 //----------------------------------------------------------------------- 502 bool VisibilityTerrainSceneManager::getOptionKeys(StringVector & refKeys)502 bool OcclusionCullingSceneManager::getOptionKeys(StringVector & refKeys) 503 503 { 504 504 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). … … 506 506 } 507 507 //----------------------------------------------------------------------- 508 void VisibilityTerrainSceneManager::setVisibilityManager(GtpVisibility::508 void OcclusionCullingSceneManager::setVisibilityManager(GtpVisibility:: 509 509 VisibilityManager *visManager) 510 510 { … … 512 512 } 513 513 //----------------------------------------------------------------------- 514 GtpVisibility::VisibilityManager * VisibilityTerrainSceneManager::getVisibilityManager( void )514 GtpVisibility::VisibilityManager *OcclusionCullingSceneManager::getVisibilityManager( void ) 515 515 { 516 516 return mVisibilityManager; 517 517 } 518 518 //----------------------------------------------------------------------- 519 void VisibilityTerrainSceneManager::WriteLog()519 void OcclusionCullingSceneManager::WriteLog() 520 520 { 521 521 std::stringstream d; … … 535 535 } 536 536 //----------------------------------------------------------------------- 537 void VisibilityTerrainSceneManager::renderObjects(537 void OcclusionCullingSceneManager::renderObjects( 538 538 const RenderPriorityGroup::TransparentRenderablePassList& objs, 539 539 bool doLightIteration, const LightList* manualLightList) … … 546 546 } 547 547 //----------------------------------------------------------------------- 548 bool VisibilityTerrainSceneManager::validatePassForRendering(Pass* pass)548 bool OcclusionCullingSceneManager::validatePassForRendering(Pass* pass) 549 549 { 550 550 // skip all but first pass if we are doing the depth pass … … 553 553 return false; 554 554 } 555 555 556 return SceneManager::validatePassForRendering(pass); 556 557 } 557 558 //----------------------------------------------------------------------- 558 void VisibilityTerrainSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup)559 void OcclusionCullingSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 559 560 { 560 561 if (!mIsItemBufferPhase) … … 575 576 } 576 577 //----------------------------------------------------------------------- 577 void VisibilityTerrainSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup)578 void OcclusionCullingSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup) 578 579 { 579 580 // Do solids … … 632 633 } 633 634 //----------------------------------------------------------------------- 634 void VisibilityTerrainSceneManager::RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass)635 void OcclusionCullingSceneManager::RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass) 635 636 { 636 637 static LightList nullLightList; … … 677 678 } 678 679 //----------------------------------------------------------------------- 679 GtpVisibility::VisibilityManager * VisibilityTerrainSceneManager::GetVisibilityManager()680 GtpVisibility::VisibilityManager *OcclusionCullingSceneManager::GetVisibilityManager() 680 681 { 681 682 return mVisibilityManager; 682 683 } 683 684 //----------------------------------------------------------------------- 684 void VisibilityTerrainSceneManager::InitVisibilityCulling(Camera *cam)685 void OcclusionCullingSceneManager::InitVisibilityCulling(Camera *cam) 685 686 { 686 687 // reset culling manager stats … … 742 743 // possible two cameras (one for culling, one for rendering) 743 744 mHierarchyInterface->InitTraversal(mCameraInProgress, 744 mCullCamera ? getCamera("CullCamera") : NULL,745 mLeavePassesInQueue);745 mCullCamera ? getCamera("CullCamera") : NULL, 746 mLeavePassesInQueue); 746 747 747 748 //std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue;LogManager::getSingleton().logMessage(d.str()); 748 749 } 749 750 //----------------------------------------------------------------------- 750 OctreeHierarchyInterface * VisibilityTerrainSceneManager::GetHierarchyInterface()751 OctreeHierarchyInterface *OcclusionCullingSceneManager::GetHierarchyInterface() 751 752 { 752 753 return mHierarchyInterface; 753 754 } 754 755 //----------------------------------------------------------------------- 755 void VisibilityTerrainSceneManager::endFrame()756 void OcclusionCullingSceneManager::endFrame() 756 757 { 757 758 TerrainRenderable::ResetRenderLevelIndex(); 758 759 } 759 760 //----------------------------------------------------------------------- 760 Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName,761 Entity* OcclusionCullingSceneManager::createEntity(const String& entityName, 761 762 const String& meshName) 762 763 { … … 774 775 } 775 776 //----------------------------------------------------------------------- 776 void VisibilityTerrainSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup)777 void OcclusionCullingSceneManager::renderAdditiveStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 777 778 { 778 779 // only render solid passes during hierarchical culling … … 806 807 } 807 808 //----------------------------------------------------------------------- 808 void VisibilityTerrainSceneManager::renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup)809 void OcclusionCullingSceneManager::renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup) 809 810 { 810 811 if (mIsHierarchicalCulling) -
GTP/trunk/Lib/Vis/Preprocessing/scripts/egsr_test_script
r674 r675 2 2 PROGRAM=../bin/release/Preprocessor.exe 3 3 4 #SCENE=soda54 SCENE=soda5 5 5 #SCENE=soda 6 SCENE=atlanta6 #SCENE=atlanta 7 7 #SCENE=vienna 8 8 … … 32 32 -view_cells_post_process_merge=true \ 33 33 -vsp_bsp_term_min_pvs=0 \ 34 -view_cells_evaluation_samples=1000000 \ 34 35 -view_cells_filename=$LOG_PREFIX-$METHOD-viewCells.x3d 35 36 … … 58 59 -view_cells_post_process_merge=false \ 59 60 -vsp_bsp_term_min_pvs=0 \ 60 -view_cells_filename=$LOG_PREFIX-$METHOD-viewCells.x3d 61 62 mv debug.log $LOG_PREFIX-$METHOD-debug.log 61 -view_cells_evaluation_samples=1000000 \ 62 -view_cells_filename=$LOG_PREFIX-$METHOD-viewCells.x3d 63 64 mv debug.log $LOG_PREFIX-$METHOD-debug.log 65 66 67 63 68 64 69 … … 86 91 87 92 mv debug.log $LOG_PREFIX-$METHOD-debug.log 93 94 88 95 89 96 … … 110 117 -vsp_bsp_max_poly_candidates=0 \ 111 118 -vsp_bsp_breath_first_splits=true \ 112 -vsp_bsp_term_min_pvs= 15\119 -vsp_bsp_term_min_pvs=50 \ 113 120 -view_cells_construction_samples=0 \ 114 121 -vsp_bsp_use_split_cost_queue=false \ 115 -vsp_bsp_term_max_depth= 20\122 -vsp_bsp_term_max_depth=19 \ 116 123 -view_cells_filename=$LOG_PREFIX-$METHOD-viewCells.x3d 117 124 … … 271 278 272 279 ################################################################ 273 # vspbsptree - many samples 280 # vspbsptree - many samples - no queue # 274 281 ################################################################ 275 282 -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r674 r675 1180 1180 optBool, 1181 1181 "vss_enlarge_viewspace=", 1182 " true");1182 "false"); 1183 1183 1184 1184 RegisterOption("VssPreprocessor.loadInitialSamples", -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r664 r675 30 30 environment->GetBoolValue("Preprocessor.loadPolygonsAsMeshes", mLoadPolygonsAsMeshes); 31 31 environment->GetBoolValue("Preprocessor.quitOnFinish", mQuitOnFinish); 32 Debug << "load polygons as meshes: " << mLoadPolygonsAsMeshes << endl; 32 33 33 34 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r666 r675 621 621 } 622 622 623 623 624 // adjust stats and reset queue one final time 624 625 mExpectedCost = realExpectedCost; … … 628 629 UpdateActiveViewCells(activeViewCells); 629 630 631 630 632 // refine view cells and reset costs 631 633 if (mRefineViewCells) … … 659 661 mMergeQueue.pop(); 660 662 } 661 662 663 663 664 // TODO delete because makes no sense here 664 665 mergeStats.expectedRenderCost = realExpectedCost; … … 676 677 // assign colors for the view cells so that at least one is always consistent 677 678 AssignRandomColors(); 679 678 680 //TODO: should return sample contributions? 679 681 return mergeStats.merged; … … 1680 1682 void ViewCellsTree::AssignRandomColors() 1681 1683 { 1682 TraversalQueue tqueue; 1683 tqueue.push(mRoot); 1684 mRoot->SetColor(RandomColor(0.3f, 1.0f)); 1685 1686 while (!tqueue.empty()) 1687 { 1688 ViewCell *vc = tqueue.top(); 1689 tqueue.pop(); 1690 1691 // save the view cells if it is a leaf or if enough view cells have already been traversed 1692 // because of the priority queue, this will be the optimal set of v 1693 if (!vc->IsLeaf()) { 1694 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1695 1696 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1697 float maxProbability = -1.0f; 1698 ViewCell *maxViewCell = NULL; 1699 for (it = interior->mChildren.begin(); it != it_end; ++ it) { 1700 ViewCell *v = *it; 1701 // set random color 1702 v->SetColor(RandomColor(0.3f, 1.0f)); 1703 if (v->GetVolume() > maxProbability) { 1704 maxProbability = v->GetVolume(); 1705 maxViewCell = v; 1706 } 1707 maxViewCell->SetColor(vc->GetColor()); 1708 tqueue.push(v); 1709 } 1710 1711 } 1712 1713 } 1714 } 1684 TraversalQueue tqueue; 1685 1686 tqueue.push(mRoot); 1687 mRoot->SetColor(RandomColor(0.3f, 1.0f)); 1688 1689 while (!tqueue.empty()) 1690 { 1691 ViewCell *vc = tqueue.top(); 1692 tqueue.pop(); 1693 1694 // save the view cells if it is a leaf or if enough view cells have already been traversed 1695 // because of the priority queue, this will be the optimal set of v 1696 if (!vc->IsLeaf()) 1697 { 1698 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1699 1700 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1701 1702 float maxProbability = -1.0f; 1703 1704 ViewCell *maxViewCell = NULL; 1705 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1706 { 1707 ViewCell *v = *it; 1708 1709 // set random color 1710 v->SetColor(RandomColor(0.3f, 1.0f)); 1711 1712 if (v->GetVolume() > maxProbability) 1713 { 1714 maxProbability = v->GetVolume(); 1715 maxViewCell = v; 1716 } 1717 1718 if (maxViewCell) 1719 maxViewCell->SetColor(vc->GetColor()); 1720 1721 tqueue.push(v); 1722 } 1723 } 1724 } 1725 } 1726 1715 1727 1716 1728 /** Get costs resulting from each merge step. */ -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r667 r675 980 980 viewCell->mLeaf = leaf; 981 981 982 float probability = max(0.0f, tData.mProbability); 983 982 984 if (mUseAreaForPvs) 983 viewCell->SetArea( tData.mProbability);985 viewCell->SetArea(probability); 984 986 else 985 viewCell->SetVolume( tData.mProbability);986 987 viewCell->SetVolume(probability); 988 987 989 //-- add pvs 988 990 if (viewCell != mOutOfBoundsCell) -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r670 r675 396 396 397 397 mBspStats.polys = (int)polys.size(); 398 399 398 mGlobalCostMisses = 0; 400 399 … … 739 738 if (1) 740 739 { 740 741 741 float cFront = (float)tFrontData.mPvs * tFrontData.mProbability; 742 742 float cBack = (float)tBackData.mPvs * tBackData.mProbability; … … 859 859 float cFront = (float)tFrontData.mPvs * tFrontData.mProbability; 860 860 float cBack = (float)tBackData.mPvs * tBackData.mProbability; 861 float cData = (float)tData.mPvs * tData.mProbability;; 862 861 float cData = (float)tData.mPvs * tData.mProbability; 862 863 863 864 float costDecr = 864 865 (cFront + cBack - cData) / mBox.GetVolume(); … … 926 927 viewCell->SetVolume(tData.mProbability); 927 928 928 929 leaf->mProbability = tData.mProbability; 929 930 930 931 EvaluateLeafStats(tData); … … 1010 1011 splitPlane, 1011 1012 mBox, 1012 mEpsilon); 1013 0.0000001f); 1014 //mEpsilon); 1013 1015 1014 1016 if (mUseAreaForPvs) … … 1021 1023 frontData.mProbability = frontData.mGeometry->GetVolume(); 1022 1024 backData.mProbability = tData.mProbability - frontData.mProbability; 1025 // clamp because of precision issues 1026 if (frontData.mProbability < 0) frontData.mProbability = 0; 1027 if (backData.mProbability < 0) backData.mProbability = 0; 1023 1028 } 1024 1029 } … … 1687 1692 candidatePlane, 1688 1693 mBox, 1689 mEpsilon); 1694 0.0000001f); 1695 //mEpsilon); 1690 1696 1691 1697 if (!mUseAreaForPvs) // use front and back cell areas to approximate volume … … 1693 1699 pFront = geomFront.GetVolume(); 1694 1700 pBack = pOverall - pFront; 1701 1702 // clamp because of possible precision issues 1703 if (pFront < 0) pFront = 0; 1704 if (pBack < 0) pBack = 0; 1695 1705 } 1696 1706 else … … 1775 1785 candidatePlane, 1776 1786 mBox, 1787 1777 1788 mEpsilon); 1778 1789 … … 1783 1794 pFront = geomFront.GetVolume(); 1784 1795 pBack = pOverall - pFront; 1796 1797 // clamp because of possible precision issues 1798 if (pFront < 0) pFront = 0; 1799 if (pBack < 0) pBack = 0; 1785 1800 } 1786 1801 else … … 2672 2687 interior->GetPlane(), 2673 2688 mBox, 2689 //0.0000001f); 2674 2690 mEpsilon); 2675 2691 … … 2763 2779 interior->GetPlane(), 2764 2780 mBox, 2781 //0.0000001f); 2765 2782 mEpsilon); 2766 2783 … … 3253 3270 interior->GetPlane(), 3254 3271 mBox, 3272 //0.0000001f); 3255 3273 mEpsilon); 3256 3274 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r674 r675 36 36 useViewspacePlane = mUseViewSpaceBox; //hack 37 37 38 39 Debug << "*********** vss preprocessor options **************" << endl; 40 Debug << "use view space box=" << mUseViewSpaceBox << endl; 41 Debug << "enlarge view space=" << mEnlargeViewSpace << endl; 42 Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; 43 44 Debug << "*********** end vss preprocessor options **************" << endl; 45 38 46 mStats.open("stats.log"); 39 47 } … … 77 85 78 86 int hits = 0; 79 static Ray ray; 80 AxisAlignedBox3 box = mViewSpaceBox ? *mViewSpaceBox : mKdTree->GetBox(); 81 82 AxisAlignedBox3 sbox = box; 83 sbox.Enlarge(Vector3(-Limits::Small)); 84 if (!sbox.IsInside(viewPoint)) 85 return 0; 86 87 SetupRay(ray, viewPoint, direction); 88 // cast ray to KD tree to find intersection with other objects 89 Intersectable *objectA, *objectB; 90 Vector3 pointA, pointB; 91 float bsize = Magnitude(box.Size()); 92 87 static Ray ray; 88 89 AxisAlignedBox3 box = mViewSpaceBox ? *mViewSpaceBox : mKdTree->GetBox(); 90 AxisAlignedBox3 sbox = box; 91 92 sbox.Enlarge(Vector3(-Limits::Small)); 93 94 if (!sbox.IsInside(viewPoint)) 95 return 0; 96 97 SetupRay(ray, viewPoint, direction); 98 99 // cast ray to KD tree to find intersection with other objects 100 Intersectable *objectA, *objectB; 101 Vector3 pointA, pointB; 102 float bsize = Magnitude(box.Size()); 93 103 94 104 if (!mDetectEmptyViewSpace) 95 105 ray.mFlags &= ~Ray::CULL_BACKFACES; 96 106 else 97 ray.mFlags |= Ray::CULL_BACKFACES; 98 99 if (mKdTree->CastRay(ray)) { 100 objectA = ray.intersections[0].mObject; 101 pointA = ray.Extrap(ray.intersections[0].mT); 102 } else { 103 objectA = NULL; 104 // compute intersection with the scene bounding box 105 float tmin, tmax; 106 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 107 pointA = ray.Extrap(tmax); 107 ray.mFlags |= Ray::CULL_BACKFACES; 108 109 if (mKdTree->CastRay(ray)) 110 { 111 objectA = ray.intersections[0].mObject; 112 pointA = ray.Extrap(ray.intersections[0].mT); 113 } 114 else 115 { 116 objectA = NULL; 117 // compute intersection with the scene bounding box 118 float tmin, tmax; 119 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 120 pointA = ray.Extrap(tmax); 121 else 122 return 0; 123 } 124 125 126 if (mDetectEmptyViewSpace) { 127 SetupRay(ray, pointA, -direction); 128 } else 129 SetupRay(ray, viewPoint, -direction); 130 131 if (!mDetectEmptyViewSpace) 132 ray.mFlags &= ~Ray::CULL_BACKFACES; 108 133 else 109 return 0;110 } 111 112 113 if (mDetectEmptyViewSpace) { 114 SetupRay(ray, pointA, -direction);115 } else 116 SetupRay(ray, viewPoint, -direction);117 118 if (!mDetectEmptyViewSpace) 119 ray.mFlags &= ~Ray::CULL_BACKFACES;120 else 121 ray.mFlags |= Ray::CULL_BACKFACES;122 123 if (mKdTree->CastRay(ray)) { 124 objectB = ray.intersections[0].mObject;125 pointB = ray.Extrap(ray.intersections[0].mT);126 } else {127 objectB = NULL;128 float tmin, tmax;129 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax)130 pointB = ray.Extrap(tmax);131 else132 return 0;133 } 134 135 // if (objectA == NULL && objectB != NULL){136 if (mDetectEmptyViewSpace) { 137 // cast again to ensure that there is no objectA138 SetupRay(ray, pointB, direction);139 ray.mFlags |= Ray::CULL_BACKFACES;140 if (mKdTree->CastRay(ray)) { 141 objectA = ray.intersections[0].mObject; 142 pointA = ray.Extrap(ray.intersections[0].mT);143 } 144 } 145 146 147 VssRay *vssRay = NULL; 148 149 bool validSample = (objectA != objectB); 150 if (0 && mDetectEmptyViewSpace) { // consider all samples valid 151 // check if the viewpoint lies on the line segment AB152 if (Distance(pointA, pointB) <153 Distance(viewPoint, pointA) + Distance(viewPoint, pointB) - Limits::Small) {154 validSample = false;155 } 156 } 157 158 if (validSample) { 159 if (objectA) {160 vssRay = new VssRay(pointB,161 pointA,162 objectB,163 objectA,164 mPass165 166 167 168 }169 170 if (objectB) {171 vssRay = new VssRay(pointA,172 pointB,173 objectA,174 objectB,175 mPass176 177 178 179 }180 181 182 134 ray.mFlags |= Ray::CULL_BACKFACES; 135 136 if (mKdTree->CastRay(ray)) 137 { 138 objectB = ray.intersections[0].mObject; 139 pointB = ray.Extrap(ray.intersections[0].mT); 140 } 141 else 142 { 143 objectB = NULL; 144 float tmin, tmax; 145 146 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 147 pointB = ray.Extrap(tmax); 148 else 149 return 0; 150 } 151 152 // if (objectA == NULL && objectB != NULL) { 153 if (mDetectEmptyViewSpace) 154 { 155 // cast again to ensure that there is no objectA 156 SetupRay(ray, pointB, direction); 157 ray.mFlags |= Ray::CULL_BACKFACES; 158 159 if (mKdTree->CastRay(ray)) 160 { 161 objectA = ray.intersections[0].mObject; 162 pointA = ray.Extrap(ray.intersections[0].mT); 163 } 164 } 165 166 167 VssRay *vssRay = NULL; 168 169 bool validSample = (objectA != objectB); 170 171 if (0 && mDetectEmptyViewSpace) 172 { 173 // consider all samples valid 174 // check if the viewpoint lies on the line segment AB 175 if (Distance(pointA, pointB) < 176 Distance(viewPoint, pointA) + Distance(viewPoint, pointB) - Limits::Small) 177 { 178 validSample = false; 179 } 180 } 181 182 if (validSample) 183 { 184 if (objectA) 185 { 186 vssRay = new VssRay(pointB, 187 pointA, 188 objectB, 189 objectA, 190 mPass); 191 vssRays.push_back(vssRay); 192 hits ++; 193 } 194 195 if (objectB) 196 { 197 vssRay = new VssRay(pointA, 198 pointB, 199 objectA, 200 objectB, 201 mPass); 202 vssRays.push_back(vssRay); 203 hits ++; 204 } 205 } 206 207 return hits; 183 208 } 184 209 … … 528 553 529 554 cout<<"mUseViewSpaceBox="<<mUseViewSpaceBox<<endl; 530 Debug << "use view space box=" << mUseViewSpaceBox << endl; 555 531 556 532 557 if (mUseViewSpaceBox) -
GTP/trunk/Lib/Vis/shared/EvalStats/EvalStats.cpp
r670 r675 38 38 39 39 int currentTag = NO_TAG; 40 40 41 41 while (!(getline(file, buf)).eof()) 42 42 { … … 106 106 //<< "#TotalRenderCostGain\n" << 100.0f - costRatio * 100.0f << endl 107 107 //<< "#AvgRenderCostGain\n" << 100.0f - avgCostRatio * 100.0f << endl << endl; 108 << "#TotalRenderCostGain\n" << 100.0f * costRatio - 100.0f<< endl 109 << "#AvgRenderCostGain\n" << 100.0f * avgCostRatio -100.0f << endl << endl; 110 } 111 108 << "#TotalRenderCostRatio\n" << costRatio << endl 109 << "#AvgRenderCostRatio\n" << avgCostRatio << endl << endl; 110 } 111 112 113 int ComputeNoViewCells(const StatsContainer &firstStats, 114 const StatsContainer ¤tStats) 115 { 116 const int n = min((int)firstStats.size(), (int)currentStats.size()); 117 118 const float renderCost = (int)currentStats[n - 1].mRenderCost; 119 120 int i = 0; 121 while ((i ++ < (int)firstStats.size()) && (renderCost > (int)firstStats[i].mRenderCost)); 122 123 return i; 124 } 112 125 113 126 … … 129 142 StatsContainer currentStats; 130 143 131 ifstream file(argv[i]); 144 ifstream file; 145 file.open(argv[i]); 132 146 133 147 // extract the render cost 134 148 cout << "extracting render cost of file " << argv[i] << endl; 135 cout.flush(); 136 137 extractRenderStats(file, currentStats); 138 renderStats.push_back(currentStats); 139 140 // create output file name 141 string fn = argv[i]; 142 143 string::size_type pos = fn.find(".log", 0); 144 fn.erase(pos, 4); 145 //sscanf(argv[i], "%s.log", fn); 146 string outFilename = string(fn) + string("-ratio.log"); 147 148 outFilenames.push_back(outFilename); 149 150 if (extractRenderStats(file, currentStats)) 151 { 152 renderStats.push_back(currentStats); 153 154 // create output file name 155 string fn = argv[i]; 156 157 string::size_type pos = fn.find(".log", 0); 158 fn.erase(pos, 4); 159 //sscanf(argv[i], "%s.log", fn); 160 string outFilename = string(fn) + string("-ratio.log"); 161 162 outFilenames.push_back(outFilename); 163 } 164 else 165 { 166 cout << "could not open file!" << endl; 167 } 149 168 } 150 169 … … 159 178 160 179 // don't compare with itself 161 ++ it;162 ++ sit;180 //++ it; 181 //++ sit; 163 182 164 183 for (it; it != it_end; ++ it) 165 184 { 166 cout << " writing output to file " << *sit << endl;167 ofstream statsOut ((*sit).c_str());168 ++ sit;185 cout << "now writing output to file " << *sit << endl; 186 ofstream statsOut; 187 statsOut.open((*sit).c_str()); 169 188 170 189 // compute size of output vector … … 176 195 } 177 196 197 int vc = ComputeNoViewCells(firstStats, *it); 198 cout << "need " << vc << " view cells to reach rendercost of method " << i << " with " << n << " view cells" << endl; 199 178 200 statsOut.close(); 201 202 ++ sit; 179 203 } 180 204
Note: See TracChangeset
for help on using the changeset viewer.