list index out of range lmao
This commit is contained in:
@@ -29,12 +29,17 @@ class Entrance:
|
|||||||
oriented_vertices.sort(key = lambda v: v.point1.x if self.direction.value % 2 == 0 else v.point1.z) # if direction is north or south, sort by x, else sort by z
|
oriented_vertices.sort(key = lambda v: v.point1.x if self.direction.value % 2 == 0 else v.point1.z) # if direction is north or south, sort by x, else sort by z
|
||||||
mid = len(oriented_vertices) // 2
|
mid = len(oriented_vertices) // 2
|
||||||
ver1, ver2 = oriented_vertices[mid], oriented_vertices[-mid-1]
|
ver1, ver2 = oriented_vertices[mid], oriented_vertices[-mid-1]
|
||||||
if ver1.point1.position == ver2.point1.position:
|
|
||||||
|
if ver1.point1.x != ver2.point1.x and ver1.point1.z != ver2.point1.z:
|
||||||
|
door_vertice = rd.choice(ver1, ver2)
|
||||||
|
facade_vertices.remove(door_vertice)
|
||||||
|
elif ver1.point1.position == ver2.point1.position:
|
||||||
door_vertice = ver1
|
door_vertice = ver1
|
||||||
|
facade_vertices.remove(door_vertice)
|
||||||
else :
|
else :
|
||||||
door_vertice = Vertice(ver2.point1, ver1.point2)
|
door_vertice = Vertice(ver2.point1, ver1.point2)
|
||||||
facade_vertices.remove(ver2)
|
|
||||||
facade_vertices.remove(ver1)
|
facade_vertices.remove(ver1)
|
||||||
|
facade_vertices.remove(ver2)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
door_vertice = rd.choice(oriented_vertices)
|
door_vertice = rd.choice(oriented_vertices)
|
||||||
@@ -44,12 +49,23 @@ class Entrance:
|
|||||||
return(door_vertice, facade)
|
return(door_vertice, facade)
|
||||||
|
|
||||||
def get_oriented_vertices(self) -> list[Vertice]:
|
def get_oriented_vertices(self) -> list[Vertice]:
|
||||||
# get the most off-centered vertices that are in the same direction as self.direction
|
# Get all the vertice that can contain the door
|
||||||
same_direction_vertices = sorted([v for v in self.vertices if v.facing == self.direction],
|
|
||||||
key = lambda v: v.point1.z if self.direction.value % 2 == 0 else v.point1.x, # if direction is north or south, sort by x, else sort by z
|
# if direction is north or south, compare by x, else compare by z
|
||||||
reverse = self.direction == DIRECTION.NORTH or self.direction == DIRECTION.WEST) # if direction is north or west, sort in reverse
|
compare = lambda v: (v.point1.x,v.point1.z) if self.direction.value % 2 == 0 else (v.point1.z,v.point1.x)
|
||||||
extremum = same_direction_vertices[0]
|
# if direction is north or west, the most off_centered is the maximum, else it is the minimum
|
||||||
return [v for v in same_direction_vertices if
|
off_centered = lambda p1,p2: max(p1,p2) if self.direction == DIRECTION.NORTH or self.direction == DIRECTION.WEST else min(p1,p2)
|
||||||
(v.point1.x == extremum.point1.x and self.direction.value % 2 == 0) or
|
|
||||||
(v.point1.z == extremum.point1.z and self.direction.value % 2 == 1)]
|
oriented_vertices = []
|
||||||
|
for v in self.vertices:
|
||||||
|
if v.facing != self.direction: continue
|
||||||
|
oriented_vertices.append(v)
|
||||||
|
sortby,position = compare(v)
|
||||||
|
for ov in oriented_vertices:
|
||||||
|
ov_sorted, ov_position = compare(ov)
|
||||||
|
if position == ov_position:
|
||||||
|
if off_centered(sortby,ov_sorted) == sortby: oriented_vertices.remove(ov)
|
||||||
|
else: oriented_vertices.remove(v)
|
||||||
|
|
||||||
|
return oriented_vertices
|
||||||
|
|
||||||
@@ -14,3 +14,4 @@ pilliers quand trop de fenêtres + pas de pilliers si tile trop petite
|
|||||||
limitateur taille
|
limitateur taille
|
||||||
facade lisses/ immeubles collés
|
facade lisses/ immeubles collés
|
||||||
matrices pré-distribués
|
matrices pré-distribués
|
||||||
|
angles 270
|
||||||
@@ -76,3 +76,5 @@ buildings:
|
|||||||
size:
|
size:
|
||||||
min_height: 5
|
min_height: 5
|
||||||
max_height: 9
|
max_height: 9
|
||||||
|
door:
|
||||||
|
|
||||||
Reference in New Issue
Block a user