Changeset 1580 for GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
- Timestamp:
- 10/06/06 21:37:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1577 r1580 174 174 ReadEnvironment(); 175 175 mSubdivisionCandidates = new SortableEntryContainer; 176 for (int i = 0; i < 3; ++ i) 177 mSortedObjects[i] = NULL; 176 178 } 177 179 … … 189 191 DEL_PTR(mSubdivisionCandidates); 190 192 193 for (int i = 0; i < 3; ++ i) 194 { 195 DEL_PTR(mSortedObjects[i]); 196 } 191 197 mSubdivisionStats.close(); 192 198 } … … 1004 1010 { 1005 1011 //-- insert object queries 1006 ObjectContainer *objects = mUseGlobalSorting ? tData.mSortedObjects[axis] : &tData.mNode->mObjects; 1012 ObjectContainer *objects = 1013 mUseGlobalSorting ? tData.mSortedObjects[axis] : &tData.mNode->mObjects; 1007 1014 1008 1015 CreateLocalSubdivisionCandidates(*objects, &mSubdivisionCandidates, !mUseGlobalSorting, axis); … … 1042 1049 1043 1050 if (sort) 1044 { 1051 { // no presorted candidate list 1045 1052 stable_sort((*subdivisionCandidates)->begin(), (*subdivisionCandidates)->end()); 1046 1053 } … … 1154 1161 } 1155 1162 1156 //////////////////////////////////// ////////1163 //////////////////////////////////// 1157 1164 //-- evaluate split cost for all three axis 1158 1165 … … 1179 1186 else 1180 1187 { 1181 //-- use surface area heuristic because view cells not constructed yet 1188 ////////////////// 1189 //-- view cells not constructed yet => use surface area heuristic 1182 1190 nCostRatio[axis] = 1183 1191 EvalSah( … … 1210 1218 } 1211 1219 1212 /////////////////////////////////////1220 //////////////// 1213 1221 //-- assign values 1214 1222 … … 1242 1250 } 1243 1251 1244 if ( 1&& ray->mOriginObject)1252 if (COUNT_ORIGIN_OBJECTS && ray->mOriginObject) 1245 1253 { 1246 1254 ray->mOriginObject->mVssRays.push_back(ray); … … 1298 1306 1299 1307 float BvHierarchy::EvalRenderCost(const ObjectContainer &objects) const 1300 { 1301 if (mHierarchyManager->GetViewSpaceSubdivisionType() == HierarchyManager::NO_VIEWSPACE_SUBDIV) 1302 { 1308 { 1309 if (mHierarchyManager->GetViewSpaceSubdivisionType() == 1310 HierarchyManager::NO_VIEWSPACE_SUBDIV) 1311 { 1312 //////////////// 1313 //-- surface area heuristics 1314 1303 1315 if (objects.empty()) 1304 1316 return 0.0f; 1305 1317 1306 ////////////////1307 //-- surface area heuristics1308 1309 1318 const AxisAlignedBox3 box = EvalBoundingBox(objects); 1310 1319 const float area = box.SurfaceArea(); 1311 1312 return (float)objects.size() * area / mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 1320 const float viewSpaceArea = mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 1321 1322 return (float)objects.size() * area / viewSpaceArea; 1313 1323 } 1314 1324 else … … 1771 1781 if (mUseGlobalSorting) 1772 1782 { 1773 CreateInitialSortedObjectList(oData);1783 AssignInitialSortedObjectList(oData); 1774 1784 } 1775 1785 … … 1793 1803 1794 1804 1795 void BvHierarchy::CreateInitialSortedObjectList(BvhTraversalData &tData) 1796 { 1797 SortableEntryContainer *sortedObjects = new SortableEntryContainer(); 1798 1805 void BvHierarchy::AssignInitialSortedObjectList(BvhTraversalData &tData) 1806 { 1799 1807 // we sort the objects as a preprocess so they don't have 1800 1808 // to be sorted for each split 1801 1809 for (int i = 0; i < 3; ++ i) 1802 1810 { 1803 CreateLocalSubdivisionCandidates(tData.mNode->mObjects, &sortedObjects, true, i); 1804 1811 // create new objects 1812 if (!mSortedObjects[i]) 1813 { 1814 mSortedObjects[i] = new SortableEntryContainer(); 1815 CreateLocalSubdivisionCandidates(tData.mNode->mObjects, &mSortedObjects[i], true, i); 1816 } 1817 1818 // copy list into traversal data list 1805 1819 tData.mSortedObjects[i] = new ObjectContainer(); 1806 tData.mSortedObjects[i]->reserve((int)sortedObjects->size()); 1807 1808 SortableEntryContainer::const_iterator oit, oit_end = sortedObjects->end(); 1809 for (oit = sortedObjects->begin(); oit != oit_end; ++ oit) 1820 tData.mSortedObjects[i]->reserve((int)mSortedObjects[i]->size()); 1821 1822 SortableEntryContainer::const_iterator oit, oit_end = mSortedObjects[i]->end(); 1823 1824 for (oit = mSortedObjects[i]->begin(); oit != oit_end; ++ oit) 1810 1825 { 1811 1826 tData.mSortedObjects[i]->push_back((*oit).mObject); 1812 1827 } 1813 1828 } 1814 1815 delete sortedObjects;1816 1829 } 1817 1830 … … 1885 1898 BvhTraversalData oData(bvhLeaf, 0, prop, nRays); 1886 1899 1900 AssignInitialSortedObjectList(oData); 1901 1902 1887 1903 /////////////////// 1888 1904 //-- add first candidate for object space partition
Note: See TracChangeset
for help on using the changeset viewer.