Changeset 1577 for GTP/trunk/Lib/Vis
- Timestamp:
- 10/06/06 08:59:09 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1576 r1577 25 25 #define PROBABILIY_IS_BV_VOLUME 1 26 26 #define USE_FIXEDPOINT_T 0 27 #define COUNT_ORIGIN_OBJECTS 0 27 28 28 29 int BvhNode::sMailId = 10000; //2147483647; -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1576 r1577 201 201 { 202 202 const float costDecr = tData.GetRenderCostDecrease(); 203 203 cout << "here44 " << mHierarchyStats.pvsEntries << endl; 204 204 AddSubdivisionStats(mHierarchyStats.Leaves(), 205 205 costDecr, 206 206 mTotalCost, 207 mTotalPvsEntries 207 //mPvsEntries 208 mHierarchyStats.pvsEntries 208 209 ); 209 210 } … … 218 219 << "#Splits\n" << splits << endl 219 220 << "#RenderCostDecrease\n" << renderCostDecr << endl 220 << "#Total PvsEntries\n" << pvsEntries << endl221 << "#TotalEntriesInPvs\n" << pvsEntries << endl 221 222 << "#TotalRenderCost\n" << totalRenderCost << endl; 222 223 } … … 301 302 cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 302 303 303 /*#if _DEBUG304 cout << "view space: " << GetViewSpaceBox() << endl;305 cout << "object space: " << GetObjectSpaceBox() << endl;306 #endif*/307 308 304 mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 309 305 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; … … 517 513 // update stats 518 514 mHierarchyStats.nodes += 2; 519 mHierarchyStats.pvsEntries += mCurrentCandidate->GetPvsEntriesIncr(); 515 const int pvsEntries = mCurrentCandidate->GetPvsEntriesIncr(); 516 mHierarchyStats.pvsEntries += pvsEntries; 517 cout << "pvs entries: " << pvsEntries << " " << mHierarchyStats.pvsEntries << endl; 520 518 mHierarchyStats.memory += 0; // TODO 521 519 // subdivision successful … … 590 588 // reevaluate candidates affected by the split for view space splits, 591 589 // this would be object space splits and other way round 592 if (repairQueue) RepairQueue(); 590 if (repairQueue) 591 { 592 RepairQueue(); 593 } 593 594 } 594 595 -
GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp
r1486 r1577 50 50 map<string, Vector3, ltstr> cht; // hash table for colors 51 51 52 FILE 52 FILE *file; 53 53 char str[80]; 54 Face *face; 55 //Vector3 *vptr; 56 54 Face *face; 55 57 56 float x,y,z; 58 int i;57 //int i; 59 58 60 59 if ((file = fopen(filename.c_str(),"rt")) == NULL) … … 66 65 Environment::GetSingleton()->GetIntValue("Unigraphics.meshGrouping", 67 66 meshGrouping); 68 69 while(fscanf(file,"%s",str)!=EOF) { 70 switch (str[0]) { 71 72 case 'c': 73 if (strcmp(str,"c_rgb")==0) 74 { 75 cout<<"c"; 76 cout.flush(); 77 /* vertex */ 78 fscanf(file,"%s",str); // label 79 fscanf(file,"%f %f %f",&x,&y,&z); 80 81 cht[str] = Vector3(x,y,z); // swap the file coordinates 82 } 83 break; 84 85 86 case 'v': // is it v ? 87 cout<<"."; 88 cout.flush(); 89 /* vertex */ 90 fscanf(file,"%s",str); // label 91 fscanf(file,"%f %f %f",&x,&y,&z); 92 93 vht[str] = Vector3(x,z,-y); // swap the file coordinates 94 // vptr = new Vector3C(x,y,z); // swap the file coordinates 95 break; 96 97 case 'f': { 98 cout<<"+"; 99 vector<Vector3> vertices; 100 VertexIndexContainer vertexIndices; 101 102 /* face */ 103 fscanf(file,"%s",str); // label may be ? 104 if (str[0]!='(') 105 fscanf(file,"%s",str); 106 107 i = 0; // index of the vertex 108 109 110 map<string, Vector3, ltstr>::const_iterator c = vht.find(&str[1]); 111 112 if (c == vht.end()) { 113 cout<<"error reading file : "<< 114 filename<<" ---missing vertex:"<<str<<endl; exit(1); 115 } 116 117 vertices.push_back((*c).second); 118 119 fscanf(file,"%s",str); // get the vertex label 120 121 while(str[0]!=')') { 122 123 c = vht.find(str); 124 125 if (c == vht.end()) 67 68 while(fscanf(file,"%s",str)!=EOF) 69 { 70 switch (str[0]) 126 71 { 127 cout<<"error reading file : "<<filename<<" -- missing vertex\n"; 128 exit(1); } 129 130 vertices.push_back((*c).second); 131 fscanf(file,"%s",str); // get the next vertex label 132 } 133 134 // add vertices to the mesh vertex list 135 int index = (int)currentMesh->mVertices.size(); 136 for (i=0; i < vertices.size(); i++, index++) { 137 currentMesh->mVertices.push_back(vertices[i]); 138 vertexIndices.push_back(index); 139 } 140 141 face = new Face(vertexIndices); 142 143 fscanf(file,"%s",str); // get the next vertex label 144 145 if (str[0]!=';') { 146 c = cht.find(str); 147 if (currentMesh->mMaterial == NULL) { 148 Material *mat = MaterialManager::GetSingleton()->CreateResource(); 149 if (c != cht.end()) { 150 mat->mDiffuseColor = RgbColor((*c).second.x, (*c).second.y, (*c).second.z); 151 currentMesh->mMaterial = mat; 72 case 'c': 73 if (strcmp(str,"c_rgb")==0) 74 { 75 cout<<"c"; 76 cout.flush(); 77 // vertex 78 fscanf(file,"%s",str); // label 79 fscanf(file,"%f %f %f",&x,&y,&z); 80 81 cht[str] = Vector3(x,y,z); // swap the file coordinates 82 } 83 break; 84 85 86 case 'v': // is it v ? 87 cout<<"."; 88 cout.flush(); 89 // vertex 90 fscanf(file,"%s",str); // label 91 fscanf(file,"%f %f %f",&x,&y,&z); 92 93 vht[str] = Vector3(x,z,-y); // swap the file coordinates 94 // vptr = new Vector3C(x,y,z); // swap the file coordinates 95 break; 96 97 case 'f': 98 { 99 cout << "+"; 100 vector<Vector3> vertices; 101 VertexIndexContainer vertexIndices; 102 103 // face 104 fscanf(file,"%s",str); // label may be ? 105 if (str[0]!='(') 106 fscanf(file,"%s",str); 107 108 map<string, Vector3, ltstr>::const_iterator c = vht.find(&str[1]); 109 110 if (c == vht.end()) 111 { 112 cout<<"error reading file : "<< filename 113 <<" ---missing vertex:"<<str<<endl; exit(1); 114 } 115 116 vertices.push_back((*c).second); 117 118 fscanf(file,"%s",str); // get the vertex label 119 120 while(str[0]!=')') 121 { 122 c = vht.find(str); 123 if (c == vht.end()) 124 { 125 cout << "error reading file : " << filename << " -- missing vertex\n"; 126 exit(1); 127 } 128 129 vertices.push_back((*c).second); 130 fscanf(file,"%s",str); // get the next vertex label 131 } 132 133 // add vertices to the mesh vertex list 134 int index = (int)currentMesh->mVertices.size(); 135 136 for (int i=0; i < (int)vertices.size(); ++ i, ++ index) 137 { 138 currentMesh->mVertices.push_back(vertices[i]); 139 vertexIndices.push_back(index); 140 } 141 142 face = new Face(vertexIndices); 143 144 fscanf(file,"%s",str); // get the next vertex label 145 146 if (str[0]!=';') 147 { 148 c = cht.find(str); 149 if (currentMesh->mMaterial == NULL) 150 { 151 Material *mat = MaterialManager::GetSingleton()->CreateResource(); 152 if (c != cht.end()) 153 { 154 mat->mDiffuseColor = RgbColor((*c).second.x, (*c).second.y, (*c).second.z); 155 currentMesh->mMaterial = mat; 156 } 157 else 158 { 159 currentMesh->AssignRandomMaterial(); 160 } 161 } 162 } 163 164 currentMesh->AddFace(face); 165 if (meshGrouping != 0 && currentMesh->mFaces.size() >= meshGrouping) 166 { 167 if (ROTATE_SCENE) 168 { 169 RotateMesh(currentMesh); 170 } 171 172 currentMesh->Preprocess(); 173 // make an instance of this mesh 174 MeshInstance *mi = new MeshInstance(currentMesh); 175 root->mGeometry.push_back(mi); 176 currentMesh = MeshManager::GetSingleton()->CreateResource(); 177 } 178 } 179 break; 180 } /* end face */ 181 182 // get the rest of the line 183 fgets(str,80,file); 184 } 185 186 if (!currentMesh->mVertices.empty()) 187 { 188 if (ROTATE_SCENE) 189 { 190 RotateMesh(currentMesh); 152 191 } 153 else 154 currentMesh->AssignRandomMaterial(); 155 } 156 } 157 158 currentMesh->AddFace(face); 159 if (meshGrouping != 0 && currentMesh->mFaces.size() >= meshGrouping) { 160 if (ROTATE_SCENE) 161 RotateMesh(currentMesh); 162 163 currentMesh->Preprocess(); 164 // make an instance of this mesh 165 MeshInstance *mi = new MeshInstance(currentMesh); 166 root->mGeometry.push_back(mi); 167 currentMesh = MeshManager::GetSingleton()->CreateResource(); 168 } 169 } 170 break; 171 } /* end face */ 172 173 // get the rest of the line 174 fgets(str,80,file); 175 } 176 177 if (currentMesh->mVertices.size()) 178 { 179 if (ROTATE_SCENE) RotateMesh(currentMesh); 180 192 181 193 currentMesh->Preprocess(); 182 194 MeshInstance *mi = new MeshInstance(currentMesh); 183 195 root->mGeometry.push_back(mi); 184 196 } 185 197 186 198 fclose(file); 187 199 return true; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1564 r1577 26 26 #define COUNT_ORIGIN_OBJECTS 1 27 27 28 28 /////////// 29 29 //-- static members 30 30 … … 2004 2004 AddObjToPvs(ray->mTerminationObject, cf, pvsFront, pvsBack, totalPvs); 2005 2005 2006 if (COUNT_ORIGIN_OBJECTS) 2006 if (COUNT_ORIGIN_OBJECTS) 2007 { 2007 2008 AddObjToPvs(ray->mOriginObject, cf, pvsFront, pvsBack, totalPvs); 2009 } 2008 2010 } 2009 2011 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1576 r1577 28 28 29 29 #define USE_FIXEDPOINT_T 0 30 31 30 #define COUNT_ORIGIN_OBJECTS 0 31 32 ///////////// 32 33 //-- static members 33 34 … … 618 619 /////////////// 619 620 //-- create new view cell 621 620 622 VspLeaf *leaf = tData.mNode; 621 623 622 624 VspViewCell *viewCell = new VspViewCell(); 623 625 leaf->SetViewCell(viewCell); … … 643 645 /////////// 644 646 //-- store sampling rays 647 645 648 RayInfoContainer::const_iterator it, it_end = tData.mRays->end(); 646 649 … … 793 796 splitCandidate.mParentData.mMaxCostMisses + 1: 794 797 splitCandidate.mParentData.mMaxCostMisses); 795 798 799 // compute global decrease in render cost 796 800 float oldRenderCost; 797 798 // compute global decrease in render cost799 801 const float renderCostDecr = EvalRenderCostDecrease(splitCandidate.mSplitPlane, 800 802 splitCandidate.mParentData, … … 843 845 844 846 UpdatePvsEntriesContribution(*ray, true, cf, fPvsSize, bPvsSize, oldPvsSize); 847 #if COUNT_ORIGIN_OBJECTS 848 UpdatePvsEntriesContribution(*ray, false, cf, fPvsSize, bPvsSize, oldPvsSize); 849 #endif 845 850 } 846 851 … … 968 973 ViewCellLeaf *vc = leaf->GetViewCell(); 969 974 970 // add contributions from samples to the PVS975 // add contributions from samples to the pvs 971 976 for (it = rays.begin(); it != it_end; ++ it) 972 977 { … … 1040 1045 RayInfoContainer::const_iterator rit, rit_end = rays.end(); 1041 1046 1047 const bool delayMinEvent = false; 1048 1049 //////////// 1042 1050 //-- insert all queries 1043 1051 for (rit = rays.begin(); rit != rit_end; ++ rit) 1044 1052 { 1045 1053 const bool positive = (*rit).mRay->HasPosDir(axis); 1046 const bool delayMinEvent = false; 1047 1054 1048 1055 // origin point 1049 1056 pos = (*rit).ExtrapOrigin(axis); … … 1051 1058 1052 1059 if (delayMinEvent && oType == SortableEntry::ERayMin) 1053 pos += mEpsilon; // for walls1060 pos += mEpsilon; // could be useful feature for walls 1054 1061 1055 1062 mLocalSubdivisionCandidates->push_back(SortableEntry(oType, pos, (*rit).mRay)); … … 1060 1067 1061 1068 if (delayMinEvent && tType == SortableEntry::ERayMin) 1062 pos += mEpsilon; // for walls1069 pos += mEpsilon; // could be useful feature for walls 1063 1070 1064 1071 mLocalSubdivisionCandidates->push_back(SortableEntry(tType, pos, (*rit).mRay)); … … 1491 1498 // with respect to the classification 1492 1499 UpdateContributionsToPvs(*ray, true, cf, pvsFront, pvsBack, totalPvs); 1500 #if COUNT_ORIGIN_OBJECTS 1493 1501 UpdateContributionsToPvs(*ray, false, cf, pvsFront, pvsBack, totalPvs); 1502 #endif 1494 1503 } 1495 1504 … … 1585 1594 1586 1595 return (mCtDivCi + newCost) / oldCost; 1596 } 1597 1598 1599 void VspTree::UpdateContributionsToPvs(Intersectable *obj, 1600 const int cf, 1601 float &frontPvs, 1602 float &backPvs, 1603 float &totalPvs) const 1604 { 1605 if (!obj) return; 1606 1607 //const float renderCost = mViewCellsManager->SimpleRay &raynderCost(obj); 1608 const int renderCost = 1; 1609 1610 // object in no pvs => new 1611 if (!obj->Mailed() && !obj->Mailed(1) && !obj->Mailed(2)) 1612 { 1613 totalPvs += renderCost; 1614 } 1615 1616 // QUESTION matt: is it safe to assume that 1617 // the object belongs to no pvs in this case? 1618 //if (cf == Ray::COINCIDENT) return; 1619 1620 if (cf >= 0) // front pvs 1621 { 1622 if (!obj->Mailed() && !obj->Mailed(2)) 1623 { 1624 frontPvs += renderCost; 1625 1626 // already in back pvs => in both pvss 1627 if (obj->Mailed(1)) 1628 obj->Mail(2); 1629 else 1630 obj->Mail(); 1631 } 1632 } 1633 1634 if (cf <= 0) // back pvs 1635 { 1636 if (!obj->Mailed(1) && !obj->Mailed(2)) 1637 { 1638 backPvs += renderCost; 1639 1640 // already in front pvs => in both pvss 1641 if (obj->Mailed()) 1642 obj->Mail(2); 1643 else 1644 obj->Mail(1); 1645 } 1646 } 1587 1647 } 1588 1648 … … 3045 3105 const bool isTermination, 3046 3106 const int cf, 3047 float & frontPvs,3048 float & backPvs,3107 float &pvsFront, 3108 float &pvsBack, 3049 3109 float &totalPvs) const 3050 3110 { 3051 /*ray.GetSampleData(isTermination, pt, &obj, &node); 3052 if (!obj) return 0; 3111 Intersectable *obj; 3112 Vector3 pt; 3113 KdNode *node; 3114 3115 ray.GetSampleData(isTermination, pt, &obj, &node); 3116 if (!obj) return; 3053 3117 3054 3118 switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) … … 3060 3124 { 3061 3125 BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 3062 UpdateContributionsToPvs(leaf, true,cf, pvsFront, pvsBack, totalPvs, true);3126 UpdateContributionsToPvs(leaf, cf, pvsFront, pvsBack, totalPvs, true); 3063 3127 break; 3064 3128 } 3065 3129 default: 3066 UpdateContributionsToPvs(obj, true, cf, pvsFront, pvsBack, totalPvs, true);3130 UpdateContributionsToPvs(obj, cf, pvsFront, pvsBack, totalPvs); 3067 3131 break; 3068 } */3132 } 3069 3133 } 3070 3134 -
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r1563 r1577 17 17 18 18 19 19 20 namespace GtpVisibilityPreprocessor { 21 20 22 21 23 bool use2dSampling = false;
Note: See TracChangeset
for help on using the changeset viewer.