Changeset 574 for trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
- Timestamp:
- 01/25/06 01:44:46 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp
r544 r574 7 7 Polygon3::Polygon3(): 8 8 mMaterial(NULL), mParent(NULL), mPiercingRays(0) 9 {} 9 { 10 // mostly there will be triangles 11 //mVertices.reserve(3); 12 } 10 13 11 14 Polygon3::Polygon3(const VertexContainer &vertices): 12 mVertices(vertices), mMaterial(NULL), mParent(NULL), mPiercingRays(0) 13 {} 15 mMaterial(NULL), mParent(NULL), mPiercingRays(0) 16 { 17 mVertices.reserve(vertices.size()); 18 mVertices = vertices; 19 } 20 14 21 15 22 Polygon3::Polygon3(MeshInstance *parent): … … 17 24 {} 18 25 26 19 27 Polygon3::Polygon3(Face *face, Mesh *parentMesh): 20 28 mMaterial(NULL), mParent(NULL), mPiercingRays(0) 21 29 { 30 mVertices.reserve(face->mVertexIndices.size()); 31 22 32 VertexIndexContainer::iterator it = face->mVertexIndices.begin(); 23 33 for (; it != face->mVertexIndices.end(); ++it) 24 34 { 25 35 mVertices.push_back(parentMesh->mVertices[*it]); 26 mMaterial = parentMesh->mMaterial; 27 } 28 } 36 } 37 38 mMaterial = parentMesh->mMaterial; 39 } 40 29 41 30 42 Plane3 Polygon3::GetSupportingPlane() const … … 32 44 return Plane3(mVertices[0], mVertices[1], mVertices[2]); 33 45 } 46 34 47 35 48 Vector3 Polygon3::GetNormal() const … … 113 126 } 114 127 128 115 129 float Polygon3::GetArea() const 116 130 { … … 123 137 } 124 138 139 125 140 int Polygon3::Side(const Plane3 &plane, 126 141 const float epsilon) const … … 136 151 } 137 152 153 138 154 int Polygon3::ClassifyPlane(const Plane3 &plane, 139 155 const float epsilon) const 140 156 { 141 VertexContainer::const_iterator it ;157 VertexContainer::const_iterator it, it_end = mVertices.end(); 142 158 143 159 bool onFrontSide = false; … … 146 162 int count = 0; 147 163 // find possible line-plane intersections 148 for (it = mVertices.begin(); it != mVertices.end(); ++ it)164 for (it = mVertices.begin(); it != it_end; ++ it) 149 165 { 150 166 const int side = plane.Side(*it, epsilon); … … 179 195 } 180 196 181 /*int Polygon3::ClassifyPlane(const Plane3 &plane) const182 {183 return ClassifyPlane(plane, Limits::Small);184 }*/185 186 197 187 198 Vector3 … … 212 223 return false; 213 224 214 #if 1 215 // check if area exceeds certain size 216 if (AREA_LIMIT > GetArea()) 217 { 218 //Debug << "area too small: " << GetArea() << endl; 219 return false; 220 } 221 #else 222 Vector3 vtx = mVertices.back(); 223 VertexContainer::const_iterator it, it_end = mVertices.end(); 224 225 for (it = mVertices.begin(); it != it_end; ++it) 226 { 227 if (!(EpsilonEqual(vtx, *it))) 228 { 229 //Debug << "Malformed vertices:\n" << *this << endl; 225 //TODO: remove for performance 226 #if 0 227 if (1) 228 { 229 // check if area exceeds certain size 230 if (GetArea() < AREA_LIMIT) 231 { 232 Debug << "area too small: " << GetArea() << endl; 230 233 return false; 231 234 } 232 vtx = *it; 233 } 234 #endif 235 } 236 else 237 { 238 Vector3 vtx = mVertices.back(); 239 VertexContainer::const_iterator it, it_end = mVertices.end(); 240 241 for (it = mVertices.begin(); it != it_end; ++it) 242 { 243 if (!(EpsilonEqualV3(vtx, *it))) 244 { 245 //Debug << "Malformed vertices:\n" << *this << endl; 246 return false; 247 } 248 vtx = *it; 249 } 250 } 251 #endif 252 235 253 return true; 236 254 } 255 237 256 238 257 void Polygon3::IncludeInBox(const PolygonContainer &polys, AxisAlignedBox3 &box) … … 243 262 box.Include(*(*it)); 244 263 } 264 245 265 246 266 // int_lineseg returns 1 if the given line segment intersects a 2D … … 283 303 } 284 304 305 285 306 int Polygon3::CastRay(const Ray &ray, float &t, const float nearestT) 286 307 { … … 353 374 return (count & 1) ? Ray::INTERSECTION : Ray::NO_INTERSECTION; 354 375 } 376 355 377 356 378 void Polygon3::InheritRays(Polygon3 &front_piece, … … 385 407 } 386 408 409 387 410 int Polygon3::ClassifyPlane(const PolygonContainer &polys, 388 411 const Plane3 &plane, … … 422 445 } 423 446 447 424 448 int Polygon3::ParentObjectsSize(const PolygonContainer &polys) 425 449 { … … 441 465 } 442 466 467 443 468 float Polygon3::GetArea(const PolygonContainer &cell) 444 469 { … … 448 473 for (pit = cell.begin(); pit != cell.end(); ++ pit) 449 474 { 450 if ((*pit)->mVertices.size() < 3)451 Debug << "ERROR" << endl;452 453 475 area += (*pit)->GetArea(); 454 476 }
Note: See TracChangeset
for help on using the changeset viewer.