public BallColliderBounds(Entity ballEntity, Aabb aabb)
 {
     BallEntity = ballEntity;
     Aabb       = aabb;
 }
示例#2
0
        public static void Create(BlobBuilder builder, ref BlobArray <BlobPtr <Collider> > colliders, ref QuadTree dest, Aabb rootBounds)
        {
            var children = builder.Allocate(ref dest._children, 4);
            var aabbs    = new List <ColliderBounds>();
            var cs       = new List <Collider>();

            for (var i = 0; i < colliders.Length; i++)
            {
                if (colliders[i].Value.Type != ColliderType.Plane)
                {
                    var c      = colliders[i].Value;
                    var bounds = colliders[i].Value.Bounds();
                    //Debug.Log("Adding aabb " + aabb + " (" + colliders[i].Value.Type + ")");
                    if (bounds.ColliderEntity == Entity.Null)
                    {
                        throw new InvalidOperationException($"Entity of {bounds} must be set ({colliders[i].Value.ItemType}).");
                    }
                    if (bounds.ColliderId < 0)
                    {
                        throw new InvalidOperationException($"ColliderId of {bounds} must be set ({colliders[i].Value.ItemType}).");
                    }

                    aabbs.Add(bounds);
                    cs.Add(c);
                }
            }

            dest.CreateNextLevel(builder, rootBounds, 0, 0, aabbs, ref children);
        }