avoid full shader rebuilds in intermediate property write

This commit is contained in:
falken10vdl
2026-04-27 11:39:36 +02:00
parent 9bbd2b1854
commit 6314d9c818
+29 -23
View File
@@ -782,34 +782,40 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator):
def _execute(self, context): def _execute(self, context):
self.props = tool.Style.get_style_props() self.props = tool.Style.get_style_props()
self.style = tool.Ifc.get().by_id(self.props.is_editing_style) self.style = tool.Ifc.get().by_id(self.props.is_editing_style)
prev_update_graph = self.props.update_graph
self.props["update_graph"] = False
style_elements = tool.Style.get_style_elements(self.style) try:
# NOTE: currently this operator is used to edit existing (and only existing) IfcSurfaceStyles style_elements = tool.Style.get_style_elements(self.style)
# or new or existing IfcSurfaceStyle components (shading, etc)
# which is kind of confusing.
if self.props.is_editing_class == "IfcSurfaceStyle":
self.surface_style = self.style
else:
self.surface_style = style_elements.get(self.props.is_editing_class, None)
self.shading_style = style_elements.get("IfcSurfaceStyleShading", None)
self.rendering_style = style_elements.get("IfcSurfaceStyleRendering", None)
self.texture_style = style_elements.get("IfcSurfaceStyleWithTextures", None)
if self.surface_style: # NOTE: currently this operator is used to edit existing (and only existing) IfcSurfaceStyles
result = self.edit_existing_style() # or new or existing IfcSurfaceStyle components (shading, etc)
else: # which is kind of confusing.
result = self.add_new_style() if self.props.is_editing_class == "IfcSurfaceStyle":
self.surface_style = self.style
else:
self.surface_style = style_elements.get(self.props.is_editing_class, None)
self.shading_style = style_elements.get("IfcSurfaceStyleShading", None)
self.rendering_style = style_elements.get("IfcSurfaceStyleRendering", None)
self.texture_style = style_elements.get("IfcSurfaceStyleWithTextures", None)
if result: if self.surface_style:
return result result = self.edit_existing_style()
else:
result = self.add_new_style()
tool.Style.disable_editing() if result:
core.load_styles(tool.Style, style_type=self.props.style_type) return result
# restore selected style type tool.Style.disable_editing()
material = tool.Ifc.get_object(self.style) core.load_styles(tool.Style, style_type=self.props.style_type)
msprops = tool.Style.get_material_style_props(material)
msprops.active_style_type = msprops.active_style_type # restore selected style type
material = tool.Ifc.get_object(self.style)
msprops = tool.Style.get_material_style_props(material)
msprops.active_style_type = msprops.active_style_type
finally:
self.props["update_graph"] = prev_update_graph
def edit_existing_style(self) -> None: def edit_existing_style(self) -> None:
ifc_file = tool.Ifc.get() ifc_file = tool.Ifc.get()