Changeset 3262 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
- Timestamp:
- 01/11/09 01:18:50 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r3259 r3262 146 146 } 147 147 148 BvhInterior::BvhInterior(BvhNode *parent): 149 mBack(NULL), mFront(NULL), BvhNode(parent) 150 {} 151 152 153 bool BvhInterior::IsLeaf() const 154 { 155 return false; 156 } 157 158 159 160 BvhLeaf::BvhLeaf(BvhNode *parent): BvhNode(parent) 161 {} 162 163 164 bool BvhLeaf::IsLeaf() const 165 { 166 return true; 167 } 168 169 148 170 149 171 /**********************************************************/ 150 172 /* class Bvh implementation */ 151 173 /**********************************************************/ 152 153 154 155 inline AxisAlignedBox3 ComputeBoundingBox(SceneEntity **entities, int numEntities)156 {157 AxisAlignedBox3 box;158 159 if (!numEntities)160 { // no box=> just initialize161 box.Initialize();162 }163 else164 {165 box = entities[0]->GetWorldBoundingBox();166 167 for (int i = 1; i < numEntities; ++ i)168 {169 box.Include(entities[i]->GetWorldBoundingBox());170 }171 }172 173 return box;174 }175 174 176 175 … … 1440 1439 leaf->mParent = parent; 1441 1440 1442 front->mBox = ComputeBoundingBox(mGeometry + front->mFirst, front->CountPrimitives());1443 leaf->mBox = ComputeBoundingBox(mGeometry + leaf->mFirst, leaf->CountPrimitives());1441 front->mBox = SceneEntity::ComputeBoundingBox(mGeometry + front->mFirst, front->CountPrimitives()); 1442 leaf->mBox = SceneEntity::ComputeBoundingBox(mGeometry + leaf->mFirst, leaf->CountPrimitives()); 1444 1443 1445 1444 // recursively continue subdivision … … 1468 1467 SceneEntity **entities = GetGeometry(node, numEntities); 1469 1468 1470 node->mBox = ComputeBoundingBox(entities, numEntities);1469 node->mBox = SceneEntity::ComputeBoundingBox(entities, numEntities); 1471 1470 //cout << "box: " << node->mBox << endl; 1472 1471 } … … 1488 1487 { 1489 1488 // the bvh has two main branches 1490 // a static branch (the old root), and a dynamic branch1489 // a static branch (the old root), and a dynamic branch 1491 1490 // we create a 'dynamic' leaf which basically is a container 1492 1491 // for all dynamic objects underneath … … 1501 1500 mDynamicRoot = l; 1502 1501 1503 l->mBox = ComputeBoundingBox(mGeometry + mStaticGeometrySize, (int)mDynamicGeometrySize); 1502 l->mBox = SceneEntity::ComputeBoundingBox(mGeometry + mStaticGeometrySize, 1503 (int)mDynamicGeometrySize); 1504 1504 1505 1505 l->mFirst = (int)mStaticGeometrySize; … … 1510 1510 1511 1511 if (mDynamicGeometrySize) 1512 { 1512 1513 mDynamicRoot = SubdivideLeaf(l, 0); 1514 } 1513 1515 } 1514 1516
Note: See TracChangeset
for help on using the changeset viewer.