How can I get all grid tiles in an area

I have a game template I am working on where the user can place tiles and build the terrain. I have a mathematical grid set up to determine what “Tile” the cursor is in based on cursor location. Grid system and everything works perfectly, and I always know that my cursor is over say XY Tile ( 2D Coordinates) What I am having an issue is creating a drag select area and place tiles in the selected area.

I made a working mode by making a temp grid from the start drag location on LMB pressed and on tick updating the end drag location and it can easily draw all the tiles in the area. the issue arises when you make a bigger area as on tick it is constantly recalculating the temp grid and as it gets bigger and bigger the tick event becomes more of a bottleneck.

I assume there is a much easier way for me to simply use a start and end location and get all coordinates inside in an optimized way instead.

Any insight on some math where i can easily get all coordinates in a box would be amazing

to further add basically i would like to create a function that takes in two vectors.

Function Exmaple

Input:
Start Vector
End Vector

Output:
Vector Array of all points in box between start and end point

If you make a BP containing a box collision volume, when the player drags, spawn this BP and scale the collision volume to the dragged area. Then, finding the tiles is as easy as

image

Well my issue is I am working with no collisions just the math of it in empty space so that the player could then simply drag over an area and let go and then spawn the tiles for all points within the area

I didn’t read it well…

Are you trying to draw the tiles while they are dragging? That’s gonna be impossible, I think.

What about just giving them a guide while dragging, but not placing tiles until they let go.

That way, you only have to record 2 points.

how would the guide be? Like a single mesh that i scale as i drag?

It could still look cool. You could do something that looks like the landscape actor before the material is set.

It would just be a plane with that fake wireframe material on it: