コード例 #1
0
        /// <summary>
        /// Add an object.
        /// </summary>
        /// <param name="obj">Object to add.</param>
        /// <param name="objBounds">3D bounding box around the object.</param>
        public void Add(ColliderProxy obj, LRect objBounds)
        {
            Debug.Trace($"ColliderProxy Add { obj.Id} objBounds  {objBounds}");
            // Add object or expand the octree until it can be added
            int count = 0; // Safety check against infinite/excessive growth

            while (!rootNode.Add(obj, objBounds))
            {
                Debug.LogError("Grow");
                Grow(objBounds.center - rootNode.Center);
                if (++count > 20)
                {
                    Debug.LogError("Aborted Add operation as it seemed to be going on forever (" + (count - 1) +
                                   ") attempts at growing the octree.");
                    return;
                }
            }

            Count++;
        }
コード例 #2
0
    public void DoStart()
    {
        if (_instance != this)
        {
            Debug.LogError("Duplicate CollisionSystemAdapt!");
            return;
        }

        var collisionSystem = new CollisionSystem()
        {
            worldSize    = worldSize,
            pos          = pos,
            minNodeSize  = minNodeSize,
            loosenessval = loosenessval
        };

        Debug.Trace($"worldSize:{worldSize} pos:{pos} minNodeSize:{minNodeSize} loosenessval:{loosenessval}");
        this.collisionSystem = collisionSystem;
        collisionSystem.DoStart(InterestingMasks, allTypes);
        collisionSystem.funcGlobalOnTriggerEvent += GlobalOnTriggerEvent;
    }