From d6913f929832c41f10c7dd5eaff1645da2c0786c Mon Sep 17 00:00:00 2001 From: luboslenco Date: Mon, 29 Jan 2024 09:37:53 +0100 Subject: [PATCH] Prepare iron to c port --- armorforge/Sources/TabObjects.ts | 1 - armorpaint/Assets/Scene.arm | Bin 174584 -> 174039 bytes armorpaint/Sources/RenderPathPaint.ts | 11 +- armorpaint/Sources/TabLayers.ts | 15 +- armorpaint/Sources/nodes/BrushOutputNode.ts | 2 +- armorpaint/Sources/nodes/InputNode.ts | 39 +++-- armorsculpt/Sources/TabLayers.ts | 12 +- armorsculpt/Sources/nodes/BrushOutputNode.ts | 2 +- base/Sources/Base.ts | 57 ++++--- base/Sources/BoxPreferences.ts | 2 +- base/Sources/Camera.ts | 116 +++++++-------- base/Sources/Context.ts | 56 ++++--- base/Sources/ExportArm.ts | 4 +- base/Sources/Gizmo.ts | 29 ++-- base/Sources/ImportArm.ts | 4 +- base/Sources/ImportEnvmap.ts | 12 +- base/Sources/Operator.ts | 14 +- base/Sources/PhysicsBody.ts | 2 +- base/Sources/Project.ts | 8 +- base/Sources/RenderPathBase.ts | 13 +- base/Sources/RenderPathRaytrace.ts | 4 +- base/Sources/TabBrushes.ts | 5 +- base/Sources/TabMaterials.ts | 5 +- base/Sources/TabSwatches.ts | 10 +- base/Sources/TabTextures.ts | 5 +- base/Sources/UIBase.ts | 149 +++++++++---------- base/Sources/UIBox.ts | 8 +- base/Sources/UIFiles.ts | 12 +- base/Sources/UIHeader.ts | 5 +- base/Sources/UIMenu.ts | 18 +-- base/Sources/UINodes.ts | 23 +-- base/Sources/UIView2D.ts | 19 +-- base/Sources/UniformsExt.ts | 33 ++-- base/Sources/UtilParticle.ts | 2 +- base/Sources/UtilRender.ts | 26 ++-- base/Sources/Viewport.ts | 10 +- 36 files changed, 333 insertions(+), 400 deletions(-) diff --git a/armorforge/Sources/TabObjects.ts b/armorforge/Sources/TabObjects.ts index 8b9c82cf..86bf6631 100644 --- a/armorforge/Sources/TabObjects.ts +++ b/armorforge/Sources/TabObjects.ts @@ -184,7 +184,6 @@ class TabObjects { Context.raw.selectedObject.transform.rot.fromEuler(rot.x, rot.y, rot.z); Context.raw.selectedObject.transform.buildMatrix(); // ///if arm_physics - // let rb = Context.raw.selectedObject.getTrait(RigidBody); // if (rb != null) rb.syncTransform(); // ///end } diff --git a/armorpaint/Assets/Scene.arm b/armorpaint/Assets/Scene.arm index 04306fd7f769ae287c121b53504ac0bad76faab2..405b03b11b33b79f13787b415d73256ee9454fe2 100644 GIT binary patch delta 326 zcmexynd|y_t_fO)F!`YVV#&JI$4xeXyVNEj2vLGdPa%Kiy1G%Rd7$<#>5X) zA~E?T(^@3a8_W<c6p4#-6 zii`rB>~*^rz6|gZ%5kqV}85 s2xN%@ndWMNlUJ$DXXKphrLH+SPeXC?Qgz2>5sh{c4aV&v8ca_b0bSx`%m4rY delta 837 zcmcb9p6kbDt_fO#oD2*Mx7mP1Nl{{EN%38V$^NWrlk-_vCx(e~fW&k2lQJjQGmA~E zT`$OmRq;y!?#XeCya?6lj8}1*%RM=di65b~o>^w{RHn7Km5WE-W(V3@mRX#cl#_Z0 z>{O_ePU6%hg=)b<7VH+-Bb4>ANl#wNid~rjPB-+ioxth_gURjeNS*{4zLp)k;cAn6 zIr%2{b08_7#c>9!sUW4Y2q(|tke_^%6Q8Nexll}%pL~&Ptsn z3UC9(k`s$d;)^p9Q}W9XPoAKftjhxwgz$^wlQI*FPl<28XmOhlE}ENI5MP{Gm3j#% T!qEIlwf&PS { - let mouse = Input.getMouse(); let mx = RenderPathPaint.lastX; let my = RenderPathPaint.lastY; - RenderPathPaint.lastX = mouse.viewX; - RenderPathPaint.lastY = mouse.viewY; + RenderPathPaint.lastX = Mouse.viewX; + RenderPathPaint.lastY = Mouse.viewY; if (Config.raw.brush_live && Context.raw.pdirty <= 0) { let moved = (mx != RenderPathPaint.lastX || my != RenderPathPaint.lastY) && (Context.inViewport() || Context.in2dView()); if (moved || Context.raw.brushLocked) { @@ -798,12 +797,12 @@ class RenderPathPaint { let cam = Scene.active.camera; Context.raw.savedCamera.setFrom(cam.transform.local); - RenderPathPaint.savedFov = cam.data.raw.fov; + RenderPathPaint.savedFov = cam.data.fov; Viewport.updateCameraType(CameraType.CameraPerspective); let m = Mat4.identity(); m.translate(0, 0, 0.5); cam.transform.setMatrix(m); - cam.data.raw.fov = Base.defaultFov; + cam.data.fov = Base.defaultFov; cam.buildProjection(); cam.buildMatrix(); @@ -869,7 +868,7 @@ class RenderPathPaint { } Context.raw.paintObject = RenderPathPaint.painto; Scene.active.camera.transform.setMatrix(Context.raw.savedCamera); - Scene.active.camera.data.raw.fov = RenderPathPaint.savedFov; + Scene.active.camera.data.fov = RenderPathPaint.savedFov; Viewport.updateCameraType(Context.raw.cameraType); Scene.active.camera.buildProjection(); Scene.active.camera.buildMatrix(); diff --git a/armorpaint/Sources/TabLayers.ts b/armorpaint/Sources/TabLayers.ts index 0f7fb878..1365ef42 100644 --- a/armorpaint/Sources/TabLayers.ts +++ b/armorpaint/Sources/TabLayers.ts @@ -234,10 +234,9 @@ class TabLayers { let checkw = (ui._windowW / 100 * 8) / ui.SCALE(); // Highlight drag destination - let mouse = Input.getMouse(); let absy = ui._windowY + ui._y; if (Base.isDragging && Base.dragLayer != null && Context.inLayers()) { - if (mouse.y > absy + step && mouse.y < absy + step * 3) { + if (Mouse.y > absy + step && Mouse.y < absy + step * 3) { let down = Project.layers.indexOf(Base.dragLayer) >= i; Context.raw.dragDestination = down ? i : i - 1; @@ -251,7 +250,7 @@ class TabLayers { } } } - else if (i == Project.layers.length - 1 && mouse.y < absy + step) { + else if (i == Project.layers.length - 1 && Mouse.y < absy + step) { Context.raw.dragDestination = Project.layers.length - 1; if (SlotLayer.canMove(Context.raw.layer, Context.raw.dragDestination)) { ui.fill(checkw, 0, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL); @@ -259,12 +258,12 @@ class TabLayers { } } if (Base.isDragging && (Base.dragMaterial != null || Base.dragSwatch != null) && Context.inLayers()) { - if (mouse.y > absy + step && mouse.y < absy + step * 3) { + if (Mouse.y > absy + step && Mouse.y < absy + step * 3) { Context.raw.dragDestination = i; if (TabLayers.canDropNewLayer(i)) ui.fill(checkw, 2 * step, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL); } - else if (i == Project.layers.length - 1 && mouse.y < absy + step) { + else if (i == Project.layers.length - 1 && Mouse.y < absy + step) { Context.raw.dragDestination = Project.layers.length; if (TabLayers.canDropNewLayer(Project.layers.length)) ui.fill(checkw, 0, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL); @@ -366,8 +365,7 @@ class TabLayers { ui.inputY > ui._windowY + ui._y - center && ui.inputY < ui._windowY + ui._y - center + (step * ui.SCALE()) * 2) { if (ui.inputStarted) { Context.setLayer(l); - let mouse = Input.getMouse(); - TabLayers.setDragLayer(Context.raw.layer, -(mouse.x - uix - ui._windowX - 3), -(mouse.y - uiy - ui._windowY + 1)); + TabLayers.setDragLayer(Context.raw.layer, -(Mouse.x - uix - ui._windowX - 3), -(Mouse.y - uiy - ui._windowY + 1)); } else if (ui.inputReleasedR) { Context.setLayer(l); @@ -563,8 +561,7 @@ class TabLayers { if (state == State.Started) { Context.setLayer(l); - let mouse = Input.getMouse(); - TabLayers.setDragLayer(Context.raw.layer, -(mouse.x - uix - ui._windowX - 3), -(mouse.y - uiy - ui._windowY + 1)); + TabLayers.setDragLayer(Context.raw.layer, -(Mouse.x - uix - ui._windowX - 3), -(Mouse.y - uiy - ui._windowY + 1)); } else if (state == State.Released) { if (Time.time() - Context.raw.selectTime < 0.2) { diff --git a/armorpaint/Sources/nodes/BrushOutputNode.ts b/armorpaint/Sources/nodes/BrushOutputNode.ts index a1e7dbe7..cb588df0 100644 --- a/armorpaint/Sources/nodes/BrushOutputNode.ts +++ b/armorpaint/Sources/nodes/BrushOutputNode.ts @@ -111,7 +111,7 @@ class BrushOutputNode extends LogicNode { !Base.isComboSelected()) { // Set color pick - let down = Input.getMouse().down() || Input.getPen().down(); + let down = Mouse.down() || Pen.down(); if (down && Context.raw.tool == WorkspaceTool.ToolColorId && Project.assets.length > 0) { Context.raw.colorIdPicked = true; UIToolbar.toolbarHandle.redraws = 1; diff --git a/armorpaint/Sources/nodes/InputNode.ts b/armorpaint/Sources/nodes/InputNode.ts index f5519cab..2ced705a 100644 --- a/armorpaint/Sources/nodes/InputNode.ts +++ b/armorpaint/Sources/nodes/InputNode.ts @@ -26,7 +26,7 @@ class InputNode extends LogicNode { update = () => { if (Context.raw.splitView) { - Context.raw.viewIndex = Input.getMouse().viewX > Base.w() / 2 ? 1 : 0; + Context.raw.viewIndex = Mouse.viewX > Base.w() / 2 ? 1 : 0; } let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText; @@ -37,22 +37,20 @@ class InputNode extends LogicNode { Operator.shortcut(Config.keymap.brush_ruler + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown) || decalMask); - let mouse = Input.getMouse(); - let paintX = mouse.viewX / App.w(); - let paintY = mouse.viewY / App.h(); - if (mouse.started()) { - InputNode.startX = mouse.viewX / App.w(); - InputNode.startY = mouse.viewY / App.h(); + let paintX = Mouse.viewX / App.w(); + let paintY = Mouse.viewY / App.h(); + if (Mouse.started()) { + InputNode.startX = Mouse.viewX / App.w(); + InputNode.startY = Mouse.viewY / App.h(); } - let pen = Input.getPen(); - if (pen.down()) { - paintX = pen.viewX / App.w(); - paintY = pen.viewY / App.h(); + if (Pen.down()) { + paintX = Pen.viewX / App.w(); + paintY = Pen.viewY / App.h(); } - if (pen.started()) { - InputNode.startX = pen.viewX / App.w(); - InputNode.startY = pen.viewY / App.h(); + if (Pen.started()) { + InputNode.startX = Pen.viewX / App.w(); + InputNode.startY = Pen.viewY / App.h(); } if (Operator.shortcut(Config.keymap.brush_ruler + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown)) { @@ -74,21 +72,20 @@ class InputNode extends LogicNode { } if (InputNode.lockBegin) { - let dx = Math.abs(InputNode.lockStartX - mouse.viewX); - let dy = Math.abs(InputNode.lockStartY - mouse.viewY); + let dx = Math.abs(InputNode.lockStartX - Mouse.viewX); + let dy = Math.abs(InputNode.lockStartY - Mouse.viewY); if (dx > 1 || dy > 1) { InputNode.lockBegin = false; dx > dy ? InputNode.lockY = true : InputNode.lockX = true; } } - let kb = Input.getKeyboard(); - if (kb.started(Config.keymap.brush_ruler)) { - InputNode.lockStartX = mouse.viewX; - InputNode.lockStartY = mouse.viewY; + if (Keyboard.started(Config.keymap.brush_ruler)) { + InputNode.lockStartX = Mouse.viewX; + InputNode.lockStartY = Mouse.viewY; InputNode.lockBegin = true; } - else if (kb.released(Config.keymap.brush_ruler)) { + else if (Keyboard.released(Config.keymap.brush_ruler)) { InputNode.lockX = InputNode.lockY = InputNode.lockBegin = false; } diff --git a/armorsculpt/Sources/TabLayers.ts b/armorsculpt/Sources/TabLayers.ts index ccce6834..9283a0e0 100644 --- a/armorsculpt/Sources/TabLayers.ts +++ b/armorsculpt/Sources/TabLayers.ts @@ -140,10 +140,9 @@ class TabLayers { let checkw = (ui._windowW / 100 * 8) / ui.SCALE(); // Highlight drag destination - let mouse = Input.getMouse(); let absy = ui._windowY + ui._y; if (Base.isDragging && Base.dragLayer != null && Context.inLayers()) { - if (mouse.y > absy + step && mouse.y < absy + step * 3) { + if (Mouse.y > absy + step && Mouse.y < absy + step * 3) { let down = Project.layers.indexOf(Base.dragLayer) >= i; Context.raw.dragDestination = down ? i : i - 1; @@ -157,7 +156,7 @@ class TabLayers { } } } - else if (i == Project.layers.length - 1 && mouse.y < absy + step) { + else if (i == Project.layers.length - 1 && Mouse.y < absy + step) { Context.raw.dragDestination = Project.layers.length - 1; if (SlotLayer.canMove(Context.raw.layer, Context.raw.dragDestination)) { ui.fill(checkw, 0, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL); @@ -165,12 +164,12 @@ class TabLayers { } } if (Base.isDragging && (Base.dragMaterial != null || Base.dragSwatch != null) && Context.inLayers()) { - if (mouse.y > absy + step && mouse.y < absy + step * 3) { + if (Mouse.y > absy + step && Mouse.y < absy + step * 3) { Context.raw.dragDestination = i; if (TabLayers.canDropNewLayer(i)) ui.fill(checkw, 2 * step, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL); } - else if (i == Project.layers.length - 1 && mouse.y < absy + step) { + else if (i == Project.layers.length - 1 && Mouse.y < absy + step) { Context.raw.dragDestination = Project.layers.length; if (TabLayers.canDropNewLayer(Project.layers.length)) ui.fill(checkw, 0, (ui._windowW / ui.SCALE() - 2) - checkw, 2 * ui.SCALE(), ui.t.HIGHLIGHT_COL); @@ -246,8 +245,7 @@ class TabLayers { ui.inputY > ui._windowY + ui._y - center && ui.inputY < ui._windowY + ui._y - center + (step * ui.SCALE()) * 2) { if (ui.inputStarted) { Context.setLayer(l); - let mouse = Input.getMouse(); - TabLayers.setDragLayer(Context.raw.layer, -(mouse.x - uix - ui._windowX - 3), -(mouse.y - uiy - ui._windowY + 1)); + TabLayers.setDragLayer(Context.raw.layer, -(Mouse.x - uix - ui._windowX - 3), -(Mouse.y - uiy - ui._windowY + 1)); } else if (ui.inputReleased) { if (Time.time() - Context.raw.selectTime > 0.2) { diff --git a/armorsculpt/Sources/nodes/BrushOutputNode.ts b/armorsculpt/Sources/nodes/BrushOutputNode.ts index 8e5e694d..03894b03 100644 --- a/armorsculpt/Sources/nodes/BrushOutputNode.ts +++ b/armorsculpt/Sources/nodes/BrushOutputNode.ts @@ -104,7 +104,7 @@ class BrushOutputNode extends LogicNode { !Base.isScrolling() && !Base.isComboSelected()) { - let down = Input.getMouse().down() || Input.getPen().down(); + let down = Mouse.down() || Pen.down(); // Prevent painting the same spot let sameSpot = Context.raw.paintVec.x == Context.raw.lastPaintX && Context.raw.paintVec.y == Context.raw.lastPaintY; diff --git a/base/Sources/Base.ts b/base/Sources/Base.ts index f932d1c4..7f88edc3 100644 --- a/base/Sources/Base.ts +++ b/base/Sources/Base.ts @@ -126,8 +126,8 @@ class Base { () => {}, // Pause () => { // Background // Release keys after alt-tab / win-tab - Input.getKeyboard().upListener(KeyCode.Alt); - Input.getKeyboard().upListener(KeyCode.Win); + Keyboard.upListener(KeyCode.Alt); + Keyboard.upListener(KeyCode.Win); }, () => { // Shutdown ///if (krom_android || krom_ios) @@ -208,7 +208,7 @@ class Base { Base.appy = UIHeader.headerh; if (Config.raw.layout[LayoutSize.LayoutHeader] == 1) Base.appy += UIHeader.headerh; let cam = Scene.active.camera; - cam.data.raw.fov = Math.floor(cam.data.raw.fov * 100) / 100; + cam.data.fov = Math.floor(cam.data.fov * 100) / 100; cam.buildProjection(); Args.run(); @@ -385,9 +385,9 @@ class Base { if (System.width == 0 || System.height == 0) return; let cam = Scene.active.camera; - if (cam.data.raw.ortho != null) { - cam.data.raw.ortho[2] = -2 * (App.h() / App.w()); - cam.data.raw.ortho[3] = 2 * (App.h() / App.w()); + if (cam.data.ortho != null) { + cam.data.ortho[2] = -2 * (App.h() / App.w()); + cam.data.ortho[3] = 2 * (App.h() / App.w()); } cam.buildProjection(); @@ -444,10 +444,7 @@ class Base { } static update = () => { - - let mouse = Input.getMouse(); - - if (mouse.movementX != 0 || mouse.movementY != 0) { + if (Mouse.movementX != 0 || Mouse.movementY != 0) { Krom.setMouseCursor(0); // Arrow } @@ -461,15 +458,15 @@ class Base { if (Config.raw.touch_ui) { // Touch and hold to activate dragging if (Base.dragStart < 0.2) { - if (hasDrag && mouse.down()) Base.dragStart += Time.realDelta; + if (hasDrag && Mouse.down()) Base.dragStart += Time.realDelta; else Base.dragStart = 0; hasDrag = false; } - if (mouse.released()) { + if (Mouse.released()) { Base.dragStart = 0; } - let moved = Math.abs(mouse.movementX) > 1 && Math.abs(mouse.movementY) > 1; - if ((mouse.released() || moved) && !hasDrag) { + let moved = Math.abs(Mouse.movementX) > 1 && Math.abs(Mouse.movementY) > 1; + if ((Mouse.released() || moved) && !hasDrag) { Base.dragAsset = null; Base.dragSwatch = null; Base.dragFile = null; @@ -484,10 +481,10 @@ class Base { Zui.touchScroll = !Base.isDragging; } - if (hasDrag && (mouse.movementX != 0 || mouse.movementY != 0)) { + if (hasDrag && (Mouse.movementX != 0 || Mouse.movementY != 0)) { Base.isDragging = true; } - if (mouse.released() && hasDrag) { + if (Mouse.released() && hasDrag) { if (Base.dragAsset != null) { if (Context.inNodes()) { // Create image texture UINodes.acceptAssetDrag(Project.assets.indexOf(Base.dragAsset)); @@ -532,8 +529,8 @@ class Base { } else if (Base.dragFile != null) { if (!Context.inBrowser()) { - Base.dropX = mouse.x; - Base.dropY = mouse.y; + Base.dropX = Mouse.x; + Base.dropY = Mouse.y; ///if (is_paint || is_sculpt) let materialCount = Project.materials.length; @@ -572,7 +569,7 @@ class Base { Krom.setMouseCursor(0); // Arrow Base.isDragging = false; } - if (Context.raw.colorPickerCallback != null && (mouse.released() || mouse.released("right"))) { + if (Context.raw.colorPickerCallback != null && (Mouse.released() || Mouse.released("right"))) { Context.raw.colorPickerCallback = null; Context.selectTool(Context.raw.colorPickerPreviousTool); } @@ -602,12 +599,12 @@ class Base { static materialDropped = () => { // Material drag and dropped onto viewport or layers tab if (Context.inViewport()) { - let uvType = Input.getKeyboard().down("control") ? UVType.UVProject : UVType.UVMap; + let uvType = Keyboard.down("control") ? UVType.UVProject : UVType.UVMap; let decalMat = uvType == UVType.UVProject ? UtilRender.getDecalMat() : null; Base.createFillLayer(uvType, decalMat); } if (Context.inLayers() && TabLayers.canDropNewLayer(Context.raw.dragDestination)) { - let uvType = Input.getKeyboard().down("control") ? UVType.UVProject : UVType.UVMap; + let uvType = Keyboard.down("control") ? UVType.UVProject : UVType.UVMap; let decalMat = uvType == UVType.UVProject ? UtilRender.getDecalMat() : null; Base.createFillLayer(uvType, decalMat, Context.raw.dragDestination); } @@ -620,15 +617,14 @@ class Base { static handleDropPaths = () => { if (Base.dropPaths.length > 0) { - let mouse = Input.getMouse(); ///if (krom_linux || krom_darwin) - let wait = !mouse.moved; // Mouse coords not updated during drag + let wait = !Mouse.moved; // Mouse coords not updated during drag ///else let wait = false; ///end if (!wait) { - Base.dropX = mouse.x; - Base.dropY = mouse.y; + Base.dropX = Mouse.x; + Base.dropY = Mouse.y; let dropPath = Base.dropPaths.shift(); ImportAsset.run(dropPath, Base.dropX, Base.dropY); } @@ -744,7 +740,6 @@ class Base { } Context.raw.frame++; - let mouse = Input.getMouse(); if (Base.isDragging) { Krom.setMouseCursor(1); // Hand let img = Base.getDragImage(); @@ -771,17 +766,17 @@ class Base { ///if (is_paint || is_sculpt) let bgRect = Base.getDragBackground(); if (bgRect != null) { - g.drawScaledSubImage(Res.get("icons.k"), bgRect.x, bgRect.y, bgRect.w, bgRect.h, mouse.x + Base.dragOffX, mouse.y + Base.dragOffY + inv, size, h - inv * 2); + g.drawScaledSubImage(Res.get("icons.k"), bgRect.x, bgRect.y, bgRect.w, bgRect.h, Mouse.x + Base.dragOffX, Mouse.y + Base.dragOffY + inv, size, h - inv * 2); } ///end Base.dragRect == null ? - g.drawScaledImage(img, mouse.x + Base.dragOffX, mouse.y + Base.dragOffY + inv, size, h - inv * 2) : - g.drawScaledSubImage(img, Base.dragRect.x, Base.dragRect.y, Base.dragRect.w, Base.dragRect.h, mouse.x + Base.dragOffX, mouse.y + Base.dragOffY + inv, size, h - inv * 2); + g.drawScaledImage(img, Mouse.x + Base.dragOffX, Mouse.y + Base.dragOffY + inv, size, h - inv * 2) : + g.drawScaledSubImage(img, Base.dragRect.x, Base.dragRect.y, Base.dragRect.w, Base.dragRect.h, Mouse.x + Base.dragOffX, Mouse.y + Base.dragOffY + inv, size, h - inv * 2); g.color = 0xffffffff; } - let usingMenu = UIMenu.show && mouse.y > UIHeader.headerh; + let usingMenu = UIMenu.show && Mouse.y > UIHeader.headerh; Base.uiEnabled = !UIBox.show && !usingMenu && !Base.isComboSelected(); if (UIBox.show) UIBox.render(g); if (UIMenu.show) UIMenu.render(g); @@ -792,7 +787,7 @@ class Base { ///if (krom_android || krom_ios) // No mouse move events for touch, re-init last paint position on touch start - if (!mouse.down()) { + if (!Mouse.down()) { Context.raw.lastPaintX = -1; Context.raw.lastPaintY = -1; } diff --git a/base/Sources/BoxPreferences.ts b/base/Sources/BoxPreferences.ts index 3f3d640b..0a599435 100644 --- a/base/Sources/BoxPreferences.ts +++ b/base/Sources/BoxPreferences.ts @@ -469,7 +469,7 @@ class BoxPreferences { // if (h.changed) Context.raw.ddirty = 2; let cam = Scene.active.camera; - let camRaw = cam.data.raw; + let camRaw = cam.data; let near_handle = Zui.handle("boxpreferences_47"); let far_handle = Zui.handle("boxpreferences_48"); near_handle.value = Math.floor(camRaw.near_plane * 1000) / 1000; diff --git a/base/Sources/Camera.ts b/base/Sources/Camera.ts index 2760ac56..937d8139 100644 --- a/base/Sources/Camera.ts +++ b/base/Sources/Camera.ts @@ -13,31 +13,29 @@ class Camera { } static update = () => { - let mouse = Input.getMouse(); - let kb = Input.getKeyboard(); let camera = Scene.active.camera; - if (mouse.viewX < 0 || - mouse.viewX > App.w() || - mouse.viewY < 0 || - mouse.viewY > App.h()) { + if (Mouse.viewX < 0 || + Mouse.viewX > App.w() || + Mouse.viewY < 0 || + Mouse.viewY > App.h()) { if (Config.raw.wrap_mouse && Camera.controlsDown) { - if (mouse.viewX < 0) { - mouse.x = mouse.lastX = App.x() + App.w(); - Krom.setMousePosition(Math.floor(mouse.x), Math.floor(mouse.y)); + if (Mouse.viewX < 0) { + Mouse.x = Mouse.lastX = App.x() + App.w(); + Krom.setMousePosition(Math.floor(Mouse.x), Math.floor(Mouse.y)); } - else if (mouse.viewX > App.w()) { - mouse.x = mouse.lastX = App.x(); - Krom.setMousePosition(Math.floor(mouse.x), Math.floor(mouse.y)); + else if (Mouse.viewX > App.w()) { + Mouse.x = Mouse.lastX = App.x(); + Krom.setMousePosition(Math.floor(Mouse.x), Math.floor(Mouse.y)); } - else if (mouse.viewY < 0) { - mouse.y = mouse.lastY = App.y() + App.h(); - Krom.setMousePosition(Math.floor(mouse.x), Math.floor(mouse.y)); + else if (Mouse.viewY < 0) { + Mouse.y = Mouse.lastY = App.y() + App.h(); + Krom.setMousePosition(Math.floor(Mouse.x), Math.floor(Mouse.y)); } - else if (mouse.viewY > App.h()) { - mouse.y = mouse.lastY = App.y(); - Krom.setMousePosition(Math.floor(mouse.x), Math.floor(mouse.y)); + else if (Mouse.viewY > App.h()) { + Mouse.y = Mouse.lastY = App.y(); + Krom.setMousePosition(Math.floor(Mouse.x), Math.floor(Mouse.y)); } } else { @@ -45,7 +43,7 @@ class Camera { } } - let modifKey = kb.down("alt") || kb.down("shift") || kb.down("control"); + let modifKey = Keyboard.down("alt") || Keyboard.down("shift") || Keyboard.down("control"); let modif = modifKey || Config.keymap.action_rotate == "middle"; let defaultKeymap = Config.raw.keymap == "default.json"; @@ -54,9 +52,9 @@ class Camera { Operator.shortcut(Config.keymap.action_pan, ShortcutType.ShortcutStarted) || Operator.shortcut(Config.keymap.rotate_envmap, ShortcutType.ShortcutStarted) || Operator.shortcut(Config.keymap.rotate_light, ShortcutType.ShortcutStarted) || - (mouse.started("right") && !modif) || - (mouse.started("middle") && !modif) || - (mouse.wheelDelta != 0 && !modifKey)) { + (Mouse.started("right") && !modif) || + (Mouse.started("middle") && !modif) || + (Mouse.wheelDelta != 0 && !modifKey)) { Camera.controlsDown = true; } else if (!Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) && @@ -64,9 +62,9 @@ class Camera { !Operator.shortcut(Config.keymap.action_pan, ShortcutType.ShortcutDown) && !Operator.shortcut(Config.keymap.rotate_envmap, ShortcutType.ShortcutDown) && !Operator.shortcut(Config.keymap.rotate_light, ShortcutType.ShortcutDown) && - !(mouse.down("right") && !modif) && - !(mouse.down("middle") && !modif) && - (mouse.wheelDelta == 0 && !modifKey)) { + !(Mouse.down("right") && !modif) && + !(Mouse.down("middle") && !modif) && + (Mouse.wheelDelta == 0 && !modifKey)) { Camera.controlsDown = false; } @@ -80,27 +78,27 @@ class Camera { } let controls = Context.raw.cameraControls; - if (controls == CameraControls.ControlsOrbit && (Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) || (mouse.down("right") && !modif && defaultKeymap))) { + if (controls == CameraControls.ControlsOrbit && (Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) || (Mouse.down("right") && !modif && defaultKeymap))) { Camera.redraws = 2; let dist = Camera.distance(); camera.transform.move(camera.lookWorld(), dist); - camera.transform.rotate(Vec4.zAxis(), -mouse.movementX / 100 * Config.raw.camera_rotation_speed); - camera.transform.rotate(camera.rightWorld(), -mouse.movementY / 100 * Config.raw.camera_rotation_speed); + camera.transform.rotate(Vec4.zAxis(), -Mouse.movementX / 100 * Config.raw.camera_rotation_speed); + camera.transform.rotate(camera.rightWorld(), -Mouse.movementY / 100 * Config.raw.camera_rotation_speed); if (camera.upWorld().z < 0) { - camera.transform.rotate(camera.rightWorld(), mouse.movementY / 100 * Config.raw.camera_rotation_speed); + camera.transform.rotate(camera.rightWorld(), Mouse.movementY / 100 * Config.raw.camera_rotation_speed); } camera.transform.move(camera.lookWorld(), -dist); } - else if (controls == CameraControls.ControlsRotate && (Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) || (mouse.down("right") && !modif && defaultKeymap))) { + else if (controls == CameraControls.ControlsRotate && (Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) || (Mouse.down("right") && !modif && defaultKeymap))) { Camera.redraws = 2; let t = Context.mainObject().transform; let up = t.up().normalize(); - t.rotate(up, mouse.movementX / 100 * Config.raw.camera_rotation_speed); + t.rotate(up, Mouse.movementX / 100 * Config.raw.camera_rotation_speed); let right = camera.rightWorld().normalize(); - t.rotate(right, mouse.movementY / 100 * Config.raw.camera_rotation_speed); + t.rotate(right, Mouse.movementY / 100 * Config.raw.camera_rotation_speed); t.buildMatrix(); if (t.up().z < 0) { - t.rotate(right, -mouse.movementY / 100 * Config.raw.camera_rotation_speed); + t.rotate(right, -Mouse.movementY / 100 * Config.raw.camera_rotation_speed); } } @@ -114,23 +112,23 @@ class Camera { camera.transform.move(camera.look(), f); } - if (mouse.wheelDelta != 0 && !modifKey) { + if (Mouse.wheelDelta != 0 && !modifKey) { Camera.redraws = 2; - let f = mouse.wheelDelta * (-0.1); + let f = Mouse.wheelDelta * (-0.1); f *= Camera.getCameraZoomSpeed(); camera.transform.move(camera.look(), f); } } - else if (controls == CameraControls.ControlsFly && mouse.down("right")) { - let moveForward = kb.down("w") || kb.down("up") || mouse.wheelDelta < 0; - let moveBackward = kb.down("s") || kb.down("down") || mouse.wheelDelta > 0; - let strafeLeft = kb.down("a") || kb.down("left"); - let strafeRight = kb.down("d") || kb.down("right"); - let strafeUp = kb.down("e"); - let strafeDown = kb.down("q"); - let fast = kb.down("shift") ? 2.0 : (kb.down("alt") ? 0.5 : 1.0); - if (mouse.wheelDelta != 0) { - fast *= Math.abs(mouse.wheelDelta) * 4.0; + else if (controls == CameraControls.ControlsFly && Mouse.down("right")) { + let moveForward = Keyboard.down("w") || Keyboard.down("up") || Mouse.wheelDelta < 0; + let moveBackward = Keyboard.down("s") || Keyboard.down("down") || Mouse.wheelDelta > 0; + let strafeLeft = Keyboard.down("a") || Keyboard.down("left"); + let strafeRight = Keyboard.down("d") || Keyboard.down("right"); + let strafeUp = Keyboard.down("e"); + let strafeDown = Keyboard.down("q"); + let fast = Keyboard.down("shift") ? 2.0 : (Keyboard.down("alt") ? 0.5 : 1.0); + if (Mouse.wheelDelta != 0) { + fast *= Math.abs(Mouse.wheelDelta) * 4.0; } if (moveForward || moveBackward || strafeRight || strafeLeft || strafeUp || strafeDown) { @@ -159,22 +157,22 @@ class Camera { } Camera.redraws = 2; - camera.transform.rotate(Vec4.zAxis(), -mouse.movementX / 200 * Config.raw.camera_rotation_speed); - camera.transform.rotate(camera.right(), -mouse.movementY / 200 * Config.raw.camera_rotation_speed); + camera.transform.rotate(Vec4.zAxis(), -Mouse.movementX / 200 * Config.raw.camera_rotation_speed); + camera.transform.rotate(camera.right(), -Mouse.movementY / 200 * Config.raw.camera_rotation_speed); } if (Operator.shortcut(Config.keymap.rotate_light, ShortcutType.ShortcutDown)) { Camera.redraws = 2; let light = Scene.active.lights[0]; - Context.raw.lightAngle = (Context.raw.lightAngle + ((mouse.movementX / 100) % (2 * Math.PI) + 2 * Math.PI)) % (2 * Math.PI); - let m = Mat4.rotationZ(mouse.movementX / 100); + Context.raw.lightAngle = (Context.raw.lightAngle + ((Mouse.movementX / 100) % (2 * Math.PI) + 2 * Math.PI)) % (2 * Math.PI); + let m = Mat4.rotationZ(Mouse.movementX / 100); light.transform.local.multmat(m); light.transform.decompose(); } if (Operator.shortcut(Config.keymap.rotate_envmap, ShortcutType.ShortcutDown)) { Camera.redraws = 2; - Context.raw.envmapAngle -= mouse.movementX / 100; + Context.raw.envmapAngle -= Mouse.movementX / 100; } if (Camera.redraws > 0) { @@ -217,11 +215,10 @@ class Camera { static panAction = (modif: bool, defaultKeymap: bool) => { let camera = Scene.active.camera; - let mouse = Input.getMouse(); - if (Operator.shortcut(Config.keymap.action_pan, ShortcutType.ShortcutDown) || (mouse.down("middle") && !modif && defaultKeymap)) { + if (Operator.shortcut(Config.keymap.action_pan, ShortcutType.ShortcutDown) || (Mouse.down("middle") && !modif && defaultKeymap)) { Camera.redraws = 2; - let look = camera.transform.look().normalize().mult(mouse.movementY / 150 * Config.raw.camera_pan_speed); - let right = camera.transform.right().normalize().mult(-mouse.movementX / 150 * Config.raw.camera_pan_speed); + let look = camera.transform.look().normalize().mult(Mouse.movementY / 150 * Config.raw.camera_pan_speed); + let right = camera.transform.right().normalize().mult(-Mouse.movementX / 150 * Config.raw.camera_pan_speed); camera.transform.loc.add(look); camera.transform.loc.add(right); Camera.origins[Camera.index()].add(look); @@ -231,11 +228,10 @@ class Camera { } static getZoomDelta = (): f32 => { - let mouse = Input.getMouse(); - return Config.raw.zoom_direction == ZoomDirection.ZoomVertical ? -mouse.movementY : - Config.raw.zoom_direction == ZoomDirection.ZoomVerticalInverted ? -mouse.movementY : - Config.raw.zoom_direction == ZoomDirection.ZoomHorizontal ? mouse.movementX : - Config.raw.zoom_direction == ZoomDirection.ZoomHorizontalInverted ? mouse.movementX : - -(mouse.movementY - mouse.movementX); + return Config.raw.zoom_direction == ZoomDirection.ZoomVertical ? -Mouse.movementY : + Config.raw.zoom_direction == ZoomDirection.ZoomVerticalInverted ? -Mouse.movementY : + Config.raw.zoom_direction == ZoomDirection.ZoomHorizontal ? Mouse.movementX : + Config.raw.zoom_direction == ZoomDirection.ZoomHorizontalInverted ? Mouse.movementX : + -(Mouse.movementY - Mouse.movementX); } } diff --git a/base/Sources/Context.ts b/base/Sources/Context.ts index 6215439b..4d896cfe 100644 --- a/base/Sources/Context.ts +++ b/base/Sources/Context.ts @@ -201,11 +201,10 @@ class Context { static inPaintArea = (): bool => { ///if (is_paint || is_sculpt) - let mouse = Input.getMouse(); let right = App.w(); if (UIView2D.show) right += UIView2D.ww; - return mouse.viewX > 0 && mouse.viewX < right && - mouse.viewY > 0 && mouse.viewY < App.h(); + return Mouse.viewX > 0 && Mouse.viewX < right && + Mouse.viewY > 0 && Mouse.viewY < App.h(); ///end ///if is_lab @@ -223,18 +222,16 @@ class Context { ///if (is_paint || is_sculpt) static in2dView = (type = View2DType.View2DLayer): bool => { - let mouse = Input.getMouse(); return UIView2D.show && UIView2D.type == type && - mouse.x > UIView2D.wx && mouse.x < UIView2D.wx + UIView2D.ww && - mouse.y > UIView2D.wy && mouse.y < UIView2D.wy + UIView2D.wh; + Mouse.x > UIView2D.wx && Mouse.x < UIView2D.wx + UIView2D.ww && + Mouse.y > UIView2D.wy && Mouse.y < UIView2D.wy + UIView2D.wh; } ///end static inNodes = (): bool => { - let mouse = Input.getMouse(); return UINodes.show && - mouse.x > UINodes.wx && mouse.x < UINodes.wx + UINodes.ww && - mouse.y > UINodes.wy && mouse.y < UINodes.wy + UINodes.wh; + Mouse.x > UINodes.wx && Mouse.x < UINodes.wx + UINodes.ww && + Mouse.y > UINodes.wy && Mouse.y < UINodes.wy + UINodes.wh; } static inSwatches = (): bool => { @@ -288,7 +285,7 @@ class Context { static updateEnvmap = () => { if (Context.raw.showEnvmap) { - Scene.active.world.envmap = Context.raw.showEnvmapBlur ? Scene.active.world.probe.radianceMipmaps[0] : Context.raw.savedEnvmap; + Scene.active.world.envmap = Context.raw.showEnvmapBlur ? Scene.active.world.radianceMipmaps[0] : Context.raw.savedEnvmap; } else { Scene.active.world.envmap = Context.raw.emptyEnvmap; @@ -361,7 +358,7 @@ class Context { !Base.isScrolling() && !Base.isComboSelected()) { - let down = Input.getMouse().down() || Input.getPen().down(); + let down = Mouse.down() || Pen.down(); // Prevent painting the same spot let sameSpot = Context.raw.paintVec.x == Context.raw.lastPaintX && Context.raw.paintVec.y == Context.raw.lastPaintY; @@ -395,22 +392,20 @@ class Context { } static update = () => { - let mouse = Input.getMouse(); - let paintX = mouse.viewX / App.w(); - let paintY = mouse.viewY / App.h(); - if (mouse.started()) { - Context.raw.startX = mouse.viewX / App.w(); - Context.raw.startY = mouse.viewY / App.h(); + let paintX = Mouse.viewX / App.w(); + let paintY = Mouse.viewY / App.h(); + if (Mouse.started()) { + Context.raw.startX = Mouse.viewX / App.w(); + Context.raw.startY = Mouse.viewY / App.h(); } - let pen = Input.getPen(); - if (pen.down()) { - paintX = pen.viewX / App.w(); - paintY = pen.viewY / App.h(); + if (Pen.down()) { + paintX = Pen.viewX / App.w(); + paintY = Pen.viewY / App.h(); } - if (pen.started()) { - Context.raw.startX = pen.viewX / App.w(); - Context.raw.startY = pen.viewY / App.h(); + if (Pen.started()) { + Context.raw.startX = Pen.viewX / App.w(); + Context.raw.startY = Pen.viewY / App.h(); } if (Operator.shortcut(Config.keymap.brush_ruler + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown)) { @@ -422,21 +417,20 @@ class Context { Context.raw.coords.y = paintY; if (Context.raw.lockBegin) { - let dx = Math.abs(Context.raw.lockStartX - mouse.viewX); - let dy = Math.abs(Context.raw.lockStartY - mouse.viewY); + let dx = Math.abs(Context.raw.lockStartX - Mouse.viewX); + let dy = Math.abs(Context.raw.lockStartY - Mouse.viewY); if (dx > 1 || dy > 1) { Context.raw.lockBegin = false; dx > dy ? Context.raw.lockY = true : Context.raw.lockX = true; } } - let kb = Input.getKeyboard(); - if (kb.started(Config.keymap.brush_ruler)) { - Context.raw.lockStartX = mouse.viewX; - Context.raw.lockStartY = mouse.viewY; + if (Keyboard.started(Config.keymap.brush_ruler)) { + Context.raw.lockStartX = Mouse.viewX; + Context.raw.lockStartY = Mouse.viewY; Context.raw.lockBegin = true; } - else if (kb.released(Config.keymap.brush_ruler)) { + else if (Keyboard.released(Config.keymap.brush_ruler)) { Context.raw.lockX = Context.raw.lockY = Context.raw.lockBegin = false; } diff --git a/base/Sources/ExportArm.ts b/base/Sources/ExportArm.ts index 65b0a205..ba220357 100644 --- a/base/Sources/ExportArm.ts +++ b/base/Sources/ExportArm.ts @@ -106,10 +106,10 @@ class ExportArm { packed_assets: packed_assets, swatches: Project.raw.swatches, envmap: Project.raw.envmap != null ? (sameDrive ? Path.toRelative(Project.filepath, Project.raw.envmap) : Project.raw.envmap) : null, - envmap_strength: Scene.active.world.probe.raw.strength, + envmap_strength: Scene.active.world.raw.strength, camera_world: Scene.active.camera.transform.local.toFloat32Array(), camera_origin: ExportArm.vec3f32(Camera.origins[0]), - camera_fov: Scene.active.camera.data.raw.fov, + camera_fov: Scene.active.camera.data.fov, ///if (is_paint || is_sculpt) mesh_datas: md, diff --git a/base/Sources/Gizmo.ts b/base/Sources/Gizmo.ts index 0dddb145..cc95c442 100644 --- a/base/Sources/Gizmo.ts +++ b/base/Sources/Gizmo.ts @@ -17,9 +17,6 @@ class Gizmo { gizmo.visible = (isObject || isDecal) && !hide; if (!gizmo.visible) return; - let mouse = Input.getMouse(); - let kb = Input.getKeyboard(); - let paintObject: BaseObject = Context.raw.paintObject; ///if is_forge if (Context.raw.selectedObject != null) { @@ -34,7 +31,7 @@ class Gizmo { gizmo.transform.loc.set(Context.raw.layer.decalMat._30, Context.raw.layer.decalMat._31, Context.raw.layer.decalMat._32); } let cam = Scene.active.camera; - let fov = cam.data.raw.fov; + let fov = cam.data.fov; let dist = Vec4.distance(cam.transform.loc, gizmo.transform.loc) / 8 * fov; gizmo.transform.scale.set(dist, dist, dist); Context.raw.gizmoTranslateX.transform.scale.set(dist, dist, dist); @@ -85,7 +82,7 @@ class Gizmo { paintObject.transform.buildMatrix(); ///if arm_physics - let pb = paintObject.getTrait(PhysicsBodyRaw); + let pb = (paintObject as any).physicsBody; if (pb != null) pb.syncTransform(); ///end } @@ -145,11 +142,11 @@ class Gizmo { } Context.raw.gizmoStarted = false; - if (mouse.started("left") && paintObject.name != "Scene") { + if (Mouse.started("left") && paintObject.name != "Scene") { // Translate, scale let trs = [Context.raw.gizmoTranslateX.transform, Context.raw.gizmoTranslateY.transform, Context.raw.gizmoTranslateZ.transform, Context.raw.gizmoScaleX.transform, Context.raw.gizmoScaleY.transform, Context.raw.gizmoScaleZ.transform]; - let hit = RayCaster.closestBoxIntersect(trs, mouse.viewX, mouse.viewY, Scene.active.camera); + let hit = RayCaster.closestBoxIntersect(trs, Mouse.viewX, Mouse.viewY, Scene.active.camera); if (hit != null) { if (hit.object == Context.raw.gizmoTranslateX) Context.raw.translateX = true; else if (hit.object == Context.raw.gizmoTranslateY) Context.raw.translateY = true; @@ -165,7 +162,7 @@ class Gizmo { else { // Rotate let trs = [Context.raw.gizmoRotateX.transform, Context.raw.gizmoRotateY.transform, Context.raw.gizmoRotateZ.transform]; - let hit = RayCaster.closestBoxIntersect(trs, mouse.viewX, mouse.viewY, Scene.active.camera); + let hit = RayCaster.closestBoxIntersect(trs, Mouse.viewX, Mouse.viewY, Scene.active.camera); if (hit != null) { if (hit.object == Context.raw.gizmoRotateX) Context.raw.rotateX = true; else if (hit.object == Context.raw.gizmoRotateY) Context.raw.rotateY = true; @@ -177,7 +174,7 @@ class Gizmo { } } } - else if (mouse.released("left")) { + else if (Mouse.released("left")) { Context.raw.translateX = Context.raw.translateY = Context.raw.translateZ = false; Context.raw.scaleX = Context.raw.scaleY = Context.raw.scaleZ = false; Context.raw.rotateX = Context.raw.rotateY = Context.raw.rotateZ = false; @@ -195,28 +192,28 @@ class Gizmo { } if (Context.raw.translateX || Context.raw.scaleX) { - let hit = RayCaster.planeIntersect(Vec4.yAxis(), Gizmo.v, mouse.viewX, mouse.viewY, Scene.active.camera); + let hit = RayCaster.planeIntersect(Vec4.yAxis(), Gizmo.v, Mouse.viewX, Mouse.viewY, Scene.active.camera); if (hit != null) { if (Context.raw.gizmoStarted) Context.raw.gizmoOffset = hit.x - Gizmo.v.x; Context.raw.gizmoDrag = hit.x - Context.raw.gizmoOffset; } } else if (Context.raw.translateY || Context.raw.scaleY) { - let hit = RayCaster.planeIntersect(Vec4.xAxis(), Gizmo.v, mouse.viewX, mouse.viewY, Scene.active.camera); + let hit = RayCaster.planeIntersect(Vec4.xAxis(), Gizmo.v, Mouse.viewX, Mouse.viewY, Scene.active.camera); if (hit != null) { if (Context.raw.gizmoStarted) Context.raw.gizmoOffset = hit.y - Gizmo.v.y; Context.raw.gizmoDrag = hit.y - Context.raw.gizmoOffset; } } else if (Context.raw.translateZ || Context.raw.scaleZ) { - let hit = RayCaster.planeIntersect(Vec4.xAxis(), Gizmo.v, mouse.viewX, mouse.viewY, Scene.active.camera); + let hit = RayCaster.planeIntersect(Vec4.xAxis(), Gizmo.v, Mouse.viewX, Mouse.viewY, Scene.active.camera); if (hit != null) { if (Context.raw.gizmoStarted) Context.raw.gizmoOffset = hit.z - Gizmo.v.z; Context.raw.gizmoDrag = hit.z - Context.raw.gizmoOffset; } } else if (Context.raw.rotateX) { - let hit = RayCaster.planeIntersect(Vec4.xAxis(), Gizmo.v, mouse.viewX, mouse.viewY, Scene.active.camera); + let hit = RayCaster.planeIntersect(Vec4.xAxis(), Gizmo.v, Mouse.viewX, Mouse.viewY, Scene.active.camera); if (hit != null) { if (Context.raw.gizmoStarted) { Context.raw.layer.decalMat.decompose(Gizmo.v, Gizmo.q, Gizmo.v0); @@ -226,7 +223,7 @@ class Gizmo { } } else if (Context.raw.rotateY) { - let hit = RayCaster.planeIntersect(Vec4.yAxis(), Gizmo.v, mouse.viewX, mouse.viewY, Scene.active.camera); + let hit = RayCaster.planeIntersect(Vec4.yAxis(), Gizmo.v, Mouse.viewX, Mouse.viewY, Scene.active.camera); if (hit != null) { if (Context.raw.gizmoStarted) { Context.raw.layer.decalMat.decompose(Gizmo.v, Gizmo.q, Gizmo.v0); @@ -236,7 +233,7 @@ class Gizmo { } } else if (Context.raw.rotateZ) { - let hit = RayCaster.planeIntersect(Vec4.zAxis(), Gizmo.v, mouse.viewX, mouse.viewY, Scene.active.camera); + let hit = RayCaster.planeIntersect(Vec4.zAxis(), Gizmo.v, Mouse.viewX, Mouse.viewY, Scene.active.camera); if (hit != null) { if (Context.raw.gizmoStarted) { Context.raw.layer.decalMat.decompose(Gizmo.v, Gizmo.q, Gizmo.v0); @@ -254,7 +251,7 @@ class Gizmo { ///end } - Input.occupied = (Context.raw.translateX || Context.raw.translateY || Context.raw.translateZ || Context.raw.scaleX || Context.raw.scaleY || Context.raw.scaleZ || Context.raw.rotateX || Context.raw.rotateY || Context.raw.rotateZ) && mouse.viewX < Base.w(); + Input.occupied = (Context.raw.translateX || Context.raw.translateY || Context.raw.translateZ || Context.raw.scaleX || Context.raw.scaleY || Context.raw.scaleZ || Context.raw.rotateX || Context.raw.rotateY || Context.raw.rotateZ) && Mouse.viewX < Base.w(); } } diff --git a/base/Sources/ImportArm.ts b/base/Sources/ImportArm.ts index 096e05f9..e2e1e27f 100644 --- a/base/Sources/ImportArm.ts +++ b/base/Sources/ImportArm.ts @@ -75,12 +75,12 @@ class ImportArm { Project.raw.envmap = Data.isAbsolute(Project.raw.envmap) ? Project.raw.envmap : base + Project.raw.envmap; } if (Project.raw.envmap_strength != null) { - Scene.active.world.probe.raw.strength = Project.raw.envmap_strength; + Scene.active.world.raw.strength = Project.raw.envmap_strength; } if (Project.raw.camera_world != null) { Scene.active.camera.transform.local = Mat4.fromFloat32Array(Project.raw.camera_world); Scene.active.camera.transform.decompose(); - Scene.active.camera.data.raw.fov = Project.raw.camera_fov; + Scene.active.camera.data.fov = Project.raw.camera_fov; Scene.active.camera.buildProjection(); let origin = Project.raw.camera_origin; Camera.origins[0].x = origin[0]; diff --git a/base/Sources/ImportEnvmap.ts b/base/Sources/ImportEnvmap.ts index 7b70be1d..925b9b80 100644 --- a/base/Sources/ImportEnvmap.ts +++ b/base/Sources/ImportEnvmap.ts @@ -74,18 +74,18 @@ class ImportEnvmap { ImportEnvmap.radianceCpu.setMipmaps(ImportEnvmap.mipsCpu); // Irradiance - Scene.active.world.probe.irradiance = ImportEnvmap.getSphericalHarmonics(radiancePixels, ImportEnvmap.radiance.width, ImportEnvmap.radiance.height); + Scene.active.world.irradiance = ImportEnvmap.getSphericalHarmonics(radiancePixels, ImportEnvmap.radiance.width, ImportEnvmap.radiance.height); // World - Scene.active.world.probe.raw.strength = 1.0; - Scene.active.world.probe.raw.radiance_mipmaps = ImportEnvmap.mipsCpu.length - 2; + Scene.active.world.raw.strength = 1.0; + Scene.active.world.raw.radiance_mipmaps = ImportEnvmap.mipsCpu.length - 2; Scene.active.world.envmap = image; Scene.active.world.raw.envmap = path; - Scene.active.world.probe.radiance = ImportEnvmap.radianceCpu; - Scene.active.world.probe.radianceMipmaps = ImportEnvmap.mipsCpu; + Scene.active.world.radiance = ImportEnvmap.radianceCpu; + Scene.active.world.radianceMipmaps = ImportEnvmap.mipsCpu; Context.raw.savedEnvmap = image; if (Context.raw.showEnvmapBlur) { - Scene.active.world.envmap = Scene.active.world.probe.radianceMipmaps[0]; + Scene.active.world.envmap = Scene.active.world.radianceMipmaps[0]; } Context.raw.ddirty = 2; Project.raw.envmap = path; diff --git a/base/Sources/Operator.ts b/base/Sources/Operator.ts index 3a32bcd2..ddaf6a97 100644 --- a/base/Sources/Operator.ts +++ b/base/Sources/Operator.ts @@ -12,7 +12,7 @@ class Operator { } static update = () => { - if (Input.getMouse().startedAny() || Input.getKeyboard().startedAny()) { + if (Mouse.startedAny() || Keyboard.startedAny()) { for (let op in Config.keymap) { if (Operator.shortcut(Config.keymap[op])) Operator.run(op); } @@ -21,14 +21,12 @@ class Operator { static shortcut = (s: string, type = ShortcutType.ShortcutStarted): bool => { if (s == "") return false; - let mouse = Input.getMouse(); - let kb = Input.getKeyboard(); let shift = s.indexOf("shift") >= 0; let ctrl = s.indexOf("ctrl") >= 0; let alt = s.indexOf("alt") >= 0; - let flag = shift == kb.down("shift") && - ctrl == kb.down("control") && - alt == kb.down("alt"); + let flag = shift == Keyboard.down("shift") && + ctrl == Keyboard.down("control") && + alt == Keyboard.down("alt"); if (s.indexOf("+") > 0) { s = s.substr(s.lastIndexOf("+") + 1); if (s == "number") return flag; @@ -36,9 +34,9 @@ class Operator { else if (shift || ctrl || alt) return flag; let key = (s == "left" || s == "right" || s == "middle") ? // Mouse - (type == ShortcutType.ShortcutDown ? mouse.down(s) : mouse.started(s)) : + (type == ShortcutType.ShortcutDown ? Mouse.down(s) : Mouse.started(s)) : // Keyboard - (type == ShortcutType.ShortcutRepeat ? kb.repeat(s) : type == ShortcutType.ShortcutDown ? kb.down(s) : type == ShortcutType.ShortcutReleased ? kb.released(s) : kb.started(s)); + (type == ShortcutType.ShortcutRepeat ? Keyboard.repeat(s) : type == ShortcutType.ShortcutDown ? Keyboard.down(s) : type == ShortcutType.ShortcutReleased ? Keyboard.released(s) : Keyboard.started(s)); return flag && key; } } diff --git a/base/Sources/PhysicsBody.ts b/base/Sources/PhysicsBody.ts index 935f196e..9290ed4d 100644 --- a/base/Sources/PhysicsBody.ts +++ b/base/Sources/PhysicsBody.ts @@ -14,7 +14,7 @@ class PhysicsBodyRaw { let t = new PhysicsBodyRaw(); t._mass = f; PhysicsBody.init(t, this.object); - this.object.addTrait(t); + (this.object as any).physicsBody = t; } else this._mass = f; } diff --git a/base/Sources/Project.ts b/base/Sources/Project.ts index fc81d0f5..8ca1be7e 100644 --- a/base/Sources/Project.ts +++ b/base/Sources/Project.ts @@ -294,10 +294,10 @@ class Project { Scene.active.world.envmap = Context.raw.emptyEnvmap; Scene.active.world.raw.envmap = "World_radiance.k"; Context.raw.showEnvmapHandle.selected = Context.raw.showEnvmap = false; - Scene.active.world.probe.radiance = Context.raw.defaultRadiance; - Scene.active.world.probe.radianceMipmaps = Context.raw.defaultRadianceMipmaps; - Scene.active.world.probe.irradiance = Context.raw.defaultIrradiance; - Scene.active.world.probe.raw.strength = 4.0; + Scene.active.world.radiance = Context.raw.defaultRadiance; + Scene.active.world.radianceMipmaps = Context.raw.defaultRadianceMipmaps; + Scene.active.world.irradiance = Context.raw.defaultIrradiance; + Scene.active.world.raw.strength = 4.0; ///if (is_paint || is_sculpt) Context.initTool(); diff --git a/base/Sources/RenderPathBase.ts b/base/Sources/RenderPathBase.ts index 585e52ce..fb8a98e3 100644 --- a/base/Sources/RenderPathBase.ts +++ b/base/Sources/RenderPathBase.ts @@ -98,7 +98,7 @@ class RenderPathBase { } else { // Set current viewport - Context.raw.viewIndex = Input.getMouse().viewX > Base.w() / 2 ? 1 : 0; + Context.raw.viewIndex = Mouse.viewX > Base.w() / 2 ? 1 : 0; } let cam = Scene.active.camera; @@ -131,7 +131,7 @@ class RenderPathBase { Context.raw.viewIndexLast = Context.raw.viewIndex; Context.raw.viewIndex = -1; - if (Context.raw.foregroundEvent && !Input.getMouse().down()) { + if (Context.raw.foregroundEvent && !Mouse.down()) { Context.raw.foregroundEvent = false; Context.raw.pdirty = 0; } @@ -146,14 +146,13 @@ class RenderPathBase { static isCached = (): bool => { if (System.width == 0 || System.height == 0) return true; - let mouse = Input.getMouse(); let mx = RenderPathBase.lastX; let my = RenderPathBase.lastY; - RenderPathBase.lastX = mouse.viewX; - RenderPathBase.lastY = mouse.viewY; + RenderPathBase.lastX = Mouse.viewX; + RenderPathBase.lastY = Mouse.viewY; if (Context.raw.ddirty <= 0 && Context.raw.rdirty <= 0 && Context.raw.pdirty <= 0) { - if (mx != RenderPathBase.lastX || my != RenderPathBase.lastY || mouse.locked) Context.raw.ddirty = 0; + if (mx != RenderPathBase.lastX || my != RenderPathBase.lastY || Mouse.locked) Context.raw.ddirty = 0; ///if (krom_metal || krom_android) if (Context.raw.ddirty > -6) { ///else @@ -546,7 +545,7 @@ class RenderPathBase { } } - let hide = Operator.shortcut(Config.keymap.stencil_hide, ShortcutType.ShortcutDown) || Input.getKeyboard().down("control"); + let hide = Operator.shortcut(Config.keymap.stencil_hide, ShortcutType.ShortcutDown) || Keyboard.down("control"); let isDecal = Base.isDecalLayer(); if (isDecal && !hide) LineDraw.render(currentG, Context.raw.layer.decalMat); } diff --git a/base/Sources/RenderPathRaytrace.ts b/base/Sources/RenderPathRaytrace.ts index a90fd584..6fff50d6 100644 --- a/base/Sources/RenderPathRaytrace.ts +++ b/base/Sources/RenderPathRaytrace.ts @@ -111,7 +111,7 @@ class RenderPathRaytrace { RenderPathRaytrace.f32a[17] = RenderPathRaytrace.helpMat._31; RenderPathRaytrace.f32a[18] = RenderPathRaytrace.helpMat._32; RenderPathRaytrace.f32a[19] = RenderPathRaytrace.helpMat._33; - RenderPathRaytrace.f32a[20] = Scene.active.world.probe.raw.strength * 1.5; + RenderPathRaytrace.f32a[20] = Scene.active.world.raw.strength * 1.5; if (!Context.raw.showEnvmap) RenderPathRaytrace.f32a[20] = -RenderPathRaytrace.f32a[20]; RenderPathRaytrace.f32a[21] = Context.raw.envmapAngle; RenderPathRaytrace.f32a[22] = RenderPathRaytrace.uvScale; @@ -174,7 +174,7 @@ class RenderPathRaytrace { ///if krom_metal // Delay path tracing additional samples while painting - let down = Input.getMouse().down() || Input.getPen().down(); + let down = Mouse.down() || Pen.down(); if (Context.inViewport() && down) RenderPathRaytrace.frame = 0; ///end diff --git a/base/Sources/TabBrushes.ts b/base/Sources/TabBrushes.ts index 1be835f4..fa099f88 100644 --- a/base/Sources/TabBrushes.ts +++ b/base/Sources/TabBrushes.ts @@ -66,9 +66,8 @@ class TabBrushes { if (Context.raw.brush != Project.brushes[i]) Context.selectBrush(i); if (Time.time() - Context.raw.selectTime < 0.25) UIBase.showBrushNodes(); Context.raw.selectTime = Time.time(); - // let mouse = Input.getMouse(); - // App.dragOffX = -(mouse.x - uix - ui._windowX - 3); - // App.dragOffY = -(mouse.y - uiy - ui._windowY + 1); + // App.dragOffX = -(Mouse.x - uix - ui._windowX - 3); + // App.dragOffY = -(Mouse.y - uiy - ui._windowY + 1); // App.dragBrush = Context.raw.brush; } if (ui.isHovered && ui.inputReleasedR) { diff --git a/base/Sources/TabMaterials.ts b/base/Sources/TabMaterials.ts index 64524bbd..a6107d03 100644 --- a/base/Sources/TabMaterials.ts +++ b/base/Sources/TabMaterials.ts @@ -132,9 +132,8 @@ class TabMaterials { } ///end } - let mouse = Input.getMouse(); - Base.dragOffX = -(mouse.x - uix - ui._windowX - 3); - Base.dragOffY = -(mouse.y - uiy - ui._windowY + 1); + Base.dragOffX = -(Mouse.x - uix - ui._windowX - 3); + Base.dragOffY = -(Mouse.y - uiy - ui._windowY + 1); Base.dragMaterial = Context.raw.material; // Double click to show nodes if (Time.time() - Context.raw.selectTime < 0.25) { diff --git a/base/Sources/TabSwatches.ts b/base/Sources/TabSwatches.ts index a8cef592..6d55ed8b 100644 --- a/base/Sources/TabSwatches.ts +++ b/base/Sources/TabSwatches.ts @@ -110,14 +110,12 @@ class TabSwatches { if (state == State.Started) { Context.setSwatch(Project.raw.swatches[i]); - let mouse = Input.getMouse(); - Base.dragOffX = -(mouse.x - uix - ui._windowX - 2 * slotw); - Base.dragOffY = -(mouse.y - uiy - ui._windowY + 1); + Base.dragOffX = -(Mouse.x - uix - ui._windowX - 2 * slotw); + Base.dragOffY = -(Mouse.y - uiy - ui._windowY + 1); Base.dragSwatch = Context.raw.swatch; } else if (state == State.Hovered) { - let mouse = Input.getMouse(); - TabSwatches.dragPosition = (mouse.x > uix + ui._windowX + slotw / 2) ? i + 1 : i; // Switch to the next position if the mouse crosses the swatch rectangle center + TabSwatches.dragPosition = (Mouse.x > uix + ui._windowX + slotw / 2) ? i + 1 : i; // Switch to the next position if the mouse crosses the swatch rectangle center dragPositionSet = true; } else if (state == State.Released) { @@ -152,7 +150,7 @@ class TabSwatches { if (ui.changed || ui.isTyping) UIMenu.keepOpen = true; if (ui.inputReleased) Context.setSwatch(Context.raw.swatch); // Trigger material preview update - }, 16, Math.floor(Input.getMouse().x - 200 * ui.SCALE()), Math.floor(Input.getMouse().y - 250 * ui.SCALE())); + }, 16, Math.floor(Mouse.x - 200 * ui.SCALE()), Math.floor(Mouse.y - 250 * ui.SCALE())); } Context.raw.selectTime = Time.time(); diff --git a/base/Sources/TabTextures.ts b/base/Sources/TabTextures.ts index dc62b62a..961a9d4b 100644 --- a/base/Sources/TabTextures.ts +++ b/base/Sources/TabTextures.ts @@ -64,9 +64,8 @@ class TabTextures { let uiy = ui._y; let sw = img.height < img.width ? img.height : 0; if (ui.image(img, 0xffffffff, slotw, 0, 0, sw, sw) == State.Started && ui.inputY > ui._windowY) { - let mouse = Input.getMouse(); - Base.dragOffX = -(mouse.x - uix - ui._windowX - 3); - Base.dragOffY = -(mouse.y - uiy - ui._windowY + 1); + Base.dragOffX = -(Mouse.x - uix - ui._windowX - 3); + Base.dragOffY = -(Mouse.y - uiy - ui._windowY + 1); Base.dragAsset = asset; Context.raw.texture = asset; diff --git a/base/Sources/UIBase.ts b/base/Sources/UIBase.ts index 8407daf0..02fd44bd 100644 --- a/base/Sources/UIBase.ts +++ b/base/Sources/UIBase.ts @@ -194,9 +194,9 @@ class UIBase { let world = Scene.active.world; if (Context.raw.savedEnvmap == null) { // Context.raw.savedEnvmap = world.envmap; - Context.raw.defaultIrradiance = world.probe.irradiance; - Context.raw.defaultRadiance = world.probe.radiance; - Context.raw.defaultRadianceMipmaps = world.probe.radianceMipmaps; + Context.raw.defaultIrradiance = world.irradiance; + Context.raw.defaultRadiance = world.radiance; + Context.raw.defaultRadianceMipmaps = world.radianceMipmaps; } world.envmap = Context.raw.showEnvmap ? Context.raw.savedEnvmap : Context.raw.emptyEnvmap; Context.raw.ddirty = 1; @@ -309,9 +309,8 @@ class UIBase { else if (Operator.shortcut(Config.keymap.file_import_assets)) Project.importAsset(); else if (Operator.shortcut(Config.keymap.edit_prefs)) BoxPreferences.show(); - let kb = Input.getKeyboard(); - if (kb.started(Config.keymap.view_distract_free) || - (kb.started("escape") && !UIBase.show && !UIBox.show)) { + if (Keyboard.started(Config.keymap.view_distract_free) || + (Keyboard.started("escape") && !UIBase.show && !UIBox.show)) { UIBase.toggleDistractFree(); } @@ -321,39 +320,37 @@ class UIBase { } ///end - let mouse = Input.getMouse(); - ///if (is_paint || is_sculpt) let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText; let decalMask = decal && Operator.shortcut(Config.keymap.decal_mask, ShortcutType.ShortcutDown); - if ((Context.raw.brushCanLock || Context.raw.brushLocked) && mouse.moved) { + if ((Context.raw.brushCanLock || Context.raw.brushLocked) && Mouse.moved) { if (Operator.shortcut(Config.keymap.brush_radius, ShortcutType.ShortcutDown) || Operator.shortcut(Config.keymap.brush_opacity, ShortcutType.ShortcutDown) || Operator.shortcut(Config.keymap.brush_angle, ShortcutType.ShortcutDown) || (decalMask && Operator.shortcut(Config.keymap.decal_mask + "+" + Config.keymap.brush_radius, ShortcutType.ShortcutDown))) { if (Context.raw.brushLocked) { if (Operator.shortcut(Config.keymap.brush_opacity, ShortcutType.ShortcutDown)) { - Context.raw.brushOpacity += mouse.movementX / 500; + Context.raw.brushOpacity += Mouse.movementX / 500; Context.raw.brushOpacity = Math.max(0.0, Math.min(1.0, Context.raw.brushOpacity)); Context.raw.brushOpacity = Math.round(Context.raw.brushOpacity * 100) / 100; Context.raw.brushOpacityHandle.value = Context.raw.brushOpacity; } else if (Operator.shortcut(Config.keymap.brush_angle, ShortcutType.ShortcutDown)) { - Context.raw.brushAngle += mouse.movementX / 5; + Context.raw.brushAngle += Mouse.movementX / 5; Context.raw.brushAngle = Math.floor(Context.raw.brushAngle) % 360; if (Context.raw.brushAngle < 0) Context.raw.brushAngle += 360; Context.raw.brushAngleHandle.value = Context.raw.brushAngle; MakeMaterial.parsePaintMaterial(); } else if (decalMask && Operator.shortcut(Config.keymap.decal_mask + "+" + Config.keymap.brush_radius, ShortcutType.ShortcutDown)) { - Context.raw.brushDecalMaskRadius += mouse.movementX / 150; + Context.raw.brushDecalMaskRadius += Mouse.movementX / 150; Context.raw.brushDecalMaskRadius = Math.max(0.01, Math.min(4.0, Context.raw.brushDecalMaskRadius)); Context.raw.brushDecalMaskRadius = Math.round(Context.raw.brushDecalMaskRadius * 100) / 100; Context.raw.brushDecalMaskRadiusHandle.value = Context.raw.brushDecalMaskRadius; } else { - Context.raw.brushRadius += mouse.movementX / 150; + Context.raw.brushRadius += Mouse.movementX / 150; Context.raw.brushRadius = Math.max(0.01, Math.min(4.0, Context.raw.brushRadius)); Context.raw.brushRadius = Math.round(Context.raw.brushRadius * 100) / 100; Context.raw.brushRadiusHandle.value = Context.raw.brushRadius; @@ -369,10 +366,10 @@ class UIBase { ///end ///if is_lab - if ((Context.raw.brushCanLock || Context.raw.brushLocked) && mouse.moved) { + if ((Context.raw.brushCanLock || Context.raw.brushLocked) && Mouse.moved) { if (Operator.shortcut(Config.keymap.brush_radius, ShortcutType.ShortcutDown)) { if (Context.raw.brushLocked) { - Context.raw.brushRadius += mouse.movementX / 150; + Context.raw.brushRadius += Mouse.movementX / 150; Context.raw.brushRadius = Math.max(0.01, Math.min(4.0, Context.raw.brushRadius)); Context.raw.brushRadius = Math.round(Context.raw.brushRadius * 100) / 100; Context.raw.brushRadiusHandle.value = Context.raw.brushRadius; @@ -392,11 +389,11 @@ class UIBase { if (!isTyping) { if (Operator.shortcut(Config.keymap.select_material, ShortcutType.ShortcutDown)) { UIBase.hwnds[TabArea.TabSidebar1].redraws = 2; - for (let i = 1; i < 10; ++i) if (kb.started(i + "")) Context.selectMaterial(i - 1); + for (let i = 1; i < 10; ++i) if (Keyboard.started(i + "")) Context.selectMaterial(i - 1); } else if (Operator.shortcut(Config.keymap.select_layer, ShortcutType.ShortcutDown)) { UIBase.hwnds[TabArea.TabSidebar0].redraws = 2; - for (let i = 1; i < 10; ++i) if (kb.started(i + "")) Context.selectLayer(i - 1); + for (let i = 1; i < 10; ++i) if (Keyboard.started(i + "")) Context.selectLayer(i - 1); } } ///end @@ -405,7 +402,7 @@ class UIBase { if (Context.inPaintArea() && !isTyping) { ///if is_paint - if (!mouse.down("right")) { // Fly mode off + if (!Mouse.down("right")) { // Fly mode off if (Operator.shortcut(Config.keymap.tool_brush)) Context.selectTool(WorkspaceTool.ToolBrush); else if (Operator.shortcut(Config.keymap.tool_eraser)) Context.selectTool(WorkspaceTool.ToolEraser); else if (Operator.shortcut(Config.keymap.tool_fill)) Context.selectTool(WorkspaceTool.ToolFill); @@ -437,9 +434,9 @@ class UIBase { Operator.shortcut(Config.keymap.brush_angle) || (decalMask && Operator.shortcut(Config.keymap.decal_mask + "+" + Config.keymap.brush_radius))) { Context.raw.brushCanLock = true; - if (!Input.getPen().connected) mouse.lock(); - Context.raw.lockStartedX = mouse.x; - Context.raw.lockStartedY = mouse.y; + if (!Pen.connected) Mouse.lock(); + Context.raw.lockStartedX = Mouse.x; + Context.raw.lockStartedY = Mouse.y; } else if (Operator.shortcut(Config.keymap.brush_radius_decrease, ShortcutType.ShortcutRepeat)) { Context.raw.brushRadius -= UIBase.getRadiusIncrement(); @@ -483,9 +480,9 @@ class UIBase { Context.raw.tool == WorkspaceTool.ToolSmudge) { if (Operator.shortcut(Config.keymap.brush_radius)) { Context.raw.brushCanLock = true; - if (!Input.getPen().connected) mouse.lock(); - Context.raw.lockStartedX = mouse.x; - Context.raw.lockStartedY = mouse.y; + if (!Pen.connected) Mouse.lock(); + Context.raw.lockStartedX = Mouse.x; + Context.raw.lockStartedY = Mouse.y; } else if (Operator.shortcut(Config.keymap.brush_radius_decrease, ShortcutType.ShortcutRepeat)) { Context.raw.brushRadius -= UIBase.getRadiusIncrement(); @@ -504,7 +501,7 @@ class UIBase { ///end // Viewpoint - if (mouse.viewX < App.w()) { + if (Mouse.viewX < App.w()) { if (Operator.shortcut(Config.keymap.view_reset)) { Viewport.reset(); Viewport.scaleToBounds(); @@ -599,7 +596,7 @@ class UIBase { } if (Context.raw.brushCanLock || Context.raw.brushLocked) { - if (mouse.moved && Context.raw.brushCanUnlock) { + if (Mouse.moved && Context.raw.brushCanUnlock) { Context.raw.brushLocked = false; Context.raw.brushCanUnlock = false; } @@ -617,7 +614,7 @@ class UIBase { ///end if (b) { - mouse.unlock(); + Mouse.unlock(); Context.raw.lastPaintX = -1; Context.raw.lastPaintY = -1; if (Context.raw.brushCanLock) { @@ -635,30 +632,30 @@ class UIBase { if (UIBase.borderHandle_ptr != 0) { if (UIBase.borderHandle_ptr == UINodes.hwnd.ptr || UIBase.borderHandle_ptr == UIView2D.hwnd.ptr) { if (UIBase.borderStarted == BorderSide.SideLeft) { - Config.raw.layout[LayoutSize.LayoutNodesW] -= Math.floor(mouse.movementX); + Config.raw.layout[LayoutSize.LayoutNodesW] -= Math.floor(Mouse.movementX); if (Config.raw.layout[LayoutSize.LayoutNodesW] < 32) Config.raw.layout[LayoutSize.LayoutNodesW] = 32; else if (Config.raw.layout[LayoutSize.LayoutNodesW] > System.width * 0.7) Config.raw.layout[LayoutSize.LayoutNodesW] = Math.floor(System.width * 0.7); } else { // UINodes / UIView2D ratio - Config.raw.layout[LayoutSize.LayoutNodesH] -= Math.floor(mouse.movementY); + Config.raw.layout[LayoutSize.LayoutNodesH] -= Math.floor(Mouse.movementY); if (Config.raw.layout[LayoutSize.LayoutNodesH] < 32) Config.raw.layout[LayoutSize.LayoutNodesH] = 32; else if (Config.raw.layout[LayoutSize.LayoutNodesH] > App.h() * 0.95) Config.raw.layout[LayoutSize.LayoutNodesH] = Math.floor(App.h() * 0.95); } } else if (UIBase.borderHandle_ptr == UIBase.hwnds[TabArea.TabStatus].ptr) { - let my = Math.floor(mouse.movementY); + let my = Math.floor(Mouse.movementY); if (Config.raw.layout[LayoutSize.LayoutStatusH] - my >= UIStatus.defaultStatusH * Config.raw.window_scale && Config.raw.layout[LayoutSize.LayoutStatusH] - my < System.height * 0.7) { Config.raw.layout[LayoutSize.LayoutStatusH] -= my; } } else { if (UIBase.borderStarted == BorderSide.SideLeft) { - Config.raw.layout[LayoutSize.LayoutSidebarW] -= Math.floor(mouse.movementX); + Config.raw.layout[LayoutSize.LayoutSidebarW] -= Math.floor(Mouse.movementX); if (Config.raw.layout[LayoutSize.LayoutSidebarW] < UIBase.sidebarMiniW) Config.raw.layout[LayoutSize.LayoutSidebarW] = UIBase.sidebarMiniW; else if (Config.raw.layout[LayoutSize.LayoutSidebarW] > System.width - UIBase.sidebarMiniW) Config.raw.layout[LayoutSize.LayoutSidebarW] = System.width - UIBase.sidebarMiniW; } else { - let my = Math.floor(mouse.movementY); + let my = Math.floor(Mouse.movementY); if (UIBase.borderHandle_ptr == UIBase.hwnds[TabArea.TabSidebar1].ptr && UIBase.borderStarted == BorderSide.SideTop) { if (Config.raw.layout[LayoutSize.LayoutSidebarH0] + my > 32 && Config.raw.layout[LayoutSize.LayoutSidebarH1] - my > 32) { Config.raw.layout[LayoutSize.LayoutSidebarH0] += my; @@ -674,18 +671,18 @@ class UIBase { if (UIBase.borderHandle_ptr != 0) { if (UIBase.borderHandle_ptr == UINodes.hwnd.ptr || UIBase.borderHandle_ptr == UIView2D.hwnd.ptr) { if (UIBase.borderStarted == BorderSide.SideLeft) { - Config.raw.layout[LayoutSize.LayoutNodesW] -= Math.floor(mouse.movementX); + Config.raw.layout[LayoutSize.LayoutNodesW] -= Math.floor(Mouse.movementX); if (Config.raw.layout[LayoutSize.LayoutNodesW] < 32) Config.raw.layout[LayoutSize.LayoutNodesW] = 32; else if (Config.raw.layout[LayoutSize.LayoutNodesW] > System.width * 0.7) Config.raw.layout[LayoutSize.LayoutNodesW] = Math.floor(System.width * 0.7); } else { // UINodes / UIView2D ratio - Config.raw.layout[LayoutSize.LayoutNodesH] -= Math.floor(mouse.movementY); + Config.raw.layout[LayoutSize.LayoutNodesH] -= Math.floor(Mouse.movementY); if (Config.raw.layout[LayoutSize.LayoutNodesH] < 32) Config.raw.layout[LayoutSize.LayoutNodesH] = 32; else if (Config.raw.layout[LayoutSize.LayoutNodesH] > App.h() * 0.95) Config.raw.layout[LayoutSize.LayoutNodesH] = Math.floor(App.h() * 0.95); } } else if (UIBase.borderHandle_ptr == UIBase.hwnds[TabArea.TabStatus].ptr) { - let my = Math.floor(mouse.movementY); + let my = Math.floor(Mouse.movementY); if (Config.raw.layout[LayoutSize.LayoutStatusH] - my >= UIStatus.defaultStatusH * Config.raw.window_scale && Config.raw.layout[LayoutSize.LayoutStatusH] - my < System.height * 0.7) { Config.raw.layout[LayoutSize.LayoutStatusH] -= my; } @@ -693,7 +690,7 @@ class UIBase { } ///end - if (!mouse.down()) { + if (!Mouse.down()) { UIBase.borderHandle_ptr = 0; Base.isResizing = false; } @@ -705,7 +702,7 @@ class UIBase { PhysicsWorld.lateUpdate(world); Context.raw.ddirty = 2; Context.raw.rdirty = 2; - if (mouse.started()) { + if (Mouse.started()) { if (Context.raw.particleTimer != null) { Tween.stop(Context.raw.particleTimer); Context.raw.particleTimer.done(); @@ -732,10 +729,10 @@ class UIBase { body.ccd = true; mo.transform.radius /= 10; // Lower ccd radius PhysicsBody.init(body, mo); - mo.addTrait(body); + (mo as any).physicsBody = body; mo.transform.radius *= 10; - let ray = RayCaster.getRay(mouse.viewX, mouse.viewY, camera); + let ray = RayCaster.getRay(Mouse.viewX, Mouse.viewY, camera); PhysicsBody.applyImpulse(body, ray.direction.mult(0.15)); Context.raw.particleTimer = Tween.timer(5, mo.remove); @@ -763,16 +760,14 @@ class UIBase { static view_top = () => { let isTyping = UIBase.ui.isTyping || UIView2D.ui.isTyping || UINodes.ui.isTyping; - let mouse = Input.getMouse(); if (Context.inPaintArea() && !isTyping) { - if (mouse.viewX < App.w()) { + if (Mouse.viewX < App.w()) { Viewport.setView(0, 0, 1, 0, 0, 0); } } } static operatorSearch = () => { - let kb = Input.getKeyboard(); let searchHandle = Zui.handle("uibase_1"); let first = true; UIMenu.draw((ui: Zui) => { @@ -791,7 +786,7 @@ class UIBase { if (ui.key == KeyCode.Down && UIBase.operatorSearchOffset < 6) UIBase.operatorSearchOffset++; if (ui.key == KeyCode.Up && UIBase.operatorSearchOffset > 0) UIBase.operatorSearchOffset--; } - let enter = kb.down("enter"); + let enter = Keyboard.down("enter"); let count = 0; let BUTTON_COL = ui.t.BUTTON_COL; @@ -852,13 +847,10 @@ class UIBase { if (!Base.uiEnabled) return; - let mouse = Input.getMouse(); - let kb = Input.getKeyboard(); - ///if (is_paint || is_sculpt) // Same mapping for paint and rotate (predefined in touch keymap) if (Context.inViewport()) { - if (mouse.started() && Config.keymap.action_paint == Config.keymap.action_rotate) { + if (Mouse.started() && Config.keymap.action_paint == Config.keymap.action_rotate) { UIBase.action_paint_remap = Config.keymap.action_paint; UtilRender.pickPosNorTex(); let isMesh = Math.abs(Context.raw.posXPicked) < 50 && Math.abs(Context.raw.posYPicked) < 50 && Math.abs(Context.raw.posZPicked) < 50; @@ -868,7 +860,7 @@ class UIBase { ///else let penOnly = Context.raw.penPaintingOnly; ///end - let isPen = penOnly && Input.getPen().down(); + let isPen = penOnly && Pen.down(); // Mesh picked - disable rotate // Pen painting only - rotate with touch, paint with pen if ((isMesh && !penOnly) || isPen) { @@ -881,7 +873,7 @@ class UIBase { Config.keymap.action_rotate = UIBase.action_paint_remap; } } - else if (!mouse.down() && UIBase.action_paint_remap != "") { + else if (!Mouse.down() && UIBase.action_paint_remap != "") { Config.keymap.action_rotate = UIBase.action_paint_remap; Config.keymap.action_paint = UIBase.action_paint_remap; UIBase.action_paint_remap = ""; @@ -890,12 +882,12 @@ class UIBase { if (Context.raw.brushStencilImage != null && Operator.shortcut(Config.keymap.stencil_transform, ShortcutType.ShortcutDown)) { let r = UIBase.getBrushStencilRect(); - if (mouse.started("left")) { + if (Mouse.started("left")) { Context.raw.brushStencilScaling = - UIBase.hitRect(mouse.x, mouse.y, r.x - 8, r.y - 8, 16, 16) || - UIBase.hitRect(mouse.x, mouse.y, r.x - 8, r.h + r.y - 8, 16, 16) || - UIBase.hitRect(mouse.x, mouse.y, r.w + r.x - 8, r.y - 8, 16, 16) || - UIBase.hitRect(mouse.x, mouse.y, r.w + r.x - 8, r.h + r.y - 8, 16, 16); + UIBase.hitRect(Mouse.x, Mouse.y, r.x - 8, r.y - 8, 16, 16) || + UIBase.hitRect(Mouse.x, Mouse.y, r.x - 8, r.h + r.y - 8, 16, 16) || + UIBase.hitRect(Mouse.x, Mouse.y, r.w + r.x - 8, r.y - 8, 16, 16) || + UIBase.hitRect(Mouse.x, Mouse.y, r.w + r.x - 8, r.h + r.y - 8, 16, 16); let cosa = Math.cos(-Context.raw.brushStencilAngle); let sina = Math.sin(-Context.raw.brushStencilAngle); let ox = 0; @@ -905,27 +897,27 @@ class UIBase { x += r.x + r.w / 2; y += r.y + r.h / 2; Context.raw.brushStencilRotating = - UIBase.hitRect(mouse.x, mouse.y, Math.floor(x - 16), Math.floor(y - 16), 32, 32); + UIBase.hitRect(Mouse.x, Mouse.y, Math.floor(x - 16), Math.floor(y - 16), 32, 32); } let _scale = Context.raw.brushStencilScale; - if (mouse.down("left")) { + if (Mouse.down("left")) { if (Context.raw.brushStencilScaling) { - let mult = mouse.x > r.x + r.w / 2 ? 1 : -1; - Context.raw.brushStencilScale += mouse.movementX / 400 * mult; + let mult = Mouse.x > r.x + r.w / 2 ? 1 : -1; + Context.raw.brushStencilScale += Mouse.movementX / 400 * mult; } else if (Context.raw.brushStencilRotating) { let gizmoX = r.x + r.w / 2; let gizmoY = r.y + r.h / 2; - Context.raw.brushStencilAngle = -Math.atan2(mouse.y - gizmoY, mouse.x - gizmoX) - Math.PI / 2; + Context.raw.brushStencilAngle = -Math.atan2(Mouse.y - gizmoY, Mouse.x - gizmoX) - Math.PI / 2; } else { - Context.raw.brushStencilX += mouse.movementX / Base.w(); - Context.raw.brushStencilY += mouse.movementY / Base.h(); + Context.raw.brushStencilX += Mouse.movementX / Base.w(); + Context.raw.brushStencilY += Mouse.movementY / Base.h(); } } else Context.raw.brushStencilScaling = false; - if (mouse.wheelDelta != 0) { - Context.raw.brushStencilScale -= mouse.wheelDelta / 10; + if (Mouse.wheelDelta != 0) { + Context.raw.brushStencilScale -= Mouse.wheelDelta / 10; } // Center after scale let ratio = Base.h() / Context.raw.brushStencilImage.height; @@ -947,17 +939,17 @@ class UIBase { decalMask || setCloneSource || Operator.shortcut(Config.keymap.brush_ruler + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown) || - (Input.getPen().down() && !kb.down("alt")); + (Pen.down() && !Keyboard.down("alt")); ///end ///if is_lab let down = Operator.shortcut(Config.keymap.action_paint, ShortcutType.ShortcutDown) || setCloneSource || Operator.shortcut(Config.keymap.brush_ruler + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown) || - (Input.getPen().down() && !kb.down("alt")); + (Pen.down() && !Keyboard.down("alt")); ///end if (Config.raw.touch_ui) { - if (Input.getPen().down()) { + if (Pen.down()) { Context.raw.penPaintingOnly = true; } else if (Context.raw.penPaintingOnly) { @@ -975,17 +967,17 @@ class UIBase { ///if krom_ios // No hover on iPad, decals are painted by pen release if (decal) { - down = Input.getPen().released(); + down = Pen.released(); if (!Context.raw.penPaintingOnly) { - down = down || Input.getMouse().released(); + down = down || Mouse.released(); } } ///end ///end if (down) { - let mx = mouse.viewX; - let my = mouse.viewY; + let mx = Mouse.viewX; + let my = Mouse.viewY; let ww = App.w(); ///if (is_paint || is_sculpt) @@ -1121,14 +1113,14 @@ class UIBase { let undoPressed = Operator.shortcut(Config.keymap.edit_undo); let redoPressed = Operator.shortcut(Config.keymap.edit_redo) || - (kb.down("control") && kb.started("y")); + (Keyboard.down("control") && Keyboard.started("y")); // Two-finger tap to undo, three-finger tap to redo if (Context.inViewport() && Config.raw.touch_ui) { - if (mouse.started("middle")) { UIBase.redoTapTime = Time.time(); } - else if (mouse.started("right")) { UIBase.undoTapTime = Time.time(); } - else if (mouse.released("middle") && Time.time() - UIBase.redoTapTime < 0.1) { UIBase.redoTapTime = UIBase.undoTapTime = 0; redoPressed = true; } - else if (mouse.released("right") && Time.time() - UIBase.undoTapTime < 0.1) { UIBase.redoTapTime = UIBase.undoTapTime = 0; undoPressed = true; } + if (Mouse.started("middle")) { UIBase.redoTapTime = Time.time(); } + else if (Mouse.started("right")) { UIBase.undoTapTime = Time.time(); } + else if (Mouse.released("middle") && Time.time() - UIBase.redoTapTime < 0.1) { UIBase.redoTapTime = UIBase.undoTapTime = 0; redoPressed = true; } + else if (Mouse.released("right") && Time.time() - UIBase.undoTapTime < 0.1) { UIBase.redoTapTime = UIBase.undoTapTime = 0; undoPressed = true; } } if (undoPressed) History.undo(); @@ -1332,10 +1324,7 @@ class UIBase { let psize = Math.floor(cursorImg.width * (Context.raw.brushRadius * Context.raw.brushNodesRadius) * UIBase.ui.SCALE()); // Clone source cursor - let mouse = Input.getMouse(); - let pen = Input.getPen(); - let kb = Input.getKeyboard(); - if (Context.raw.tool == WorkspaceTool.ToolClone && !kb.down("alt") && (mouse.down() || pen.down())) { + if (Context.raw.tool == WorkspaceTool.ToolClone && !Keyboard.down("alt") && (Mouse.down() || Pen.down())) { g.color = 0x66ffffff; g.drawScaledImage(cursorImg, mx + Context.raw.cloneDeltaX * App.w() - psize / 2, my + Context.raw.cloneDeltaY * App.h() - psize / 2, psize, psize); g.color = 0xffffffff; @@ -1515,7 +1504,7 @@ class UIBase { static onDeselectText = () => { ///if krom_ios - Input.getKeyboard().upListener(KeyCode.Shift); + Keyboard.upListener(KeyCode.Shift); ///end } diff --git a/base/Sources/UIBox.ts b/base/Sources/UIBox.ts index 20410b5c..e721cb65 100644 --- a/base/Sources/UIBox.ts +++ b/base/Sources/UIBox.ts @@ -19,11 +19,9 @@ class UIBox { static render = (g: Graphics2) => { if (!UIMenu.show) { - let mouse = Input.getMouse(); - let kb = Input.getKeyboard(); let ui = Base.uiBox; let inUse = ui.comboSelectedHandle_ptr != null; - let isEscape = kb.started("escape"); + let isEscape = Keyboard.started("escape"); if (UIBox.draws > 2 && (ui.inputReleased || isEscape) && !inUse && !ui.isTyping) { let appw = System.width; let apph = System.height; @@ -33,8 +31,8 @@ class UIBox { let right = (appw / 2 + mw / 2) + UIBox.hwnd.dragX; let top = (apph / 2 - mh / 2) + UIBox.hwnd.dragY; let bottom = (apph / 2 + mh / 2) + UIBox.hwnd.dragY; - let mx = mouse.x; - let my = mouse.y; + let mx = Mouse.x; + let my = Mouse.y; if ((UIBox.clickToHide && (mx < left || mx > right || my < top || my > bottom)) || isEscape) { UIBox.hide(); } diff --git a/base/Sources/UIFiles.ts b/base/Sources/UIFiles.ts index 8aa04843..9c9c6172 100644 --- a/base/Sources/UIFiles.ts +++ b/base/Sources/UIFiles.ts @@ -72,11 +72,10 @@ class UIFiles { static releaseKeys = () => { // File dialog may prevent firing key up events - let kb = Input.getKeyboard(); - kb.upListener(KeyCode.Shift); - kb.upListener(KeyCode.Control); + Keyboard.upListener(KeyCode.Shift); + Keyboard.upListener(KeyCode.Control); ///if krom_darwin - kb.upListener(KeyCode.Meta); + Keyboard.upListener(KeyCode.Meta); ///end } @@ -319,9 +318,8 @@ class UIFiles { if (state == State.Started) { if (f != ".." && dragFiles) { - let mouse = Input.getMouse(); - Base.dragOffX = -(mouse.x - uix - ui._windowX - 3); - Base.dragOffY = -(mouse.y - uiy - ui._windowY + 1); + Base.dragOffX = -(Mouse.x - uix - ui._windowX - 3); + Base.dragOffY = -(Mouse.y - uiy - ui._windowY + 1); Base.dragFile = handle.text; ///if krom_ios if (!isCloud) Base.dragFile = documentDirectory + Base.dragFile; diff --git a/base/Sources/UIHeader.ts b/base/Sources/UIHeader.ts index 082e001d..9a34ad01 100644 --- a/base/Sources/UIHeader.ts +++ b/base/Sources/UIHeader.ts @@ -121,11 +121,10 @@ class UIHeader { h.color = color; let state = ui.text("", 0, h.color); if (state == State.Started) { - let mouse = Input.getMouse(); let uix = ui._x; let uiy = ui._y; - Base.dragOffX = -(mouse.x - uix - ui._windowX - 3); - Base.dragOffY = -(mouse.y - uiy - ui._windowY + 1); + Base.dragOffX = -(Mouse.x - uix - ui._windowX - 3); + Base.dragOffY = -(Mouse.y - uiy - ui._windowY + 1); Base.dragSwatch = Project.cloneSwatch(Context.raw.pickedColor); } if (ui.isHovered) ui.tooltip(tr("Drag and drop picked color to swatches, materials, layers or to the node editor")); diff --git a/base/Sources/UIMenu.ts b/base/Sources/UIMenu.ts index ea2d3f33..f44b832b 100644 --- a/base/Sources/UIMenu.ts +++ b/base/Sources/UIMenu.ts @@ -120,7 +120,7 @@ class UIMenu { ui.changed = false; UIMenu.menuFill(ui); - let p = Scene.active.world.probe; + let p = Scene.active.world; let envHandle = Zui.handle("uimenu_0"); envHandle.value = p.raw.strength; UIMenu.menuAlign(ui); @@ -147,10 +147,10 @@ class UIMenu { UIMenu.menuFill(ui); let lhandle = Zui.handle("uimenu_2"); let scale = 1333; - lhandle.value = light.data.raw.strength / scale; + lhandle.value = light.data.strength / scale; lhandle.value = Math.floor(lhandle.value * 100) / 100; UIMenu.menuAlign(ui); - light.data.raw.strength = ui.slider(lhandle, tr("Light"), 0.0, 4.0, true) * scale; + light.data.strength = ui.slider(lhandle, tr("Light"), 0.0, 4.0, true) * scale; if (lhandle.changed) Context.raw.ddirty = 2; UIMenu.menuFill(ui); @@ -173,9 +173,9 @@ class UIMenu { UIMenu.menuFill(ui); let sxhandle = Zui.handle("uimenu_4"); - sxhandle.value = light.data.raw.size; + sxhandle.value = light.data.size; UIMenu.menuAlign(ui); - light.data.raw.size = ui.slider(sxhandle, tr("Light Size"), 0.0, 4.0, true); + light.data.size = ui.slider(sxhandle, tr("Light Size"), 0.0, 4.0, true); if (sxhandle.changed) Context.raw.ddirty = 2; } @@ -359,9 +359,9 @@ class UIMenu { UIMenu.menuFill(ui); let cam = Scene.active.camera; - Context.raw.fovHandle = Zui.handle("uimenu_11", { value: Math.floor(cam.data.raw.fov * 100) / 100 }); + Context.raw.fovHandle = Zui.handle("uimenu_11", { value: Math.floor(cam.data.fov * 100) / 100 }); UIMenu.menuAlign(ui); - cam.data.raw.fov = ui.slider(Context.raw.fovHandle, tr("FoV"), 0.3, 1.4, true); + cam.data.fov = ui.slider(Context.raw.fovHandle, tr("FoV"), 0.3, 1.4, true); if (Context.raw.fovHandle.changed) { Viewport.updateCameraType(Context.raw.cameraType); } @@ -538,8 +538,8 @@ class UIMenu { UIMenu.show = true; UIMenu.menuCommands = commands; UIMenu.menuElements = elements; - UIMenu.menuX = x > -1 ? x : Math.floor(Input.getMouse().x + 1); - UIMenu.menuY = y > -1 ? y : Math.floor(Input.getMouse().y + 1); + UIMenu.menuX = x > -1 ? x : Math.floor(Mouse.x + 1); + UIMenu.menuY = y > -1 ? y : Math.floor(Mouse.y + 1); UIMenu.fitToScreen(); } diff --git a/base/Sources/UINodes.ts b/base/Sources/UINodes.ts index 6b748e50..7ec38d0e 100644 --- a/base/Sources/UINodes.ts +++ b/base/Sources/UINodes.ts @@ -63,8 +63,7 @@ class UINodes { else { linkY += nodes.INPUT_Y(UINodes.getCanvas(true), node.inputs, linkDrag.to_socket) + nodes.OUTPUTS_H(node.outputs) + nodes.BUTTONS_H(node); } - let mouse = Input.getMouse(); - if (Math.abs(mouse.x - linkX) > 5 || Math.abs(mouse.y - linkY) > 5) { // Link length + if (Math.abs(Mouse.x - linkX) > 5 || Math.abs(Mouse.y - linkY) > 5) { // Link length UINodes.nodeSearch(-1, -1, () => { let n = nodes.getNode(UINodes.getCanvas(true).nodes, nodes.nodesSelectedId[0]); if (linkDrag.to_id == -1 && n.inputs.length > 0) { @@ -442,9 +441,6 @@ class UINodes { static update = () => { if (!UINodes.show || !Base.uiEnabled) return; - let mouse = Input.getMouse(); - let kb = Input.getKeyboard(); - ///if (is_paint || is_sculpt) UINodes.wx = Math.floor(App.w()) + UIToolbar.toolbarw; ///end @@ -466,8 +462,8 @@ class UINodes { UINodes.wy = 0; } - let mx = mouse.x; - let my = mouse.y; + let mx = Mouse.x; + let my = Mouse.y; if (mx < UINodes.wx || mx > UINodes.wx + ww || my < UINodes.wy) return; if (UINodes.ui.isTyping || !UINodes.ui.inputEnabled) return; @@ -482,8 +478,8 @@ class UINodes { // Node search popup if (Operator.shortcut(Config.keymap.node_search)) UINodes.nodeSearch(); if (UINodes.nodeSearchSpawn != null) { - UINodes.ui.inputX = mouse.x; // Fix inputDX after popup removal - UINodes.ui.inputY = mouse.y; + UINodes.ui.inputX = Mouse.x; // Fix inputDX after popup removal + UINodes.ui.inputY = Mouse.y; UINodes.nodeSearchSpawn = null; } @@ -500,7 +496,6 @@ class UINodes { } static nodeSearch = (x = -1, y = -1, done: ()=>void = null) => { - let kb = Input.getKeyboard(); let searchHandle = Zui.handle("uinodes_9"); let first = true; UIMenu.draw((ui: Zui) => { @@ -522,7 +517,7 @@ class UINodes { if (ui.key == KeyCode.Down && UINodes.nodeSearchOffset < 6) UINodes.nodeSearchOffset++; if (ui.key == KeyCode.Up && UINodes.nodeSearchOffset > 0) UINodes.nodeSearchOffset--; } - let enter = kb.down("enter"); + let enter = Keyboard.down("enter"); let count = 0; let BUTTON_COL = ui.t.BUTTON_COL; @@ -571,13 +566,11 @@ class UINodes { } static getNodeX = (): i32 => { - let mouse = Input.getMouse(); - return Math.floor((mouse.x - UINodes.wx - UINodes.getNodes().PAN_X()) / UINodes.getNodes().SCALE()); + return Math.floor((Mouse.x - UINodes.wx - UINodes.getNodes().PAN_X()) / UINodes.getNodes().SCALE()); } static getNodeY = (): i32 => { - let mouse = Input.getMouse(); - return Math.floor((mouse.y - UINodes.wy - UINodes.getNodes().PAN_Y()) / UINodes.getNodes().SCALE()); + return Math.floor((Mouse.y - UINodes.wy - UINodes.getNodes().PAN_Y()) / UINodes.getNodes().SCALE()); } static drawGrid = () => { diff --git a/base/Sources/UIView2D.ts b/base/Sources/UIView2D.ts index f81abca6..1617cb57 100644 --- a/base/Sources/UIView2D.ts +++ b/base/Sources/UIView2D.ts @@ -380,9 +380,6 @@ class UIView2D { } static update = () => { - let mouse = Input.getMouse(); - let kb = Input.getKeyboard(); - let headerh = UIView2D.ui.ELEMENT_H() * 1.4; ///if (is_paint || is_sculpt) @@ -391,10 +388,10 @@ class UIView2D { if (!Base.uiEnabled || !UIView2D.show || - mouse.x < UIView2D.wx || - mouse.x > UIView2D.wx + UIView2D.ww || - mouse.y < UIView2D.wy + headerh || - mouse.y > UIView2D.wy + UIView2D.wh) { + Mouse.x < UIView2D.wx || + Mouse.x > UIView2D.wx + UIView2D.ww || + Mouse.y < UIView2D.wy + headerh || + Mouse.y > UIView2D.wy + UIView2D.wh) { if (UIView2D.controlsDown) { UINodes.getCanvasControl(UIView2D.ui, UIView2D); } @@ -438,10 +435,10 @@ class UIView2D { if (UIView2D.ui.isTyping) return; - if (kb.started("left")) UIView2D.panX -= 5; - else if (kb.started("right")) UIView2D.panX += 5; - if (kb.started("up")) UIView2D.panY -= 5; - else if (kb.started("down")) UIView2D.panY += 5; + if (Keyboard.started("left")) UIView2D.panX -= 5; + else if (Keyboard.started("right")) UIView2D.panX += 5; + if (Keyboard.started("up")) UIView2D.panY -= 5; + else if (Keyboard.started("down")) UIView2D.panY += 5; // Limit panning to keep texture in viewport let border = 32; diff --git a/base/Sources/UniformsExt.ts b/base/Sources/UniformsExt.ts index 0408c15b..78293a3c 100644 --- a/base/Sources/UniformsExt.ts +++ b/base/Sources/UniformsExt.ts @@ -30,9 +30,8 @@ class UniformsExt { } let radius = decalMask ? brushDecalMaskRadius : Context.raw.brushRadius; let val = (radius * Context.raw.brushNodesRadius) / 15.0; - let pen = Input.getPen(); - if (Config.raw.pressure_radius && pen.down()) { - val *= pen.pressure * Config.raw.pressure_sensitivity; + if (Config.raw.pressure_radius && Pen.down()) { + val *= Pen.pressure * Config.raw.pressure_sensitivity; } let scale2d = (900 / Base.h()) * Config.raw.window_scale; @@ -47,9 +46,8 @@ class UniformsExt { ///if is_lab let radius = Context.raw.brushRadius; let val = radius / 15.0; - let pen = Input.getPen(); - if (Config.raw.pressure_radius && pen.down()) { - val *= pen.pressure * Config.raw.pressure_sensitivity; + if (Config.raw.pressure_radius && Pen.down()) { + val *= Pen.pressure * Config.raw.pressure_sensitivity; } val *= 2; ///end @@ -75,9 +73,8 @@ class UniformsExt { } case "_brushOpacity": { let val = Context.raw.brushOpacity * Context.raw.brushNodesOpacity; - let pen = Input.getPen(); - if (Config.raw.pressure_opacity && pen.down()) { - val *= pen.pressure * Config.raw.pressure_sensitivity; + if (Config.raw.pressure_opacity && Pen.down()) { + val *= Pen.pressure * Config.raw.pressure_sensitivity; } return val; } @@ -86,9 +83,8 @@ class UniformsExt { let decalMask = Operator.shortcut(Config.keymap.decal_mask + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown); if (Context.raw.tool != WorkspaceTool.ToolBrush && Context.raw.tool != WorkspaceTool.ToolEraser && Context.raw.tool != WorkspaceTool.ToolClone && !decalMask) return 1.0; let val = Context.raw.brushHardness * Context.raw.brushNodesHardness; - let pen = Input.getPen(); - if (Config.raw.pressure_hardness && pen.down()) { - val *= pen.pressure * Config.raw.pressure_sensitivity; + if (Config.raw.pressure_hardness && Pen.down()) { + val *= Pen.pressure * Config.raw.pressure_sensitivity; } if (Config.raw.brush_3d) { if (Context.raw.paint2d) { @@ -173,9 +169,8 @@ class UniformsExt { let brushAngle = Context.raw.brushAngle + Context.raw.brushNodesAngle; let angle = Context.raw.layer.fill_layer != null ? Context.raw.layer.angle : brushAngle; angle *= (Math.PI / 180); - let pen = Input.getPen(); - if (Config.raw.pressure_angle && pen.down()) { - angle *= pen.pressure * Config.raw.pressure_sensitivity; + if (Config.raw.pressure_angle && Pen.down()) { + angle *= Pen.pressure * Config.raw.pressure_sensitivity; } UniformsExt.vec.set(Math.cos(-angle), Math.sin(-angle), 0); return UniformsExt.vec; @@ -269,7 +264,7 @@ class UniformsExt { static linkVec4 = (object: BaseObject, mat: MaterialData, link: string): Vec4 => { switch (link) { case "_inputBrush": { - let down = Input.getMouse().down() || Input.getPen().down(); + let down = Mouse.down() || Pen.down(); UniformsExt.vec.set(Context.raw.paintVec.x, Context.raw.paintVec.y, down ? 1.0 : 0.0, 0.0); ///if (is_paint || is_sculpt) @@ -281,7 +276,7 @@ class UniformsExt { return UniformsExt.vec; } case "_inputBrushLast": { - let down = Input.getMouse().down() || Input.getPen().down(); + let down = Mouse.down() || Pen.down(); UniformsExt.vec.set(Context.raw.lastPaintVecX, Context.raw.lastPaintVecY, down ? 1.0 : 0.0, 0.0); ///if (is_paint || is_sculpt) @@ -293,11 +288,11 @@ class UniformsExt { return UniformsExt.vec; } case "_envmapData": { - UniformsExt.vec.set(Context.raw.envmapAngle, Math.sin(-Context.raw.envmapAngle), Math.cos(-Context.raw.envmapAngle), Scene.active.world.probe.raw.strength); + UniformsExt.vec.set(Context.raw.envmapAngle, Math.sin(-Context.raw.envmapAngle), Math.cos(-Context.raw.envmapAngle), Scene.active.world.raw.strength); return UniformsExt.vec; } case "_envmapDataWorld": { - UniformsExt.vec.set(Context.raw.envmapAngle, Math.sin(-Context.raw.envmapAngle), Math.cos(-Context.raw.envmapAngle), Context.raw.showEnvmap ? Scene.active.world.probe.raw.strength : 1.0); + UniformsExt.vec.set(Context.raw.envmapAngle, Math.sin(-Context.raw.envmapAngle), Math.cos(-Context.raw.envmapAngle), Context.raw.showEnvmap ? Scene.active.world.raw.strength : 1.0); return UniformsExt.vec; } ///if (is_paint || is_sculpt) diff --git a/base/Sources/UtilParticle.ts b/base/Sources/UtilParticle.ts index 3a5a33fb..a25d0463 100644 --- a/base/Sources/UtilParticle.ts +++ b/base/Sources/UtilParticle.ts @@ -106,7 +106,7 @@ class UtilParticle { Context.raw.paintBody = PhysicsBody.create(); Context.raw.paintBody.shape = ShapeType.ShapeMesh; PhysicsBody.init(Context.raw.paintBody, po); - po.addTrait(Context.raw.paintBody); + (po as any).physicsBody = Context.raw.paintBody; } ///end diff --git a/base/Sources/UtilRender.ts b/base/Sources/UtilRender.ts index eed51fb3..77b0c2bc 100644 --- a/base/Sources/UtilRender.ts +++ b/base/Sources/UtilRender.ts @@ -25,14 +25,14 @@ class UtilRender { Context.raw.savedCamera.setFrom(Scene.active.camera.transform.local); let m = new Mat4(0.9146286343879498, -0.0032648027153306235, 0.404281837254303, 0.4659988049397712, 0.404295023959927, 0.007367569133732468, -0.9145989516155143, -1.0687517188018691, 0.000007410128652369705, 0.9999675337275382, 0.008058532943908717, 0.015935682577325486, 0, 0, 0, 1); Scene.active.camera.transform.setMatrix(m); - let savedFov = Scene.active.camera.data.raw.fov; - Scene.active.camera.data.raw.fov = 0.92; + let savedFov = Scene.active.camera.data.fov; + Scene.active.camera.data.fov = 0.92; Viewport.updateCameraType(CameraType.CameraPerspective); let light = Scene.active.lights[0]; - let _lightStrength = light.data.raw.strength; - let probe = Scene.active.world.probe; + let _lightStrength = light.data.strength; + let probe = Scene.active.world; let _probeStrength = probe.raw.strength; - light.data.raw.strength = 0; + light.data.strength = 0; probe.raw.strength = 7; let _envmapAngle = Context.raw.envmapAngle; Context.raw.envmapAngle = 6.0; @@ -65,10 +65,10 @@ class UtilRender { Scene.active.camera.transform.setMatrix(Context.raw.savedCamera); Viewport.updateCameraType(Context.raw.cameraType); - Scene.active.camera.data.raw.fov = savedFov; + Scene.active.camera.data.fov = savedFov; Scene.active.camera.buildProjection(); Scene.active.camera.buildMatrix(); - light.data.raw.strength = _lightStrength; + light.data.strength = _lightStrength; probe.raw.strength = _probeStrength; Context.raw.envmapAngle = _envmapAngle; Context.raw.brushScale = _brushScale; @@ -101,8 +101,8 @@ class UtilRender { let m = Mat4.identity(); m.translate(0, 0, 1); Scene.active.camera.transform.setMatrix(m); - let savedFov = Scene.active.camera.data.raw.fov; - Scene.active.camera.data.raw.fov = 0.92; + let savedFov = Scene.active.camera.data.fov; + Scene.active.camera.data.fov = 0.92; Viewport.updateCameraType(CameraType.CameraPerspective); let light = Scene.active.lights[0]; light.visible = false; @@ -130,7 +130,7 @@ class UtilRender { Context.raw.paintObject = painto; Scene.active.camera.transform.setMatrix(Context.raw.savedCamera); - Scene.active.camera.data.raw.fov = savedFov; + Scene.active.camera.data.fov = savedFov; Viewport.updateCameraType(Context.raw.cameraType); Scene.active.camera.buildProjection(); Scene.active.camera.buildMatrix(); @@ -256,12 +256,12 @@ class UtilRender { let cam = Scene.active.camera; Context.raw.savedCamera.setFrom(cam.transform.local); - let savedFov = cam.data.raw.fov; + let savedFov = cam.data.fov; Viewport.updateCameraType(CameraType.CameraPerspective); let m = Mat4.identity(); m.translate(0, 0, 0.5); cam.transform.setMatrix(m); - cam.data.raw.fov = 0.92; + cam.data.fov = 0.92; cam.buildProjection(); cam.buildMatrix(); m.getInverse(Scene.active.camera.VP); @@ -335,7 +335,7 @@ class UtilRender { } Context.raw.paintObject = painto; Scene.active.camera.transform.setMatrix(Context.raw.savedCamera); - Scene.active.camera.data.raw.fov = savedFov; + Scene.active.camera.data.fov = savedFov; Viewport.updateCameraType(Context.raw.cameraType); Scene.active.camera.buildProjection(); Scene.active.camera.buildMatrix(); diff --git a/base/Sources/Viewport.ts b/base/Sources/Viewport.ts index 33d8e17d..f8c40066 100644 --- a/base/Sources/Viewport.ts +++ b/base/Sources/Viewport.ts @@ -25,9 +25,9 @@ class Viewport { if (o.type == "camera_object") { cam.transform.local.setF32(o.transform.values); cam.transform.decompose(); - if (Context.raw.fovHandle != null) Context.raw.fovHandle.value = cam.data.raw.fov = Base.defaultFov; + if (Context.raw.fovHandle != null) Context.raw.fovHandle.value = cam.data.fov = Base.defaultFov; Context.raw.camHandle.position = 0; - cam.data.raw.ortho = null; + cam.data.ortho = null; cam.buildProjection(); Context.raw.ddirty = 2; Camera.reset(); @@ -76,17 +76,17 @@ class Viewport { let cam = Scene.active.cameras[0]; let light = Scene.active.lights[0]; if (cameraType == CameraType.CameraPerspective) { - cam.data.raw.ortho = null; + cam.data.ortho = null; light.visible = true; } else { let f32a = new Float32Array(4); - let f = cam.data.raw.fov * cam.transform.world.getLoc().length() / 2.5; + let f = cam.data.fov * cam.transform.world.getLoc().length() / 2.5; f32a[0] = -2 * f; f32a[1] = 2 * f; f32a[2] = -2 * f * (App.h() / App.w()); f32a[3] = 2 * f * (App.h() / App.w()); - cam.data.raw.ortho = f32a; + cam.data.ortho = f32a; light.visible = false; } cam.buildProjection();