use automatic drop down setting from SceneNodeSettings

This commit is contained in:
Maël Kerbiriou 2022-09-01 15:29:52 +02:00
parent ccdbc3e06f
commit 111136cf49

View file

@ -10,6 +10,7 @@ from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
from UM.Math.Vector import Vector
from UM.Scene.Selection import Selection
from UM.Scene.SceneNodeSettings import SceneNodeSettings
from UM.Util import parseBool
from cura.Scene.ConvexHullDecorator import ConvexHullDecorator
@ -50,8 +51,13 @@ class PlatformPhysics:
if not self._enabled:
return
app_instance = Application.getInstance()
app_preferences = app_instance.getPreferences()
app_automatic_drop_down = str(app_preferences.getValue("physics/automatic_drop_down"))
app_automatic_push_free = app_preferences.getValue("physics/automatic_push_free")
root = self._controller.getScene().getRoot()
build_volume = Application.getInstance().getBuildVolume()
build_volume = app_instance.getBuildVolume()
build_volume.updateNodeBoundaryCheck()
# Keep a list of nodes that are moving. We use this so that we don't move two intersecting objects in the
@ -75,7 +81,7 @@ class PlatformPhysics:
# Move it downwards if bottom is above platform
move_vector = Vector()
if Application.getInstance().getPreferences().getValue("physics/automatic_drop_down") and not (node.getParent() and node.getParent().callDecoration("isGroup") or node.getParent() != root) and node.isEnabled(): #If an object is grouped, don't move it down
if parseBool(node.getSetting(SceneNodeSettings.AutoDropDown, app_automatic_drop_down)) and not (node.getParent() and node.getParent().callDecoration("isGroup") or node.getParent() != root) and node.isEnabled(): #If an object is grouped, don't move it down
z_offset = node.callDecoration("getZOffset") if node.getDecorator(ZOffsetDecorator.ZOffsetDecorator) else 0
move_vector = move_vector.set(y = -bbox.bottom + z_offset)
@ -84,7 +90,7 @@ class PlatformPhysics:
node.addDecorator(ConvexHullDecorator())
# only push away objects if this node is a printing mesh
if not node.callDecoration("isNonPrintingMesh") and Application.getInstance().getPreferences().getValue("physics/automatic_push_free"):
if not node.callDecoration("isNonPrintingMesh") and app_automatic_push_free:
# Do not move locked nodes
if node.getSetting(SceneNodeSettings.LockPosition):
continue