Changeset 437
- Timestamp:
- 11/25/05 22:31:30 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/Preprocessor.vcproj
r420 r437 300 300 </File> 301 301 <File 302 RelativePath="..\src\VspBspTree.cpp"> 303 </File> 304 <File 305 RelativePath="..\src\VspBspTree.h"> 306 </File> 307 <File 302 308 RelativePath="..\src\VspKdTree.cpp"> 303 309 </File> -
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r436 r437 19 19 20 20 Preprocessor { 21 #type sampling21 # type sampling 22 22 type vss 23 23 } … … 184 184 Termination { 185 185 # parameters used for autopartition 186 minRays 200186 minRays 300 187 187 minPolygons -1 188 maxDepth 30189 minPvs 150188 maxDepth 20 189 minPvs 400 190 190 minArea 0.01 191 191 maxRayContribution 0.005 -
trunk/VUT/GtpVisibilityPreprocessor/src/Plane3.h
r396 r437 15 15 16 16 Plane3(const Vector3 &a, 17 const Vector3 &b,18 const Vector3 &c17 const Vector3 &b, 18 const Vector3 &c 19 19 ) { 20 20 Vector3 v1=a-b, v2=c-b; … … 44 44 } 45 45 46 /** Finds intersection of line segment between points a and b with plane. 47 @param a start point 48 @param b end point 49 @param t if not NULL, returns parameter value of intersections 50 @param coplanar if not NULL, returns true if plane and line segments are coplanar. 51 */ 46 52 Vector3 FindIntersection(const Vector3 &a, 47 53 const Vector3 &b, … … 56 62 { 57 63 if (coplanar) (*coplanar) = true; 58 if (t) (*t) = 1;64 if (t) (*t) = 0; 59 65 return a; 60 66 } … … 68 74 } 69 75 76 /** Finds value of intersection parameter t on line segment from a to b. 77 @returns -1 if coplanar, else parameter t 78 */ 70 79 float FindT(const Vector3 &a, 71 80 const Vector3 &b) const … … 74 83 const float dv = DotProd(v, mNormal); 75 84 85 // does not intersect 76 86 if (signum(dv) == 0) 77 return 1;87 return -1; 78 88 79 89 return - Distance(a) / dv; // TODO: could be done more efficiently -
trunk/VUT/GtpVisibilityPreprocessor/src/RayInfo.cpp
r432 r437 2 2 #include "Ray.h" 3 3 #include "VssRay.h" 4 #include "Plane3.h" 4 5 5 6 RayInfo::RayInfo(): mRay(NULL), mMinT(0), … … 51 52 return mRay->GetOrigin(axis) + GetMaxT()*mRay->GetDir(axis); 52 53 } 54 55 Vector3 RayInfo::ExtrapOrigin() const 56 { 57 return mRay->GetOrigin() * mRay->GetDir(); 58 } 53 59 60 Vector3 RayInfo::ExtrapTermination() const 61 { 62 return mRay->GetOrigin() + GetMaxT() * mRay->GetDir(); 63 } 64 54 65 #if USE_FIXEDPOINT_T 55 66 float RayInfo::GetMinT () const … … 117 128 return 0; 118 129 } 130 131 132 int RayInfo::ComputeRayIntersection(const Plane3 &splitPlane, float &t) const 133 { 134 t = splitPlane.FindT(mRay->GetOrigin(), mRay->GetTermination()); 135 136 if ((t < GetMinT()) || (t > GetMaxT())) 137 return splitPlane.Side(ExtrapOrigin()); 138 139 return 0; 140 } 141 142 float RayInfo::SegmentLength() const 143 { 144 return Distance(ExtrapOrigin(), ExtrapTermination()); 145 } 146 147 float RayInfo::SqrSegmentLength() const 148 { 149 return SqrDistance(ExtrapOrigin(), ExtrapTermination()); 150 } -
trunk/VUT/GtpVisibilityPreprocessor/src/RayInfo.h
r420 r437 7 7 class VssRay; 8 8 class RayInfo; 9 class Plane3; 10 class Vector3; 9 11 10 12 typedef vector<RayInfo> RayInfoContainer; … … 40 42 } 41 43 44 /** Extracts the scalar of the starting point of the ray segment 45 that lies in the axis. 46 */ 47 float ExtrapOrigin(const int axis) const; 48 /** Extracts the scalar of the termination point of the ray segment 49 that lies in the axis. 50 */ 51 float ExtrapTermination(const int axis) const; 42 52 43 float ExtrapOrigin(const int axis) const; 53 /** Extracts the starting point of the ray segment. 54 */ 55 Vector3 ExtrapOrigin() const; 44 56 45 float ExtrapTermination(const int axis) const; 57 /** Extracts the end point of the ray segment. 58 */ 59 Vector3 ExtrapTermination() const; 46 60 47 61 float GetMinT () const; … … 52 66 void SetMaxT (const float t); 53 67 68 float SegmentLength() const; 69 float SqrSegmentLength() const; 70 54 71 /** Computes intersection of this ray with the axis aligned split plane. 72 55 73 @param axis axis of the split plane 56 @param position position of the split plane57 @param t returns the t value of the ray intersection74 @param position scalar position of the split plane for the chosen axis 75 @param t returns the t parameter value of the ray intersection 58 76 59 77 @returns 0 if ray intersects plane, -1 if on back side of plane, 1 if on front side 60 78 */ 61 79 int ComputeRayIntersection(const int axis, const float position, float &t) const; 80 81 /** Computes intersection of this ray with the split plane. 82 83 @param splitPlane the split plane 84 @param t returns the t parameter value of the ray intersection 85 86 @returns 0 if ray intersects plane, -1 if on back side of plane, 1 if on front side 87 */ 88 int ComputeRayIntersection(const Plane3 &splitPlane, float &t) const; 62 89 }; 63 90 -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r433 r437 64 64 { 65 65 case BspTree::FROM_INPUT_VIEW_CELLS: 66 mBspTree->SetGenerateViewCells(false);67 66 mBspTree->Construct(mViewCells); 68 67 break; 69 68 case BspTree::FROM_SCENE_GEOMETRY: 70 69 DeleteViewCells(); // we generate new view cells 71 mBspTree->SetGenerateViewCells(true);72 70 mSceneGraph->CollectObjects(&objects); 73 71 mBspTree->Construct(objects); … … 75 73 case BspTree::FROM_SAMPLES: 76 74 DeleteViewCells(); // we generate new view cells 77 mBspTree->SetGenerateViewCells(true);78 75 mBspTree->Construct(mSampleRays); 79 76 break; -
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() -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r436 r437 333 333 334 334 */ 335 void AddToPvs(const BoundedRayContainer &rays, int &sampleContributions, 336 int &contributingSamples, bool storeLeavesWithRays = false); 335 void AddToPvs(const BoundedRayContainer &rays, 336 int &sampleContributions, 337 int &contributingSamples, 338 bool storeLeavesWithRays = false); 337 339 338 340 protected: … … 471 473 int CastRay(Ray &ray); 472 474 473 /** Set to true if new view cells shall be generated in each leaf.474 */475 void SetGenerateViewCells(int generateViewCells);476 477 475 /// bsp tree construction types 478 476 enum {FROM_INPUT_VIEW_CELLS, FROM_SCENE_GEOMETRY, FROM_SAMPLES}; … … 701 699 BspTraversalData &backData, 702 700 const PolygonContainer &coincident, 703 const Plane3 splitPlane) const;701 const Plane3 &splitPlane) const; 704 702 705 703 /** Computes best cost ratio for the suface area heuristics for axis aligned … … 767 765 */ 768 766 void AddObjToPvs(Intersectable *obj, const int cf, int &frontPvs, int &backPvs) const; 769 767 768 /** Computes PVS size induced by the rays. 769 */ 770 770 int ComputePvsSize(const BoundedRayContainer &rays) const; 771 771 772 /** Returns true if tree can be terminated. 773 */ 772 774 inline bool TerminationCriteriaMet(const BspTraversalData &data) const; 773 775 776 /** Computes accumulated ray lenght of this rays. 777 */ 774 778 float AccumulatedRayLength(BoundedRayContainer &rays) const; 775 779 776 /// Pointer to the root of the tree 780 /// Pointer to the root of the tree. 777 781 BspNode *mRoot; 778 782 783 /// Stores statistics during traversal. 779 784 BspTreeStatistics mStat; 780 785 … … 800 805 BspViewCell *mRootCell; 801 806 802 /// should view cells be stored or generated in the leaves?807 /// if view cells should be generated or the given view cells should be used. 803 808 bool mGenerateViewCells; 804 809 -
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r436 r437 463 463 ObjectContainer objects; 464 464 mSceneGraph->CollectObjects(&objects); 465 466 mBspTree->SetGenerateViewCells(true);467 465 mBspTree->Construct(objects, bspRays); 468 466 }
Note: See TracChangeset
for help on using the changeset viewer.