Changeset 1143 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 07/19/06 18:31:33 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1142 r1143 1446 1446 RegisterOption("ViewCells.PostProcess.avgCostMaxDeviation", 1447 1447 optFloat, 1448 "v sp_bsp_avgcost_max_deviations",1448 "view_cells_avgcost_max_deviations", 1449 1449 "0.5"); 1450 1450 … … 2217 2217 "true"); 2218 2218 2219 2220 2219 2221 /***************************************************************************/ 2220 2222 /* Object space partition tree related options */ 2221 2223 /***************************************************************************/ 2224 2222 2225 2223 2226 RegisterOption("OspTree.Construction.randomize", -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r1135 r1143 34 34 35 35 /// # of object references 36 int m ObjectRefs;36 int mReferences; 37 37 38 38 enum { MESH_INSTANCE, … … 44 44 }; 45 45 46 Intersectable():mMailbox(0), m ObjectRefs(0) {}46 Intersectable():mMailbox(0), mReferences(0) {} 47 47 48 48 void SetId(const int id) { mId = id; } -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r1122 r1143 295 295 // determine the side of this ray with respect to the plane 296 296 AxisAlignedBox3 box = (*mi)->GetBox(); 297 298 if (box.Max(axis) >= position ) 297 298 // for handling multiple objects: keep track of references 299 if (leaf->IsRoot()) 300 (*mi)->mReferences = 1; // initialise references at root 301 302 -- (*mi)->mReferences; // remove parent ref 303 304 305 if (box.Max(axis) >= position ) 306 { 299 307 front->mObjects.push_back(*mi); 300 308 ++ (*mi)->mReferences; 309 } 310 301 311 if (box.Min(axis) < position ) 312 { 302 313 back->mObjects.push_back(*mi); 303 314 ++ (*mi)->mReferences; 315 } 316 317 // store objects referenced in more than one leaf 318 // for easy access 319 ProcessMultipleRefs(back); 320 ProcessMultipleRefs(front); 321 304 322 mStat.objectRefs -= (int)leaf->mObjects.size(); 305 323 mStat.objectRefs += objectsBack + objectsFront; … … 308 326 delete leaf; 309 327 return node; 328 } 329 330 331 void KdTree::ProcessMultipleRefs(KdLeaf *leaf) const 332 { 333 // find objects from multiple kd-leaves 334 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 335 336 for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 337 { 338 Intersectable *object = *oit; 339 340 if (object->mReferences > 1) 341 { 342 leaf->mMultipleObjects.push_back(object); 343 } 344 } 310 345 } 311 346 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r1122 r1143 540 540 ); 541 541 542 /** does some post processing on the objects in the new child leaves. 543 */ 544 void ProcessMultipleRefs(KdLeaf *leaf) const; 542 545 543 546 int mTermMaxNodes; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1135 r1143 440 440 { 441 441 mVspTree = new VspTree(); 442 mOspTree = new OspTree(); 442 //mOspTree = new OspTree(); 443 // HACK 444 mOspTree = new OspTree(*mKdTree); 443 445 444 446 mViewCellsManager = new VspOspViewCellsManager(mVspTree, mOspTree); … … 446 448 else if (strcmp(name, "sceneDependent") == 0) 447 449 { 450 Debug << "view cell type: Bsp" << endl; 451 448 452 //TODO 449 453 mBspTree = new BspTree(); 450 451 Debug << "view cell type: Bsp" << endl;452 453 454 mViewCellsManager = new BspViewCellsManager(mBspTree); 454 455 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp
r1141 r1143 30 30 Intersectable *obj = (*it).first; 31 31 32 // found kd node 33 // the pvs is the sum of the objects in the leaves in the subtree 34 // We eliminate already accounted kd nodes and objects 35 // using mailboxing. 32 36 if (obj->Type() == Intersectable::KD_INTERSECTABLE) 33 37 { … … 51 55 if (node->IsLeaf()) 52 56 { 53 54 57 KdLeaf *leaf = dynamic_cast<KdLeaf *>(node); 55 58 56 59 pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 57 60 58 ObjectContainer::const_iterator it, it_end = leaf->mMultipleObjects.end(); 61 // Objects already accounted for can only be found among those 62 // which are referenced in more than one leaf 63 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 64 for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 59 65 { 60 Intersectable *object = * it;66 Intersectable *object = *oit; 61 67 62 68 if (!object->Mailed()) -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1142 r1143 2217 2217 2218 2218 2219 2220 2221 2219 void 2222 2220 ViewCellsManager::ApplyFilter(ViewCell *viewCell, … … 4257 4255 } 4258 4256 4259 const int maxDepth = mVspBspTree-> mBspStats.maxDepth;4257 const int maxDepth = mVspBspTree->GetStatistics().maxDepth; 4260 4258 4261 4259 ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); … … 4904 4902 long startTime; 4905 4903 4906 //mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox); 4907 //mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox); 4908 mHierarchyManager->Construct3(constructionRays, objects, &mViewSpaceBox); 4909 4910 //-- stats 4904 if (!mOspTree->GetRoot()) 4905 { 4906 cout << "constructing vsp and osp tree" << endl; 4907 //mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox); 4908 mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox); 4909 } 4910 else // just build view space partition tree 4911 { 4912 cout << "constructing only vsp tree" << endl; 4913 mHierarchyManager->Construct3(constructionRays, objects, &mViewSpaceBox); 4914 } 4915 4916 // print subdivision statistics 4911 4917 Debug << mVspTree->GetStatistics() << endl; 4912 4918 4919 // print view cell statistics 4913 4920 ResetViewCells(); 4914 4921 Debug << "\nView cells after construction:\n" << mCurrentViewCellsStats << endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r1022 r1143 640 640 mOspTree = new OspTree(); 641 641 642 // mCurrentBspNode = mVspBspTree->GetRoot();642 // hack 643 643 mViewCellsManager = new VspOspViewCellsManager(mVspTree, mOspTree); 644 644 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
r1142 r1143 401 401 402 402 if (!mUseKdPvsForHeuristics) 403 Debug << "pvs count method: per object" << endl;403 Debug << "pvs heuristics: per object" << endl; 404 404 else 405 Debug << "pvs count method: per kd node" << endl;405 Debug << "pvs heuristics: per kd node" << endl; 406 406 407 407 mSplitCandidates = new vector<SortableEntry>; … … 443 443 444 444 445 void VspTree::ComputeBoundingBox(const RayInfoContainer &rays,445 void VspTree::ComputeBoundingBox(const VssRayContainer &rays, 446 446 AxisAlignedBox3 *forcedBoundingBox) 447 447 { … … 454 454 mBoundingBox.Initialize(); 455 455 456 RayInfoContainer::const_iterator rit, rit_end = rays.end();456 VssRayContainer::const_iterator rit, rit_end = rays.end(); 457 457 458 458 //-- compute bounding box 459 459 for (rit = rays.begin(); rit != rit_end; ++ rit) 460 460 { 461 VssRay *ray = (*rit).mRay;461 VssRay *ray = *rit; 462 462 463 463 // compute bounding box of view space … … 499 499 bool VspTree::LocalTerminationCriteriaMet(const VspTraversalData &data) const 500 500 { 501 return(501 const bool localTerminationCriteriaMet = ( 502 502 ((int)data.mRays->size() <= mTermMinRays) || 503 503 (data.mPvs <= mTermMinPvs) || … … 506 506 (data.mDepth >= mTermMaxDepth) 507 507 ); 508 509 if (0 && localTerminationCriteriaMet) 510 { 511 Debug << "********local termination *********" << endl; 512 Debug << "rays: " << (int)data.mRays->size() << " " << mTermMinRays << endl; 513 Debug << "pvs: " << data.mPvs << " " << mTermMinPvs << endl; 514 Debug << "p: " << data.mProbability << " " << mTermMinProbability << endl; 515 Debug << "avg contri: " << data.GetAvgRayContribution() << " " << mTermMaxRayContribution << endl; 516 Debug << "depth " << data.mDepth << " " << mTermMaxDepth << endl; 517 } 518 519 return localTerminationCriteriaMet; 508 520 509 521 } … … 512 524 bool VspTree::GlobalTerminationCriteriaMet(const VspTraversalData &data) const 513 525 { 514 Debug << "cost misses " << mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 515 Debug << "leaves " << mVspStats.Leaves() << " " << mMaxViewCells << endl; 516 517 return ( 518 // mOutOfMemory || 526 const bool terminationCriteriaMet = ( 527 // mOutOfMemory || 519 528 (mVspStats.Leaves() >= mMaxViewCells) || 520 529 (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 521 ); 530 ); 531 532 if (0 && terminationCriteriaMet) 533 { 534 Debug << "********* terminationCriteriaMet *********" << endl; 535 Debug << "cost misses: " << mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 536 Debug << "leaves: " << mVspStats.Leaves() << " " << mMaxViewCells << endl; 537 } 538 return terminationCriteriaMet; 522 539 } 523 540 … … 559 576 } 560 577 578 // 561 579 viewCell->mLeaf = leaf; 562 580 563 581 viewCell->SetVolume(tData.mProbability); 564 582 leaf->mProbability = tData.mProbability; 565 566 mVspStats.contributingSamples += conSamp;567 mVspStats.sampleContributions += (int)sampCon;568 569 // finally evaluate statistics for this leaf570 EvaluateLeafStats(tData);571 583 } 572 584 … … 632 644 633 645 // delete old view cell 634 delete tData.mNode-> GetViewCell();646 delete tData.mNode->mViewCell; 635 647 // delete old leaf node 636 648 DEL_PTR(tData.mNode); 637 649 } 638 650 639 // subdivision terminated 640 if (newNode->IsLeaf()) 641 { 642 //-- create new view cell 643 //CreateViewCell(tData); 644 651 if (newNode->IsLeaf()) // subdivision terminated 652 { 653 //CreateViewCell(tData); // create new view cell 654 655 VspLeaf *leaf = dynamic_cast<VspLeaf *>(newNode); 656 ViewCell *viewCell = leaf->GetViewCell(); 657 658 int conSamp = 0; 659 float sampCon = 0.0f; 660 661 662 //-- store pvs optained from rays 663 AddSamplesToPvs(leaf, *tData.mRays, sampCon, conSamp); 664 665 // update scalar pvs size value 666 mViewCellsManager->SetScalarPvsSize(viewCell, viewCell->GetPvs().CountPvs()); 667 668 mVspStats.contributingSamples += conSamp; 669 mVspStats.sampleContributions += (int)sampCon; 670 645 671 //-- store additional info 646 672 if (mStoreRays) … … 771 797 772 798 // explicitely create front and back view cell 773 CreateViewCell(frontData, true);774 CreateViewCell(backData, true);799 CreateViewCell(frontData, false); 800 CreateViewCell(backData, false); 775 801 776 802 … … 907 933 908 934 ViewCellLeaf *vc = leaf->GetViewCell(); 909 910 935 911 936 // add contributions from samples to the PVS 912 937 for (it = rays.begin(); it != it_end; ++ it) … … 922 947 if (obj) 923 948 { 924 Intersectable *entry;925 926 949 // potentially visible kd cells 927 950 if (mStoreKdPvs) … … 945 968 if (obj) 946 969 { 947 Intersectable *entry;948 949 970 // potentially visible kd cells 950 971 if (mUseKdPvsForHeuristics) … … 2684 2705 OspTree::OspTree(): 2685 2706 mRoot(NULL), 2686 mTimeStamp(1) 2707 mTimeStamp(1), 2708 mCopyFromKdTree(false) 2709 { 2710 ReadEnvironment(); 2711 2712 mSplitCandidates = new vector<SortableEntry>; 2713 } 2714 2715 2716 OspTree::OspTree(const KdTree &kdTree) 2717 { 2718 ReadEnvironment(); 2719 2720 // copy values from kd tree 2721 mCopyFromKdTree = true; 2722 mBoundingBox = kdTree.GetBox(); 2723 mRoot = kdTree.GetRoot(); 2724 } 2725 2726 2727 OspTree::~OspTree() 2728 { 2729 KdIntersectableMap::iterator it, it_end = mKdIntersectables.end(); 2730 2731 for (it = mKdIntersectables.begin(); it != mKdIntersectables.end(); ++ it) 2732 { 2733 DEL_PTR((*it).second); 2734 } 2735 2736 // if not using kd tree root 2737 if (!mCopyFromKdTree) 2738 DEL_PTR(mRoot); 2739 } 2740 2741 2742 void OspTree::ReadEnvironment() 2687 2743 { 2688 2744 bool randomize = false; … … 2748 2804 Debug << "split borders: " << mSplitBorder << endl; 2749 2805 Debug << "render cost decrease weight: " << mRenderCostDecreaseWeight << endl; 2750 2751 2752 mSplitCandidates = new vector<SortableEntry>;2753 2754 2806 Debug << endl; 2755 2807 } 2756 2808 2757 2809 2758 OspTree::~OspTree() 2759 { 2760 KdIntersectableMap::iterator it, it_end = mKdIntersectables.end(); 2761 2762 for (it = mKdIntersectables.begin(); it != mKdIntersectables.end(); ++ it) 2763 { 2764 DEL_PTR((*it).second); 2765 } 2766 } 2767 2768 2769 void OspTree::SplitObjects(const AxisAlignedPlane & splitPlane, 2810 void OspTree::SplitObjects(KdLeaf *parent, 2811 const AxisAlignedPlane& splitPlane, 2770 2812 const ObjectContainer &objects, 2771 2813 ObjectContainer &front, … … 2777 2819 { 2778 2820 Intersectable *object = *oit; 2821 2822 // initialise 2823 if (parent->IsRoot()) 2824 object->mReferences = 1; 2825 2826 // remove parent ref 2827 -- object->mReferences; 2779 2828 2780 2829 // determine the side of this ray with respect to the plane … … 2784 2833 { 2785 2834 front.push_back(object); 2786 ++ object->m ObjectRefs;2835 ++ object->mReferences; 2787 2836 } 2788 2837 … … 2790 2839 { 2791 2840 back.push_back(object); 2792 ++ object->mObjectRefs; 2793 } 2794 2795 // remove parent reference 2796 -- object->mObjectRefs; 2841 ++ object->mReferences; 2842 } 2797 2843 } 2798 2844 … … 2890 2936 node->SetupChildLinks(back, front); 2891 2937 2892 SplitObjects(splitPlane, leaf->mObjects, front->mObjects, back->mObjects); 2893 //ProcessLeafObjects(leaf, front, back); 2894 2938 SplitObjects(leaf, splitPlane, leaf->mObjects, front->mObjects, back->mObjects); 2939 2940 ProcessMultipleRefs(front); 2941 ProcessMultipleRefs(back); 2942 2895 2943 backData.mNode = back; 2896 2944 frontData.mNode = front; … … 3604 3652 3605 3653 3606 #if DEPRECATED 3607 void OspTree::ProcessLeafObjects(KdLeaf *parent, KdLeaf *front, KdLeaf *back) const 3608 { 3609 if (parent) 3610 { 3611 // remove the parents from the set 3612 ObjectContainer::const_iterator oit, oit_end = parent->mObjects.end(); 3613 3614 for (oit = parent->mObjects.begin(); oit != oit_end; ++ oit) 3615 { 3616 Intersectable *object = *oit; 3617 3618 set<KdLeaf *>::iterator kdit = object->mKdLeaves.find(parent); 3619 3620 // remove parent leaf 3621 if (kdit != object->mKdLeaves.end()) 3622 object->mKdLeaves.erase(kdit); 3623 } 3624 } 3625 3626 //Intersectable::NewMail(); 3627 3628 if (front) 3629 { 3630 // Add front to leaf kd cells 3631 ObjectContainer::const_iterator oit, oit_end = front->mObjects.end(); 3632 3633 for (oit = front->mObjects.begin(); oit != oit_end; ++ oit) 3634 { 3635 Intersectable *object = *oit; 3636 object->mKdLeaves.insert(front); 3637 } 3638 } 3639 3640 if (back) 3641 { 3642 // Add back to leaf kd cells 3643 ObjectContainer::const_iterator oit, oit_end = back->mObjects.end(); 3644 3645 for (oit = back->mObjects.begin(); oit != oit_end; ++ oit) 3646 { 3647 Intersectable *object = *oit; 3648 object->mKdLeaves.insert(back); 3649 } 3650 } 3651 3652 // note: can find out about multiple objects only now after adding and deleting 3653 // finished 3654 if (front) 3655 { 3656 // find objects from multiple kd-leaves 3657 ObjectContainer::const_iterator oit, oit_end = front->mObjects.end(); 3658 3659 for (oit = front->mObjects.begin(); oit != oit_end; ++ oit) 3660 { 3661 Intersectable *object = *oit; 3662 3663 if (object->mKdLeaves.size() > 1) 3664 front->mMultipleObjects.push_back(object); 3665 } 3666 } 3667 3668 if (back) 3669 { 3670 // find objects from multiple kd-leaves 3671 ObjectContainer::const_iterator oit, oit_end = back->mObjects.end(); 3672 3673 for (oit = back->mObjects.begin(); oit != oit_end; ++ oit) 3674 { 3675 Intersectable *object = *oit; 3676 3677 if (object->mKdLeaves.size() > 1) 3678 back->mMultipleObjects.push_back(object); 3679 } 3680 } 3681 3682 } 3683 #endif 3654 void OspTree::ProcessMultipleRefs(KdLeaf *leaf) const 3655 { 3656 // find objects from multiple kd-leaves 3657 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 3658 3659 for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 3660 { 3661 Intersectable *object = *oit; 3662 3663 if (object->mReferences > 1) 3664 { 3665 leaf->mMultipleObjects.push_back(object); 3666 } 3667 } 3668 } 3669 3684 3670 3685 3671 void OspTree::CollectLeaves(vector<KdLeaf *> &leaves) const … … 3972 3958 3973 3959 3960 3974 3961 /********************************************************************/ 3975 3962 /* class HierarchyManager implementation */ … … 4003 3990 RayInfoContainer &rays) 4004 3991 { 4005 // get clipped rays4006 mVspTree.ProcessRays(sampleRays, rays);4007 4008 3992 // store pointer to this tree 4009 3993 VspTree::VspSplitCandidate::sVspTree = &mVspTree; … … 4011 3995 4012 3996 // compute view space bounding box 4013 mVspTree.ComputeBoundingBox(rays, forcedViewSpace); 4014 3997 mVspTree.ComputeBoundingBox(sampleRays, forcedViewSpace); 3998 3999 // initialise termination criteria 4015 4000 mVspTree.mTermMinProbability *= mBoundingBox.GetVolume(); 4016 4001 mVspTree.mGlobalCostMisses = 0; 4017 4002 4003 // get clipped rays 4004 mVspTree.ProcessRays(sampleRays, rays); 4018 4005 4019 4006 const int pvsSize = mVspTree.ComputePvsSize(rays); 4020 4007 4021 cout << "here450 pvs size: " << pvsSize << endl; 4022 // -- prepare view space partition 4008 Debug << "pvs size: " << pvsSize << endl; 4009 Debug << "rays size: " << rays.size() << endl; 4010 4011 //-- prepare view space partition 4023 4012 4024 4013 // add first candidate for view space partition … … 4038 4027 4039 4028 // create first view cell 4040 mVspTree.CreateViewCell(vData, true);4029 mVspTree.CreateViewCell(vData, false); 4041 4030 4042 4031 // add first view cell to all the objects view cell pvs … … 4088 4077 const float prop = mOspTree.mBoundingBox.GetVolume(); 4089 4078 4090 cout << "here40 pvs size: " << pvsSize << endl;4091 4079 // first osp traversal data 4092 4080 OspTree::OspTraversalData oData(kdleaf, … … 4098 4086 4099 4087 4100 //mOspTree.Process LeafObjects(NULL, kdleaf, NULL);4088 //mOspTree.ProcessMultipleRefs(NULL, kdleaf, NULL); 4101 4089 4102 4090 // compute first split candidate … … 4133 4121 4134 4122 4123 void HierarchyManager::Construct(const VssRayContainer &sampleRays, 4124 const ObjectContainer &objects, 4125 AxisAlignedBox3 *forcedViewSpace) 4126 { 4127 RayInfoContainer *objectSpaceRays = new RayInfoContainer(); 4128 RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 4129 4130 // prepare vsp and osp trees for traversal 4131 PrepareConstruction(sampleRays, objects, forcedViewSpace, *viewSpaceRays, *objectSpaceRays); 4132 4133 mVspTree.mVspStats.Reset(); 4134 mVspTree.mVspStats.Start(); 4135 4136 cout << "Constructing view space / object space tree ... \n"; 4137 const long startTime = GetTime(); 4138 4139 int i = 0; 4140 while (!FinishedConstruction()) 4141 { 4142 mCurrentCandidate = NextSplitCandidate(); 4143 4144 const bool globalTerminationCriteriaMet = 4145 GlobalTerminationCriteriaMet(mCurrentCandidate); 4146 4147 cout << "view cells: " << i ++ << endl; 4148 4149 // cost ratio of cost decrease / totalCost 4150 const float costRatio = mCurrentCandidate->GetPriority() / mTotalCost; 4151 //Debug << "cost ratio: " << costRatio << endl; 4152 4153 if (costRatio < mTermMinGlobalCostRatio) 4154 ++ mGlobalCostMisses; 4155 4156 //-- subdivide leaf node 4157 4158 // we have either a object space or view space split 4159 if (mCurrentCandidate->Type() == SplitCandidate::VIEW_SPACE) 4160 { 4161 VspTree::VspSplitCandidate *sc = 4162 dynamic_cast<VspTree::VspSplitCandidate *>(mCurrentCandidate); 4163 4164 VspNode *r = mVspTree.Subdivide(mTQueue, *sc, globalTerminationCriteriaMet); 4165 } 4166 else // object space split 4167 { 4168 OspTree::OspSplitCandidate *sc = 4169 dynamic_cast<OspTree::OspSplitCandidate *>(mCurrentCandidate); 4170 4171 KdNode *r = mOspTree.Subdivide(mTQueue, *sc, globalTerminationCriteriaMet); 4172 } 4173 4174 // reevaluate candidates affected by the split 4175 // for view space splits, this would be object space splits 4176 // and other way round 4177 RepairQueue(); 4178 4179 DEL_PTR(mCurrentCandidate); 4180 } 4181 4182 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 4183 4184 mVspTree.mVspStats.Stop(); 4185 } 4186 4187 4135 4188 void HierarchyManager::Construct2(const VssRayContainer &sampleRays, 4136 4189 const ObjectContainer &objects, … … 4139 4192 RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 4140 4193 RayInfoContainer *objectSpaceRays = new RayInfoContainer(); 4194 4195 ///////////////////////////////////////////////////////////// 4196 // view space space partition 4197 ///////////////////////////////////////////////////////////// 4141 4198 4142 4199 // makes no sense otherwise because only one kd cell available … … 4148 4205 mVspTree.mStoreKdPvs = false; 4149 4206 4150 mTQueue.Push(PrepareVsp(sampleRays, forcedViewSpace, *viewSpaceRays)); 4207 SplitCandidate *sc = PrepareVsp(sampleRays, forcedViewSpace, *viewSpaceRays); 4208 mTQueue.Push(sc); 4151 4209 4152 4210 long startTime = GetTime(); 4153 4211 cout << "starting vsp contruction ... " << endl; 4212 4213 mVspTree.mVspStats.Reset(); 4214 mVspTree.mVspStats.Start(); 4215 4154 4216 int i = 0; 4155 4217 … … 4186 4248 4187 4249 4188 ///////////////////////////////////////////////////////////// //4189 // --object space partition4250 ///////////////////////////////////////////////////////////// 4251 // object space partition 4190 4252 ///////////////////////////////////////////////////////////// 4191 4253 … … 4239 4301 AxisAlignedBox3 *forcedViewSpace) 4240 4302 { 4303 mVspTree.mVspStats.Reset(); 4304 mVspTree.mVspStats.Start(); 4305 4241 4306 RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 4242 4307 4243 4308 SplitCandidate *sc = PrepareVsp(sampleRays, forcedViewSpace, *viewSpaceRays); 4244 4309 mTQueue.Push(sc); … … 4257 4322 4258 4323 cout << "vsp nodes: " << i ++ << endl; 4259 4324 4260 4325 // cost ratio of cost decrease / totalCost 4261 4326 const float costRatio = splitCandidate->GetPriority() / mTotalCost; … … 4266 4331 4267 4332 //-- subdivide leaf node 4268 4333 4269 4334 // we have either a object space or view space split 4270 4335 VspTree::VspSplitCandidate *sc = … … 4278 4343 4279 4344 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 4280 mVspTree.mVspStats.Stop();4281 }4282 4283 4284 4285 void HierarchyManager::Construct(const VssRayContainer &sampleRays,4286 const ObjectContainer &objects,4287 AxisAlignedBox3 *forcedViewSpace)4288 {4289 RayInfoContainer *objectSpaceRays = new RayInfoContainer();4290 RayInfoContainer *viewSpaceRays = new RayInfoContainer();4291 4292 // prepare vsp and osp trees for traversal4293 PrepareConstruction(sampleRays, objects, forcedViewSpace, *viewSpaceRays, *objectSpaceRays);4294 4295 mVspTree.mVspStats.Reset();4296 mVspTree.mVspStats.Start();4297 4298 cout << "Constructing view space / object space tree ... \n";4299 const long startTime = GetTime();4300 4301 int i = 0;4302 while (!FinishedConstruction())4303 {4304 mCurrentCandidate = NextSplitCandidate();4305 4306 const bool globalTerminationCriteriaMet =4307 GlobalTerminationCriteriaMet(mCurrentCandidate);4308 4309 cout << "view cells: " << i ++ << endl;4310 4311 // cost ratio of cost decrease / totalCost4312 const float costRatio = mCurrentCandidate->GetPriority() / mTotalCost;4313 //Debug << "cost ratio: " << costRatio << endl;4314 4315 if (costRatio < mTermMinGlobalCostRatio)4316 ++ mGlobalCostMisses;4317 4318 //-- subdivide leaf node4319 4320 // we have either a object space or view space split4321 if (mCurrentCandidate->Type() == SplitCandidate::VIEW_SPACE)4322 {4323 VspTree::VspSplitCandidate *sc =4324 dynamic_cast<VspTree::VspSplitCandidate *>(mCurrentCandidate);4325 4326 VspNode *r = mVspTree.Subdivide(mTQueue, *sc, globalTerminationCriteriaMet);4327 }4328 else // object space split4329 {4330 OspTree::OspSplitCandidate *sc =4331 dynamic_cast<OspTree::OspSplitCandidate *>(mCurrentCandidate);4332 4333 KdNode *r = mOspTree.Subdivide(mTQueue, *sc, globalTerminationCriteriaMet);4334 }4335 4336 // reevaluate candidates affected by the split4337 // for view space splits, this would be object space splits4338 // and other way round4339 RepairQueue();4340 4341 DEL_PTR(mCurrentCandidate);4342 }4343 4344 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl;4345 4346 4345 mVspTree.mVspStats.Stop(); 4347 4346 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h
r1142 r1143 34 34 class OspTree; 35 35 class KdIntersectable; 36 37 38 36 class KdTree; 37 class VspTree; 39 38 class KdTreeStatistics; 39 40 40 41 41 42 template <typename T> class GtPriority … … 410 411 class VspLeaf: public VspNode 411 412 { 413 friend VspTree; 412 414 413 415 public: … … 802 804 float &pBack) const; 803 805 804 void ComputeBoundingBox(const RayInfoContainer &rays,805 AxisAlignedBox3 *forcedBoundingBox);806 void ComputeBoundingBox(const VssRayContainer &rays, 807 AxisAlignedBox3 *forcedBoundingBox); 806 808 807 809 /** Evaluates candidate for splitting. … … 1262 1264 OspTree(); 1263 1265 1266 OspTree(const KdTree &kdTree); 1267 1264 1268 /** Default destructor. 1265 1269 */ … … 1481 1485 OspTraversalData &backData); 1482 1486 1483 void SplitObjects(const AxisAlignedPlane & splitPlane, 1487 void SplitObjects(KdLeaf *leaf, 1488 const AxisAlignedPlane & splitPlane, 1484 1489 const ObjectContainer &objects, 1485 1490 ObjectContainer &front, 1486 1491 ObjectContainer &back); 1487 1492 1488 #if DEPRECATED 1489 /** does some post processing on the objects in the new child leaves. 1490 */ 1491 void ProcessLeafObjects(KdLeaf *parent, KdLeaf *front, KdLeaf *back) const; 1492 #endif 1493 /** does some post processing on the objects in the new child leaves. 1494 */ 1495 void ProcessMultipleRefs(KdLeaf *leaf) const; 1496 1493 1497 /** Selects an axis aligned for the next split. 1494 1498 @returns cost for this split … … 1603 1607 */ 1604 1608 void ComputeBoundingBox(const ObjectContainer &objects, 1605 AxisAlignedBox3 *forcedBoundingBox);1609 AxisAlignedBox3 *forcedBoundingBox); 1606 1610 1607 1611 void CollectDirtyCandidates(OspSplitCandidate *sc, … … 1616 1620 RayInfoContainer &rays); 1617 1621 1622 1623 void ReadEnvironment(); 1618 1624 1619 1625 protected: … … 1700 1706 /// stores the kd node intersectables used for pvs 1701 1707 KdIntersectableMap mKdIntersectables; 1708 1709 1710 private: 1711 1712 bool mCopyFromKdTree; 1702 1713 }; 1703 1714
Note: See TracChangeset
for help on using the changeset viewer.