mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 04:45:52 +08:00
Merge branch 'master' of https://github.com/Ultimaker/Cura
This commit is contained in:
commit
2742251529
@ -29,16 +29,24 @@ class ConvexHullNode(SceneNode):
|
|||||||
self._node.parentChanged.connect(self._onNodeParentChanged)
|
self._node.parentChanged.connect(self._onNodeParentChanged)
|
||||||
self._node.decoratorsChanged.connect(self._onNodeDecoratorsChanged)
|
self._node.decoratorsChanged.connect(self._onNodeDecoratorsChanged)
|
||||||
self._onNodeDecoratorsChanged(self._node)
|
self._onNodeDecoratorsChanged(self._node)
|
||||||
|
self.convexHullHeadMesh = None
|
||||||
self._hull = hull
|
self._hull = hull
|
||||||
|
|
||||||
hull_points = self._hull.getPoints()
|
hull_points = self._hull.getPoints()
|
||||||
|
hull_mesh = self.createHullMesh(self._hull.getPoints())
|
||||||
|
if hull_mesh:
|
||||||
|
self.setMeshData(hull_mesh)
|
||||||
|
convex_hull_head = self._node.callDecoration("getConvexHullHead")
|
||||||
|
if convex_hull_head:
|
||||||
|
self.convexHullHeadMesh = self.createHullMesh(convex_hull_head.getPoints())
|
||||||
|
|
||||||
|
def createHullMesh(self, hull_points):
|
||||||
mesh = MeshData()
|
mesh = MeshData()
|
||||||
if len(hull_points) > 3:
|
if len(hull_points) > 3:
|
||||||
center = (hull_points.min(0) + hull_points.max(0)) / 2.0
|
center = (hull_points.min(0) + hull_points.max(0)) / 2.0
|
||||||
mesh.addVertex(center[0], 0.1, center[1])
|
mesh.addVertex(center[0], 0.1, center[1])
|
||||||
else: #Hull has not enough points
|
else:
|
||||||
return
|
return None
|
||||||
for point in hull_points:
|
for point in hull_points:
|
||||||
mesh.addVertex(point[0], 0.1, point[1])
|
mesh.addVertex(point[0], 0.1, point[1])
|
||||||
indices = []
|
indices = []
|
||||||
@ -48,8 +56,7 @@ class ConvexHullNode(SceneNode):
|
|||||||
indices.append([0, mesh.getVertexCount() - 1, 1])
|
indices.append([0, mesh.getVertexCount() - 1, 1])
|
||||||
|
|
||||||
mesh.addIndices(numpy.array(indices, numpy.int32))
|
mesh.addIndices(numpy.array(indices, numpy.int32))
|
||||||
|
return mesh
|
||||||
self.setMeshData(mesh)
|
|
||||||
|
|
||||||
def getWatchedNode(self):
|
def getWatchedNode(self):
|
||||||
return self._node
|
return self._node
|
||||||
@ -61,6 +68,8 @@ class ConvexHullNode(SceneNode):
|
|||||||
if self.getParent():
|
if self.getParent():
|
||||||
self._material.setUniformValue("u_color", self._color)
|
self._material.setUniformValue("u_color", self._color)
|
||||||
renderer.queueNode(self, material = self._material, transparent = True)
|
renderer.queueNode(self, material = self._material, transparent = True)
|
||||||
|
if self.convexHullHeadMesh:
|
||||||
|
renderer.queueNode(self, material = self._material,transparent = True, mesh = self.convexHullHeadMesh)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# Cura is released under the terms of the AGPLv3 or higher.
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
from UM.Scene.Iterator import Iterator
|
from UM.Scene.Iterator import Iterator
|
||||||
|
from UM.Scene.SceneNode import SceneNode
|
||||||
from functools import cmp_to_key
|
from functools import cmp_to_key
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
|
||||||
@ -10,13 +11,16 @@ from UM.Application import Application
|
|||||||
# Take note that the list of nodes can have children (that may or may not contain mesh data)
|
# Take note that the list of nodes can have children (that may or may not contain mesh data)
|
||||||
class OneAtATimeIterator(Iterator.Iterator):
|
class OneAtATimeIterator(Iterator.Iterator):
|
||||||
def __init__(self, scene_node):
|
def __init__(self, scene_node):
|
||||||
super(OneAtATimeIterator, self).__init__(scene_node) # Call super to make multiple inheritence work.
|
super().__init__(scene_node) # Call super to make multiple inheritence work.
|
||||||
self._hit_map = [[]]
|
self._hit_map = [[]]
|
||||||
self._original_node_list = []
|
self._original_node_list = []
|
||||||
|
|
||||||
def _fillStack(self):
|
def _fillStack(self):
|
||||||
node_list = []
|
node_list = []
|
||||||
for node in self._scene_node.getChildren():
|
for node in self._scene_node.getChildren():
|
||||||
|
if not type(node) is SceneNode:
|
||||||
|
continue
|
||||||
|
|
||||||
if node.getBoundingBox().height > Application.getInstance().getMachineManager().getActiveProfile().getSettingValue("gantry_height"):
|
if node.getBoundingBox().height > Application.getInstance().getMachineManager().getActiveProfile().getSettingValue("gantry_height"):
|
||||||
return
|
return
|
||||||
if node.callDecoration("getConvexHull"):
|
if node.callDecoration("getConvexHull"):
|
||||||
|
@ -111,7 +111,11 @@ class PlatformPhysics:
|
|||||||
|
|
||||||
# Get the overlap distance for both convex hulls. If this returns None, there is no intersection.
|
# Get the overlap distance for both convex hulls. If this returns None, there is no intersection.
|
||||||
try:
|
try:
|
||||||
overlap = node.callDecoration("getConvexHull").intersectsPolygon(other_node.callDecoration("getConvexHull"))
|
head_hull = node.callDecoration("getConvexHullHead")
|
||||||
|
if head_hull:
|
||||||
|
overlap = head_hull.intersectsPolygon(other_node.callDecoration("getConvexHull"))
|
||||||
|
else:
|
||||||
|
overlap = node.callDecoration("getConvexHull").intersectsPolygon(other_node.callDecoration("getConvexHull"))
|
||||||
except:
|
except:
|
||||||
overlap = None #It can sometimes occur that the caclulated convex hull has no size, in which case there is no overlap.
|
overlap = None #It can sometimes occur that the caclulated convex hull has no size, in which case there is no overlap.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user