Example #1
0
        static void Check(Tree4 tree)
        {
            if (!tree.collisonInfo.active)
            {
                return;
            }

            int count = tree.objs.Count;
            var objs  = tree.objs;

            for (int i = 0; i < count; i++)
            {
                for (int j = i + 1; j < count; j++)
                {
                    if (objs[i] != objs[j] && (objs[i].rigibody.useCheck || objs[j].rigibody.useCheck))
                    {
                        if (ShapPhysics.Check(objs[i].Shap, objs[j].Shap))
                        {
                            objs[i].rigibody.AddCollistionData(objs[j]);
                            objs[j].rigibody.AddCollistionData(objs[i]);
                        }
                    }
                }
            }
            //lastCheckTime = InputCenter.Time;
            tree.collisonInfo.active = false;
        }
Example #2
0
        public List <NetData> CheckShap(ShapBase shap)
        {
            List <NetData> objs     = new List <NetData>();
            var            treeList = GetInTress(shap);

            foreach (var tree in treeList)
            {
                for (int i = 0; i < tree.objs.Count; i++)
                {
                    if (ShapPhysics.Check(shap, tree.objs[i].Shap))
                    {
                        objs.Add(tree.objs[i]);
                    }
                }
            }
            return(objs);
        }
Example #3
0
        /// <summary>
        /// 碰撞检测
        /// </summary>
        /// <param name="tree">检测的节点</param>
        /// <returns>碰撞的对象</returns>
        public Dictionary <NetData, List <NetData> > Check(Tree4 tree)
        {
            if (!active && InputCenter.Time <= lastCheckTime)
            {
                return(checkList);
            }
            checkList.Clear();
            int count = tree.objs.Count;
            var objs  = tree.objs;

            for (int i = 0; i < count; i++)
            {
                for (int j = i + 1; j < count; j++)
                {
                    if (objs[i] != objs[j] && ShapPhysics.Check(objs[i], objs[j]))
                    {
                        if (checkList.ContainsKey(objs[i]))
                        {
                            checkList[objs[i]].Add(objs[j]);
                        }
                        else
                        {
                            checkList.Add(objs[i], new List <NetData>());
                            checkList[objs[i]].Add(objs[j]);
                        }
                        if (checkList.ContainsKey(objs[j]))
                        {
                            checkList[objs[j]].Add(objs[i]);
                        }
                        else
                        {
                            checkList.Add(objs[j], new List <NetData>());
                            checkList[objs[j]].Add(objs[i]);
                        }
                    }
                }
            }
            lastCheckTime = InputCenter.Time;
            active        = false;
            return(checkList);
        }
Example #4
0
        public List <NetData> CheckShap(ShapBase shap)
        {
            List <NetData> objs     = new List <NetData>();
            var            treeList = GetInTress(shap);

            foreach (var tree in treeList)
            {
                for (int i = 0; i < tree.objs.Count; i++)
                {
                    if (!tree.objs[i].isTrigger && ShapPhysics.Check(shap, tree.objs[i].Shap))
                    {
                        //当物体处于四叉树交界处 可能会添加多次
                        if (!objs.Contains(tree.objs[i]))
                        {
                            objs.Add(tree.objs[i]);
                        }
                    }
                }
            }
            return(objs);
        }
Example #5
0
        public static void Check(Tree4 tree)
        {
            if (!tree.collisonInfo.active)
            {
                return;
            }

            int count = tree.objs.Count;
            var objs  = tree.objs;

            for (int i = 0; i < count; i++)
            {
                for (int j = i + 1; j < count; j++)
                {
                    if (objs[i] != objs[j] && ShapPhysics.Check(objs[i], objs[j]))
                    {
                        objs[i].physics.collisonDatas.Add(objs[j]);
                        objs[j].physics.collisonDatas.Add(objs[i]);
                    }
                }
            }
            //lastCheckTime = InputCenter.Time;
            tree.collisonInfo.active = false;
        }