@@ -49,6 +49,8 @@ def run(self):
4949
5050 layer_index = 0
5151 for layer in self .svg_info ['layers' ]:
52+ if self ._running == False :
53+ raise Exception ("Canceled" )
5254 num_points = max (int (layer ['path' ].length ()) * 20 , 100 )
5355 num_points = min (num_points , 10000 )
5456 poly = path_to_polygon (layer ['path' ], num_points )
@@ -59,7 +61,7 @@ def run(self):
5961 self .debug_log .emit (f"Unable to determine surface type based on assigned fill color! ({ layer ["attr" ]} )" )
6062 return None
6163
62- self .debug_log .emit (f"Processing surface: { surface } , { num_points } points" )
64+ self .debug_log .emit (f"Processing surface: { surface } , { num_points } points" )
6365
6466 layers .append ({
6567 "index" : layer_index ,
@@ -69,8 +71,8 @@ def run(self):
6971 "surface" : surface ,
7072 "color" : color
7173 })
72-
7374 layer_index += 1
75+
7476 # self.progress.emit(layer_index)
7577 # time.sleep(1) # blocking work simulated
7678
@@ -92,6 +94,8 @@ def run(self):
9294 layers_completed = 0
9395
9496 for layer in layers :
97+ if self ._running == False :
98+ raise Exception ("Canceled" )
9599 if layer ['polygon' ].is_empty :
96100 self .debug_log .emit (f" Skipping empty polygon for { layer ['surface' ]} " )
97101 continue
@@ -107,18 +111,26 @@ def run(self):
107111 interior_spacing = 0.5
108112 if layer ['surface' ] == "river" :
109113 interior_spacing = 0.2
114+ # if layer['surface'] == "rough":
115+ # interior_spacing = 1.0
116+ # boundary_spacing = 0.75
110117
111118 self .debug_log .emit (f"Generating { layer ['label' ]} polygons with spacing { interior_spacing } " )
112119 vertices , faces = triangulate_polygon (layer ['polygon' ], boundary_spacing , interior_spacing )
113-
120+ if self ._running == False :
121+ raise Exception ("Canceled" )
114122 if vertices .shape [0 ] == 0 or faces .shape [0 ] == 0 :
115123 self .debug_log .emit (f" Skipping empty shape for { layer ['surface' ]} " )
116124 continue
117125
118126 # conform meshes to heightmap
119127 self .debug_log .emit (f"Conforming { layer ['label' ]} polygon to heightmap" )
128+
129+ # keep lake surfaces flat
130+ # if layer['surface'] != "water":
120131 vertices = map_mesh_to_heightmap (vertices , terrain_data ["data" ], self .svg_info ["width" ], self .svg_info ["height" ], max_world_height )
121-
132+ if self ._running == False :
133+ raise Exception ("Canceled" )
122134 face_colors = np .tile (hex_to_rgba (layer ["color" ]), (faces .shape [0 ], 1 ))
123135 mesh = trimesh .Trimesh (vertices = vertices , faces = faces , face_colors = face_colors )
124136
@@ -138,9 +150,9 @@ def run(self):
138150 # # self.debug_log.emit(f"Exporting OBJ files to output folder: {self.output_path}")
139151 # # lib.export.export_individual_obj_files(allMeshes, layers, self.output_path)
140152
141- self .finished .emit (result )
153+ self .finished .emit (0 )
142154 except Exception as e :
143- self .finished .emit (None )
155+ self .finished .emit (1 )
144156 self .error .emit (str (e ))
145157
146158 def stop (self ):
@@ -151,6 +163,7 @@ def stop(self):
151163
152164
153165
166+
154167def generate_meshes (args , layers , terrain_data , width , height , debug_log ):
155168 allMeshes = []
156169
@@ -223,6 +236,7 @@ def parse_layers(svg_file):
223236 if (surface == None or color == None ):
224237 debug_log (f"Unable to determine surface type based on assigned fill color! ({ attr } )" , True )
225238 return None
239+
226240 print (f"Processing surface: { surface } , { num_points } points" )
227241
228242 layers .append ({
0 commit comments