Changeset 437 for trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
- Timestamp:
- 11/25/05 22:31:30 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r436 r437 124 124 PolygonContainer &coincident) 125 125 { 126 Polygon3 *splitPoly = NULL;127 128 126 int splits = 0; 129 127 … … 140 138 // classify polygon 141 139 const int cf = poly->ClassifyPlane(mPlane); 142 143 Polygon3 *front_piece = NULL;144 Polygon3 *back_piece = NULL;145 140 146 141 switch (cf) … … 156 151 break; 157 152 case Polygon3::SPLIT: 158 front_piece = new Polygon3(poly->mParent); 159 back_piece = new Polygon3(poly->mParent); 160 161 //-- split polygon into front and back part 162 poly->Split(mPlane, 163 *front_piece, 164 *back_piece); 153 { 154 Polygon3 *front_piece = new Polygon3(poly->mParent); 155 Polygon3 *back_piece = new Polygon3(poly->mParent); 156 157 //-- split polygon into front and back part 158 poly->Split(mPlane, *front_piece, *back_piece); 165 159 166 ++ splits; // increase number of splits167 168 //-- inherit rays from parent polygon for blocked ray criterium169 poly->InheritRays(*front_piece, *back_piece);170 //Debug << "p: " << poly->mPiercingRays.size() << " f: " << front_piece->mPiercingRays.size() << " b: " << back_piece->mPiercingRays.size() << endl;160 ++ splits; // increase number of splits 161 162 //-- inherit rays from parent polygon for blocked ray criterium 163 poly->InheritRays(*front_piece, *back_piece); 164 //Debug << "p: " << poly->mPiercingRays.size() << " f: " << front_piece->mPiercingRays.size() << " b: " << back_piece->mPiercingRays.size() << endl; 171 165 172 // check if polygons still valid173 if (front_piece->Valid())174 frontPolys.push_back(front_piece);175 else176 DEL_PTR(front_piece);166 // check if polygons still valid 167 if (front_piece->Valid()) 168 frontPolys.push_back(front_piece); 169 else 170 DEL_PTR(front_piece); 177 171 178 if (back_piece->Valid())179 backPolys.push_back(back_piece);180 else181 DEL_PTR(back_piece);172 if (back_piece->Valid()) 173 backPolys.push_back(back_piece); 174 else 175 DEL_PTR(back_piece); 182 176 183 177 #ifdef _DEBUG 184 Debug << "split " << *poly << endl << *front_piece << endl << *back_piece << endl;178 Debug << "split " << *poly << endl << *front_piece << endl << *back_piece << endl; 185 179 #endif 186 DEL_PTR(poly); 180 DEL_PTR(poly); 181 } 187 182 break; 188 183 default: … … 273 268 mRootCell(viewCell), 274 269 mRoot(NULL), 275 mGenerateViewCells(false),276 270 mStoreLeavesWithRays(false), 277 mPvsUseArea(true) 271 mPvsUseArea(true), 272 mGenerateViewCells(true) 278 273 { 279 274 Randomize(); // initialise random generator for heuristics … … 447 442 PolygonContainer *polys = new PolygonContainer(); 448 443 444 // don't generate new view cell, insert this one 445 mGenerateViewCells = false; 449 446 // extract polygons that guide the split process 450 447 mStat.polys += AddMeshToPolygons(viewCell->GetMesh(), *polys, viewCell); … … 457 454 { 458 455 std::stack<BspTraversalData> tStack; 459 456 460 457 // traverse existing tree or create new tree 461 458 if (!mRoot) … … 624 621 mStat.polys = AddToPolygonSoup(viewCells, *polys); 625 622 623 // view cells are given 624 mGenerateViewCells = false; 626 625 // construct tree from the view cell polygons 627 626 Construct(polys, new BoundedRayContainer()); … … 635 634 636 635 PolygonContainer *polys = new PolygonContainer(); 637 636 637 mGenerateViewCells = true; 638 638 // copy mesh instance polygons into one big polygon soup 639 639 mStat.polys = AddToPolygonSoup(objects, *polys); … … 652 652 653 653 RayContainer::const_iterator rit, rit_end = sampleRays.end(); 654 655 // generate view cells 656 mGenerateViewCells = false; 654 657 655 658 long startTime = GetTime(); … … 726 729 PolygonContainer *polys = new PolygonContainer(); 727 730 731 mGenerateViewCells = true; 732 728 733 // copy mesh instance polygons into one big polygon soup 729 734 mStat.polys = AddToPolygonSoup(objects, *polys); … … 844 849 PolygonContainer coincident; 845 850 846 PolygonContainer *frontPolys = new PolygonContainer();847 PolygonContainer *backPolys = new PolygonContainer();848 849 BoundedRayContainer *frontRays = new BoundedRayContainer();850 BoundedRayContainer *backRays = new BoundedRayContainer();851 852 851 BspTraversalData tFrontData(NULL, new PolygonContainer(), tData.mDepth + 1, mRootCell, 853 852 new BoundedRayContainer(), 0, 0, new BspNodeGeometry()); … … 856 855 857 856 // create new interior node and two leaf nodes 858 BspInterior *interior = SubdivideNode(tData, 859 tFrontData, 860 tBackData, 861 coincident); 857 BspInterior *interior = 858 SubdivideNode(tData, tFrontData, tBackData, coincident); 862 859 863 860 #ifdef _DEBUG … … 897 894 BspTraversalData &backData, 898 895 const PolygonContainer &coincident, 899 const Plane3 splitPlane) const896 const Plane3 &splitPlane) const 900 897 { 901 898 // if not empty, tree is further subdivided => don't have to find view cell … … 1534 1531 1535 1532 // add the termination object 1536 AddObjToPvs(ray->intersections[0].mObject, cf, frontPvs, backPvs); 1533 if (!ray->intersections.empty()) 1534 AddObjToPvs(ray->intersections[0].mObject, cf, frontPvs, backPvs); 1537 1535 1538 1536 // add the source object … … 1592 1590 1593 1591 const float raysSize = (float)rays.size() + Limits::Small; 1592 1594 1593 if (mSplitPlaneStrategy & LEAST_RAY_SPLITS) 1595 1594 val += mLeastRaySplitsFactor * sumRaySplits / raysSize; … … 1604 1603 1605 1604 // give penalty to unbalanced split 1606 if ( 1)1605 if (0) 1607 1606 if (((pFront * 0.2 + Limits::Small) > pBack) || (pFront < (pBack * 0.2 + Limits::Small))) 1608 1607 val += 0.5; … … 1614 1613 << " backpvs: " << backPvs << " pBack: " << pBack << endl << endl; 1615 1614 #endif 1615 1616 1616 return val; 1617 1617 } … … 2036 2036 } 2037 2037 2038 void BspTree::SetGenerateViewCells(int generateViewCells)2039 {2040 mGenerateViewCells = generateViewCells;2041 }2042 2038 2043 2039 BspTreeStatistics &BspTree::GetStat()
Note: See TracChangeset
for help on using the changeset viewer.