Changeset 2707 for GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
- Timestamp:
- 05/24/08 22:40:42 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2703 r2707 25 25 #include "GlobalLinesRenderer.h" 26 26 #include "ObjectsParser.h" 27 #include "SepPlanesBox3.h" 27 28 28 29 … … 1658 1659 /** Object has moved - must dynamically update all affected PVSs */ 1659 1660 void 1660 Preprocessor::ObjectMoved(SceneGraphLeaf * object)1661 Preprocessor::ObjectMoved(SceneGraphLeaf *leaf) 1661 1662 { 1662 1663 // first invalidate all PVS from which this object is visible 1663 1664 ViewCellContainer::const_iterator vit, vit_end = mViewCellsManager->GetViewCells().end(); 1664 1665 AxisAlignedBox3 box = object->GetBox(); 1666 1667 ObjectContainer objects; 1668 1669 if (0) 1670 { 1671 // simplified computation taking only the objects intersecting the box 1672 KdNode::NewMail(); 1673 1674 // first mail all kDObjects which are intersected by the object 1675 preprocessor->mKdTree->CollectKdObjects(box, objects); 1676 1677 } 1678 else 1679 { 1680 ViewCellContainer viewCells; 1681 mViewCellsManager->ComputeBoxIntersections(box, viewCells); 1682 1683 // add object to all viewcells that intersect the bounding box 1684 ObjectPvs pvs; 1685 1686 ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 1687 1688 for (int i = 0; it != it_end; ++ it, ++ i) 1689 { 1690 //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 1691 pvs.MergeInPlace((*it)->GetPvs()); 1692 } 1693 1694 ObjectPvsIterator pit = pvs.GetIterator(); 1695 while (pit.HasMoreEntries()) 1696 { 1697 PvsData pvsData; 1698 Intersectable *object = pit.Next(pvsData); 1699 objects.push_back(object); 1700 } 1701 } 1702 1703 int pvsCounter = 0; 1704 1705 // now search for pvss which contained any mailed node 1706 for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) 1707 { 1708 ObjectPvs &pvs = (*vit)->GetPvs(); 1709 1710 for (int i=0; i < objects.size(); i++) 1711 { 1712 vector<PvsEntry<Intersectable *,PvsData> >::iterator v; 1665 1666 AxisAlignedBox3 box = leaf->GetBox(); 1667 Intersectable *inter = leaf->GetIntersectable(); 1668 int removedEntries = 0; 1669 1670 // now search for pvss which contained any mailed node 1671 for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) { 1672 ObjectPvs &pvs = (*vit)->GetPvs(); 1673 if (Overlap(box, (*vit)->GetBox())) { 1674 pvs.Clear(); 1675 removedEntries += pvs.GetSize(); 1676 } else { 1677 CSeparatingAxisTester shadowVolume; 1678 1679 // cout<<(*vit)->GetBox()<<" "<<box<<endl; 1680 shadowVolume.Init((*vit)->GetBox(), box); 1681 1682 int j = 0; 1683 for (int i=0; i < pvs.mEntries.size(); i++) { 1684 Intersectable *o = pvs.mEntries[i].mObject; 1713 1685 1714 if (pvs.Find(objects[i], v)) { 1715 // clear the pvs 1716 pvs.Clear(); 1717 pvsCounter++; 1718 break; 1719 } 1720 } 1721 } 1722 1723 cout<<"Number of affected objects "<<objects.size()<<endl; 1724 cout<<"Cleared "<<pvsCounter<<" PVSs ("<<mViewCellsManager->GetViewCells().size()/ 1725 (float)pvsCounter*100.0f<<"%) "<<endl; 1726 1686 if (!shadowVolume.TestIsInsideShaft(o->GetBox())) { 1687 if (j != i) 1688 pvs.mEntries[j] = pvs.mEntries[i]; 1689 j++; 1690 } else { 1691 removedEntries++; 1692 } 1693 } 1694 pvs.mLastSorted = 0; 1695 if (j==0) 1696 pvs.mEntries.clear(); 1697 else { 1698 pvs.mEntries.resize(j); 1699 pvs.SimpleSort(); 1700 } 1701 } 1702 } 1703 1704 cerr<<"Number of removed pvs entries = "<<removedEntries<<endl; 1705 // cout<<"Cleared "<<pvsCounter<<" PVSs ("<<mViewCellsManager->GetViewCells().size()/ 1706 // (float)pvsCounter*100.0f<<"%) "<<endl; 1707 1727 1708 } 1728 1709 … … 1745 1726 cout<<"done."<<endl; 1746 1727 1747 c out<<"Updating affected PVSs..."<<endl;1728 cerr<<"Updating affected PVSs..."<<endl; 1748 1729 preprocessor->ObjectMoved(l); 1749 c out<<"done."<<endl;1730 cerr<<"done."<<endl; 1750 1731 } 1751 1732
Note: See TracChangeset
for help on using the changeset viewer.