- Timestamp:
- 11/05/05 20:03:25 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VssPreprocessor.cpp
r376 r382 8 8 #include "ViewCell.h" 9 9 #include "VssRay.h" 10 #include "VssTree.h" 10 11 11 12 VssPreprocessor::VssPreprocessor(): … … 48 49 Intersectable *objectA, *objectB; 49 50 Vector3 pointA, pointB; 50 51 float bsize = Magnitude(box.Size()); 51 52 if (mKdTree->CastRay(ray)) { 52 53 objectA = ray.intersections[0].mObject; … … 57 58 float tmin, tmax; 58 59 box.ComputeMinMaxT(ray, &tmin, &tmax); 60 if (tmax > bsize) { 61 cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl; 62 cerr<<"ray"<<ray<<endl; 63 } 59 64 pointA = ray.Extrap(tmax); 65 60 66 } 61 67 … … 69 75 float tmin, tmax; 70 76 box.ComputeMinMaxT(ray, &tmin, &tmax); 77 if (tmax > bsize) { 78 cerr<<"Warning: tmax > box size tmax="<<tmax<<" tmin="<<tmin<<" size="<<bsize<<endl; 79 cerr<<"ray"<<ray<<endl; 80 } 81 71 82 pointB = ray.Extrap(tmax); 72 83 } … … 86 97 87 98 Vector3 88 VssPreprocessor::GetViewpoint() 89 { 90 AxisAlignedBox3 box = mKdTree->GetBox(); 91 99 VssPreprocessor::GetViewpoint(AxisAlignedBox3 *viewSpaceBox) 100 { 101 AxisAlignedBox3 box; 102 103 if (viewSpaceBox) 104 box =*viewSpaceBox; 105 else 106 box = mKdTree->GetBox(); 107 92 108 // shrink the box in the y direction 93 Vector3 diff(0, -box.Size().y*0.4f, 0);94 box.Enlarge(diff);95 96 109 return box.GetRandomPoint(); 97 110 } … … 100 113 VssPreprocessor::GetDirection(const Vector3 &viewpoint) 101 114 { 102 int i = RandomValue(0, mObjects.size() );115 int i = RandomValue(0, mObjects.size()-1); 103 116 Intersectable *object = mObjects[i]; 104 117 Vector3 point, normal; … … 114 127 115 128 mSceneGraph->CollectObjects(&mObjects); 116 117 129 cout<<"#NUM_OBJECTS (Total numner of objects)\n"<<mObjects.size()<<endl; 130 118 131 long startTime = GetTime(); 119 132 … … 121 134 int totalSamples = 0; 122 135 123 136 AxisAlignedBox3 *viewSpaceBox = NULL; 137 138 AxisAlignedBox3 box = mKdTree->GetBox(); 139 box.Enlarge(box.Size()*-Vector3(0.45, 0.45, 0.45)); 140 141 bool useViewSpaceBox = false; 142 if (useViewSpaceBox) 143 viewSpaceBox = &box; 144 124 145 while (totalSamples < mTotalSamples) { 125 146 int passContributingSamples = 0; … … 132 153 133 154 for (int k=0; k < mSamplesPerPass; k++) { 134 135 Vector3 viewpoint = GetViewpoint( );155 156 Vector3 viewpoint = GetViewpoint(viewSpaceBox); 136 157 Vector3 direction = GetDirection(viewpoint); 137 158 138 159 VssRay *vssRay = CastRay(viewpoint, direction); 139 160 … … 153 174 154 175 mPass++; 155 176 156 177 int pvsSize = 0; 157 178 float avgRayContrib = (passContributingSamples > 0) ? … … 176 197 177 198 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 178 cout << "#totalRayStackSize=" << mVssRays.size() << endl; 179 199 cout << "#totalRayStackSize=" << mVssRays.size() << endl <<flush; 200 201 VssTree *vssTree = new VssTree; 202 203 vssTree->Construct(mVssRays, viewSpaceBox); 204 180 205 return true; 181 206 }
Note: See TracChangeset
for help on using the changeset viewer.