feat: add primitive cutter

fix: eevee shadow
fix: save node toggle not work
fix: color over 1.0 fail to render
This commit is contained in:
2024-07-10 12:45:04 +08:00
parent 99ce5c28d0
commit 8b862b3fe0
6 changed files with 53 additions and 39 deletions

View File

@@ -9,7 +9,7 @@ bl_info = {
"author": "Ma Nan", "author": "Ma Nan",
"description": "", "description": "",
"blender": (4, 1, 0), "blender": (4, 1, 0),
"version": (0, 2, 5), "version": (0, 2, 6),
"location": "File -> Import", "location": "File -> Import",
"warning": "", "warning": "",
"category": "Node" "category": "Node"

View File

@@ -173,6 +173,13 @@ MENU_ITEMS = [
'node_description': '' 'node_description': ''
}, },
"separator", "separator",
{
'label': 'Primitive Cutter',
'icon': 'MOD_LINEART',
'node_type': 'BioxelNodes_PrimitiveCutter',
'node_description': ''
},
"separator",
{ {
'label': 'Plane Cutter', 'label': 'Plane Cutter',
'icon': 'MESH_PLANE', 'icon': 'MESH_PLANE',

View File

@@ -31,60 +31,67 @@ class SaveAllToShare(bpy.types.Operator):
bl_label = "Save All Staged Data" bl_label = "Save All Staged Data"
bl_description = "Save all staged data for sharing" 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( layer_dir: bpy.props.StringProperty(
name="Layer Directory", name="Layer Directory",
subtype='DIR_PATH', subtype='DIR_PATH',
default="//" default="//"
) # type: ignore ) # type: ignore
save_node: bpy.props.BoolProperty( save_lib: bpy.props.BoolProperty(
name="Save Node Library File", name="Save Node Library File",
default=True, default=True,
) # type: ignore ) # type: ignore
node_file_dir: bpy.props.StringProperty( lib_dir: bpy.props.StringProperty(
name="Library Directory", name="Library Directory",
subtype='DIR_PATH', subtype='DIR_PATH',
default="//" default="//"
) # type: ignore ) # type: ignore
def execute(self, context): def execute(self, context):
files = [] if self.save_lib:
for classname in dir(bpy.types): files = []
if CLASS_PREFIX in classname: for classname in dir(bpy.types):
cls = getattr(bpy.types, classname) if CLASS_PREFIX in classname:
files.append(cls.nodes_file) cls = getattr(bpy.types, classname)
files = list(set(files)) files.append(cls.nodes_file)
files = list(set(files))
for file in files: for file in files:
file_name = Path(file).name file_name = Path(file).name
# "//" # "//"
node_file_dir = bpy.path.abspath(self.node_file_dir) lib_dir = bpy.path.abspath(self.lib_dir)
output_path: Path = Path(node_file_dir, file_name).resolve() output_path: Path = Path(lib_dir, file_name).resolve()
source_path: Path = Path(file).resolve() source_path: Path = Path(file).resolve()
if output_path != source_path: if output_path != source_path:
shutil.copy(source_path, output_path) shutil.copy(source_path, output_path)
for lib in bpy.data.libraries: for lib in bpy.data.libraries:
lib_path = Path(bpy.path.abspath(lib.filepath)).resolve() lib_path = Path(bpy.path.abspath(lib.filepath)).resolve()
if lib_path == source_path: if lib_path == source_path:
blend_path = Path(bpy.path.abspath("//")).resolve() blend_path = Path(bpy.path.abspath("//")).resolve()
lib.filepath = bpy.path.relpath( lib.filepath = bpy.path.relpath(
str(output_path), start=str(blend_path)) str(output_path), start=str(blend_path))
self.report({"INFO"}, f"Successfully saved to {output_path}") self.report({"INFO"}, f"Successfully saved to {output_path}")
layers = get_all_layers() if self.save_layer:
for layer in layers: layers = get_all_layers()
try: for layer in layers:
save_layer(layer, self.layer_dir) try:
except: save_layer(layer, self.layer_dir)
self.report( except:
{"WARNING"}, f"Fail to save {layer.name}, skiped") self.report(
{"WARNING"}, f"Fail to save {layer.name}, skiped")
self.report({"INFO"}, f"Successfully saved bioxel layers.") self.report({"INFO"}, f"Successfully saved bioxel layers.")
return {'FINISHED'} return {'FINISHED'}
@@ -100,11 +107,11 @@ class SaveAllToShare(bpy.types.Operator):
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
panel = layout.box() panel = layout.box()
panel.prop(self, "save_layer")
panel.prop(self, "layer_dir") panel.prop(self, "layer_dir")
panel = layout.box() panel = layout.box()
panel.prop(self, "save_node") panel.prop(self, "save_lib")
panel.prop(self, "node_file_dir") panel.prop(self, "lib_dir")
layout.label(text="Save your blender file first.")
def save_layer(layer, output_dir): def save_layer(layer, output_dir):

View File

@@ -3,7 +3,7 @@ schema_version = "1.0.0"
# Example of manifest file for a Blender extension # Example of manifest file for a Blender extension
# Change the values according to your extension # Change the values according to your extension
id = "bioxelnodes" id = "bioxelnodes"
version = "0.2.5" version = "0.2.6"
name = "Bioxel Nodes" name = "Bioxel Nodes"
tagline = "For scientific volumetric data visualization in Blender" tagline = "For scientific volumetric data visualization in Blender"
maintainer = "Ma Nan <icrdr2010@outlook.com>" maintainer = "Ma Nan <icrdr2010@outlook.com>"

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "bioxelnodes" name = "bioxelnodes"
version = "0.2.5" version = "0.2.6"
description = "" description = ""
authors = ["Ma Nan <icrdr2010@outlook.com>"] authors = ["Ma Nan <icrdr2010@outlook.com>"]
license = "MIT" license = "MIT"