balcony fixed

This commit is contained in:
AKreuzer
2024-06-05 02:10:01 +02:00
parent c3fc592f84
commit a4561c4ccb
3 changed files with 55 additions and 20 deletions

11
buildings/TODO Normal file
View File

@@ -0,0 +1,11 @@
Encadrement fenêtre
toit de balcon avec/sans pilliers
border radius balcon
collumn style
détails facade
rdc
toit
tiles 3d
opti géométrique
opti textures
opti gdpc

View File

@@ -10,13 +10,30 @@ class Balcony:
self.windows = windows
self.max_width = max_width
self.length = self.get_len()
self.has_multiple = self.has_multiple_balcony()
self.has_multiple = self.has_multiple()
self.has_details = self.has_details()
self.follow_window = self.follow_window()
self.structure = self.get_structures()
self.editor, self.materials = None,None
def build(self, editor : Editor, materials : list[str]):
self.editor = editor
self.materials = materials
for s in self.structure:
s.fill(editor, materials[0])
self.build_rembard(s)
self.build_details(s)
def build_rembard(self, s : Vertice):
geometry.placeCuboid(self.editor,(s.point1.x,1,-1),(s.point1.x,1,-self.length),Block(self.materials[3]))
geometry.placeCuboid(self.editor,(s.point2.x,1,-1),(s.point2.x,1,-self.length),Block(self.materials[3]))
geometry.placeCuboid(self.editor,(s.point1.x,1,-self.length),(s.point2.x,1,-self.length),Block(self.materials[3]))
def build_details(self, s : Vertice):
if not self.has_details: return
geometry.placeCuboid(self.editor,(s.point1.x,0,-1),(s.point1.x,0,-self.length),Block(self.materials[4], {"facing": "east", "half": "top"}))
geometry.placeCuboid(self.editor,(s.point2.x,0,-1),(s.point2.x,0,-self.length),Block(self.materials[4], {"facing": "west", "half": "top"}))
geometry.placeCuboid(self.editor,(s.point1.x,0,-self.length),(s.point2.x,0,-self.length),Block(self.materials[4], {"facing": "south", "half": "top"}))
def get_structures(self) -> list[Vertice]:
attach_points = self.get_attach_points()
@@ -29,51 +46,56 @@ class Balcony:
structures = []
centered = True
while True:
while x1 > 0:
x1 -= 1
x2 += 1 if centered else 0
print(x1,x2, attach_points)
leng = attach_points[x2] - attach_points[x1] - 1
if x1 == 0:
if leng >= min_wid: structures.append(self.create_structure(attach_points[x1], attach_points[x2]))
if leng >= min_wid: self.append_structure(structures, x1, x2, attach_points, len_attach_points, centered)
break
if leng < min_wid: continue
if growth_chance < rd.random():
structures.append(self.create_structure(attach_points[x1], attach_points[x2]))
if not centered:
structures.append(self.create_structure(attach_points[len_attach_points-x1], attach_points[len_attach_points-x2]))
self.append_structure(structures, x1, x2, attach_points, len_attach_points, centered)
if not self.has_multiple: break
else:
print(x1,min_wid, min_gap)
if x1-min_wid < min_gap: break
gap = rd.randint(min_gap, x1-min_wid)
centered = False
if attach_points[x1]-min_wid < min_gap: break
gap = rd.randint(min_gap, attach_points[x1]-min_wid)
x2 = x1-gap
x1 = x2-min_wid
x1 = x2-min_wid+1
return structures
def get_attach_points(self) -> list[int]:
points = [i for i in range(self.max_width)]
if self.follow_window:
pad = self.windows.padding
for w in self.windows.windows:
for i in range(w.x1, w.x2+1):
for i in range(pad+w.x1, pad+w.x2+1):
points.remove(i)
return points
def create_structure(self, x1 : int, x2 : int) -> Vertice:
return Vertice(Point(x1,0,0), Point(x2,0,-self.length+1))
return Vertice(Point(x1,0,0), Point(x2,0,-self.length))
def append_structure(self, structures : list[Vertice], x1 : int, x2 : int, attach_points : list[int], len_attach_points : int, centered : bool):
structures.append(self.create_structure(attach_points[x1], attach_points[x2]))
if not centered:
structures.append(self.create_structure(attach_points[len_attach_points-x1], attach_points[len_attach_points-x2]))
def follow_window(self) -> bool:
return self.windows.ypadding > 3
return not self.windows.ypadding > 3
def has_multiple_balcony(self) -> bool:
def has_multiple(self) -> bool:
if self.max_width < self.rdata["multiple"]["min_width"]: return False
return self.rdata["multiple"]["proba"] >= rd.random()
def has_details(self) -> bool:
return self.rdata["details"] >= rd.random()
def get_len(self) -> int:
return rd.randint(self.rdata["size"]["min_len"], self.rdata["size"]["max_len"])

View File

@@ -42,13 +42,15 @@ buildings:
inter_floor: 0.5
balcony:
proba : 0.25
growth: 0.8 # [growth]% chance to have min_width + 1 balcony length, [growth**2]% chance to have min_width + 2 balcony length, etc
growth: 0.5 # [growth]% chance to have min_width + 1 balcony length, [growth**2]% chance to have min_width + 2 balcony length, etc
size:
min_len : 1
max_len : 3
min_width : 3
multiple:
# probability to have multiple balcony IF POSSIBLE
proba: 0.5
# this feature need a very large facade
proba: 1
min_width: 5
min_gap: 0
min_gap: 1
details: 0.35