From b48c5aff50233c26ea96aee1bb9f4cdff5e7ebe0 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Mon, 15 Apr 2024 21:28:01 +0200 Subject: [PATCH] Fix compile --- armorforge/Sources/tab_objects.ts | 72 ++++++++++--------- armorlab/Sources/make_mesh.ts | 2 +- armorlab/Sources/make_paint.ts | 2 +- armorlab/Sources/nodes/brush_output_node.ts | 2 +- armorlab/Sources/nodes/inpaint_node.ts | 21 +++--- armorlab/Sources/nodes/photo_to_pbr_node.ts | 4 +- armorlab/Sources/nodes/rgb_node.ts | 2 +- armorlab/Sources/nodes/text_to_photo_node.ts | 15 ++-- armorlab/Sources/nodes/tiling_node.ts | 6 +- armorlab/Sources/nodes/upscale_node.ts | 3 +- armorlab/Sources/nodes_brush.ts | 16 ++--- armorlab/Sources/render_path_paint.ts | 9 ++- armorlab/Sources/ui_nodes_ext.ts | 15 ++-- armorpaint/Sources/nodes_brush.ts | 1 + armorsculpt/Sources/make_brush.ts | 2 +- armorsculpt/Sources/make_material.ts | 2 +- armorsculpt/Sources/make_mesh.ts | 4 +- armorsculpt/Sources/make_mesh_preview.ts | 2 +- armorsculpt/Sources/make_sculpt.ts | 2 +- .../Sources/nodes/brush_output_node.ts | 2 +- armorsculpt/Sources/tab_layers.ts | 32 ++++----- base/Sources/base.ts | 6 +- base/Sources/context.ts | 6 +- base/Sources/ui_base.ts | 3 +- base/Sources/ui_nodes.ts | 4 +- base/Sources/ui_view2d.ts | 4 +- 26 files changed, 121 insertions(+), 118 deletions(-) diff --git a/armorforge/Sources/tab_objects.ts b/armorforge/Sources/tab_objects.ts index 3a553f96..48a5a06f 100644 --- a/armorforge/Sources/tab_objects.ts +++ b/armorforge/Sources/tab_objects.ts @@ -1,6 +1,7 @@ let tab_objects_material_id: i32 = 0; let tab_objects_line_counter: i32 = 0; +let tab_objects_current_object: object_t; function tab_objects_roundfp(f: f32, precision: i32 = 2): f32 { f *= math_pow(10, precision); @@ -37,13 +38,13 @@ function tab_objects_draw_menu(ui: zui_t) { } let md: material_data_t = data_get_material("Scene", "TempMaterial" + tab_objects_material_id); - let mo: mesh_object_t = current_object.ext; + let mo: mesh_object_t = tab_objects_current_object.ext; mo.materials = [md]; make_material_parse_mesh_preview_material(md); } } -function tab_objects_draw_list(list_handle: zui_handle_t, current_object: object_t) { +function tab_objects_draw_list(ui: zui_t, list_handle: zui_handle_t, current_object: object_t) { if (char_at(current_object.name, 0) == ".") { return; // Hidden } @@ -51,13 +52,13 @@ function tab_objects_draw_list(list_handle: zui_handle_t, current_object: object // Highlight every other line if (tab_objects_line_counter % 2 == 0) { - g2_set_color(ui.t.SEPARATOR_COL); + g2_set_color(ui.ops.theme.SEPARATOR_COL); g2_fill_rect(0, ui._y, ui._window_w, zui_ELEMENT_H(ui)); g2_set_color(0xffffffff); } // Highlight selected line - if (current_object == context_context_raw.selected_object) { + if (current_object == context_raw.selected_object) { g2_set_color(0xff205d9c); g2_fill_rect(0, ui._y, ui._window_w, zui_ELEMENT_H(ui)); g2_set_color(0xffffffff); @@ -72,7 +73,7 @@ function tab_objects_draw_list(list_handle: zui_handle_t, current_object: object ui._x += 18; // Sign offset // Draw line that shows parent relations - g2_set_color(ui.t.ACCENT_COL); + g2_set_color(ui.ops.theme.ACCENT_COL); g2_draw_line(ui._x - 10, ui._y + zui_ELEMENT_H(ui) / 2, ui._x, ui._y + zui_ELEMENT_H(ui) / 2); g2_set_color(0xffffffff); @@ -85,10 +86,11 @@ function tab_objects_draw_list(list_handle: zui_handle_t, current_object: object ui._y -= zui_ELEMENT_OFFSET(ui); if (ui.is_released) { - context_context_raw.selected_object = current_object; + context_raw.selected_object = current_object; } if (ui.is_hovered && ui.input_released_r) { + tab_objects_current_object = current_object; ui_menu_draw(tab_objects_draw_menu, 1); } @@ -97,12 +99,12 @@ function tab_objects_draw_list(list_handle: zui_handle_t, current_object: object for (let i: i32 = 0; i < current_object.children.length; ++i) { let child: object_t = current_object.children[i]; // ui.indent(); - tab_objects_draw_list(list_handle, child); + tab_objects_draw_list(ui, list_handle, child); // ui.unindent(); } // Draw line that shows parent relations - g2_set_color(ui.t.ACCENT_COL); + g2_set_color(ui.ops.theme.ACCENT_COL); g2_draw_line(ui._x + 14, current_y, ui._x + 14, ui._y - zui_ELEMENT_H(ui) / 2); g2_set_color(0xffffffff); } @@ -124,9 +126,9 @@ function tab_objects_draw(htab: zui_handle_t) { tab_objects_line_counter = 0; - for (let i: i32 = 0; i < _scene_root.children.length) { + for (let i: i32 = 0; i < _scene_root.children.length; ++i) { let c: object_t = _scene_root.children[i]; - tab_objects_draw_list(zui_handle(__ID__), c); + tab_objects_draw_list(ui, zui_handle(__ID__), c); } // ui.unindent(); @@ -135,12 +137,12 @@ function tab_objects_draw(htab: zui_handle_t) { if (zui_panel(zui_handle(__ID__, {selected: true}), "Properties")) { // ui.indent(); - if (context_context_raw.selected_object != null) { + if (context_raw.selected_object != null) { let h = zui_handle(__ID__); - h.selected = context_context_raw.selected_object.visible; - context_context_raw.selected_object.visible = zui_check(h, "Visible"); + h.selected = context_raw.selected_object.visible; + context_raw.selected_object.visible = zui_check(h, "Visible"); - let t = context_context_raw.selected_object.transform; + let t = context_raw.selected_object.transform; let local_pos = t.loc; let scale = t.scale; let rot = quat_get_euler(t.rot); @@ -152,21 +154,21 @@ function tab_objects_draw(htab: zui_handle_t) { zui_text("Loc"); h = zui_handle(__ID__); - h.text = roundfp(local_pos.x) + ""; + h.text = math_round(local_pos.x) + ""; f = parse_float(zui_text_input(h, "X")); if (h.changed) { local_pos.x = f; } h = zui_handle(__ID__); - h.text = roundfp(local_pos.y) + ""; + h.text = math_round(local_pos.y) + ""; f = parse_float(zui_text_input(h, "Y")); if (h.changed) { local_pos.y = f; } h = zui_handle(__ID__); - h.text = roundfp(local_pos.z) + ""; + h.text = math_round(local_pos.z) + ""; f = parse_float(zui_text_input(h, "Z")); if (h.changed) { local_pos.z = f; @@ -176,7 +178,7 @@ function tab_objects_draw(htab: zui_handle_t) { zui_text("Rotation"); h = zui_handle(__ID__); - h.text = roundfp(rot.x) + ""; + h.text = math_round(rot.x) + ""; f = parse_float(zui_text_input(h, "X")); let changed = false; if (h.changed) { @@ -185,7 +187,7 @@ function tab_objects_draw(htab: zui_handle_t) { } h = zui_handle(__ID__); - h.text = roundfp(rot.y) + ""; + h.text = math_round(rot.y) + ""; f = parse_float(zui_text_input(h, "Y")); if (h.changed) { changed = true; @@ -193,17 +195,17 @@ function tab_objects_draw(htab: zui_handle_t) { } h = zui_handle(__ID__); - h.text = roundfp(rot.z) + ""; + h.text = math_round(rot.z) + ""; f = parse_float(zui_text_input(h, "Z")); if (h.changed) { changed = true; rot.z = f; } - if (changed && context_context_raw.selected_object.name != "Scene") { + if (changed && context_raw.selected_object.name != "Scene") { vec4_mult(rot, 3.141592 / 180); - quat_from_euler(context_context_raw.selected_object.transform.rot, rot.x, rot.y, rot.z); - transform_build_matrix(context_context_raw.selected_object.transform); + quat_from_euler(context_raw.selected_object.transform.rot, rot.x, rot.y, rot.z); + transform_build_matrix(context_raw.selected_object.transform); // ///if arm_physics // if (rb != null) rb.syncTransform(); // ///end @@ -213,21 +215,21 @@ function tab_objects_draw(htab: zui_handle_t) { zui_text("Scale"); h = zui_handle(__ID__); - h.text = roundfp(scale.x) + ""; + h.text = math_round(scale.x) + ""; f = parse_float(zui_text_input(h, "X")); if (h.changed) { scale.x = f; } h = zui_handle(__ID__); - h.text = roundfp(scale.y) + ""; + h.text = math_round(scale.y) + ""; f = parse_float(zui_text_input(h, "Y")); if (h.changed) { scale.y = f; } h = zui_handle(__ID__); - h.text = roundfp(scale.z) + ""; + h.text = math_round(scale.z) + ""; f = parse_float(zui_text_input(h, "Z")); if (h.changed) { scale.z = f; @@ -237,40 +239,40 @@ function tab_objects_draw(htab: zui_handle_t) { zui_text("Dimensions"); h = zui_handle(__ID__); - h.text = roundfp(dim.x) + ""; + h.text = math_round(dim.x) + ""; f = parse_float(zui_text_input(h, "X")); if (h.changed) { dim.x = f; } h = zui_handle(__ID__); - h.text = roundfp(dim.y) + ""; + h.text = math_round(dim.y) + ""; f = parse_float(zui_text_input(h, "Y")); if (h.changed) { dim.y = f; } h = zui_handle(__ID__); - h.text = roundfp(dim.z) + ""; + h.text = math_round(dim.z) + ""; f = parse_float(zui_text_input(h, "Z")); if (h.changed) { dim.z = f; } - context_context_raw.selected_object.transform.dirty = true; + context_raw.selected_object.transform.dirty = true; - if (context_context_raw.selected_object.name == "Scene") { + if (context_raw.selected_object.name == "Scene") { let p = scene_world; p.strength = zui_slider(zui_handle(__ID__, {value: p.strength}), "Environment", 0.0, 5.0, true); } - else if (context_context_raw.selected_object.ext_type == "light_object_t") { - let light = context_context_raw.selected_object.ext; + else if (context_raw.selected_object.ext_type == "light_object_t") { + let light = context_raw.selected_object.ext; let light_handle = zui_handle(__ID__); light_handle.value = light.data.strength / 10; light.data.strength = zui_slider(light_handle, "Strength", 0.0, 5.0, true) * 10; } - else if (context_context_raw.selected_object.ext_type == "camera_object_t") { - let cam = context_context_raw.selected_object.ext; + else if (context_raw.selected_object.ext_type == "camera_object_t") { + let cam = context_raw.selected_object.ext; let fov_handle = zui_handle(__ID__); fov_handle.value = math_floor(cam.data.fov * 100) / 100; cam.data.fov = zui_slider(fov_handle, "FoV", 0.3, 2.0, true); diff --git a/armorlab/Sources/make_mesh.ts b/armorlab/Sources/make_mesh.ts index 83de14c8..d3c2216d 100644 --- a/armorlab/Sources/make_mesh.ts +++ b/armorlab/Sources/make_mesh.ts @@ -1,7 +1,7 @@ let make_mesh_layer_pass_count: i32 = 1; -function make_mesh_run(data: material_t, layer_pass: i32 = 0): NodeShaderContextRaw { +function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_context_t { let con_mesh = node_shader_context_create(data, { name: "mesh", depth_write: layer_pass == 0 ? true : false, diff --git a/armorlab/Sources/make_paint.ts b/armorlab/Sources/make_paint.ts index 1958d96a..ead61b04 100644 --- a/armorlab/Sources/make_paint.ts +++ b/armorlab/Sources/make_paint.ts @@ -1,5 +1,5 @@ -function make_paint_run(data: material_t, matcon: material_context_t): NodeShaderContextRaw { +function make_paint_run(data: material_t, matcon: material_context_t): node_shader_context_t { let con_paint = node_shader_context_create(data, { name: "paint", depth_write: false, diff --git a/armorlab/Sources/nodes/brush_output_node.ts b/armorlab/Sources/nodes/brush_output_node.ts index 52cad4e9..828f7709 100644 --- a/armorlab/Sources/nodes/brush_output_node.ts +++ b/armorlab/Sources/nodes/brush_output_node.ts @@ -68,5 +68,5 @@ function brush_output_node_create(arg: any): brush_output_node_t { } function brush_output_node_get_as_image(self: brush_output_node_t, from: i32): image_t { - return self.base.inputs[from].get_as_image(); + return logic_node_input_get_as_image(self.base.inputs[from]); } diff --git a/armorlab/Sources/nodes/inpaint_node.ts b/armorlab/Sources/nodes/inpaint_node.ts index 7dde2e7c..dcc46eed 100644 --- a/armorlab/Sources/nodes/inpaint_node.ts +++ b/armorlab/Sources/nodes/inpaint_node.ts @@ -61,7 +61,7 @@ function inpaint_node_buttons(ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) { } function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): image_t { - let source: image_t = self.base.inputs[0].get_as_image(); + let source: image_t = logic_node_input_get_as_image(self.base.inputs[0]); console_progress(tr("Processing") + " - " + tr("Inpaint")); krom_g4_swap_buffers(); @@ -69,12 +69,12 @@ function inpaint_node_get_as_image(self: inpaint_node_t, from: i32): image_t { g2_draw_scaled_image(source, 0, 0, config_get_texture_res_x(), config_get_texture_res_y()); g2_end(); - return inpaint_node_auto ? inpaint_node_texsynth_inpaint(inpaint_node_image, false, inpaint_node_mask) : inpaint_node_inpaint_node_sd_inpaint(inpaint_node_image, inpaint_node_mask); + return inpaint_node_auto ? inpaint_node_texsynth_inpaint(inpaint_node_image, false, inpaint_node_mask) : inpaint_node_sd_inpaint(inpaint_node_image, inpaint_node_mask); } function inpaint_node_get_cached_image(self: inpaint_node_t): image_t { app_notify_on_next_frame(function (self: inpaint_node_t) { - let source: image_t = self.base.inputs[0].get_as_image(); + let source: image_t = logic_node_input_get_as_image(self.base.inputs[0]); if (base_pipe_copy == null) { base_make_pipe(); } @@ -152,20 +152,23 @@ function inpaint_node_sd_inpaint(image: image_t, mask: image_t): image_t { f32a[i + 512 * 512 * 2] = (u8a[i * 4 + 2] / 255.0) * 2.0 - 1.0; } - let latents_buf = krom_ml_inference(vae_encoder_blob, [f32a.buffer], [[1, 3, 512, 512]], [1, 4, 64, 64], config_raw.gpu_inference); - let latents = f32_array_create_from_buffer(latents_buf); + let latents_buf: buffer_t = krom_ml_inference(vae_encoder_blob, [f32a.buffer], [[1, 3, 512, 512]], [1, 4, 64, 64], config_raw.gpu_inference); + let latents: f32_array_t = f32_array_create_from_buffer(latents_buf); for (let i: i32 = 0; i < latents.length; ++i) { latents[i] = 0.18215 * latents[i]; } - let latents_orig = array_slice(latents, 0, latents.length); + // let latents_orig: f32_array_t = array_slice(latents, 0, latents.length); + let latents_orig: f32_array_t = latents.slice(0, latents.length); let noise = f32_array_create(latents.length); - for (let i: i32 = 0; i < noise.length; ++i) noise[i] = math_cos(2.0 * 3.14 * random_node_get_float()) * math_sqrt(-2.0 * math_log(random_node_get_float())); + for (let i: i32 = 0; i < noise.length; ++i) { + noise[i] = math_cos(2.0 * 3.14 * random_node_get_float()) * math_sqrt(-2.0 * math_log(random_node_get_float())); + } let num_inference_steps = 50; let init_timestep = math_floor(num_inference_steps * inpaint_node_strength); - let timestep = text_to_photo_node.timesteps[num_inference_steps - init_timestep]; - let alphas_cumprod = text_to_photo_node.alphas_cumprod; + let timestep = text_to_photo_node_timesteps[num_inference_steps - init_timestep]; + let alphas_cumprod = text_to_photo_node_alphas_cumprod; let sqrt_alpha_prod = math_pow(alphas_cumprod[timestep], 0.5); let sqrt_one_minus_alpha_prod = math_pow(1.0 - alphas_cumprod[timestep], 0.5); for (let i: i32 = 0; i < latents.length; ++i) { diff --git a/armorlab/Sources/nodes/photo_to_pbr_node.ts b/armorlab/Sources/nodes/photo_to_pbr_node.ts index 5d06c172..2e5859b7 100644 --- a/armorlab/Sources/nodes/photo_to_pbr_node.ts +++ b/armorlab/Sources/nodes/photo_to_pbr_node.ts @@ -42,7 +42,7 @@ function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): i source = photo_to_pbr_node_cached_source; } else { - source = self.base.inputs[0].get_as_image(); + source = logic_node_input_get_as_image(self.base.inputs[0]); } photo_to_pbr_node_cached_source = source; @@ -157,7 +157,7 @@ function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): i g2_begin(photo_to_pbr_node_images[from]); g2_draw_image(temp2, x * photo_to_pbr_node_tile_w, y * photo_to_pbr_node_tile_w); g2_end(); - app_notify_on_next_frame(temp2: image_t) { + app_notify_on_next_frame(function(temp2: image_t) { image_unload(temp2); }, temp2); } diff --git a/armorlab/Sources/nodes/rgb_node.ts b/armorlab/Sources/nodes/rgb_node.ts index 8278b2c0..13203932 100644 --- a/armorlab/Sources/nodes/rgb_node.ts +++ b/armorlab/Sources/nodes/rgb_node.ts @@ -20,7 +20,7 @@ function rgb_node_get_as_image(self: rgb_node_t, from: i32): image_t { } let f32a = f32_array_create(4); - let raw = parser_logic_get_raw_node(self); + let raw = parser_logic_get_raw_node(self.base); let default_value = raw.outputs[0].default_value; f32a[0] = default_value[0]; f32a[1] = default_value[1]; diff --git a/armorlab/Sources/nodes/text_to_photo_node.ts b/armorlab/Sources/nodes/text_to_photo_node.ts index 2d0378a1..0045698b 100644 --- a/armorlab/Sources/nodes/text_to_photo_node.ts +++ b/armorlab/Sources/nodes/text_to_photo_node.ts @@ -33,7 +33,7 @@ function text_to_photo_node_buttons(ui: zui_t, nodes: zui_nodes_t, node: zui_nod node.buttons[1].height = string_split(text_to_photo_node_prompt, "\n").length; } -function stable_diffusion(prompt: string, inpaint_latents: f32_array_t = null, offset: i32 = 0, upscale: bool = true, mask: f32_array_t = null, latents_orig: f32_array_t = null): image_t { +function text_to_photo_node_stable_diffusion(prompt: string, inpaint_latents: f32_array_t = null, offset: i32 = 0, upscale: bool = true, mask: f32_array_t = null, latents_orig: f32_array_t = null): image_t { let _text_encoder_blob: buffer_t = data_get_blob("models/sd_text_encoder.quant.onnx"); let _unet_blob: buffer_t = data_get_blob("models/sd_unet.quant.onnx"); let _vae_decoder_blob: buffer_t = data_get_blob("models/sd_vae_decoder.quant.onnx"); @@ -56,15 +56,15 @@ function text_to_photo_node_text_encoder(prompt: string, inpaint_latents: f32_ar let words = string_split(string_replace_all(string_replace_all(string_replace_all(prompt, "\n", " "), ",", " , "), " ", " ").trim(), " "); for (let i: i32 = 0; i < words.length; ++i) { - text_to_photo_node_text_input_ids[i + 1] = to_lower_case(text_to_photo_node_vocab[words[i]) + ""]; + text_to_photo_node_text_input_ids[i + 1] = text_to_photo_node_vocab[to_lower_case(words[i]) + ""]; } for (let i: i32 = words.length; i < (text_to_photo_node_text_input_ids.length - 1); ++i) { text_to_photo_node_text_input_ids[i + 1] = 49407; // <|endoftext|> } let i32a = i32_array_create_from_array(text_to_photo_node_text_input_ids); - let text_embeddings_buf = krom_ml_inference(text_to_photo_node_text_encoder_blob, [i32a.buffer], [[1, 77]], [1, 77, 768], config_raw.gpu_inference); - let text_embeddings = f32_array_create_from_array(text_embeddings_buf); + let text_embeddings_buf: buffer_t = krom_ml_inference(text_to_photo_node_text_encoder_blob, [i32a.buffer], [[1, 77]], [1, 77, 768], config_raw.gpu_inference); + let text_embeddings = f32_array_create_from_buffer(text_embeddings_buf); i32a = i32_array_create_from_array(text_to_photo_node_uncond_input_ids); let uncond_embeddings_buf = krom_ml_inference(text_to_photo_node_text_encoder_blob, [i32a.buffer], [[1, 77]], [1, 77, 768], config_raw.gpu_inference); @@ -102,7 +102,7 @@ function text_to_photo_node_unet(latents: f32_array_t, text_embeddings: f32_arra while (true) { console_progress(tr("Processing") + " - " + tr("Text to Photo") + " (" + (counter + 1) + "/" + (50 - offset) + ")"); - krom_g4_swa_buffers(); + krom_g4_swap_buffers(); let timestep = text_to_photo_node_timesteps[counter + offset]; for (let i: i32 = 0; i < latents.length; ++i) latent_model_input[i] = latents[i]; @@ -289,18 +289,17 @@ let text_to_photo_node_def: zui_node_t = { type: "CUSTOM", output: -1, default_value: null, - height: 1, data: null, min: 0.0, max: 1.0, precision: 100, - height: 0 + height: 1 } ], width: 0 }; -let text_to_photo_node_text_input_ids: i32[] = [49406, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, +let text_to_photo_node_text_input_ids: i32[] = [49406, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, 49407, diff --git a/armorlab/Sources/nodes/tiling_node.ts b/armorlab/Sources/nodes/tiling_node.ts index c1efb5de..646fb1ef 100644 --- a/armorlab/Sources/nodes/tiling_node.ts +++ b/armorlab/Sources/nodes/tiling_node.ts @@ -37,7 +37,7 @@ function tiling_node_buttons(ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) { } function tiling_node_get_as_image(self: tiling_node_t, from: i32): image_t { - let source: image_t = self.base.inputs[0].get_as_image(); + let source: image_t = logic_node_input_get_as_image(self.base.inputs[0]); g2_begin(tiling_node_image); g2_draw_scaled_image(source, 0, 0, config_get_texture_res_x(), config_get_texture_res_y()); g2_end(); @@ -110,7 +110,7 @@ let tiling_node_def: zui_node_t = { name: _tr("Color"), type: "RGBA", color: 0xffc7c729, - default_value: f32_array_xyzw(0.0, 0.0, 0.0, 1.0), + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), min: 0.0, max: 1.0, precision: 100, @@ -124,7 +124,7 @@ let tiling_node_def: zui_node_t = { name: _tr("Color"), type: "RGBA", color: 0xffc7c729, - default_value: f32_array_xyzw(0.0, 0.0, 0.0, 1.0), + default_value: f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0), min: 0.0, max: 1.0, precision: 100, diff --git a/armorlab/Sources/nodes/upscale_node.ts b/armorlab/Sources/nodes/upscale_node.ts index 1f26025d..bdc5cae5 100644 --- a/armorlab/Sources/nodes/upscale_node.ts +++ b/armorlab/Sources/nodes/upscale_node.ts @@ -16,7 +16,7 @@ function upscale_node_create(arg: any): upscale_node_t { } function upscale_node_get_as_image(self: upscale_node_t, from: i32): image_t { - upscale_node_image = self.base.inputs[0].get_as_image(); + upscale_node_image = logic_node_input_get_as_image(self.base.inputs[0]); console_progress(tr("Processing") + " - " + tr("Upscale")); krom_g4_swap_buffers(); @@ -35,6 +35,7 @@ function upscale_node_get_as_image(self: upscale_node_t, from: i32): image_t { function upscale_node_load_blob() { upscale_node_esrgan_blob = data_get_blob("models/esrgan.quant.onnx"); +} function upscale_node_get_cached_image(self: upscale_node_t): image_t { return upscale_node_image; diff --git a/armorlab/Sources/nodes_brush.ts b/armorlab/Sources/nodes_brush.ts index 32118504..9221b115 100644 --- a/armorlab/Sources/nodes_brush.ts +++ b/armorlab/Sources/nodes_brush.ts @@ -11,16 +11,16 @@ let nodes_brush_categories: string[] = [_tr("Input"), _tr("Model")]; let nodes_brush_list: zui_node_t[][] = [ [ // Input - image_texture_node.def, - rgb_node.def, + image_texture_node_def, + rgb_node_def, ], [ // Model - inpaint_node.def, - photo_to_pbr_node.def, - text_to_photo_node.def, - tiling_node.def, - upscale_node.def, - variance_node.def, + inpaint_node_def, + photo_to_pbr_node_def, + text_to_photo_node_def, + tiling_node_def, + upscale_node_def, + variance_node_def, ] ]; diff --git a/armorlab/Sources/render_path_paint.ts b/armorlab/Sources/render_path_paint.ts index 7023986b..212a21da 100644 --- a/armorlab/Sources/render_path_paint.ts +++ b/armorlab/Sources/render_path_paint.ts @@ -262,9 +262,9 @@ function render_path_paint_bind_layers() { let canvas = ui_nodes_get_canvas(true); if (nodes.nodes_selected_id.length > 0) { let node = zui_get_node(canvas.nodes, nodes.nodes_selected_id[0]); - let brush_node: inpaint_node_t = parser_logic_get_logic_node(node); - if (brush_node: inpaint_node_t != null) { - image = brush_node: inpaint_node_t.get_cached_image(); + let brush_node: logic_node_t = parser_logic_get_logic_node(node); + if (brush_node != null) { + image = logic_node_get_cached_image(brush_node); } } if (image != null) { @@ -294,8 +294,7 @@ function render_path_paint_bind_layers() { let node = zui_get_node(canvas.nodes, nodes.nodes_selected_id[0]); let inpaint = node.type == "InpaintNode"; if (inpaint) { - let brush_node: inpaint_node_t = parser_logic_get_logic_node(node); - map_get(render_path_render_targets, "texpaint_node_target")._image = inpaint_node_get_target(brush_node); + map_get(render_path_render_targets, "texpaint_node_target")._image = inpaint_node_get_target(); } } else { diff --git a/armorlab/Sources/ui_nodes_ext.ts b/armorlab/Sources/ui_nodes_ext.ts index 4e07c66e..6837a55b 100644 --- a/armorlab/Sources/ui_nodes_ext.ts +++ b/armorlab/Sources/ui_nodes_ext.ts @@ -10,8 +10,6 @@ function ui_nodes_ext_draw_buttons(ew: f32, start_y: f32) { } app_notify_on_render_2d(delay_idle_sleep); - ui_nodes_ext_tasks = 1; - console_progress(tr("Processing")); krom_g4_swap_buffers(); @@ -19,11 +17,11 @@ function ui_nodes_ext_draw_buttons(ew: f32, start_y: f32) { parser_logic_parse(project_canvas); photo_to_pbr_node_cached_source = null; - let texbase: image_t = brush_output_node_inst.get_as_image(channel_type_t.BASE_COLOR); - let texocc: image_t = brush_output_node_inst.get_as_image(channel_type_t.OCCLUSION); - let texrough: image_t = brush_output_node_inst.get_as_image(channel_type_t.ROUGHNESS); - let texnor: image_t = brush_output_node_inst.get_as_image(channel_type_t.NORMAL_MAP); - let texheight: image_t = brush_output_node_inst.get_as_image(channel_type_t.HEIGHT); + let texbase: image_t = logic_node_get_as_image(brush_output_node_inst.base, channel_type_t.BASE_COLOR); + let texocc: image_t = logic_node_get_as_image(brush_output_node_inst.base, channel_type_t.OCCLUSION); + let texrough: image_t = logic_node_get_as_image(brush_output_node_inst.base, channel_type_t.ROUGHNESS); + let texnor: image_t = logic_node_get_as_image(brush_output_node_inst.base, channel_type_t.NORMAL_MAP); + let texheight: image_t = logic_node_get_as_image(brush_output_node_inst.base, channel_type_t.HEIGHT); if (texbase != null) { let texpaint = map_get(render_path_render_targets, "texpaint")._image; @@ -77,7 +75,7 @@ function ui_nodes_ext_draw_buttons(ew: f32, start_y: f32) { g4_end(); if (ui_header_worktab.position == space_type_t.SPACE3D && - BrushOutputNode.inst.inputs[channel_type_t.HEIGHT].node.constructor != FloatNode) { + brush_output_node_inst.base.inputs[channel_type_t.HEIGHT].node.get != float_node_get) { // Make copy of vertices before displacement let o = project_paint_objects[0]; @@ -98,7 +96,6 @@ function ui_nodes_ext_draw_buttons(ew: f32, start_y: f32) { // Apply displacement if (config_raw.displace_strength > 0) { - ui_nodes_ext_tasks++; console_progress(tr("Apply Displacement")); krom_g4_swap_buffers(); diff --git a/armorpaint/Sources/nodes_brush.ts b/armorpaint/Sources/nodes_brush.ts index 2446cb23..7d79545f 100644 --- a/armorpaint/Sources/nodes_brush.ts +++ b/armorpaint/Sources/nodes_brush.ts @@ -1,5 +1,6 @@ /// /// +/// let nodes_brush_categories = [_tr("Nodes")]; diff --git a/armorsculpt/Sources/make_brush.ts b/armorsculpt/Sources/make_brush.ts index 930d2fc2..741e6968 100644 --- a/armorsculpt/Sources/make_brush.ts +++ b/armorsculpt/Sources/make_brush.ts @@ -1,5 +1,5 @@ -function make_brush_run(vert: NodeShaderRaw, frag: NodeShaderRaw) { +function make_brush_run(vert: node_shader_t, frag: node_shader_t) { node_shader_write(frag, "float dist = 0.0;"); diff --git a/armorsculpt/Sources/make_material.ts b/armorsculpt/Sources/make_material.ts index a6eac218..83dfcc3b 100644 --- a/armorsculpt/Sources/make_material.ts +++ b/armorsculpt/Sources/make_material.ts @@ -129,7 +129,7 @@ function make_material_parse_mesh_preview_material() { let m = project_materials[0].data; let scon: shader_context_t = null; - for (let i: i32 = 0; i < m._.shader._.contexts; ++i) { + for (let i: i32 = 0; i < m._.shader._.contexts.length; ++i) { let c = m._.shader._.contexts[i]; if (c.name == "mesh") { scon = c; diff --git a/armorsculpt/Sources/make_mesh.ts b/armorsculpt/Sources/make_mesh.ts index 17a3884a..0fc8e3cf 100644 --- a/armorsculpt/Sources/make_mesh.ts +++ b/armorsculpt/Sources/make_mesh.ts @@ -1,7 +1,7 @@ let make_mesh_layer_pass_count = 1; -function make_mesh_run(data: material_t, layer_pass: i32 = 0): NodeShaderContextRaw { +function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_context_t { let context_id = layer_pass == 0 ? "mesh" : "mesh" + layer_pass; let con_mesh = node_shader_context_create(data, { name: context_id, @@ -111,7 +111,7 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): NodeShaderContext // Get layers for this pass make_mesh_layer_pass_count = 1; - let layers: SlotLayerRaw[] = []; + let layers: slot_layer_t[] = []; let start_count = texture_count; for (let i: i32 = 0; i < project_layers.length; ++i) { let l = project_layers[i]; diff --git a/armorsculpt/Sources/make_mesh_preview.ts b/armorsculpt/Sources/make_mesh_preview.ts index 6ca10c43..145c1bea 100644 --- a/armorsculpt/Sources/make_mesh_preview.ts +++ b/armorsculpt/Sources/make_mesh_preview.ts @@ -1,7 +1,7 @@ let make_mesh_preview_opacity_discard_decal: f32 = 0.05; -function make_mesh_preview_run(data: material_t, matcon: material_context_t): NodeShaderContextRaw { +function make_mesh_preview_run(data: material_t, matcon: material_context_t): node_shader_context_t { let context_id = "mesh"; let con_mesh = node_shader_context_create(data, { name: context_id, diff --git a/armorsculpt/Sources/make_sculpt.ts b/armorsculpt/Sources/make_sculpt.ts index a866f698..ee7487de 100644 --- a/armorsculpt/Sources/make_sculpt.ts +++ b/armorsculpt/Sources/make_sculpt.ts @@ -1,5 +1,5 @@ -function make_sculpt_run(data: material_t, matcon: material_context_t): NodeShaderContextRaw { +function make_sculpt_run(data: material_t, matcon: material_context_t): node_shader_context_t { let context_id = "paint"; let con_paint = node_shader_context_create(data, { name: context_id, diff --git a/armorsculpt/Sources/nodes/brush_output_node.ts b/armorsculpt/Sources/nodes/brush_output_node.ts index 001d8edb..2c206808 100644 --- a/armorsculpt/Sources/nodes/brush_output_node.ts +++ b/armorsculpt/Sources/nodes/brush_output_node.ts @@ -42,7 +42,7 @@ function brush_output_node_parse_inputs(self: brush_output_node_t) { context_raw.brush_mask_image = null; } - context_raw.brush_nodes_hardness = input3; + context_raw.brush_nodes_hardness = input3._f32; let stencil: logic_node_value_t = input4; // Float or texture name if (stencil == null) { diff --git a/armorsculpt/Sources/tab_layers.ts b/armorsculpt/Sources/tab_layers.ts index d4ac88aa..ae9b14c8 100644 --- a/armorsculpt/Sources/tab_layers.ts +++ b/armorsculpt/Sources/tab_layers.ts @@ -12,8 +12,8 @@ function tab_layers_draw_mini(htab: zui_handle_t) { let ui = ui_base_ui; zui_set_hovered_tab_name(tr("Layers")); - let _ELEMENT_H = ui.t.ELEMENT_H; - ui.t.ELEMENT_H = math_floor(ui_base_sidebar_mini_w / 2 / zui_SCALE(ui)); + let _ELEMENT_H = ui.ops.theme.ELEMENT_H; + ui.ops.theme.ELEMENT_H = math_floor(ui_base_sidebar_mini_w / 2 / zui_SCALE(ui)); zui_begin_sticky(); zui_separator(5); @@ -27,7 +27,7 @@ function tab_layers_draw_mini(htab: zui_handle_t) { tab_layers_highlight_odd_lines(); tab_layers_draw_slots(true); - ui.t.ELEMENT_H = _ELEMENT_H; + ui.ops.theme.ELEMENT_H = _ELEMENT_H; } function tab_layers_draw_full(htab: zui_handle_t) { @@ -60,11 +60,11 @@ function tab_layers_draw_slots(mini: bool) { function tab_layers_highlight_odd_lines() { let ui = ui_base_ui; - let step = ui.t.ELEMENT_H * 2; + let step = ui.ops.theme.ELEMENT_H * 2; let full_h = ui._window_h - ui_base_hwnds[0].scroll_offset; for (let i: i32 = 0; i < math_floor(full_h / step); ++i) { if (i % 2 == 0) { - zui_fill(0, i * step, (ui._w / zui_SCALE(ui) - 2), step, ui.t.WINDOW_BG_COL - 0x00040404); + zui_fill(0, i * step, (ui._w / zui_SCALE(ui) - 2), step, ui.ops.theme.WINDOW_BG_COL - 0x00040404); } } } @@ -143,7 +143,7 @@ function tab_layers_draw_layer_slot(l: slot_layer_t, i: i32, mini: bool) { return; } - let step = ui.t.ELEMENT_H; + let step = ui.ops.theme.ELEMENT_H; let checkw = (ui._window_w / 100 * 8) / zui_SCALE(ui); // Highlight drag destination @@ -159,14 +159,14 @@ function tab_layers_draw_layer_slot(l: slot_layer_t, i: i32, mini: bool) { let nestedGroup = slot_layer_is_group(base_drag_layer) && toGroup; if (!nestedGroup) { if (slot_layer_can_move(context_raw.layer, context_raw.drag_dest)) { - zui_fill(checkw, step * 2, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL); + zui_fill(checkw, step * 2, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.ops.theme.HIGHLIGHT_COL); } } } else if (i == project_layers.length - 1 && mouse_y < absy + step) { context_raw.drag_dest = project_layers.length - 1; if (slot_layer_can_move(context_raw.layer, context_raw.drag_dest)) { - zui_fill(checkw, 0, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL); + zui_fill(checkw, 0, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.ops.theme.HIGHLIGHT_COL); } } } @@ -174,13 +174,13 @@ function tab_layers_draw_layer_slot(l: slot_layer_t, i: i32, mini: bool) { if (mouse_y > absy + step && mouse_y < absy + step * 3) { context_raw.drag_dest = i; if (tab_layers_can_drop_new_layer(i)) { - zui_fill(checkw, 2 * step, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL); + zui_fill(checkw, 2 * step, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.ops.theme.HIGHLIGHT_COL); } } else if (i == project_layers.length - 1 && mouse_y < absy + step) { context_raw.drag_dest = project_layers.length; if (tab_layers_can_drop_new_layer(project_layers.length)) { - zui_fill(checkw, 0, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL); + zui_fill(checkw, 0, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.ops.theme.HIGHLIGHT_COL); } } } @@ -210,7 +210,7 @@ function tab_layers_draw_layer_slot_mini(l: slot_layer_t, i: i32) { function tab_layers_draw_layer_slot_full(l: slot_layer_t, i: i32) { let ui = ui_base_ui; - let step = ui.t.ELEMENT_H; + let step = ui.ops.theme.ELEMENT_H; let hasPanel = slot_layer_is_group(l) || (slot_layer_is_layer(l) && slot_layer_get_masks(l, false) != null); if (hasPanel) { @@ -227,7 +227,7 @@ function tab_layers_draw_layer_slot_full(l: slot_layer_t, i: i32) { ui._x += 2; ui._y += 3; ui._y += center; - let col = ui.t.ACCENT_SELECT_COL; + let col = ui.ops.theme.ACCENT_SELECT_COL; let parentHidden = l.parent != null && (!l.parent.visible || (l.parent.parent != null && !l.parent.parent.visible)); if (parentHidden) { col -= 0x99000000; @@ -366,18 +366,18 @@ function tab_layers_layer_toggle_visible(l: slot_layer_t) { function tab_layers_draw_layer_highlight(l: slot_layer_t, mini: bool) { let ui = ui_base_ui; - let step = ui.t.ELEMENT_H; + let step = ui.ops.theme.ELEMENT_H; // Separator line - zui_fill(0, 0, (ui._w / zui_SCALE(ui) - 2), 1 * zui_SCALE(ui), ui.t.SEPARATOR_COL); + zui_fill(0, 0, (ui._w / zui_SCALE(ui) - 2), 1 * zui_SCALE(ui), ui.ops.theme.SEPARATOR_COL); // Highlight selected if (context_raw.layer == l) { if (mini) { - zui_rect(1, -step * 2, ui._w / zui_SCALE(ui) - 1, step * 2 + (mini ? -1 : 1), ui.t.HIGHLIGHT_COL, 3); + zui_rect(1, -step * 2, ui._w / zui_SCALE(ui) - 1, step * 2 + (mini ? -1 : 1), ui.ops.theme.HIGHLIGHT_COL, 3); } else { - zui_rect(1, -step * 2 - 1, ui._w / zui_SCALE(ui) - 2, step * 2 + (mini ? -2 : 1), ui.t.HIGHLIGHT_COL, 2); + zui_rect(1, -step * 2 - 1, ui._w / zui_SCALE(ui) - 2, step * 2 + (mini ? -2 : 1), ui.ops.theme.HIGHLIGHT_COL, 2); } } } diff --git a/base/Sources/base.ts b/base/Sources/base.ts index c0cefee6..af10b031 100644 --- a/base/Sources/base.ts +++ b/base/Sources/base.ts @@ -2353,9 +2353,9 @@ function base_flatten(height_to_normal: bool = false): any { let canvas: zui_node_canvas_t = ui_nodes_get_canvas(true); if (nodes.nodes_selected_id.length > 0) { let node: zui_node_t = zui_get_node(canvas.nodes, nodes.nodes_selected_id[0]); - let brush_node: LogicNode = parser_logic_get_logic_node(node); - if (brush_node != null && brush_node.get_cached_image() != null) { - texpaint = brush_node.get_cached_image(); + let brush_node: logic_node_t = parser_logic_get_logic_node(node); + if (brush_node != null && logic_node_get_cached_image(brush_node) != null) { + texpaint = logic_node_get_cached_image(brush_node); texpaint_nor = map_get(render_path_render_targets, "texpaint_nor_empty")._image; texpaint_pack = map_get(render_path_render_targets, "texpaint_pack_empty")._image; } diff --git a/base/Sources/context.ts b/base/Sources/context.ts index 9c7b7886..d6010063 100644 --- a/base/Sources/context.ts +++ b/base/Sources/context.ts @@ -968,7 +968,7 @@ function context_update() { context_raw.start_y = pen_view_y() / app_h(); } - if (operator_shortcut(config_keymap.brush_ruler + "+" + config_keymap.action_paint, shortcut_type_t.DOWN)) { + if (operator_shortcut(map_get(config_keymap, "brush_ruler") + "+" + map_get(config_keymap, "action_paint"), shortcut_type_t.DOWN)) { if (context_raw.lock_x) { paint_x = context_raw.start_x; } @@ -989,12 +989,12 @@ function context_update() { } } - if (keyboard_started(config_keymap.brush_ruler)) { + if (keyboard_started(map_get(config_keymap, "brush_ruler"))) { context_raw.lock_start_x = mouse_view_x(); context_raw.lock_start_y = mouse_view_y(); context_raw.lock_begin = true; } - else if (keyboard_released(config_keymap.brush_ruler)) { + else if (keyboard_released(map_get(config_keymap, "brush_ruler"))) { context_raw.lock_x = context_raw.lock_y = context_raw.lock_begin = false; } diff --git a/base/Sources/ui_base.ts b/base/Sources/ui_base.ts index 605c6c1e..383fec2e 100644 --- a/base/Sources/ui_base.ts +++ b/base/Sources/ui_base.ts @@ -1149,7 +1149,8 @@ function ui_base_update_ui() { ///end ///if is_lab if (context_run_brush != null) { - context_run_brush(context_raw.brush_output_node_inst, 0); + // context_run_brush(context_raw.brush_output_node_inst, 0); + context_run_brush(0); } ///end } diff --git a/base/Sources/ui_nodes.ts b/base/Sources/ui_nodes.ts index e2f9b962..1f9b56f1 100644 --- a/base/Sources/ui_nodes.ts +++ b/base/Sources/ui_nodes.ts @@ -981,9 +981,9 @@ function ui_nodes_render() { ///else - let brush_node: LogicNode = parser_logic_get_logic_node(sel); + let brush_node: logic_node_t = parser_logic_get_logic_node(sel); if (brush_node != null) { - img = brush_node.get_cached_image(); + img = logic_node_get_cached_image(brush_node); } ///end diff --git a/base/Sources/ui_view2d.ts b/base/Sources/ui_view2d.ts index 32f69e41..86b03852 100644 --- a/base/Sources/ui_view2d.ts +++ b/base/Sources/ui_view2d.ts @@ -150,9 +150,9 @@ function ui_view2d_render() { let nodes: zui_nodes_t = ui_nodes_get_nodes(); if (nodes.nodes_selected_id.length > 0) { let sel: zui_node_t = zui_get_node(ui_nodes_get_canvas(true).nodes, nodes.nodes_selected_id[0]); - let brush_node: LogicNode = parser_logic_get_logic_node(sel); + let brush_node: logic_node_t = parser_logic_get_logic_node(sel); if (brush_node != null) { - tex = brush_node.get_cached_image(); + tex = logic_node_get_cached_image(brush_node); } }