Ignore:
Timestamp:
01/11/09 02:43:59 (15 years ago)
Author:
mattausch
Message:

worked on bvh constructor

File:
1 edited

Legend:

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

    r3264 r3265  
    266266 
    267267        mVboId = -1; 
    268         // bound the maximal depth of the dynamic branch 
    269         mMaxDepthForDynamicBranch = 1; 
     268        // bounds the maximal depth of the dynamic branch 
     269        mMaxDepthForDynamicBranch = 10; 
    270270} 
    271271 
     
    13571357    while (1) 
    13581358        { 
    1359                 while (mGeometry[i]->GetWorldCenter()[axis] < position) ++ i; 
    1360                 //while ((j > 0) && (position < mGeometry[j]->GetWorldCenter()[axis])) -- j; 
    1361                 while (position < mGeometry[j]->GetWorldCenter()[axis]) -- j; 
     1359                //while (mGeometry[i]->GetWorldCenter()[axis] < position) ++ i; 
     1360                //while (position < mGeometry[j]->GetWorldCenter()[axis]) -- j; 
     1361 
     1362                while ((i < leaf->mLast) && (mGeometry[i]->GetWorldCenter()[axis] < position)) ++ i; 
     1363                while ((j > leaf->mFirst) && (position < mGeometry[j]->GetWorldCenter()[axis])) -- j; 
    13621364 
    13631365                // sorting finished 
     
    13911393        if (TerminationCriteriaMet(leaf)) 
    13921394        { 
    1393                 //cout << "leaf constructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl; 
     1395                if (leaf->CountPrimitives() == 0) 
     1396                        cout << "error: leaf constructed:" << leaf->mBox << " " << leaf->mFirst << " " << leaf->mLast << endl; 
     1397                 
    13941398                return leaf; 
    13951399        } 
     
    14091413        pos = leaf->mBox.Center()[axis]; 
    14101414         
     1415        //if ((split >= leaf->mLast) || (split < leaf->mFirst)) 
    14111416        if (split == leaf->mLast) 
    14121417        { 
    14131418                // no split could be achieved => just halve number of objects 
    1414                 split = (leaf->mLast - leaf->mFirst) / 2; 
    1415                 cerr << "no reduction " << leaf->CountPrimitives() << " " << leaf->mFirst << " " << leaf->mLast << endl; 
     1419                split = (leaf->mLast + leaf->mFirst) / 2; 
     1420                cerr << "no reduction " << leaf->CountPrimitives() << " " << leaf->mFirst << " " << leaf->mLast << " " << split << endl; 
    14161421        } 
    14171422 
     
    14361441        front->mDepth = leaf->mDepth + 1; 
    14371442 
     1443        if (leaf->mFirst > leaf->mLast) 
     1444                cerr << "erorr!!! " << leaf->CountPrimitives() << " " << leaf->mFirst << " " << leaf->mLast << " " << split << endl; 
     1445 
    14381446        leaf->mLast = split; 
    14391447        leaf->mDepth = front->mDepth; 
     
    14551463        const bool criteriaMet =  
    14561464                (leaf->mDepth > mMaxDepthForDynamicBranch) || 
    1457                 (leaf->CountPrimitives() == 1); 
     1465                (leaf->CountPrimitives() <= 1); 
    14581466 
    14591467        return criteriaMet; 
     
    15011509        -- mNumNodes; 
    15021510 
    1503 #if 0 
     1511#if 1 
    15041512        BvhConstructor bvhConstructor(mGeometry, (int)mStaticGeometrySize, (int)mGeometrySize - 1); 
    15051513 
     
    15101518 
    15111519#else 
     1520 
    15121521        BvhLeaf *l = new BvhLeaf(mRoot); 
    15131522        mDynamicRoot = l; 
Note: See TracChangeset for help on using the changeset viewer.