| 665 | //----------------------------------------------------------------------------- |
| 666 | |
| 667 | void SceneContainer::findObjectList( const Box3F& searchBox, U32 mask, Vector<SceneObject*> *outFound ) |
| 668 | { |
| 669 | PROFILE_SCOPE( Container_FindObjectList_Box ); |
| 670 | |
| 671 | AssertFatal( !mSearchInProgress, "SceneContainer::findObjectList - Container queries are not re-entrant" ); |
| 672 | mSearchInProgress = true; |
| 673 | |
| 674 | // TODO: Optimize for water and zones? |
| 675 | |
| 676 | U32 minX, maxX, minY, maxY; |
| 677 | getBinRange(searchBox.minExtents.x, searchBox.maxExtents.x, minX, maxX); |
| 678 | getBinRange(searchBox.minExtents.y, searchBox.maxExtents.y, minY, maxY); |
| 679 | mCurrSeqKey++; |
| 680 | |
| 681 | for (U32 i = minY; i <= maxY; i++) |
| 682 | { |
| 683 | U32 insertY = i % csmNumBins; |
| 684 | U32 base = insertY * csmNumBins; |
| 685 | for (U32 j = minX; j <= maxX; j++) |
| 686 | { |
| 687 | U32 insertX = j % csmNumBins; |
| 688 | |
| 689 | SceneObjectRef* chain = mBinArray[base + insertX].nextInBin; |
| 690 | while (chain) |
| 691 | { |
| 692 | SceneObject *object = chain->object; |
| 693 | |
| 694 | if (object->getContainerSeqKey() != mCurrSeqKey) |
| 695 | { |
| 696 | object->setContainerSeqKey(mCurrSeqKey); |
| 697 | |
| 698 | if ((object->getTypeMask() & mask) != 0 && |
| 699 | object->isCollisionEnabled()) |
| 700 | { |
| 701 | const Box3F &worldBox = object->getWorldBox(); |
| 702 | if ( object->isGlobalBounds() || worldBox.isOverlapped( searchBox ) ) |
| 703 | { |
| 704 | outFound->push_back( object ); |
| 705 | } |
| 706 | } |
| 707 | } |
| 708 | chain = chain->nextInBin; |
| 709 | } |
| 710 | } |
| 711 | } |
| 712 | |
| 713 | SceneObjectRef* chain = mOverflowBin.nextInBin; |
| 714 | while (chain) |
| 715 | { |
| 716 | SceneObject *object = chain->object; |
| 717 | |
| 718 | if (object->getContainerSeqKey() != mCurrSeqKey) |
| 719 | { |
| 720 | object->setContainerSeqKey(mCurrSeqKey); |
| 721 | |
| 722 | if ((object->getTypeMask() & mask) != 0 && |
| 723 | object->isCollisionEnabled()) |
| 724 | { |
no test coverage detected