Changeset 3262 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
- Timestamp:
- 01/11/09 01:18:50 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
r3259 r3262 31 31 friend class BvhLoader; 32 32 friend class BvhExporter; 33 friend class mygreaterdistance;33 friend class BvhConstructor; 34 34 35 35 public: … … 236 236 //-- rendering related options 237 237 238 /// the bounding boxes of the test nodes are queries instead of the actualnode238 /// we query the bounding boxes of the test nodes when testing this node 239 239 int mTestNodesIdx; 240 240 /// the number of these test nodes … … 246 246 247 247 248 /////////////////249 //-- public inline functions250 251 252 int BvhNode::GetLastVisitedFrame() const253 {254 return mVisibility[sCurrentState].mLastVisitedFrame;255 }256 257 258 void BvhNode::SetLastVisitedFrame(const int lastVisited)259 {260 mVisibility[sCurrentState].mLastVisitedFrame = lastVisited;261 }262 263 264 bool BvhNode::IsVisible() const265 {266 return mVisibility[sCurrentState].mIsVisible;267 }268 269 270 void BvhNode::SetVisible(bool visible)271 {272 mVisibility[sCurrentState].mIsVisible = visible;273 }274 275 276 void BvhNode::IncTimesTestedInvisible()277 {278 ++ mVisibility[sCurrentState].mTimesInvisible;279 }280 281 282 int BvhNode::GetTimesTestedInvisible() const283 {284 return mVisibility[sCurrentState].mTimesInvisible;285 }286 287 288 void BvhNode::SetTimesTestedInvisible(int t)289 {290 mVisibility[sCurrentState].mTimesInvisible = t;291 }292 293 294 bool BvhNode::IsViewFrustumCulled() const295 {296 return mVisibility[sCurrentState].mIsFrustumCulled;297 }298 299 300 void BvhNode::SetViewFrustumCulled(bool frustumCulled)301 {302 mVisibility[sCurrentState].mIsFrustumCulled = frustumCulled;303 }304 305 306 bool BvhNode::IsNew() const307 {308 return mVisibility[sCurrentState].mIsNew;309 }310 311 312 void BvhNode::SetIsNew(bool isNew)313 {314 mVisibility[sCurrentState].mIsNew = isNew;315 }316 317 318 void BvhNode::SetAssumedVisibleFrameId(int t)319 {320 mVisibility[sCurrentState].mAssumedVisibleFrameId = t;321 }322 323 324 int BvhNode::GetAssumedVisibleFrameId() const325 {326 return mVisibility[sCurrentState].mAssumedVisibleFrameId;327 }328 329 330 int BvhNode::GetLastQueriedFrame() const331 {332 return mVisibility[sCurrentState].mLastQueriedFrame;333 }334 335 336 void BvhNode::SetLastQueriedFrame(int lastTested)337 {338 mVisibility[sCurrentState].mLastQueriedFrame = lastTested;339 }340 341 342 int BvhNode::GetLastRenderedFrame() const343 {344 return mLastRenderedFrame[sCurrentState];345 }346 347 348 void BvhNode::SetLastRenderedFrame(int lastRenderedFrame)349 {350 mLastRenderedFrame[sCurrentState] = lastRenderedFrame;351 }352 353 354 bool BvhNode::Empty() const355 {356 return (mFirst == -1);357 }358 359 360 int BvhNode::CountPrimitives() const361 {362 return mLast - mFirst + 1;363 }364 365 int BvhNode::GetDepth() const366 {367 return mDepth;368 }369 370 371 BvhNode *BvhNode::GetParent()372 {373 return mParent;374 }375 376 377 int BvhNode::GetNumLeaves() const378 {379 return mNumLeaves;380 }381 382 383 bool BvhNode::IsVirtualLeaf() const384 {385 return mIsVirtualLeaf;386 }387 388 389 float BvhNode::GetDistance() const390 {391 return mDistance;392 }393 394 395 const AxisAlignedBox3 &BvhNode::GetBox() const396 {397 return mBox;398 }399 400 401 int BvhNode::GetId() const402 {403 return mId;404 }405 406 407 void BvhNode::SetId(int id)408 {409 mId = id;410 }411 412 413 void BvhNode::SetCurrentState(int _state)414 {415 sCurrentState = _state;416 }417 418 419 248 /** Internal node of the bv hierarchy. 420 249 */ … … 424 253 friend class BvhLoader; 425 254 friend class BvhExporter; 255 friend class BvhConstructor; 426 256 427 257 public: 428 258 429 BvhInterior(BvhNode *parent) : mBack(NULL), mFront(NULL), BvhNode(parent)430 {}431 virtual bool IsLeaf() const { return false; }259 BvhInterior(BvhNode *parent); 260 261 virtual bool IsLeaf() const; 432 262 /** Back child. 433 263 */ 434 inline BvhNode *GetBack() { return mBack; }264 inline BvhNode *GetBack(); 435 265 /** Front child. 436 266 */ 437 inline BvhNode *GetFront() { return mFront; }267 inline BvhNode *GetFront(); 438 268 /** Recursivly delete hierarchy. 439 269 */ … … 448 278 449 279 280 450 281 class BvhLeaf: public BvhNode 451 282 { … … 455 286 public: 456 287 457 BvhLeaf(BvhNode *parent): BvhNode(parent) 458 {} 288 BvhLeaf(BvhNode *parent); 459 289 460 290 ~BvhLeaf(); 461 291 462 virtual bool IsLeaf() const { return true; }292 virtual bool IsLeaf() const; 463 293 }; 464 294 … … 485 315 { 486 316 friend class BvhLoader; 317 friend class BvhConstructor; 487 318 friend class BvhExporter; 488 319 … … 646 477 647 478 //////////// 648 //-- functions influencing the tightness of the bounds that are used for testing479 //-- these functions determine the 'tightness' of the bounds that are used for querying 649 480 650 481 … … 681 512 Sets the static and dynamic objects for the hierarchy. 682 513 */ 683 constBvh(const SceneEntityContainer &staticEntities,684 514 Bvh(const SceneEntityContainer &staticEntities, 515 const SceneEntityContainer &dynamicEntities); 685 516 /** Protected constructor taking scene geometry into account 686 517 Sets the static and dynamic objects for the hierarchy. 687 518 */ 688 constBvh(const SceneEntityContainer &staticEntities,689 690 519 Bvh(const SceneEntityContainer &staticEntities, 520 const SceneEntityContainer &dynamicEntities, 521 int maxDepthForTestingChildren); 691 522 /** Called by the constructor. Initializes important members. 692 523 */ … … 842 673 843 674 844 int Bvh::GetNumNodes() const 675 inline int BvhNode::GetLastVisitedFrame() const 676 { 677 return mVisibility[sCurrentState].mLastVisitedFrame; 678 } 679 680 681 inline void BvhNode::SetLastVisitedFrame(const int lastVisited) 682 { 683 mVisibility[sCurrentState].mLastVisitedFrame = lastVisited; 684 } 685 686 687 inline bool BvhNode::IsVisible() const 688 { 689 return mVisibility[sCurrentState].mIsVisible; 690 } 691 692 693 inline void BvhNode::SetVisible(bool visible) 694 { 695 mVisibility[sCurrentState].mIsVisible = visible; 696 } 697 698 699 inline void BvhNode::IncTimesTestedInvisible() 700 { 701 ++ mVisibility[sCurrentState].mTimesInvisible; 702 } 703 704 705 inline int BvhNode::GetTimesTestedInvisible() const 706 { 707 return mVisibility[sCurrentState].mTimesInvisible; 708 } 709 710 711 inline void BvhNode::SetTimesTestedInvisible(int t) 712 { 713 mVisibility[sCurrentState].mTimesInvisible = t; 714 } 715 716 717 inline bool BvhNode::IsViewFrustumCulled() const 718 { 719 return mVisibility[sCurrentState].mIsFrustumCulled; 720 } 721 722 723 inline void BvhNode::SetViewFrustumCulled(bool frustumCulled) 724 { 725 mVisibility[sCurrentState].mIsFrustumCulled = frustumCulled; 726 } 727 728 729 inline bool BvhNode::IsNew() const 730 { 731 return mVisibility[sCurrentState].mIsNew; 732 } 733 734 735 inline void BvhNode::SetIsNew(bool isNew) 736 { 737 mVisibility[sCurrentState].mIsNew = isNew; 738 } 739 740 741 inline void BvhNode::SetAssumedVisibleFrameId(int t) 742 { 743 mVisibility[sCurrentState].mAssumedVisibleFrameId = t; 744 } 745 746 747 inline int BvhNode::GetAssumedVisibleFrameId() const 748 { 749 return mVisibility[sCurrentState].mAssumedVisibleFrameId; 750 } 751 752 753 inline int BvhNode::GetLastQueriedFrame() const 754 { 755 return mVisibility[sCurrentState].mLastQueriedFrame; 756 } 757 758 759 inline void BvhNode::SetLastQueriedFrame(int lastTested) 760 { 761 mVisibility[sCurrentState].mLastQueriedFrame = lastTested; 762 } 763 764 765 inline int BvhNode::GetLastRenderedFrame() const 766 { 767 return mLastRenderedFrame[sCurrentState]; 768 } 769 770 771 inline void BvhNode::SetLastRenderedFrame(int lastRenderedFrame) 772 { 773 mLastRenderedFrame[sCurrentState] = lastRenderedFrame; 774 } 775 776 777 inline bool BvhNode::Empty() const 778 { 779 return (mFirst == -1); 780 } 781 782 783 inline int BvhNode::CountPrimitives() const 784 { 785 return mLast - mFirst + 1; 786 } 787 788 inline int BvhNode::GetDepth() const 789 { 790 return mDepth; 791 } 792 793 794 inline BvhNode *BvhNode::GetParent() 795 { 796 return mParent; 797 } 798 799 800 inline int BvhNode::GetNumLeaves() const 801 { 802 return mNumLeaves; 803 } 804 805 806 inline bool BvhNode::IsVirtualLeaf() const 807 { 808 return mIsVirtualLeaf; 809 } 810 811 812 inline float BvhNode::GetDistance() const 813 { 814 return mDistance; 815 } 816 817 818 inline const AxisAlignedBox3 &BvhNode::GetBox() const 819 { 820 return mBox; 821 } 822 823 824 inline int BvhNode::GetId() const 825 { 826 return mId; 827 } 828 829 830 inline void BvhNode::SetId(int id) 831 { 832 mId = id; 833 } 834 835 836 inline void BvhNode::SetCurrentState(int _state) 837 { 838 sCurrentState = _state; 839 } 840 841 842 inline BvhNode *BvhInterior::GetBack() 843 { 844 return mBack; 845 } 846 847 848 inline BvhNode *BvhInterior::GetFront() 849 { 850 return mFront; 851 } 852 853 854 inline int Bvh::GetNumNodes() const 845 855 { 846 856 return mNumNodes; … … 848 858 849 859 850 in t Bvh::GetNumLeaves() const860 inline int Bvh::GetNumLeaves() const 851 861 { 852 862 return mNumNodes / 2 + 1; … … 854 864 855 865 856 in t Bvh::GetNumVirtualNodes() const866 inline int Bvh::GetNumVirtualNodes() const 857 867 { 858 868 return mNumVirtualNodes; … … 860 870 861 871 862 in t Bvh::GetNumVirtualLeaves() const872 inline int Bvh::GetNumVirtualLeaves() const 863 873 { 864 874 return mNumVirtualNodes / 2 + 1; … … 866 876 867 877 868 BvhNode *Bvh::GetRoot()878 inline BvhNode *Bvh::GetRoot() 869 879 { 870 880 return mRoot; … … 872 882 873 883 874 BvhNode *Bvh::GetDynamicRoot()884 inline BvhNode *Bvh::GetDynamicRoot() 875 885 { 876 886 return mDynamicRoot; … … 878 888 879 889 880 BvhNode *Bvh::GetStaticRoot()890 inline BvhNode *Bvh::GetStaticRoot() 881 891 { 882 892 return mStaticRoot; … … 884 894 885 895 886 const AxisAlignedBox3 &Bvh::GetBox() const896 inline const AxisAlignedBox3 &Bvh::GetBox() const 887 897 { 888 898 return mBox;
Note: See TracChangeset
for help on using the changeset viewer.