Changeset 607 for trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
- Timestamp:
- 02/08/06 18:25:17 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r605 r607 116 116 environment->GetFloatValue("VspBspTree.Construction.renderCostWeight", mRenderCostWeight); 117 117 118 environment->GetBoolValue("VspBspTree.usePolygonSplitIfAvailable", mUsePolygonSplitIfAvailable); 118 119 119 120 mSubdivisionStats.open("subdivisionStats.log"); … … 431 432 432 433 mTotalCost = tData.mPvs * tData.mProbability / mBox.GetVolume(); 433 434 mTotalPvsSize = tData.mPvs; 435 434 436 mSubdivisionStats 435 437 << "#ViewCells\n1\n" << endl 436 438 << "#RenderCostDecrease\n0\n" << endl 437 << "#TotalRenderCost\n" << mTotalCost << endl; 439 << "#TotalRenderCost\n" << mTotalCost << endl 440 << "#AvgRenderCost\n" << mTotalPvsSize << endl; 438 441 439 442 Debug << "total cost: " << mTotalCost << endl; … … 533 536 float cData = tData.mPvs * tData.mProbability;; 534 537 535 538 float costDecr = 536 539 (cFront + cBack - cData) / mBox.GetVolume(); 540 541 int pvsFront = tFrontData.mPvs * tFrontData.mProbability; 542 int pvsBack = tBackData.mPvs * tBackData.mProbability; 543 int pvsData = tData.mPvs * tData.mProbability;; 544 537 545 mTotalCost += costDecr; 546 mTotalPvsSize += tFrontData.mPvs + tBackData.mPvs - tData.mPvs; 538 547 539 548 mSubdivisionStats 540 549 << "#ViewCells\n" << mBspStats.Leaves() << endl 541 550 << "#RenderCostDecrease\n" << -costDecr << endl 542 << "#TotalRenderCost\n" << mTotalCost << endl; 551 << "#TotalRenderCost\n" << mTotalCost << endl 552 << "#AvgRenderCost\n" << mTotalPvsSize / mBspStats.Leaves() << endl; 543 553 } 544 554 … … 1111 1121 } 1112 1122 1123 // cost ratio miss 1124 if (!mUsePolygonSplitIfAvailable || data.mPolygons->empty()) 1125 { 1126 frontData.mIsKdNode = backData.mIsKdNode = false; 1127 if (lowestCost > mTermMaxCostRatio) 1128 return false; 1129 1130 return true; 1131 } 1132 1113 1133 //-- evaluate axis aligned splits 1114 1134 int axis; … … 1361 1381 1362 1382 // only render cost heuristics or combined with standard deviation 1383 const float penaltyOld = EvalPvsPenalty(totalPvs, lowerPvsLimit, upperPvsLimit); 1384 const float penaltyFront = EvalPvsPenalty(pvsFront, lowerPvsLimit, upperPvsLimit); 1385 const float penaltyBack = EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); 1386 1387 const float oldRenderCost = pOverall * (float)penaltyOld + Limits::Small; 1388 const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 1389 1390 float oldCost, newCost; 1391 1392 // only render cost 1363 1393 if (1) 1364 1394 { 1365 const float penaltyOld = EvalPvsPenalty(totalPvs, lowerPvsLimit, upperPvsLimit); 1366 const float penaltyFront = EvalPvsPenalty(pvsFront, lowerPvsLimit, upperPvsLimit); 1367 const float penaltyBack = EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); 1368 1369 const float oldRenderCost = pOverall * (float)penaltyOld + Limits::Small; 1370 const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 1371 1372 float oldCost, newCost; 1373 1374 // only render cost 1375 if (1) 1376 { 1377 oldCost = oldRenderCost; 1378 newCost = newRenderCost; 1379 } 1380 else // also considering standard deviation 1381 { 1382 // standard deviation is difference of back and front pvs 1383 const float expectedCost = 0.5f * (penaltyFront + penaltyBack); 1384 1385 const float newDeviation = 0.5f * 1386 fabs(penaltyFront - expectedCost) + fabs(penaltyBack - expectedCost); 1387 1388 const float oldDeviation = penaltyOld + Limits::Small; 1389 1390 newCost = mRenderCostWeight * newRenderCost + (1.0f - mRenderCostWeight) * newDeviation; 1391 oldCost = mRenderCostWeight * oldRenderCost + (1.0f - mRenderCostWeight) * oldDeviation; 1392 } 1393 1394 cost += mPvsFactor * newCost / oldCost; 1395 } 1395 oldCost = oldRenderCost; 1396 newCost = newRenderCost; 1397 } 1398 else // also considering standard deviation 1399 { 1400 // standard deviation is difference of back and front pvs 1401 const float expectedCost = 0.5f * (penaltyFront + penaltyBack); 1402 1403 const float newDeviation = 0.5f * 1404 fabs(penaltyFront - expectedCost) + fabs(penaltyBack - expectedCost); 1405 1406 const float oldDeviation = penaltyOld + Limits::Small; 1407 1408 newCost = mRenderCostWeight * newRenderCost + (1.0f - mRenderCostWeight) * newDeviation; 1409 oldCost = mRenderCostWeight * oldRenderCost + (1.0f - mRenderCostWeight) * oldDeviation; 1410 } 1411 1412 cost += mPvsFactor * newCost / oldCost; 1413 1396 1414 } 1397 1415
Note: See TracChangeset
for help on using the changeset viewer.