def res_add_placement_helper(inst: Entity, res: Property): """Add a placement helper to a specific tile. `Offset` and `normal` specify the position and direction out of the surface the helper should be added to. If `upDir` is specified, this is the direction of the top of the portal. """ orient = Matrix.from_angle(Angle.from_str(inst['angles'])) pos = conditions.resolve_offset(inst, res['offset', '0 0 0'], zoff=-64) normal = res.vec('normal', 0, 0, 1) @ orient up_dir: Vec | None try: up_dir = Vec.from_str(res['upDir']) @ orient except LookupError: up_dir = None try: tile = tiling.TILES[(pos - 64 * normal).as_tuple(), normal.as_tuple()] except KeyError: LOGGER.warning('No tile at {} @ {}', pos, normal) return tile.add_portal_helper(up_dir)
def _fill_norm_rotations() -> dict[tuple[tuple[float, float, float], tuple[ float, float, float]], Matrix, ]: """Given a norm->norm rotation, return the angles producing that.""" rotations = {} for norm_ax in 'xyz': for norm_mag in [-1, +1]: norm = Vec.with_axes(norm_ax, norm_mag) for angle_ax in ('pitch', 'yaw', 'roll'): for angle_mag in (-90, 90): angle = Matrix.from_angle( Angle.with_axes(angle_ax, angle_mag)) new_norm = norm @ angle if new_norm != norm: rotations[norm.as_tuple(), new_norm.as_tuple()] = angle # Assign a null rotation as well. rotations[norm.as_tuple(), norm.as_tuple()] = Matrix() rotations[norm.as_tuple(), (-norm).as_tuple()] = Matrix() return rotations
def res_antigel(inst: Entity) -> None: """Implement the Antigel marker.""" inst.remove() origin = Vec.from_str(inst['origin']) orient = Matrix.from_angle(Angle.from_str(inst['angles'])) pos = round(origin - 128 * orient.up(), 6) norm = round(orient.up(), 6) try: tiling.TILES[pos.as_tuple(), norm.as_tuple()].is_antigel = True except KeyError: LOGGER.warning('No tile to set antigel at {}, {}', pos, norm) texturing.ANTIGEL_LOCS.add((origin // 128).as_tuple())
def res_set_tile(inst: Entity, res: Property) -> None: """Set 4x4 parts of a tile to the given values. `Offset` defines the position of the upper-left tile in the grid. Each `Tile` section defines a row of the positions to edit like so: "Tile" "bbbb" "Tile" "b..b" "Tile" "b..b" "Tile" "bbbb" If `Force` is true, the specified tiles will override any existing ones and create the tile if necessary. Otherwise they will be merged in - white/black tiles will not replace tiles set to nodraw or void for example. `chance`, if specified allows producing irregular tiles by randomly not changing the tile. If you need less regular placement (other orientation, precise positions) use a bee2_template_tilesetter in a template. Allowed tile characters: - `W`: White tile. - `w`: White 4x4 only tile. - `B`: Black tile. - `b`: Black 4x4 only tile. - `g`: The side/bottom of goo pits. - `n`: Nodraw surface. - `i`: Invert the tile surface, if black/white. - `1`: Convert to a 1x1 only tile, if a black/white tile. - `4`: Convert to a 4x4 only tile, if a black/white tile. - `.`: Void (remove the tile in this position). - `_` or ` `: Placeholder (don't modify this space). - `x`: Cutout Tile (Broken) - `o`: Cutout Tile (Partial) """ origin = Vec.from_str(inst['origin']) orient = Matrix.from_angle(Angle.from_str(inst['angles'])) offset = (res.vec('offset', -48, 48) - (0, 0, 64)) @ orient + origin norm = round(orient.up(), 6) force_tile = res.bool('force') tiles: list[str] = [ row.value for row in res if row.name in ('tile', 'tiles') ] if not tiles: raise ValueError('No "tile" parameters in SetTile!') chance = srctools.conv_float(res['chance', '100'].rstrip('%'), 100.0) if chance < 100.0: rng = rand.seed(b'tile', inst, res['seed', '']) else: rng = None for y, row in enumerate(tiles): for x, val in enumerate(row): if val in '_ ': continue if rng is not None and rng.uniform(0, 100) > chance: continue pos = Vec(32 * x, -32 * y, 0) @ orient + offset if val == '4': size = tiling.TileSize.TILE_4x4 elif val == '1': size = tiling.TileSize.TILE_1x1 elif val == 'i': size = None else: try: new_tile = tiling.TILETYPE_FROM_CHAR[val] except KeyError: LOGGER.warning('Unknown tiletype "{}"!', val) else: tiling.edit_quarter_tile(pos, norm, new_tile, force_tile) continue # Edit the existing tile. try: tile, u, v = tiling.find_tile(pos, norm, force_tile) except KeyError: LOGGER.warning( 'Expected tile, but none found: {}, {}', pos, norm, ) continue if size is None: # Invert the tile. tile[u, v] = tile[u, v].inverted continue # Unless forcing is enabled don't alter the size of GOO_SIDE. if tile[u, v].is_tile and tile[u, v] is not tiling.TileType.GOO_SIDE: tile[u, v] = tiling.TileType.with_color_and_size( size, tile[u, v].color) elif force_tile: # If forcing, make it black. Otherwise no need to change. tile[u, v] = tiling.TileType.with_color_and_size( size, tiling.Portalable.BLACK)
def res_fix_rotation_axis(vmf: VMF, ent: Entity, res: Property): """Properly setup rotating brush entities to match the instance. This uses the orientation of the instance to determine the correct spawnflags to make it rotate in the correct direction. This can either modify an existing entity (which may be in an instance), or generate a new one. The generated brush will be 2x2x2 units large, and always set to be non-solid. For both modes: - `Axis`: specifies the rotation axis local to the instance. - `Reversed`: If set, flips the direction around. - `Classname`: Specifies which entity, since the spawnflags required varies. For application to an existing entity: - `ModifyTarget`: The local name of the entity to modify. For brush generation mode: - `Pos` and `name` are local to the instance, and will set the `origin` and `targetname` respectively. - `Keys` are any other keyvalues to be be set. - `Flags` sets additional spawnflags. Multiple values may be separated by `+`, and will be added together. - `Classname` specifies which entity will be created, as well as which other values will be set to specify the correct orientation. - `AddOut` is used to add outputs to the generated entity. It takes the options `Output`, `Target`, `Input`, `Inst_targ`, `Param` and `Delay`. If `Inst_targ` is defined, it will be used with the input to construct an instance proxy input. If `OnceOnly` is set, the output will be deleted when fired. Permitted entities: * [`func_door_rotating`](https://developer.valvesoftware.com/wiki/func_door_rotating) * [`func_platrot`](https://developer.valvesoftware.com/wiki/func_platrot) * [`func_rot_button`](https://developer.valvesoftware.com/wiki/func_rot_button) * [`func_rotating`](https://developer.valvesoftware.com/wiki/func_rotating) * [`momentary_rot_button`](https://developer.valvesoftware.com/wiki/momentary_rot_button) """ des_axis = res['axis', 'z'].casefold() reverse = res.bool('reversed') door_type = res['classname', 'func_door_rotating'] orient = Matrix.from_angle(Angle.from_str(ent['angles'])) axis = round(Vec.with_axes(des_axis, 1) @ orient, 6) if axis.x > 0 or axis.y > 0 or axis.z > 0: # If it points forward, we need to reverse the rotating door reverse = not reverse axis = abs(axis) try: flag_values = FLAG_ROTATING[door_type] except KeyError: LOGGER.warning('Unknown rotating brush type "{}"!', door_type) return name = res['ModifyTarget', ''] door_ent: Entity | None if name: name = conditions.local_name(ent, name) setter_loc = ent['origin'] door_ent = None spawnflags = 0 else: # Generate a brush. name = conditions.local_name(ent, res['name', '']) pos = res.vec('Pos') @ Angle.from_str(ent['angles', '0 0 0']) pos += Vec.from_str(ent['origin', '0 0 0']) setter_loc = str(pos) door_ent = vmf.create_ent( classname=door_type, targetname=name, origin=pos.join(' '), ) # Extra stuff to apply to the flags (USE, toggle, etc) spawnflags = sum( map( # Add together multiple values srctools.conv_int, res['flags', '0'].split('+') # Make the door always non-solid! )) | flag_values.get('solid_flags', 0) conditions.set_ent_keys(door_ent, ent, res) for output in res.find_all('AddOut'): door_ent.add_out( Output( out=output['Output', 'OnUse'], inp=output['Input', 'Use'], targ=output['Target', ''], inst_in=output['Inst_targ', None], param=output['Param', ''], delay=srctools.conv_float(output['Delay', '']), times=(1 if srctools.conv_bool(output['OnceOnly', False]) else -1), )) # Generate brush door_ent.solids = [vmf.make_prism(pos - 1, pos + 1).solid] # Add or remove flags as needed for flag, value in zip( ('x', 'y', 'z', 'rev'), [axis.x > 1e-6, axis.y > 1e-6, axis.z > 1e-6, reverse], ): if flag not in flag_values: continue if door_ent is not None: if value: spawnflags |= flag_values[flag] else: spawnflags &= ~flag_values[flag] else: # Place a KV setter to set this. vmf.create_ent( 'comp_kv_setter', origin=setter_loc, target=name, mode='flags', kv_name=flag_values[flag], kv_value_global=value, ) if door_ent is not None: door_ent['spawnflags'] = spawnflags # This ent uses a keyvalue for reversing... if door_type == 'momentary_rot_button': vmf.create_ent( 'comp_kv_setter', origin=setter_loc, target=name, mode='kv', kv_name='StartDirection', kv_value_global='1' if reverse else '-1', )
def res_import_template(vmf: VMF, coll: Collisions, res: Property): """Import a template VMF file, retexturing it to match orientation. It will be placed overlapping the given instance. If no block is used, only ID can be specified. Options: - `ID`: The ID of the template to be inserted. Add visgroups to additionally add after a colon, comma-seperated (`temp_id:vis1,vis2`). Either section, or the whole value can be a `$fixup`. - `angles`: Override the instance rotation, so it is always rotated this much. - `rotation`: Apply the specified rotation before the instance's rotation. - `offset`: Offset the template from the instance's position. - `force`: a space-seperated list of overrides. If 'white' or 'black' is present, the colour of tiles will be overridden. If `invert` is added, white/black tiles will be swapped. If a tile size (`2x2`, `4x4`, `wall`, `special`) is included, all tiles will be switched to that size (if not a floor/ceiling). If 'world' or 'detail' is present, the brush will be forced to that type. - `replace`: A block of template material -> replacement textures. This is case insensitive - any texture here will not be altered otherwise. If the material starts with a `#`, it is instead a list of face IDs separated by spaces. If the result evaluates to "", no change occurs. Both can be $fixups (parsed first). - `bindOverlay`: Bind overlays in this template to the given surface, and bind overlays on a surface to surfaces in this template. The value specifies the offset to the surface, where 0 0 0 is the floor position. It can also be a block of multiple positions. - `alignBindOverlay`: If set, align the bindOverlay offsets to the grid. - `keys`/`localkeys`: If set, a brush entity will instead be generated with these values. This overrides force world/detail. Specially-handled keys: - `"origin"`, offset automatically. - `"movedir"` on func_movelinear - set a normal surrounded by `<>`, this gets replaced with angles. - `colorVar`: If this fixup var is set to `white` or `black`, that colour will be forced. If the value is `<editor>`, the colour will be chosen based on the color of the surface for ItemButtonFloor, funnels or entry/exit frames. - `invertVar`: If this fixup value is true, tile colour will be swapped to the opposite of the current force option. This applies after colorVar. - `visgroup`: Sets how visgrouped parts are handled. Several values are possible: - A property block: Each name should match a visgroup, and the value should be a block of flags that if true enables that group. - 'none' (default): All extra groups are ignored. - 'choose': One group is chosen randomly. - a number: The percentage chance for each visgroup to be added. - `visgroup_force_var`: If set and True, visgroup is ignored and all groups are added. - `pickerVars`: If this is set, the results of colorpickers can be read out of the template. The key is the name of the picker, the value is the fixup name to write to. The output is either 'white', 'black' or ''. - `outputs`: Add outputs to the brush ent. Syntax is like VMFs, and all names are local to the instance. - `senseOffset`: If set, colorpickers and tilesetters will be treated as being offset by this amount. """ if res.has_children(): orig_temp_id = res['id'] else: orig_temp_id = res.value res = Property('TemplateBrush', []) force = res['force', ''].casefold().split() if 'white' in force: conf_force_colour = texturing.Portalable.white elif 'black' in force: conf_force_colour = texturing.Portalable.black elif 'invert' in force: conf_force_colour = 'INVERT' else: conf_force_colour = None if 'world' in force: force_type = template_brush.TEMP_TYPES.world elif 'detail' in force: force_type = template_brush.TEMP_TYPES.detail else: force_type = template_brush.TEMP_TYPES.default force_grid: texturing.TileSize | None size: texturing.TileSize for size in texturing.TileSize: if size in force: force_grid = size break else: force_grid = None if 'bullseye' in force: surf_cat = texturing.GenCat.BULLSEYE elif 'special' in force or 'panel' in force: surf_cat = texturing.GenCat.PANEL else: surf_cat = texturing.GenCat.NORMAL replace_tex: dict[str, list[str]] = {} for prop in res.find_block('replace', or_blank=True): replace_tex.setdefault(prop.name, []).append(prop.value) if 'replaceBrush' in res: LOGGER.warning( 'replaceBrush command used for template "{}", which is no ' 'longer used.', orig_temp_id, ) bind_tile_pos = [ # So it's the floor block location. Vec.from_str(value) - (0, 0, 128) for value in res.find_key('BindOverlay', or_blank=True).as_array() ] align_bind_overlay = res.bool('alignBindOverlay') key_values = res.find_block("Keys", or_blank=True) if key_values: key_block = Property("", [ key_values, res.find_block("LocalKeys", or_blank=True), ]) # Ensure we have a 'origin' keyvalue - we automatically offset that. if 'origin' not in key_values: key_values['origin'] = '0 0 0' # Spawn everything as detail, so they get put into a brush # entity. force_type = template_brush.TEMP_TYPES.detail outputs = [Output.parse(prop) for prop in res.find_children('Outputs')] else: key_block = None outputs = [] # None = don't add any more. visgroup_func: Callable[[Random, list[str]], Iterable[str]] | None = None try: # allow both spellings. visgroup_prop = res.find_key('visgroups') except NoKeyError: visgroup_prop = res.find_key('visgroup', 'none') if visgroup_prop.has_children(): visgroup_instvars = list(visgroup_prop) else: visgroup_instvars = [] visgroup_mode = res['visgroup', 'none'].casefold() # Generate the function which picks which visgroups to add to the map. if visgroup_mode == 'none': pass elif visgroup_mode == 'choose': def visgroup_func(rng: Random, groups: list[str]) -> Iterable[str]: """choose = add one random group.""" return [rng.choice(groups)] else: percent = srctools.conv_float(visgroup_mode.rstrip('%'), 0.00) if percent > 0.0: def visgroup_func(rng: Random, groups: list[str]) -> Iterable[str]: """Number = percent chance for each to be added""" for group in sorted(groups): if rng.uniform(0, 100) <= percent: yield group picker_vars = [(prop.real_name, prop.value) for prop in res.find_children('pickerVars')] try: ang_override = to_matrix(Angle.from_str(res['angles'])) except LookupError: ang_override = None try: rotation = to_matrix(Angle.from_str(res['rotation'])) except LookupError: rotation = Matrix() offset = res['offset', '0 0 0'] invert_var = res['invertVar', ''] color_var = res['colorVar', ''] if color_var.casefold() == '<editor>': color_var = '<editor>' # If true, force visgroups to all be used. visgroup_force_var = res['forceVisVar', ''] sense_offset = res.vec('senseOffset') def place_template(inst: Entity) -> None: """Place a template.""" temp_id = inst.fixup.substitute(orig_temp_id) # Special case - if blank, just do nothing silently. if not temp_id: return temp_name, visgroups = template_brush.parse_temp_name(temp_id) try: template = template_brush.get_template(temp_name) except template_brush.InvalidTemplateName: # If we did lookup, display both forms. if temp_id != orig_temp_id: LOGGER.warning('{} -> "{}" is not a valid template!', orig_temp_id, temp_name) else: LOGGER.warning('"{}" is not a valid template!', temp_name) # We don't want an error, just quit. return for vis_flag_block in visgroup_instvars: if all( conditions.check_flag(flag, coll, inst) for flag in vis_flag_block): visgroups.add(vis_flag_block.real_name) force_colour = conf_force_colour if color_var == '<editor>': # Check traits for the colour it should be. traits = instance_traits.get(inst) if 'white' in traits: force_colour = texturing.Portalable.white elif 'black' in traits: force_colour = texturing.Portalable.black else: LOGGER.warning( '"{}": Instance "{}" ' "isn't one with inherent color!", temp_id, inst['file'], ) elif color_var: color_val = conditions.resolve_value(inst, color_var).casefold() if color_val == 'white': force_colour = texturing.Portalable.white elif color_val == 'black': force_colour = texturing.Portalable.black # else: no color var if srctools.conv_bool(conditions.resolve_value(inst, invert_var)): force_colour = template_brush.TEMP_COLOUR_INVERT[conf_force_colour] # else: False value, no invert. if ang_override is not None: orient = ang_override else: orient = rotation @ Angle.from_str(inst['angles', '0 0 0']) origin = conditions.resolve_offset(inst, offset) # If this var is set, it forces all to be included. if srctools.conv_bool( conditions.resolve_value(inst, visgroup_force_var)): visgroups.update(template.visgroups) elif visgroup_func is not None: visgroups.update( visgroup_func( rand.seed(b'temp', template.id, origin, orient), list(template.visgroups), )) LOGGER.debug('Placing template "{}" at {} with visgroups {}', template.id, origin, visgroups) temp_data = template_brush.import_template( vmf, template, origin, orient, targetname=inst['targetname'], force_type=force_type, add_to_map=True, coll=coll, additional_visgroups=visgroups, bind_tile_pos=bind_tile_pos, align_bind=align_bind_overlay, ) if key_block is not None: conditions.set_ent_keys(temp_data.detail, inst, key_block) br_origin = Vec.from_str(key_block.find_key('keys')['origin']) br_origin.localise(origin, orient) temp_data.detail['origin'] = br_origin move_dir = temp_data.detail['movedir', ''] if move_dir.startswith('<') and move_dir.endswith('>'): move_dir = Vec.from_str(move_dir) @ orient temp_data.detail['movedir'] = move_dir.to_angle() for out in outputs: out = out.copy() out.target = conditions.local_name(inst, out.target) temp_data.detail.add_out(out) template_brush.retexture_template( temp_data, origin, inst.fixup, replace_tex, force_colour, force_grid, surf_cat, sense_offset, ) for picker_name, picker_var in picker_vars: picker_val = temp_data.picker_results.get(picker_name, None) if picker_val is not None: inst.fixup[picker_var] = picker_val.value else: inst.fixup[picker_var] = '' return place_template
def edit_panel(vmf: VMF, inst: Entity, props: Property, create: bool) -> None: """Implements SetPanelOptions and CreatePanel.""" orient = Matrix.from_angle(Angle.from_str(inst['angles'])) normal: Vec = round(props.vec('normal', 0, 0, 1) @ orient, 6) origin = Vec.from_str(inst['origin']) uaxis, vaxis = Vec.INV_AXIS[normal.axis()] points: set[tuple[float, float, float]] = set() if 'point' in props: for prop in props.find_all('point'): points.add( conditions.resolve_offset(inst, prop.value, zoff=-64).as_tuple()) elif 'pos1' in props and 'pos2' in props: pos1, pos2 = Vec.bbox( conditions.resolve_offset(inst, props['pos1', '-48 -48 0'], zoff=-64), conditions.resolve_offset(inst, props['pos2', '48 48 0'], zoff=-64), ) points.update(map(Vec.as_tuple, Vec.iter_grid(pos1, pos2, 32))) else: # Default to the full tile. points.update({(Vec(u, v, -64.0) @ orient + origin).as_tuple() for u in [-48.0, -16.0, 16.0, 48.0] for v in [-48.0, -16.0, 16.0, 48.0]}) tiles_to_uv: dict[tiling.TileDef, set[tuple[int, int]]] = defaultdict(set) for pos in points: try: tile, u, v = tiling.find_tile(Vec(pos), normal, force=create) except KeyError: continue tiles_to_uv[tile].add((u, v)) if not tiles_to_uv: LOGGER.warning('"{}": No tiles found for panels!', inst['targetname']) return # If bevels is provided, parse out the overall world positions. bevel_world: set[tuple[int, int]] | None try: bevel_prop = props.find_key('bevel') except NoKeyError: bevel_world = None else: bevel_world = set() if bevel_prop.has_children(): # Individually specifying offsets. for bevel_str in bevel_prop.as_array(): bevel_point = Vec.from_str(bevel_str) @ orient + origin bevel_world.add( (int(bevel_point[uaxis]), int(bevel_point[vaxis]))) elif srctools.conv_bool(bevel_prop.value): # Fill the bounding box. bbox_min, bbox_max = Vec.bbox(map(Vec, points)) off = Vec.with_axes(uaxis, 32, vaxis, 32) bbox_min -= off bbox_max += off for pos in Vec.iter_grid(bbox_min, bbox_max, 32): if pos.as_tuple() not in points: bevel_world.add((pos[uaxis], pos[vaxis])) # else: No bevels. panels: list[tiling.Panel] = [] for tile, uvs in tiles_to_uv.items(): if create: panel = tiling.Panel( None, inst, tiling.PanelType.NORMAL, thickness=4, bevels=(), ) panel.points = uvs tile.panels.append(panel) else: for panel in tile.panels: if panel.same_item(inst) and panel.points == uvs: break else: LOGGER.warning('No panel to modify found for "{}"!', inst['targetname']) continue panels.append(panel) pan_type = '<nothing?>' try: pan_type = conditions.resolve_value(inst, props['type']) panel.pan_type = tiling.PanelType(pan_type.lower()) except LookupError: pass except ValueError: raise ValueError('Unknown panel type "{}"!'.format(pan_type)) if 'thickness' in props: panel.thickness = srctools.conv_int( conditions.resolve_value(inst, props['thickness'])) if panel.thickness not in (2, 4, 8): raise ValueError( '"{}": Invalid panel thickess {}!\n' 'Must be 2, 4 or 8.', inst['targetname'], panel.thickness, ) if bevel_world is not None: panel.bevels.clear() for u, v in bevel_world: # Convert from world points to UV positions. u = (u - tile.pos[uaxis] + 48) // 32 v = (v - tile.pos[vaxis] + 48) // 32 # Cull outside here, we wont't use them. if -1 <= u <= 4 and -1 <= v <= 4: panel.bevels.add((u, v)) if 'offset' in props: panel.offset = conditions.resolve_offset(inst, props['offset']) panel.offset -= Vec.from_str(inst['origin']) if 'template' in props: # We only want the template inserted once. So remove it from all but one. if len(panels) == 1: panel.template = inst.fixup.substitute(props['template']) else: panel.template = '' if 'nodraw' in props: panel.nodraw = srctools.conv_bool( inst.fixup.substitute(props['nodraw'], allow_invert=True)) if 'seal' in props: panel.seal = srctools.conv_bool( inst.fixup.substitute(props['seal'], allow_invert=True)) if 'move_bullseye' in props: panel.steals_bullseye = srctools.conv_bool( inst.fixup.substitute(props['move_bullseye'], allow_invert=True)) if 'keys' in props or 'localkeys' in props: # First grab the existing ent, so we can edit it. # These should all have the same value, unless they were independently # edited with mismatching point sets. In that case destroy all those existing ones. existing_ents: set[Entity | None] = {panel.brush_ent for panel in panels} try: [brush_ent] = existing_ents except ValueError: LOGGER.warning( 'Multiple independent panels for "{}" were made, then the ' 'brush entity was edited as a group! Discarding ' 'individual ents...', inst['targetname']) for brush_ent in existing_ents: if brush_ent is not None and brush_ent in vmf.entities: brush_ent.remove() brush_ent = None if brush_ent is None: brush_ent = vmf.create_ent('') old_pos = brush_ent.keys.pop('origin', None) conditions.set_ent_keys(brush_ent, inst, props) if not brush_ent['classname']: if create: # This doesn't make sense, you could just omit the prop. LOGGER.warning( 'No classname provided for panel "{}"!', inst['targetname'], ) # Make it a world brush. brush_ent.remove() brush_ent = None else: # We want to do some post-processing. # Localise any origin value. if 'origin' in brush_ent.keys: pos = Vec.from_str(brush_ent['origin']) pos.localise( Vec.from_str(inst['origin']), Angle.from_str(inst['angles']), ) brush_ent['origin'] = pos elif old_pos is not None: brush_ent['origin'] = old_pos # If it's func_detail, clear out all the keys. # Particularly `origin`, but the others are useless too. if brush_ent['classname'] == 'func_detail': brush_ent.clear_keys() brush_ent['classname'] = 'func_detail' for panel in panels: panel.brush_ent = brush_ent