Beispiel #1
0
    public bool IsInside(Vector3 position)
    {
        if (!aabb.IsInside(position))
        {
            return(false);
        }

        //player is inside bounding box. Double check by looking at the direct environment.
        int roomHits = 0;

        for (int i = 0; i < 8; i++)
        {
            Vector3 dir = new Vector3(i & 1, (i << 1) & 1, (i << 2) & 1);
            dir = 2f * dir - Vector3.one;
            if (InRoom(position, dir))
            {
                roomHits++;
            }
        }
        roomHits += InRoom(position, Vector3.up) ? 1 : 0;
        roomHits += InRoom(position, Vector3.down) ? 1 : 0;

        return(roomHits > 0);
    }