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",
"description": "",
"blender": (4, 1, 0),
"version": (0, 2, 5),
"version": (0, 2, 6),
"location": "File -> Import",
"warning": "",
"category": "Node"

View File

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

View File

@@ -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))
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
# "//"
node_file_dir = bpy.path.abspath(self.node_file_dir)
for file in files:
file_name = Path(file).name
# "//"
lib_dir = bpy.path.abspath(self.lib_dir)
output_path: Path = Path(node_file_dir, file_name).resolve()
source_path: Path = Path(file).resolve()
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)
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))
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}")
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")
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.")
self.report({"INFO"}, f"Successfully saved bioxel layers.")
return {'FINISHED'}
@@ -100,11 +107,11 @@ class SaveAllToShare(bpy.types.Operator):
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):