- Timestamp:
- 11/05/05 12:40:40 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r378 r379 56 56 57 57 Sampling { 58 totalSamples 40000058 totalSamples 300000 59 59 samplesPerPass 3 60 60 } … … 73 73 minPvs 10 74 74 maxPvs 300 75 samples 100 00075 samples 100 76 76 } 77 77 … … 126 126 #splitPlaneStrategy 130 127 127 128 splitPlaneStrategy 130128 splitPlaneStrategy 256 129 129 130 maxCandidates 80 130 maxPolyCandidates 5 131 maxRayCandidates 50 131 132 132 133 Termination { 133 134 # autopartition 134 maxRays 30135 maxRays 1000 135 136 maxPolygons 1 136 maxDepth 50137 maxDepth 10 137 138 138 139 # axis aligned splits 139 140 AxisAligned { 140 141 maxPolys 5000 141 maxRays 600142 maxRays 500 142 143 maxObjects 10 143 144 maxCostRatio 0.9 -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r378 r379 1203 1203 optInt, 1204 1204 "-bsp_postprocessing_samples=", 1205 "20 0000");1205 "206000"); 1206 1206 1207 1207 RegisterOption("BspTree.Construction.sideTolerance", … … 1261 1261 1262 1262 RegisterOption("BspTree.splitPlaneStrategy", 1263 1264 1265 1266 1267 RegisterOption("BspTree.max Candidates",1263 optString, 1264 "-bsp_split_method=", 1265 "leastSplits"); 1266 1267 RegisterOption("BspTree.maxPolyCandidates", 1268 1268 optInt, 1269 "-bsp_max_candidates=", 1269 "-bsp_max_poly_candidates=", 1270 "20"); 1271 1272 RegisterOption("BspTree.maxRayCandidates", 1273 optInt, 1274 "-bsp_max_plane_candidates=", 1270 1275 "20"); 1271 1276 -
trunk/VUT/GtpVisibilityPreprocessor/src/Exporter.h
r373 r379 79 79 80 80 virtual void 81 ExportBspViewCellPartition(const BspTree &tree ) = 0;81 ExportBspViewCellPartition(const BspTree &tree, const int maxPvs = 0) = 0; 82 82 83 83 virtual void -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r378 r379 551 551 Debug << "original view cell partition:\n" << stat << endl; 552 552 553 cout << "starting post processing using " << mSampleRays.size() << " samples ... "; 553 if (1) // export view cells 554 { 555 cout << "exporting view cells ... "; 556 Exporter *exporter = Exporter::GetExporter("view_cells.x3d"); 557 if (exporter) 558 { 559 //exporter->ExportBspViewCellPartition(*mBspTree, stat.maxPvs); 560 exporter->ExportBspViewCellPartition(*mBspTree, 0); 561 delete exporter; 562 } 563 cout << "finished" << endl; 564 } 565 566 cout << "starting post processing using " << (int)mSampleRays.size() << " samples ... "; 554 567 555 568 long startTime = GetTime(); … … 572 585 cout << "render time: " << rt * 1e-3 << endl; 573 586 Debug << "render time: " << rt * 1e-3 << endl; 587 588 if (1) // export view cells 589 { 590 cout << "exporting view cells after merge ... "; 591 Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d"); 592 if (exporter) 593 { 594 //exporter->ExportBspViewCellPartition(*mBspTree, stat.maxPvs); 595 exporter->ExportBspViewCellPartition(*mBspTree, 0); 596 delete exporter; 597 } 598 599 cout << "finished" << endl; 600 } 601 602 //-- visualization of the bsp splits 603 bool exportSplits = false; 604 environment->GetBoolValue("BspTree.exportSplits", exportSplits); 605 606 607 cout << "exporting splits ... "; 608 if (exportSplits) 609 ExportSplits(objects); 610 cout << "finished" << endl; 611 612 // export the PVS of sample view cells 613 if (1) 614 ExportBspPvs(objects); 574 615 } 575 616 … … 603 644 //-- several visualizations and statistics 604 645 if (1) { 605 if (mBspTree && (ViewCell::sHierarchy == ViewCell::BSP)) 606 { 607 bool exportSplits = false; 608 environment->GetBoolValue("BspTree.exportSplits", exportSplits); 609 610 // export the bsp splits 611 cout << "exporting splits ... "; 612 if (exportSplits) 613 ExportSplits(objects); 614 cout << "finished" << endl; 615 616 ExportBspPvs(objects); 617 } 646 618 647 for (int k=0; k < pvsOut; k++) { 619 648 Intersectable *object = objects[k]; … … 901 930 cout << "finished" << endl; 902 931 } 903 904 if (1) // export view cells and leaves905 {906 cout << "exporting view cells and leaves ... ";907 Exporter *exporter = Exporter::GetExporter("viewCells.x3d");908 if (exporter)909 {910 exporter->ExportBspViewCellPartition(*mBspTree);911 delete exporter;912 }913 914 exporter = Exporter::GetExporter("bspLeaves.x3d");915 916 if (exporter)917 {918 exporter->ExportBspLeaves(*mBspTree);919 delete exporter;920 }921 cout << "finished" << endl;922 }923 924 932 } 925 933 … … 940 948 const float vcOverhead = 0.01f; 941 949 942 float totalArea = 0; 950 // total area of view cells 951 float totalArea = 0;//= mKdTree->GetBox().SurfaceArea(); 943 952 944 953 ViewCellContainer viewCells; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r378 r379 16 16 int BspTree::sTermMaxPolygons = 10; 17 17 int BspTree::sTermMaxDepth = 20; 18 int BspTree::sMaxCandidates = 10; 18 int BspTree::sMaxPolyCandidates = 10; 19 int BspTree::sMaxRayCandidates = 10; 19 20 int BspTree::sSplitPlaneStrategy = BALANCED_POLYS; 20 21 int BspTree::sConstructionMethod = FROM_INPUT_VIEW_CELLS; … … 1050 1051 const BoundedRayContainer &rays) 1051 1052 { 1052 if (polys.empty() )1053 if (polys.empty() && rays.empty()) 1053 1054 { 1054 1055 Debug << "Warning: No autopartition polygon candidate available\n"; … … 1082 1083 if (sSplitPlaneStrategy & RANDOM_POLYGON) 1083 1084 { 1084 return polys[Random((int)polys.size())]->GetSupportingPlane(); 1085 Vector3 pt[3]; 1086 for (int j = 0; j < 3; j ++) 1087 { 1088 int idx = Random((int)rays.size()); 1089 pt[j] = rays[idx]->mRay->Extrap(rays[idx]->mMaxT); 1090 } 1091 1092 return Plane3(pt[0], pt[1], pt[2]); 1093 1094 //return polys[Random((int)polys.size())]->GetSupportingPlane(); 1085 1095 } 1086 1096 1087 1097 // use heuristics to find appropriate plane 1088 return SelectPlaneHeuristics(polys, rays, sMax Candidates);1098 return SelectPlaneHeuristics(polys, rays, sMaxPolyCandidates, sMaxRayCandidates); 1089 1099 } 1090 1100 1091 1101 Plane3 BspTree::SelectPlaneHeuristics(PolygonContainer &polys, 1092 1102 const BoundedRayContainer &rays, 1093 const int maxTests) 1103 const int maxPolyCandidates, 1104 const int maxRayCandidates) 1094 1105 { 1095 1106 float lowestCost = MAX_FLOAT; 1096 1107 int bestPlaneIdx = 0; 1097 1108 1098 int limit = max Tests > 0 ? Min((int)polys.size(), maxTests) : (int)polys.size();1109 int limit = maxPolyCandidates > 0 ? Min((int)polys.size(), maxPolyCandidates) : (int)polys.size(); 1099 1110 1100 1111 int candidateIdx = limit; 1101 1102 for (int i = 0; i < limit; ++ i) 1112 1113 //Debug << endl; 1114 /*for (int i = 0; i < limit; ++ i) 1103 1115 { 1104 1116 candidateIdx = GetNextCandidateIdx(candidateIdx, polys); 1105 1117 1106 1118 Plane3 candidatePlane = polys[candidateIdx]->GetSupportingPlane(); 1107 1119 //Debug << polys[candidateIdx] << endl; 1108 1120 // evaluate current candidate 1109 1121 float candidateCost = SplitPlaneCost(candidatePlane, polys, rays); … … 1114 1126 lowestCost = candidateCost; 1115 1127 } 1116 } 1117 1128 }*/ 1129 1130 //limit = maxRaysCandidates > 0 ? Min((int)rays.size(), maxRayCandidates) : (int)rays.size(); 1131 bool chooseFromRays = false; 1132 int bestIdx[3]; 1133 1134 for (int i = 0; i < maxRayCandidates; ++ i) 1135 { 1136 Vector3 pt[3]; 1137 int idx[3]; 1138 1139 for (int j = 0; j < 3; j ++) 1140 { 1141 idx[j] = Random((int)rays.size()); 1142 pt[j] = rays[idx[j]]->mRay->Extrap(rays[idx[j]]->mMaxT); 1143 } 1144 1145 float candidateCost = SplitPlaneCost(Plane3(pt[0], pt[1], pt[2]), polys, rays); 1146 1147 if (candidateCost < lowestCost) 1148 { 1149 chooseFromRays = true; 1150 bestIdx[0] = idx[0]; bestIdx[1]= idx[1]; bestIdx[2] = idx[2]; 1151 1152 lowestCost = candidateCost; 1153 } 1154 } 1155 1156 if (chooseFromRays) 1157 { 1158 return Plane3(rays[bestIdx[0]]->mRay->Extrap(rays[bestIdx[0]]->mMaxT), 1159 rays[bestIdx[1]]->mRay->Extrap(rays[bestIdx[1]]->mMaxT), 1160 rays[bestIdx[2]]->mRay->Extrap(rays[bestIdx[2]]->mMaxT)); 1161 } 1162 1118 1163 //Debug << "Plane lowest cost: " << lowestCost << endl; 1119 1164 return polys[bestPlaneIdx]->GetSupportingPlane(); … … 1126 1171 // swap candidates to avoid testing same plane 2 times 1127 1172 std::swap(polys[currentIdx], polys[candidateIdx]); 1128 1129 /*Polygon3 *p = polys[candidateIdx];1130 polys[candidateIdx] = polys[currentIdx];1131 polys[currentIdx] = p;*/1132 1173 1133 1174 return currentIdx; … … 1281 1322 float sumBalancedRays = 0; 1282 1323 float sumRaySplits = 0; 1283 float pvsSize = 0; 1324 float frontPvs = 0; 1325 float backPvs = 0; 1326 1284 1327 float totalSize = 0; 1285 1286 // need three unique ids for small pvs criterium 1287 Intersectable::NewMail(); 1288 const int backId = ViewCell::sMailId; 1289 Intersectable::NewMail(); 1290 const int frontId = ViewCell::sMailId; 1291 Intersectable::NewMail(); 1292 const int frontAndBackId = ViewCell::sMailId; 1293 //Debug << "f " << frontId << " b " << backId << " fb " << frontAndBackId << endl; 1294 1328 1329 // create three unique ids for pvs heuristics 1330 Intersectable::NewMail(); const int backId = ViewCell::sMailId; 1331 Intersectable::NewMail(); const int frontId = ViewCell::sMailId; 1332 Intersectable::NewMail(); const int frontAndBackId = ViewCell::sMailId; 1333 1334 /*PolygonContainer cell; 1335 PolygonContainer front; 1336 PolygonContainer back; 1337 1338 ConstructGeometry(currentNode, cell); 1339 ConstructChildrenGeometry(front, cell, planes, sides); 1340 ConstructChildrenGeometry(back, cell, planes, sides);*/ 1341 1342 1343 int frontRays = 0; 1344 int backRays = 0; 1345 1346 // todo create geometry of left and right leaves 1347 1295 1348 BoundedRayContainer::const_iterator rit, rit_end = rays.end(); 1296 1349 … … 1316 1369 if (sSplitPlaneStrategy & PVS) 1317 1370 { 1318 vector<Ray::Intersection>::const_iterator it,1319 it_end = ray->intersections.end();1320 1321 1371 if (!ray->intersections.empty()) 1322 1372 { 1323 1373 // in case the ray intersects an objcrs 1324 1374 // assure that we only count a object 1325 1375 // once for the front and once for the back side of the plane 1326 pvsSize += PvsValue(*ray->intersections[0].mObject, 1327 cf, 1328 frontId, 1329 backId, 1330 frontAndBackId); 1331 1332 // always add 2 for each object (= maximal large PVS) 1333 //if (inc > 0.01) totalSize += 2.0; 1376 ComputePvs(*ray->intersections[0].mObject, 1377 frontPvs, 1378 backPvs, 1379 cf, 1380 frontId, 1381 backId, 1382 frontAndBackId); 1334 1383 } 1335 //todo emerging obj 1384 1385 // the source object in the origin of the ray 1386 ComputePvs(*ray->sourceObject.mObject, 1387 frontPvs, 1388 backPvs, 1389 cf, 1390 frontId, 1391 backId, 1392 frontAndBackId); 1393 1394 if ((cf == Ray::BACK) || (cf == Ray::FRONT_BACK) || (cf == Ray::BACK_FRONT)) 1395 ++ backRays; 1396 if ((cf == Ray::FRONT) || (cf == Ray::FRONT_BACK) || (cf == Ray::BACK_FRONT)) 1397 ++ frontRays; 1336 1398 } 1337 1399 } … … 1346 1408 1347 1409 if (sSplitPlaneStrategy & PVS) 1348 if (!rays.empty()) // HACK (should be maximal possible pvs) 1349 val += sPvsFactor * pvsSize / (float)rays.size(); 1410 if (!rays.empty()) // HACK (should divide by maximal possible pvs) 1411 val += sPvsFactor * (frontPvs * (float)frontRays + (backPvs * (float)backRays)) / 1412 (float)rays.size(); 1350 1413 1351 1414 //Debug << "pvs: " << pvsSize << " val " << val << endl; … … 1354 1417 1355 1418 1356 float BspTree::PvsValue(Intersectable &obj, 1357 const int cf, 1358 const int frontId, 1359 const int backId, 1360 const int frontAndBackId) const 1361 { 1362 float pvsVal = 0; 1363 1419 /*void BspTree::CreateChildrenGeometry(PolygonContainer &cell, 1420 PolygonContainer &front, 1421 PolygonContainer &back, 1422 Plane3 &splitPlane) 1423 { 1424 }*/ 1425 1426 void BspTree::ComputePvs(Intersectable &obj, 1427 float &frontPvs, 1428 float &backPvs, 1429 const int cf, 1430 const int frontId, 1431 const int backId, 1432 const int frontAndBackId) const 1433 { 1364 1434 if (cf == Ray::COINCIDENT) 1365 return pvsVal;1435 return; 1366 1436 1367 1437 if (cf == Ray::FRONT) … … 1369 1439 if ((obj.mMailbox != frontId) && 1370 1440 (obj.mMailbox != frontAndBackId)) 1371 pvsVal= 1.0;1441 frontPvs += 1.0; 1372 1442 1373 1443 if (obj.mMailbox != backId) … … 1381 1451 (obj.mMailbox != frontAndBackId)) 1382 1452 { 1383 pvsVal= 1.0;1453 backPvs += 1.0; 1384 1454 1385 1455 if (obj.mMailbox != frontId) … … 1391 1461 else if ((cf == Ray::FRONT_BACK) || (cf == Ray::BACK_FRONT)) 1392 1462 { 1393 if ((obj.mMailbox == backId) || (obj.mMailbox == frontId)) 1394 pvsVal = 1.0; 1395 else if (obj.mMailbox != frontAndBackId) 1396 pvsVal = 2.0; 1397 1463 if (obj.mMailbox == backId) 1464 frontPvs += 1.0; 1465 else if (obj.mMailbox == frontId) 1466 backPvs += 1.0; 1467 else if (obj.mMailbox != frontAndBackId) // can add to both PVS 1468 { 1469 frontPvs += 1.0; 1470 backPvs += 1.0; 1471 } 1398 1472 obj.mMailbox = frontAndBackId; 1399 1473 } 1400 1401 return pvsVal;1402 1474 } 1403 1475 … … 1477 1549 sTermMaxObjectsForAxisAligned); 1478 1550 //-- partition criteria 1479 environment->GetIntValue("BspTree.maxCandidates", sMaxCandidates); 1551 environment->GetIntValue("BspTree.maxPolyCandidates", sMaxPolyCandidates); 1552 environment->GetIntValue("BspTree.maxRayCandidates", sMaxRayCandidates); 1480 1553 environment->GetIntValue("BspTree.splitPlaneStrategy", sSplitPlaneStrategy); 1481 1554 environment->GetFloatValue("BspTree.AxisAligned.splitBorder", sSplitBorder); … … 1493 1566 Debug << "BSP max depth: " << sTermMaxDepth << endl; 1494 1567 Debug << "BSP max polys: " << sTermMaxPolygons << endl; 1495 Debug << "BSP max candidates: " << sMaxCandidates << endl; 1496 1568 Debug << "BSP max rays: " << sTermMaxRays << endl; 1569 Debug << "BSP max polygon candidates: " << sMaxPolyCandidates << endl; 1570 Debug << "BSP max plane candidates: " << sMaxRayCandidates << endl; 1571 1497 1572 Debug << "Split plane strategy: "; 1498 1573 if (sSplitPlaneStrategy & RANDOM_POLYGON) … … 1512 1587 if (sSplitPlaneStrategy & BLOCKED_RAYS) 1513 1588 Debug << "blocked rays "; 1589 if (sSplitPlaneStrategy & LEAST_RAY_SPLITS) 1590 Debug << "least ray splits "; 1591 if (sSplitPlaneStrategy & BALANCED_RAYS) 1592 Debug << "balanced rays "; 1514 1593 if (sSplitPlaneStrategy & PVS) 1515 1594 Debug << "pvs"; … … 1939 2018 } 1940 2019 1941 struct Candidate 1942 { 1943 Polygon3 *mPoly; 1944 Plane3 mPlane; 1945 bool mSide; 1946 1947 Candidate(Polygon3 *poly, const Plane3 &plane, const bool &side): 1948 mPoly(poly), mPlane(plane), mSide(side) 1949 {} 1950 }; 1951 1952 void BspTree::AddHalfspace(PolygonContainer &cell, 1953 vector<Plane3> &planes, 1954 vector<bool> &sides, 1955 const Plane3 &halfspace, 1956 const bool side) const 1957 { 1958 Polygon3 *poly = GetBoundingBox().CrossSection(halfspace); 2020 bool BspTree::ComputeChildrenGeometry(PolygonContainer &newCell, 2021 const PolygonContainer &cell, 2022 const vector<Plane3> &planes, 2023 const vector<bool> &sides, 2024 const Plane3 &splitPlane, 2025 const bool side) const 2026 { 2027 // get cross section of new polygon 2028 Polygon3 *planePoly = GetBoundingBox().CrossSection(splitPlane); 1959 2029 1960 2030 bool inside = true; … … 1963 2033 for (int i = 0; (i < planes.size()) && inside; ++ i) 1964 2034 { 1965 VertexContainer splitPts; 1966 Polygon3 *frontPoly, *backPoly; 1967 1968 const int cf = poly->ClassifyPlane(planes[i]); 2035 const int cf = planePoly->ClassifyPlane(planes[i]); 1969 2036 1970 2037 // split new polygon with all previous planes … … 1972 2039 { 1973 2040 case Polygon3::SPLIT: 1974 frontPoly = new Polygon3();1975 backPoly = new Polygon3();1976 1977 poly->Split(planes[i], *frontPoly, *backPoly, splitPts);1978 DEL_PTR(poly);1979 1980 if(sides[i] == true)1981 2041 { 1982 poly = frontPoly; 1983 DEL_PTR(backPoly); 1984 } 2042 VertexContainer splitPts; 2043 2044 Polygon3 *frontPoly = new Polygon3(); 2045 Polygon3 *backPoly = new Polygon3(); 2046 2047 planePoly->Split(planes[i], *frontPoly, *backPoly, splitPts); 2048 DEL_PTR(planePoly); 2049 2050 if(sides[i] == true) 2051 { 2052 planePoly = frontPoly; 2053 DEL_PTR(backPoly); 2054 } 1985 2055 else 1986 2056 { 1987 p oly = backPoly;2057 planePoly = backPoly; 1988 2058 DEL_PTR(frontPoly); 1989 2059 } 2060 1990 2061 inside = true; 1991 break; 2062 } 2063 break; 1992 2064 case Polygon3::BACK_SIDE: 1993 2065 if (sides[i]) … … 2002 2074 } 2003 2075 } 2076 2077 //-- finally add polygon 2078 if (inside) 2079 newCell.push_back(planePoly); 2080 else 2081 { 2082 //just copy polygons 2083 DEL_PTR(planePoly); 2084 PolygonContainer::const_iterator it, it_end = cell.end(); 2085 2086 for (it = cell.begin(); it != it_end; ++ it) 2087 newCell.push_back(*it); 2088 2089 return false; 2090 } 2004 2091 2005 2092 //-- plane poly splits all other candidates 2006 2007 // some polygons may fall out => rebuild cell2008 vector<Candidate> candidates;2009 2010 2093 for (int i = 0; i < (int)cell.size(); ++ i) 2011 2094 { 2012 candidates.push_back(Candidate(cell[i], planes[i], sides[i])); 2013 } 2014 2015 cell.clear(); 2016 planes.clear(); 2017 sides.clear(); 2018 2019 for (int i = 0; i < (int)candidates.size(); ++ i) 2020 { 2021 bool candidateInside = true; 2022 2023 VertexContainer splitPts; 2024 Polygon3 *frontPoly, *backPoly; 2025 2026 const int cf = poly->ClassifyPlane(halfspace); 2095 inside = true; 2096 2097 const int cf = cell[i]->ClassifyPlane(splitPlane); 2027 2098 2028 2099 // split new polygon with all previous planes … … 2030 2101 { 2031 2102 case Polygon3::SPLIT: 2032 frontPoly = new Polygon3();2033 backPoly = new Polygon3();2034 2035 poly->Split(halfspace, *frontPoly, *backPoly, splitPts);2036 DEL_PTR(candidates[i].mPoly);2037 2038 if (sides[i] == true)2039 2103 { 2040 candidates[i].mPoly = frontPoly; 2041 DEL_PTR(backPoly); 2104 Polygon3 *poly = new Polygon3(*cell[i]); 2105 2106 Polygon3 *frontPoly = new Polygon3(); 2107 Polygon3 *backPoly = new Polygon3(); 2108 2109 VertexContainer splitPts; 2110 2111 poly->Split(splitPlane, *frontPoly, *backPoly, splitPts); 2112 DEL_PTR(poly); 2113 2114 if (sides[i] == true) 2115 { 2116 newCell.push_back(frontPoly); 2117 DEL_PTR(backPoly); 2118 } 2119 else 2120 { 2121 newCell.push_back(backPoly); 2122 DEL_PTR(frontPoly); 2123 } 2042 2124 } 2043 else2044 {2045 candidates[i].mPoly = backPoly;2046 DEL_PTR(frontPoly);2047 }2048 inside = true;2049 2125 break; 2050 2126 case Polygon3::BACK_SIDE: 2051 if (candidates[i].mSide) 2052 candidateInside = false; 2127 if (!sides[i]) 2128 newCell.push_back(new Polygon3(*cell[i])); 2129 2053 2130 break; 2054 2131 case Polygon3::FRONT_SIDE: 2055 if (!candidates[i].mSide) 2056 candidateInside = false; 2132 if (sides[i]) 2133 newCell.push_back(new Polygon3(*cell[i])); 2134 inside = false; 2057 2135 break; 2058 2136 default: 2059 2137 break; 2060 2138 } 2061 2062 if (candidateInside) 2063 { 2064 cell.push_back(candidates[i].mPoly); 2065 sides.push_back(candidates[i].mSide); 2066 planes.push_back(candidates[i].mPlane); 2067 } 2068 else 2069 { 2070 DEL_PTR(candidates[i].mPoly); 2071 } 2072 } 2073 2074 //-- finally add polygon 2075 if (inside) 2076 { 2077 cell.push_back(poly); 2078 planes.push_back(halfspace); 2079 sides.push_back(side); 2080 } 2081 else 2082 { 2083 DEL_PTR(poly); 2084 } 2139 } 2140 2141 return true; 2085 2142 } 2086 2143 … … 2340 2397 return NULL; 2341 2398 } 2342 2343 int BspTree::CountPvs(const BoundedRayContainer &rays) const2344 {2345 int pvsSize = 0;2346 2347 BoundedRayContainer::const_iterator rit, rit_end = rays.end();2348 vector<Ray::BspIntersection>::const_iterator iit;2349 2350 ViewCell::NewMail();2351 2352 for (rit = rays.begin(); rit != rit_end; ++ rit)2353 {2354 Ray *ray = (*rit)->mRay;2355 2356 for (iit = ray->bspIntersections.begin();2357 iit != ray->bspIntersections.end(); ++ iit)2358 {2359 BspViewCell *vc = (*iit).mLeaf->mViewCell;2360 2361 if (vc->Mailed())2362 {2363 pvsSize += vc->GetPvs().GetSize();2364 }2365 }2366 }2367 2368 return pvsSize;2369 } -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r378 r379 455 455 BspLeaf *GetRandomLeaf(const bool onlyUnmailed = false); 456 456 457 /** Adds halfspace to cell definition. 458 @param side indicates which side of halfspace is added 459 */ 460 void AddHalfspace(PolygonContainer &cell, 461 vector<Plane3> &planes, 462 vector<bool> &sides, 463 const Plane3 &halfspace, 464 const bool side) const; 457 /** Computes new cell based on the old cell definition and a new split plane 458 @param side indicates which side of the halfspace 459 @returns true if plane contributes to the cell. 460 */ 461 bool ComputeChildrenGeometry(PolygonContainer &newCell, 462 const PolygonContainer &cell, 463 const vector<Plane3> &planes, 464 const vector<bool> &sides, 465 const Plane3 &splitPlane, 466 const bool side) const; 467 465 468 466 469 /** Returns true if merge criteria are reached. … … 602 605 @param polygons container of polygons 603 606 @param rays bundle of rays on which the split can be based 604 @param maxTests the maximal number of candidate tests 607 @param maxPolyCandidates the maximal number of tested polygon candidates 608 @param maxRayCandidates the maximal number of ray candidates 605 609 */ 606 610 Plane3 SelectPlaneHeuristics(PolygonContainer &polys, 607 611 const BoundedRayContainer &rays, 608 const int maxTests); 612 const int maxPolyCandidates, 613 const int maxRayCandidates); 609 614 610 615 /** Extracts the meshes of the objects and adds them to polygons. … … 710 715 void ExtractSplitPlanes(BspNode *n, vector<Plane3 *> &planes, vector<bool> &sides) const; 711 716 712 int CountPvs(const BoundedRayContainer &rays) const; 713 714 float PvsValue(Intersectable &obj, 715 const int cf, 716 const int frontId, 717 const int backId, 718 const int frontAndBackId) const; 717 /** Computes the pvs of the front and back leaf with a given classification. 718 */ 719 void ComputePvs(Intersectable &obj, 720 float &frontPvs, 721 float &backPvs, 722 const int cf, 723 const int frontId, 724 const int backId, 725 const int frontAndBackId) const; 719 726 720 727 /// Pointer to the root of the tree 721 728 BspNode *mRoot; 722 723 729 724 730 BspTreeStatistics mStat; … … 764 770 static int sSplitPlaneStrategy; 765 771 /// number of candidates evaluated for the next split plane 766 static int sMaxCandidates; 772 static int sMaxPolyCandidates; 773 static int sMaxRayCandidates; 767 774 /// BSP tree construction method 768 775 static int sConstructionMethod; -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r378 r379 179 179 180 180 void 181 X3dExporter::ExportBspViewCellPartition(const BspTree &tree )181 X3dExporter::ExportBspViewCellPartition(const BspTree &tree, const int maxPvs) 182 182 { 183 183 ViewCellContainer viewCells; … … 186 186 ViewCellContainer::const_iterator it, it_end = viewCells.end(); 187 187 188 189 if (maxPvs == 0) 190 mUseForcedMaterial = true; 191 188 192 for (it = viewCells.begin(); it != it_end; ++ it) 189 193 { 194 mForcedMaterial.mDiffuseColor.b = 1.0f; 195 196 float importance = 0; 197 198 if (maxPvs > 0) 199 importance = (float)(*it)->GetPvs().GetSize() / (float)maxPvs; 200 201 mForcedMaterial.mDiffuseColor.r = importance; 202 mForcedMaterial.mDiffuseColor.g = 1.0f - mForcedMaterial.mDiffuseColor.r; 203 190 204 if ((*it)->GetMesh()) 191 205 ExportViewCell(*it); … … 194 208 PolygonContainer cell; 195 209 tree.ConstructGeometry(dynamic_cast<BspViewCell *>(*it), cell); 210 196 211 ExportPolygons(cell); 197 212 } -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.h
r373 r379 86 86 87 87 virtual void 88 ExportBspViewCellPartition(const BspTree &tree );88 ExportBspViewCellPartition(const BspTree &tree, const int maxPvs = 0); 89 89 90 90 virtual void
Note: See TracChangeset
for help on using the changeset viewer.