Changeset 487 for trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
- Timestamp:
- 01/01/06 06:25:55 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r486 r487 85 85 environment->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 86 86 environment->GetBoolValue("VspBspTree.PostProcess.useRaysForMerge", mUseRaysForMerge); 87 environment->GetIntValue("ViewCells.maxPvs", mMaxPvs); 88 87 89 88 90 //-- debug output … … 400 402 BspLeaf *leaf = dynamic_cast<BspLeaf *>(newNode); 401 403 404 if (!CheckValid(tData)) 405 { 406 leaf->SetTreeValid(false); 407 PropagateUpValidity(leaf); 408 } 409 402 410 // create new view cell for this leaf 403 411 BspViewCell *viewCell = new BspViewCell(); 404 412 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 406 422 if (mStoreRays) 407 423 { … … 415 431 leaf->mArea = tData.mArea; 416 432 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 } 427 435 428 436 //-- cleanup … … 431 439 return newNode; 432 440 } 441 433 442 434 443 BspNode *VspBspTree::SubdivideNode(VspBspTraversalData &tData, … … 519 528 520 529 // replace a link from node's parent 521 if ( !leaf->IsRoot())530 if (parent) 522 531 { 523 532 parent->ReplaceChildLink(leaf, interior); … … 1897 1906 if (extSide < 0) 1898 1907 node = in->GetBack(); 1899 else if (extSide > 0)1908 else 1900 1909 node = in->GetFront(); 1901 1910 1902 1911 continue; // no far child 1903 1912 } … … 1908 1917 // find intersection of ray segment with plane 1909 1918 extp = splitPlane.FindIntersection(origin, extp, &t); 1910 //cout << "x";1911 1919 } 1912 1920 else 1913 1921 { 1914 //cout << "o";1915 1922 // reached leaf => intersection with view cell 1916 1923 BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); … … 1937 1944 } 1938 1945 } 1939 //cout << "!!!!!!!!!!!" << endl; 1946 1940 1947 return hits; 1941 1948 } … … 2506 2513 } 2507 2514 2515 bool 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 2546 bool VspBspTree::CheckValid(const VspBspTraversalData &data) const 2547 { 2548 return data.mPvs <= mMaxPvs; 2549 } 2550 2551 2552 void VspBspTree::PropagateUpValidity(BspNode *node) 2553 { 2554 while (!node->IsRoot() && node->TreeValid()) 2555 { 2556 node = node->GetParent(); 2557 node->SetTreeValid(false); 2558 } 2559 } 2560 2508 2561 2509 2562 /************************************************************************/
Note: See TracChangeset
for help on using the changeset viewer.