Assistance on creating a 3D Room Detection System

Hello, I require assistance on creating a 3D Room Detection System, there are (unsolved) several topics on devforum on this issue (some even created by me in the past).

This was the closest I believe I’ve gotten, but there were several misunderstandings and / or issues.

(@ThanksRoBama posted a very in depth reply, but going it several times, it wasn’t really of help to use + there wasn’t a way they were checking if the tiles were even checking the walls?, also we don’t think it originated in lua since there were many errors / missing functions?, but overall great read for anyone wanting to learn Flood Fill :+1:)

Fundamentals:
Each post has been met with some form of confusion or misunderstandings, here is what I (and many others probably) am seeking:

Something a long the lines of this:

Flood Fill:
Everyone who replied to the many posts on ‘Room Detection’ on the devforum (including myself), has pointed to the Flood Fill Algorithm or DPS (which I already know how to achieve).

But, what I’ve been trying to explain is, we can’t use ‘color’ for the basis, and we wan’t to know what walls are making up said room.

Instead of checking the color of a ‘tile’, we were left with some options, but no one has elaborated or said which was the best answer to recreate the room detection (in the video above).

Said Options:
So we don’t want ‘color’ to decide what is / isn’t in a room, so we could:

(Issue with using Flood Fill in general: What if a room is divided in 2 rooms itself, because it’s on the inside, the rest of the tiles will cast blue, and return both rooms as 1 room)


(Blue is the tiles iterated by Flood Fill, black is the ignored / avoided color)
(this should be 2 rooms, with one shared wall)

  • Region cast each tile, and check if it’s touching a wall, and exclude that tile from the DPS.
    (Issue / unsure reaction: we can’t just region each tile, due to if there’s just one wall (not connected to others), it would return as a room, so we need to check if walls are touching?, well if we were to iterate each wall, why even use Flood Fill in the first place?).

  • We can use Flood Fill, return all tiles touching a wall, then loop through that table checking if Tile[1] and Tile[2] are touching the same wall, then we could get the walls in a room.
    (Issue / unsure reaction: Simply and Hypothesis and was untested.)

I’ll try the second option, just to be sure, and update this topic on it’s success, but we have doubts over all.

2 Likes

is the size of the room always consistent?

Negative, we want a similar system to what’s in the video linked above, where you can ‘Draw’ the walls and create rooms with the preferred shape and size.

hmm I see, I’ll see what I can do tommrow, I’m sorry it’s 10pm here so I can’t help you out rn :man_bowing:

also one more thing, is the size of the building erea consistent?

By ’ Area’ if you are referring to the Plot where players place the walls, yes at the moment the plot’s size is a constant vector (around 80x80, subject to change).

hey so do the detection has be done automaticly? or does check when the player click the ground?
can diagonal walls be created? if so, can it be all directions or just 0 45 90 135 180 225 270 315?

Well not only does it appear to be only when the player places a wall in the video (above), but it might be costly constantly calling the function, so when a player places a wall.

I saw a post from @sleitnick stating, that it would be easier with a direction cap, so we can try (0, 45, 90, …) degrees only, first, then I’ll try to modify the code later.

@Sir_Pixelated
I hypothesize that in the video (above), each time a wall is places it does a Flood Fill Check (probably from top right, but it doesn’t matter what corner), then if there’s a room created (but what defines a room?), Flood Fill Check in said room (any corner), and check for sub rooms.

Issues with this theory: What defines a room, a lone wall can be checked as a room to Flood Fill, if Flood Check each time a wall is placed, the direction where the start point for Flood Fill would determine which side gets checked as a room.

so, what if you did the flood fill from where the wall is placed? like


let’s say the blue line is the all the player just placed, and the orange are the ones placed before
and the yellow tiles are the tiles are where the flood starts,
when flooding, let’s say the top tile, when the flood stops, it means theres a room, because there’s no more place for the tiles to muiltiply, but if the tile on the bottom, touches the edge of the plot, it means there’s no room and it’s just outside

Yeah I stated that previously, I just didn’t know which side to start the Flood Fill, but I’ve never considered both sides (I don’t know why), that would also solve the “sub room” issue (a room being divided from the inside, resulting in two rooms with a shared wall).