Changeset 2187 for GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
- Timestamp:
- 03/05/07 11:07:44 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2183 r2187 32 32 namespace GtpVisibilityPreprocessor { 33 33 34 const static bool ADDITIONAL_GEOMETRY_HACK = false; 35 36 Preprocessor *preprocessor = NULL; 37 38 // HACK: Artificially modify scene to watch rendercost changes 39 static void AddGeometry(SceneGraph *scene) 40 { 41 scene->GetRoot()->UpdateBox(); 42 43 AxisAlignedBox3 sceneBox = scene->GetBox(); 44 45 int n = 200; 46 47 if (0) 48 { 49 // form grid of boxes 50 for (int i = 0; i < n; ++ i) 51 { 52 for (int j = 0; j < n; ++ j) 53 { 54 const Vector3 scale2((float)j * 0.8f / n + 0.1f, 0.05f, (float)i * 0.8f / (float)n + 0.1f); 55 56 const Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 57 58 const Vector3 boxSize = sceneBox.Size() * Vector3(0.0025f, 0.01f, 0.0025f); 59 AxisAlignedBox3 box(pt2, pt2 + boxSize); 60 Mesh *mesh = CreateMeshFromBox(box); 61 62 mesh->Preprocess(); 63 64 MeshInstance *mi = new MeshInstance(mesh); 65 scene->GetRoot()->mGeometry.push_back(mi); 66 } 67 } 68 69 for (int i = 0; i < n; ++ i) 70 { 71 for (int j = 0; j < n; ++ j) 72 { 73 const Vector3 scale2(0.15f, (float)j * 0.8f / n + 0.1f, (float)i * 0.8f / (float)n + 0.1f); 74 75 Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 76 77 Vector3 boxSize = sceneBox.Size() * Vector3(0.0025f, 0.01f, 0.0025f); 78 AxisAlignedBox3 box(pt2, pt2 + boxSize); 79 Mesh *mesh = CreateMeshFromBox(box); 80 81 mesh->Preprocess(); 82 83 MeshInstance *mi = new MeshInstance(mesh); 84 scene->GetRoot()->mGeometry.push_back(mi); 85 } 86 } 87 88 for (int i = 0; i < n; ++ i) 89 { 90 const Vector3 scale2(2, 0.2f, (float)i * 0.8f / (float)n + 0.1f); 91 92 Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 93 Vector3 boxSize = sceneBox.Size() * Vector3(0.005f, 0.02f, 0.005f); 94 95 AxisAlignedBox3 box(pt2 + 0.1f, pt2 + boxSize); 96 Mesh *mesh = CreateMeshFromBox(box); 97 98 mesh->Preprocess(); 99 100 MeshInstance *mi = new MeshInstance(mesh); 101 scene->GetRoot()->mGeometry.push_back(mi); 102 } 103 104 scene->GetRoot()->UpdateBox(); 105 } 106 107 if (1) 108 { 109 // plane separating view space regions 110 const Vector3 scale(1.0f, 0.0, 0); 111 112 Vector3 pt = sceneBox.Min() + scale * (sceneBox.Max() - sceneBox.Min()); 113 114 Plane3 cuttingPlane(Vector3(1, 0, 0), pt); 115 Mesh *planeMesh = new Mesh(); 116 117 Polygon3 *poly = sceneBox.CrossSection(cuttingPlane); 118 IncludePolyInMesh(*poly, *planeMesh); 119 120 planeMesh->Preprocess(); 121 122 MeshInstance *planeMi = new MeshInstance(planeMesh); 123 scene->GetRoot()->mGeometry.push_back(planeMi); 124 } 125 } 126 34 35 Preprocessor *preprocessor = NULL; 36 127 37 128 38 Preprocessor::Preprocessor(): … … 599 509 if (result) 600 510 { 601 // HACK602 if (ADDITIONAL_GEOMETRY_HACK)603 AddGeometry(mSceneGraph);604 511 605 512 mSceneGraph->AssignObjectIds(); … … 1228 1135 Environment::GetSingleton()->GetBoolValue("ViewCells.loadFromFile", loadViewCells); 1229 1136 1230 int reserveRays; 1137 int reserveRays; 1138 int constructionSamples; 1231 1139 1232 1140 if (!loadViewCells) 1233 1141 { 1234 cout << "setting ray pool size to view cell construction ize" << endl; 1142 cout << "hack: setting ray pool size to view cell construction or evaluation size" << endl; 1143 1144 constructionSamples = 1000000; 1235 1145 1236 1146 char buf[100]; 1237 1147 Environment::GetSingleton()->GetStringValue("ViewCells.type", buf); 1238 1148 1239 1149 if (strcmp(buf, "vspBspTree") == 0) 1240 1150 { 1241 Environment::GetSingleton()->GetIntValue("VspBspTree.Construction.samples", reserveRays);1242 reserveRays *= 2;1151 Environment::GetSingleton()->GetIntValue("VspBspTree.Construction.samples", constructionSamples); 1152 1243 1153 } 1244 1154 else if (strcmp(buf, "vspOspTree") == 0) 1245 1155 { 1246 Environment::GetSingleton()->GetIntValue("Hierarchy.Construction.samples", reserveRays); 1247 reserveRays *= 2; 1248 } 1156 Environment::GetSingleton()->GetIntValue("Hierarchy.Construction.samples", constructionSamples); 1157 } 1158 1159 int evalSamplesPerPass; 1160 1161 Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samplesPerPass", evalSamplesPerPass); 1162 1163 reserveRays = max(constructionSamples, evalSamplesPerPass); 1164 reserveRays *= 2; 1249 1165 } 1250 1166 else 1251 1167 { 1252 cout << "setting ray pool size to samples per pass" << endl; 1253 1168 cout << "setting ray pool size to samples per pass" << endl; 1254 1169 reserveRays = mSamplesPerPass * 2; 1255 1170 } … … 1274 1189 const long t1 = GetTime(); 1275 1190 1276 if ((int)rays.size() > 10000) { 1191 if (1 && (rays.size() > 10000)) 1192 { 1277 1193 1278 1194 mRayCaster->SortRays(rays); … … 1298 1214 1299 1215 if (mUseHwGlobalLines) 1216 { 1300 1217 CastRaysWithHwGlobalLines( 1301 1218 rays, … … 1304 1221 pruneInvalidRays 1305 1222 ); 1223 } 1306 1224 else 1225 { 1307 1226 mRayCaster->CastRays( 1308 1227 rays, … … 1311 1230 castDoubleRays, 1312 1231 pruneInvalidRays); 1313 1314 if ((int)rays.size() > 10000) 1232 } 1233 1234 if (rays.size() > 10000) 1315 1235 { 1316 1236 cout << endl; … … 1328 1248 } 1329 1249 1330 1331 1250 1332 1251 void 1333 1252 Preprocessor::CastRaysWithHwGlobalLines( 1334 1253 SimpleRayContainer &rays, 1335 VssRayContainer &vssRays, 1336 const bool castDoubleRays, 1337 const bool pruneInvalidRays 1338 ) 1254 VssRayContainer &vssRays, 1255 const bool castDoubleRays, 1256 const bool pruneInvalidRays) 1339 1257 { 1340 1258 SimpleRayContainer::const_iterator rit, rit_end = rays.end(); … … 1352 1270 } 1353 1271 #endif 1354 1355 1356 1357 if ((int)rayBucket.size() >= 16)1358 { 1359 1360 1361 1362 1363 1364 1365 1366 1367 } 1368 1369 if ( (int)rays.size() > 100000 && i % 100000 == 0)1272 rayBucket.push_back(ray); 1273 1274 // 16 rays gathered => do ray casting 1275 if (rayBucket.size() >= 16) 1276 { 1277 mRayCaster->CastRays16( 1278 rayBucket, 1279 vssRays, 1280 mViewCellsManager->GetViewSpaceBox(), 1281 castDoubleRays, 1282 pruneInvalidRays); 1283 1284 rayBucket.clear(); 1285 } 1286 1287 if (rays.size() > 100000 && i % 100000 == 0) 1370 1288 cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r"; 1371 1289 }
Note: See TracChangeset
for help on using the changeset viewer.