From 8b862b3fe067e65726249268071bf65aff554264 Mon Sep 17 00:00:00 2001 From: Ma Nan Date: Wed, 10 Jul 2024 12:45:04 +0800 Subject: [PATCH] feat: add primitive cutter fix: eevee shadow fix: save node toggle not work fix: color over 1.0 fail to render --- bioxelnodes/__init__.py | 2 +- .../assets/Nodes/BioxelNodes_4.1.blend | 4 +- bioxelnodes/nodes.py | 7 ++ bioxelnodes/save.py | 89 ++++++++++--------- extension/blender_manifest.toml | 2 +- pyproject.toml | 2 +- 6 files changed, 60 insertions(+), 46 deletions(-) diff --git a/bioxelnodes/__init__.py b/bioxelnodes/__init__.py index 766101a..c093c5c 100644 --- a/bioxelnodes/__init__.py +++ b/bioxelnodes/__init__.py @@ -9,7 +9,7 @@ "author": "Ma Nan", "description": "", "blender": (4, 1, 0), - "version": (0, 2, 5), + "version": (0, 2, 6), "location": "File -> Import", "warning": "", "category": "Node" diff --git a/bioxelnodes/assets/Nodes/BioxelNodes_4.1.blend b/bioxelnodes/assets/Nodes/BioxelNodes_4.1.blend index e45e938..a4a66b7 100644 --- a/bioxelnodes/assets/Nodes/BioxelNodes_4.1.blend +++ b/bioxelnodes/assets/Nodes/BioxelNodes_4.1.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:98a47b3c20b3c84bbde76395b182da5a875931dee615192400af495f47927faf -size 6159997 +oid sha256:09e23fa95ee7262a284e2539ec5873e32100116ebaa17374c0bb97923c24aeb5 +size 6508765 diff --git a/bioxelnodes/nodes.py b/bioxelnodes/nodes.py index 3ae2530..9b2a6a4 100644 --- a/bioxelnodes/nodes.py +++ b/bioxelnodes/nodes.py @@ -173,6 +173,13 @@ 'node_description': '' }, "separator", + { + 'label': 'Primitive Cutter', + 'icon': 'MOD_LINEART', + 'node_type': 'BioxelNodes_PrimitiveCutter', + 'node_description': '' + }, + "separator", { 'label': 'Plane Cutter', 'icon': 'MESH_PLANE', diff --git a/bioxelnodes/save.py b/bioxelnodes/save.py index 99cf6a9..bedd613 100644 --- a/bioxelnodes/save.py +++ b/bioxelnodes/save.py @@ -31,60 +31,67 @@ class SaveAllToShare(bpy.types.Operator): bl_label = "Save All Staged Data" bl_description = "Save all staged data for sharing" + save_layer: bpy.props.BoolProperty( + name="Save Layer VDB Cache", + default=True, + ) # type: ignore + layer_dir: bpy.props.StringProperty( name="Layer Directory", subtype='DIR_PATH', default="//" ) # type: ignore - save_node: bpy.props.BoolProperty( + save_lib: bpy.props.BoolProperty( name="Save Node Library File", default=True, ) # type: ignore - node_file_dir: bpy.props.StringProperty( + lib_dir: bpy.props.StringProperty( name="Library Directory", subtype='DIR_PATH', default="//" ) # type: ignore def execute(self, context): - files = [] - for classname in dir(bpy.types): - if CLASS_PREFIX in classname: - cls = getattr(bpy.types, classname) - files.append(cls.nodes_file) - files = list(set(files)) - - for file in files: - file_name = Path(file).name - # "//" - node_file_dir = bpy.path.abspath(self.node_file_dir) - - output_path: Path = Path(node_file_dir, file_name).resolve() - source_path: Path = Path(file).resolve() - - if output_path != source_path: - shutil.copy(source_path, output_path) - - for lib in bpy.data.libraries: - lib_path = Path(bpy.path.abspath(lib.filepath)).resolve() - if lib_path == source_path: - blend_path = Path(bpy.path.abspath("//")).resolve() - lib.filepath = bpy.path.relpath( - str(output_path), start=str(blend_path)) - - self.report({"INFO"}, f"Successfully saved to {output_path}") - - layers = get_all_layers() - for layer in layers: - try: - save_layer(layer, self.layer_dir) - except: - self.report( - {"WARNING"}, f"Fail to save {layer.name}, skiped") - - self.report({"INFO"}, f"Successfully saved bioxel layers.") + if self.save_lib: + files = [] + for classname in dir(bpy.types): + if CLASS_PREFIX in classname: + cls = getattr(bpy.types, classname) + files.append(cls.nodes_file) + files = list(set(files)) + + for file in files: + file_name = Path(file).name + # "//" + lib_dir = bpy.path.abspath(self.lib_dir) + + output_path: Path = Path(lib_dir, file_name).resolve() + source_path: Path = Path(file).resolve() + + if output_path != source_path: + shutil.copy(source_path, output_path) + + for lib in bpy.data.libraries: + lib_path = Path(bpy.path.abspath(lib.filepath)).resolve() + if lib_path == source_path: + blend_path = Path(bpy.path.abspath("//")).resolve() + lib.filepath = bpy.path.relpath( + str(output_path), start=str(blend_path)) + + self.report({"INFO"}, f"Successfully saved to {output_path}") + + if self.save_layer: + layers = get_all_layers() + for layer in layers: + try: + save_layer(layer, self.layer_dir) + except: + self.report( + {"WARNING"}, f"Fail to save {layer.name}, skiped") + + self.report({"INFO"}, f"Successfully saved bioxel layers.") return {'FINISHED'} @@ -100,11 +107,11 @@ def poll(cls, context): def draw(self, context): layout = self.layout panel = layout.box() + panel.prop(self, "save_layer") panel.prop(self, "layer_dir") panel = layout.box() - panel.prop(self, "save_node") - panel.prop(self, "node_file_dir") - layout.label(text="Save your blender file first.") + panel.prop(self, "save_lib") + panel.prop(self, "lib_dir") def save_layer(layer, output_dir): diff --git a/extension/blender_manifest.toml b/extension/blender_manifest.toml index 1dfcbb3..77857e3 100644 --- a/extension/blender_manifest.toml +++ b/extension/blender_manifest.toml @@ -3,7 +3,7 @@ schema_version = "1.0.0" # Example of manifest file for a Blender extension # Change the values according to your extension id = "bioxelnodes" -version = "0.2.5" +version = "0.2.6" name = "Bioxel Nodes" tagline = "For scientific volumetric data visualization in Blender" maintainer = "Ma Nan " diff --git a/pyproject.toml b/pyproject.toml index dc265e5..7ac030e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "bioxelnodes" -version = "0.2.5" +version = "0.2.6" description = "" authors = ["Ma Nan "] license = "MIT"