Changeset 503 for trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
- Timestamp:
- 01/05/06 20:41:52 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r502 r503 8 8 #include "Ray.h" 9 9 #include "AxisAlignedBox3.h" 10 #include "Triangle3.h" 11 10 12 #include <stack> 11 13 … … 423 425 app << "#N_INVALIDLEAVES (number of invalid leaves )\n" << invalidLeaves << endl; 424 426 427 app << "#N_RAYS (number of rays / leaf)\n" << AvgRays() << endl; 425 428 //app << "#N_PVS: " << pvs << endl; 426 429 … … 776 779 777 780 // constrruct root node geometry 778 BspNodeGeometry * cell= new BspNodeGeometry();779 ConstructGeometry(mRoot, * cell);781 BspNodeGeometry *geom = new BspNodeGeometry(); 782 ConstructGeometry(mRoot, *geom); 780 783 781 784 BspTraversalData tData(mRoot, polys, 0, mRootCell, rays, 782 ComputePvsSize(*rays), cell->GetArea(), cell);785 ComputePvsSize(*rays), geom->GetArea(), geom); 783 786 784 787 tStack.push(tData); … … 1809 1812 // accumulate depth to compute average depth 1810 1813 mStat.accumDepth += data.mDepth; 1811 1814 // accumulate rays to compute rays / leaf 1815 mStat.accumRays += (int)data.mRays->size(); 1812 1816 1813 1817 if (data.mDepth >= mTermMaxDepth) … … 2196 2200 } 2197 2201 2198 void BspTree::ConstructGeometry(BspNode *n, BspNodeGeometry &cell) const 2199 { 2200 PolygonContainer polys; 2201 ConstructGeometry(n, polys); 2202 cell.mPolys = polys; 2203 } 2204 2205 void BspTree::ConstructGeometry(BspViewCell *vc, PolygonContainer &cell) const 2202 void BspTree::ConstructGeometry(BspViewCell *vc, BspNodeGeometry &geom) const 2206 2203 { 2207 2204 vector<BspLeaf *> leaves = vc->mLeaves; … … 2210 2207 2211 2208 for (it = leaves.begin(); it != it_end; ++ it) 2212 ConstructGeometry(*it, cell);2213 } 2214 2215 2216 void BspTree::ConstructGeometry(BspNode *n, PolygonContainer &cell) const2209 ConstructGeometry(*it, geom); 2210 } 2211 2212 2213 void BspTree::ConstructGeometry(BspNode *n, BspNodeGeometry &geom) const 2217 2214 { 2218 2215 vector<Plane3> halfSpaces; … … 2291 2288 2292 2289 if (candidates[i]) 2293 cell.push_back(candidates[i]);2290 geom.mPolys.push_back(candidates[i]); 2294 2291 } 2295 2292 } … … 2299 2296 const bool onlyUnmailed) const 2300 2297 { 2301 PolygonContainer cell; 2302 2303 ConstructGeometry(n, cell); 2298 BspNodeGeometry geom; 2299 ConstructGeometry(n, geom); 2304 2300 2305 2301 stack<BspNode *> nodeStack; … … 2319 2315 if (node != n && (!onlyUnmailed || !node->Mailed())) 2320 2316 { 2321 // test all planes of current node if candidate really2322 // is neighbour2323 PolygonContainer neighborCandidate;2324 ConstructGeometry(node, neighborCandidate);2317 // test all planes of current node if neighbour 2318 // candidate really is neighbour 2319 BspNodeGeometry candidateGeom; 2320 ConstructGeometry(node, candidateGeom); 2325 2321 2326 2322 bool isAdjacent = true; … … 2328 2324 { 2329 2325 const int cf = 2330 Polygon3::ClassifyPlane( neighborCandidate,2326 Polygon3::ClassifyPlane(candidateGeom.mPolys, 2331 2327 halfSpaces[i], 2332 2328 mEpsilon); … … 2338 2334 if (isAdjacent) 2339 2335 neighbors.push_back(dynamic_cast<BspLeaf *>(node)); 2340 2341 CLEAR_CONTAINER(neighborCandidate);2342 2336 } 2343 2337 } … … 2346 2340 BspInterior *interior = dynamic_cast<BspInterior *>(node); 2347 2341 2348 const int cf = Polygon3::ClassifyPlane( cell,2342 const int cf = Polygon3::ClassifyPlane(geom.mPolys, 2349 2343 interior->mPlane, 2350 2344 mEpsilon); … … 2364 2358 } 2365 2359 2366 CLEAR_CONTAINER(cell);2367 2360 return (int)neighbors.size(); 2368 2361 } 2362 2369 2363 2370 2364 BspLeaf *BspTree::GetRandomLeaf(const Plane3 &halfspace) … … 2387 2381 { 2388 2382 BspInterior *interior = dynamic_cast<BspInterior *>(node); 2389 2390 2383 BspNode *next; 2391 2384 2392 PolygonContainer cell; 2393 2385 BspNodeGeometry geom; 2394 2386 // todo: not very efficient: constructs full cell everytime 2395 ConstructGeometry(interior, cell);2396 2397 const int cf = Polygon3::ClassifyPlane( cell,2387 ConstructGeometry(interior, geom); 2388 2389 const int cf = Polygon3::ClassifyPlane(geom.mPolys, 2398 2390 halfspace, 2399 2391 mEpsilon); … … 2534 2526 /*************************************************************/ 2535 2527 2528 2536 2529 BspNodeGeometry::~BspNodeGeometry() 2537 2530 { 2538 2531 CLEAR_CONTAINER(mPolys); 2539 2532 } 2533 2540 2534 2541 2535 float BspNodeGeometry::GetArea() const … … 2543 2537 return Polygon3::GetArea(mPolys); 2544 2538 } 2539 2540 2541 void BspNodeGeometry::AddToMesh(Mesh &mesh) 2542 { 2543 PolygonContainer::const_iterator it, it_end = mPolys.end(); 2544 int vcount = 0; 2545 2546 for (it = mPolys.begin(); it != mPolys.end(); ++ it) 2547 { 2548 Polygon3 *poly = *it; 2549 2550 vector<Triangle3> triangles; 2551 poly->Triangulate(triangles); 2552 vector<Triangle3>::const_iterator tit, tit_end = triangles.end(); 2553 2554 for (tit = triangles.begin(); tit != tit_end; ++ tit) 2555 { 2556 mesh.mVertices.push_back((*tit).mVertices[0]); 2557 mesh.mVertices.push_back((*tit).mVertices[1]); 2558 mesh.mVertices.push_back((*tit).mVertices[2]); 2559 2560 Face *face = new Face(vcount ++, vcount ++, vcount ++); 2561 mesh.AddFace(face); 2562 } 2563 } 2564 } 2565 2545 2566 2546 2567 void BspNodeGeometry::SplitGeometry(BspNodeGeometry &front,
Note: See TracChangeset
for help on using the changeset viewer.