Changeset 442 for trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
- Timestamp:
- 12/02/05 02:02:07 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r441 r442 218 218 /****************************************************************/ 219 219 220 VspBspTree::VspBspTree( BspViewCell *viewCell):221 mRoot Cell(viewCell),222 m Root(NULL),223 mStoreLeavesWithRays(false), 224 mPvsUseLen(true) 225 { 220 VspBspTree::VspBspTree(): 221 mRoot(NULL), 222 mPvsUseArea(true) 223 { 224 mRootCell = new BspViewCell(); 225 226 226 Randomize(); // initialise random generator for heuristics 227 227 … … 349 349 { 350 350 DEL_PTR(mRoot); 351 DEL_PTR(mRootCell); 351 352 } 352 353 … … 485 486 486 487 VspBspTraversalData tData(mRoot, polys, 0, mRootCell, rays, 487 ComputePvsSize(*rays) );488 ComputePvsSize(*rays), cell->GetArea(), cell); 488 489 489 490 tStack.push(tData); … … 515 516 (((int)data.mRays->size() <= mTermMinRays) || 516 517 (data.mPvs <= mTermMinPvs) || 518 (data.mArea <= mTermMinArea) || 517 519 (data.mDepth >= mTermMaxDepth) || 518 520 (data.GetAvgRayContribution() < mTermMaxRayContribution)); … … 547 549 DEL_PTR(tData.mPolygons); 548 550 DEL_PTR(tData.mRays); 549 //DEL_PTR(tData.mGeometry);551 DEL_PTR(tData.mGeometry); 550 552 551 553 return leaf; … … 556 558 557 559 VspBspTraversalData tFrontData(NULL, new PolygonContainer(), tData.mDepth + 1, mRootCell, 558 new RayInfoContainer(), 0 );560 new RayInfoContainer(), 0, 0, new VspBspNodeGeometry()); 559 561 VspBspTraversalData tBackData(NULL, new PolygonContainer(), tData.mDepth + 1, mRootCell, 560 new RayInfoContainer(), 0 );562 new RayInfoContainer(), 0, 0, new VspBspNodeGeometry()); 561 563 562 564 // create new interior node and two leaf nodes … … 582 584 DEL_PTR(tData.mPolygons); 583 585 DEL_PTR(tData.mRays); 584 //DEL_PTR(tData.mGeometry);586 DEL_PTR(tData.mGeometry); 585 587 586 588 return interior; … … 615 617 frontData.mPvs = ComputePvsSize(*frontData.mRays); 616 618 backData.mPvs = ComputePvsSize(*backData.mRays); 619 620 // split geometry and compute area 621 if (1) 622 { 623 tData.mGeometry->SplitGeometry(*frontData.mGeometry, 624 *backData.mGeometry, 625 *this, 626 interior->mPlane); 627 628 629 frontData.mArea = frontData.mGeometry->GetArea(); 630 backData.mArea = backData.mGeometry->GetArea(); 631 } 617 632 618 633 // compute accumulated ray length … … 991 1006 float pBack = 0; 992 1007 1008 const bool pvsUseLen = false; 1009 993 1010 if (mSplitPlaneStrategy & PVS) 1011 { 994 1012 // create unique ids for pvs heuristics 995 1013 GenerateUniqueIdsForPvs(); 996 1014 1015 if (mPvsUseArea) // use front and back cell areas to approximate volume 1016 { 1017 // construct child geometry with regard to the candidate split plane 1018 VspBspNodeGeometry frontCell; 1019 VspBspNodeGeometry backCell; 1020 1021 data.mGeometry->SplitGeometry(frontCell, backCell, *this, candidatePlane); 1022 1023 pFront = frontCell.GetArea(); 1024 pBack = backCell.GetArea(); 1025 1026 pOverall = data.mArea; 1027 } 1028 } 997 1029 998 1030 RayInfoContainer::const_iterator rit, rit_end = data.mRays->end(); … … 1026 1058 AddObjToPvs(ray->mOriginObject, cf, frontPvs, backPvs); 1027 1059 1028 float len = 1; 1029 1030 if (mPvsUseLen) // use front and back cell areas to approximate volume 1031 len = (*rit).SqrSegmentLength(); 1060 // use number or length of rays to approximate volume 1061 if (!mPvsUseArea) 1062 { 1063 float len = 1; 1064 1065 if (pvsUseLen) // use length of rays 1066 len = (*rit).SqrSegmentLength(); 1032 1067 1033 pOverall += len; 1034 1035 // use length of rays to approximate volume 1036 if (cf == 1) 1037 pFront += len; 1038 if (cf == -1) 1039 pBack += len; 1040 if (cf == 0) 1041 { 1042 if (mPvsUseLen) 1068 pOverall += len; 1069 1070 if (cf == 1) 1071 pFront += len; 1072 if (cf == -1) 1073 pBack += len; 1074 if (cf == 0) 1043 1075 { 1044 float newLen = len * 1045 ((*rit).GetMaxT() - (*rit).mRay->mT) / 1046 ((*rit).GetMaxT() - (*rit).GetMinT()); 1047 1048 1049 if (candidatePlane.Side((*rit).ExtrapOrigin()) <= 0) 1076 // use length of rays to approximate volume 1077 if (pvsUseLen) 1050 1078 { 1051 pBack += newLen; 1052 pFront += len - newLen; 1079 float newLen = len * 1080 ((*rit).GetMaxT() - (*rit).mRay->mT) / 1081 ((*rit).GetMaxT() - (*rit).GetMinT()); 1082 1083 if (candidatePlane.Side((*rit).ExtrapOrigin()) <= 0) 1084 { 1085 pBack += newLen; 1086 pFront += len - newLen; 1087 } 1088 else 1089 { 1090 pFront += newLen; 1091 pBack += len - newLen; 1092 } 1053 1093 } 1054 1094 else 1055 1095 { 1056 pFront += newLen;1057 pBack += len - newLen;1096 ++ pFront; 1097 ++ pBack; 1058 1098 } 1059 1099 } 1060 else1061 {1062 ++ pFront;1063 ++ pBack;1064 }1065 1100 } 1066 1101 } … … 1083 1118 // give penalty to unbalanced split 1084 1119 if (0) 1085 if (((pFront * 0.2 + Limits::Small) > pBack) || (pFront < (pBack * 0.2 + Limits::Small))) 1120 if (((pFront * 0.2 + Limits::Small) > pBack) || 1121 (pFront < (pBack * 0.2 + Limits::Small))) 1086 1122 val += 0.5; 1087 1123 } … … 1199 1235 ++ mStat.maxRayContribNodes; 1200 1236 1237 if (data.mGeometry->GetArea() <= mTermMinArea) 1238 ++ mStat.minAreaNodes; 1201 1239 1202 1240 #ifdef _DEBUG … … 1984 2022 app << "===== END OF VspBspViewCells statistics ==========\n"; 1985 2023 } 2024 2025 BspViewCell *VspBspTree::GetRootCell() const 2026 { 2027 return mRootCell; 2028 }
Note: See TracChangeset
for help on using the changeset viewer.