| 709 | //----------------------------------------------------------------------------- |
| 710 | |
| 711 | U32 SceneCullingState::cullObjects( SceneObject** objects, U32 numObjects, U32 cullOptions ) const |
| 712 | { |
| 713 | PROFILE_SCOPE( SceneCullingState_cullObjects ); |
| 714 | |
| 715 | U32 numRemainingObjects = 0; |
| 716 | |
| 717 | // We test near and far planes separately in order to not do the tests |
| 718 | // repeatedly, so fetch the planes now. |
| 719 | const PlaneF& nearPlane = getCullingFrustum().getPlanes()[ Frustum::PlaneNear ]; |
| 720 | const PlaneF& farPlane = getCullingFrustum().getPlanes()[ Frustum::PlaneFar ]; |
| 721 | |
| 722 | for( U32 i = 0; i < numObjects; ++ i ) |
| 723 | { |
| 724 | SceneObject* object = objects[ i ]; |
| 725 | bool isCulled = true; |
| 726 | |
| 727 | // If we should respect editor overrides, test that now. |
| 728 | |
| 729 | if( !( cullOptions & CullEditorOverrides ) && |
| 730 | gEditingMission && |
| 731 | ( ( object->isCullingDisabledInEditor() && object->isRenderEnabled() ) || object->isSelected() ) ) |
| 732 | { |
| 733 | isCulled = false; |
| 734 | } |
| 735 | |
| 736 | // If the object is render-disabled, it gets culled. The only |
| 737 | // way around this is the editor override above. |
| 738 | |
| 739 | else if( !( cullOptions & DontCullRenderDisabled ) && |
| 740 | !object->isRenderEnabled() ) |
| 741 | { |
| 742 | isCulled = true; |
| 743 | } |
| 744 | |
| 745 | // Global bounds objects are never culled. Note that this means |
| 746 | // that if these objects are to respect zoning, they need to manually |
| 747 | // trigger the respective culling checks for whatever they want to |
| 748 | // batch. |
| 749 | |
| 750 | else if( object->isGlobalBounds() ) |
| 751 | isCulled = false; |
| 752 | |
| 753 | // If terrain occlusion checks are enabled, run them now. |
| 754 | |
| 755 | else if( !mDisableTerrainOcclusion && |
| 756 | object->getWorldBox().minExtents.x > -1e5 && |
| 757 | isOccludedByTerrain( object ) ) |
| 758 | { |
| 759 | // Occluded by terrain. |
| 760 | isCulled = true; |
| 761 | } |
| 762 | |
| 763 | // If the object shouldn't be subjected to more fine-grained culling |
| 764 | // or if zone culling is disabled, just test against the root frustum. |
| 765 | |
| 766 | else if( !( object->getTypeMask() & CULLING_INCLUDE_TYPEMASK ) || |
| 767 | ( object->getTypeMask() & CULLING_EXCLUDE_TYPEMASK ) || |
| 768 | disableZoneCulling() ) |
no test coverage detected