Changeset 1789 for GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
- Timestamp:
- 11/25/06 00:19:18 (18 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.