Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions src/bonsai/bonsai/bim/module/style/prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ def update_shader_graph(self: Union["Texture", "BIMStylesProperties"], context:
tool.Loader.create_surface_style_with_textures(material, shading_data, textures_data)


def _make_clear_null_updater(null_prop: str):
def _update(self: "BIMStylesProperties", context: bpy.types.Context) -> None:
self[null_prop] = False
update_shader_graph(self, context)

return _update


update_diffuse_colour = _make_clear_null_updater("is_diffuse_colour_null")
update_specular_colour = _make_clear_null_updater("is_specular_colour_null")
update_specular_highlight_value = _make_clear_null_updater("is_specular_highlight_null")


UV_MODES = [
("UV", "UV", _("Actual UV data presented on the geometry")),
("Generated", "Generated", _("Automatically-generated UV from the vertex positions of the mesh")),
Expand Down Expand Up @@ -221,24 +234,29 @@ class BIMStylesProperties(PropertyGroup):
transparency: bpy.props.FloatProperty(
name="Transparency", default=0.0, min=0.0, max=1.0, update=update_shader_graph
)
# TODO: do something on null?
is_diffuse_colour_null: BoolProperty(name="Is Null")
is_diffuse_colour_null: BoolProperty(name="Is Null", update=update_shader_graph)
diffuse_colour_class: EnumProperty(
items=[(x, x, "") for x in get_args(ColourClass)],
name="Diffuse Colour Class",
update=update_shader_graph,
update=update_diffuse_colour,
)
diffuse_colour: bpy.props.FloatVectorProperty(
name="Diffuse Colour", subtype="COLOR", default=(1, 1, 1), min=0.0, max=1.0, size=3, update=update_shader_graph
name="Diffuse Colour",
subtype="COLOR",
default=(1, 1, 1),
min=0.0,
max=1.0,
size=3,
update=update_diffuse_colour,
)
diffuse_colour_ratio: bpy.props.FloatProperty(
name="Diffuse Ratio", default=0.0, min=0.0, max=1.0, update=update_shader_graph
name="Diffuse Ratio", default=0.0, min=0.0, max=1.0, update=update_diffuse_colour
)
is_specular_colour_null: BoolProperty(name="Is Null")
is_specular_colour_null: BoolProperty(name="Is Null", update=update_shader_graph)
specular_colour_class: EnumProperty(
items=[(x, x, "") for x in get_args(ColourClass)],
name="Specular Colour Class",
update=update_shader_graph,
update=update_specular_colour,
default="IfcNormalisedRatioMeasure",
)
specular_colour: bpy.props.FloatVectorProperty(
Expand All @@ -248,24 +266,24 @@ class BIMStylesProperties(PropertyGroup):
min=0.0,
max=1.0,
size=3,
update=update_shader_graph,
update=update_specular_colour,
)
specular_colour_ratio: bpy.props.FloatProperty(
name="Specular Ratio",
description="Used as Metallic value in PHYSICAL Reflectance Method",
default=0.0,
min=0.0,
max=1.0,
update=update_shader_graph,
update=update_specular_colour,
)
is_specular_highlight_null: BoolProperty(name="Is Null")
is_specular_highlight_null: BoolProperty(name="Is Null", update=update_shader_graph)
specular_highlight: bpy.props.FloatProperty(
name="Specular Highlight",
description="Used as Roughness value in PHYSICAL Reflectance Method",
default=0.0,
min=0.0,
max=1.0,
update=update_shader_graph,
update=update_specular_highlight_value,
)
reflectance_method: EnumProperty(
name="Reflectance Method",
Expand Down
5 changes: 5 additions & 0 deletions src/bonsai/bonsai/tool/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ def get_shading_style_data_from_props(cls) -> dict[str, Any]:

available_props = props.bl_rna.properties.keys()
for prop_blender, prop_ifc in STYLE_PROPS_MAP.items():
null_prop_name = f"is_{prop_blender}_null"
if null_prop_name in available_props and getattr(props, null_prop_name):
surface_style_data[prop_ifc] = None
continue

class_prop_name = f"{prop_blender}_class"

# get detailed color properties if available
Expand Down
Loading