Changeset 1186 for GTP/trunk/Lib/Vis
- Timestamp:
- 08/07/06 18:35:51 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
r1184 r1186 2737 2737 2738 2738 // get classification and receive new t 2739 // --test if start point behind or in front of plane2739 // test if start point behind or in front of plane 2740 2740 const int side = bRay.ComputeRayIntersection(plane.mAxis, plane.mPosition, t); 2741 2741 … … 2911 2911 2912 2912 2913 void VspTree::GetViewCells(const VssRay &ray, ViewCellContainer &viewCells) 2914 { 2913 void VspTree::GetViewCells(VssRay &ray, ViewCellContainer &viewCells) 2914 { 2915 mViewCellsManager->ComputeSampleContribution(ray, false, true); 2916 viewCells = ray.mViewCells; 2917 ray.mViewCells.clear(); 2918 /* 2915 2919 static Ray hray; 2916 2920 hray.Init(ray); … … 2927 2931 2928 2932 // if no precomputation of view cells 2929 CastLineSegment(origin, termination, viewCells); 2930 } 2933 CastLineSegment(origin, termination, viewCells);*/ 2934 } 2935 2931 2936 2932 2937 … … 3123 3128 backData.mRays = new RayInfoContainer(); 3124 3129 3125 SplitRays(splitPlane,3130 /* SplitRays(splitPlane, 3126 3131 *tData.mRays, 3127 3132 *frontData.mRays, 3128 3133 *backData.mRays); 3129 3134 */ 3130 3135 3131 3136 //-- classify objects … … 3150 3155 3151 3156 // TODO matt: compute pvs 3152 frontData.mPvs = objectsFront;3153 backData.mPvs = objectsBack;3157 //frontData.mPvs = objectsFront; 3158 //backData.mPvs = objectsBack; 3154 3159 3155 3160 //CheckViewCellsPvs(leaf, *tData.mRays); … … 3181 3186 3182 3187 SplitObjects(leaf, splitPlane, leaf->mObjects, front->mObjects, back->mObjects); 3188 3189 FilterRays(front, *tData.mRays, *frontData.mRays); 3190 FilterRays(back, *tData.mRays, *backData.mRays); 3183 3191 3184 3192 … … 3273 3281 if (newNode->IsLeaf()) 3274 3282 { 3275 EvaluateLeafStats(tData); 3276 const bool mStoreRays= true; 3283 EvaluateLeafStats(tData); 3284 3285 const bool mStoreRays= true; 3286 3277 3287 //-- store additional info 3278 3288 if (mStoreRays) … … 3366 3376 ++ mCreatedLeaves; 3367 3377 3368 if (data.mPvs > mOspStats.maxPvs)3378 /*if (data.mPvs > mOspStats.maxPvs) 3369 3379 { 3370 3380 mOspStats.maxPvs = data.mPvs; … … 3376 3386 { 3377 3387 mOspStats.minDepth = data.mDepth; 3378 } 3388 }*/ 3379 3389 3380 3390 if (data.mDepth >= mTermMaxDepth) … … 3686 3696 ViewCellContainer viewCells; 3687 3697 3688 mVspTree->GetViewCells( ray, viewCells);3698 mVspTree->GetViewCells(VssRay(ray), viewCells); 3689 3699 3690 3700 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); … … 3798 3808 ViewCellContainer viewCells; 3799 3809 3800 mVspTree->GetViewCells( ray, viewCells);3810 mVspTree->GetViewCells(VssRay(ray), viewCells); 3801 3811 3802 3812 /// classify view cells and compute volume contri accordingly … … 4028 4038 4029 4039 4040 int OspTree::ClassifyRays(const RayInfoContainer &rays, 4041 KdLeaf *leaf, 4042 const AxisAlignedPlane &plane, 4043 RayInfoContainer &frontRays, 4044 RayInfoContainer &backRays) const 4045 { 4046 RayInfoContainer::const_iterator rit, rit_end = rays.end(); 4047 4048 for (rit = rays.begin(); rit < rit_end; ++ rit) 4049 { 4050 VssRay *ray = (*rit).mRay; 4051 4052 bool originGt = false; 4053 bool terminationGt = false; 4054 4055 Intersectable *obj = ray->mOriginObject; 4056 4057 if (obj) 4058 { 4059 originGt = ray->mOrigin[plane.mAxis] > plane.mPosition; 4060 } 4061 4062 obj = ray->mTerminationObject; 4063 4064 if (obj) 4065 { 4066 terminationGt = ray->mTermination[plane.mAxis] > plane.mPosition; 4067 } 4068 4069 // either begin or end point on front side 4070 const bool addToFront = originGt || terminationGt; 4071 4072 // add view cell volume to back volume 4073 const bool addToBack = !originGt || !terminationGt; 4074 4075 // classify ray with respect to the child nodes the view cells contribute 4076 if (addToFront) 4077 frontRays.push_back(*rit); 4078 if (addToBack) 4079 backRays.push_back(*rit); 4080 } 4081 4082 return 0; 4083 } 4084 4085 4086 #if 1 4087 4030 4088 float OspTree::EvalRenderCostDecrease(const AxisAlignedPlane &candidatePlane, 4031 4089 const OspTraversalData &tData, … … 4048 4106 const int totalPvs = (int)leaf->mObjects.size(); 4049 4107 4050 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 4051 4052 // evaluate reverse pvs and view cell volume on left and right cell 4053 // note: should I take all leaf objects or rather the objects hit by rays? 4054 for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 4055 { 4056 int pvsContri = 0; 4057 4058 Intersectable *obj = *oit; 4059 const AxisAlignedBox3 box = obj->GetBox(); 4060 4061 // test if box falls in left / right child node 4062 if (box.Max(candidatePlane.mAxis) >= candidatePlane.mPosition) 4063 { 4064 ++ pvsFront; 4065 obj->Mail(); 4066 } 4067 4068 if (box.Min(candidatePlane.mAxis) < candidatePlane.mPosition) 4069 { 4070 ++ pvsBack; 4071 4072 if (obj->Mailed()) 4073 obj->Mail(2); 4074 else 4075 obj->Mail(1); 4076 } 4077 4078 //Debug << "here3 pt: " << obj << " mail: " << obj->mMailbox - Intersectable::sMailId << endl; 4079 } 4080 4081 4108 RayInfoContainer frontRays, backRays; 4109 ClassifyRays(*tData.mRays, leaf, candidatePlane, frontRays, backRays); 4110 4082 4111 ViewCellContainer touchedViewCells; 4083 RayInfoContainer touchedRays; 4084 4112 4085 4113 // sum up volume seen from the objects of left and right children 4086 4114 // => the volume is the weight for the render cost equation … … 4088 4116 4089 4117 RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end(); 4090 //map<Intersectable *, ViewCellContainer> objectsMap;4091 4118 4092 4119 for (rit = tData.mRays->begin(); rit < rit_end; ++ rit) … … 4100 4127 if (originInside || terminationInside) 4101 4128 { 4102 touchedRays.push_back(*rit);4103 4129 // add volume to volumes of left and / or right children 4104 4130 // if one of the ray end points is inside … … 4124 4150 // classify / mail the view cell 4125 4151 MailViewCell(vc, classification); 4126 4127 /*if (terminationInside)4128 objectsMap[ray->mTerminationObject].push_back(vc);4129 if (originInside)4130 objectsMap[ray->mOriginObject].push_back(vc);*/4131 4152 } 4132 4153 } … … 4154 4175 ViewCellPvsData::NewMail(); 4155 4176 4156 for (rit = t ouchedRays.begin(); rit != touchedRays.end(); ++ rit)4177 for (rit = tData.mRays->begin(); rit != tData.mRays->end(); ++ rit) 4157 4178 { 4158 4179 VssRay *ray = (*rit).mRay; … … 4173 4194 // => the render cost was falsly reduced, add them again 4174 4195 4175 if ( EndPointInsideNode(leaf, *ray, true))4196 if (ray->mTerminationObject) 4176 4197 { 4177 4198 Intersectable *obj = ray->mTerminationObject; … … 4179 4200 const bool renderCostWrong = 4180 4201 ViewCellHasMultipleReferences(obj, viewCell, true); 4181 // if(!obj->Mailed()){ 4182 // Debug << "pt: " << obj << endl; 4183 // Debug << "vc mail: " << viewCell->mMailbox - ViewCell::sMailId << " obj mail: " << obj->mMailbox << " "<< Intersectable::sMailId << " " <<obj->mMailbox - Intersectable::sMailId << endl; 4184 // obj->Mail(); 4185 // } 4202 4186 4203 // if there is already an entry of this object in the view cell pvs 4187 4204 if (renderCostWrong) … … 4189 4206 // view cell was counted only for front or back => correct tjos 4190 4207 if (viewCell->Mailed(1) && obj->Mailed()) 4208 { 4191 4209 additionalFrontRenderCost += viewCell->GetVolume(); 4210 } 4192 4211 else if (viewCell->Mailed() && obj->Mailed(1)) 4212 { 4193 4213 additionalBackRenderCost += viewCell->GetVolume(); 4214 } 4194 4215 } 4195 4216 } 4196 4217 4197 if ( EndPointInsideNode(leaf, *ray, false))4218 if (ray->mOriginObject) 4198 4219 { 4199 4220 Intersectable *obj = ray->mOriginObject; … … 4205 4226 { 4206 4227 if (viewCell->Mailed(1) && obj->Mailed()) 4228 { 4207 4229 additionalFrontRenderCost += viewCell->GetVolume(); 4230 } 4208 4231 else if (viewCell->Mailed() && obj->Mailed(1)) 4232 { 4209 4233 additionalBackRenderCost += viewCell->GetVolume(); 4234 } 4210 4235 } 4211 4236 } … … 4256 4281 } 4257 4282 4283 #else 4284 4285 float OspTree::EvalRenderCostDecrease(const AxisAlignedPlane &candidatePlane, 4286 const OspTraversalData &tData, 4287 float &normalizedOldRenderCost) const 4288 { 4289 float pvsFront = 0; 4290 float pvsBack = 0; 4291 4292 // probability that view point lies in back / front node 4293 float pOverall = 0;//data.mProbability; // todo matt§: value ok? 4294 float pFront = 0; 4295 float pBack = 0; 4296 float pFrontAndBack = 0; 4297 4298 const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 4299 4300 Intersectable::NewMail(3); 4301 4302 KdLeaf *leaf = tData.mNode; 4303 const int totalPvs = (int)leaf->mObjects.size(); 4304 4305 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 4306 4307 // evaluate reverse pvs and view cell volume on left and right cell 4308 // note: should I take all leaf objects or rather the objects hit by rays? 4309 for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 4310 { 4311 int pvsContri = 0; 4312 4313 Intersectable *obj = *oit; 4314 const AxisAlignedBox3 box = obj->GetBox(); 4315 4316 // test if box falls in left / right child node 4317 if (box.Max(candidatePlane.mAxis) >= candidatePlane.mPosition) 4318 { 4319 ++ pvsFront; 4320 obj->Mail(); 4321 } 4322 4323 if (box.Min(candidatePlane.mAxis) < candidatePlane.mPosition) 4324 { 4325 ++ pvsBack; 4326 4327 if (obj->Mailed()) 4328 obj->Mail(2); 4329 else 4330 obj->Mail(1); 4331 } 4332 //Debug << "here3 pt: " << obj << " mail: " << obj->mMailbox - Intersectable::sMailId << endl; 4333 } 4334 4335 4336 ViewCellContainer touchedViewCells; 4337 4338 // sum up volume seen from the objects of left and right children 4339 // => the volume is the weight for the render cost equation 4340 ViewCell::NewMail(3); 4341 4342 RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end(); 4343 //map<Intersectable *, ViewCellContainer> objectsMap; 4344 4345 for (rit = tData.mRays->begin(); rit < rit_end; ++ rit) 4346 { 4347 VssRay *ray = (*rit).mRay; 4348 4349 // add volume to volumes of left and / or right children 4350 // if one of the ray end points is inside 4351 const int classification = ClassifyRay(ray, leaf, candidatePlane); 4352 4353 ViewCellContainer viewCells; 4354 mVspTree->GetViewCells(*ray, viewCells); 4355 4356 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 4357 4358 // traverse through view cells and classify them according 4359 // to them being seen from to back / front / front and back node 4360 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 4361 { 4362 ViewCell *vc = *vit; 4363 4364 // if not previously mailed 4365 if (!vc->Mailed() && !vc->Mailed(1) && !vc->Mailed(2)) 4366 { 4367 touchedViewCells.push_back(vc); 4368 } 4369 4370 // classify / mail the view cell 4371 MailViewCell(vc, classification); 4372 4373 /*if (terminationInside) 4374 objectsMap[ray->mTerminationObject].push_back(vc); 4375 if (originInside) 4376 objectsMap[ray->mOriginObject].push_back(vc);*/ 4377 } 4378 } 4379 4380 // evaluate view cells volume contribution 4381 // with respect to the mail box classification 4382 ViewCellContainer::const_iterator vit, vit_end = touchedViewCells.end(); 4383 4384 for (vit = touchedViewCells.begin(); vit != vit_end; ++ vit) 4385 { 4386 AddViewCellVolumeContri(*vit, pFront, pBack, pFrontAndBack); 4387 } 4388 4389 ////////////////////////////////////////////// 4390 // 4391 // evaluate contribution of objects which are part of other kd nodes 4392 // which are seen by the same view cell 4393 // These contributions cannot be reduced by splitting, because 4394 // the object would still be part of the pvs 4395 4396 float frontRc = 0; 4397 float backRc = 0; 4398 float rc = 0; 4399 4400 ViewCellPvsData::NewMail(); 4401 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 4402 4403 //Debug << "here53 " << touchedViewCells.size() << endl; 4404 for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 4405 { 4406 Intersectable *obj = *oit; 4407 ViewCellContainer::const_iterator vit, vit_end = touchedViewCells.end(); 4408 4409 for (vit = touchedViewCells.begin(); vit != vit_end; ++ vit) 4410 { 4411 ViewCell *vc = *vit; 4412 /*ObjectPvsData *vdata = vc->GetPvs().Find(obj); 4413 4414 if (!vdata) 4415 { 4416 vc->GetPvs().AddSample(obj, 1); 4417 newCost += vc->GetVolume(); 4418 //prop += vc->GetVolume(); 4419 }*/ 4420 4421 ViewCellPvsData *vdata = obj->mViewCellPvs.Find(vc); 4422 4423 if (!vdata || !vdata->Mailed()) 4424 { 4425 newCost += vc->GetVolume(); 4426 if (!vdata) 4427 vdata = obj->mViewCellPvs.AddSample2(vc, 1); 4428 vdata->Mail(); 4429 } 4430 } 4431 } 4432 4433 4434 } 4435 4436 ///////////////////////////// 4437 4438 4439 // these are non-overlapping sets 4440 pOverall = pFront + pBack + pFrontAndBack; 4441 4442 4443 //-- pvs rendering heuristics 4444 4445 const float oldRenderCost = pOverall * totalPvs; 4446 4447 // sum up the terms: 4448 // the view cells seeing 4449 // a) the left node are weighted by the #left node objects 4450 // b) the right node are weighted by the #right node objects 4451 // c) both nodes are weighted by the #parent node objects 4452 const float newRenderCost = pvsFront * pFront + pvsBack * pBack + totalPvs * pFrontAndBack 4453 + additionalFrontRenderCost + additionalBackRenderCost; 4454 4455 // normalize volume with view space volume 4456 const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol; 4457 4458 Debug << "\n(((( eval render cost decrease ))))" << endl 4459 << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl 4460 << "back p: " << pBack / viewSpaceVol << " front p " << pFront / viewSpaceVol 4461 << " front and back p " << pFrontAndBack / viewSpaceVol << " p: " << tData.mProbability / viewSpaceVol << endl 4462 << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl 4463 << "render cost decrease: " << renderCostDecrease << endl 4464 << "additional front " << additionalFrontRenderCost / viewSpaceVol 4465 << " additional back " << additionalBackRenderCost / viewSpaceVol << endl; 4466 4467 if (oldRenderCost < newRenderCost * 0.99) 4468 Debug <<"error!!"<<endl; 4469 4470 //if ((((pOverall - tData.mProbability) / viewSpaceVol) > 0.00001)) 4471 // Debug << "ERROR!!"<<endl; 4472 4473 normalizedOldRenderCost = oldRenderCost / viewSpaceVol; 4474 4475 4476 return renderCostDecrease; 4477 } 4478 #endif 4258 4479 4259 4480 void OspTree::ComputeBoundingBox(const ObjectContainer &objects, … … 4469 4690 4470 4691 4471 void OspTree::PreprocessRays(const VssRayContainer &sampleRays, 4692 void OspTree::PreprocessRays(KdLeaf *root, 4693 const VssRayContainer &sampleRays, 4472 4694 RayInfoContainer &rays) 4473 4695 { 4474 4696 VssRayContainer::const_iterator rit, rit_end = sampleRays.end(); 4697 RayInfoContainer clippedRays; 4475 4698 4476 4699 long startTime = GetTime(); … … 4494 4717 { 4495 4718 float len = ray->Length(); 4496 4497 if (!len) 4719 if (!len) 4498 4720 len = Limits::Small; 4499 4721 4500 rays.push_back(RayInfo(ray, minT / len, maxT / len));4722 clippedRays.push_back(RayInfo(ray, minT / len, maxT / len)); 4501 4723 4502 4724 // HACK: reset nodes for the case we have used object kd tree for … … 4506 4728 } 4507 4729 } 4730 4731 FilterRays(root, clippedRays, rays); 4508 4732 4509 4733 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; … … 4560 4784 } 4561 4785 4786 4787 int OspTree::FilterRays(KdLeaf *leaf, 4788 const RayInfoContainer &rays, 4789 RayInfoContainer &filteredRays) 4790 { 4791 RayInfoContainer::const_iterator rit, rit_end = rays.end(); 4792 4793 for (rit = rays.begin(); rit != rit_end; ++ rit) 4794 { 4795 VssRay *ray = (*rit).mRay; 4796 4797 // test if intersection point with one of the objects is inside this node 4798 const bool originInside = EndPointInsideNode(leaf, *ray, false); 4799 const bool terminationInside = EndPointInsideNode(leaf, *ray, true); 4800 4801 if (originInside || terminationInside) 4802 { 4803 filteredRays.push_back(ray); 4804 } 4805 } 4806 4807 return 0; 4808 } 4809 4562 4810 4563 4811 int OspTree::SplitViewCells(const AxisAlignedPlane &candidatePlane, … … 4990 5238 4991 5239 4992 float OspTree::EvalRenderCost( )5240 float OspTree::EvalRenderCost(const VssRayContainer &myrays) 4993 5241 { 4994 5242 float rc = 0; 4995 float prop = mVspTree->GetBoundingBox().GetVolume(); 5243 float prop = mVspTree->GetBoundingBox().GetVolume(); 5244 4996 5245 KdLeafContainer leaves; 4997 5246 CollectLeaves(leaves); 4998 5247 5248 ViewCellContainer vcleaves; 5249 mVspTree->CollectViewCells(vcleaves, false); 5250 5251 5252 ViewCellContainer::const_iterator vit, vit_end = vcleaves.end(); 5253 5254 for (vit = vcleaves.begin(); vit != vit_end; ++ vit) 5255 { 5256 ViewCell *vc = *vit; 5257 vc->GetPvs().Clear(); 5258 } 5259 4999 5260 KdLeafContainer::const_iterator kit, kit_end = leaves.end(); 5261 5262 ViewCellPvsData::NewMail(); 5263 5000 5264 for (kit = leaves.begin(); kit != kit_end; ++ kit) 5001 5265 { … … 5013 5277 5014 5278 // test if intersection point with one of the objects is inside this node 5279 5015 5280 const bool originInside = EndPointInsideNode(leaf, *ray, false); 5016 5281 const bool terminationInside = EndPointInsideNode(leaf, *ray, true); … … 5031 5296 { 5032 5297 vc->Mail(); 5033 vc->GetPvs().Clear();5034 5298 touchedViewCells.push_back(vc); 5035 5299 } … … 5039 5303 } 5040 5304 5041 //ViewCellPvsData::NewMail();5042 5305 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 5043 5306 5307 //Debug << "here53 " << touchedViewCells.size() << endl; 5044 5308 for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 5045 5309 { … … 5050 5314 { 5051 5315 ViewCell *vc = *vit; 5052 ObjectPvsData *vdata = vc->GetPvs().Find(obj);5316 /*ObjectPvsData *vdata = vc->GetPvs().Find(obj); 5053 5317 5054 5318 if (!vdata) … … 5057 5321 newCost += vc->GetVolume(); 5058 5322 //prop += vc->GetVolume(); 5323 }*/ 5324 5325 ViewCellPvsData *vdata = obj->mViewCellPvs.Find(vc); 5326 5327 if (!vdata || !vdata->Mailed()) 5328 { 5329 newCost += vc->GetVolume(); 5330 if (!vdata) 5331 vdata = obj->mViewCellPvs.AddSample2(vc, 1); 5332 vdata->Mail(); 5059 5333 } 5060 5334 } … … 5068 5342 5069 5343 5070 /********************************************************************/ 5071 /* class HierarchyManager implementation */ 5072 /********************************************************************/ 5344 float OspTree::EvalLeafCost(const OspTraversalData &tData) 5345 { 5346 KdLeaf *leaf = tData.mNode; 5347 5348 float rc = 0; 5349 //float prop = mVspTree->GetBoundingBox().GetVolume(); 5350 //float vol = 0; 5351 //ViewCell::NewMail(); 5352 5353 RayInfoContainer::const_iterator rit, rit_end = tData.mRays->end(); 5354 ViewCellContainer touchedViewCells; 5355 5356 for (rit = tData.mRays->begin(); rit != rit_end; ++ rit) 5357 { 5358 VssRay *ray = (*rit).mRay; 5359 5360 // test if intersection point with one of the objects is inside this node 5361 5362 ViewCellContainer viewCells; 5363 mVspTree->GetViewCells(*ray, viewCells); 5364 5365 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 5366 5367 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 5368 { 5369 ViewCell *vc = *vit; 5370 5371 // if not previously mailed 5372 if (!vc->Mailed()) 5373 { 5374 vc->Mail(); 5375 touchedViewCells.push_back(vc); 5376 } 5377 } 5378 } 5379 5380 // clear pvs of involved view cells 5381 ViewCellContainer::const_iterator vit, vit_end = touchedViewCells.end(); 5382 5383 for (vit = touchedViewCells.begin(); vit != vit_end; ++ vit) 5384 { 5385 ViewCell *vc = *vit; 5386 vc->GetPvs().Clear(); 5387 } 5388 5389 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 5390 5391 //Debug << "here53 " << touchedViewCells.size() << endl; 5392 for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 5393 { 5394 Intersectable *obj = *oit; 5395 5396 for (vit = touchedViewCells.begin(); vit != vit_end; ++ vit) 5397 { 5398 ViewCell *vc = *vit; 5399 ObjectPvsData *vdata = vc->GetPvs().Find(obj); 5400 5401 if (!vdata) 5402 { 5403 vc->GetPvs().AddSample(obj, 1); 5404 rc += vc->GetVolume(); 5405 //prop += vc->GetVolume(); 5406 } 5407 } 5408 } 5409 5410 return rc; 5411 } 5412 5413 5414 5415 /*******************************************************************/ 5416 /* class HierarchyManager implementation */ 5417 /*******************************************************************/ 5073 5418 5074 5419 … … 5178 5523 mGlobalCostMisses = 0; 5179 5524 5180 // get clipped rays5181 mOspTree.PreprocessRays(sampleRays, rays);5182 5183 5525 // create new root 5184 5526 KdLeaf *kdleaf = new KdLeaf(NULL, 0); … … 5186 5528 mOspTree.mRoot = kdleaf; 5187 5529 5530 // get clipped rays 5531 mOspTree.PreprocessRays(kdleaf, sampleRays, rays); 5532 5533 5188 5534 // probabilty is voume of all "seen" view cells 5189 #if 15535 #if 0 5190 5536 const float prop = mOspTree.EvalViewCellsVolume(kdleaf, rays); 5191 5537 #else … … 5436 5782 mOspTree.mOspStats.Stop(); 5437 5783 5438 float rc = mOspTree.EvalRenderCost( );5784 float rc = mOspTree.EvalRenderCost(sampleRays); 5439 5785 5440 5786 Debug << "My render cost evalulation: " << rc << endl; 5441 5787 5442 5443 5444 5445 ViewCellContainer leaves;5446 5447 mVspTree.CollectViewCells(leaves, false);5448 float rc2 = 0;5449 ViewCellContainer::const_iterator vit, vit_end = leaves.end();5450 for (vit = leaves.begin(); vit != vit_end; ++ vit)5451 {5452 ViewCell *vc = *vit;5453 5454 int pvs = vc->GetPvs().CountObjectsInPvs();5455 float vol = vc->GetVolume();5456 rc2 += (float)pvs * vol;5457 5458 }5459 5460 Debug << "here225 " << rc2 / mVspTree.GetBoundingBox().GetVolume()<<endl;5461 5788 #if 0 5462 5789 // reset parameters -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h
r1184 r1186 778 778 or by recomputation. 779 779 */ 780 void GetViewCells( constVssRay &ray, ViewCellContainer &viewCells);780 void GetViewCells(VssRay &ray, ViewCellContainer &viewCells); 781 781 782 782 … … 1124 1124 1125 1125 1126 1127 1126 //-- split heuristics based parameters 1128 1127 … … 1192 1191 AxisAlignedBox3 mBoundingBox; 1193 1192 /// pvs size 1194 int mPvs;1193 float mRenderCost; 1195 1194 /// how often this branch has missed the max-cost ratio 1196 1195 int mMaxCostMisses; … … 1205 1204 mRays(NULL), 1206 1205 mDepth(0), 1207 m Pvs(0),1206 mRenderCost(0), 1208 1207 mProbability(0.0), 1209 1208 mMaxCostMisses(0), … … 1215 1214 const int depth, 1216 1215 RayInfoContainer *rays, 1217 const int pvs,1216 const float rc, 1218 1217 const float p, 1219 1218 const AxisAlignedBox3 &box): … … 1221 1220 mDepth(depth), 1222 1221 mRays(rays), 1223 m Pvs(pvs),1222 mRenderCost(rc), 1224 1223 mProbability(p), 1225 1224 mBoundingBox(box), … … 1235 1234 mDepth(depth), 1236 1235 mRays(rays), 1237 m Pvs(0),1236 mRenderCost(0), 1238 1237 mProbability(0), 1239 1238 mMaxCostMisses(0), … … 1422 1421 void SetViewCellsTree(ViewCellsTree *vt) { mViewCellsTree = vt; } 1423 1422 1424 float EvalRenderCost(); 1423 float EvalRenderCost(const VssRayContainer &myrays); 1424 float EvalLeafCost(const OspTraversalData &tData); 1425 1425 1426 1426 protected: … … 1585 1585 RayInfoContainer &backRays) const; 1586 1586 1587 int FilterRays(KdLeaf *leaf, const RayInfoContainer &rays, RayInfoContainer &filteredRays); 1588 1587 1589 int SplitViewCells( 1588 1590 const AxisAlignedPlane &candidatePlane, … … 1679 1681 /** Rays will be clipped to the bounding box. 1680 1682 */ 1681 void PreprocessRays(const VssRayContainer &sampleRays, 1683 void PreprocessRays( 1684 KdLeaf *root, 1685 const VssRayContainer &sampleRays, 1682 1686 RayInfoContainer &rays); 1683 1687 … … 1729 1733 float &contribution, 1730 1734 bool onlyMailed) const; 1735 1736 int ClassifyRays( 1737 const RayInfoContainer &rays, 1738 KdLeaf *leaf, 1739 const AxisAlignedPlane &plane, 1740 RayInfoContainer &frontRays, 1741 RayInfoContainer &backRays) const; 1731 1742 1732 1743 protected:
Note: See TracChangeset
for help on using the changeset viewer.