Changeset 2542 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 08/20/07 12:51:12 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2539 r2542 34 34 #define PVS_ADD_DIRTY 1 35 35 36 37 36 38 namespace GtpVisibilityPreprocessor { 37 39 … … 46 48 const static bool CLAMP_TO_BOX = true; 47 49 50 51 52 inline static bool ilt(Intersectable *obj1, Intersectable *obj2) 53 { 54 return obj1->mId < obj2->mId; 55 } 48 56 49 57 … … 994 1002 EvaluateViewCellsStats(); 995 1003 996 if (1) CompressViewCells(); 1004 // compress the final solution 1005 if (0) CompressViewCells(); 997 1006 998 1007 // write view cells to disc … … 1021 1030 1022 1031 { 1032 if (!Debug.is_open()) Debug.open("debug.log"); 1033 1023 1034 // give just an empty container as parameter: 1024 1035 // this loading function is used in the engine, thus it 1025 1036 // does not need to load the entities the preprocessor works on 1026 1037 ObjectContainer preprocessorObjects; 1027 1028 if (!Debug.is_open()) Debug.open("debug.log");1029 1038 1030 1039 return LoadViewCells(filename, … … 1033 1042 finalizeViewCells, 1034 1043 bconverter); 1044 } 1045 1046 1047 void ViewCellsManager::LoadIndexedBoundingBoxes(IN_STREAM &stream, IndexedBoundingBoxContainer &iboxes) 1048 { 1049 Vector3 bmin; 1050 Vector3 bmax; 1051 int id; 1052 1053 stream.read(reinterpret_cast<char *>(&bmin), sizeof(Vector3)); 1054 stream.read(reinterpret_cast<char *>(&bmax), sizeof(Vector3)); 1055 stream.read(reinterpret_cast<char *>(&id), sizeof(int)); 1056 1057 AxisAlignedBox3 box(bmin, bmax); 1058 1059 iboxes.push_back(IndexedBoundingBox(id, box)); 1060 //Debug << "bbox: " << box << endl; 1061 } 1062 1063 1064 ViewCellsManager *ViewCellsManager::LoadViewCellsBin(const string &filename, 1065 ObjectContainer &pvsObjects, 1066 ObjectContainer &preprocessorObjects, 1067 bool finalizeViewCells, 1068 BoundingBoxConverter *bconverter) 1069 { 1070 IN_STREAM stream(filename.c_str()); 1071 1072 IndexedBoundingBoxContainer iboxes; 1073 LoadIndexedBoundingBoxes(stream, iboxes); 1074 1075 if (bconverter) 1076 { 1077 // all bounding boxes gathered in this step => 1078 // associate object ids with bounding boxes 1079 bconverter->IdentifyObjects(iboxes, pvsObjects); 1080 } 1081 1082 // sort objects by id 1083 sort(pvsObjects.begin(), pvsObjects.end(), ilt); 1084 1085 ViewCellsTree *vcTree = new ViewCellsTree(); 1086 VspTree *vspTree = new VspTree(); 1087 1088 HierarchyManager *hm = new HierarchyManager(0); 1089 1090 vspTree->ImportBinary(stream, pvsObjects); 1091 1092 VspOspViewCellsManager *vcm = new VspOspViewCellsManager(vcTree, hm); 1093 1094 return vcm; 1035 1095 } 1036 1096 … … 1061 1121 } 1062 1122 1063 if (0) //hack: should work with reset function, but something is wrong ..1123 if (0) //hack: reset function should work, but something is wrong .. 1064 1124 { 1065 1125 vm->ResetViewCells(); … … 1104 1164 const ObjectContainer &objects) 1105 1165 { 1166 // no view cells constructed yet 1106 1167 if (!ViewCellsConstructed() || !ViewCellsTreeConstructed()) 1107 {1108 1168 return false; 1109 }1110 1169 1111 1170 cout << "exporting view cells to xml ... "; … … 2424 2483 2425 2484 2426 2427 if (evaluateFilter){2485 if (evaluateFilter) 2486 { 2428 2487 ObjectPvs filteredPvs; 2429 2488 2430 PvsFilterStatistics fstat = ApplyFilter2(viewcell, 2431 false, 2432 mFilterWidth, 2433 filteredPvs); 2434 2435 float filteredCost = filteredPvs.EvalPvsCost(); 2489 PvsFilterStatistics fstat = ApplyFilter2(viewcell, false, mFilterWidth, filteredPvs); 2490 2491 const float filteredCost = filteredPvs.EvalPvsCost(); 2436 2492 2437 2493 stat.avgFilteredPvs += filteredCost; … … 3070 3126 MeshInstance *mi = static_cast<MeshInstance *>(*it); 3071 3127 const AxisAlignedBox3 box = mi->GetBox(); 3128 3072 3129 Vector3 bmin = box.Min(); 3073 3130 Vector3 bmax = box.Max(); 3131 3074 3132 int id = mi->GetId(); 3075 3133 … … 3444 3502 3445 3503 // Minimal number of samples so that filtering takes place 3446 #define MIN_SAMPLES 50 3504 const float MIN_SAMPLES = 50; 3447 3505 3448 3506 if (samples > MIN_SAMPLES) … … 3537 3595 } 3538 3596 3539 Debug << " nPvs size = " << pvs.GetSize() << endl;3597 //Debug << " nPvs size = " << pvs.GetSize() << endl; 3540 3598 3541 3599 if (!mUseKdPvs) … … 5887 5945 5888 5946 5889 Intersectable * 5890 VspOspViewCellsManager::GetIntersectable(const VssRay &ray,const bool isTermination) const5947 Intersectable *VspOspViewCellsManager::GetIntersectable(const VssRay &ray, 5948 const bool isTermination) const 5891 5949 { 5892 5950 if (mUseKdPvs) … … 6387 6445 const bool exportBounds = false; 6388 6446 6389 if (1)6390 6447 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, 6391 6448 objects, … … 6575 6632 const ObjectContainer &objects) 6576 6633 { 6634 // no view cells were computed 6577 6635 if (!ViewCellsConstructed() || !ViewCellsTreeConstructed()) 6578 6636 return false; 6637 6638 cout << "exporting binary" << endl; 6639 string fname("test.vc"); 6640 return ExportBinaryViewCells(fname, exportPvs, objects); 6579 6641 6580 6642 const long starttime = GetTime(); … … 6612 6674 6613 6675 stream << "<BoundingBox" << " id=\"" << id << "\"" 6614 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\""6615 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl;6676 << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 6677 << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 6616 6678 } 6679 6617 6680 stream << "</BoundingBoxes>" << endl; 6618 6681 } … … 6661 6724 const ObjectContainer &objects) 6662 6725 { 6726 // no view cells constructed yet 6663 6727 if (!ViewCellsConstructed() || !ViewCellsTreeConstructed()) 6664 6728 return false; … … 6678 6742 /////////////// 6679 6743 //-- export bounding boxes 6680 //-- we need the boxes to identify objects in the target engine 6681 6744 6745 // we use bounding box intersection to identify pvs objects in the target engine 6682 6746 vector<KdIntersectable *>::const_iterator kit, kit_end = mPreprocessor->mKdTree->mKdIntersectables.end(); 6683 6747 … … 6689 6753 const AxisAlignedBox3 &box = obj->GetBox(); 6690 6754 6691 // set kd node id6755 // setting the kd node id important to identify the kd node as pvs entry 6692 6756 obj->SetId(id); 6757 6693 6758 Vector3 bmin = box.Min(); 6694 6759 Vector3 bmax = box.Max(); … … 6703 6768 //-- export the view cells and the pvs 6704 6769 6705 6706 6770 int numViewCells = mCurrentViewCellsStats.viewCells; 6707 6771 stream.write(reinterpret_cast<char *>(&numViewCells), sizeof(int)); … … 6712 6776 stream.write(reinterpret_cast<char *>(&vmin), sizeof(Vector3)); 6713 6777 stream.write(reinterpret_cast<char *>(&vmax), sizeof(Vector3)); 6778 6779 // todo 6780 mViewCellsTree->ExportBinary(stream); 6714 6781 6715 6782
Note: See TracChangeset
for help on using the changeset viewer.