mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
Improved robustness of Platform physics by checking if the hulls are calculated before trying to intersect them.
fixes CURA-1827
This commit is contained in:
parent
1ced206c5d
commit
19933cb4e7
2 changed files with 11 additions and 13 deletions
|
@ -63,9 +63,6 @@ class PlatformPhysics:
|
|||
elif bbox.bottom < z_offset:
|
||||
move_vector = move_vector.set(y=(-bbox.bottom) - z_offset)
|
||||
|
||||
#if not Float.fuzzyCompare(bbox.bottom, 0.0):
|
||||
# pass#move_vector.setY(-bbox.bottom)
|
||||
|
||||
# If there is no convex hull for the node, start calculating it and continue.
|
||||
if not node.getDecorator(ConvexHullDecorator):
|
||||
node.addDecorator(ConvexHullDecorator())
|
||||
|
@ -78,24 +75,18 @@ class PlatformPhysics:
|
|||
if other_node is root or type(other_node) is not SceneNode or other_node is node:
|
||||
continue
|
||||
|
||||
# Ignore colissions of a group with it's own children
|
||||
# Ignore collisions of a group with it's own children
|
||||
if other_node in node.getAllChildren() or node in other_node.getAllChildren():
|
||||
continue
|
||||
|
||||
# Ignore colissions within a group
|
||||
# Ignore collisions within a group
|
||||
if other_node.getParent().callDecoration("isGroup") is not None or node.getParent().callDecoration("isGroup") is not None:
|
||||
continue
|
||||
#if node.getParent().callDecoration("isGroup") is other_node.getParent().callDecoration("isGroup"):
|
||||
# continue
|
||||
|
||||
# Ignore nodes that do not have the right properties set.
|
||||
if not other_node.callDecoration("getConvexHull") or not other_node.getBoundingBox():
|
||||
continue
|
||||
|
||||
# Check to see if the bounding boxes intersect. If not, we can ignore the node as there is no way the hull intersects.
|
||||
#if node.getBoundingBox().intersectsBox(other_node.getBoundingBox()) == AxisAlignedBox.IntersectionResult.NoIntersection:
|
||||
# continue
|
||||
|
||||
# Get the overlap distance for both convex hulls. If this returns None, there is no intersection.
|
||||
head_hull = node.callDecoration("getConvexHullHead")
|
||||
if head_hull:
|
||||
|
@ -105,7 +96,14 @@ class PlatformPhysics:
|
|||
if other_head_hull:
|
||||
overlap = node.callDecoration("getConvexHull").intersectsPolygon(other_head_hull)
|
||||
else:
|
||||
overlap = node.callDecoration("getConvexHull").intersectsPolygon(other_node.callDecoration("getConvexHull"))
|
||||
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.intersectsPolygon(other_convex_hull)
|
||||
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 overlap is None:
|
||||
continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue