Search Unity

Finding grid cells inside a rectangle

Discussion in '2D' started by sollniss, Aug 2, 2019.

  1. sollniss

    sollniss

    Joined:
    Aug 23, 2017
    Posts:
    11
    How would I go about finding all grid cells that are contained in (intersect with) a rectangle gived by four vectors in world space?

    The only thing I can imagine is calculating the edges and sampling at specific intervals and then doing the same for diagonals to find cells inside of the rectangle. But it feels like there should be a mathematically prettier solution.