- Home /
Detect perimetral walls of a room
Hi, I'm developing a building editor. Users can draw rooms by adding angles (vertices of the room) with a left click. Clicking on an existing angle closes the room and fills the floor by using the PointInPolygon algorithm. Let me illustrate the problem. I have this room.
#-----------#
| |
| |
| #-----#
| |
| |
| |
#-----#
Now I want to create another room by connecting two of the vertices like this:
#-----------#
| |
| |
| V--A--X < first click
| | |
| B | <--new room
| | |
#-----Y-----#
^
second click
I need to detect the vertex V and the edges A and B. I tried to implement the convex hull algorithm to find the external walls, but there are degenerated cases where those edges are interior walls... I even tried the Dijstra's algorithm to find the shortest path between X and Y, but again there are degenerated cases like this:
first click
v
X----------# < second click
| |
#-----#-----# |
| | | |
| | | | <--new room
| | | |
#-----#-----# |
| |
Y----------# < third click
^
fourth click
How should I approach this problem?
Answer by suchoparek · Jun 21, 2015 at 11:01 AM
This question was answered here: link text.
Rather than a graph algorithm, you can use a boolean operation to subtract the first room from the second one.
Your answer
Follow this Question
Related Questions
Detect where line intersects outline shape 1 Answer
Selecting a single polygon / face at runtime 1 Answer
Vertex count 10 times higher in Unity 5 Answers
how to: create a four vertex, two tri square polygon in Unity Editor or Script? 4 Answers
How to get the number of vertices, triangles programmatically? 3 Answers