Ignore:
Timestamp:
01/01/06 06:25:55 (19 years ago)
Author:
mattausch
Message:

fixed bug in raycasting
added valid view point regions, get view point only from valid regions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp

    r486 r487  
    8585        environment->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 
    8686        environment->GetBoolValue("VspBspTree.PostProcess.useRaysForMerge", mUseRaysForMerge); 
     87        environment->GetIntValue("ViewCells.maxPvs", mMaxPvs); 
     88 
    8789 
    8890        //-- debug output 
     
    400402                BspLeaf *leaf = dynamic_cast<BspLeaf *>(newNode); 
    401403 
     404                if (!CheckValid(tData)) 
     405                { 
     406                        leaf->SetTreeValid(false); 
     407                        PropagateUpValidity(leaf); 
     408                } 
     409 
    402410                // create new view cell for this leaf 
    403411                BspViewCell *viewCell = new BspViewCell(); 
    404412                leaf->SetViewCell(viewCell); 
    405                  
     413         
     414                //-- update pvs 
     415                int conSamp = 0, sampCon = 0; 
     416                AddToPvs(leaf, *tData.mRays, conSamp, sampCon); 
     417 
     418                mStat.contributingSamples += conSamp; 
     419                mStat.sampleContributions += sampCon; 
     420 
     421                //-- store additional info 
    406422                if (mStoreRays) 
    407423                { 
     
    415431                leaf->mArea = tData.mArea; 
    416432 
    417                 //-- update pvs 
    418                 int conSamp = 0, sampCon = 0; 
    419                 AddToPvs(leaf, *tData.mRays, conSamp, sampCon); 
    420          
    421                 mStat.contributingSamples += conSamp; 
    422                 mStat.sampleContributions += sampCon; 
    423  
    424                 EvaluateLeafStats(tData); 
    425         } 
    426  
     433                EvaluateLeafStats(tData);                
     434        } 
    427435 
    428436        //-- cleanup 
     
    431439        return newNode; 
    432440} 
     441 
    433442 
    434443BspNode *VspBspTree::SubdivideNode(VspBspTraversalData &tData, 
     
    519528 
    520529        // replace a link from node's parent 
    521         if (!leaf->IsRoot()) 
     530        if (parent) 
    522531        { 
    523532                parent->ReplaceChildLink(leaf, interior); 
     
    18971906                                if (extSide < 0) 
    18981907                                        node = in->GetBack(); 
    1899                                 else if (extSide > 0) 
     1908                                else  
    19001909                                        node = in->GetFront(); 
    1901  
     1910                                                                 
    19021911                                continue; // no far child 
    19031912                        } 
     
    19081917                        // find intersection of ray segment with plane 
    19091918                        extp = splitPlane.FindIntersection(origin, extp, &t); 
    1910                         //cout << "x"; 
    19111919                }  
    19121920                else 
    19131921                { 
    1914                         //cout << "o"; 
    19151922                        // reached leaf => intersection with view cell 
    19161923                        BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
     
    19371944                } 
    19381945        } 
    1939         //cout << "!!!!!!!!!!!" << endl; 
     1946 
    19401947        return hits; 
    19411948} 
     
    25062513} 
    25072514 
     2515bool VspBspTree::ViewPointValid(const Vector3 &viewPoint) const 
     2516{ 
     2517        BspNode *node = mRoot; 
     2518 
     2519        while (1) 
     2520        { 
     2521                // early exit 
     2522                if (node->TreeValid()) 
     2523                        return true; 
     2524 
     2525                if (node->IsLeaf()) 
     2526                        return false; 
     2527                         
     2528                BspInterior *in = dynamic_cast<BspInterior *>(node); 
     2529                Plane3 splitPlane = in->GetPlane(); 
     2530                         
     2531                if (splitPlane.Side(viewPoint) <= 0)  
     2532                { 
     2533                        node = in->GetBack(); 
     2534                }  
     2535                else 
     2536                { 
     2537                        node = in->GetFront(); 
     2538                } 
     2539        } 
     2540 
     2541        // should never come here 
     2542        return false; 
     2543} 
     2544 
     2545 
     2546bool VspBspTree::CheckValid(const VspBspTraversalData &data) const 
     2547{ 
     2548        return data.mPvs <= mMaxPvs; 
     2549} 
     2550 
     2551 
     2552void VspBspTree::PropagateUpValidity(BspNode *node) 
     2553{ 
     2554        while (!node->IsRoot() && node->TreeValid()) 
     2555        { 
     2556                node = node->GetParent(); 
     2557                node->SetTreeValid(false); 
     2558        } 
     2559} 
     2560 
    25082561 
    25092562/************************************************************************/ 
Note: See TracChangeset for help on using the changeset viewer.