Skip to content

Commit 20b75b7

Browse files
authored
editor: replace 1729ceb (#219) with a better fix (#220)
When dragging the representation the cursor could point at it which would result in the object moving away from itself. For whatever reason I didn't come across this when testing. And now I know why the collisions are being disabled. So here's a better fix that only disables the collisions when the element is being dragged.
1 parent 1729ceb commit 20b75b7

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

[editor]/editor_main/client/main.lua

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -635,19 +635,6 @@ function setRepresentationCollisionsEnabled(element, state)
635635
end
636636
end
637637

638-
function requiresObjectCollisions(element)
639-
for k, child in ipairs(getElementChildren(element)) do
640-
if not getElementData(child, "edf:dummy") then
641-
if getElementData(child, "edf:rep") then
642-
if getElementType(child) ~= "object" then
643-
return false
644-
end
645-
end
646-
end
647-
end
648-
return true
649-
end
650-
651638
-- Drag and drop
652639
function processCursorMove(cursorX, cursorY, absoluteX, absoluteY, worldX, worldY, worldZ)
653640
if g_dragElement then
@@ -770,11 +757,6 @@ function selectElement(element, submode, shortcut, dropreleaseLock, dropclonedro
770757

771758
assert(handle == nil or isElement(handle), "Bad handle ["..tostring(handle).."] for element: "..getElementType(element))
772759

773-
-- temporarily disable collisions for all parts
774-
if not requiresObjectCollisions(element) then
775-
setRepresentationCollisionsEnabled(element, false)
776-
end
777-
778760
-- if we can position this element, grab it and add the markers
779761
if handle then
780762
local move_resource
@@ -785,6 +767,8 @@ function selectElement(element, submode, shortcut, dropreleaseLock, dropclonedro
785767
move_resource = move_cursor
786768
end
787769
move_resource.setMaxMoveDistance(g_moveDistance)
770+
-- if we're dragging the object, disable collisions for all parts so the cursor can point through it
771+
setRepresentationCollisionsEnabled(element, false)
788772
elseif (submode == KEYBOARD_SUBMODE) then
789773
move_resource = move_keyboard
790774
else

0 commit comments

Comments
 (0)