Fixes to grouping.

Fixes Ultimaker/Cura#377
This commit is contained in:
Jaime van Kessel 2015-09-14 13:25:03 +02:00
parent 91a5439f88
commit 4d6528e90d
2 changed files with 25 additions and 14 deletions

View file

@ -47,6 +47,7 @@ import sys
import os import os
import os.path import os.path
import numpy import numpy
import copy
numpy.seterr(all="ignore") numpy.seterr(all="ignore")
class CuraApplication(QtApplication): class CuraApplication(QtApplication):
@ -270,6 +271,14 @@ class CuraApplication(QtApplication):
if node: if node:
op = GroupedOperation() op = GroupedOperation()
for i in range(count): for i in range(count):
if node.getParent() and node.getParent().callDecoration("isGroup"):
new_node = copy.deepcopy(node.getParent()) #Copy the group node.
new_node.callDecoration("setConvexHull",None)
op.addOperation(AddSceneNodeOperation(new_node,node.getParent().getParent()))
pass
else:
new_node = SceneNode() new_node = SceneNode()
new_node.setMeshData(node.getMeshData()) new_node.setMeshData(node.getMeshData())
@ -450,7 +459,8 @@ class CuraApplication(QtApplication):
for node in Selection.getAllSelectedObjects(): for node in Selection.getAllSelectedObjects():
node.setParent(group_node) node.setParent(group_node)
group_node.setCenterPosition(group_node.getBoundingBox().center) group_node.setCenterPosition(group_node.getBoundingBox().center)
group_node.translate(Vector(0,group_node.getBoundingBox().center.y,0)) #group_node.translate(Vector(0,group_node.getBoundingBox().center.y,0))
group_node.translate(group_node.getBoundingBox().center)
for node in group_node.getChildren(): for node in group_node.getChildren():
Selection.remove(node) Selection.remove(node)

View file

@ -98,9 +98,10 @@ class PlatformPhysics:
continue continue
# Ignore colissions within a group # Ignore colissions within a group
if other_node.getParent().callDecoration("isGroup") is not None: if other_node.getParent().callDecoration("isGroup") is not None or node.getParent().callDecoration("isGroup") is not None:
if node.getParent().callDecoration("isGroup") is other_node.getParent().callDecoration("isGroup"):
continue continue
#if node.getParent().callDecoration("isGroup") is other_node.getParent().callDecoration("isGroup"):
# continue
# Ignore nodes that do not have the right properties set. # Ignore nodes that do not have the right properties set.
if not other_node.callDecoration("getConvexHull") or not other_node.getBoundingBox(): if not other_node.callDecoration("getConvexHull") or not other_node.getBoundingBox():
@ -126,9 +127,9 @@ class PlatformPhysics:
if overlap is None: if overlap is None:
continue continue
print(overlap)
move_vector.setX(overlap[0] * 1.1) move_vector.setX(overlap[0] * 1.01)
move_vector.setZ(overlap[1] * 1.1) move_vector.setZ(overlap[1] * 1.01)
convex_hull = node.callDecoration("getConvexHull") convex_hull = node.callDecoration("getConvexHull")
if convex_hull: if convex_hull:
if not convex_hull.isValid(): if not convex_hull.isValid():