Changeset 1789 for GTP/trunk/Lib/Vis
- Timestamp:
- 11/25/06 00:19:18 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1787 r1789 304 304 Environment::GetSingleton()->GetIntValue("BvHierarchy.minRaysForVisibility", mMinRaysForVisibility); 305 305 Environment::GetSingleton()->GetIntValue("BvHierarchy.maxTests", mMaxTests); 306 //Environment::GetSingleton()->GetBoolValue("BvHierarchy.Construction.useInitialSubdivision", mApplyInitialPartition);306 Environment::GetSingleton()->GetBoolValue("BvHierarchy.Construction.useInitialSubdivision", mApplyInitialPartition); 307 307 Environment::GetSingleton()->GetIntValue("BvHierarchy.Construction.Initial.minObjects", mInitialMinObjects); 308 308 Environment::GetSingleton()->GetFloatValue("BvHierarchy.Construction.Initial.maxAreaRatio", mInitialMaxAreaRatio); … … 957 957 958 958 const bool noValidSplit = ((objectsLeft <= Limits::Small) || (objectsRight <= Limits::Small)); 959 const float sum = 959 const float sum = noValidSplit ? 1e25 : objectsLeft * al + objectsRight * ar; 960 960 961 961 /*cout << "pos=" << (*cit).mPos << "\t q=(" << objectsLeft << "," << objectsRight <<")\t r=(" … … 1553 1553 } 1554 1554 1555 // no good results for degenerate axis split 1556 if (0 && tData.mNode->GetBoundingBox().Size(axis) < Limits::Small) 1557 nCostRatio[axis] += 9999; 1558 1555 1559 if ((bestAxis == -1) || (nCostRatio[axis] < nCostRatio[bestAxis])) 1556 1560 { … … 2149 2153 new BvhSubdivisionCandidate(oData); 2150 2154 2151 // evaluate priority2152 EvalSubdivisionCandidate(*oSubdivisionCandidate);2153 2155 bvhLeaf->SetSubdivisionCandidate(oSubdivisionCandidate); 2154 2156 … … 2156 2158 mPvsEntries = CountViewCells(objects); 2157 2159 2158 PrintSubdivisionStats(*oSubdivisionCandidate);2159 2160 2160 if (mApplyInitialPartition) 2161 2161 { 2162 ApplyInitialSubdivision(oSubdivisionCandidate, tQueue); 2162 vector<SubdivisionCandidate *> candidateContainer; 2163 2164 mIsInitialSubdivision = true; 2165 2166 // evaluate priority 2167 EvalSubdivisionCandidate(*oSubdivisionCandidate); 2168 PrintSubdivisionStats(*oSubdivisionCandidate); 2169 2170 ApplyInitialSubdivision(oSubdivisionCandidate, candidateContainer); 2171 2172 mIsInitialSubdivision = false; 2173 2174 vector<SubdivisionCandidate *>::const_iterator cit, cit_end = candidateContainer.end(); 2175 2176 for (cit = candidateContainer.begin(); cit != cit_end; ++ cit) 2177 { 2178 // reevaluate priority 2179 EvalSubdivisionCandidate(*oSubdivisionCandidate); 2180 tQueue.Push(*cit); 2181 } 2163 2182 } 2164 2183 else 2165 2184 { 2185 // evaluate priority 2186 EvalSubdivisionCandidate(*oSubdivisionCandidate); 2187 PrintSubdivisionStats(*oSubdivisionCandidate); 2188 2166 2189 tQueue.Push(oSubdivisionCandidate); 2167 2190 } 2191 2168 2192 cout << "!!size: " << GetStatistics().Leaves() << endl; 2169 2193 } … … 2510 2534 2511 2535 void BvHierarchy::ApplyInitialSubdivision(SubdivisionCandidate *firstCandidate, 2512 SplitQueue &tQueue) 2513 { 2514 mIsInitialSubdivision = true; 2515 2536 vector<SubdivisionCandidate *> &candidateContainer) 2537 { 2516 2538 SplitQueue tempQueue; 2517 2539 tempQueue.Push(firstCandidate); … … 2523 2545 BvhSubdivisionCandidate *bsc = 2524 2546 dynamic_cast<BvhSubdivisionCandidate *>(candidate); 2525 cout << "§§§§§§§§here49 "<< bsc->mParentData.mSortedObjects[3]->size() << " " << mInitialMinObjects << endl;2526 2547 2527 2548 const bool globalCriteriaMet = GlobalTerminationCriteriaMet(bsc->mParentData); 2528 2549 2529 2550 if (!InitialTerminationCriteriaMet(bsc->mParentData)) 2530 { 2531 cout << "here9"<<bsc->mParentData.mNode->mObjects.size()<<endl; 2551 {cout << "here9"<<endl; 2532 2552 BvhNode *node = Subdivide(tempQueue, bsc, globalCriteriaMet); 2533 2553 … … 2536 2556 } 2537 2557 else // initial preprocessing finished for this candidate 2538 {cout << "here1 4"<<endl;2558 {cout << "here19"<<endl; 2539 2559 // add to "real" traversal queue 2540 tQueue.Push(bsc); 2541 } 2542 } 2543 2544 mIsInitialSubdivision = false; 2560 candidateContainer.push_back(bsc); 2561 } 2562 } 2545 2563 } 2546 2564 … … 2550 2568 ObjectContainer &backObjects) 2551 2569 { 2552 cout << "*******here54 "<<tData.mSortedObjects[3]->size()<<endl;2553 2570 ObjectContainer *objects = tData.mSortedObjects[3]; 2554 2571 … … 2563 2580 2564 2581 ObjectContainer::const_iterator backObjectsStart = objects->begin(); 2565 2566 for (oit = objects->begin(); oit != (objects->end() - 1); ++ oit )2582 int dummy = 0; 2583 for (oit = objects->begin(); oit != (objects->end() - 1); ++ oit, ++ dummy) 2567 2584 { 2568 2585 Intersectable *objS = *oit; … … 2574 2591 if (areaDiff > maxAreaDiff) 2575 2592 { 2576 //cout << "here5 " << areaDiff << " " << maxAreaDiff << endl;2577 2593 maxAreaDiff = areaDiff; 2594 //cout << "maxAreaDiff : " << maxAreaDiff << " " << dummy << " " << objects->size() - dummy << endl; 2578 2595 backObjectsStart = oit + 1; 2579 2596 } … … 2583 2600 for (oit = objects->begin(); oit != backObjectsStart; ++ oit) 2584 2601 { 2585 backObjects.push_back(*oit);2602 frontObjects.push_back(*oit); 2586 2603 } 2587 2604 … … 2589 2606 for (oit = backObjectsStart; oit != oit_end; ++ oit) 2590 2607 { 2591 frontObjects.push_back(*oit); 2592 } 2608 backObjects.push_back(*oit); 2609 } 2610 TriangleIntersectable *tObj1 = (TriangleIntersectable *)frontObjects.back(); 2611 TriangleIntersectable *tObj2 = (TriangleIntersectable *)backObjects.front(); 2612 2613 cout << "here4 " << tObj1->GetItem().GetArea() << " " << tObj2->GetItem().GetArea() << endl; 2614 2615 2616 if (maxAreaDiff < 0.0001) 2617 cout << "big error!!!! " << maxAreaDiff << endl; 2618 2619 cout << "front: " << (int)frontObjects.size() << " back " << (int)backObjects.size() << " " << backObjects.front()->GetBox().SurfaceArea() - frontObjects.back()->GetBox().SurfaceArea() << endl; 2593 2620 } 2594 2621 -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1786 r1789 887 887 */ 888 888 void ApplyInitialSubdivision(SubdivisionCandidate *firstCandidate, 889 SplitQueue &tQueue);889 vector<SubdivisionCandidate *> &candidateContainer); 890 890 891 891 void ApplyInitialSplit(const BvhTraversalData &tData, -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1787 r1789 2020 2020 2021 2021 ObjectPvs pvs; 2022 //GetPvsRecursive(vc, pvs); 2023 2024 // uses mailing 2025 // warning: pvs not sorted!! 2022 2026 2023 if (vc->GetPvs().Empty()) 2027 2024 { 2025 // warning: uses mailing, pvs not sorted!! 2028 2026 GetPvsEfficiently(vc, pvs); 2027 //GetPvsRecursive(vc, pvs); 2029 2028 vc->SetPvs(pvs); 2030 2029 //cout << "q"; … … 2105 2104 //-- or the reverse order of subdivision for subdivision-only 2106 2105 //-- view cell hierarchies. 2107 2106 2108 2107 while (!tQueue.Empty()) 2109 2108 { … … 2114 2113 int entriesIncr; 2115 2114 2116 2115 if (nextCandidate->Type() == SubdivisionCandidate::VIEW_SPACE) 2117 2116 { 2118 2117 timeStamp = (int)-nextCandidate->GetPriority(); … … 2120 2119 VspNode *newNode = mVspTree->SubdivideAndCopy(tQueue, nextCandidate); 2121 2120 VspNode *oldNode = (VspNode *)nextCandidate->mEvaluationHack; 2122 2121 2123 2122 isLeaf = newNode->IsLeaf(); 2124 2123 //subStats.mRenderCostDecrease = oldNode->mRenderCostDecr; … … 2128 2127 { 2129 2128 timeStamp = (int)-nextCandidate->GetPriority(); 2130 2129 2131 2130 BvhNode *newNode = mBvHierarchy->SubdivideAndCopy(tQueue, nextCandidate); 2132 2131 BvhNode *oldNode = (BvhNode *)nextCandidate->mEvaluationHack; 2133 2132 2134 2133 isLeaf = newNode->IsLeaf(); 2135 2134 //subStats.mRenderCostDecrease = oldNode->mRenderCostDecr; 2136 2135 //entriesIncr = oldNode->mPvsEntriesIncr; 2137 2136 } 2138 2137 2139 2138 if (!isLeaf) 2140 2139 { … … 2164 2163 2165 2164 subStats.Print(stats); 2166 2165 2167 2166 } 2168 2167 -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r1786 r1789 32 32 template<typename T, typename S> 33 33 friend int operator< (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b); 34 template<typename T, typename S> 35 friend int operator== (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b); 34 36 }; 35 37 … … 39 41 { 40 42 return a.mObject < b.mObject; 43 } 44 45 template<typename T, typename S> 46 int operator== (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b) 47 { 48 return a.mObject == b.mObject; 41 49 } 42 50 … … 51 59 }; 52 60 61 template<typename T, typename S> 62 int equalSample (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b) 63 { 64 return a.mObject == b.mObject; 65 } 53 66 54 67 /** Information stored with a PVS entry. Consists of the number … … 189 202 190 203 /** Finds sample in PVS. 204 @param checkDirty if dirty part of the pvs should be checked for entry 205 (warning: linear runtime in dirty part) 191 206 @returns iterator on the sample. 192 207 */ 193 typename vector<PvsEntry<T, S> >::iterator Find(T sample );208 typename vector<PvsEntry<T, S> >::iterator Find(T sample, const bool checkDirty = true); 194 209 195 210 bool GetSampleContribution(T sample, const float pdf, float &contribution); … … 199 214 @returns true if sample was not already in PVS. 200 215 */ 201 bool AddSample(T sample, const float pdf, float &contribution);216 //bool AddSample(T sample, const float pdf, float &contribution); 202 217 203 218 /** Adds sample to PVS. … … 206 221 float AddSample(T sample, const float pdf); 207 222 208 /** Adds sample to PVS without checking for presence of the sample 209 pvs remians unsorted! 210 */ 211 void AddSampleDirty(T sample, const float pdf); 212 213 /** Sort pvs entries - this should always be called after a 214 sequence of AddSampleDirty calls */ 215 void Sort(); 216 223 /** Adds sample to PVS without checking for presence of the sample 224 pvs remains unsorted! 225 */ 226 void AddSampleDirty(T sample, const float pdf); 227 228 /** Adds sample dirty (on the end of the vector) but 229 first checks if sample is already in clean part of the pvs. 230 */ 231 bool AddSampleDirtyCheck(T sample, const float pdf);//, float &contribution); 232 233 /** Sort pvs entries - this should always be called after a 234 sequence of AddSampleDirty calls 235 */ 236 void Sort(); 237 217 238 /** Adds sample to PVS. Assumes that the pvs is sorted 218 239 @returns contribution of sample (0 or 1) … … 266 287 static void Merge(Pvs<T, S> &mergedPvs, const Pvs<T, S> &a, const Pvs<T, S> &b); 267 288 289 static void Merge(Pvs<T, S> &mergedPvs, 290 const typename std::vector<PvsEntry<T, S> >::const_iterator &aBegin, 291 const typename std::vector<PvsEntry<T, S> >::const_iterator &aEnd, 292 const typename std::vector<PvsEntry<T, S> >::const_iterator &bBegin, 293 const typename std::vector<PvsEntry<T, S> >::const_iterator &bEnd, 294 const int aSamples, 295 const int bSamples); 296 268 297 int GetSamples() const 269 298 { 270 299 return mSamples; 300 } 301 302 303 bool IsDirty() const 304 { 305 return mLastSorted < mEntries.size(); 306 } 307 308 bool RequiresResort() const 309 { 310 // the last part should not be more than log of the sorted part. this 311 // way we can achieve logarithmic behaviour for insertion and find 312 const int dirtySize = (int)mEntries.size() - mLastSorted; 313 return dirtySize > (int)(log((double)mEntries.size()) / log(2.0)); 314 } 315 316 317 int GetLastSorted() const 318 { 319 return mLastSorted; 271 320 } 272 321 … … 281 330 int mSamples; 282 331 283 /// Last sorted entry in the pvs (important for find and merge 284 int mLastSorted; 285 332 /// Last sorted entry in the pvs (important for find and merge) 333 int mLastSorted; 286 334 }; 287 335 … … 293 341 mEntries = samples; 294 342 mLastSorted = 0; 295 } 343 mSamples = samples.size(); 344 } 345 296 346 297 347 template <typename T, typename S> 298 348 void Pvs<T, S>::Sort() 299 349 { 300 std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin(); 301 it.inc(mLastSorted); 302 sort(it, mEntries.end()); 303 mLastSorted = mEntries.size() - 1; 304 } 350 std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted; 351 //std::vector<PvsEntry<T, S> >::const_iterator it = mEntries.begin() + mLastSorted; 352 std::vector<PvsEntry<T, S> >::iterator it_end = mEntries.end(); 353 354 // throw out double entries 355 std::vector<PvsEntry<T, S> >::iterator newEnd = unique(it, it_end); 356 sort(it, newEnd); 357 //sort(mEntries.begin(), mEntries.end()); 358 359 // now merge sorted ranges 360 ObjectPvs newPvs; 361 Merge(newPvs, 362 mEntries.begin(), it, 363 it, newEnd, 364 mSamples, 0); 365 366 mEntries = newPvs.mEntries; 367 mLastSorted = (int)mEntries.size(); 368 } 369 305 370 306 371 /** … … 436 501 std::vector<PvsEntry<T, S> >::const_iterator bit = b.mEntries.begin(), bit_end = b.mEntries.end(); 437 502 438 for (; (ait != ait_end); ++ ait) 503 Merge(mergedPvs, 504 ait, ait_end, 505 bit, bit_end, 506 a.mSamples, 507 b.mSamples); 508 } 509 510 511 template <typename T, typename S> 512 void Pvs<T, S>::Merge(Pvs<T, S> &mergedPvs, 513 const typename std::vector<PvsEntry<T, S> >::const_iterator &aBegin, 514 const typename std::vector<PvsEntry<T, S> >::const_iterator &aEnd, 515 const typename std::vector<PvsEntry<T, S> >::const_iterator &bBegin, 516 const typename std::vector<PvsEntry<T, S> >::const_iterator &bEnd, 517 const int aSamples, 518 const int bSamples) 519 { 520 std::vector<PvsEntry<T, S> >::const_iterator ait = aBegin; 521 std::vector<PvsEntry<T, S> >::const_iterator bit = bBegin; 522 523 for (; (ait != aEnd); ++ ait) 439 524 { 440 525 Intersectable *aObj = (*ait).mObject; 441 526 Intersectable *bObj = NULL; 442 PvsEntry<T, S> aEntry = (*ait); 443 444 for (; (bit != bit_end) && ((*bit).mObject <= (*ait).mObject); ++ bit) 527 //Intersectable *bObjOld = NULL; 528 529 const PvsEntry<T, S> &aEntry = (*ait); 530 531 for (; (bit != bEnd) && ((*bit).mObject <= (*ait).mObject); ++ bit) 445 532 { 446 533 bObj = (*bit).mObject; … … 457 544 mergedPvs.mEntries.push_back(*bit); 458 545 } 546 547 //bObjOld = bObj; 459 548 } 460 549 … … 468 557 469 558 // add the rest 470 for (; (bit != b it_end); ++ bit)559 for (; (bit != bEnd); ++ bit) 471 560 { 472 561 mergedPvs.mEntries.push_back(*bit); 473 562 } 474 mergedPvs.mSamples = a.mSamples + b.mSamples; 563 564 mergedPvs.mSamples = aSamples + bSamples; 475 565 } 476 566 … … 480 570 mEntries.clear(); 481 571 mSamples = 0; 572 mLastSorted = 0; 482 573 483 574 if (trim) … … 495 586 496 587 template <typename T, typename S> 497 typename std::vector<PvsEntry<T, S> >::iterator Pvs<T, S>::Find(T sample )588 typename std::vector<PvsEntry<T, S> >::iterator Pvs<T, S>::Find(T sample, const bool checkDirty) 498 589 { 499 590 PvsEntry<T, S> dummy(sample, PvsData()); 500 vector<PvsEntry<T, S> >::iterator it = lower_bound(mEntries.begin(), mEntries.end(), dummy); 501 591 592 // only check clean part 593 //mLastSorted = 0; 594 vector<PvsEntry<T, S> >::iterator sorted_end = mEntries.begin() + mLastSorted; 595 if (sorted_end != mEntries.end()) 596 cout << "not entries end!! " << endl; 597 // binary search 598 vector<PvsEntry<T, S> >::iterator it = lower_bound(mEntries.begin(), sorted_end, dummy); 599 600 // sample not found yet => search further in the unsorted part 601 if (checkDirty && 602 ((it == mEntries.end()) || ((*it).mObject != sample))) 603 { 604 vector<PvsEntry<T, S> >::const_iterator it_end = mEntries.end(); 605 for (it = sorted_end; (it != it_end) && ((*it).mObject != sample); ++ it); 606 } 607 else cout << "f "; 502 608 return it; 503 609 } … … 519 625 { 520 626 ++ mSamples; 627 cout << "! "; 521 628 std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 522 629 523 630 if ((it != mEntries.end()) && ((*it).mObject == sample)) 524 { 631 { cout << "g"; 525 632 S &data = (*it).mData; 526 633 data.mSumPdf += pdf; … … 528 635 } 529 636 else 530 { 637 {cout << "t"; 531 638 PvsEntry<T, S> entry(sample, pdf); 532 639 mEntries.insert(it, entry); 640 ++ mLastSorted; 533 641 return pdf; 534 642 } 643 cout << " $"; 535 644 } 536 645 … … 539 648 void Pvs<T, S>::AddSampleDirty(T sample, const float pdf) 540 649 { 541 542 650 ++ mSamples; 651 mEntries.push_back(PvsEntry<T, S>(sample, pdf)); 543 652 } 544 653 … … 548 657 { 549 658 ++ mSamples; 659 550 660 std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 551 661 … … 559 669 PvsEntry<T, S> entry(sample, pdf); 560 670 mEntries.insert(it, entry); 671 ++ mLastSorted; 561 672 } 562 673 … … 565 676 566 677 567 template <typename T, typename S>678 /*template <typename T, typename S> 568 679 bool Pvs<T, S>::AddSample(T sample, 569 680 const float pdf, … … 589 700 mEntries.insert(it, entry); 590 701 contribution = 1.0f; 702 ++ mLastSorted; 703 704 return true; 705 } 706 }*/ 707 708 709 /** Adds sample dirty (on the end of the vector) but 710 first checks if sample is already in clean part of the pvs. 711 */ 712 template <typename T, typename S> 713 bool Pvs<T, S>::AddSampleDirtyCheck(T sample, 714 const float pdf) 715 //,float &contribution) 716 { 717 ++ mSamples; 718 719 std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 720 721 if ((it != mEntries.end()) && ((*it).mObject == sample)) 722 { 723 S &data = (*it).mData; 724 725 data.mSumPdf += pdf; 726 //contribution = pdf / data.mSumPdf; 727 728 return false; 729 } 730 else 731 { 732 AddSampleDirty(sample, pdf); 733 //contribution = 1.0f; 591 734 592 735 return true; … … 620 763 { 621 764 -- mSamples; 622 765 623 766 std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 624 767 … … 633 776 { 634 777 mEntries.erase(it); 778 -- mLastSorted; // wrong if sample was in tail!! 635 779 } 636 780 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1786 r1789 263 263 float &contribution) 264 264 { 265 const bool result = mPvs.AddSample(sample, pdf , contribution);265 const bool result = mPvs.AddSample(sample, pdf);//, contribution); 266 266 // have to recompute pvs size 267 267 mPvsSizeValid = false; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r1715 r1789 2699 2699 if (!ray->intersections.empty()) 2700 2700 contribution += vc->GetPvs().AddSample(ray->intersections[0].mObject, 2701 1.0f ,2702 relContribution);2701 1.0f); 2702 //relContribution); 2703 2703 2704 2704 if (ray->sourceObject.mObject) 2705 2705 contribution += vc->GetPvs().AddSample(ray->sourceObject.mObject, 2706 1.0f ,2707 relContribution);2706 1.0f); 2707 //relContribution); 2708 2708 2709 2709 if (contribution) -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1787 r1789 1956 1956 } 1957 1957 1958 1958 /* 1959 1959 void 1960 1960 ViewCellsManager::AddSampleContributions(const VssRayContainer &rays) … … 1964 1964 1965 1965 VssRayContainer::const_iterator it, it_end = rays.end(); 1966 1966 cout <<"here60"<<endl; 1967 1967 for (it = rays.begin(); it != it_end; ++ it) { 1968 1968 AddSampleContributions(*(*it)); 1969 1969 } 1970 1970 } 1971 1971 */ 1972 1972 1973 1973 int ViewCellsManager::GetMinPvsSize() const … … 1983 1983 } 1984 1984 1985 1985 /* 1986 1986 void 1987 1987 ViewCellsManager::AddSampleContributions(VssRay &ray) 1988 { 1988 {cout << "here12" << endl; 1989 1989 // assumes viewcells have been stored... 1990 1990 ViewCellContainer *viewcells = &ray.mViewCells; … … 2008 2008 } 2009 2009 } 2010 2010 */ 2011 2011 2012 2012 float ViewCellsManager::ComputeSampleContribution(VssRay &ray, 2013 2013 const bool addRays, 2014 2014 const bool storeViewCells) 2015 { 2015 {cout << "$$$$$$$$$$$$$4here10" << endl; 2016 2016 ViewCellContainer viewcells; 2017 2017 … … 3470 3470 if (sortViewCells) 3471 3471 { // sort view cells to visualize the largest view cells 3472 s table_sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost);3472 sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 3473 3473 } 3474 3474 … … 4824 4824 { 4825 4825 // sort view cells to visualize the largest view cells 4826 s table_sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost);4826 sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 4827 4827 } 4828 4828 … … 5278 5278 5279 5279 5280 VspOspViewCellsManager::VspOspViewCellsManager(ViewCellsTree *vcTree, const string &hierarchyType) 5280 VspOspViewCellsManager::VspOspViewCellsManager(ViewCellsTree *vcTree, 5281 const string &hierarchyType) 5281 5282 : ViewCellsManager(vcTree) 5282 5283 { … … 5297 5298 mHierarchyManager->SetViewCellsTree(mViewCellsTree); 5298 5299 } 5300 5299 5301 5300 5302 Intersectable * … … 5307 5309 #endif 5308 5310 } 5311 5309 5312 5310 5313 HierarchyManager *VspOspViewCellsManager::CreateHierarchyManager(const string &hierarchyType) … … 5675 5678 Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 5676 5679 5677 Vector3 scale(0.9f, 0.9f, 0.9f); 5680 //Vector3 scale(0.9f, 0.9f, 0.9f); 5681 Vector3 scale(1.0f, 1.0f, 1.0f); 5682 5678 5683 if (exporter) 5679 5684 { … … 5773 5778 { 5774 5779 // sort view cells to visualize the view cells with highest render cost 5775 s table_sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost);5780 sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 5776 5781 } 5777 5782 … … 6055 6060 float tmin = 0, tmax = 1.0; 6056 6061 6057 6058 6062 if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 6059 6063 return 0; … … 6069 6073 if (storeViewCells) 6070 6074 { 6071 6072 6073 6075 // copy viewcells memory efficiently 6076 ray.mViewCells.reserve(viewcells.size()); 6077 ray.mViewCells = viewcells; 6074 6078 } 6075 6079 … … 6078 6082 Intersectable *terminationObj = GetIntersectable(ray, true); 6079 6083 Intersectable *originObj = GetIntersectable(ray, false); 6080 6081 for (; it != viewcells.end(); ++ it) { 6082 ViewCell *viewcell = *it; 6083 6084 if (viewcell->GetValid()) 6084 6085 for (; it != viewcells.end(); ++ it) 6086 { 6087 ViewCell *viewcell = *it; 6088 6089 if (viewcell->GetValid()) 6085 6090 { // if ray not outside of view space 6086 6087 6088 6091 float contribution; 6092 6093 if (terminationObj) 6089 6094 { 6090 6091 6092 6095 // todo: maybe not correct for kd node pvs 6096 /* if (viewcell->GetPvs().GetSampleContribution( 6097 terminationObj, ray.mPdf, contribution)) 6093 6098 { 6094 6099 ++ ray.mPvsContribution; 6095 6100 } 6096 6097 ray.mRelativePvsContribution += contribution; 6101 ray.mRelativePvsContribution += contribution;*/ 6098 6102 } 6099 6100 6101 6102 6103 6104 6103 6104 //////////////// 6105 //-- for directional sampling it is important to count 6106 //-- only contributions made in one direction! 6107 //-- the other contributions of this sample will be counted for the opposite ray! 6108 6105 6109 #if SAMPLE_ORIGIN_OBJECTS 6106 6107 6108 6109 6110 6110 6111 /* if (originObj && 6112 viewcell->GetPvs().GetSampleContribution(originObj, 6113 ray.mPdf, 6114 contribution)) 6111 6115 { 6112 6113 6114 } 6116 ++ ray.mPvsContribution; 6117 ray.mRelativePvsContribution += contribution; 6118 }*/ 6115 6119 #endif 6116 6120 } 6117 6121 } 6118 6122 6119 6123 if (!addRays) 6120 6124 { … … 6131 6135 6132 6136 //$$JB hack 6133 viewCell->GetPvs().AddSample(terminationObj, ray.mPdf); 6134 6137 float contrib; 6138 //viewCell->GetPvs().AddSampleDirtyCheck(terminationObj, ray.mPdf, contrib); 6139 viewCell->GetPvs().AddSample(terminationObj, ray.mPdf);//, contrib); 6140 6141 if (viewCell->GetPvs().GetSize() == 50) 6142 //if (viewCell->GetPvs().RequiresResort()) 6143 {Intersectable::NewMail(); 6144 cout << "\nbefore sort: " << viewCell->GetPvs().GetLastSorted() << " \n"; 6145 ObjectPvsIterator pit = viewCell->GetPvs().GetIterator(); int i = 0; 6146 while (pit.HasMoreEntries()) 6147 { 6148 ObjectPvsEntry entry = pit.Next(); 6149 Intersectable *object = entry.mObject; 6150 6151 if ((i ++) == viewCell->GetPvs().GetLastSorted()) 6152 cout << "| "; 6153 6154 //if (object->Mailed()) cout << "error!!"<<endl; 6155 object->Mail(); 6156 cout << (int)object << " "; 6157 } 6158 6159 //viewCell->GetPvs().Sort(); 6160 6161 /*cout << "\nafter sort\n"; 6162 pit = viewCell->GetPvs().GetIterator(); i = 0; 6163 while (pit.HasMoreEntries()) 6164 { 6165 ObjectPvsEntry entry = pit.Next(); 6166 Intersectable *object = entry.mObject; 6167 6168 if ((i ++) == viewCell->GetPvs().GetLastSorted()) 6169 cout << "| "; 6170 cout << (int)object << " "; 6171 }*/ 6172 } 6173 //else cout << "b"; 6135 6174 #if SAMPLE_ORIGIN_OBJECTS 6136 viewCell->GetPvs().AddSample(originObj, ray.mPdf);6137 #endif 6138 } 6139 6175 //viewCell->GetPvs().AddSample(originObj, ray.mPdf); 6176 #endif 6177 } 6178 6140 6179 return ABS_CONTRIBUTION_WEIGHT*ray.mPvsContribution + 6141 6180 (1.0f - ABS_CONTRIBUTION_WEIGHT)*ray.mRelativePvsContribution; 6142 6181 } 6143 6182 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1787 r1789 131 131 /** Add sample contributions to the viewcells they intersect 132 132 */ 133 void AddSampleContributions(const VssRayContainer &rays);133 //void AddSampleContributions(const VssRayContainer &rays); 134 134 135 135 … … 144 144 const bool storeViewCells); 145 145 146 virtual void AddSampleContributions(VssRay &ray);146 //virtual void AddSampleContributions(VssRay &ray); 147 147 148 148 /** Prints out statistics of the view cells. -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1773 r1789 1357 1357 // C = ct_div_ci + (ql*rl + qr*rr)/queries 1358 1358 1359 int pvsl = 0;1360 int pvsr =pvsSize;1361 1362 int pvsBack = pvsl;1363 int pvsFront = pvsr;1359 float pvsl = 0; 1360 float pvsr = (float)pvsSize; 1361 1362 float pvsBack = pvsl; 1363 float pvsFront = pvsr; 1364 1364 1365 1365 float sum = (float)pvsSize * sizeBox; … … 1504 1504 const float pFront = maxBox - position; 1505 1505 1506 const float penaltyOld = EvalPvsPenalty( pvsSize, lowerPvsLimit, upperPvsLimit);1506 const float penaltyOld = EvalPvsPenalty((float)pvsSize, lowerPvsLimit, upperPvsLimit); 1507 1507 const float penaltyFront = EvalPvsPenalty(pvsFront, lowerPvsLimit, upperPvsLimit); 1508 1508 const float penaltyBack = EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r1627 r1789 243 243 for (fit = fit_begin; fit != fit_end; ++ fit) 244 244 { 245 //cout << "f";246 245 // triangulate the faces 247 246 Face *face = *fit;
Note: See TracChangeset
for help on using the changeset viewer.