Changeset 570
- Timestamp:
- 01/23/06 18:34:47 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r569 r570 88 88 89 89 90 int ViewCellsManager::Construct(VssRayContainer &rays) 91 { 92 /* VssPreprocessor preprocessor; 93 94 VssRayContainer vssRays; 95 preprocessor->GenerateVssRays(mConstructionSamples, vssRays); 96 Construct(preprocessor->mObjects, vssRays); 97 98 // add rays to output rays 99 while (!vssRays.empty) 100 { 101 rays.push_back(vssRays.back()); 102 vssRays.pop_back(); 103 } 104 105 const int importanceRays = 1000000; 106 preprocessor->GenerateVssRays(max(importanceRays, mPostProcessSamples); 107 108 PostProcess(preprocesor->mObjects, importanceRays); 90 int ViewCellsManager::Construct(Preprocessor *preprocessor, VssRayContainer *outRays) 91 { 92 SimpleRayContainer simpleRays; 93 VssRayContainer constructionRays; 94 95 preprocessor->GenerateRays(mConstructionSamples, 96 Preprocessor::SPATIAL_BOX_BASED_DISTRIBUTION, 97 simpleRays); 98 99 Construct(preprocessor->mObjects, constructionRays); 100 101 int numRays = (int)simpleRays.size(); 102 103 static Ray traversalRay; 104 105 // shoot simple ray and add it to construction rays 106 while (!simpleRays.empty()) 107 { 108 SimpleRay sray = simpleRays.back(); 109 110 // TODO: shoot into kdtree 111 constructionRays.push_back(new VssRay(traversalRay)); 112 113 if (outRays) 114 outRays->push_back(constructionRays.back()); 115 116 simpleRays.pop_back(); 117 } 118 119 if (!outRays) 120 CLEAR_CONTAINER(constructionRays); 121 122 // guided rays 123 VssRayContainer importanceRays; 124 const int desiredImportanceRays = max(1000000, mPostProcessSamples); 125 preprocessor->GenerateRays(desiredImportanceRays, 126 Preprocessor::RSS_BASED_DISTRIBUTION, 127 simpleRays); 128 129 numRays += (int)simpleRays.size(); 130 131 // shoot simple ray and add it to construction rays 132 while (!simpleRays.empty()) 133 { 134 SimpleRay sray = simpleRays.back(); 135 136 // TODO: shoot into kdtree 137 importanceRays.push_back(new VssRay(traversalRay)); 138 139 if (outRays) 140 outRays->push_back(importanceRays.back()); 141 142 simpleRays.pop_back(); 143 } 144 145 if (!outRays) 146 CLEAR_CONTAINER(importanceRays); 147 148 // merge the view cells 149 PostProcess(preprocessor->mObjects, importanceRays); 150 109 151 Visualize(preprocessor->mObjects, importanceRays); 110 152 111 // add rays to output rays 112 while (!importanceRays.empty) 113 { 114 rays.push_back(importanceRays.back()); 115 importanceRays.pop_back(); 116 } 117 */ 118 return (int)rays.size(); 153 154 return numRays; 119 155 } 120 156 … … 130 166 return false; 131 167 } 132 168 133 169 return true; 134 170 } … … 144 180 void 145 181 ViewCellsManager::SetValidity( 146 int minPvsSize, 182 int minPvsSize, 147 183 int maxPvsSize) const 148 184 { 149 185 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 150 186 151 187 for (it = mViewCells.begin(); it != it_end; ++ it) { 152 188 SetValidity(*it, minPvsSize, maxPvsSize); … … 161 197 { 162 198 sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 163 199 164 200 int start = mViewCells.size()*minValid; 165 201 int end = mViewCells.size()*maxValid; 166 202 167 203 for (int i=0; i < mViewCells.size(); i++) 168 204 mViewCells[i]->SetValid(i >= start && i <= end); … … 542 578 } 543 579 544 float 545 ViewCellsManager::ComputeSampleContributions(VssRay &ray, 546 const bool addRays 547 ) 548 { 549 ViewCellContainer viewcells; 550 551 ray.mPvsContribution = 0; 552 ray.mRelativePvsContribution = 0.0f; 553 554 static Ray hray; 580 float ViewCellsManager::ComputeSampleContributions(VssRay &ray, 581 const bool addRays) 582 { 583 ViewCellContainer viewcells; 584 585 ray.mPvsContribution = 0; 586 ray.mRelativePvsContribution = 0.0f; 587 588 static Ray hray; 555 589 hray.Init(ray); 556 590 //hray.mFlags |= Ray::CULL_BACKFACES; … … 567 601 CastLineSegment(origin, termination, viewcells); 568 602 //Debug << "constribution: " << (int)viewcells.size() << endl; 569 CastLineSegment(origin, termination, viewcells); 570 571 //Debug << "constribution: " << (int)viewcells.size() << endl; 572 573 // copy viewcells memory efficiently 574 const bool storeViewcells = !addRays; 575 576 if (storeViewcells) 577 { 578 ray.mViewCells.reserve(viewcells.size()); 579 ray.mViewCells = viewcells; 580 } 581 582 ViewCellContainer::const_iterator it = viewcells.begin(); 603 604 // copy viewcells memory efficiently 605 const bool storeViewcells = !addRays; 606 607 if (storeViewcells) 608 { 609 ray.mViewCells.reserve(viewcells.size()); 610 ray.mViewCells = viewcells; 611 } 612 613 ViewCellContainer::const_iterator it = viewcells.begin(); 583 614 584 615 … … 605 636 } 606 637 } 607 608 638 639 return ray.mRelativePvsContribution; 609 640 } 610 641 … … 1568 1599 } 1569 1600 1601 1570 1602 int VspKdViewCellsManager::Construct(const ObjectContainer &objects, 1571 1603 const VssRayContainer &rays) … … 1934 1966 } 1935 1967 1936 1937 1968 <<<<<<< .mine 1969 1970 ======= 1971 1972 1973 >>>>>>> .r569 1938 1974 int VspBspViewCellsManager::Construct(const ObjectContainer &objects, 1939 1975 const VssRayContainer &rays) … … 2268 2304 // validy update in preprocessor for all managers) 2269 2305 return ViewCellsManager::ViewPointValid(viewPoint); 2270 2306 2271 2307 // return mViewSpaceBox.IsInside(viewPoint) && 2272 2308 // mVspBspTree->ViewPointValid(viewPoint); … … 2508 2544 importance = (float)vc->GetPvs().GetSize() / 2509 2545 (float)mViewCellsStats.maxPvs; 2546 2510 2547 } 2511 2548 break; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r569 r570 26 26 class Exporter; 27 27 class Beam; 28 class Preprocessor; 28 29 29 30 struct BspRay; … … 55 56 56 57 /** Constructs view cells container taking a preprocessor 57 @returns construction rays.58 */ 59 int Construct( VssRayContainer &rays);58 @returns the output rays (if not null) 59 */ 60 int Construct(Preprocessor *preprocessor, VssRayContainer *outRays = NULL); 60 61 61 62 /** Constructs view cell container with a given number of samples. … … 411 412 const VssRayContainer &rays); 412 413 413 414 414 int PostProcess(const ObjectContainer &objects, 415 415 const VssRayContainer &rays); -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r568 r570 1980 1980 bool isAdjacent = true; 1981 1981 1982 /*if (1)1982 if (1) 1983 1983 { 1984 1984 // test all planes of current node if still adjacent … … 2014 2014 } 2015 2015 } 2016 } */2016 } 2017 2017 // neighbor was found 2018 2018 if (isAdjacent) … … 3115 3115 queue<BspMergeCandidate> *backQueue = &queue2; 3116 3116 3117 #if 13118 Exporter *exporter = Exporter::GetExporter("neighors.x3d");3119 3120 if (exporter)3121 {3122 cout << "exporting neighbors ... ";3123 exporter->ExportGeometry(objects);3124 }3125 3126 // HACK for visualization3127 //ViewCellContainer viewCells;3128 //ViewCell::NewMail();3129 //CollectViewCells(mRoot, true, viewCells, true);3130 //for (int i = 0; i < viewCells.size(); ++i)3131 // viewCells[i]->SetId((int)RandomValue(0, Real(256*256*256)));3132 3133 3134 3117 while (!mMergeQueue.empty()) 3135 3118 { … … 3137 3120 shuffleQueue->push(mc); 3138 3121 mMergeQueue.pop(); 3139 3140 // visualize neighbors 3141 Material m = RandomMaterial(); 3142 exporter->SetForcedMaterial(m); 3143 3144 3145 if (!mc.GetLeaf1()->Mailed()) 3146 { 3147 BspNodeGeometry geom1; 3148 ConstructGeometry(mc.GetLeaf1(), geom1); 3149 //m.mDiffuseColor.r = (mc.GetLeaf1()->GetViewCell()->GetId() & 256)/ 255.0f; 3150 //m.mDiffuseColor.g = ((mc.GetLeaf1()->GetViewCell()->GetId()>>8) & 256)/ 255.0f; 3151 //m.mDiffuseColor.b = ((mc.GetLeaf1()->GetViewCell()->GetId()>>16) & 256)/ 255.0f; 3152 //exporter->SetForcedMaterial(m); 3153 exporter->ExportPolygons(geom1.mPolys); 3154 mc.GetLeaf1()->Mail(); 3155 } 3156 3157 if (!mc.GetLeaf2()->Mailed()) 3158 { 3159 BspNodeGeometry geom2; 3160 ConstructGeometry(mc.GetLeaf2(), geom2); 3161 //m.mDiffuseColor.r = (mc.GetLeaf2()->GetViewCell()->GetId() & 256)/ 255.0f; 3162 //m.mDiffuseColor.g = ((mc.GetLeaf2()->GetViewCell()->GetId()>>8) & 256)/ 255.0f; 3163 //m.mDiffuseColor.b = ((mc.GetLeaf2()->GetViewCell()->GetId()>>16) & 256)/ 255.0f; 3164 //exporter->SetForcedMaterial(m); 3165 exporter->ExportPolygons(geom2.mPolys); 3166 mc.GetLeaf2()->Mail(); 3167 } 3168 } 3169 3170 if (exporter) 3171 { 3172 cout << "finished" << endl; 3173 delete exporter; 3174 } 3175 #else 3176 while (!mMergeQueue.empty()) 3177 { 3178 BspMergeCandidate mc = mMergeQueue.top(); 3179 shuffleQueue->push(mc); 3180 mMergeQueue.pop(); 3181 } 3182 #endif 3122 } 3123 3183 3124 const int numPasses = 5; 3184 3125 int pass = 0; … … 3257 3198 //const int pvs1 = SubtractedPvsSize(vc1, leaf, *leaf->mPvs); 3258 3199 const int pvs1 = SubtractedPvsSize(vc1->GetPvs(), *leaf->mPvs); 3259 3260 3200 const int pvs2 = AddedPvsSize(vc2->GetPvs(), *leaf->mPvs); 3261 3201 … … 3277 3217 } 3278 3218 3279 const float cost1 = (float)pvs1 * p1;3280 const float cost2 = (float)pvs2 * p2;3219 const float cost1 = (float)pvs1;// * p1; 3220 const float cost2 = (float)pvs2;// * p2; 3281 3221 3282 3222 return cost1 + cost2; … … 3330 3270 BspViewCell *vc2 = leaf2->GetViewCell(); 3331 3271 3332 float cost1 ;3333 float cost2 ;3334 3335 if (mUseAreaForPvs)3272 float cost1 = vc1->GetPvs().GetSize(); 3273 float cost2 = vc2->GetPvs().GetSize(); 3274 3275 /*if (mUseAreaForPvs) 3336 3276 { 3337 3277 cost1 = vc1->GetPvs().GetSize() * vc1->GetArea(); … … 3342 3282 cost1 = vc1->GetPvs().GetSize() * vc1->GetVolume(); 3343 3283 cost2 = vc2->GetPvs().GetSize() * vc2->GetVolume(); 3344 } 3284 }*/ 3345 3285 3346 3286 const float oldCost = cost1 + cost2; … … 3450 3390 } 3451 3391 3392 3452 3393 /************************************************************************/ 3453 3394 /* BspMergeCandidate implementation */ -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r556 r570 21 21 #define USE_EXE_PATH false 22 22 23 23 #include <crtdbg.h> 24 24 25 25 … … 28 28 main(int argc, char **argv) 29 29 { 30 31 //Now just call this function at the start of your program and if you're 32 //compiling in debug mode (F5), any leaks will be displayed in the Output 33 //window when the program shuts down. If you're not in debug mode this will 34 //be ignored. Use it as you will! 35 //note: from GDNet Direct [3.8.04 - 3.14.04] void detectMemoryLeaks() { 36 _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF); 37 _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE); 38 _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR); 39 30 40 Debug.open("debug.log"); 31 41 environment = new Environment;
Note: See TracChangeset
for help on using the changeset viewer.