Esempio n. 1
0
    public List <TriangleData> getTrianglesInOOBB(OOBB col)
    {
        // clear previous list
        retList.Clear();

        Vector3 center = col.center - offset;

        // map our coordinates
        int topLeftX = Mathf.Max(0, Mathf.FloorToInt(center.x / cellSize));
        int topLeftY = Mathf.Max(0, Mathf.FloorToInt(center.y / cellSize));
        int topLeftZ = Mathf.Max(0, Mathf.FloorToInt(center.z / cellSize));

        int bottomRightX = Mathf.Min(cols - 1, Mathf.CeilToInt((center.x + col.aabbWidth - 1) / cellSize));
        int bottomRightY = Mathf.Min(rows - 1, Mathf.CeilToInt((center.y + col.aabbHeight - 1) / cellSize));
        int bottomRightZ = Mathf.Min(depth - 1, Mathf.CeilToInt((center.z + col.aabbLength - 1) / cellSize));

        //Debug.Log("TOP" + topLeftX + " " + topLeftY + " " + topLeftZ);
        //Debug.Log("BOT" + bottomRightX + " " + bottomRightY + " " + bottomRightZ);
        if (grid.Length == 0)
        {
            return(retList);
        }

        //int count = 0;
        for (int x = topLeftX; x <= bottomRightX; x++)
        {
            for (int y = topLeftY; y <= bottomRightY; y++)
            {
                for (int z = topLeftZ; z <= bottomRightZ; z++)
                {
                    int hash = x + rows * (y + depth * z);
                    //Debug.Log(x + " " + y + " " + z);
                    //Debug.Log("Getting into Grid: " + x + " " + y + " " + z);
                    // there is data in this grid
                    if (grid[hash].dataPt.Count > 0)
                    {
                        // loop through
                        //count++;
                        foreach (TriangleData dat in grid[hash].dataPt)
                        {
                            if (!retList.Contains(dat))
                            {
                                retList.Add(dat);
                            }
                        }
                    }
                }
            }
        }

        //Debug.Log(count + " " + retList.Count);

        // finally, return our list of triangles
        return(retList);
    }
Esempio n. 2
0
 public List <TriangleData> getTrianglesInOOBB(OOBB col)
 {
     return(grid.getTrianglesInOOBB(col));
 }
Esempio n. 3
0
 public List<TriangleData> getTrianglesInOOBB(OOBB col)
 {
     return grid.getTrianglesInOOBB(col);
 }
Esempio n. 4
0
    public List<TriangleData> getTrianglesInOOBB(OOBB col)
    {
        // clear previous list
        retList.Clear();

        Vector3 center = col.center - offset;

        // map our coordinates
        int topLeftX = Mathf.Max(0, Mathf.FloorToInt(center.x / cellSize));
        int topLeftY = Mathf.Max(0, Mathf.FloorToInt(center.y / cellSize));
        int topLeftZ = Mathf.Max(0, Mathf.FloorToInt(center.z / cellSize));

        int bottomRightX = Mathf.Min(cols - 1, Mathf.CeilToInt((center.x + col.aabbWidth - 1) / cellSize));
        int bottomRightY = Mathf.Min(rows - 1, Mathf.CeilToInt((center.y + col.aabbHeight - 1) / cellSize));
        int bottomRightZ = Mathf.Min(depth - 1, Mathf.CeilToInt((center.z + col.aabbLength - 1) / cellSize));

        //Debug.Log("TOP" + topLeftX + " " + topLeftY + " " + topLeftZ);
        //Debug.Log("BOT" + bottomRightX + " " + bottomRightY + " " + bottomRightZ);
        if (grid.Length == 0) {
            return retList;
        }

        //int count = 0;
        for (int x = topLeftX; x <= bottomRightX; x++) {
            for (int y = topLeftY; y <= bottomRightY; y++) {
                for (int z = topLeftZ; z <= bottomRightZ; z++) {
                    int hash = x + rows * (y + depth * z);
                    //Debug.Log(x + " " + y + " " + z);
                    //Debug.Log("Getting into Grid: " + x + " " + y + " " + z);
                    // there is data in this grid
                    if (grid[hash].dataPt.Count > 0) {
                        // loop through
                        //count++;
                        foreach (TriangleData dat in grid[hash].dataPt) {
                            if (!retList.Contains(dat)) {
                                retList.Add(dat);
                            }
                        }
                    }
                }
            }
        }

        //Debug.Log(count + " " + retList.Count);

        // finally, return our list of triangles
        return retList;
    }