- Timestamp:
- 01/11/09 13:34:37 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r3266 r3267 504 504 if (mDynamicGeometrySize) 505 505 { 506 Update DynamicBranch(mDynamicRoot);506 UpdateBoundingBoxes(mDynamicRoot); 507 507 UpdateDynamicBounds(state); 508 508 } … … 874 874 cout << "created tighter bounds for " << p << " percent of the nodes" << endl; 875 875 876 // recreate indices used for indirect mode rendering876 // recreate indices used for indirect rendering mode 877 877 if (mIndices) CreateIndices(); 878 878 } … … 956 956 int numVirtualLeaves = 0; 957 957 int numGeometry = 0; 958 cout<<"here3 computing stats"<<endl; 958 959 959 while (!nodeStack.empty()) 960 960 { … … 962 962 nodeStack.pop(); 963 963 964 cout << "x";965 if (node->IsLeaf() && !node->IsVirtualLeaf())966 cerr << "here34"<<endl;967 968 964 if (node->IsVirtualLeaf()) 969 965 { … … 971 967 numGeometry += node->CountPrimitives(); 972 968 973 cout << " l " << numGeometry;974 969 BvhLeaf *leaf = static_cast<BvhLeaf *>(node); 975 970 … … 980 975 else 981 976 { 982 cout << "i";983 984 977 bvhStats.mInteriorSA += node->mBox.SurfaceArea(); 985 978 bvhStats.mInteriorVol += node->mBox.GetVolume(); … … 1090 1083 // assign new virtual leaves based on specified #triangles per leaf 1091 1084 std::stack<BvhNode *> nodeStack; 1092 nodeStack.push(m Root);1093 1094 cout << "here9" << endl; 1085 nodeStack.push(mStaticRoot); 1086 nodeStack.push(mDynamicRoot); 1087 1095 1088 while (!nodeStack.empty()) 1096 1089 { 1097 cout <<"u"<< endl;1098 1090 BvhNode *node = nodeStack.top(); 1099 1091 nodeStack.pop(); … … 1116 1108 (CountTriangles(node) <= numTriangles)) 1117 1109 { 1118 cout << " l " << CountTriangles(node) << " " << node->mIsMaxDepthForVirtualLeaf << endl;1110 //cout << " l " << CountTriangles(node) << " " << node->mIsMaxDepthForVirtualLeaf << endl; 1119 1111 node->mIsVirtualLeaf = true; 1120 1112 } … … 1145 1137 1146 1138 std::stack<BvhNode *> nodeStack; 1147 nodeStack.push(mRoot); 1148 1149 cout << "here7 computing depth" << endl; 1139 1140 nodeStack.push(mStaticRoot); 1141 nodeStack.push(mDynamicRoot); 1142 1150 1143 while (!nodeStack.empty()) 1151 1144 { 1152 1145 BvhNode *node = nodeStack.top(); 1153 1146 nodeStack.pop(); 1154 cout << "z"; 1147 1155 1148 if (node->IsLeaf()) 1156 1149 { … … 1166 1159 if ((f->mFirst == b->mFirst) && (f->mLast == b->mLast)) 1167 1160 { 1168 cout << "f: " << f->mFirst << " " << f->mLast << endl;1169 1161 // point reached where beyond there would be no further reduction 1170 1162 // as both subtrees contain the same objects => stop here … … 1180 1172 } 1181 1173 } 1182 cout << "here7" << endl;1183 1174 } 1184 1175 … … 1205 1196 1206 1197 BvhStats staticBvhStats; 1207 ComputeBvhStats(m Root, staticBvhStats);1198 ComputeBvhStats(mStaticRoot, staticBvhStats); 1208 1199 cout << "\n============ Static BVH statistics =============" << endl; 1209 1200 … … 1404 1395 1405 1396 1406 void Bvh::Update DynamicBranch(BvhNode *node)1397 void Bvh::UpdateBoundingBoxes(BvhNode *node) 1407 1398 { 1408 1399 if (node->IsLeaf()) … … 1419 1410 BvhNode *b = static_cast<BvhInterior *>(node)->GetBack(); 1420 1411 1421 Update DynamicBranch(f);1422 Update DynamicBranch(b);1412 UpdateBoundingBoxes(f); 1413 UpdateBoundingBoxes(b); 1423 1414 1424 1415 node->mBox = f->mBox; … … 1452 1443 } 1453 1444 1454 } 1445 1446 1447 1448 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
r3266 r3267 590 590 void CreateDynamicBranch(); 591 591 592 void Update DynamicBranch(BvhNode *node);592 void UpdateBoundingBoxes(BvhNode *node); 593 593 594 594 inline bool TerminationCriteriaMet(BvhLeaf *leaf) const; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.cpp
r3265 r3267 40 40 41 41 int BvhConstructor::SortTriangles(BvhLeaf *leaf, 42 43 44 42 int axis, 43 float position 44 ) 45 45 { 46 46 int i = leaf->mFirst; … … 69 69 70 70 71 void BvhConstructor::UpdateBoundingBoxes(BvhNode *node) 72 { 73 if (node->IsLeaf()) 74 { 75 int numEntities = node->CountPrimitives(); 76 SceneEntity **entities = mEntities + node->mFirst; 77 78 node->mBox = SceneEntity::ComputeBoundingBox(entities, numEntities); 79 //cout << "box: " << node->mBox << endl; 80 } 81 else 82 { 83 BvhNode *f = static_cast<BvhInterior *>(node)->GetFront(); 84 BvhNode *b = static_cast<BvhInterior *>(node)->GetBack(); 85 86 UpdateBoundingBoxes(f); 87 UpdateBoundingBoxes(b); 88 89 node->mBox = f->mBox; 90 node->mBox.Include(b->mBox); 91 } 92 } 93 94 71 95 int BvhConstructor::SortTrianglesSpatialMedian(BvhLeaf *leaf, 72 96 int axis) … … 84 108 if (TerminationCriteriaMet(leaf)) 85 109 { 86 if (leaf->CountPrimitives() <= 0)87 110 //if (leaf->CountPrimitives() <= 0) 111 //cout << "leaf constructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl; 88 112 return leaf; 89 113 } … … 157 181 { 158 182 BvhNode *root; 159 160 183 mNumNodes = 1; 161 184 … … 168 191 l->mArea = l->mBox.SurfaceArea(); 169 192 170 cout << "constructing bvh "<< endl;193 cout << "constructing bvh from " << l->mFirst << " to " << l->mLast << endl; 171 194 172 195 root = SubdivideLeaf(l, 0); 173 196 197 UpdateBoundingBoxes(root); 198 174 199 numNodes = mNumNodes; 175 200 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhConstructor.h
r3264 r3267 32 32 inline bool TerminationCriteriaMet(BvhLeaf *leaf) const; 33 33 34 void UpdateBoundingBoxes(BvhNode *node); 35 34 36 35 37 ///////////////// -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp
r3266 r3267 142 142 Bvh *bvh = new Bvh(staticEntities, dynamicEntities, maxDepthForTestingChildren); 143 143 144 cout << "here8 " << (int)bvh->mStaticGeometrySize - 1 << endl; 144 145 BvhConstructor bvhConstructor(bvh->mGeometry, 145 146 0, -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3266 r3267 77 77 FrameBufferObject *fbo = NULL; 78 78 /// the renderable scene geometry 79 SceneEntityContainer s ceneEntities;79 SceneEntityContainer staticObjects; 80 80 /// the dynamic objects in the scene 81 81 SceneEntityContainer dynamicObjects; … … 568 568 //-- load the static scene geometry 569 569 570 LoadModel(filename + ".dem", s ceneEntities);570 LoadModel(filename + ".dem", staticObjects); 571 571 572 572 … … 645 645 646 646 BvhFactory bvhFactory; 647 //bvh = bvhFactory.Create(bvh_filename, s ceneEntities, dynamicObjects, maxDepthForTestingChildren);648 bvh = bvhFactory.Create(s ceneEntities, dynamicObjects, maxDepthForTestingChildren);647 //bvh = bvhFactory.Create(bvh_filename, staticObjects, dynamicObjects, maxDepthForTestingChildren); 648 bvh = bvhFactory.Create(staticObjects, dynamicObjects, maxDepthForTestingChildren); 649 649 650 650 if (!bvh) … … 671 671 //-- setup the skydome model 672 672 673 LoadModel("sky.dem", s ceneEntities);674 skyDome = s ceneEntities.back();673 LoadModel("sky.dem", staticObjects); 674 skyDome = staticObjects.back(); 675 675 676 676 /// the turbitity of the sky (from clear to hazy, use <3 for clear sky)
Note: See TracChangeset
for help on using the changeset viewer.