Changeset 352 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 10/27/05 18:50:39 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r350 r352 9 9 # filename vienna.x3d 10 10 # filename ../data/vienna/vienna-simple.x3d 11 #filename ../data/vienna/vienna-buildings.x3d11 filename ../data/vienna/vienna-buildings.x3d 12 12 # filename ../data/vienna/viewcells-25-sel.x3d 13 filename ../data/atlanta/atlanta2.x3d13 # filename ../data/atlanta/atlanta2.x3d 14 14 # filename ../data/soda/soda.dat 15 15 # filename ../data/soda/soda5.dat … … 76 76 BspTree { 77 77 Construction { 78 input fromRays78 # input fromRays 79 79 # input fromViewCells 80 #input fromSceneGeometry80 input fromSceneGeometry 81 81 samples 150000 82 82 sideTolerance 0.005 … … 114 114 115 115 #splitPlaneStrategy 384 116 splitPlaneStrategy 130 116 #splitPlaneStrategy 130 117 118 splitPlaneStrategy 66 117 119 118 120 maxCandidates 80 … … 120 122 Termination { 121 123 # autopartition 122 maxRays 30123 maxPolygons 0124 maxRays -1 125 maxPolygons 250 124 126 maxDepth 100 125 127 126 # axis aligned split127 maxPolysForAxisAligned 200128 # axis aligned splits 129 maxPolysForAxisAligned 400 128 130 maxCostRatio 0.9 129 131 ct_div_ci 0.5 -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r350 r352 742 742 743 743 // export scene geometry 744 if ( 1)744 if (0) 745 745 { 746 746 Material m;//= RandomMaterial(); -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp
r338 r352 5 5 #include "Triangle3.h" 6 6 7 ViewCell::ViewCell(): MeshInstance(NULL) 7 ViewCell::ViewCell(): MeshInstance(NULL), mPiercingRays(0) 8 8 { 9 9 } 10 10 11 ViewCell::ViewCell(Mesh *mesh): MeshInstance(mesh) 11 ViewCell::ViewCell(Mesh *mesh): MeshInstance(mesh), mPiercingRays(0) 12 12 { 13 13 } … … 80 80 } 81 81 82 ViewCell *ViewCell::MergeViewCells(const ViewCell &front, const ViewCell &back) 83 { 84 /*stable_sort(front.mPiercingRays.begin(), front.mPiercingRays.end()); 85 stable_sort(back.mPiercingRays.begin(), back.mPiercingRays.end()); 86 87 ViewCell *vc = front.Merge(back); 88 89 if (vc) 90 return vc; 91 92 return back.Merge(front);*/return NULL; 93 } 94 95 ViewCell *ViewCell::Merge(const ViewCell &other) const 96 { 97 //-- compute set differences 98 const float minDif = 10; 99 100 RayContainer diff; 101 102 set_difference(mPiercingRays.begin(), mPiercingRays.end(), 103 other.mPiercingRays.begin(), other.mPiercingRays.end(), 104 diff.begin()); 105 106 if (diff.size() < minDif) 107 { 108 ViewCell *vc = new ViewCell(); 109 110 RayContainer::const_iterator it, it_end = other.mPiercingRays.end(); 111 112 for (it = other.mPiercingRays.begin(); it != it_end; ++ it) 113 vc->mPiercingRays.push_back(*it); 114 115 while (!diff.empty()) 116 { 117 vc->mPiercingRays.push_back(diff.back()); 118 diff.pop_back(); 119 } 120 121 return vc; 122 } 123 124 return NULL; 125 } 126 127 82 128 void ViewCell::AddPassingRay(const Ray &ray, const int contributions) 83 129 { -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h
r311 r352 37 37 const int maxViewCells); 38 38 39 40 /** Adds a passing ray to the passing ray container. 41 */ 42 void AddPassingRay(const Ray &ray, const int contributions); 43 39 44 /** Constructs view cell from base triangle. The ViewCell is extruded along the normal vector. 40 45 @param the base triangle … … 43 48 static ViewCell *ExtrudeViewCell(const Triangle3 &baseTri, const float height); 44 49 45 void AddPassingRay(const Ray &ray, const int contributions); 50 /** Merges two view cells based on some criteria 51 @returns new view cell if merge was success. NULL if merge failed. 52 */ 53 static ViewCell *MergeViewCells(const ViewCell &front, const ViewCell &back); 46 54 47 static bool ParseEnvironment();48 55 49 / ** Ray set description of the rays passing through this node */56 /// Ray set description of the rays passing through this node. 50 57 PassingRaySet mPassingRays; 51 58 59 /// Rays piercing this view cell. 60 RayContainer mPiercingRays; 61 52 62 protected: 63 64 /** Merges view cell with other view cell if certain criteria are met. 65 @note because of performance issues the precondition is that the piercing rays are ordered. 66 */ 67 ViewCell *Merge(const ViewCell &other) const; 53 68 54 69 /// the potentially visible objects -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r351 r352 220 220 //-- inherit rays from parent polygon 221 221 poly->InheritRays(*front_piece, *back_piece); 222 Debug << "p: " << poly->mPiercingRays.size() << " f: " << front_piece->mPiercingRays.size() << " b: " << back_piece->mPiercingRays.size() << endl;222 //Debug << "p: " << poly->mPiercingRays.size() << " f: " << front_piece->mPiercingRays.size() << " b: " << back_piece->mPiercingRays.size() << endl; 223 223 224 224 // check if polygons still valid … … 250 250 /* class BspLeaf implementation */ 251 251 /****************************************************************/ 252 BspLeaf::BspLeaf(): mViewCell(NULL) , mPiercingRays(0)252 BspLeaf::BspLeaf(): mViewCell(NULL) 253 253 { 254 254 } 255 255 256 256 BspLeaf::BspLeaf(ViewCell *viewCell): 257 mViewCell(viewCell) , mPiercingRays(0)257 mViewCell(viewCell) 258 258 { 259 259 } 260 260 261 261 BspLeaf::BspLeaf(BspInterior *parent): 262 BspNode(parent), mViewCell(NULL) , mPiercingRays(0)262 BspNode(parent), mViewCell(NULL) 263 263 {} 264 264 265 265 BspLeaf::BspLeaf(BspInterior *parent, ViewCell *viewCell): 266 BspNode(parent), mViewCell(viewCell) , mPiercingRays(0)266 BspNode(parent), mViewCell(viewCell) 267 267 { 268 268 } … … 285 285 void BspLeaf::GenerateViewCell(const RayContainer &rays, 286 286 int &sampleContributions, 287 int &contributingSamples) 287 int &contributingSamples, 288 const bool storeRays) 288 289 { 289 290 sampleContributions = 0; … … 311 312 ++ contributingSamples; 312 313 } 314 315 if (storeRays) 316 mViewCell->mPiercingRays.push_back(*it); 313 317 } 314 318 } … … 694 698 leaf->ProcessPolygons(tData.mPolygons, sStoreSplitPolys); 695 699 DEL_PTR(tData.mPolygons); 696 697 if (mStorePiercingRays)698 {699 RayContainer::const_iterator it, it_end = tData.mRays->end();700 for (it = tData.mRays->begin(); it != it_end; ++ it)701 {702 leaf->mPiercingRays.push_back(*it);703 }704 }705 700 DEL_PTR(tData.mRays); 706 701 … … 1580 1575 nodeStack.push(mRoot); 1581 1576 1582 BspLeaf * rightLeaf = NULL;1577 BspLeaf *storedLeaf = NULL; 1583 1578 1584 1579 while (!nodeStack.empty()) … … 1591 1586 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 1592 1587 1593 if (rightLeaf && MergeNecessary(leaf, rightLeaf)) 1594 MergeLeafs(leaf, rightLeaf); 1588 if (storedLeaf) 1589 MergeLeafs(leaf, storedLeaf); 1590 1591 // store current leaf 1592 storedLeaf = leaf; 1595 1593 } 1596 1594 else … … 1605 1603 } 1606 1604 1607 bool BspTree::MergeNecessary(BspLeaf *front, BspLeaf *back) const 1608 { 1609 if ((front->mPiercingRays.size() < 2) || 1610 (back->mPiercingRays.size() < 2)) 1611 return true; 1612 //else if ((Raydiff(front, back) > 100) || 1613 // (Raydiff(back, front) > 100))return true; 1614 1615 return false; 1616 } 1617 1618 void BspTree::MergeLeafs(BspLeaf *front, BspLeaf *back) 1605 void BspTree::MergeLeafs(BspLeaf *front, BspLeaf *back) const 1619 1606 { 1620 1607 //std::merge(front->mPvs.mEntries.begin(), back->mPvs.mEntries.begin()); 1621 ViewCell *viewCell = new ViewCell(); 1622 viewCell->GetPvs().Merge(front->mViewCell->GetPvs(), back->mViewCell->GetPvs()); 1623 1624 DEL_PTR(front->mViewCell); 1625 DEL_PTR(back->mViewCell); 1626 1627 front->SetViewCell(viewCell); 1628 back->SetViewCell(viewCell); 1608 ViewCell *viewCell = ViewCell::MergeViewCells(*front->mViewCell, *back->mViewCell); 1609 //viewCell->GetPvs().Merge(front->mViewCell->GetPvs(), back->mViewCell->GetPvs()); 1610 1611 if (viewCell) 1612 { 1613 DEL_PTR(front->mViewCell); 1614 DEL_PTR(back->mViewCell); 1615 1616 front->SetViewCell(viewCell); 1617 back->SetViewCell(viewCell); 1618 } 1629 1619 } 1630 1620 … … 1688 1678 return splits; 1689 1679 } 1680 1681 int BspTree::FindNeighbors(KdNode *n, vector<BspNode *> &neighbors, bool onlyUnmailed) 1682 { 1683 stack<BspNode *> nodeStack; 1684 nodeStack.push(mRoot); 1685 1686 AxisAlignedBox3 box = GetBox(n); 1687 1688 while (!nodeStack.empty()) 1689 { 1690 BspNode *node = nodeStack.top(); 1691 nodeStack.pop(); 1692 1693 if (node->IsLeaf()) 1694 { 1695 if (node != n && (!onlyUnmailed || !node->Mailed())) 1696 neighbors.push_back(node); 1697 } 1698 else 1699 { 1700 KdInterior *interior = (KdInterior *)node; 1701 1702 if (interior->mPosition > box.Max(interior->mAxis)) 1703 nodeStack.push(interior->mBack); 1704 else 1705 if (interior->mPosition < box.Min(interior->mAxis)) 1706 nodeStack.push(interior->mFront); 1707 else 1708 { 1709 // random decision 1710 nodeStack.push(interior->mBack); 1711 nodeStack.push(interior->mFront); 1712 } 1713 } 1714 1715 } 1716 return neighbors.size(); 1717 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r350 r352 221 221 @param sampleContributions the number contributions of the sampels 222 222 @param contributingSampels the number of contributing rays 223 @param storeRays if ray set should be stored in view cell 223 224 */ 224 225 void BspLeaf::GenerateViewCell(const RayContainer &rays, 225 226 int &sampleContributions, 226 int &contributingSamples); 227 int &contributingSamples, 228 const bool storeRays = false); 227 229 228 230 protected: … … 230 232 /// if NULL this does not correspond to feasible viewcell 231 233 ViewCell *mViewCell; 232 RayContainer mPiercingRays;233 234 }; 234 235 … … 377 378 }; 378 379 379 BspNode *MergeNodes(BspInterior *node);380 381 bool MergeNecessary(BspLeaf *front, BspLeaf *back) const;380 /** Merges view cells of leafs. 381 */ 382 void MergeLeafs(BspLeaf *front, BspLeaf *back) const; 382 383 383 384 /** Evaluates tree stats in the BSP tree leafs. … … 584 585 RayContainer &backRays); 585 586 586 void MergeLeafs(BspLeaf *front, BspLeaf *back);587 588 587 /// Pointer to the root of the tree 589 588 BspNode *mRoot;
Note: See TracChangeset
for help on using the changeset viewer.