Changeset 1528 for GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.cpp
- Timestamp:
- 09/28/06 18:51:43 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/VssRay.cpp
r1259 r1528 7 7 int 8 8 VssRay::mailID = 0; 9 10 11 VssRay::VssRay( 12 const Vector3 &origin, 13 const Vector3 &termination, 14 Intersectable *originObject, 15 Intersectable *terminationObject, 16 const int pass, 17 const float pdf 18 ): 19 mMailbox(-1), 20 mOrigin(origin), 21 mTermination(termination), 22 mOriginObject(originObject), 23 mTerminationObject(terminationObject), 24 mRefCount(0), 25 mFlags(0), 26 mPass(pass), 27 mViewCells(0), 28 mWeightedPvsContribution(0), 29 mPdf(pdf), 30 mTerminationNode(NULL), 31 mOriginNode(NULL), 32 mPvsContribution(0) 33 { 34 Precompute(); 35 } 36 37 38 VssRay::VssRay(const Ray &ray): 39 mRefCount(0), 40 mFlags(0), 41 mMailbox(-1), 42 mOriginObject(ray.sourceObject.mObject), 43 mPass(0), 44 mViewCells(0), 45 mPdf(1.0f), 46 mTerminationNode(NULL), 47 mOriginNode(NULL), 48 mPvsContribution(0) 49 { 50 if (ray.sourceObject.mObject) 51 mOrigin = ray.Extrap(ray.sourceObject.mT); 52 else 53 mOrigin = ray.GetLoc(); 54 55 //Debug << "origin: " << mOrigin << endl; 56 if (!ray.intersections.empty()) 57 { 58 mTermination = ray.Extrap(ray.intersections[0].mT); 59 mTerminationObject = ray.intersections[0].mObject; 60 } 61 else 62 { 63 mTermination = ray.Extrap(1e6);//TODO: should be Limits::Infinity 64 mTerminationObject = NULL; 65 } 66 67 Precompute(); 68 } 69 70 71 void VssRay::Precompute() 72 { 73 mFlags = 0; 74 Vector3 dir = GetDir(); 75 76 #define BIDIRECTIONAL_RAY 0 77 #if BIDIRECTIONAL_RAY 78 if (dir.y < 0) { 79 // swap objects and poits 80 swap(mOriginObject, mTerminationObject); 81 swap(mOrigin, mTermination); 82 dir = -dir; 83 } 84 #endif 85 if (dir.x > 0.0f) mFlags |= FPosDirX; 86 if (dir.y > 0.0f) mFlags |= FPosDirY; 87 if (dir.z > 0.0f) mFlags |= FPosDirZ; 88 89 mInvSize = 1.0f/Magnitude(GetDir()); 90 } 9 91 10 92 … … 265 347 266 348 267 void VssRay::GetSampleData(const bool isTermination, 268 Vector3 &pt, 269 Intersectable **obj, 270 KdNode **node) const 271 { 272 if (isTermination) 273 { 274 pt = mTermination; 275 *obj = mTerminationObject; 276 *node = mTerminationNode; 277 } 278 else 279 { 280 pt = mOrigin; 281 *obj = mOriginObject; 282 *node = mOriginNode; 283 } 284 } 285 286 287 } 349 350 }
Note: See TracChangeset
for help on using the changeset viewer.