示例#1
0
        public IEnumerator Test5AdditionAndUpdate()
        {
            List <GameObject> objects = SetupScene(0);
            BVH <GameObject>  bvh     = CreateBVH(objects);

            float t    = 0;
            int   last = 0;

            while (t < TIME_PER_TEST)
            {
                t += Time.deltaTime;
                if (t * 5 > last)
                {
                    last++;
                    GameObject obj = CreateGameObject();
                    objects.Add(obj);
                    bvh.Add(obj);
                }

                foreach (GameObject obj in objects)
                {
                    obj.transform.Translate(obj.transform.forward * Time.deltaTime * 5);
                    bvh.MarkForUpdate(obj);
                }

                bvh.Optimize();
                bvh.RenderDebug();

                yield return(null);
            }

            DestroyScene(objects);
        }
示例#2
0
        public IEnumerator Test4MultipleItemPositionUpdate()
        {
            List <GameObject> objects = SetupScene();
            BVH <GameObject>  bvh     = CreateBVH(objects);

            float t = 0;

            while (t < TIME_PER_TEST)
            {
                t += Time.deltaTime;

                foreach (GameObject obj in objects)
                {
                    obj.transform.Translate(obj.transform.forward * Time.deltaTime * 5);
                    bvh.MarkForUpdate(obj);
                }

                bvh.Optimize();
                bvh.RenderDebug();

                yield return(null);
            }

            DestroyScene(objects);
        }
示例#3
0
        public IEnumerator Test8AddDestroyAndUpdate()
        {
            List <GameObject> objects = SetupScene();
            BVH <GameObject>  bvh     = CreateBVH(objects);

            float t    = 0;
            int   last = 0;

            while (t < TIME_PER_TEST)
            {
                t += Time.deltaTime;
                if (t * 5 > last)
                {
                    last++;

                    if (Random.Range(0, 2) == 1)
                    {
                        GameObject obj = CreateGameObject();
                        objects.Add(obj);
                        bvh.Add(obj);
                    }
                    else if (objects.Count > 0)
                    {
                        GameObject obj = objects[objects.Count - 1];
                        bvh.Remove(obj);
                        objects.RemoveAt(objects.Count - 1);
                        Object.Destroy(obj);
                    }
                }

                foreach (GameObject obj in objects)
                {
                    obj.transform.Translate(obj.transform.forward * Time.deltaTime * 5);
                    bvh.MarkForUpdate(obj);
                }

                bvh.Optimize();
                bvh.RenderDebug();

                yield return(null);
            }

            DestroyScene(objects);
        }