diff --git a/src/python/render_daemon.py b/src/python/render_daemon.py index f1fbb5a..9b377af 100644 --- a/src/python/render_daemon.py +++ b/src/python/render_daemon.py @@ -54,21 +54,22 @@ def apply_collections(list_collections: list) -> None: if not list_collections: return - def _set_layer_collection(obj_lc: object, str_name: str, is_val: bool) -> None: + def _set_layer_collection(obj_lc: object, str_name: str, is_exclude: bool) -> None: """Parcourt recursivement les layer collections pour exclure/inclure.""" for obj_child in obj_lc.children: if obj_child.name == str_name: - obj_child.exclude = is_val + obj_child.exclude = is_exclude return - _set_layer_collection(obj_child, str_name, is_val) + _set_layer_collection(obj_child, str_name, is_exclude) obj_view_layer_collection = bpy.context.view_layer.layer_collection for obj_col in list_collections: str_name: str = obj_col["str_name"] is_hide: bool = obj_col["is_hide_render"] + is_exclude: bool = obj_col.get("is_exclude", False) bpy.data.collections[str_name].hide_render = is_hide - _set_layer_collection(obj_view_layer_collection, str_name, is_hide) + _set_layer_collection(obj_view_layer_collection, str_name, is_exclude) def process_render(obj_cmd: dict) -> None: diff --git a/src/renderer/index.html b/src/renderer/index.html index bbc8003..76598c6 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -153,7 +153,12 @@
Cameras - 0 +
+ + 0 +
@@ -170,15 +175,19 @@
Collections
+
+ + +
0
-
+
Chargez un fichier .blend diff --git a/src/renderer/scripts/App.js b/src/renderer/scripts/App.js index 11b8282..d86f9f9 100644 --- a/src/renderer/scripts/App.js +++ b/src/renderer/scripts/App.js @@ -309,6 +309,7 @@ const App = { str_output_path: App.str_output_path, list_cameras: CameraList.list_cameras, list_collections: CollectionList.list_collections, + is_skip_collections: CollectionList.is_skip_collections, obj_render_settings: RenderSettings.get_settings(), }; @@ -375,9 +376,15 @@ const App = { obj_badge.textContent = String(obj_config.list_cameras.length); } + if (obj_config.is_skip_collections !== undefined) { + CollectionList.is_skip_collections = obj_config.is_skip_collections; + document.getElementById("check_skip_collections").checked = obj_config.is_skip_collections; + } + if (obj_config.list_collections && obj_config.list_collections.length > 0) { CollectionList.list_collections = obj_config.list_collections; CollectionList.render(); + CollectionList._update_panel_state(); let obj_badge_col = document.getElementById("badge_collection_count"); obj_badge_col.textContent = String(obj_config.list_collections.length); } else { diff --git a/src/renderer/scripts/CameraList.js b/src/renderer/scripts/CameraList.js index f12dd2e..b664970 100644 --- a/src/renderer/scripts/CameraList.js +++ b/src/renderer/scripts/CameraList.js @@ -5,6 +5,11 @@ const CameraList = { init: (fn_on_select) => { CameraList.fn_on_select = fn_on_select; + + let obj_btn_toggle = document.getElementById("btn_toggle_all_cameras"); + obj_btn_toggle.addEventListener("click", () => { + CameraList.toggle_all(); + }); }, set_cameras: (list_names, obj_scene) => { @@ -45,6 +50,27 @@ const CameraList = { return null; }, + toggle_all: () => { + if (CameraList.list_cameras.length === 0) { + return; + } + + let is_any_enabled = false; + for (let obj_cam of CameraList.list_cameras) { + if (obj_cam.is_enabled) { + is_any_enabled = true; + break; + } + } + + let is_new_state = !is_any_enabled; + for (let obj_cam of CameraList.list_cameras) { + obj_cam.is_enabled = is_new_state; + } + + CameraList.render(); + }, + get_enabled_cameras: () => { let list_enabled = []; for (let obj_cam of CameraList.list_cameras) { diff --git a/src/renderer/scripts/CollectionList.js b/src/renderer/scripts/CollectionList.js index 32c9a5b..e4cf004 100644 --- a/src/renderer/scripts/CollectionList.js +++ b/src/renderer/scripts/CollectionList.js @@ -1,8 +1,29 @@ const CollectionList = { list_collections: [], + is_skip_collections: true, init: () => { - // Peuple lors du chargement du .blend + let obj_check = document.getElementById("check_skip_collections"); + obj_check.checked = true; + CollectionList.is_skip_collections = true; + obj_check.addEventListener("change", () => { + CollectionList.is_skip_collections = obj_check.checked; + CollectionList._update_panel_state(); + }); + }, + + _update_panel_state: () => { + let obj_container = document.getElementById("container_collection_list"); + let obj_btn_reset = document.getElementById("btn_reset_collections"); + if (CollectionList.is_skip_collections) { + obj_container.style.pointerEvents = "none"; + obj_container.style.opacity = "0.4"; + obj_btn_reset.disabled = true; + } else { + obj_container.style.pointerEvents = ""; + obj_container.style.opacity = ""; + obj_btn_reset.disabled = false; + } }, set_collections: (list_raw) => { @@ -10,6 +31,7 @@ const CollectionList = { if (!list_raw || list_raw.length === 0) { CollectionList.render(); + CollectionList._update_panel_state(); let obj_badge = document.getElementById("badge_collection_count"); obj_badge.textContent = "0"; return; @@ -28,12 +50,16 @@ const CollectionList = { } CollectionList.render(); + CollectionList._update_panel_state(); let obj_badge = document.getElementById("badge_collection_count"); obj_badge.textContent = String(CollectionList.list_collections.length); }, get_overrides: () => { + if (CollectionList.is_skip_collections) { + return []; + } let list_overrides = []; for (let obj_col of CollectionList.list_collections) { list_overrides.push({