- Timestamp:
- 04/06/06 17:54:00 (19 years ago)
- Location:
- GTP/trunk/Lib/Vis
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj
r727 r728 267 267 RelativePath="..\src\OgreVisibilitySceneManagerDll.cpp"> 268 268 </File> 269 <File270 RelativePath="..\src\ViewCellBspTree.cpp">271 </File>272 269 </Filter> 273 270 </Filter> -
GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj
r726 r728 20 20 Name="VCCLCompilerTool" 21 21 Optimization="0" 22 AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;..\include..\support;"..\include ..\support";..\include;"$( GTPDIR)\NonGTP\Devil\include";"$(QTDIR)\include\QtCore";"$(GTPDIR)\NonGTP\Xerces";"$(CG_INC_PATH)";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";"$(QTDIR)\include\QtGui";"$(GTPDIR)\NonGTP\Zlib\include""22 AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;..\include..\support;"..\include ..\support";..\include;"$(QTDIR)\include\QtCore";"$(CG_INC_PATH)";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";"$(QTDIR)\include\QtGui";"$(GTPDIR)\NonGTP\Zlib\include";..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Devil\include" 23 23 PreprocessorDefinitions="WIN32;_DEBUG;_LIB" 24 24 MinimalRebuild="TRUE" … … 67 67 InlineFunctionExpansion="2" 68 68 FavorSizeOrSpeed="1" 69 OptimizeForWindowsApplication="TRUE"70 69 AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;..\include;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)";..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces" 71 70 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;" … … 84 83 AdditionalDependencies="xerces-c_2.lib zdll.lib zziplib.lib devil.lib qtmain.lib QtOpenGL4.lib QtCore4.lib QtGui4.lib Qt3Supportd4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib" 85 84 AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;"$(QTDIR)\lib";..\include;..\src\GL;"$(CG_LIB_PATH)";"$(GTPDIR)\NonGTP\Xerces";"$(GTPDIR)\NonGTP\Xerces\xercesc\lib";"$(GTPDIR)\NonGTP\zlib\lib";"$(GTPDIR)\NonGTP\Devil\lib"" 85 GenerateDebugInformation="TRUE" 86 86 LargeAddressAware="2"/> 87 87 <Tool -
GTP/trunk/Lib/Vis/Preprocessing/scripts/default.env
r697 r728 177 177 # samples used for view cell construction 178 178 Construction { 179 samples 100000 179 samples 1000000 180 180 samplesPerPass 200000 181 181 } … … 199 199 #percentage of total visible objects where pvs is considered invalid 200 200 maxPvsRatio 1.0 201 201 202 renderCostEvaluationType perobject 203 #renderCostEvaluationType pertriangle 204 202 205 pruneEmptyViewCells false 203 206 processOnlyValidViewCells false … … 242 245 } 243 246 244 showVisualization true247 showVisualization false 245 248 evaluateViewCells false 246 249 247 250 Evaluation { 248 251 samplesPerPass 800000 249 samples 1000000252 samples 800000 250 253 statsPrefix ../scripts/viewCells 251 254 } … … 308 311 VspBspTree { 309 312 Construction { 310 samples 200000313 samples 50000 311 314 epsilon 0.00005 312 315 randomize false … … 363 366 364 367 AxisAligned { 365 minRays 5000 0368 minRays 5000 366 369 maxRayContribution 9.9 367 370 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r722 r728 1223 1223 "view_cells_evaluation_stats_prefix=", 1224 1224 "viewCells"); 1225 1225 1226 RegisterOption("ViewCells.renderCostEvaluationType", 1227 optString, 1228 "view_cells_render_cost_evaluation=", 1229 "perobject"); 1230 1226 1231 RegisterOption("ViewCells.active", 1227 1232 optInt, -
GTP/trunk/Lib/Vis/Preprocessing/src/RenderSimulator.cpp
r605 r728 105 105 // that view point is in view cell 106 106 const float vcCost = pInVc * 107 mViewCellsManager->GetRendercost(vc , mObjRenderCost);107 mViewCellsManager->GetRendercost(vc/*, mObjRenderCost*/); 108 108 109 109 renderTime += vcCost; … … 113 113 loadPvsOverhead += GetCrossVcProbability() * mVcOverhead; 114 114 115 115 116 //-- update statistics 116 117 -
GTP/trunk/Lib/Vis/Preprocessing/src/Vector3.cpp
r492 r728 123 123 ViewN = -N; // forwards 124 124 #ifdef _DEBUG 125 const float eps = 1e-3 ;125 const float eps = 1e-3f; 126 126 if (fabs(Magnitude(ViewU) - 1.0) > eps) { 127 127 Debug << "ViewU magnitude error= " << Magnitude(ViewU) << "\n"; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r720 r728 39 39 40 40 // pvs penalty can be different from pvs size 41 inline float EvalPvsPenalty(const int pvs, 42 const int lower, 43 const int upper) 41 inline float EvalPvsPenalty(const int pvs, const int lower, const int upper) 44 42 { 45 43 // clamp to minmax values 46 /*if (pvs < lower) 44 #if HAS_TO_BE_REDONE 45 if (pvs < lower) 47 46 return (float)lower; 48 47 if (pvs > upper) 49 48 return (float)upper; 50 */ 49 #endif 51 50 return (float)pvs; 52 51 } … … 204 203 { 205 204 mMergeCost = mergeCost; 205 } 206 207 208 float ViewCell::GetRenderCost() const 209 { 210 return (float)mPvs.GetSize() * GetVolume(); 206 211 } 207 212 … … 791 796 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 792 797 { 793 int lower = mViewCellsManager->GetMinPvsSize();794 int upper = mViewCellsManager->GetMaxPvsSize();795 float penalty = EvalPvsPenalty((*vit)->GetPvs().GetSize(), lower, upper);798 const int lower = mViewCellsManager->GetMinPvsSize(); 799 const int upper = mViewCellsManager->GetMaxPvsSize(); 800 const float penalty = EvalPvsPenalty((*vit)->GetPvs().GetSize(), lower, upper); 796 801 797 802 mDeviation += fabs(mAvgRenderCost - penalty); -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r703 r728 147 147 bool GetValid() const; 148 148 149 /** Returns estimated render cost of this view cell. 150 */ 151 float GetRenderCost() const; 149 152 150 153 /** set color for visiualizations */ -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r727 r728 91 91 environment->GetIntValue("ViewCells.Filter.maxSize", mMaxFilterSize); 92 92 environment->GetFloatValue("ViewCells.Filter.width", mFilterWidth); 93 environment->GetIntValue("ViewCells.mRenderCostEvaluationType", mRenderCostEvaluationType); 93 94 94 95 char buf[100]; … … 119 120 { 120 121 mEvaluationSamplingType = Preprocessor::DIRECTION_BASED_DISTRIBUTION; 122 } 123 else 124 { 125 Debug << "error! wrong sampling type" << endl; 126 exit(0); 127 } 128 129 environment->GetStringValue("ViewCells.renderCostEvaluationType", buf); 130 131 if (strcmp(buf, "box") == 0) 132 { 133 mRenderCostEvaluationType = ViewCellsManager::PER_OBJECT; 134 } 135 else if (strcmp(buf, "directional") == 0) 136 { 137 mRenderCostEvaluationType = ViewCellsManager::PER_TRIANGLE; 121 138 } 122 139 else … … 162 179 Debug << "evaluate view cells: " << mEvaluateViewCells << endl; 163 180 Debug << "sampling type: " << mSamplingType << endl; 181 Debug << "render cost evaluation type" << mRenderCostEvaluationType << endl; 182 Debug << "evaluation sampling type: " << mEvaluationSamplingType << endl; 164 183 Debug << "show visualization: " << mShowVisualization << endl; 165 184 Debug << "filter width: " << mFilterWidth << endl; … … 219 238 { 220 239 Ray *pray = (*it)->mPiercingRays[0]; 221 Debug << "view cell " << (*it)->GetId() << " not empty, pvs: " << (*it)->GetPvs().GetSize() << " " << (int)pray->intersections.size() << endl; 240 Debug << "view cell " << (*it)->GetId() << " not empty, pvs: " 241 << (*it)->GetPvs().GetSize() << " " << (int)pray->intersections.size() << endl; 222 242 223 243 exporter->ExportRays((*it)->mPiercingRays); … … 493 513 494 514 return numSamples; 515 } 516 517 518 void ComputeMinMaxRenderCost(float &minRenderCost, 519 float &maxRenderCost, 520 const ViewCellContainer &viewCells) 521 { 522 minRenderCost = 1e20f; 523 maxRenderCost = -1; 524 525 ViewCellContainer::const_iterator it, it_end = viewCells.end(); 526 527 for (it = viewCells.begin(); it != it_end; ++ it) 528 { 529 const float renderCost = (float)(*it)->GetPvs().GetSize() * (*it)->GetVolume(); 530 if (renderCost > maxRenderCost) 531 maxRenderCost = renderCost; 532 else if (renderCost < minRenderCost) 533 minRenderCost = renderCost; 534 } 535 } 536 537 void ViewCellsManager::EvalViewCellHistogram(const string filename, const int nViewCells) 538 { 539 std::ofstream outstream; 540 outstream.open(filename.c_str()); 541 542 ViewCellContainer viewCells; 543 mViewCellsTree->CollectBestViewCellSet(mViewCells, nViewCells); 544 545 float maxRenderCost, minRenderCost; 546 /// find out the range for valid render cost 547 ComputeMinMaxRenderCost(minRenderCost, maxRenderCost, viewCells); 548 549 const int intervals = 10000; 550 const float range = maxRenderCost - minRenderCost; 551 int currentRenderCost = (int)ceil(minRenderCost); 552 const int stepSize = (int)((float)range / (float)intervals); 553 554 for (; currentRenderCost < (int)maxRenderCost; currentRenderCost += stepSize) 555 { 556 ViewCellContainer::const_iterator it, it_end = viewCells.end(); 557 558 int smallerCost = 0; 559 560 for (it = viewCells.begin(); it != viewCells.end(); ++ it) 561 { 562 ViewCell *vc = *it; 563 564 if (EvalRenderCost(vc) < currentRenderCost) 565 ++ smallerCost; 566 } 567 568 outstream << "#RenderCost: " << currentRenderCost << endl; 569 outstream << "#ViewCells: " << smallerCost << endl; 570 } 571 495 572 } 496 573 … … 578 655 disposeRays(evaluationSamples, NULL); 579 656 } 657 658 string filename = "histogram.log"; 659 int nViewCells = 5000; 660 661 EvalViewCellHistogram(filename, nViewCells); 580 662 581 663 // find empty view cells bug … … 593 675 594 676 677 // Returns index of the best view cells of the neighborhood 595 678 int GetBestViewCellIdx(ViewCell *root, const ViewCellContainer &neighborhood) 596 679 { … … 614 697 615 698 return bestViewCellIdx; 699 } 700 701 702 void ViewCellsManager::SetMaxFilterSize(const int size) 703 { 704 mMaxFilterSize = size; 705 } 706 707 708 float ViewCellsManager::EvalRenderCost(Intersectable *obj) const 709 { 710 switch (mRenderCostEvaluationType) 711 { 712 case PER_OBJECT: 713 return 1; 714 715 case PER_TRIANGLE: 716 { 717 // HACK 718 MeshInstance *mi = dynamic_cast<MeshInstance *>(obj); 719 720 // HACK: assume meshes are triangles 721 if (mi->GetMesh()) 722 { 723 return mi->GetMesh()->mFaces.size(); 724 } 725 } 726 default: 727 return 1; 728 } 729 730 // should not come here 731 return 0; 616 732 } 617 733 … … 691 807 //cout << "neighborhood: " << neighborhood.size() << endl; 692 808 for (int nMergedViewCells = 0; nMergedViewCells < n; ++ nMergedViewCells) 693 809 { 694 810 ViewCell *bestViewCell = neighborhood[nMergedViewCells].mViewCell; 695 811 //cout <<nMergedViewCells<<":"<<"homogenity=" <<neighborhood[nMergedViewCells].mValue<<endl; … … 698 814 // set negative cost so that this view cell gets deleted 699 815 root->SetMergeCost(-1.0f); 700 816 } 701 817 702 818 return root; … … 1453 1569 1454 1570 1455 float ViewCellsManager::GetRendercost(ViewCell *viewCell, float objRendercost) const 1456 { 1457 return mViewCellsTree->GetPvsSize(viewCell) * objRendercost; 1571 float ViewCellsManager::GetRendercost(ViewCell *viewCell) const 1572 { 1573 const ObjectPvs &pvs = viewCell->GetPvs(); 1574 1575 ObjectPvsMap::iterator it, it_end = viewCell->GetPvs().mEntries.end(); 1576 1577 for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it) 1578 { 1579 1580 } 1581 1582 return mViewCellsTree->GetPvsSize(viewCell); 1458 1583 } 1459 1584 … … 1463 1588 // if already computed 1464 1589 if (mTotalAreaValid) 1590 { 1465 1591 return mTotalArea; 1592 } 1466 1593 1467 1594 mTotalArea = 0; … … 2548 2675 exporter->ExportKdTree(*mKdTree); 2549 2676 2550 for (i =0; i < pvsOut; i++)2677 for (i = 0; i < pvsOut; i++) 2551 2678 exporter->ExportRays(rays[i], RgbColor(1, 0, 0)); 2552 2679 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r722 r728 57 57 class ViewCellsManager 58 58 { 59 60 59 public: 61 struct PvsStatistics { 62 int minPvs; 63 int maxPvs; 64 float avgPvs; 65 int viewcells; 60 struct PvsStatistics 61 { 62 int minPvs; 63 int maxPvs; 64 float avgPvs; 65 int viewcells; 66 66 }; 67 68 /// view cell container types 69 enum {BSP, KD, VSP_KD, VSP_BSP}; 67 70 68 /** 69 Candidate for leaf merging based on priority. 70 */ 71 class LocalMergeCandidate 72 { 73 public: 74 LocalMergeCandidate(ViewCell *l, ViewCell *r); 75 76 /** If this merge pair is still valid. 77 */ 78 //bool IsValid() const; 79 80 friend bool operator<(const LocalMergeCandidate &leafa, const LocalMergeCandidate &leafb) 81 { 82 return leafb.GetMergeCost() < leafa.GetMergeCost(); 83 } 84 85 void SetLeftViewCell(ViewCell *l) {mLeftViewCell = l;} 86 void SetRightViewCell(ViewCell *l) {mRightViewCell = l;} 87 88 ViewCell *GetLeftViewCell() const {return mLeftViewCell;} 89 ViewCell *GetRightViewCell() const { return mRightViewCell;} 90 91 float GetMergeCost() const {return mMergeCost;} 92 void SetMergeCost(const float cost) {mMergeCost = cost;} 93 94 protected: 95 96 /// render cost increase by this merge 97 float mMergeCost; 98 99 ViewCell *mLeftViewCell; 100 ViewCell *mRightViewCell; 101 }; 102 103 104 105 /// view cell container types 106 enum {BSP, KD, VSP_KD, VSP_BSP}; 107 71 /// view cells evaluation type 72 enum {PER_OBJECT, PER_TRIANGLE}; 73 108 74 /** Constructor taking the initial and construction samples. 109 75 @param initialSamples the maximal number of samples used for creating the hierarchy … … 277 243 /** Returns render cost of a single view cell given the render cost of an object. 278 244 */ 279 float GetRendercost(ViewCell *viewCell , float objRendercost) const;245 float GetRendercost(ViewCell *viewCell) const; 280 246 281 247 /** Returns reference to container of loaded / generated view cells. … … 427 393 void EvalViewCellPartition(Preprocessor *preprocessor); 428 394 429 void SetMaxFilterSize(const int size) { 430 mMaxFilterSize = size; 431 } 432 433 /** deletes interior nodes from the tree which have negative merge cost set (local merge) */ 434 void 435 DeleteLocalMergeTree(ViewCell *vc 436 ) const; 395 /** Sets maximal size of a view cell filter. 396 */ 397 void SetMaxFilterSize(const int size); 398 399 /** Deletes interior nodes from the tree which have negative merge cost set (local merge) 400 */ 401 void DeleteLocalMergeTree(ViewCell *vc) const; 437 402 403 /** Evaluautes histogram for a given number of view cells. 404 */ 405 void EvalViewCellHistogram(const string filename, const int nViewCells); 406 407 /** Evaluates the render cost of a view cell. 408 */ 409 float EvalRenderCost(Intersectable *obj) const; 410 438 411 protected: 439 412 … … 591 564 592 565 ViewCellContainer mEmptyViewCells; 566 567 int mRenderCostEvaluationType; 593 568 }; 594 569 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r727 r728 2078 2078 if (!obj) 2079 2079 return; 2080 2080 2081 // new object 2081 2082 if ((obj->mMailbox != sFrontId) && … … 2330 2331 { 2331 2332 // TODO 2332 #if VC_HISTORY2333 #if HAS_TO_BE_REDONE 2333 2334 stack<BspNode *> nodeStack; 2334 2335 … … 3274 3275 { 3275 3276 // TODO 3276 #if VC_HISTORY3277 #if HAS_TO_BE_REDONE 3277 3278 if (node->IsLeaf()) 3278 3279 return node; … … 3317 3318 int collapsed = 0; 3318 3319 //TODO 3319 #if VC_HISTORY3320 #if HAS_TO_BE_REDONE 3320 3321 (void)CollapseTree(mRoot, collapsed); 3321 3322 … … 3330 3331 { 3331 3332 // TODO 3332 #if VC_HISTORY3333 #if HAS_TO_BE_REDONE 3333 3334 // list not valid anymore => clear 3334 3335 stack<BspNode *> nodeStack; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspKdTree.cpp
r667 r728 2203 2203 if (!vc) return false; 2204 2204 // TODO 2205 #if VC_HISTORY2205 #if HAS_TO_BE_REDONE 2206 2206 // set new size of view cell 2207 2207 vc->SetVolume(fVc->GetVolume() + bVc->GetVolume()); … … 2342 2342 2343 2343 VspKdViewCell *viewCell = leaf->GetViewCell(); 2344 #if VC_HISTORY2344 #if HAS_TO_BE_REDONE 2345 2345 if (!viewCell->Mailed()) 2346 2346 { … … 2486 2486 { 2487 2487 // compute new pvs and area 2488 // TODO 2489 #if VC_HISTORY 2488 #if HAS_TO_BE_REDONE 2490 2489 vc1->GetPvs().SubtractPvs(*leaf->mPvs); 2491 2490 vc2->GetPvs().AddPvs(*leaf->mPvs);
Note: See TracChangeset
for help on using the changeset viewer.