Changeset 2643 for GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
- Timestamp:
- 02/21/08 18:10:24 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2633 r2643 12 12 #include "BvHierarchy.h" 13 13 #include "Polygon3.h" 14 #include "IntersectableWrapper.h" 15 14 16 15 17 … … 18 20 19 21 #define GVS_DEBUG 0 22 static ObjectContainer myobjects; 20 23 21 24 struct VizStruct … … 37 40 mCurrentViewCell(NULL), 38 41 mCurrentViewPoint(Vector3(0.0f, 0.0f, 0.0f)) 39 //,mGenericStats(0)40 42 { 41 43 Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples); … … 75 77 76 78 mGvsStats.Reset(); 79 80 mGenericStats = 0; 81 mGenericStats2 = 0; 77 82 } 78 83 … … 184 189 Intersectable *obj = ray.mTerminationObject; 185 190 186 if ( !obj->mCounter)191 if (obj->mCounter < 2) 187 192 { 188 obj->mCounter = 1;193 obj->mCounter += 2; 189 194 mTrianglePvs.push_back(obj); 190 195 196 mGenericStats = mTrianglePvs.size(); 197 191 198 // if using kd pvs, exchange the triangle with the node in the pvs 192 199 if (mUseKdPvs) … … 199 206 KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(node); 200 207 mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 208 //mCurrentViewCell->GetPvs().AddSampleDirtyCheck(kdInt, 1.0f); 209 201 210 mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 211 myobjects.clear(); 212 mKdTree->CollectObjects(node, myobjects); 213 214 // account for kd object pvs 215 ObjectContainer::const_iterator oit, oit_end = myobjects.end(); 216 217 for (oit = myobjects.begin(); oit != oit_end; ++ oit) 218 { 219 TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit); 220 221 if ((triObj->mCounter != 1) && (triObj->mCounter != 3)) 222 { 223 ++ triObj->mCounter; 224 ++ mGenericStats2; 225 } 226 } 202 227 } 203 228 } 204 229 205 230 result = true; 206 231 } … … 755 780 756 781 mGvsStats.mPerViewCellSamples = 0; 782 757 783 int oldContribution = mGvsStats.mTotalContribution; 758 784 int passSamples = 0; 759 760 785 mGenericStats = 0; 786 mGenericStats2 = 0; 761 787 762 788 //while (mGvsStats.mPerViewCellSamples < mTotalSamples) 763 while (1) 789 while (1) 764 790 { 765 791 mRayCaster->InitPass(); … … 788 814 cout << "contribution=" << mGvsStats.mPassContribution << " (of " << mMinContribution << ")" << endl; 789 815 790 //mGenericStats = GvsStats.mGvsStats.mPassContribution;816 //mGenericStats = mGvsStats.mPassContribution; 791 817 792 818 // termination criterium … … 865 891 AxisAlignedBox3 box = mCurrentViewCell->GetMesh()->mBox; 866 892 867 vector<KdLeaf *> leaves; 868 mKdTree->GetBoxIntersections(box, leaves); 869 870 vector<KdLeaf *>::const_iterator lit, lit_end = leaves.end(); 871 872 for (lit = leaves.begin(); lit != leaves.end(); ++ lit) 873 { 874 KdLeaf *leaf = *lit; 893 //vector<KdLeaf *> leaves; 894 //mKdTree->GetBoxIntersections(box, leaves); 895 896 ObjectContainer kdobjects; 897 mKdTree->CollectKdObjects(box, kdobjects); 898 //vector<KdLeaf *>::const_iterator lit, lit_end = leaves.end(); 899 //for (lit = leaves.begin(); lit != lit_end; ++ lit) 900 ObjectContainer::const_iterator oit, oit_end = kdobjects.end(); 901 for (oit = kdobjects.begin(); oit != oit_end; ++ oit) 902 { 903 // add to kdnode pvs 904 KdIntersectable *kdInt = static_cast<KdIntersectable *>(*oit); 875 905 876 // add to kdnode pvs 877 if (mUseKdPvs) 878 { 879 leaf->Mail(); 880 KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(leaf); 881 mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 882 883 mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 884 } 885 886 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 887 888 for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 906 //mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 907 mCurrentViewCell->GetPvs().AddSampleDirtyCheck(kdInt, 1.0f); 908 mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 909 910 myobjects.clear(); 911 mKdTree->CollectObjects(kdInt->GetItem(), myobjects); 912 913 // account for kd object pvs 914 ObjectContainer::const_iterator oit, oit_end = myobjects.end(); 915 916 for (oit = myobjects.begin(); oit != oit_end; ++ oit) 889 917 { 890 918 TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit); 891 919 920 // account for the overall pvs 921 if ((triObj->mCounter != 1) && (triObj->mCounter != 3)) 922 { 923 ++ triObj->mCounter; 924 ++ mGenericStats2; 925 } 926 927 // the triangle itself intersects 892 928 if (box.Intersects(triObj->GetItem())) 893 929 { 894 if ( !triObj->mCounter)930 if ((triObj->mCounter < 2)) 895 931 { 896 triObj->mCounter = 1; 932 triObj->mCounter += 2; 933 897 934 mTrianglePvs.push_back(triObj); 935 mGenericStats = mTrianglePvs.size(); 898 936 } 899 } 937 } 900 938 } 901 939 } 902 940 } 941 903 942 904 943 … … 929 968 continue; 930 969 931 //ViewCell *vc = mViewCellsManager->GetViewCell(mCurrentViewPoint);932 970 ViewCell *vc = mViewCellsManager->GetViewCell(mRendererWidget->GetViewPoint()); 933 971 934 //cout << "v " << mRendererWidget->GetViewPoint() << " ";935 936 972 // no valid view cell or view cell already computed 937 if (!vc || !vc->GetPvs().Empty() )973 if (!vc || !vc->GetPvs().Empty() || !mRendererWidget->mComputeGVS) 938 974 continue; 939 975 940 //cout << "computing new view cell: " << vc->GetId() << endl; 941 976 mRendererWidget->mComputeGVS = false; 942 977 // hack: reset counters 943 978 ObjectContainer::const_iterator oit, oit_end = mObjects.end(); … … 950 985 } 951 986 } 952 953 954 987 955 988 … … 999 1032 1000 1033 BvhLeaf::NewMail(); 1001 //KdNode::NewMail();1002 1034 1003 1035 ObjectContainer::const_iterator oit, oit_end = mTrianglePvs.end(); … … 1209 1241 { 1210 1242 mCurrentViewCell = vc; 1211 1212 if (mUseKdPvs) 1213 { 1214 KdNode::NewMail(); 1215 //mKdPvs.clear(); 1216 } 1243 KdNode::NewMail(); 1217 1244 1218 1245 long startTime = GetTime(); 1219 1246 cout << "\n***********************\n" 1220 << " processing view cell " << mProcessedViewCells1247 << "computing view cell " << mProcessedViewCells 1221 1248 << " (id: " << mCurrentViewCell->GetId() << ")" << endl; 1222 1249 … … 1256 1283 mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 1257 1284 */ 1258 mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize();; 1285 mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize(); 1286 1287 cout << "pvs cost: " << mCurrentViewCell->GetPvs().EvalPvsCost() << " pvs tri: " << mGenericStats2 << endl; 1259 1288 } 1260 1289 … … 1279 1308 1280 1309 mTrianglePvs.clear(); 1281 #if 0 1282 if (GVS_DEBUG) 1283 { 1284 //VisualizeViewCell(mCurrentViewCell); 1285 VisualizeViewCell(objectPvs); 1286 CLEAR_CONTAINER(mVssRays); 1287 } 1288 cout << "finished" << endl; 1289 1290 if (mEvaluatePixelError || mExportVisibility) 1291 { 1292 StorePvs(objectPvs); 1293 } 1294 #endif 1295 } 1296 1297 } 1310 } 1311 1312 }
Note: See TracChangeset
for help on using the changeset viewer.