Esempio n. 1
0
        public void QueryVisibleRenderers(DrawDevice device, RawList <ICmpRenderer> visibleRenderers)
        {
            int activeCount = this.cullingInfo.Count;

            CullingInfo[]  cullingData  = this.cullingInfo.Data;
            ICmpRenderer[] rendererData = this.cullingRenderers.Data;

            visibleRenderers.Clear();
            visibleRenderers.Reserve(activeCount);

            ICmpRenderer[] visibleRendererData = visibleRenderers.Data;
            int            visibleCount        = 0;

            VisibilityFlag mask = device.VisibilityMask;

            for (int i = 0; i < activeCount; i++)
            {
                // Check group and overlay / world visibility
                if ((cullingData[i].Visibility & VisibilityFlag.AllGroups & mask) == VisibilityFlag.None)
                {
                    continue;
                }
                if ((cullingData[i].Visibility & VisibilityFlag.ScreenOverlay) != (mask & VisibilityFlag.ScreenOverlay))
                {
                    continue;
                }

                // Check spatial visibility
                if (!device.IsCoordInView(cullingData[i].Position, cullingData[i].Radius))
                {
                    continue;
                }

                // Add renderer to visible result list
                visibleRendererData[visibleCount] = rendererData[i];
                visibleCount++;
            }

            visibleRenderers.Count = visibleCount;
        }