Changeset 240 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 08/16/05 02:08:07 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.cpp
r191 r240 42 42 data = (*i).second; 43 43 } 44 45 BspPvsData *BspPvs::Find(BspNode *node) 46 { 47 BspPvsMap::iterator i = mEntries.find(node); 48 49 if (i != mEntries.end()) 50 { 51 // cout<<node<<" "<<(*i).first<<" "<<(*i).second.mVisibleSamples<<endl; 52 return &(*i).second; 53 } 54 else 55 return NULL; 56 } 57 58 // TODO: Get common ancestor for bsp and kd tree (HierarchyNode) 59 int BspPvs::AddNodeSample(BspNode *node) 60 { 61 int result; 62 63 BspPvsData *data = Find(node); 64 65 if (data) 66 { 67 data->mVisibleSamples ++; 68 result = 0; 69 } 70 else 71 { 72 mEntries[node] = BspPvsData(1); 73 result = 1; 74 } 75 76 return result; 77 } 78 79 80 void BspPvs::GetData(const int index, BspNode *&node, BspPvsData &data) 81 { 82 BspPvsMap::iterator i = mEntries.begin(); 83 84 for (int k = 0; k!=index && i != mEntries.end(); i++, k++); 85 86 node = (*i).first; 87 data = (*i).second; 88 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h
r191 r240 5 5 6 6 class KdNode; 7 class BspNode; 7 8 class Ray; 8 9 … … 17 18 }; 18 19 20 /** Superclass for all types of PVS data. 21 */ 22 class Pvs { 23 public: 24 Pvs(): mSamples(0) {} 25 int mSamples; 26 27 virtual int Compress() = 0; 28 virtual int GetSize() = 0; 29 }; 30 19 31 struct KdPvsData { 20 32 int mVisibleSamples; … … 26 38 27 39 28 class KdPvs {40 class KdPvs: public Pvs { 29 41 public: 30 int mSamples;42 31 43 KdPvsMap mEntries; 32 44 33 KdPvs():m Samples(0),mEntries() {}45 KdPvs():mEntries() {} 34 46 35 47 KdPvsData *Find(KdNode *node); … … 44 56 }; 45 57 58 struct LtBspNode 59 { 60 bool operator()(const BspNode *a, 61 const BspNode *b) const 62 { 63 return a < b; 64 } 65 }; 46 66 67 struct BspPvsData { 68 int mVisibleSamples; 69 BspPvsData() {} 70 BspPvsData(const int samples): mVisibleSamples(samples) {} 71 }; 72 73 typedef std::map<BspNode *, BspPvsData, LtBspNode> BspPvsMap; 74 75 class BspPvs: public Pvs 76 { 77 public: 78 BspPvs(): mEntries() {} 79 80 BspPvsMap mEntries; 81 82 BspPvsData *Find(BspNode *node); 83 int AddNodeSample(BspNode *node); 84 85 int Compress() {return 0;} 86 87 int GetSize() {return mEntries.size();} 88 89 void GetData(const int index, 90 BspNode *&node, 91 BspPvsData &data); 92 }; 47 93 48 94 #endif -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r239 r240 11 11 #include <iomanip> 12 12 13 #define INITIAL_ TEST_VAL 999999// unreachable high initial valuefor heuristic evaluation13 #define INITIAL_COST 999999// unreachable high initial cost for heuristic evaluation 14 14 15 15 int BspTree::sTermMaxPolygons = 10; … … 452 452 Plane3 BspTree::SelectPlaneHeuristics(PolygonContainer *polygons, int maxTests) const 453 453 { 454 int bestValue = INITIAL_TEST_VAL;454 int lowestCost = INITIAL_COST; 455 455 Plane3 *bestPlane = NULL; 456 456 … … 463 463 464 464 // evaluate current candidate 465 int candidate Value= EvalSplitPlane(polygons, candidatePlane);465 int candidateCost = EvalSplitPlane(polygons, candidatePlane); 466 466 467 if (candidate Value < bestValue)467 if (candidateCost < lowestCost) 468 468 { 469 469 bestPlane = &candidatePlane; 470 bestValue = candidateValue;471 //Debug << "new plane value " << bestValue<< endl;470 lowestCost = candidateCost; 471 //Debug << "new plane cost " << lowestCost << endl; 472 472 } 473 473 } … … 593 593 } 594 594 595 void BspTree::CollectLeaves(vector<BspLeaf *> &leaves) 596 { 597 stack<BspNode *> nodeStack; 598 nodeStack.push(mRoot); 599 600 while (!nodeStack.empty()) 601 { 602 BspNode *node = nodeStack.top(); 603 604 nodeStack.pop(); 605 606 if (node->IsLeaf()) 607 { 608 BspLeaf *leaf = (BspLeaf *)node; 609 610 leaves.push_back(leaf); 611 } else 612 { 613 BspInterior *interior = dynamic_cast<BspInterior *>(node); 614 nodeStack.push(interior->GetBack()); 615 nodeStack.push(interior->GetFront()); 616 } 617 } 618 } 619 620 int BspTree::CollectLeafPvs() 621 { 622 int totalPvsSize = 0; 623 624 stack<BspNode *> nodeStack; 625 626 nodeStack.push(mRoot); 627 628 while (!nodeStack.empty()) 629 { 630 BspNode *node = nodeStack.top(); 631 632 nodeStack.pop(); 633 634 if (node->IsLeaf()) 635 { 636 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 637 638 ViewCell *viewcell = leaf->GetViewCell(); 639 640 if (!viewcell->Mailed()) 641 { 642 viewcell->Mail(); 643 644 // add this node to pvs of all nodes it can see 645 BspPvsMap::iterator ni; 646 647 /* for (ni = object->mBspPvs.mEntries.begin(); ni != object->mKdPvs.mEntries.end(); ni++) 648 { 649 BspNode *node = (*ni).first; 650 651 // $$ JB TEMPORARY solution -> should add object PVS or explictly computed 652 // BSP tree PVS 653 if (leaf->mBspPvs.AddNodeSample(node)) 654 totalPvsSize++; 655 }*/ 656 } 657 } else 658 { 659 // traverse tree 660 BspInterior *interior = (BspInterior *)node; 661 662 nodeStack.push(interior->GetFront()); 663 nodeStack.push(interior->GetBack()); 664 } 665 } 666 667 return totalPvsSize; 668 } 669 595 670 void BspTree::EvaluateLeafStats(const BspTraversalData &data) 596 671 { -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r239 r240 230 230 void Construct(const ObjectContainer &objects); 231 231 232 int BspTree::CollectLeafPvs(); 233 234 void CollectLeaves(vector<BspLeaf *> &leaves); 232 235 233 236 protected:
Note: See TracChangeset
for help on using the changeset viewer.