- Timestamp:
- 11/09/05 18:23:43 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r396 r397 126 126 #splitPlaneStrategy 130 127 127 128 splitPlaneStrategy 8128 splitPlaneStrategy 1024 129 129 130 maxPolyCandidates 50131 maxRayCandidates 1024130 maxPolyCandidates 200 131 maxRayCandidates 0 132 132 133 133 Termination { 134 134 # autopartition 135 maxRays 100 136 maxPolygons 0 137 maxDepth 50 138 minPvs -1 135 maxRays 200 136 maxPolygons 5 137 maxDepth 30 138 minPvs 50 139 minArea -0.001 139 140 140 141 # axis aligned splits -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r390 r397 1220 1220 "20"); 1221 1221 1222 RegisterOption("BspTree.Termination.minArea", 1223 optFloat, 1224 "-bsp_term_min_area=", 1225 "0.001"); 1226 1222 1227 RegisterOption("BspTree.Termination.maxRays", 1223 1228 optInt, -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r396 r397 17 17 int BspTree::sTermMinPvs = 20; 18 18 int BspTree::sTermMaxDepth = 20; 19 float BspTree::sTermMinArea = 0.001; 19 20 int BspTree::sMaxPolyCandidates = 10; 20 21 int BspTree::sMaxRayCandidates = 10; … … 692 693 } 693 694 695 inline bool BspTree::TerminationCriteriaMet(const BspTraversalData &data) const 696 { 697 return 698 (((int)data.mPolygons->size() <= sTermMaxPolygons) || 699 ((int)data.mRays->size() <= sTermMaxRays) || 700 (data.mPvs <= sTermMinPvs) || 701 (data.mArea <= sTermMinArea) || 702 (data.mDepth >= sTermMaxDepth)); 703 } 694 704 695 705 BspNode *BspTree::Subdivide(BspTraversalStack &tStack, BspTraversalData &tData) 696 706 { 697 707 //-- terminate traversal 698 if (((int)tData.mPolygons->size() <= sTermMaxPolygons) || 699 ((int)tData.mRays->size() <= sTermMaxRays) || 700 (tData.mPvs <= sTermMinPvs) || 701 (tData.mDepth >= sTermMaxDepth)) 702 708 if (TerminationCriteriaMet(tData)) 703 709 { 704 710 BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); … … 747 753 748 754 //-- continue subdivision 749 750 755 PolygonContainer coincident; 751 756 … … 1053 1058 if (sSplitPlaneStrategy & RANDOM_POLYGON) 1054 1059 { 1055 Polygon3 *nextPoly = (*data.mPolygons)[Random((int)data.mPolygons->size())]; 1056 return nextPoly->GetSupportingPlane(); 1060 if (!data.mPolygons->empty()) 1061 { 1062 Polygon3 *nextPoly = (*data.mPolygons)[Random((int)data.mPolygons->size())]; 1063 return nextPoly->GetSupportingPlane(); 1064 } 1065 1066 return Plane3(); 1057 1067 } 1058 1068 … … 1083 1093 SplitPlaneCost(poly->GetSupportingPlane(), data, frontData, backData); 1084 1094 1085 Debug << "cost: " << candidateCost << ", lowest: " << lowestCost << endl;1086 1087 1095 if (candidateCost < lowestCost) 1088 1096 { … … 1092 1100 } 1093 1101 1102 Debug << "lowest: " << lowestCost << endl; 1103 1094 1104 //limit = maxRaysCandidates > 0 ? Min((int)rays.size(), maxRayCandidates) : (int)rays.size(); 1095 1105 const BoundedRayContainer *rays = data.mRays; … … 1103 1113 Vector3 pt[3]; 1104 1114 int idx[3]; 1105 1115 1106 1116 for (int j = 0; j < 3; j ++) 1107 1117 { 1108 1118 idx[j] = Random((int)rays->size() * 2); 1109 1119 1110 BoundedRay *bRay = (*rays)[idx[j]];1111 Ray *ray = bRay->mRay;1112 1113 1120 if (idx[j] < (int)rays->size()) 1114 pt[j] = ray->Extrap(bRay->mMinT);1121 pt[j] = (*rays)[idx[j]]->mRay->Extrap((*rays)[idx[j]]->mMinT); 1115 1122 else 1116 { 1123 { 1117 1124 idx[j] -= (int)rays->size(); 1118 pt[j] = ray->Extrap(bRay->mMaxT);1125 pt[j] = (*rays)[idx[j]]->mRay->Extrap((*rays)[idx[j]]->mMaxT); 1119 1126 } 1120 1127 } 1121 1128 1122 1129 plane = Plane3(pt[0], pt[1], pt[2]); 1123 1130 } … … 1144 1151 if (candidateCost < lowestCost) 1145 1152 { 1146 Debug << "choose ray plane: " << lowestCost << endl;1153 Debug << "choose ray plane: " << candidateCost << endl; 1147 1154 bestPlane = plane; 1148 1155 1149 1156 lowestCost = candidateCost; 1150 1157 } 1151 else 1152 Debug << "ray cost: " << candidateCost << ", lowest: " << lowestCost << endl; 1153 } 1154 1155 //Debug << "Plane lowest cost: " << lowestCost << endl; 1158 } 1159 1160 Debug << "Plane lowest cost: " << lowestCost << endl; 1156 1161 return bestPlane; 1157 1162 } … … 1262 1267 // all values should be approx. between 0 and 1 so they can be combined 1263 1268 // and scaled with the factors according to their importance 1264 if ( sSplitPlaneStrategy & BALANCED_POLYS)1269 if ((sSplitPlaneStrategy & BALANCED_POLYS) && (!polys.empty())) 1265 1270 val += sBalancedPolysFactor * fabs(sumBalancedPolys) / (float)polys.size(); 1266 1271 1267 if ( sSplitPlaneStrategy & LEAST_SPLITS)1272 if ((sSplitPlaneStrategy & LEAST_SPLITS) && (!polys.empty())) 1268 1273 val += sLeastSplitsFactor * sumSplits / (float)polys.size(); 1269 1274 … … 1411 1416 if ((sSplitPlaneStrategy & BALANCED_RAYS) && !rays.empty()) 1412 1417 val += sBalancedRaysFactor * fabs(sumBalancedRays) / (float)rays.size(); 1413 1418 pOverall = 1; pFront = 1; pBack = 1; 1414 1419 if ((sSplitPlaneStrategy & PVS) && area && pvs) 1415 1420 val += sPvsFactor * (frontData.mPvs * pFront + (backData.mPvs * pBack)) / … … 1543 1548 environment->GetIntValue("BspTree.Termination.maxPolygons", sTermMaxPolygons); 1544 1549 environment->GetIntValue("BspTree.Termination.maxRays", sTermMaxRays); 1550 environment->GetFloatValue("BspTree.Termination.minArea", sTermMinArea); 1545 1551 1546 1552 //-- termination criteria for axis aligned split … … 1569 1575 Debug << "BSP max depth: " << sTermMaxDepth << endl; 1570 1576 Debug << "BSP min PVS: " << sTermMinPvs << endl; 1577 Debug << "BSP min area: " << sTermMinArea << endl; 1571 1578 Debug << "BSP max polys: " << sTermMaxPolygons << endl; 1572 1579 Debug << "BSP max rays: " << sTermMaxRays << endl; … … 1652 1659 1653 1660 // store minimal and maximal pvs 1654 /*if (data.mPvs > mStat.pvs) 1655 mStat.pvs = data.mPvs; 1656 1657 if (data.mPvs < mStat.pvs) 1658 mStat.pvs = data.mPvs;*/ 1661 /*if (data.mPvs > mStat.pvs)mStat.pvs = data.mPvs; 1662 if (data.mPvs < mStat.pvs) mStat.pvs = data.mPvs;*/ 1659 1663 1660 1664 // accumulate depth to compute average … … 1664 1668 Debug << "BSP stats: " 1665 1669 << "Depth: " << data.mDepth << " (max: " << sTermMaxDepth << "), " 1666 << "PVS: " << data.mPvs << " (max: " << sTermMinPvs << "), " 1670 << "PVS: " << data.mPvs << " (min: " << sTermMinPvs << "), " 1671 << "Area: " << data.mArea << " (min: " << sTermMinArea << "), " 1667 1672 << "#polygons: " << (int)data.mPolygons->size() << " (max: " << sTermMaxPolygons << "), " 1668 1673 << "#rays: " << (int)data.mRays->size() << " (max: " << sTermMaxRays << "), " … … 2392 2397 } 2393 2398 2394 //Debug << "returning new geometry " << mPolys.size() << " CHILD: " << childCell->mPolys.size() << endl;2395 //Debug << "old area " << this->GetArea() << " new: " << childCell->GetArea() << endl;2399 Debug << "returning new geometry " << mPolys.size() << " f: " << front.mPolys.size() << " b: " << back.mPolys.size() << endl; 2400 Debug << "old area " << GetArea() << " f: " << front.GetArea() << " b: " << back.GetArea() << endl; 2396 2401 } 2397 2402 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r396 r397 740 740 int ComputePvsSize(const BoundedRayContainer &rays) const; 741 741 742 bool TerminationCriteriaMet(const BspTraversalData &data) const; 743 742 744 /// Pointer to the root of the tree 743 745 BspNode *mRoot; … … 782 784 /// maximal possible depth 783 785 static int sTermMaxDepth; 784 /// mininam pvs 786 /// mininum area 787 static float sTermMinArea; 788 /// mininum PVS 785 789 static int sTermMinPvs; 786 790 /// strategy to get the best split plane
Note: See TracChangeset
for help on using the changeset viewer.