Ignore:
Timestamp:
10/24/08 16:39:24 (16 years ago)
Author:
mattausch
Message:

working on dynamic stuff again

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp

    r3066 r3068  
    419419        if (!mDynamicEntities.empty()) 
    420420        { 
    421                 //UpdateDynamicBranch(); 
     421                UpdateDynamicBranch(); 
    422422        } 
    423423} 
     
    427427{ 
    428428        // q: should we use distance to center rather than the distance to the near plane? 
    429          
    430         // because otherwise problems with big object penetrating the near plane  
    431         // (e.g., big objects in the distance which are then always visible) 
    432         // especially annoying is this problem when using the frustum  
    433         // fitting on the visible objects for shadow mapping 
    434         // on the other hand, distance to near plane can also be used  
    435         // for near plane intersection 
    436         node->mDistance = sNearPlane.Distance(node->GetBox().Center()); 
    437         //node->mDistance = node->GetBox().GetMinDistance(sNearPlane); 
     429        // distance to near plane can also be used for checking near plane intersection 
     430        //node->mDistance = sNearPlane.Distance(node->GetBox().Center()); 
     431        node->mDistance = node->GetBox().GetMinDistance(sNearPlane); 
    438432} 
    439433 
     
    441435float Bvh::CalcMaxDistance(BvhNode *node) const 
    442436{ 
     437#if 1 
    443438        return node->GetBox().GetMaxDistance(sNearPlane); 
    444439 
     440#else 
     441        // use bounding boxes of geometry to determine max dist 
    445442        float maxDist = .0f; 
    446443 
     
    457454 
    458455        return maxDist; 
     456#endif 
    459457} 
    460458 
     
    932930 
    933931        mNumVirtualNodes = 0; 
    934  
    935932        // assign new virtual leaves based on specified #triangles per leaf 
    936933        std::stack<BvhNode *> nodeStack; 
    937  
    938934        nodeStack.push(mRoot); 
    939935 
     
    12731269void Bvh::UpdateDynamicBranch() 
    12741270{ 
    1275         BvhNode *dynamicRoot = static_cast<BvhInterior *>(mRoot)->mBack; 
    1276  
    12771271        // delete old branch 
    1278         if (!dynamicRoot->IsLeaf()) 
     1272        if (!mDynamicRoot->IsLeaf()) 
    12791273        { 
    12801274                cout << "deleting old branch" << endl; 
    12811275 
    1282                 DEL_PTR(dynamicRoot); 
    1283  
    1284                 dynamicRoot = new BvhLeaf(mRoot); 
    1285                 dynamicRoot->mBox = mRoot->mBox; 
     1276                DEL_PTR(mDynamicRoot); 
     1277 
     1278                mDynamicRoot = new BvhLeaf(mRoot); 
     1279                mDynamicRoot->mBox = mRoot->mBox; 
     1280 
     1281                mDynamicRoot->mFirst = 0; 
     1282                mDynamicRoot->mLast = 0; 
     1283                mDynamicRoot->mArea = mDynamicRoot->mBox.SurfaceArea(); 
    12861284        } 
    12871285 
    12881286        cout << "updating dynamic branch" << endl; 
    12891287 
    1290         dynamicRoot = SubdivideLeaf(static_cast<BvhLeaf *>(dynamicRoot), 0, mDynamicEntities); 
     1288        mDynamicRoot = SubdivideLeaf(static_cast<BvhLeaf *>(mDynamicRoot), 0, mDynamicEntities); 
    12911289 
    12921290        cout << "finished updating dynamic branch" << endl; 
     
    13021300bool Bvh::IntersectsNearPlane(BvhNode *node) const 
    13031301{  
    1304         float distanceToNearPlane = node->GetBox().GetMinDistance(sNearPlane); 
     1302        // note: we have problems with large scale object penetrating the near plane  
     1303        // (e.g., objects in the distance which are always handled to be visible) 
     1304        // especially annoying is this problem when using the frustum  
     1305        // fitting on the visible objects for shadow mapping 
     1306        // but don't see how to solve this issue without using much costlier calculations 
     1307         
    13051308        // we stored the near plane distance => we can use it also here 
    1306         //float distanceToNearPlane = node->GetDistance(); 
    1307          
    1308         return distanceToNearPlane < sNear; 
    1309 } 
    1310  
    1311  
    1312 } 
     1309        float distanceToNearPlane = node->GetDistance(); 
     1310        //float distanceToNearPlane = node->GetBox().GetMinDistance(sNearPlane); 
     1311         
     1312        return (distanceToNearPlane < sNear); 
     1313} 
     1314 
     1315 
     1316} 
Note: See TracChangeset for help on using the changeset viewer.