Changeset 1141 for GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
- Timestamp:
- 07/18/06 19:03:14 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
r1139 r1141 364 364 Environment::GetSingleton()->GetBoolValue("VspTree.simulateOctree", mCirculatingAxis); 365 365 366 Environment::GetSingleton()->GetBoolValue("VspTree.useKdPvs ", mUseKdPvs);366 Environment::GetSingleton()->GetBoolValue("VspTree.useKdPvsForHeuristics", mUseKdPvsForHeuristics); 367 367 368 368 char subdivisionStatsLog[100]; … … 400 400 Debug << "maxband: " << mMaxBand << endl; 401 401 402 if (!mUseKdPvs )402 if (!mUseKdPvsForHeuristics) 403 403 Debug << "pvs count method: per object" << endl; 404 404 else … … 534 534 int conSamp = 0; 535 535 float sampCon = 0.0f; 536 Add ToPvs(leaf, *tData.mRays, sampCon, conSamp);536 AddSamplesToPvs(leaf, *tData.mRays, sampCon, conSamp); 537 537 538 538 // update scalar pvs size value 539 mViewCellsManager->SetScalarPvsSize(viewCell, viewCell->GetPvs(). GetSize());539 mViewCellsManager->SetScalarPvsSize(viewCell, viewCell->GetPvs().CountPvs()); 540 540 541 541 mVspStats.contributingSamples += conSamp; … … 847 847 848 848 849 void VspTree::AddToPvs(VspLeaf *leaf, 850 const RayInfoContainer &rays, 851 float &sampleContributions, 852 int &contributingSamples) 849 bool VspTree::AddKdLeafToPvs(KdLeaf *leaf, 850 ViewCell *vc, 851 float &pdf, 852 float &contribution) 853 { 854 bool contri = false; 855 856 #if 1 // add kd intersecable to pvs 857 KdIntersectable *kdObj = mOspTree->GetOrCreateKdIntersectable(leaf); 858 859 if (vc->AddPvsSample(kdObj, pdf, contribution)) 860 { 861 return true; 862 } 863 864 #else // add all objects of kd node 865 866 pdf = 0; 867 contribution = 0; 868 869 ObjectContainer::const_iterator it, it_end = leaf->mObjects.end(); 870 871 for (it = leaf->mObjects.begin(); it != it_end; ++ it) 872 { 873 Intersectable *object = *it; 874 875 float newpdf; 876 float newcontri; 877 878 if (vc->AddPvsSample(object, newpdf, newcontri)) 879 { 880 contri = true; 881 } 882 883 pdf += newPdf; 884 newContri += contribution; 885 } 886 887 #endif 888 889 return contri; 890 } 891 892 void VspTree::AddSamplesToPvs(VspLeaf *leaf, 893 const RayInfoContainer &rays, 894 float &sampleContributions, 895 int &contributingSamples) 853 896 { 854 897 sampleContributions = 0; … … 859 902 ViewCellLeaf *vc = leaf->GetViewCell(); 860 903 904 861 905 // add contributions from samples to the PVS 862 906 for (it = rays.begin(); it != it_end; ++ it) … … 875 919 876 920 // potentially visible kd cells 877 if (m UseKdPvs)921 if (mStoreKdPvs) 878 922 { 879 923 KdLeaf *leaf = mOspTree->GetLeaf(ray->mTermination, ray->mTerminationNode); 880 KdIntersectable *kdObj = new KdIntersectable(leaf); 881 882 entry = kdObj; 924 AddKdLeafToPvs(leaf, vc, ray->mPdf, contribution); 883 925 } 884 926 else 885 entry = obj;886 887 if (vc->AddPvsSample(obj, ray->mPdf, contribution))888 {889 madeContrib = true;927 { 928 if (vc->AddPvsSample(obj, ray->mPdf, contribution)) 929 { 930 madeContrib = true; 931 } 890 932 } 891 933 … … 900 942 901 943 // potentially visible kd cells 902 if (mUseKdPvs) 903 { 904 KdLeaf *leaf = mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode); 905 KdIntersectable *kdObj = new KdIntersectable(leaf); 906 907 entry = kdObj; 944 if (mUseKdPvsForHeuristics) 945 { 946 KdLeaf *leaf = mOspTree->GetLeaf(ray->mOrigin, ray->mOriginNode); 947 AddKdLeafToPvs(leaf, vc, ray->mPdf, contribution); 908 948 } 909 949 else 910 entry = obj;911 912 if (vc->AddPvsSample(obj, ray->mPdf, contribution))913 {914 madeContrib = true;950 { 951 if (vc->AddPvsSample(obj, ray->mPdf, contribution)) 952 { 953 madeContrib = true; 954 } 915 955 } 916 956 … … 919 959 920 960 if (madeContrib) 961 { 921 962 ++ contributingSamples; 922 963 } 964 923 965 // store rays for visualization 924 966 if (0) leaf->mVssRays.push_back(new VssRay(*ray)); … … 1056 1098 if (oObject) 1057 1099 { 1058 if (!mUseKdPvs )1100 if (!mUseKdPvsForHeuristics) 1059 1101 { 1060 1102 if (!oObject->Mailed()) … … 1080 1122 if (tObject) 1081 1123 { 1082 if (!mUseKdPvs )1124 if (!mUseKdPvsForHeuristics) 1083 1125 { 1084 1126 if (!tObject->Mailed()) … … 1166 1208 if (oObject) 1167 1209 { 1168 if (!mUseKdPvs )1210 if (!mUseKdPvsForHeuristics) 1169 1211 { 1170 1212 if (ci.type == SortableEntry::ERayMin) … … 1202 1244 if (tObject) 1203 1245 { 1204 if (!mUseKdPvs )1246 if (!mUseKdPvsForHeuristics) 1205 1247 { 1206 1248 if (ci.type == SortableEntry::ERayMin) … … 1615 1657 if (leaf->TreeValid() && 1616 1658 (!onlyUnmailed || !leaf->Mailed()) && 1617 ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs(). GetSize() <= maxPvsSize)))1659 ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().CountPvs() <= maxPvsSize))) 1618 1660 { 1619 1661 leaves.push_back(leaf); … … 1692 1734 << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 1693 1735 << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 1694 << "#pvs: " << leaf->GetViewCell()->GetPvs(). GetSize() << "), "1736 << "#pvs: " << leaf->GetViewCell()->GetPvs().CountPvs() << "), " 1695 1737 << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 1696 1738 #endif … … 2707 2749 } 2708 2750 2751 2752 OspTree::~OspTree() 2753 { 2754 KdIntersectableMap::iterator it, it_end = mKdIntersectables.end(); 2755 2756 for (it = mKdIntersectables.begin(); it != mKdIntersectables.end(); ++ it) 2757 { 2758 DEL_PTR((*it).second); 2759 } 2760 } 2709 2761 2710 2762 … … 3895 3947 3896 3948 3949 KdIntersectable *OspTree::GetOrCreateKdIntersectable(KdNode *node) 3950 { 3951 // search nodes 3952 std::map<KdNode *, KdIntersectable *>::const_iterator it = mKdIntersectables.find(node); 3953 3954 if (it != mKdIntersectables.end()) 3955 { 3956 return (*it).second; 3957 } 3958 3959 // not in map => create new entry 3960 KdIntersectable *kdObj= new KdIntersectable(node); 3961 3962 mKdIntersectables[node] = kdObj; 3963 3964 return kdObj; 3965 } 3897 3966 3898 3967 … … 3900 3969 /* class HierarchyManager implementation */ 3901 3970 /********************************************************************/ 3902 3903 3971 3904 3972 … … 4068 4136 // makes no sense otherwise because only one kd cell available 4069 4137 // during view space partition 4070 const bool savedCountMethod = mVspTree.mUseKdPvs; 4071 mVspTree.mUseKdPvs = false; 4138 const bool savedCountMethod = mVspTree.mUseKdPvsForHeuristics; 4139 const bool savedStoreMethod = mVspTree.mStoreKdPvs; 4140 4141 mVspTree.mUseKdPvsForHeuristics = false; 4142 mVspTree.mStoreKdPvs = false; 4072 4143 4073 4144 mTQueue.Push(PrepareVsp(sampleRays, forcedViewSpace, *viewSpaceRays)); … … 4148 4219 cout << "finished in " << TimeDiff(startTime, GetTime())*1e-3 << " secs" << endl; 4149 4220 4150 mVspTree.mUseKdPvs = savedCountMethod; 4221 mVspTree.mUseKdPvsForHeuristics = savedCountMethod; 4222 mVspTree.mStoreKdPvs = savedStoreMethod; 4151 4223 } 4152 4224
Note: See TracChangeset
for help on using the changeset viewer.