- Timestamp:
- 10/17/06 12:06:36 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1614 r1632 408 408 } 409 409 410 /*bool Apply(SplitQueue *queue, bool terminationCriteriaMet) 411 { 412 BvhNode *n = sBvHierarchy->Subdivide(splitQueue, this, terminationCriteriaMet); 413 // local or global termination criteria failed 414 return !n->IsLeaf(); 415 }*/ 416 410 417 bool GlobalTerminationCriteriaMet() const 411 418 { -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1627 r1632 119 119 Debug << "min global cost ratio: " << mTermMinGlobalCostRatio << endl; 120 120 Debug << "global cost miss tolerance: " << mTermGlobalCostMissTolerance << endl; 121 Debug << "construction type: " << mConstructionType << endl;122 121 Debug << "min depth for object space subdivision: " << mMinDepthForObjectSpaceSubdivion << endl; 123 122 Debug << "repair queue: " << mRepairQueue << endl; 124 123 Debug << "number of multilevels: " << mNumMultiLevels << endl; 124 125 switch (mConstructionType) 126 { 127 case 0: 128 Debug << "construction type: sequential" << endl; 129 break; 130 case 1: 131 Debug << "construction type: interleaved" << endl; 132 break; 133 case 2: 134 Debug << "construction type: gradient" << endl; 135 break; 136 case 3: 137 Debug << "construction type: multilevel" << endl; 138 break; 139 default: 140 Debug << "construction type " << mConstructionType << " unknown" << endl; 141 break; 142 } 143 125 144 //Debug << "min render cost " << mMinRenderCostDecrease << endl; 126 145 Debug << endl; … … 308 327 SplitQueue viewSpaceQueue; 309 328 310 int maxSteps = 200; // number of initial splits; 329 // number of initial splits 330 int maxSteps = 200; 311 331 float renderCostDecr = 0; 312 332 … … 322 342 // for first round, use sah splits. Once view space partition 323 343 // has started, use render cost heuristics instead 324 SubdivisionCandidate *osc = ResetObjectSpaceSubdivision(sampleRays, objects); 344 SubdivisionCandidate *osc = 345 ResetObjectSpaceSubdivision(sampleRays, objects); 325 346 objectSpaceQueue.Push(osc); 326 347 327 // process object space candidates using 328 // render queue for objects until slope of previous subdivision 329 // is reached 348 // process object space candidates using render queue for 349 // objects until slope of previous subdivision is reached 330 350 SubdivisionCandidateContainer ospContainer; 331 351 332 const int ospSteps = RunConstruction(objectSpaceQueue, ospContainer, renderCostDecr, maxSteps); 352 const int ospSteps = 353 RunConstruction(objectSpaceQueue, ospContainer, renderCostDecr, maxSteps); 333 354 cout << ospSteps << " object space partition steps taken" << endl; 334 355 … … 345 366 346 367 CollectDirtyCandidates(ospContainer, dirtyList); 347 RepairQueue(dirtyList, viewSpaceQueue);368 //RepairQueue(dirtyList, viewSpaceQueue); 348 369 349 370 cout << "finished repairing queue ... " << endl; … … 354 375 // subdivide view space with respect to the objects 355 376 356 SubdivisionCandidate *vsc = ResetViewSpaceSubdivision(sampleRays, objects); 377 SubdivisionCandidate *vsc = 378 ResetViewSpaceSubdivision(sampleRays, objects); 357 379 viewSpaceQueue.Push(vsc); 358 380 359 381 SubdivisionCandidateContainer vspContainer; 360 382 // process view space candidates 361 const int vspSteps = RunConstruction(viewSpaceQueue, vspContainer, renderCostDecr, maxSteps); 362 363 cout << vspSteps << " object space partition steps taken" << endl; 383 const int vspSteps = 384 RunConstruction(viewSpaceQueue, vspContainer, renderCostDecr, maxSteps); 385 386 cout << vspSteps << " view space partition steps taken" << endl; 364 387 365 388 // view space subdivision constructed … … 373 396 374 397 CollectDirtyCandidates(vspContainer, dirtyList); 375 RepairQueue(dirtyList, objectSpaceQueue);398 //RepairQueue(dirtyList, objectSpaceQueue); 376 399 377 400 cout << "finished repairing queue ... " << endl; … … 417 440 mViewSpaceSubdivisionType = NO_VIEWSPACE_SUBDIV; 418 441 419 // start withview space subdivison immediately?442 // start view space subdivison immediately? 420 443 if (StartViewSpaceSubdivision()) 421 444 { 422 445 // prepare vsp tree for traversal 423 446 mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 424 PrepareViewSpaceSubdivision(sampleRays, objects); 447 SubdivisionCandidate *vspSc = 448 PrepareViewSpaceSubdivision(sampleRays, objects); 449 mTQueue.Push(vspSc); 425 450 } 426 451 … … 429 454 { 430 455 mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 431 PrepareObjectSpaceSubdivision(sampleRays, objects); 432 } 433 cout << "****************555555555555555555555555" << endl; 456 SubdivisionCandidate *ospSc = 457 PrepareObjectSpaceSubdivision(sampleRays, objects); 458 mTQueue.Push(ospSc); 459 } 460 434 461 // begin subdivision 435 462 RunConstruction(mRepairQueue, sampleRays, objects, forcedViewSpace); … … 449 476 const ObjectContainer &objects) 450 477 { 451 cout << "\n starting view space hierarchy construction ... " << endl;478 cout << "\npreparing view space hierarchy construction ... " << endl; 452 479 453 480 // hack: reset global cost misses … … 541 568 { 542 569 VspNode *n = mVspTree->Subdivide(splitQueue, sc, terminationCriteriaMet); 543 // check if termination criteria failed 570 571 // check if terminated 544 572 success = !n->IsLeaf(); 545 573 } … … 564 592 break; 565 593 default: 594 cerr << "unknown subdivision type" << endl; 566 595 break; 567 596 } … … 682 711 { 683 712 SubdivisionCandidate *sc = NextSubdivisionCandidate(mTQueue); 684 713 685 714 /////////////////// 686 715 //-- subdivide leaf node … … 698 727 << mMinDepthForObjectSpaceSubdivion << ") " << endl; 699 728 700 PrepareObjectSpaceSubdivision(sampleRays, objects); 729 SubdivisionCandidate *ospSc = PrepareObjectSpaceSubdivision(sampleRays, objects); 730 mTQueue.Push(ospSc); 701 731 702 732 cout << "reseting queue ... "; … … 713 743 << mMinDepthForViewSpaceSubdivion << ") " << endl; 714 744 715 PrepareViewSpaceSubdivision(sampleRays, objects); 745 SubdivisionCandidate *vspSc = PrepareViewSpaceSubdivision(sampleRays, objects); 746 mTQueue.Push(vspSc); 716 747 717 748 cout << "reseting queue ... "; … … 763 794 764 795 const bool repairQueue = false; 765 ApplySubdivisionCandidate(sc, splitQueue, repairQueue); 766 767 chosenCandidates.push_back(sc); 796 bool success = ApplySubdivisionCandidate(sc, splitQueue, repairQueue); 797 798 if (success) 799 { 800 chosenCandidates.push_back(sc); 801 } 768 802 } 769 803 … … 781 815 } 782 816 783 SubdivisionCandidate *firstCandidate = NULL;817 SubdivisionCandidate *firstCandidate; 784 818 785 819 // object space partition constructed => reconstruct … … 791 825 Debug << "old bv hierarchy:\n " << mBvHierarchy->mBvhStats << endl; 792 826 793 SubdivisionCandidate *firstCandidate = 794 mBvHierarchy->Reset(sampleRays, objects); 795 827 firstCandidate = mBvHierarchy->Reset(sampleRays, objects); 828 cout << "here4" << endl; 796 829 mHierarchyStats.mTotalCost = mBvHierarchy->mTotalCost; 797 830 … … 802 835 // evaluate stats before first subdivision 803 836 EvalSubdivisionStats(); 837 cout << "here5" << endl; 804 838 } 805 839 break; … … 807 841 case KD_BASED_OBJ_SUBDIV: 808 842 // TODO 809 break;810 843 default: 811 break; 812 } 813 844 firstCandidate = NULL; 845 break; 846 } 847 cout << "here6" << endl; 814 848 return firstCandidate; 815 849 } -
GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp
r1581 r1632 2178 2178 2179 2179 2180 int nrays = leaf->rays.size();2181 int startIndex = rays.size();2180 int nrays = (int)leaf->rays.size(); 2181 int startIndex = (int)rays.size(); 2182 2182 2183 2183 AxisAlignedBox3 box = GetBBox(leaf); … … 2451 2451 if (leaf->rays[i].mRay->RefCount() != 0) { 2452 2452 cerr<<"Error: refcount!=0, but"<<leaf->rays[i].mRay->RefCount()<<endl; 2453 cerr<<"desired="<<desired<<"i="<<i<<" size="<< leaf->rays.size()<<endl;2453 cerr<<"desired="<<desired<<"i="<<i<<" size="<<(int)leaf->rays.size()<<endl; 2454 2454 exit(1); 2455 2455 } … … 2577 2577 int fixedPerLeaf = 0; 2578 2578 // int fixedPerLeaf = 0; 2579 int fixed = fixedPerLeaf* leaves.size();2579 int fixed = fixedPerLeaf*(int)leaves.size(); 2580 2580 int iGenerated = numberOfRays; 2581 2581 float ratioPerLeaf = iGenerated /(avgContrib*numberOfLeaves); … … 2592 2592 } 2593 2593 2594 return rays.size();2594 return (int)rays.size(); 2595 2595 } 2596 2596 … … 2933 2933 int id = object->GetId()-1; 2934 2934 if (id < 0 || id >= mRoots.size()) { 2935 Debug<<"Error: object Id out of range, Id="<<id<<" roots.size()="<< mRoots.size()<<2935 Debug<<"Error: object Id out of range, Id="<<id<<" roots.size()="<<(int)mRoots.size()<< 2936 2936 endl<<flush; 2937 2937 id = (int)mRoots.size()-1; // $$ last tree is used by all unsigned objects -
GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h
r1576 r1632 22 22 virtual void EvalPriority() = 0; 23 23 virtual int Type() const = 0; 24 //virtual bool Apply() = 0; 24 25 virtual bool GlobalTerminationCriteriaMet() const = 0; 25 26 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r1564 r1632 724 724 725 725 // extract planes of box 726 // TODO: can be done more elegantly than first extracting polygons727 // and take their planes726 // TODO: can be done more elegantly than here 727 // where we first extract polygons, then compute their planes 728 728 for (pit = boxPolys.begin(); pit != pit_end; ++ pit) 729 729 { -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1627 r1632 38 38 // HACK 39 39 const static bool SAMPLE_AFTER_SUBDIVISION = true; 40 const static bool CLAMP_TO_BOX = true;40 const static bool CLAMP_TO_BOX = false; 41 41 42 42 template <typename T> class myless -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1603 r1632 241 241 242 242 int VspBspTree::AddMeshToPolygons(Mesh *mesh, 243 PolygonContainer &polys, 244 MeshInstance *parent) 245 { 246 if (!mesh) 247 return 0; 243 PolygonContainer &polys) const 244 { 245 if (!mesh) return 0; 248 246 249 247 FaceContainer::const_iterator fi; … … 256 254 if (poly->Valid(mEpsilon)) 257 255 { 258 poly->mParent = parent; // set parent intersectable259 256 polys.push_back(poly); 260 257 } … … 269 266 270 267 271 int VspBspTree::AddToPolygonSoup(const ViewCellContainer &viewCells, 272 PolygonContainer &polys, 273 int maxObjects) 274 { 275 const int limit = (maxObjects > 0) ? 276 Min((int)viewCells.size(), maxObjects) : (int)viewCells.size(); 277 278 int polysSize = 0; 279 280 for (int i = 0; i < limit; ++ i) 281 { 282 Mesh *mesh = viewCells[i]->GetMesh(); 283 if (mesh) 284 { // copy the mesh into polygons and add to BSP tree aabb 285 mBoundingBox.Include(viewCells[i]->GetBox()); 286 polysSize += AddMeshToPolygons(mesh, 287 polys, 288 viewCells[i]); 289 } 290 } 291 292 return polysSize; 268 void VspBspTree::ExtractPolygons(Intersectable *object, PolygonContainer &polys) const 269 { 270 // extract the polygons from the intersectables 271 switch (object->Type()) 272 { 273 case Intersectable::MESH_INSTANCE: 274 { 275 Mesh *mesh = dynamic_cast<MeshInstance *>(object)->GetMesh(); 276 AddMeshToPolygons(mesh, polys); 277 } 278 break; 279 case Intersectable::VIEW_CELL: 280 { 281 Mesh *mesh = dynamic_cast<ViewCell *>(object)->GetMesh(); 282 AddMeshToPolygons(mesh, polys); 283 break; 284 } 285 case Intersectable::TRANSFORMED_MESH_INSTANCE: 286 { 287 TransformedMeshInstance *mi = 288 dynamic_cast<TransformedMeshInstance *>(object); 289 290 Mesh mesh; 291 mi->GetTransformedMesh(mesh); 292 AddMeshToPolygons(&mesh, polys); 293 } 294 break; 295 case Intersectable::TRIANGLE_INTERSECTABLE: 296 { 297 TriangleIntersectable *intersect = 298 dynamic_cast<TriangleIntersectable *>(object); 299 300 Polygon3 *poly = new Polygon3(intersect->GetItem()); 301 302 if (poly->Valid(mEpsilon)) 303 { 304 polys.push_back(poly); 305 } 306 else 307 { 308 delete poly; 309 } 310 } 311 break; 312 default: 313 Debug << "intersectable type not supported" << endl; 314 break; 315 } 293 316 } 294 317 … … 304 327 { 305 328 Intersectable *object = objects[i];//*it; 306 Mesh *mesh = NULL; 307 308 switch (object->Type()) // extract the meshes 309 { 310 case Intersectable::MESH_INSTANCE: 311 mesh = dynamic_cast<MeshInstance *>(object)->GetMesh(); 312 AddMeshToPolygons(mesh, polys, NULL); 313 break; 314 case Intersectable::VIEW_CELL: 315 mesh = dynamic_cast<ViewCell *>(object)->GetMesh(); 316 AddMeshToPolygons(mesh, polys, NULL); 317 break; 318 case Intersectable::TRANSFORMED_MESH_INSTANCE: 319 { 320 TransformedMeshInstance *mi = 321 dynamic_cast<TransformedMeshInstance *>(object); 322 323 Mesh mesh; 324 mi->GetTransformedMesh(mesh); 325 AddMeshToPolygons(&mesh, polys, NULL); 326 break; 327 } 328 case Intersectable::TRIANGLE_INTERSECTABLE: 329 { 330 TriangleIntersectable *intersect = 331 dynamic_cast<TriangleIntersectable *>(object); 332 333 Polygon3 *poly = new Polygon3(intersect->GetItem()); 334 335 if (poly->Valid(mEpsilon)) 336 polys.push_back(poly); 337 else 338 delete poly; 339 } 340 default: 341 Debug << "intersectable type not supported" << endl; 342 break; 343 } 329 ExtractPolygons(object, polys); 344 330 345 331 mBoundingBox.Include(object->GetBox()); // add to BSP tree aabb … … 404 390 Intersectable *obj = ray->mTerminationObject; 405 391 406 if ((mBoundingBox.IsInside(ray->mTermination) || !forcedBoundingBox) && 407 obj && !obj->Mailed()) 408 { 409 obj->Mail(); 410 411 // handle intersectable 412 switch (obj->Type()) 413 { 414 case Intersectable::TRANSFORMED_MESH_INSTANCE: 415 { 416 Mesh mesh; 417 418 TransformedMeshInstance *tmobj = 419 dynamic_cast<TransformedMeshInstance *>(obj); 420 421 tmobj->GetTransformedMesh(mesh); 422 AddMeshToPolygons(&mesh, polys, tmobj); 423 } 424 break; 425 426 case Intersectable::MESH_INSTANCE: 427 { 428 MeshInstance *mobj = dynamic_cast<MeshInstance *>(obj); 429 AddMeshToPolygons(mobj->GetMesh(), polys, mobj); 430 } 431 break; 432 433 case Intersectable::TRIANGLE_INTERSECTABLE: 434 { 435 TriangleIntersectable *intersect = 436 dynamic_cast<TriangleIntersectable *>(obj); 437 438 Polygon3 *poly = new Polygon3(intersect->GetItem()); 439 440 if (poly->Valid(mEpsilon)) 441 polys.push_back(poly); 442 else 443 delete poly; 444 } 445 break; 446 447 default: 448 cout << "not implemented yet" << endl; 449 break; 450 } 451 452 ++ numObj; 453 454 ///////// 455 //-- compute bounding box 456 457 if (!forcedBoundingBox) 458 { 459 mBoundingBox.Include(ray->mTermination); 460 } 392 ++ numObj; 393 394 ///////// 395 //-- compute bounding box 396 397 if (!forcedBoundingBox) 398 { 399 mBoundingBox.Include(ray->mTermination); 461 400 } 462 401 … … 466 405 { 467 406 ray->mOriginObject->Mail(); 468 MeshInstance *obj = dynamic_cast<MeshInstance *>(ray->mOriginObject); 469 AddMeshToPolygons(obj->GetMesh(), polys, obj); 470 407 ExtractPolygons(ray->mOriginObject, polys); 408 471 409 ++ numObj; 472 410 } … … 475 413 // throw out unnecessary polygons 476 414 PreprocessPolygons(polys); 477 478 415 cout << "finished" << endl; 479 416 … … 1021 958 ////////////////// 1022 959 //-- terminate traversal and create new view cell 960 1023 961 if (newNode->IsLeaf()) 1024 962 { … … 1035 973 // update scalar pvs size value 1036 974 ObjectPvs &pvs = viewCell->GetPvs(); 1037 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountObjectsInPvs(), pvs.GetSize()); 975 mViewCellsManager->UpdateScalarPvsSize(viewCell, 976 pvs.CountObjectsInPvs(), 977 pvs.GetSize()); 1038 978 1039 979 mBspStats.contributingSamples += conSamp; 1040 mBspStats.sampleContributions += (int)sampCon;980 mBspStats.sampleContributions += (int)sampCon; 1041 981 1042 982 viewCell->mLeaves.push_back(leaf); … … 1044 984 /////////// 1045 985 //-- store additional info 986 1046 987 if (mStoreRays) 1047 988 { -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h
r1563 r1632 538 538 int maxObjects = 0); 539 539 540 /** Extracts the meshes of the view cells and and adds them to polygons. 541 Adds view cell aabb to the aabb of the tree. 542 @param maxPolys the maximal number of objects to be stored as polygons 543 @returns the number of polygons 544 */ 545 int AddToPolygonSoup(const ViewCellContainer &viewCells, 546 PolygonContainer &polys, 547 int maxObjects = 0); 548 549 /** Extract polygons of this mesh and add to polygon container. 540 void ExtractPolygons(Intersectable *obj, PolygonContainer &polys) const; 541 542 /** Extract polygons of this mesh and adds them to container. 550 543 @param mesh the mesh that drives the polygon construction 551 @param parent the parent intersectable this polygon is constructed from552 544 @returns number of polygons 553 545 */ 554 int AddMeshToPolygons(Mesh *mesh, PolygonContainer &polys , MeshInstance *parent);546 int AddMeshToPolygons(Mesh *mesh, PolygonContainer &polys) const; 555 547 556 548 /** Selects an axis aligned for the next split.
Note: See TracChangeset
for help on using the changeset viewer.