Changeset 710 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
- Timestamp:
- 03/20/06 00:11:27 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r704 r710 159 159 mFront = f; 160 160 } 161 161 162 162 163 /****************************************************************/ … … 588 589 } 589 590 591 590 592 int BspTree::AddMeshToPolygons(Mesh *mesh, 591 593 PolygonContainer &polys, 592 594 MeshInstance *parent) 593 595 { 594 FaceContainer::const_iterator fi ;596 FaceContainer::const_iterator fi, fi_end = mesh->mFaces.end(); 595 597 596 598 // copy the face data to polygons 597 for (fi = mesh->mFaces.begin(); fi != mesh->mFaces.end(); ++ fi)599 for (fi = mesh->mFaces.begin(); fi != fi_end; ++ fi) 598 600 { 599 601 Polygon3 *poly = new Polygon3((*fi), mesh); … … 2839 2841 { 2840 2842 mPolys.reserve(rhs.mPolys.size()); 2841 2843 mPlanes.reserve(rhs.mPolys.size()); 2844 2845 2842 2846 PolygonContainer::const_iterator it, it_end = rhs.mPolys.end(); 2843 2847 2844 2848 int i = 0; 2845 2849 2846 for (it = rhs.mPolys.begin(); it != it_end; ++ it )2850 for (it = rhs.mPolys.begin(); it != it_end; ++ it, ++i) 2847 2851 { 2848 2852 Polygon3 *poly = *it; 2849 Add(new Polygon3(*poly), rhs.mPlanes[i ++]); 2853 Add(new Polygon3(*poly), rhs.mPlanes[i]); 2854 } 2855 } 2856 2857 2858 BspNodeGeometry& BspNodeGeometry::operator=(const BspNodeGeometry& g) 2859 { 2860 if (this == &g) 2861 return *this; 2862 2863 CLEAR_CONTAINER(mPolys); 2864 2865 mPolys.reserve(g.mPolys.size()); 2866 mPlanes.reserve(g.mPolys.size()); 2867 2868 PolygonContainer::const_iterator it, it_end = g.mPolys.end(); 2869 2870 int i = 0; 2871 2872 for (it = g.mPolys.begin(); it != it_end; ++ it, ++ i) 2873 { 2874 Polygon3 *poly = *it; 2875 Add(new Polygon3(*poly), g.mPlanes[i]); 2876 } 2877 2878 return *this; 2879 } 2880 2881 2882 BspNodeGeometry::BspNodeGeometry(const PolygonContainer &polys) 2883 { 2884 mPolys = polys; 2885 mPlanes.reserve(polys.size()); 2886 2887 PolygonContainer::const_iterator it, it_end = polys.end(); 2888 2889 for (it = polys.begin(); it != it_end; ++ it) 2890 { 2891 Polygon3 *poly = *it; 2892 mPlanes.push_back(poly->GetSupportingPlane()); 2850 2893 } 2851 2894 } … … 2922 2965 2923 2966 2924 int BspNodeGeometry::Side(const Plane3 &plane ) const2967 int BspNodeGeometry::Side(const Plane3 &plane, const float eps) const 2925 2968 { 2926 2969 PolygonContainer::const_iterator it, it_end = mPolys.end(); … … 2931 2974 for (it = mPolys.begin(); it != it_end; ++ it) 2932 2975 { 2933 const int side = (*it)->Side(plane, 0.0f);2976 const int side = (*it)->Side(plane, eps); 2934 2977 2935 2978 if (side == -1) … … 3042 3085 const float epsilon) const 3043 3086 { 3087 #if 0 3088 // trivial cases 3089 const int cf = Side(splitPlane, epsilon); 3090 3091 if (cf == -1) 3092 { 3093 back = *this; 3094 return false; 3095 } 3096 else if (cf == 1) 3097 { 3098 front = *this; 3099 return false; 3100 } 3101 #endif 3102 3044 3103 // get cross section of new polygon 3045 3104 Polygon3 *planePoly = box.CrossSection(splitPlane); 3046 //Vector3 ndummy = planePoly->GetSupportingPlane().mNormal;3105 3047 3106 // split polygon with all other polygons 3048 3107 planePoly = SplitPolygon(planePoly, epsilon);
Note: See TracChangeset
for help on using the changeset viewer.