Changeset 1181 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 08/03/06 15:38:53 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
r1144 r1181 57 57 { 58 58 mForcedMaterial.mDiffuseColor.b = 1.0f; 59 const float importance = (float) ospTree.ComputePvsSize(leaf->mObjects) / (float)maxPvs;59 const float importance = (float)leaf->mObjects.size() / (float)maxPvs; 60 60 61 61 mForcedMaterial.mDiffuseColor.r = importance; … … 72 72 return true; 73 73 } 74 74 75 75 76 void Exporter::ExportKdIntersectable(const KdIntersectable &kdObj) -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
r1180 r1181 812 812 813 813 //-- compute pvs 814 frontData.mPvs = ComputePvsSize(*frontData.mRays);815 backData.mPvs = ComputePvsSize(*backData.mRays);814 frontData.mPvs = EvalPvsSize(*frontData.mRays); 815 backData.mPvs = EvalPvsSize(*backData.mRays); 816 816 817 817 // split front and back node geometry and compute area … … 2271 2271 2272 2272 2273 int VspTree:: ComputePvsSize(const RayInfoContainer &rays) const2273 int VspTree::EvalPvsSize(const RayInfoContainer &rays) const 2274 2274 { 2275 2275 int pvsSize = 0; … … 2302 2302 } 2303 2303 } 2304 else 2304 else // compute pvs from kd nodes 2305 2305 { 2306 2306 KdNode::NewMail(); … … 3047 3047 // initialise leaf references of objects 3048 3048 if (parent->IsRoot()) 3049 { 3049 3050 object->mReferences = 1; 3051 } 3050 3052 3051 3053 // remove parent ref … … 3069 3071 3070 3072 mOspStats.objectRefs -= (int)objects.size(); 3071 mOspStats.objectRefs += (int) back.size() + (int)front.size();3073 mOspStats.objectRefs += (int)(back.size() + front.size()); 3072 3074 } 3073 3075 … … 3104 3106 frontData.mDepth = backData.mDepth = tData.mDepth + 1; 3105 3107 3106 // TODO matt: compute pvs3107 frontData.mPvs = 999999; // ComputePvsSize(*frontData.mRays);3108 backData.mPvs = 9999999; //ComputePvsSize(*backData.mRays);3109 3110 frontData.mProbability = frontData.mBoundingBox.GetVolume();3111 3112 3113 3108 //-- subdivide rays 3114 3109 frontData.mRays = new RayInfoContainer(); … … 3139 3134 } 3140 3135 3136 // TODO matt: compute pvs 3137 frontData.mPvs = objectsFront; 3138 backData.mPvs = objectsBack; 3139 3141 3140 KdLeaf *back = new KdLeaf(node, objectsBack); 3142 3141 KdLeaf *front = new KdLeaf(node, objectsFront); … … 3166 3165 ProcessMultipleRefs(back); 3167 3166 3167 frontData.mNode = front; 3168 3168 backData.mNode = back; 3169 frontData.mNode = front; 3169 3170 3171 // compute probability, i.e., volume of seen view cells 3172 frontData.mProbability = EvalViewCellsVolume(front, *frontData.mRays); 3173 backData.mProbability = EvalViewCellsVolume(back, *backData.mRays); 3174 3170 3175 3171 3176 //delete leaf; … … 3446 3451 3447 3452 // HACK: current positition is BETWEEN visibility events 3448 if (1 && (( ci + 1) != ci_end))3453 if (1 && ((*ci).mType == SortableEntry::BOX_INTERSECT) && ((ci + 1) != ci_end)) 3449 3454 currentPos = ((*ci).mPos + (*(ci + 1)).mPos) * 0.5f; 3450 3455 else 3451 3456 currentPos = (*ci).mPos; 3452 3457 3453 if ((totalVol - voll - volr - debugVol) / viewSpaceVol > 0.0001)3458 /*if ((totalVol - voll - volr - debugVol) / viewSpaceVol > 0.0001) 3454 3459 Debug << "front and back volume: " << (totalVol - voll - volr) / viewSpaceVol << " error: " << (totalVol - voll - volr - debugVol) / viewSpaceVol << endl; 3455 /*Debug << "pos: " << currentPos3460 Debug << "pos: " << currentPos 3456 3461 << "\t (pvsl: " << pvsl << ", pvsr: " << pvsr << ")" 3457 3462 << "\t (voll: " << voll << ", volr: " << volr << ")" … … 3961 3966 3962 3967 KdLeaf *leaf = tData.mNode; 3963 int totalPvs = (int)leaf->mObjects.size();3964 3968 const int totalPvs = (int)leaf->mObjects.size(); 3969 3965 3970 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 3966 3971 … … 3973 3978 Intersectable *obj = *oit; 3974 3979 const AxisAlignedBox3 box = obj->GetBox(); 3975 3976 //cout << "totalpvs " << totalPvs << endl;3977 3980 3978 3981 // test if box falls in left / right child node … … 4015 4018 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 4016 4019 4017 // mail view cell 4020 // traverse through view cells and classify them according 4021 // to them being seen from to back / front / front and back node 4018 4022 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 4019 4023 { … … 4024 4028 collectedViewCells.push_back(vc); 4025 4029 4030 // classify / mail the view cell 4026 4031 MailViewCell(*vit, classification); 4027 4032 } … … 4029 4034 } 4030 4035 4036 4037 // evaluate view cells volume contribution with respect to the mail box classification 4031 4038 ViewCellContainer::const_iterator vit, vit_end = collectedViewCells.end(); 4032 4039 4033 // evaluate view cells volume contribution with respect to mail box4034 4040 for (vit = collectedViewCells.begin(); vit != vit_end; ++ vit) 4035 4041 { 4036 4042 AddViewCellVolumeContri(*vit, pFront, pBack, pFrontAndBack); 4037 4043 } 4044 4038 4045 4039 4046 // these are non-overlapping sets 4040 4047 pOverall = pFront + pBack + pFrontAndBack; 4041 4048 4049 4042 4050 //-- pvs rendering heuristics 4051 4043 4052 const float oldRenderCost = pOverall * totalPvs; 4053 4054 // sum up the terms: 4055 // the view cells seeing 4056 // a) the left node are weighted by the #left node objects 4057 // b) the right node are weighted by the #right node objects 4058 // c) both nodes are weighted by the #parent node objects 4044 4059 const float newRenderCost = pvsFront * pFront + pvsBack * pBack + totalPvs * pFrontAndBack; 4045 4060 … … 4050 4065 << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl 4051 4066 << "back p: " << pBack / viewSpaceVol << " front p " << pFront / viewSpaceVol 4052 << " front and back p " << pFrontAndBack / viewSpaceVol << " p: " << pOverall/ viewSpaceVol << endl4067 << " front and back p " << pFrontAndBack / viewSpaceVol << " p: " << tData.mProbability / viewSpaceVol << endl 4053 4068 << "old rc: " << oldRenderCost / viewSpaceVol << " new rc: " << newRenderCost / viewSpaceVol << endl 4054 4069 << "render cost decrease: " << renderCostDecrease << endl; 4070 4071 //if ((((pOverall - tData.mProbability) / viewSpaceVol) > 0.00001)) 4072 // Debug << "ERROR!!"<<endl; 4055 4073 4056 4074 normalizedOldRenderCost = oldRenderCost / viewSpaceVol; 4057 4075 4058 if (oldRenderCost < newRenderCost * 0.99) 4059 Debug << "\nwarning2!!:\n" << "old rc: " << oldRenderCost * viewSpaceVol << " new rc: " << newRenderCost * viewSpaceVol << endl; 4060 4076 4061 4077 return renderCostDecrease; 4062 4078 } … … 4224 4240 dirtyList.push_back(leaf->GetSplitCandidate()); 4225 4241 } 4226 }4227 4228 4229 int OspTree::ComputePvsSize(const ObjectContainer &objects) const4230 {4231 int pvsSize = 0;4232 4233 ObjectContainer::const_iterator oit, oit_end = objects.end();4234 4235 for (oit = objects.begin(); oit != oit_end; ++ oit)4236 {4237 pvsSize += (*oit)->mViewCellPvs.GetSize();4238 }4239 4240 return pvsSize;4241 4242 } 4242 4243 … … 4486 4487 { 4487 4488 if (vc->Mailed()) 4489 { 4488 4490 frontVol += vc->GetVolume(); 4491 } 4489 4492 else if (vc->Mailed(1)) 4493 { 4490 4494 backVol += vc->GetVolume(); 4495 } 4491 4496 else if (vc->Mailed(2)) 4497 { 4492 4498 frontAndBackVol += vc->GetVolume(); 4493 } 4494 4495 4496 float OspTree::EvalViewCellsVolume(const RayInfoContainer &rays) const 4499 } 4500 } 4501 4502 4503 float OspTree::EvalViewCellsVolume(KdLeaf *leaf, const RayInfoContainer &rays) const 4497 4504 { 4498 4505 float vol = 0; … … 4505 4512 VssRay *ray = (*rit).mRay; 4506 4513 4507 if (!ray->mTerminationObject && !ray->mOriginObject) 4514 // process ray if the hit point with termination / origin object 4515 // is inside this kd leaf 4516 if (!((ray->mOriginObject && (GetLeaf(ray->mOrigin, ray->mOriginNode) == leaf)) || 4517 (ray->mTerminationObject && (GetLeaf(ray->mTermination, ray->mTerminationNode) == leaf)))) 4508 4518 continue; 4509 4519 … … 4574 4584 mVspTree.PreprocessRays(sampleRays, rays); 4575 4585 4576 const int pvsSize = mVspTree. ComputePvsSize(rays);4586 const int pvsSize = mVspTree.EvalPvsSize(rays); 4577 4587 4578 4588 Debug << "pvs size: " << (int)pvsSize << endl; … … 4647 4657 mOspTree.mRoot = kdleaf; 4648 4658 4649 // add first candidate for view space partition 4650 4651 // TODO matt: this is something different than pvs size. 4652 const int pvsSize = mOspTree.ComputePvsSize(objects); 4653 const float prop = mOspTree.mBoundingBox.GetVolume(); 4659 const float prop = mOspTree.EvalViewCellsVolume(kdleaf, rays); 4660 4661 //-- add first candidate for view space partition 4654 4662 4655 4663 // first osp traversal data … … 4657 4665 0, 4658 4666 &rays, 4659 pvsSize,4667 (int)objects.size(), 4660 4668 prop, 4661 4669 mOspTree.mBoundingBox); … … 4668 4676 mOspTree.EvalSplitCandidate(*oSplitCandidate); 4669 4677 4670 const float vol = mOspTree.EvalViewCellsVolume(rays); 4671 4672 mOspTree.mTotalCost = (float)objects.size() * vol; 4678 mOspTree.mTotalCost = (float)objects.size() * prop / mVspTree.GetBoundingBox().GetVolume(); 4673 4679 mOspTree.EvalSubdivisionStats(*oSplitCandidate); 4674 4680 … … 4780 4786 4781 4787 mTotalCost -= splitCandidate->GetRenderCostDecrease(); 4788 4782 4789 // cost ratio of cost decrease / totalCost 4783 4790 const float costRatio = splitCandidate->GetRenderCostDecrease() / mTotalCost; … … 4785 4792 if (costRatio < mTermMinGlobalCostRatio) 4786 4793 ++ mGlobalCostMisses; 4787 4788 /* 4789 cout << "nodes: " << ++ numNodes << endl; 4794 4790 4795 Debug << "\n**********" << endl 4791 4796 << "total cost: " << mTotalCost << " render cost decr: " 4792 4797 << splitCandidate->GetRenderCostDecrease() 4793 4798 << " cost ratio: " << costRatio << endl << endl; 4794 */ 4799 4795 4800 //-- subdivide leaf node 4796 4801 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h
r1180 r1181 918 918 float maxBand); 919 919 920 /** Evaluate pvs size associated with the rays. 921 */ 922 int EvalPvsSize(const RayInfoContainer &rays) const; 923 920 924 /** Computes pvs increase with respect to the previous pvs for heuristics. 921 925 */ … … 991 995 float &totalPvs) const; 992 996 993 994 /** Computes PVS size induced by the rays.995 */996 int ComputePvsSize(const RayInfoContainer &rays) const;997 998 997 /** Collects pvs from rays. 999 998 */ … … 1056 1055 /** Rays will be clipped to the bounding box. 1057 1056 */ 1058 void PreprocessRays(const VssRayContainer &sampleRays, 1059 RayInfoContainer &rays); 1057 void PreprocessRays(const VssRayContainer &sampleRays, RayInfoContainer &rays); 1060 1058 1061 1059 /** Evaluate subdivision statistics. … … 1406 1404 1407 1405 1408 /** Compute "pvs size" of this object container1409 @note not really pvs size just weighted sum of object taking their1410 appearances in pvss into account1411 */1412 int ComputePvsSize(const ObjectContainer &objects) const;1413 1414 1406 /** Returns kd leaf the point pt lies in, starting from root. 1415 1407 */ … … 1417 1409 1418 1410 1419 /// pointer to the hierarchy of view cells 1420 ViewCellsTree *mViewCellsTree; 1411 ViewCellsTree *GetViewCellsTree() const { return mViewCellsTree; } 1412 1413 void SetViewCellsTree(ViewCellsTree *vt) { mViewCellsTree = vt; } 1421 1414 1422 1415 … … 1704 1697 float &volRight); 1705 1698 1706 float EvalViewCellsVolume( const RayInfoContainer &rays) const;1699 float EvalViewCellsVolume(KdLeaf *leaf, const RayInfoContainer &rays) const; 1707 1700 1708 1701 1709 1702 protected: 1703 1704 /// pointer to the hierarchy of view cells 1705 ViewCellsTree *mViewCellsTree; 1710 1706 1711 1707 VspTree *mVspTree; -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1154 r1181 179 179 if (preprocessor->mUseGlRenderer || preprocessor->mUseGlDebugger) 180 180 { 181 cout << "here99" << endl;182 181 // create and run the preprocessor application in a parallel thread 183 pt.InitThread(); cout << "here77" << endl;182 pt.InitThread(); 184 183 //pt.RunThread(); 185 184 186 cout << "here51" << endl;187 185 // display the render widget 188 186 DisplayWidget(); … … 193 191 pt.Main(); 194 192 } 195 cout << "here39" << endl;193 196 194 Cleanup(); 197 195
Note: See TracChangeset
for help on using the changeset viewer.