private void ConstructQuadTree()
        {
            float        width  = CVars.Get <float>("play_field_width");
            float        height = CVars.Get <float>("play_field_height");
            QuadTreeNode qt     = new QuadTreeNode(new BoundingRect(-width / 2, -height / 2, width, height), null);

            foreach (Entity e in _quadTreeEntities)
            {
                qt.AddReference(e);
            }
        }
Exemple #2
0
        protected override void OnUpdate()
        {
            int counter = 0;

            quadTreeDict.Clear();
            rootNode = new QuadTreeNode(new CenteredRectangle(4 * Constants.GameBoundaryOffset, 2 * Constants.GameBoundaryOffset, new Unity.Mathematics.float3()));
            Entities.ForEach((Entity e, ref CollisionComponent coll, ref Translation translation) =>
            {
                counter++;
                rootNode.AddReference(e, coll, translation);
            });
            Debug.Log("Number of items added to tree = " + counter);
        }