mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-19 01:35:56 +08:00
Store the disallowed areas as polygons and use those to test for intersection
This prevents issues when trying to print larger things Contributes to Asana issue 37107676459484
This commit is contained in:
parent
8ca0e8eef2
commit
886dac5781
@ -18,6 +18,7 @@ from UM.Preferences import Preferences
|
||||
from UM.Message import Message
|
||||
from UM.PluginRegistry import PluginRegistry
|
||||
from UM.JobQueue import JobQueue
|
||||
from UM.Math.Polygon import Polygon
|
||||
|
||||
from UM.Scene.BoxRenderer import BoxRenderer
|
||||
from UM.Scene.Selection import Selection
|
||||
@ -466,23 +467,13 @@ class CuraApplication(QtApplication):
|
||||
disallowed_areas = machine.getSettingValueByKey("machine_disallowed_areas")
|
||||
areas = []
|
||||
if disallowed_areas:
|
||||
|
||||
for area in disallowed_areas:
|
||||
polygon = []
|
||||
polygon.append(Vector(area[0][0], 0.2, area[0][1]))
|
||||
polygon.append(Vector(area[1][0], 0.2, area[1][1]))
|
||||
polygon.append(Vector(area[2][0], 0.2, area[2][1]))
|
||||
polygon.append(Vector(area[3][0], 0.2, area[3][1]))
|
||||
areas.append(polygon)
|
||||
areas.append(Polygon(numpy.array(area, numpy.float32)))
|
||||
|
||||
self._volume.setDisallowedAreas(areas)
|
||||
|
||||
self._volume.rebuild()
|
||||
|
||||
if self.getController().getTool("ScaleTool"):
|
||||
bbox = self._volume.getBoundingBox()
|
||||
bbox.setBottom(0.0)
|
||||
self.getController().getTool("ScaleTool").setMaximumBounds(bbox)
|
||||
|
||||
offset = machine.getSettingValueByKey("machine_platform_offset")
|
||||
if offset:
|
||||
self._platform.setPosition(Vector(offset[0], offset[1], offset[2]))
|
||||
|
@ -94,14 +94,19 @@ class PlatformPhysics:
|
||||
move_vector.setX(overlap[0] * 1.1)
|
||||
move_vector.setZ(overlap[1] * 1.1)
|
||||
|
||||
if hasattr(node, "_convex_hull"):
|
||||
# Check for collisions between disallowed areas and the object
|
||||
for area in self._build_volume.getDisallowedAreas():
|
||||
overlap = node._convex_hull.intersectsPolygon(area)
|
||||
if overlap is None:
|
||||
continue
|
||||
|
||||
node._outside_buildarea = True
|
||||
|
||||
if move_vector != Vector():
|
||||
op = PlatformPhysicsOperation.PlatformPhysicsOperation(node, move_vector)
|
||||
op.push()
|
||||
|
||||
if node.getBoundingBox().intersectsBox(self._build_volume.getBoundingBox()) == AxisAlignedBox.IntersectionResult.FullIntersection:
|
||||
op = ScaleToBoundsOperation(node, self._build_volume.getBoundingBox())
|
||||
op.push()
|
||||
|
||||
def _onToolOperationStarted(self, tool):
|
||||
self._enabled = False
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user