@@ -99,14 +99,17 @@ def execute(self, context: Context):
9999 paint_layers = terrain_info .paint_layers
100100 paint_layers_index = terrain_info .paint_layers_index
101101
102- if self .direction == 'UP' and paint_layers_index > 0 :
103- paint_layers .move (paint_layers_index , paint_layers_index - 1 )
104- terrain_info .paint_layers_index -= 1
105- build_terrain_material (active_object )
106- elif self .direction == 'DOWN' and paint_layers_index < len (paint_layers ) - 1 :
107- paint_layers .move (paint_layers_index , paint_layers_index + 1 )
108- terrain_info .paint_layers_index += 1
109- build_terrain_material (active_object )
102+ match self .direction :
103+ case 'UP' :
104+ if paint_layers_index > 0 :
105+ paint_layers .move (paint_layers_index , paint_layers_index - 1 )
106+ terrain_info .paint_layers_index -= 1
107+ build_terrain_material (active_object )
108+ case 'DOWN' :
109+ if paint_layers_index < len (paint_layers ) - 1 :
110+ paint_layers .move (paint_layers_index , paint_layers_index + 1 )
111+ terrain_info .paint_layers_index += 1
112+ build_terrain_material (active_object )
110113
111114 # The order of the paint layers changed. Therefore, we need to:
112115 # 1. Rebuild the paint layer node groups.
@@ -465,19 +468,20 @@ def add_terrain_layer_node(terrain_info_object: Object, nodes, type: str):
465468 node .terrain_info_object = terrain_info_object
466469 node .type = type
467470
468- if type == 'PAINT' :
469- # mesh_data = cast(Mesh, terrain_info_object.data)
470- # TODO: when we can paint non-color data, rewrite this!
471- # Add the density map attribute to the TerrainInfo mesh.
472- terrain_info_object .vertex_groups .new (name = node .id )
473- # attribute = mesh_data.attributes.get(node.id, None)
474- # vertex_count = len(attribute.data)
475- # color_data = numpy.ndarray(shape=(vertex_count, 4), dtype=float)
476- # color_data[:] = (0.0, 0.0, 0.0, 0.0)
477- # attribute.data.foreach_set('color', color_data.flatten())
478- elif type == 'FIELD' :
479- mesh_data = cast (Mesh , terrain_info_object .data )
480- mesh_data .attributes .new (node .id , 'FLOAT' , domain = 'POINT' )
471+ match type :
472+ case 'PAINT' :
473+ # mesh_data = cast(Mesh, terrain_info_object.data)
474+ # TODO: when we can paint non-color data, rewrite this!
475+ # Add the density map attribute to the TerrainInfo mesh.
476+ terrain_info_object .vertex_groups .new (name = node .id )
477+ # attribute = mesh_data.attributes.get(node.id, None)
478+ # vertex_count = len(attribute.data)
479+ # color_data = numpy.ndarray(shape=(vertex_count, 4), dtype=float)
480+ # color_data[:] = (0.0, 0.0, 0.0, 0.0)
481+ # attribute.data.foreach_set('color', color_data.flatten())
482+ case 'FIELD' :
483+ mesh_data = cast (Mesh , terrain_info_object .data )
484+ mesh_data .attributes .new (node .id , 'FLOAT' , domain = 'POINT' )
481485
482486 # Move the node to the top of the list.
483487 nodes .move (len (nodes ) - 1 , 0 )
@@ -507,14 +511,15 @@ def remove_terrain_layer_node(terrain_info_object: Object, nodes, nodes_index: i
507511
508512
509513def move_terrain_layer_node (direction : str , nodes , nodes_index : int ) -> int :
510- if direction == 'UP' :
511- if nodes_index > 0 :
512- nodes .move (nodes_index , nodes_index - 1 )
513- nodes_index -= 1
514- elif direction == 'DOWN' :
515- if nodes_index < len (nodes ) - 1 :
516- nodes .move (nodes_index , nodes_index + 1 )
517- nodes_index += 1
514+ match direction :
515+ case 'UP' :
516+ if nodes_index > 0 :
517+ nodes .move (nodes_index , nodes_index - 1 )
518+ nodes_index -= 1
519+ case 'DOWN' :
520+ if nodes_index < len (nodes ) - 1 :
521+ nodes .move (nodes_index , nodes_index + 1 )
522+ nodes_index += 1
518523 return nodes_index
519524
520525
0 commit comments