mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 07:03:56 -06:00
CURA-4525 solved merge conflicts
This commit is contained in:
commit
bfa33c721c
39 changed files with 11005 additions and 337 deletions
|
@ -34,6 +34,7 @@ class PlatformPhysics:
|
|||
self._change_timer.timeout.connect(self._onChangeTimerFinished)
|
||||
self._move_factor = 1.1 # By how much should we multiply overlap to calculate a new spot?
|
||||
self._max_overlap_checks = 10 # How many times should we try to find a new spot per tick?
|
||||
self._minimum_gap = 2 # It is a minimum distance between two models, applicable for small models
|
||||
|
||||
Preferences.getInstance().addPreference("physics/automatic_push_free", True)
|
||||
Preferences.getInstance().addPreference("physics/automatic_drop_down", True)
|
||||
|
@ -77,7 +78,8 @@ class PlatformPhysics:
|
|||
if not node.getDecorator(ConvexHullDecorator):
|
||||
node.addDecorator(ConvexHullDecorator())
|
||||
|
||||
if Preferences.getInstance().getValue("physics/automatic_push_free"):
|
||||
# only push away objects if this node is a printing mesh
|
||||
if not node.callDecoration("isNonPrintingMesh") and Preferences.getInstance().getValue("physics/automatic_push_free"):
|
||||
# Check for collisions between convex hulls
|
||||
for other_node in BreadthFirstIterator(root):
|
||||
# Ignore root, ourselves and anything that is not a normal SceneNode.
|
||||
|
@ -99,6 +101,9 @@ class PlatformPhysics:
|
|||
if other_node in transformed_nodes:
|
||||
continue # Other node is already moving, wait for next pass.
|
||||
|
||||
if other_node.callDecoration("isNonPrintingMesh"):
|
||||
continue
|
||||
|
||||
overlap = (0, 0) # Start loop with no overlap
|
||||
current_overlap_checks = 0
|
||||
# Continue to check the overlap until we no longer find one.
|
||||
|
@ -113,26 +118,41 @@ class PlatformPhysics:
|
|||
overlap = node.callDecoration("getConvexHull").translate(move_vector.x, move_vector.z).intersectsPolygon(other_head_hull)
|
||||
if overlap:
|
||||
# Moving ensured that overlap was still there. Try anew!
|
||||
move_vector = move_vector.set(x=move_vector.x + overlap[0] * self._move_factor,
|
||||
z=move_vector.z + overlap[1] * self._move_factor)
|
||||
move_vector = move_vector.set(x = move_vector.x + overlap[0] * self._move_factor,
|
||||
z = move_vector.z + overlap[1] * self._move_factor)
|
||||
else:
|
||||
# Moving ensured that overlap was still there. Try anew!
|
||||
move_vector = move_vector.set(x=move_vector.x + overlap[0] * self._move_factor,
|
||||
z=move_vector.z + overlap[1] * self._move_factor)
|
||||
move_vector = move_vector.set(x = move_vector.x + overlap[0] * self._move_factor,
|
||||
z = move_vector.z + overlap[1] * self._move_factor)
|
||||
else:
|
||||
own_convex_hull = node.callDecoration("getConvexHull")
|
||||
other_convex_hull = other_node.callDecoration("getConvexHull")
|
||||
if own_convex_hull and other_convex_hull:
|
||||
overlap = own_convex_hull.translate(move_vector.x, move_vector.z).intersectsPolygon(other_convex_hull)
|
||||
if overlap: # Moving ensured that overlap was still there. Try anew!
|
||||
move_vector = move_vector.set(x=move_vector.x + overlap[0] * self._move_factor,
|
||||
z=move_vector.z + overlap[1] * self._move_factor)
|
||||
temp_move_vector = move_vector.set(x = move_vector.x + overlap[0] * self._move_factor,
|
||||
z = move_vector.z + overlap[1] * self._move_factor)
|
||||
|
||||
# if the distance between two models less than 2mm then try to find a new factor
|
||||
if abs(temp_move_vector.x - overlap[0]) < self._minimum_gap and abs(temp_move_vector.y - overlap[1]) < self._minimum_gap:
|
||||
temp_scale_factor = self._move_factor
|
||||
temp_x_factor = (abs(overlap[0]) + self._minimum_gap) / overlap[0] if overlap[0] != 0 else 0 # find x move_factor, like (3.4 + 2) / 3.4 = 1.58
|
||||
temp_y_factor = (abs(overlap[1]) + self._minimum_gap) / overlap[1] if overlap[1] != 0 else 0 # find y move_factor
|
||||
if abs(temp_x_factor) > abs(temp_y_factor):
|
||||
temp_scale_factor = temp_x_factor
|
||||
else:
|
||||
temp_scale_factor = temp_y_factor
|
||||
|
||||
move_vector = move_vector.set(x = move_vector.x + overlap[0] * temp_scale_factor,
|
||||
z = move_vector.z + overlap[1] * temp_scale_factor)
|
||||
else:
|
||||
move_vector = temp_move_vector
|
||||
else:
|
||||
# This can happen in some cases if the object is not yet done with being loaded.
|
||||
# Simply waiting for the next tick seems to resolve this correctly.
|
||||
overlap = None
|
||||
|
||||
if not Vector.Null.equals(move_vector, epsilon=1e-5):
|
||||
if not Vector.Null.equals(move_vector, epsilon = 1e-5):
|
||||
transformed_nodes.append(node)
|
||||
op = PlatformPhysicsOperation.PlatformPhysicsOperation(node, move_vector)
|
||||
op.push()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue