mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
CURA-4269 added a flag to determine wether auto drop should be executed or not
This commit is contained in:
parent
86e5a1ed97
commit
4ca5987ca8
2 changed files with 13 additions and 6 deletions
|
@ -9,6 +9,7 @@ from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
|
|||
from UM.Math.Vector import Vector
|
||||
from UM.Scene.Selection import Selection
|
||||
from UM.Preferences import Preferences
|
||||
from UM.Logger import Logger
|
||||
|
||||
from cura.ConvexHullDecorator import ConvexHullDecorator
|
||||
|
||||
|
@ -41,10 +42,12 @@ class PlatformPhysics:
|
|||
def _onSceneChanged(self, source):
|
||||
self._change_timer.start()
|
||||
|
||||
def _onChangeTimerFinished(self):
|
||||
def _onChangeTimerFinished(self, was_triggered_by_tool=False):
|
||||
if not self._enabled:
|
||||
return
|
||||
|
||||
Logger.log("d", "was_triggered_by_tool=%s", was_triggered_by_tool)
|
||||
|
||||
root = self._controller.getScene().getRoot()
|
||||
|
||||
# Keep a list of nodes that are moving. We use this so that we don't move two intersecting objects in the
|
||||
|
@ -71,14 +74,15 @@ class PlatformPhysics:
|
|||
# Check if this is the first time a project file node was loaded (disable auto drop in that case), defaults to True
|
||||
should_auto_drop = node.getSetting("auto_drop", True)
|
||||
|
||||
# This should NOT happen if the scene change was triggered by a tool (like translate), only on project load
|
||||
if was_triggered_by_tool:
|
||||
should_auto_drop = True
|
||||
|
||||
# If a node is grouped or it's loaded from a project file (auto-drop disabled), don't move it down
|
||||
if Preferences.getInstance().getValue("physics/automatic_drop_down") and not (node.getParent() and node.getParent().callDecoration("isGroup")) and node.isEnabled() and should_auto_drop:
|
||||
z_offset = node.callDecoration("getZOffset") if node.getDecorator(ZOffsetDecorator.ZOffsetDecorator) else 0
|
||||
move_vector = move_vector.set(y=-bbox.bottom + z_offset)
|
||||
|
||||
# Enable auto-drop after processing the project file node for the first time
|
||||
node.setSetting("auto_drop", False)
|
||||
|
||||
# If there is no convex hull for the node, start calculating it and continue.
|
||||
if not node.getDecorator(ConvexHullDecorator):
|
||||
node.addDecorator(ConvexHullDecorator())
|
||||
|
@ -167,4 +171,4 @@ class PlatformPhysics:
|
|||
node.removeDecorator(ZOffsetDecorator.ZOffsetDecorator)
|
||||
|
||||
self._enabled = True
|
||||
self._onChangeTimerFinished()
|
||||
self._onChangeTimerFinished(True)
|
||||
|
|
|
@ -77,7 +77,10 @@ class ThreeMFReader(MeshReader):
|
|||
# \returns Uranium SceneNode.
|
||||
def _convertSavitarNodeToUMNode(self, savitar_node):
|
||||
um_node = SceneNode()
|
||||
um_node.setSetting("auto_drop", False) # Disable the auto-drop feature when loading a project file and processing the nodes for the first time
|
||||
|
||||
# Disable the auto-drop feature when loading a project file and processing the nodes for the first time
|
||||
um_node.setSetting("auto_drop", False)
|
||||
|
||||
transformation = self._createMatrixFromTransformationString(savitar_node.getTransformation())
|
||||
um_node.setTransformation(transformation)
|
||||
mesh_builder = MeshBuilder()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue