From 9cf328274e29f9cfab6872715ea702e36729740e Mon Sep 17 00:00:00 2001 From: Sorata <39014375+q8X@users.noreply.github.com> Date: Tue, 3 Sep 2024 22:17:38 +0300 Subject: [PATCH 1/2] Fix EDF custom elements have wrong rotation --- [editor]/move_keyboard/move_keyboard.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/[editor]/move_keyboard/move_keyboard.lua b/[editor]/move_keyboard/move_keyboard.lua index 416c85c41..0eadf1a19 100644 --- a/[editor]/move_keyboard/move_keyboard.lua +++ b/[editor]/move_keyboard/move_keyboard.lua @@ -190,9 +190,9 @@ local function onClientRender_keyboard() else local tempRotX, tempRotY, tempRotZ = rotX, rotY, rotZ if (not tempRotX) then return false end - + local yaw, pitch, roll = 0, 0, 0 - + -- yaw if (getCommandTogSTATE("element_move_right")) then yaw = speed @@ -206,14 +206,14 @@ local function onClientRender_keyboard() elseif (getCommandTogSTATE("element_move_downwards")) then pitch = -speed end - + -- roll if (getCommandTogSTATE("element_move_forward")) then roll = speed elseif (getCommandTogSTATE("element_move_backward")) then roll = -speed end - + -- Perform rotation about one axis at a time if yaw ~= 0 then tempRotX, tempRotY, tempRotZ = exports.editor_main:applyIncrementalRotation(selectedElement, "yaw", yaw, world_space) @@ -289,7 +289,7 @@ local function onClientRender_keyboard() if (not tempRotX) then return false end local yaw, pitch, roll = 0, 0, 0 - + -- yaw if (getCommandTogSTATE("element_move_right")) then yaw = speed @@ -303,14 +303,14 @@ local function onClientRender_keyboard() elseif (getCommandTogSTATE("element_move_downwards")) then pitch = -speed end - + -- roll if (getCommandTogSTATE("element_move_forward")) then roll = speed elseif (getCommandTogSTATE("element_move_backward")) then roll = -speed end - + -- Perform rotation about one axis at a time if yaw ~= 0 then tempRotX, tempRotY, tempRotZ = exports.editor_main:applyIncrementalRotation(selectedElement, "yaw", yaw, world_space) @@ -404,6 +404,9 @@ function attachElement(element) posX, posY, posZ = getElementPosition(element) movementType = MOVEMENT_MOVE + -- Clear the quat rotation when attaching to element + exports.editor_main:clearElementQuat(selectedElement) + if (getElementType(element) == "vehicle") or (getElementType(element) == "object") then rotX, rotY, rotZ = getElementRotation(element, "ZYX") elseif (getElementType(element) == "player") or (getElementType(element) == "ped") then @@ -420,6 +423,9 @@ function detachElement() if (selectedElement) then disable() + -- Clear the quat rotation when detaching from element + exports.editor_main:clearElementQuat(selectedElement) + -- fix for local elements if not isElementLocal(selectedElement) then -- sync position/rotation From fd017fb9488d02291308bb93bc4c0a634db4e680 Mon Sep 17 00:00:00 2001 From: Sorata <39014375+q8X@users.noreply.github.com> Date: Sun, 8 Sep 2024 12:30:33 +0300 Subject: [PATCH 2/2] fix whitespaces --- [editor]/move_keyboard/move_keyboard.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/[editor]/move_keyboard/move_keyboard.lua b/[editor]/move_keyboard/move_keyboard.lua index 0eadf1a19..48a9f7ba4 100644 --- a/[editor]/move_keyboard/move_keyboard.lua +++ b/[editor]/move_keyboard/move_keyboard.lua @@ -190,9 +190,9 @@ local function onClientRender_keyboard() else local tempRotX, tempRotY, tempRotZ = rotX, rotY, rotZ if (not tempRotX) then return false end - + local yaw, pitch, roll = 0, 0, 0 - + -- yaw if (getCommandTogSTATE("element_move_right")) then yaw = speed @@ -206,14 +206,14 @@ local function onClientRender_keyboard() elseif (getCommandTogSTATE("element_move_downwards")) then pitch = -speed end - + -- roll if (getCommandTogSTATE("element_move_forward")) then roll = speed elseif (getCommandTogSTATE("element_move_backward")) then roll = -speed end - + -- Perform rotation about one axis at a time if yaw ~= 0 then tempRotX, tempRotY, tempRotZ = exports.editor_main:applyIncrementalRotation(selectedElement, "yaw", yaw, world_space) @@ -289,7 +289,7 @@ local function onClientRender_keyboard() if (not tempRotX) then return false end local yaw, pitch, roll = 0, 0, 0 - + -- yaw if (getCommandTogSTATE("element_move_right")) then yaw = speed @@ -303,14 +303,14 @@ local function onClientRender_keyboard() elseif (getCommandTogSTATE("element_move_downwards")) then pitch = -speed end - + -- roll if (getCommandTogSTATE("element_move_forward")) then roll = speed elseif (getCommandTogSTATE("element_move_backward")) then roll = -speed end - + -- Perform rotation about one axis at a time if yaw ~= 0 then tempRotX, tempRotY, tempRotZ = exports.editor_main:applyIncrementalRotation(selectedElement, "yaw", yaw, world_space)