From 99c224293f97396c9a5eea164923fbb223c8a52e Mon Sep 17 00:00:00 2001 From: lviguier Date: Mon, 20 Jan 2025 10:35:37 +0100 Subject: [PATCH] Meshspray: fix mesh spray preview circle not updated when pressing shift oustide of the scene editor --- hrt/prefab/l3d/MeshSpray.hx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/hrt/prefab/l3d/MeshSpray.hx b/hrt/prefab/l3d/MeshSpray.hx index 7387d496f..8822ca08c 100644 --- a/hrt/prefab/l3d/MeshSpray.hx +++ b/hrt/prefab/l3d/MeshSpray.hx @@ -444,21 +444,28 @@ class MeshSpray extends Spray { var s2d = shared.root2d.getScene(); + var isShiftPressed = false; + ectx.scene.editor.view.element.keydown(function(e) { + if (e.shiftKey) + isShiftPressed = true; + }); + ectx.scene.editor.view.element.keyup(function(e) { + isShiftPressed = false; + }); + interactive.onMove = function(e) { var worldPos = ectx.screenToGround(s2d.mouseX, s2d.mouseY); - var shiftPressed = hxd.Key.isDown( hxd.Key.SHIFT); - if( worldPos == null ) { clearBrushes(); return; } - drawCircle(worldPos.x, worldPos.y, worldPos.z, (shiftPressed) ? currentConfig.deleteRadius : currentConfig.radius, 5, (shiftPressed) ? 9830400 : 38400); + drawCircle(worldPos.x, worldPos.y, worldPos.z, (isShiftPressed) ? currentConfig.deleteRadius : currentConfig.radius, 5, (isShiftPressed) ? 9830400 : 38400); if (lastSpray < Date.now().getTime() - 100) { clearPreview(); - if( !shiftPressed ) { + if( !isShiftPressed ) { previewItemsAround(ectx, worldPos); } @@ -467,7 +474,7 @@ class MeshSpray extends Spray { binaryChanged = true; if (sprayEnable) { - if( shiftPressed ) { + if( isShiftPressed ) { removeItemsAround(worldPos); } else { if (currentConfig.density == 1) {