diff --git a/Sources/arm/App.hx b/Sources/arm/App.hx index 65874162..2f535d77 100644 --- a/Sources/arm/App.hx +++ b/Sources/arm/App.hx @@ -355,12 +355,12 @@ class App extends iron.Trait { var isPicker = UITrait.inst.selectedTool == ToolPicker; Zui.alwaysRedrawWindow = showMenu || - isDragging || - (!UITrait.inst.brush3d) || showBox || + isDragging || isPicker || - UIView2D.inst.show || decal || + UIView2D.inst.show || + !UITrait.inst.brush3d || UITrait.inst.frame < 3; if (Zui.alwaysRedrawWindow && UITrait.inst.ddirty < 0) UITrait.inst.ddirty = 0; } diff --git a/Sources/arm/renderpath/RenderPathDeferred.hx b/Sources/arm/renderpath/RenderPathDeferred.hx index a7561e24..d0273af2 100644 --- a/Sources/arm/renderpath/RenderPathDeferred.hx +++ b/Sources/arm/renderpath/RenderPathDeferred.hx @@ -186,7 +186,8 @@ class RenderPathDeferred { lastY = mouse.y; if (!UITrait.inst.dirty()) { - if (mx != lastX || my != lastY || UITrait.inst.ddirty > -2 || mouse.locked) { + if (mx != lastX || my != lastY || mouse.locked) UITrait.inst.ddirty = 0; + if (UITrait.inst.ddirty > -2) { path.setTarget(""); path.bindTarget(taaFrame % 2 == 0 ? "taa" : "taa2", "tex"); ssaa4 ? diff --git a/Sources/arm/ui/UIMenu.hx b/Sources/arm/ui/UIMenu.hx index ddfcb164..c88e3778 100644 --- a/Sources/arm/ui/UIMenu.hx +++ b/Sources/arm/ui/UIMenu.hx @@ -211,12 +211,12 @@ class UIMenu { g.begin(false); } - public static function show(commands:Zui->Void = null) { + public static function show(commands:Zui->Void = null, x = -1, y = -1) { var uibox = App.uibox; App.showMenu = true; menuCommands = commands; - menuX = Std.int(iron.App.x() + iron.system.Input.getMouse().x); - menuY = Std.int(iron.App.y() + iron.system.Input.getMouse().y); + menuX = x > -1 ? x : Std.int(iron.App.x() + iron.system.Input.getMouse().x); + menuY = y > -1 ? y : Std.int(iron.App.y() + iron.system.Input.getMouse().y); var menuw = uibox.ELEMENT_W() * 1.5; if (menuX + menuw > kha.System.windowWidth()) { menuX = Std.int(kha.System.windowWidth() - menuw); diff --git a/Sources/arm/ui/UINodes.hx b/Sources/arm/ui/UINodes.hx index 37f70353..b951a06d 100644 --- a/Sources/arm/ui/UINodes.hx +++ b/Sources/arm/ui/UINodes.hx @@ -238,61 +238,7 @@ class UINodes extends iron.Trait { } // Node search popup - if (keyboard.started("space")) { - var searchHandle = Id.handle(); - var first = true; - UIMenu.show(function(ui:Zui) { - ui.fill(0, 0, ui._w / ui.SCALE, ui.t.ELEMENT_H * 8, ui.t.WINDOW_BG_COL); - ui.textInput(searchHandle, ""); - ui.changed = false; - if (first) { - first = false; - ui.startTextEdit(searchHandle); // Focus search bar - ui.textSelectedCurrentText = searchHandle.text; - searchHandle.text = ""; - nodeSearchLast = ""; - - } - var search = ui.textSelectedCurrentText.toLowerCase(); - if (searchHandle.text != "") search = searchHandle.text; - if (search != nodeSearchLast) { - nodeSearchOffset = 0; - nodeSearchLast = search; - } - if (ui.isKeyDown) { // Move selection - if (ui.key == kha.input.KeyCode.Down && nodeSearchOffset < 6) nodeSearchOffset++; - if (ui.key == kha.input.KeyCode.Up && nodeSearchOffset > 0) nodeSearchOffset--; - } - var enter = keyboard.down("enter"); - var count = 0; - var BUTTON_COL = ui.t.BUTTON_COL; - for (list in NodeCreator.list) { - for (n in list) { - if (n.name.toLowerCase().indexOf(search) >= 0) { - ui.t.BUTTON_COL = count == nodeSearchOffset ? ui.t.HIGHLIGHT_COL : ui.t.WINDOW_BG_COL; - if (ui.button(n.name, Left) || (enter && count == nodeSearchOffset)) { - nodeSearchSpawn = makeNode(n, nodes, canvas); // Spawn selected node - canvas.nodes.push(nodeSearchSpawn); - nodes.nodesSelected = [nodeSearchSpawn]; - nodes.nodesDrag = true; - hwnd.redraws = 2; - if (enter) { - ui.changed = true; - count = 6; // Trigger break - } - } - if (++count > 6) break; - } - } - if (count > 6) break; - } - if (enter && count == 0) { // Hide popup on enter when node is not found - ui.changed = true; - searchHandle.text = ""; - } - ui.t.BUTTON_COL = BUTTON_COL; - }); - } + if (keyboard.started("space")) nodeSearch(); if (nodeSearchSpawn != null) { ui.inputX = mouse.x + App.x(); // Fix inputDX after popup removal ui.inputY = mouse.y + App.y(); @@ -300,6 +246,64 @@ class UINodes extends iron.Trait { } } + function nodeSearch(x = -1, y = -1) { + var keyboard = iron.system.Input.getKeyboard(); + var searchHandle = Id.handle(); + var first = true; + UIMenu.show(function(ui:Zui) { + ui.fill(0, 0, ui._w / ui.SCALE, ui.t.ELEMENT_H * 8, ui.t.WINDOW_BG_COL); + ui.textInput(searchHandle, ""); + ui.changed = false; + if (first) { + first = false; + ui.startTextEdit(searchHandle); // Focus search bar + ui.textSelectedCurrentText = searchHandle.text; + searchHandle.text = ""; + nodeSearchLast = ""; + } + var search = ui.textSelectedCurrentText.toLowerCase(); + if (searchHandle.text != "") search = searchHandle.text; + if (search != nodeSearchLast) { + nodeSearchOffset = 0; + nodeSearchLast = search; + } + if (ui.isKeyDown) { // Move selection + if (ui.key == kha.input.KeyCode.Down && nodeSearchOffset < 6) nodeSearchOffset++; + if (ui.key == kha.input.KeyCode.Up && nodeSearchOffset > 0) nodeSearchOffset--; + } + var enter = keyboard.down("enter"); + var count = 0; + var BUTTON_COL = ui.t.BUTTON_COL; + var nodeList = canvasType == 0 ? NodeCreator.list : NodeCreatorBrush.list; + for (list in nodeList) { + for (n in list) { + if (n.name.toLowerCase().indexOf(search) >= 0) { + ui.t.BUTTON_COL = count == nodeSearchOffset ? ui.t.HIGHLIGHT_COL : ui.t.WINDOW_BG_COL; + if (ui.button(n.name, Left) || (enter && count == nodeSearchOffset)) { + var canvas = getCanvas(); + nodeSearchSpawn = makeNode(n, nodes, canvas); // Spawn selected node + canvas.nodes.push(nodeSearchSpawn); + nodes.nodesSelected = [nodeSearchSpawn]; + nodes.nodesDrag = true; + hwnd.redraws = 2; + if (enter) { + ui.changed = true; + count = 6; // Trigger break + } + } + if (++count > 6) break; + } + } + if (count > 6) break; + } + if (enter && count == 0) { // Hide popup on enter when node is not found + ui.changed = true; + searchHandle.text = ""; + } + ui.t.BUTTON_COL = BUTTON_COL; + }, x, y); + } + public function getNodeX():Int { var mouse = iron.system.Input.getMouse(); return Std.int((mouse.x + App.x() - wx - nodes.PAN_X()) / nodes.SCALE); @@ -434,6 +438,11 @@ class UINodes extends iron.Trait { } } + ui._x += ew + 3; + ui._y = 3; + if (ui.button("Search")) nodeSearch(Std.int(ui._windowX + ui._x), Std.int(ui._windowY + ui._y)); + if (ui.isHovered) ui.tooltip("(Space)"); + ui.t.BUTTON_COL = BUTTON_COL; } diff --git a/Sources/arm/ui/UITrait.hx b/Sources/arm/ui/UITrait.hx index dd98c4e1..1b32ce37 100644 --- a/Sources/arm/ui/UITrait.hx +++ b/Sources/arm/ui/UITrait.hx @@ -2485,7 +2485,7 @@ class UITrait extends iron.Trait { } function tabProperties() { - if (ui.tab(htab, 'Properties')) { + if (ui.tab(htab1, 'Properties')) { if (selectedObject != null) { var h = Id.handle(); diff --git a/compiled/Glsl/Material_voxel.vert.glsl b/compiled/Glsl/Material_voxel.vert.glsl new file mode 100644 index 00000000..11c05db2 --- /dev/null +++ b/compiled/Glsl/Material_voxel.vert.glsl @@ -0,0 +1,9 @@ +#version 450 +#include "../Shaders/compiled.inc" +in vec4 pos; +in vec2 nor; +out vec3 voxpositionGeom; +uniform mat4 W; +void main() { + voxpositionGeom = vec3(W * vec4(pos.xyz, 1.0)) / voxelgiHalfExtents; +} diff --git a/compiled/Glsl/armdefault_voxel.frag.glsl b/compiled/Glsl/armdefault_voxel.frag.glsl new file mode 100644 index 00000000..19609ec8 --- /dev/null +++ b/compiled/Glsl/armdefault_voxel.frag.glsl @@ -0,0 +1,11 @@ +#version 450 +#extension GL_ARB_shader_image_load_store : enable +#include "../Shaders/compiled.inc" +#include "../Shaders/std/math.glsl" +#include "../Shaders/std/imageatomic.glsl" +in vec3 voxposition; +uniform layout(r8) writeonly image3D voxels; +void main() { + if (abs(voxposition.z) > 1.0 || abs(voxposition.x) > 1 || abs(voxposition.y) > 1) return; + imageStore(voxels, ivec3(voxelgiResolution * (voxposition * 0.5 + 0.5)), vec4(1.0)); +} diff --git a/compiled/Glsl/armdefault_voxel.geom.glsl b/compiled/Glsl/armdefault_voxel.geom.glsl new file mode 100644 index 00000000..ad03390c --- /dev/null +++ b/compiled/Glsl/armdefault_voxel.geom.glsl @@ -0,0 +1,25 @@ +#version 450 +layout(triangles) in; +layout(triangle_strip) out; +layout(max_vertices=3) out; +in vec3 voxpositionGeom[]; +out vec3 voxposition; +void main() { + vec3 p1 = voxpositionGeom[1] - voxpositionGeom[0]; + vec3 p2 = voxpositionGeom[2] - voxpositionGeom[0]; + vec3 p = abs(cross(p1, p2)); + for (uint i = 0; i < 3; ++i) { + voxposition = voxpositionGeom[i]; + if (p.z > p.x && p.z > p.y) { + gl_Position = vec4(voxposition.x, voxposition.y, 0.0, 1.0); + } + else if (p.x > p.y && p.x > p.z) { + gl_Position = vec4(voxposition.y, voxposition.z, 0.0, 1.0); + } + else { + gl_Position = vec4(voxposition.x, voxposition.z, 0.0, 1.0); + } + EmitVertex(); + } + EndPrimitive(); +} diff --git a/compiled/Glsl/armdefault_voxel.vert.glsl b/compiled/Glsl/armdefault_voxel.vert.glsl new file mode 100644 index 00000000..11c05db2 --- /dev/null +++ b/compiled/Glsl/armdefault_voxel.vert.glsl @@ -0,0 +1,9 @@ +#version 450 +#include "../Shaders/compiled.inc" +in vec4 pos; +in vec2 nor; +out vec3 voxpositionGeom; +uniform mat4 W; +void main() { + voxpositionGeom = vec3(W * vec4(pos.xyz, 1.0)) / voxelgiHalfExtents; +} diff --git a/khafile.js b/khafile.js index 2c7729a0..cba60bdb 100644 --- a/khafile.js +++ b/khafile.js @@ -6,7 +6,6 @@ project.addLibrary("iron"); project.addLibrary("zui"); project.addLibrary("iron_format"); project.addShaders("compiled/Shaders/*.glsl", { noembed: false}); -project.addShaders("compiled/Hlsl/*.glsl", { noprocessing: true, noembed: false }); project.addAssets("compiled/Assets/**", { notinlist: true , destination: "data/{name}" }); project.addAssets("compiled/Shaders/*.arm", { notinlist: true , destination: "data/{name}" }); project.addAssets("Bundled/data/**", { notinlist: true , destination: "data/{name}" }); @@ -54,6 +53,13 @@ project.addDefine('arm_data_dir'); project.addParameter('--macro include("arm.brushnode")'); project.addParameter('-dce full'); +if (process.platform === 'win32') { + project.addShaders("compiled/Hlsl/*.glsl", { noprocessing: true, noembed: false }); +} +else { + project.addShaders("compiled/Glsl/*.glsl", { noembed: false }); +} + if (process.platform === 'win32') { project.addAssets("Bundled/cmft/cmft.exe", { notinlist: true , destination: "data/{name}" }); }