for b in initialList:
self._hitMap[a][b] = self._checkHit(a, b)
+ #Check if we have 2 files that overlap so that they can never be printed one at a time.
+ for a in initialList:
+ if self._hitMap[a][b] and self._hitMap[b][a]:
+ self.order = None
+ return
+
initialList.sort(self._objIdxCmp)
n = 0
self.pushFree()
def pushFree(self):
- return
n = 1000
while self._pushFree():
n -= 1
def _pushFree(self):
for a in self._objectList:
for b in self._objectList:
- if not self._checkHit(a, b):
+ if a == b:
+ continue
+ v = polygon.polygonCollisionPushVector(a._boundaryHull + a.getPosition(), b._boundaryHull + b.getPosition())
+ if type(v) is bool:
continue
- posDiff = a.getPosition() - b.getPosition()
- if posDiff[0] == 0.0 and posDiff[1] == 0.0:
- posDiff[1] = 1.0
- if abs(posDiff[0]) > abs(posDiff[1]):
- axis = 0
- else:
- axis = 1
- aPos = a.getPosition()
- bPos = b.getPosition()
- center = (aPos[axis] + bPos[axis]) / 2
- distance = (a.getSize()[axis] + b.getSize()[axis]) / 2 + 0.1 + self._sizeOffsets[axis] + self._headSizeOffsets[axis]
- if posDiff[axis] < 0:
- distance = -distance
- aPos[axis] = center + distance / 2
- bPos[axis] = center - distance / 2
- a.setPosition(aPos)
- b.setPosition(bPos)
+ a.setPosition(a.getPosition() + v / 2.0)
+ b.setPosition(b.getPosition() - v / 2.0)
return True
return False
if aMax < bMin:
return False
return True
+
+def polygonCollisionPushVector(polyA, polyB):
+ retSize = 10000000.0
+ ret = False
+ for n in xrange(0, len(polyA)):
+ p0 = polyA[n-1]
+ p1 = polyA[n]
+ normal = (p1 - p0)[::-1]
+ normal[1] = -normal[1]
+ normal /= numpy.linalg.norm(normal)
+ aMin, aMax = projectPoly(polyA, normal)
+ bMin, bMax = projectPoly(polyB, normal)
+ if aMin > bMax:
+ return False
+ if bMin > aMax:
+ return False
+ size = min(bMax, bMax) - max(aMin, bMin)
+ if size < retSize:
+ ret = normal * (size + 0.1)
+ retSize = size
+ for n in xrange(0, len(polyB)):
+ p0 = polyB[n-1]
+ p1 = polyB[n]
+ normal = (p1 - p0)[::-1]
+ normal[1] = -normal[1]
+ normal /= numpy.linalg.norm(normal)
+ aMin, aMax = projectPoly(polyA, normal)
+ bMin, bMax = projectPoly(polyB, normal)
+ if aMin > bMax:
+ return False
+ if aMax < bMin:
+ return False
+ size = min(bMax, bMax) - max(aMin, bMin)
+ if size < retSize:
+ ret = normal * -(size + 0.1)
+ retSize = size
+ #ret = ret[::-1]
+ #ret[1] = -ret[1]
+ return ret