示例#1
0
        public void ReleaseSphere(ICullingSystemListener listener)
        {
            if (cullingGroup == null)
            {
                return;
            }
            var sphereIndex = indices[listener];

            cullingGroup.EraseSwapBack(sphereIndex);
            indices[listeners[boundingSphereCount - 1]] = sphereIndex;
            CullingGroup.EraseSwapBack(sphereIndex, listeners, ref boundingSphereCount);
        }
示例#2
0
    public static int EraseSwapBack(IntPtr l)
    {
        int result;

        try
        {
            CullingGroup cullingGroup = (CullingGroup)LuaObject.checkSelf(l);
            int          index;
            LuaObject.checkType(l, 2, out index);
            cullingGroup.EraseSwapBack(index);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
        /// <summary>
        /// 移除一个裁剪请求
        /// </summary>
        /// <param name="_cullingObject"></param>
        public void RemoveRequest(IViewCullingObject _cullingObject)
        {
            var index = _cullingObject.index;

            //如果Index为-1,说明根本就不在队列中
            if (index != -1)
            {
                //从CullingGroup中移除该元素
                cullingGroup.EraseSwapBack(index);

                //减少数量,并且同步设置CullingGroup的数量
                --currentRequestingCount;
                cullingGroup.SetBoundingSphereCount(currentRequestingCount);

                //CullingGroup中是将最后一个元素移动到当前元素进行替换的
                //因此ViewCullingObjects这边也采取相同的措施
                //并更新被替换的Object的Index
                viewCullingObjects[index]       = viewCullingObjects[currentRequestingCount];
                viewCullingObjects[index].index = index;

                //将申请者的Index设置为-1,表示其已经不属于列表内
                _cullingObject.index = -1;
            }
        }
示例#4
0
    /// <summary>
    /// Removes Bounding Sphere at specified Index and records that array position as available
    /// </summary>
    /// <param name="index">Index of Bounding Sphere to remove</param>
    public void RemoveSphere(int index)
    {
        //only do this if the index exists
        if (!cullGroupBehaveDict.ContainsKey(index))
        {
            return;
        }

        //clearedSpaces.Enqueue(index);//record that this space is open if we add a new Bounding Sphere later
        //cullGroupBehaveDict.Remove(index);

        //remove the desired Bounding Sphere by moving the last Bounding Sphere on top of it
        cullGroup.EraseSwapBack(index);


        //update the information on the Culling Group Behaviour to preserve callback functionality
        cullGroupBehaveDict[index] = cullGroupBehaveDict[cullGroupBehaveDict.Count - 1];
        cullGroupBehaveDict[index].boundingSphereIndex = index;


        //remove the old Culling Group Behaviour from the callback Dictionary
        //cullGroupBehaveDict[cullGroupBehaveDict.Count - 1] = null;
        cullGroupBehaveDict.Remove(cullGroupBehaveDict.Count - 1);
    }