Skip to content

Commit

Permalink
Brush node fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed Sep 24, 2024
1 parent 2ff0218 commit 20ac542
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
4 changes: 2 additions & 2 deletions armorpaint/sources/nodes/brush_output_node.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

type brush_output_node_t = {
base?: logic_node_t;
Directional?: bool; // button 0
};

function brush_output_node_create(arg: any): brush_output_node_t {
Expand Down Expand Up @@ -70,7 +69,8 @@ function brush_output_node_parse_inputs(self: brush_output_node_t) {
make_material_parse_paint_material();
}

context_raw.brush_directional = self.Directional;
let n: ui_node_t = map_get(parser_logic_raw_map, self);
context_raw.brush_directional = n.buttons[0].default_value[0] > 0.0;
}

function brush_output_node_run(self: brush_output_node_t, from: i32) {
Expand Down
2 changes: 1 addition & 1 deletion armorpaint/sources/nodes/input_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ let input_node_def: ui_node_t = {
name: _tr("Position"),
type: "VECTOR",
color: 0xff63c763,
default_value: null,
default_value: f32_array_create_xyz(0.0, 0.0, 0.0),
min: 0.0,
max: 1.0,
precision: 100,
Expand Down
14 changes: 9 additions & 5 deletions armorpaint/sources/nodes/tex_image_node.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

type tex_image_node_t = {
base?: logic_node_t;
file?: string;
color_space?: string;
};

function tex_image_node_create(arg: any): tex_image_node_t {
Expand All @@ -13,20 +11,26 @@ function tex_image_node_create(arg: any): tex_image_node_t {
}

function tex_image_node_get(self: tex_image_node_t, from: i32): logic_node_value_t {
let n: ui_node_t = map_get(parser_logic_raw_map, self);
let ar: string[] = ui_nodes_enum_texts(n.type);
let i: i32 = n.buttons[0].default_value[0];
let file: string = ar[i];

if (from == 0) {
let v: logic_node_value_t = { _str: self.file + ".rgb" };
let v: logic_node_value_t = { _str: file + ".rgb" };
return v;
}
else {
let v: logic_node_value_t = { _str: self.file + ".a" };
let v: logic_node_value_t = { _str: file + ".a" };
return v;
}
}

let tex_image_node_def: ui_node_t = {
id: 0,
name: _tr("Image Texture"),
type: "tex_image_node",
// type: "tex_image_node",
type: "TEX_IMAGE",
x: 0,
y: 0,
color: 0xff4982a0,
Expand Down
3 changes: 2 additions & 1 deletion armorpaint/sources/nodes_brush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ let nodes_brush_creates: map_t<string, (args: f32_array_t)=>logic_node_ext_t>;
function nodes_brush_init() {
nodes_brush_creates = map_create();
map_set(nodes_brush_creates, "brush_output_node", brush_output_node_create);
map_set(nodes_brush_creates, "tex_image_node", tex_image_node_create);
// map_set(nodes_brush_creates, "tex_image_node", tex_image_node_create);
map_set(nodes_brush_creates, "TEX_IMAGE", tex_image_node_create);
map_set(nodes_brush_creates, "input_node", input_node_create);
map_set(nodes_brush_creates, "math_node", math_node_create);
map_set(nodes_brush_creates, "random_node", random_node_create);
Expand Down
27 changes: 21 additions & 6 deletions base/sources/operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,27 @@ function operator_shortcut(s: string, type: shortcut_type_t = shortcut_type_t.ST
return flag;
}

let key: bool = (s == "left" || s == "right" || s == "middle") ?
// Mouse
(type == shortcut_type_t.DOWN ? mouse_down(s) : mouse_started(s)) :
// Keyboard
(type == shortcut_type_t.REPEAT ? keyboard_repeat(s) : type == shortcut_type_t.DOWN ? keyboard_down(s) :
type == shortcut_type_t.RELEASED ? keyboard_released(s) : keyboard_started(s));
let key: bool = false;
if (s == "left" || s == "right" || s == "middle") {
if (type == shortcut_type_t.DOWN) {
key = mouse_down(s);
}
else {
key = mouse_started(s);
}
}
else if (type == shortcut_type_t.REPEAT) {
key = keyboard_repeat(s);
}
else if (type == shortcut_type_t.DOWN) {
key = keyboard_down(s);
}
else if (type == shortcut_type_t.RELEASED) {
key = keyboard_released(s);
}
else {
key = keyboard_started(s);
}

return flag && key;
}
Expand Down
13 changes: 0 additions & 13 deletions base/sources/parser_logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,6 @@ function parser_logic_build_node(node: ui_node_t): string {
map_set(parser_logic_node_map, name, v);
map_set(parser_logic_raw_map, v, node);

// Expose button values in node
// for (let i: i32 = 0; i < node.buttons.length; ++i) {
// let b: ui_node_button_t = node.buttons[i];
// if (b.type == "ENUM") {
// let array_data: bool = b.data.length > 1;
// let texts: string[] = array_data ? b.data : ui_enum_texts_js(node.type);
// v[b.name] = texts[b.default_value];
// }
// else {
// v[b.name] = b.default_value;
// }
// }

// Create inputs
let inp_node: logic_node_ext_t = null;
let inp_from: i32 = 0;
Expand Down

0 comments on commit 20ac542

Please sign in to comment.