Changeset 1997 for GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp
- Timestamp:
- 01/18/07 21:09:55 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Mutation.cpp
r1995 r1997 18 18 #define MUTATION_USE_CDF 0 19 19 #define USE_SILHOUETTE_MUTATIONS 0 20 21 #define USE_SIL_TERMINATION_MUTATION 1 22 20 23 #define EVALUATE_MUTATION_STATS 1 21 24 … … 257 260 258 261 262 Vector3 263 MutationBasedDistribution::ComputeSilhouetteTerminationMutation(const VssRay &ray, 264 const Vector3 &origin, 265 const AxisAlignedBox3 &box, 266 const Vector3 &U, 267 const Vector3 &V, 268 const Vector2 vr2, 269 const float radius 270 ) 271 { 272 const int packetSize = 16; 273 274 static int hit_triangles[packetSize]; 275 static float dist[packetSize]; 276 static Vector3 dirs[packetSize]; 277 // mutate the 278 float alpha = RandomValue(0.0f, 2.0f*M_PI); 279 280 // direction along which we will mutate the ray 281 Vector3 line = sin(alpha)*U + cos(alpha)*V; 282 283 // cout<<line<<endl; 284 // create 16 rays along the selected dir 285 286 // cast rays to find silhouette ray 287 for (int i=0; i < packetSize; i++) { 288 dirs[i] = Normalize(ray.mTermination + ((radius/(packetSize - i))*line) - origin ); 289 mlrtaStoreRayAS16(&origin.x, 290 &dirs[i].x, 291 i); 292 } 293 294 mlrtaTraverseGroupAS16(&box.Min().x, 295 &box.Max().x, 296 hit_triangles, 297 dist); 298 299 for (int i=0; i < packetSize; i++) { 300 if (hit_triangles[i] == -1 || !box.IsInside(origin + dist[i]*dirs[i])) { 301 // break on first passing ray 302 break; 303 } 304 } 305 306 if (i == packetSize) { 307 // cerr<<"Warning: hit the same box here should never happen!"<<endl; 308 // shift the ray even a bit more 309 // cout<<"W"<<i<<endl; 310 return ray.mTermination + (RandomValue(1.0f, 2.0f)*radius)*line; 311 } 312 313 // cout<<i<<endl; 314 return dirs[i]; 315 } 259 316 260 317 … … 385 442 mutationRadius); 386 443 444 #if USE_SIL_TERMINATION_MUTATION 445 termination += ComputeSilhouetteTerminationMutation(*ray, 446 origin, 447 box, 448 U, V, 449 Vector2(rr[2], rr[3]), 450 3.0f*objectRadius); 451 #else 387 452 termination += ComputeTerminationMutation(*ray, U, V, 388 453 Vector2(rr[2], rr[3]), 389 454 mutationRadius); 390 455 #endif 391 456 Vector3 direction = termination - origin; 392 457
Note: See TracChangeset
for help on using the changeset viewer.