Get aabb on tiles in a gridmap with rotation

Godot Version

4.2

Question

Greetings,

again a problem i can’t fix on my own. Have tried it but i think my math knowledge is on the level of a turtle :wink: So here it is: there are oversized tiles inside a gridmap. To get the aabb() is not the prob. What i try is to get the boundary of the tiles/objects inside my “decoration” gridmap and remove the overlaped tiles on my “surface” gridmap. Here is some code:

var aabb = decoration.mesh_library.get_item_mesh(decorationTileId).get_aabb()
				
var tilesToCheck_start = Vector3i(tileVector)
var tilesToCheck_end = Vector3i(tileVector) + decoration.local_to_map( floor(aabb.size) )
				
if decorationTile.rotation == 'north': #0°
	for x in range(tilesToCheck_start.x, tilesToCheck_end.x):
		for z in range(tilesToCheck_start.z, tilesToCheck_end.z):
			surface.set_cell_item(Vector3i(x,tileVector.y,z), -1)
							
if decorationTile.rotation == 'east': #90°
					????
					
if decorationTile.rotation == 'south': #180°
					????
					
if decorationTile.rotation == 'west': #270°
					????

This works like charm without rotated Tiles. I have tried some stuff but it results in an “if” hell or the “turtle” was coming up again with: Don’t do math. Thats not good, it hurts. Better go for some pizza my friend. Here is an image for better understanding. The mesh pivot is the green cross and the squares are showing the overlapping tiles.

Hope this explanation is better than in my last Topic.