Changeset 580 for trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
- Timestamp:
- 02/01/06 19:29:59 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r556 r580 30 30 // Static variables 31 31 int VspKdLeaf::sMailId = 0; 32 int MergeCandidate::sMaxPvsSize = 150;33 float MergeCandidate::sOverallCost = Limits::Small;32 int VspKdMergeCandidate::sMaxPvsSize = 150; 33 float VspKdMergeCandidate::sOverallCost = Limits::Small; 34 34 #define USE_FIXEDPOINT_T 0 35 35 … … 430 430 environment->GetFloatValue("VspKdTree.PostProcess.maxCostRatio", mMergeMaxCostRatio); 431 431 environment->GetIntValue("VspKdTree.PostProcess.maxPvsSize", 432 MergeCandidate::sMaxPvsSize);432 VspKdMergeCandidate::sMaxPvsSize); 433 433 434 434 environment->GetBoolValue("VspKdTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); … … 2173 2173 vc->SetArea(GetBBox(leaf).SurfaceArea()); 2174 2174 2175 vc->mLea ves.push_back(leaf);2175 vc->mLeaf = leaf; 2176 2176 2177 2177 for (it = leaf->GetRays().begin(); it != it_end; ++ it) … … 2200 2200 // if merge was unsuccessful 2201 2201 if (!vc) return false; 2202 2202 // TODO 2203 #if VC_HISTORY 2203 2204 // set new size of view cell 2204 2205 vc->SetVolume(fVc->GetVolume() + bVc->GetVolume()); … … 2223 2224 vc->mLeaves.push_back(*it); 2224 2225 } 2225 2226 #endif 2226 2227 vc->Mail(); 2227 2228 … … 2235 2236 void VspKdTree::CollectMergeCandidates() 2236 2237 { 2237 MergeCandidate::sOverallCost = 0;2238 VspKdMergeCandidate::sOverallCost = 0; 2238 2239 vector<VspKdLeaf *> leaves; 2239 2240 … … 2256 2257 // no leaf is part of two merge candidates 2257 2258 leaf->Mail(); 2258 MergeCandidate::sOverallCost +=2259 VspKdMergeCandidate::sOverallCost += 2259 2260 vc->GetVolume() * vc->GetPvs().GetSize(); 2260 2261 vector<VspKdLeaf *> neighbors; … … 2266 2267 for (nit = neighbors.begin(); nit != nit_end; ++ nit) 2267 2268 { 2268 mMergeQueue.push( MergeCandidate(leaf, *nit));2269 mMergeQueue.push(VspKdMergeCandidate(leaf, *nit)); 2269 2270 } 2270 2271 } … … 2273 2274 void VspKdTree::CollectMergeCandidates(const vector<VspKdRay *> &rays) 2274 2275 { 2275 MergeCandidate::sOverallCost = 0;2276 VspKdMergeCandidate::sOverallCost = 0; 2276 2277 2277 2278 vector<VspKdIntersection>::const_iterator iit; … … 2299 2300 leaf->Mail 2300 2301 // TODO: how to sort out doubles? 2301 MergeCandidate mc =MergeCandidate(leaf, previousLeaf);2302 VspKdMergeCandidate mc = VspKdMergeCandidate(leaf, previousLeaf); 2302 2303 mMergeQueue.push(mc); 2303 2304 2304 MergeCandidate::sOverallCost += mc.GetLeaf1Cost();2305 MergeCandidate::sOverallCost += mc.GetLeaf2Cost();2305 VspKdMergeCandidate::sOverallCost += mc.GetLeaf1Cost(); 2306 VspKdMergeCandidate::sOverallCost += mc.GetLeaf2Cost(); 2306 2307 2307 2308 previousLeaf = leaf; … … 2321 2322 while (!mMergeQueue.empty() && (vcSize > mMergeMinViewCells) && 2322 2323 (mMergeQueue.top().GetMergeCost() < 2323 mMergeMaxCostRatio * MergeCandidate::sOverallCost))2324 mMergeMaxCostRatio * VspKdMergeCandidate::sOverallCost)) 2324 2325 { 2325 2326 //Debug << "mergecost: " << mergeQueue.top().GetMergeCost() / 2326 // MergeCandidate::sOverallCost << " " << mMergeMaxCostRatio << endl;2327 MergeCandidate mc = mMergeQueue.top();2327 //VspKdMergeCandidate::sOverallCost << " " << mMergeMaxCostRatio << endl; 2328 VspKdMergeCandidate mc = mMergeQueue.top(); 2328 2329 mMergeQueue.pop(); 2329 2330 … … 2340 2341 -- vcSize; 2341 2342 // increase absolute merge cost 2342 MergeCandidate::sOverallCost += mc.GetMergeCost();2343 VspKdMergeCandidate::sOverallCost += mc.GetMergeCost(); 2343 2344 } 2344 2345 // merge candidate not valid, because one of the leaves was already … … 2378 2379 2379 2380 VspKdViewCell *viewCell = leaf->GetViewCell(); 2380 2381 #if VC_HISTORY 2381 2382 if (!viewCell->Mailed()) 2382 2383 { … … 2386 2387 2387 2388 viewCell->mLeaves.push_back(leaf); 2389 #endif 2388 2390 } 2389 2391 else … … 2468 2470 while (!mMergeQueue.empty()) 2469 2471 { 2470 MergeCandidate mc = mMergeQueue.top();2472 VspKdMergeCandidate mc = mMergeQueue.top(); 2471 2473 mMergeQueue.pop(); 2472 2474 … … 2501 2503 2502 2504 2503 float GetShuffledVcCost(VspKdLeaf *leaf, VspKdViewCell *vc1, VspKdViewCell *vc2)2505 float EvalShuffleCost(VspKdLeaf *leaf, VspKdViewCell *vc1, VspKdViewCell *vc2) 2504 2506 { 2505 2507 const int pvs1 = SubtractedPvsSize(vc1->GetPvs(), *leaf->mPvs); … … 2521 2523 { 2522 2524 // compute new pvs and area 2525 // TODO 2526 #if VC_HISTORY 2523 2527 vc1->GetPvs().SubtractPvs(*leaf->mPvs); 2524 2528 vc2->GetPvs().AddPvs(*leaf->mPvs); … … 2537 2541 2538 2542 leaf->SetViewCell(vc2); // finally change view cell 2543 #endif 2539 2544 } 2540 2545 … … 2554 2559 2555 2560 // the view cell should not be empty after the shuffle 2556 if (vc1->mLeaves.size() > 1) 2557 shuffledCost1 = GetShuffledVcCost(leaf1, vc1, vc2); 2561 //todo 2562 /* if (vc1->mLeaves.size() > 1) 2563 shuffledCost1 = EvalShuffleCost(leaf1, vc1, vc2); 2558 2564 if (vc2->mLeaves.size() > 1) 2559 shuffledCost2 = GetShuffledVcCost(leaf2, vc2, vc1);2560 2561 // shuffling unsuccessful2565 shuffledCost2 = EvalShuffleCost(leaf2, vc2, vc1); 2566 2567 */ // shuffling unsuccessful 2562 2568 if ((oldCost <= shuffledCost1) && (oldCost <= shuffledCost2)) 2563 2569 return false; … … 2581 2587 2582 2588 /*********************************************************************/ 2583 /* MergeCandidate implementation */2589 /* VspKdMergeCandidate implementation */ 2584 2590 /*********************************************************************/ 2585 2591 2586 2592 2587 MergeCandidate::MergeCandidate(VspKdLeaf *l1, VspKdLeaf *l2):2593 VspKdMergeCandidate::VspKdMergeCandidate(VspKdLeaf *l1, VspKdLeaf *l2): 2588 2594 mMergeCost(0), 2589 2595 mLeaf1(l1), … … 2595 2601 } 2596 2602 2597 float MergeCandidate::GetLeaf1Cost() const2603 float VspKdMergeCandidate::GetLeaf1Cost() const 2598 2604 { 2599 2605 VspKdViewCell *vc = mLeaf1->GetViewCell(); … … 2601 2607 } 2602 2608 2603 float MergeCandidate::GetLeaf2Cost() const2609 float VspKdMergeCandidate::GetLeaf2Cost() const 2604 2610 { 2605 2611 VspKdViewCell *vc = mLeaf2->GetViewCell(); … … 2607 2613 } 2608 2614 2609 void MergeCandidate::EvalMergeCost()2615 void VspKdMergeCandidate::EvalMergeCost() 2610 2616 { 2611 2617 //-- compute pvs difference … … 2630 2636 } 2631 2637 2632 void MergeCandidate::SetLeaf1(VspKdLeaf *l)2638 void VspKdMergeCandidate::SetLeaf1(VspKdLeaf *l) 2633 2639 { 2634 2640 mLeaf1 = l; 2635 2641 } 2636 2642 2637 void MergeCandidate::SetLeaf2(VspKdLeaf *l)2643 void VspKdMergeCandidate::SetLeaf2(VspKdLeaf *l) 2638 2644 { 2639 2645 mLeaf2 = l; … … 2641 2647 2642 2648 2643 VspKdLeaf * MergeCandidate::GetLeaf1()2649 VspKdLeaf *VspKdMergeCandidate::GetLeaf1() 2644 2650 { 2645 2651 return mLeaf1; … … 2647 2653 2648 2654 2649 VspKdLeaf * MergeCandidate::GetLeaf2()2655 VspKdLeaf *VspKdMergeCandidate::GetLeaf2() 2650 2656 { 2651 2657 return mLeaf2; … … 2653 2659 2654 2660 2655 bool MergeCandidate::Valid() const2661 bool VspKdMergeCandidate::Valid() const 2656 2662 { 2657 2663 return … … 2661 2667 2662 2668 2663 float MergeCandidate::GetMergeCost() const2669 float VspKdMergeCandidate::GetMergeCost() const 2664 2670 { 2665 2671 return mMergeCost; … … 2667 2673 2668 2674 2669 void MergeCandidate::SetValid()2675 void VspKdMergeCandidate::SetValid() 2670 2676 { 2671 2677 mLeaf1Id = mLeaf1->GetViewCell()->mMailbox;
Note: See TracChangeset
for help on using the changeset viewer.