DangerBlack / fantasy-city-planner

A tool for creating random city in a middle age fantasy world
GNU General Public License v3.0
3 stars 1 forks source link

Buildings can overlap along quadrant edges #4

Closed hawson closed 9 years ago

hawson commented 9 years ago

This is likely due to the fact buildings along a quadrant edges are not checked against buildings in the neighboring quadrant.

DangerBlack commented 9 years ago

Tonight come in my mind 4 solution:

1) Time lock: colse the quadrant in order, and when a quadrant it closed you can not change it anymore. Now you can freely check collision also with the closed quadrant.

2) Overlapping priority: solving the overlapping postmortem using the priority between quadrant.

3) No house exiting: avoiding that a house can exit from a quadrant.

4) Mutex on border zone: Using a mutex or a semaphore in order to check all the house inside the semaphore without race condition

I chose the 2 one due two the fact that is the easiest one and can be added without to much refactory. Let's hope it works fine.

hawson commented 9 years ago

A simpler fix, for option 2 would be to create buildings like this:

  1. determine building dimensions (Bx, By)
  2. Place the NW corner of the building between (0,0) and (QUADRANT_X-Bx, QUADRANT_Y-By)

Obviously, adjust the coordinates for each quadrant, but that should keep buildings from crossing boundaries This method may show the quadrant boundary artifacts, however.