Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Ha <jackha@gmail.com>2018-01-03 15:52:55 +0300
committerJack Ha <jackha@gmail.com>2018-01-03 15:52:55 +0300
commitbfa33c721cb8f5be9337c9f732d8047f98420728 (patch)
tree5f6adeec9c5e99645c237b788814083cb8415e5a /cura/PlatformPhysics.py
parentdd989a1a51be0854a47515500d016c13bda39ae6 (diff)
parent6997c2d2dce03f0b85f17e1a3ef18ce319047ecd (diff)
CURA-4525 solved merge conflicts
Diffstat (limited to 'cura/PlatformPhysics.py')
-rwxr-xr-xcura/PlatformPhysics.py36
1 files changed, 28 insertions, 8 deletions
diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py
index 43118c5d01..7aec519e6f 100755
--- a/cura/PlatformPhysics.py
+++ b/cura/PlatformPhysics.py
@@ -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()