Пример #1
0
    public void CheckCollisions()
    {
        List <AABB> currentlyChecking    = new List <AABB>();
        List <AABB> newCurrentlyChecking = new List <AABB>();
        List <Pair <AABB, AABB> > pairs  = new List <Pair <AABB, AABB> >();

        collisionChecks = 0;

        foreach (AABB aabb in sortedX)
        {
            foreach (AABB active in currentlyChecking)
            {
                if (BoundsInteraction.CheckOverlap1D(aabb, active, true))
                {
                    newCurrentlyChecking.Add(active);
                    pairs.Add(new Pair <AABB, AABB>(aabb, active));
                }
            }
            currentlyChecking = new List <AABB>(newCurrentlyChecking);
            currentlyChecking.Add(aabb);
            newCurrentlyChecking = new List <AABB>();
        }

        foreach (Pair <AABB, AABB> pair in pairs)
        {
            collisionChecks++;
            if (BoundsInteraction.CheckOverlap1D(pair.First, pair.Second, false))
            {
                Debug.Log("Intersection " + pair.First.gameObject.name + "  and  " + pair.Second.gameObject.name);
            }
        }
    }
Пример #2
0
    public KeyValuePair <AABB, float> GetNearestNeighbour(GameObject obj)
    {
        int      hashOfAAbb       = HashIt(obj.transform.position);
        HashNode node             = buckets[hashOfAAbb];
        AABB     nearestNeighbour = obj.GetComponent <AABB>();
        float    distance         = float.MaxValue;

        foreach (AABB aabb in node.Content)
        {
            if (aabb.Equals(obj))
            {
                continue;
            }

            float newDist = BoundsInteraction.GetDistance(aabb, obj.GetComponent <AABB>());
            if (newDist < distance)
            {
                distance         = newDist;
                nearestNeighbour = aabb;
            }
        }

        Debug.Log("Distance: " + distance + "| Object: " + nearestNeighbour.gameObject.name);

        return(new KeyValuePair <AABB, float>(nearestNeighbour, distance));
    }
Пример #3
0
    public KeyValuePair <AABB, float> GetNearestNeighbour(GameObject obj)
    {
        INode node             = FindNode(obj);
        AABB  objectBound      = obj.GetComponent <AABB>();
        AABB  nearestNeighbour = obj.GetComponent <AABB>();
        float distance         = float.MaxValue;

        foreach (AABB aabb in node.Content)
        {
            if (aabb.Equals(objectBound))
            {
                continue;
            }

            float newDist = BoundsInteraction.GetDistance(aabb, objectBound);
            if (newDist < distance)
            {
                distance         = newDist;
                nearestNeighbour = aabb;
            }
        }

        Debug.Log("Distance: " + distance + "| Object: " + nearestNeighbour.gameObject.name);

        return(new KeyValuePair <AABB, float>(nearestNeighbour, distance));
    }
Пример #4
0
    public void CheckCollisions()
    {
        foreach (Kd_TreeNode lst in leaves)
        {
            collisionChecks += BoundsInteraction.CheckN2(lst.Content);
        }

        /* Framestats fst = GetStats();
         * //Debug.Log("Deltatime: " + fst.deltaTime + " Framerate: " + fst.framerate);
         * if (GameManager.Instance.WriteStats)
         * {
         *  StatsExcelSender.Instance.WriteStat(GetStats());
         * } */
    }
Пример #5
0
    public void CheckCollisions()
    {
        foreach (var node in leaves)
        {
            if (node.Content.Count > 1)
            {
                collisionChecks += BoundsInteraction.CheckN2(node.Content);
            }
        }

        if (GameManager.Instance.WriteStats)
        {
            StatsExcelSender.Instance.WriteStat(GetStats());
        }
    }