docs: v1.0.0
This commit is contained in:
Binary file not shown.
BIN
bioxelnodes/assets/Nodes/BioxelNodes_v1.0.0.blend
LFS
Normal file
BIN
bioxelnodes/assets/Nodes/BioxelNodes_v1.0.0.blend
LFS
Normal file
Binary file not shown.
Binary file not shown.
@@ -2,7 +2,7 @@ from ast import literal_eval
|
||||
from pathlib import Path
|
||||
import bpy
|
||||
|
||||
from ..constants import NODE_LIB_FILEPATH, VERSION
|
||||
from ..constants import NODE_LIB_DIRPATH, VERSIONS
|
||||
from ..utils import get_cache_dir
|
||||
|
||||
|
||||
@@ -215,31 +215,46 @@ def get_file_prop(prop):
|
||||
return props.get(prop)
|
||||
|
||||
|
||||
def get_node_version():
|
||||
node_version = get_file_prop("node_version")
|
||||
return literal_eval(node_version) if node_version else None
|
||||
|
||||
|
||||
def is_incompatible():
|
||||
if get_file_prop("addon_version") is None:
|
||||
node_version = get_node_version()
|
||||
if node_version is None:
|
||||
for node_group in bpy.data.node_groups:
|
||||
if node_group.name.startswith("BioxelNodes"):
|
||||
return True
|
||||
else:
|
||||
addon_version = literal_eval(get_file_prop("addon_version"))
|
||||
if addon_version[0] != VERSION[0]\
|
||||
or addon_version[1] != VERSION[1]:
|
||||
addon_version = VERSIONS[0]["node_version"]
|
||||
if node_version[0] != addon_version[0]\
|
||||
or node_version[1] != addon_version[1]:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def get_node_lib_path(node_version):
|
||||
version_str = "v"+".".join([str(i) for i in list(node_version)])
|
||||
lib_filename = f"BioxelNodes_{version_str}.blend"
|
||||
return Path(NODE_LIB_DIRPATH,
|
||||
lib_filename).resolve()
|
||||
|
||||
|
||||
def local_lib_not_updated():
|
||||
addon_version = VERSIONS[0]["node_version"]
|
||||
addon_lib_path = get_node_lib_path(addon_version)
|
||||
|
||||
use_local = False
|
||||
for node_group in bpy.data.node_groups:
|
||||
if node_group.name.startswith("BioxelNodes"):
|
||||
node_group_lib = node_group.library
|
||||
if node_group_lib:
|
||||
abs_filepath = bpy.path.abspath(node_group_lib.filepath)
|
||||
_local_lib_file = Path(abs_filepath).resolve().as_posix()
|
||||
if _local_lib_file != NODE_LIB_FILEPATH.as_posix():
|
||||
lib = node_group.library
|
||||
if lib:
|
||||
lib_path = Path(bpy.path.abspath(lib.filepath)).resolve()
|
||||
if lib_path != addon_lib_path:
|
||||
use_local = True
|
||||
break
|
||||
|
||||
addon_version = literal_eval(get_file_prop("addon_version"))
|
||||
not_update = addon_version != VERSION
|
||||
return use_local and not_update
|
||||
|
||||
not_update = get_node_version() != addon_version
|
||||
return use_local and not_update
|
||||
|
||||
@@ -92,7 +92,7 @@ def add_layers(layers: list[Layer],
|
||||
layer_obj = layer_to_obj(layer, container_obj, cache_dir)
|
||||
fetch_node = add_node_to_graph("FetchLayer",
|
||||
node_group,
|
||||
get_use_link())
|
||||
use_link=get_use_link())
|
||||
fetch_node.label = get_layer_prop_value(layer_obj, "name")
|
||||
fetch_node.inputs[0].default_value = layer_obj
|
||||
|
||||
|
||||
@@ -172,7 +172,9 @@ def layer_to_obj(layer: Layer,
|
||||
socket_type="NodeSocketGeometry")
|
||||
modifier.node_group = node_group
|
||||
|
||||
layer_node = add_node_to_graph("_Layer", node_group, get_use_link())
|
||||
layer_node = add_node_to_graph("_Layer",
|
||||
node_group,
|
||||
use_link=get_use_link())
|
||||
|
||||
layer_node.inputs['name'].default_value = layer.name
|
||||
layer_node.inputs['shape'].default_value = layer.shape
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import bpy
|
||||
|
||||
from .common import get_file_prop, set_file_prop
|
||||
from .common import get_file_prop, get_node_lib_path, set_file_prop
|
||||
from ..exceptions import Incompatible, NoFound
|
||||
|
||||
from ..constants import NODE_LIB_FILEPATH, VERSION
|
||||
from ..constants import VERSIONS
|
||||
|
||||
|
||||
def get_node_group(node_type: str, use_link=True):
|
||||
@@ -13,26 +12,27 @@ def get_node_group(node_type: str, use_link=True):
|
||||
# node_group = bpy.data.node_groups[node_type]
|
||||
# return node_group
|
||||
|
||||
if get_file_prop("addon_version") is None:
|
||||
set_file_prop("addon_version", VERSION)
|
||||
# added node is always from latest node version
|
||||
addon_version = VERSIONS[0]["node_version"]
|
||||
addon_lib_path = get_node_lib_path(addon_version)
|
||||
|
||||
local_lib_file = None
|
||||
addon_lib_file = NODE_LIB_FILEPATH.as_posix()
|
||||
if get_file_prop("node_version") is None:
|
||||
set_file_prop("node_version", addon_version)
|
||||
|
||||
local_lib_path = None
|
||||
for node_group in bpy.data.node_groups:
|
||||
if node_group.name.startswith("BioxelNodes"):
|
||||
node_group_lib = node_group.library
|
||||
if node_group_lib:
|
||||
abs_filepath = bpy.path.abspath(node_group_lib.filepath)
|
||||
_local_lib_file = Path(abs_filepath).resolve().as_posix()
|
||||
if _local_lib_file != addon_lib_file:
|
||||
local_lib_file = _local_lib_file
|
||||
lib = node_group.library
|
||||
if lib:
|
||||
lib_path = Path(bpy.path.abspath(lib.filepath)).resolve()
|
||||
if lib_path != addon_lib_path:
|
||||
local_lib_path = lib_path
|
||||
break
|
||||
|
||||
# local lib first
|
||||
lib_file = local_lib_file or addon_lib_file
|
||||
lib_path = local_lib_path or addon_lib_path
|
||||
bpy.ops.wm.append('EXEC_DEFAULT',
|
||||
directory=f"{lib_file}/NodeTree",
|
||||
directory=f"{lib_path.as_posix()}/NodeTree",
|
||||
filename=node_type,
|
||||
link=use_link,
|
||||
use_recursive=True,
|
||||
@@ -52,8 +52,9 @@ def assign_node_group(node, node_type: str):
|
||||
return node
|
||||
|
||||
|
||||
def add_node_to_graph(node_name: str, node_group, use_link=True):
|
||||
def add_node_to_graph(node_name: str, node_group, node_label=None, use_link=True):
|
||||
node_type = f"BioxelNodes_{node_name}"
|
||||
node_label = node_label or node_name
|
||||
|
||||
# Deselect all nodes first
|
||||
for node in node_group.nodes:
|
||||
@@ -64,5 +65,6 @@ def add_node_to_graph(node_name: str, node_group, use_link=True):
|
||||
node = node_group.nodes.new("GeometryNodeGroup")
|
||||
assign_node_group(node, node_type)
|
||||
|
||||
node.label = node_label
|
||||
node.show_options = False
|
||||
return node
|
||||
|
||||
@@ -19,10 +19,10 @@ wheels = [
|
||||
"./wheels/SimpleITK-2.3.1-cp311-cp311-macosx_10_9_x86_64.whl",
|
||||
"./wheels/SimpleITK-2.3.1-cp311-cp311-macosx_11_0_arm64.whl",
|
||||
"./wheels/SimpleITK-2.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
|
||||
"./wheels/lxml-5.2.2-cp311-cp311-win_amd64.whl",
|
||||
"./wheels/lxml-5.2.2-cp311-cp311-macosx_10_9_arm64.whl",
|
||||
"./wheels/lxml-5.2.2-cp311-cp311-macosx_10_9_x86_64.whl",
|
||||
"./wheels/lxml-5.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
|
||||
"./wheels/lxml-5.3.0-cp311-cp311-win_amd64.whl",
|
||||
"./wheels/lxml-5.3.0-cp311-cp311-macosx_10_9_arm64.whl",
|
||||
"./wheels/lxml-5.3.0-cp311-cp311-macosx_10_9_x86_64.whl",
|
||||
"./wheels/lxml-5.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
|
||||
"./wheels/h5py-3.11.0-cp311-cp311-win_amd64.whl",
|
||||
"./wheels/h5py-3.11.0-cp311-cp311-macosx_11_0_arm64.whl",
|
||||
"./wheels/h5py-3.11.0-cp311-cp311-macosx_10_9_x86_64.whl",
|
||||
@@ -34,4 +34,4 @@ wheels = [
|
||||
]
|
||||
|
||||
[permissions]
|
||||
files = "Import/export volume data from/to disk"
|
||||
files = "Import/export volume data from/to disk"
|
||||
@@ -1,9 +1,11 @@
|
||||
from pathlib import Path
|
||||
|
||||
VERSION = (1, 0, 0)
|
||||
NODE_LIB_FILENAME = "BioxelNodes_v1.0.x"
|
||||
NODE_LIB_FILEPATH = Path(Path(__file__).parent,
|
||||
f"assets/Nodes/{NODE_LIB_FILENAME}.blend").resolve()
|
||||
VERSIONS = [{"label": "Current", "node_version": (1, 0, 0)},
|
||||
{"label": "v0.3.x", "node_version": (0, 3, 3)},
|
||||
{"label": "v0.2.x", "node_version": (0, 2, 9)}]
|
||||
|
||||
NODE_LIB_DIRPATH = Path(Path(__file__).parent,
|
||||
"assets/Nodes").resolve()
|
||||
|
||||
MENU_ITEMS = [
|
||||
{
|
||||
@@ -23,9 +25,9 @@ MENU_ITEMS = [
|
||||
'description': ''
|
||||
},
|
||||
{
|
||||
'label': 'Cutout by Color',
|
||||
'label': 'Cutout by Hue',
|
||||
'icon': 'COLOR',
|
||||
'name': 'CutoutByColor',
|
||||
'name': 'CutoutByHue',
|
||||
'description': ''
|
||||
},
|
||||
"separator",
|
||||
@@ -50,7 +52,7 @@ MENU_ITEMS = [
|
||||
]
|
||||
},
|
||||
{
|
||||
'label': 'Properties',
|
||||
'label': 'Property',
|
||||
'icon': 'PROPERTIES',
|
||||
'items': [
|
||||
{
|
||||
@@ -148,7 +150,7 @@ MENU_ITEMS = [
|
||||
]
|
||||
},
|
||||
{
|
||||
'label': 'Cutters',
|
||||
'label': 'Cut',
|
||||
'icon': 'MOD_BEVEL',
|
||||
'items': [
|
||||
{
|
||||
@@ -173,31 +175,31 @@ MENU_ITEMS = [
|
||||
]
|
||||
},
|
||||
{
|
||||
'label': 'Utils',
|
||||
'label': 'Extra',
|
||||
'icon': 'MODIFIER',
|
||||
'items': [
|
||||
{
|
||||
'label': 'Pick Surface',
|
||||
'label': 'Fetch Surface',
|
||||
'icon': 'OUTLINER_OB_MESH',
|
||||
'name': 'PickSurface',
|
||||
'name': 'FetchSurface',
|
||||
'description': ''
|
||||
},
|
||||
{
|
||||
'label': 'Pick Volume',
|
||||
'label': 'Fetch Volume',
|
||||
'icon': 'OUTLINER_OB_VOLUME',
|
||||
'name': 'PickVolume',
|
||||
'name': 'FetchVolume',
|
||||
'description': ''
|
||||
},
|
||||
{
|
||||
'label': 'Pick Shape Wire',
|
||||
'label': 'Fetch Shape Wire',
|
||||
'icon': 'FILE_VOLUME',
|
||||
'name': 'PickShapeWire',
|
||||
'name': 'FetchShapeWire',
|
||||
'description': ''
|
||||
},
|
||||
{
|
||||
'label': 'Pick Bbox Wire',
|
||||
'label': 'Fetch Bbox Wire',
|
||||
'icon': 'MESH_CUBE',
|
||||
'name': 'PickBboxWire',
|
||||
'name': 'FetchBboxWire',
|
||||
'description': ''
|
||||
},
|
||||
"separator",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import bpy
|
||||
|
||||
from .constants import MENU_ITEMS, NODE_LIB_FILENAME
|
||||
from .constants import MENU_ITEMS, VERSIONS
|
||||
from .node_menu import NodeMenu
|
||||
|
||||
from .bioxelutils.common import (get_container_obj,
|
||||
get_container_layer_objs, get_layer_label,
|
||||
get_layer_prop_value)
|
||||
get_layer_prop_value, get_node_version, is_incompatible)
|
||||
from .operators.layer import (FetchLayer, RelocateLayer, RetimeLayer, RenameLayer,
|
||||
RemoveSelectedLayers, SaveSelectedLayersCache,
|
||||
ResampleLayer, SignScalar, CombineLabels,
|
||||
@@ -22,6 +22,39 @@ from .operators.misc import (CleanTemp,
|
||||
ReLinkNodeLib, RemoveAllMissingLayers, RenderSettingPreset, SaveAllLayersCache, SaveNodeLib, SliceViewer)
|
||||
|
||||
|
||||
class IncompatibleMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_INCOMPATIBLE"
|
||||
bl_label = "Bioxel Nodes"
|
||||
|
||||
def draw(self, context):
|
||||
tip_text = "please downgrade addon version."
|
||||
node_version = get_node_version()
|
||||
if node_version:
|
||||
version_str = "v"+".".join([str(i) for i in list(node_version)])
|
||||
tip_text = f"please downgrade addon version to {version_str}."
|
||||
|
||||
layout = self.layout
|
||||
layout.label(text="Incompatible node version detected.")
|
||||
layout.separator()
|
||||
layout.label(
|
||||
text="If you still want to edit this file with bioxel nodes, ")
|
||||
layout.label(text=tip_text)
|
||||
layout.separator()
|
||||
layout.label(text="If this file is archived, "
|
||||
"please relink node library, ")
|
||||
layout.label(text="check if it still works, "
|
||||
"then save node library.")
|
||||
layout.separator()
|
||||
layout.menu(ReLinkNodeLibMenu.bl_idname)
|
||||
layout.operator(SaveNodeLib.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.menu(DangerZoneMenu.bl_idname)
|
||||
|
||||
layout.separator()
|
||||
layout.menu(RenderSettingMenu.bl_idname)
|
||||
|
||||
|
||||
class FetchLayerMenu(bpy.types.Menu):
|
||||
bl_idname = "BIOXELNODES_MT_ADD_LAYER"
|
||||
bl_label = "Fetch Layer"
|
||||
@@ -122,18 +155,11 @@ class ReLinkNodeLibMenu(bpy.types.Menu):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
versions = [{"label": "v0.3.x", "filename": "BioxelNodes_v0.3.x"},
|
||||
{"label": "v0.2.x", "filename": "BioxelNodes_v0.2.x"},
|
||||
{"label": "v0.1.x", "filename": "BioxelNodes_v0.1.x"}]
|
||||
|
||||
op = layout.operator(ReLinkNodeLib.bl_idname,
|
||||
text="Current Version")
|
||||
op.node_lib_filename = NODE_LIB_FILENAME
|
||||
layout.separator()
|
||||
for version in versions:
|
||||
for index, version in enumerate(VERSIONS):
|
||||
op = layout.operator(ReLinkNodeLib.bl_idname,
|
||||
text=version["label"])
|
||||
op.node_lib_filename = version["filename"]
|
||||
op.index = index
|
||||
|
||||
|
||||
class RenderSettingMenu(bpy.types.Menu):
|
||||
@@ -185,7 +211,11 @@ class BioxelNodesTopbarMenu(bpy.types.Menu):
|
||||
|
||||
def TOPBAR(self, context):
|
||||
layout = self.layout
|
||||
layout.menu(BioxelNodesTopbarMenu.bl_idname)
|
||||
|
||||
if is_incompatible():
|
||||
layout.menu(IncompatibleMenu.bl_idname)
|
||||
else:
|
||||
layout.menu(BioxelNodesTopbarMenu.bl_idname)
|
||||
|
||||
|
||||
class NodeHeadMenu(bpy.types.Menu):
|
||||
@@ -248,6 +278,9 @@ class NodeContextMenu(bpy.types.Menu):
|
||||
|
||||
|
||||
def NODE_CONTEXT(self, context):
|
||||
if is_incompatible():
|
||||
return
|
||||
|
||||
container_obj = context.object
|
||||
is_geo_nodes = context.area.ui_type == "GeometryNodeTree"
|
||||
is_container = get_container_obj(container_obj)
|
||||
@@ -261,6 +294,9 @@ def NODE_CONTEXT(self, context):
|
||||
|
||||
|
||||
def NODE_HEAD(self, context):
|
||||
if is_incompatible():
|
||||
return
|
||||
|
||||
container_obj = context.object
|
||||
is_geo_nodes = context.area.ui_type == "GeometryNodeTree"
|
||||
is_container = get_container_obj(container_obj)
|
||||
@@ -274,6 +310,9 @@ def NODE_HEAD(self, context):
|
||||
|
||||
|
||||
def NODE_PROP(self, context):
|
||||
if is_incompatible():
|
||||
return
|
||||
|
||||
container_obj = context.object
|
||||
is_geo_nodes = context.area.ui_type == "GeometryNodeTree"
|
||||
is_container = get_container_obj(container_obj)
|
||||
@@ -354,8 +393,7 @@ def NODE_PROP(self, context):
|
||||
|
||||
def VIEW3D_TOPBAR(self, context):
|
||||
layout = self.layout
|
||||
layout.operator(SliceViewer.bl_idname,
|
||||
icon=SliceViewer.bl_icon, text="")
|
||||
layout.operator(SliceViewer.bl_idname)
|
||||
|
||||
|
||||
node_menu = NodeMenu(
|
||||
|
||||
@@ -100,7 +100,8 @@ class ExtractObject():
|
||||
output_node = get_nodes_by_type(node_group, 'NodeGroupOutput')[0]
|
||||
fetch_mesh_node = add_node_to_graph(f"Fetch{self.object_type}",
|
||||
node_group,
|
||||
get_use_link())
|
||||
node_label=f"Fetch {self.object_type}",
|
||||
use_link=get_use_link())
|
||||
|
||||
fetch_mesh_node.inputs[0].default_value = container_obj
|
||||
node_group.links.new(fetch_mesh_node.outputs[0], output_node.inputs[0])
|
||||
@@ -220,7 +221,7 @@ class AddCutter():
|
||||
# center = [find_center(axis) for axis in [x, y, z]]
|
||||
|
||||
# cutter_obj.location = center
|
||||
name = self.cutter_type.capitalize()
|
||||
name = f"{self.cutter_type.capitalize()}_Cutter"
|
||||
cutter_obj.name = name
|
||||
cutter_obj.data.name = name
|
||||
cutter_obj.visible_camera = False
|
||||
@@ -243,13 +244,14 @@ class AddCutter():
|
||||
if len(cut_nodes) == 0:
|
||||
cutter_node = add_node_to_graph("ObjectCutter",
|
||||
node_group,
|
||||
get_use_link())
|
||||
node_label=name,
|
||||
use_link=get_use_link())
|
||||
cutter_node.inputs[0].default_value = self.cutter_type.capitalize()
|
||||
cutter_node.inputs[1].default_value = cutter_obj
|
||||
|
||||
cut_node = add_node_to_graph("Cut",
|
||||
node_group,
|
||||
get_use_link())
|
||||
use_link=get_use_link())
|
||||
|
||||
output_node = get_nodes_by_type(node_group,
|
||||
'NodeGroupOutput')[0]
|
||||
@@ -362,7 +364,7 @@ class AddSlicer(bpy.types.Operator):
|
||||
|
||||
slice_node = add_node_to_graph("Slice",
|
||||
node_group,
|
||||
get_use_link())
|
||||
use_link=get_use_link())
|
||||
|
||||
slice_node.inputs[1].default_value = slicer_obj
|
||||
|
||||
@@ -412,7 +414,8 @@ class AddLocator(bpy.types.Operator):
|
||||
|
||||
parent_node = add_node_to_graph("TransformParent",
|
||||
node_group,
|
||||
get_use_link())
|
||||
node_label="Transform Parent",
|
||||
use_link=get_use_link())
|
||||
|
||||
parent_node.inputs[1].default_value = locator_obj
|
||||
|
||||
|
||||
@@ -828,7 +828,7 @@ class ImportVolumetricDataDialog(bpy.types.Operator):
|
||||
container = Container(name=name,
|
||||
layers=self.layers)
|
||||
|
||||
step_size = container.layers[0].bioxel_size[0]*5
|
||||
step_size = container.layers[0].bioxel_size[0]*10
|
||||
container_obj = container_to_obj(container,
|
||||
scene_scale=self.scene_scale,
|
||||
step_size=step_size,
|
||||
@@ -839,8 +839,8 @@ class ImportVolumetricDataDialog(bpy.types.Operator):
|
||||
# Change render setting for better result
|
||||
if is_first_import:
|
||||
bpy.ops.bioxelnodes.render_setting_preset('EXEC_DEFAULT',
|
||||
preset="preview_c")
|
||||
# bpy.ops.bioxelnodes.slice_viewer('EXEC_DEFAULT')
|
||||
preset="balance")
|
||||
bpy.context.scene.render.engine = 'CYCLES'
|
||||
|
||||
self.report({"INFO"}, "Successfully Imported")
|
||||
return {'FINISHED'}
|
||||
|
||||
@@ -3,14 +3,17 @@ import bpy
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
|
||||
from ..exceptions import NoContent
|
||||
from ..bioxel.layer import Layer
|
||||
from ..bioxelutils.node import add_node_to_graph
|
||||
from ..bioxelutils.common import (get_container_obj, get_layer_kind, get_layer_label, get_layer_name,
|
||||
get_layer_prop_value,
|
||||
get_container_layer_objs,
|
||||
get_node_type, is_missing_layer, set_layer_prop_value)
|
||||
get_node_type, is_missing_layer, move_node_to_node, set_layer_prop_value)
|
||||
from ..bioxelutils.layer import layer_to_obj, obj_to_layer
|
||||
from ..utils import get_cache_dir, copy_to_dir
|
||||
from ..utils import get_cache_dir, copy_to_dir, get_use_link
|
||||
|
||||
|
||||
def get_label_layer_selection(self, context):
|
||||
@@ -105,12 +108,17 @@ class OutputLayerOperator():
|
||||
return orig_layer
|
||||
|
||||
def add_layer_node(self, context, layer):
|
||||
orig_node = context.selected_nodes[0]
|
||||
layer_obj = layer_to_obj(layer,
|
||||
container_obj=context.object,
|
||||
cache_dir=get_cache_dir())
|
||||
|
||||
bpy.ops.bioxelnodes.fetch_layer('INVOKE_DEFAULT',
|
||||
layer_obj_name=layer_obj.name)
|
||||
node_group = context.space_data.edit_tree
|
||||
fetch_node = add_node_to_graph("FetchLayer",
|
||||
node_group,
|
||||
use_link=get_use_link())
|
||||
fetch_node.label = get_layer_prop_value(layer_obj, "name")
|
||||
fetch_node.inputs[0].default_value = layer_obj
|
||||
move_node_to_node(fetch_node, orig_node, (0, -100))
|
||||
|
||||
def execute(self, context):
|
||||
layer_obj = get_selected_layer(context)
|
||||
|
||||
@@ -2,10 +2,10 @@ import bpy
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
from ..bioxelutils.common import get_all_layer_objs, is_missing_layer, set_file_prop
|
||||
from ..bioxelutils.common import get_all_layer_objs, get_node_lib_path, get_node_version, is_missing_layer, set_file_prop
|
||||
from .layer import RemoveLayers, SaveLayersCache
|
||||
|
||||
from ..constants import NODE_LIB_FILEPATH, VERSION
|
||||
from ..constants import NODE_LIB_DIRPATH, VERSIONS
|
||||
from ..utils import get_cache_dir
|
||||
|
||||
|
||||
@@ -15,13 +15,12 @@ class ReLinkNodeLib(bpy.types.Operator):
|
||||
bl_description = "Relink all nodes to addon library source"
|
||||
bl_options = {'UNDO'}
|
||||
|
||||
node_lib_filename: bpy.props.StringProperty(
|
||||
default=""
|
||||
) # type: ignore
|
||||
index: bpy.props.IntProperty() # type: ignore
|
||||
|
||||
def execute(self, context):
|
||||
lib_filepath = Path(NODE_LIB_FILEPATH.parent,
|
||||
f"{self.node_lib_filename}.blend")
|
||||
node_version = VERSIONS[self.index]['node_version']
|
||||
lib_path = get_node_lib_path(node_version)
|
||||
|
||||
node_libs = []
|
||||
for node_group in bpy.data.node_groups:
|
||||
if node_group.name.startswith("BioxelNodes"):
|
||||
@@ -32,10 +31,12 @@ class ReLinkNodeLib(bpy.types.Operator):
|
||||
node_libs = list(set(node_libs))
|
||||
|
||||
for node_lib in node_libs:
|
||||
node_lib.filepath = str(lib_filepath)
|
||||
node_lib.filepath = str(lib_path)
|
||||
# FIXME: may cause crash
|
||||
node_lib.reload()
|
||||
|
||||
set_file_prop("node_version", node_version)
|
||||
|
||||
self.report({"INFO"}, f"Successfully relinked.")
|
||||
|
||||
return {'FINISHED'}
|
||||
@@ -54,13 +55,22 @@ class SaveNodeLib(bpy.types.Operator):
|
||||
) # type: ignore
|
||||
|
||||
def execute(self, context):
|
||||
node_version = get_node_version()
|
||||
if node_version is None:
|
||||
node_version = VERSIONS[0]["node_version"]
|
||||
else:
|
||||
if node_version not in [v["node_version"] for v in VERSIONS]:
|
||||
node_version = VERSIONS[0]["node_version"]
|
||||
|
||||
lib_path = get_node_lib_path(node_version)
|
||||
|
||||
lib_dir = bpy.path.abspath(self.lib_dir)
|
||||
local_lib_path: Path = Path(lib_dir, NODE_LIB_FILEPATH.name).resolve()
|
||||
addon_lib_path: Path = NODE_LIB_FILEPATH
|
||||
local_lib_path: Path = Path(lib_dir, lib_path.name).resolve()
|
||||
node_lib_path: Path = lib_path
|
||||
blend_path = Path(bpy.path.abspath("//")).resolve()
|
||||
|
||||
if local_lib_path != addon_lib_path:
|
||||
shutil.copy(addon_lib_path, local_lib_path)
|
||||
if local_lib_path != node_lib_path:
|
||||
shutil.copy(node_lib_path, local_lib_path)
|
||||
|
||||
libs = []
|
||||
for node_group in bpy.data.node_groups:
|
||||
@@ -73,8 +83,6 @@ class SaveNodeLib(bpy.types.Operator):
|
||||
lib.filepath = bpy.path.relpath(str(local_lib_path),
|
||||
start=str(blend_path))
|
||||
|
||||
set_file_prop("addon_version", VERSION)
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
@@ -116,55 +124,64 @@ class RenderSettingPreset(bpy.types.Operator):
|
||||
bl_options = {'UNDO'}
|
||||
|
||||
PRESETS = {
|
||||
"preview_e": "Preview (EEVEE)",
|
||||
"preview_c": "Preview (Cycles)",
|
||||
"production_e": "Production (EEVEE)",
|
||||
"production_c": "Production (Cycles)"
|
||||
"performance": "Performance",
|
||||
"balance": "Balance",
|
||||
"quality": "Quality",
|
||||
}
|
||||
|
||||
preset: bpy.props.EnumProperty(name="Preset",
|
||||
default="preview_c",
|
||||
default="balance",
|
||||
items=[(k, v, "")
|
||||
for k, v in PRESETS.items()]) # type: ignore
|
||||
|
||||
def execute(self, context):
|
||||
if self.preset == "preview_e":
|
||||
bpy.context.scene.render.engine = 'BLENDER_EEVEE_NEXT'
|
||||
if self.preset == "performance":
|
||||
# EEVEE
|
||||
bpy.context.scene.eevee.use_taa_reprojection = False
|
||||
bpy.context.scene.eevee.taa_samples = 16
|
||||
bpy.context.scene.eevee.volumetric_tile_size = '2'
|
||||
bpy.context.scene.eevee.volumetric_shadow_samples = 128
|
||||
bpy.context.scene.eevee.volumetric_samples = 128
|
||||
bpy.context.scene.eevee.volumetric_ray_depth = 16
|
||||
bpy.context.scene.eevee.volumetric_shadow_samples = 32
|
||||
bpy.context.scene.eevee.volumetric_samples = 64
|
||||
bpy.context.scene.eevee.volumetric_ray_depth = 1
|
||||
bpy.context.scene.eevee.use_volumetric_shadows = True
|
||||
|
||||
elif self.preset == "production_e":
|
||||
bpy.context.scene.render.engine = 'BLENDER_EEVEE_NEXT'
|
||||
# Cycles
|
||||
bpy.context.scene.cycles.shading_system = True
|
||||
bpy.context.scene.cycles.volume_bounces = 0
|
||||
bpy.context.scene.cycles.transparent_max_bounces = 4
|
||||
bpy.context.scene.cycles.volume_preview_step_rate = 4
|
||||
bpy.context.scene.cycles.volume_step_rate = 4
|
||||
|
||||
elif self.preset == "balance":
|
||||
# EEVEE
|
||||
bpy.context.scene.eevee.use_taa_reprojection = False
|
||||
bpy.context.scene.eevee.taa_samples = 16
|
||||
bpy.context.scene.eevee.volumetric_tile_size = '1'
|
||||
bpy.context.scene.eevee.volumetric_tile_size = '2'
|
||||
bpy.context.scene.eevee.volumetric_shadow_samples = 64
|
||||
bpy.context.scene.eevee.volumetric_samples = 128
|
||||
bpy.context.scene.eevee.volumetric_ray_depth = 8
|
||||
bpy.context.scene.eevee.use_volumetric_shadows = True
|
||||
|
||||
# Cycles
|
||||
bpy.context.scene.cycles.shading_system = True
|
||||
bpy.context.scene.cycles.volume_bounces = 4
|
||||
bpy.context.scene.cycles.transparent_max_bounces = 8
|
||||
bpy.context.scene.cycles.volume_preview_step_rate = 1
|
||||
bpy.context.scene.cycles.volume_step_rate = 1
|
||||
|
||||
elif self.preset == "quality":
|
||||
# EEVEE
|
||||
bpy.context.scene.eevee.use_taa_reprojection = False
|
||||
bpy.context.scene.eevee.volumetric_tile_size = '2'
|
||||
bpy.context.scene.eevee.volumetric_shadow_samples = 128
|
||||
bpy.context.scene.eevee.volumetric_samples = 256
|
||||
bpy.context.scene.eevee.volumetric_ray_depth = 16
|
||||
bpy.context.scene.eevee.use_volumetric_shadows = True
|
||||
|
||||
elif self.preset == "preview_c":
|
||||
bpy.context.scene.render.engine = 'CYCLES'
|
||||
# Cycles
|
||||
bpy.context.scene.cycles.shading_system = True
|
||||
bpy.context.scene.cycles.volume_bounces = 12
|
||||
bpy.context.scene.cycles.volume_bounces = 8
|
||||
bpy.context.scene.cycles.transparent_max_bounces = 16
|
||||
bpy.context.scene.cycles.volume_preview_step_rate = 1
|
||||
bpy.context.scene.cycles.volume_step_rate = 1
|
||||
# bpy.context.scene.cycles.use_fast_gi = True
|
||||
|
||||
elif self.preset == "production_c":
|
||||
bpy.context.scene.render.engine = 'CYCLES'
|
||||
bpy.context.scene.cycles.shading_system = True
|
||||
bpy.context.scene.cycles.volume_bounces = 16
|
||||
bpy.context.scene.cycles.transparent_max_bounces = 32
|
||||
bpy.context.scene.cycles.volume_preview_step_rate = 0.5
|
||||
bpy.context.scene.cycles.volume_step_rate = 0.5
|
||||
# bpy.context.scene.cycles.use_fast_gi = False
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
@@ -177,7 +194,6 @@ class SliceViewer(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
bpy.context.scene.eevee.use_taa_reprojection = False
|
||||
bpy.context.scene.eevee.taa_samples = 4
|
||||
bpy.context.scene.eevee.volumetric_tile_size = '2'
|
||||
bpy.context.scene.eevee.volumetric_shadow_samples = 128
|
||||
bpy.context.scene.eevee.volumetric_samples = 128
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import bpy
|
||||
|
||||
from ..bioxelutils.common import get_file_prop, is_incompatible, local_lib_not_updated
|
||||
from ..constants import VERSION
|
||||
from ast import literal_eval
|
||||
from ..bioxelutils.common import is_incompatible, local_lib_not_updated
|
||||
from ..bioxelutils.node import assign_node_group, get_node_group
|
||||
from ..utils import get_use_link
|
||||
|
||||
@@ -57,6 +55,6 @@ class AddNode(bpy.types.Operator):
|
||||
|
||||
if local_lib_not_updated():
|
||||
self.report({"WARNING"},
|
||||
"Local library version does not match the current addon version, which may cause problems, please save the node library again.")
|
||||
"Local node library version does not match the current addon version, which may cause problems, please save the node library again.")
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
Reference in New Issue
Block a user