Merge pull request #141 from abosafia/master

meander back to work
pull/258/head
Alain Pelletier 2024-03-07 14:51:25 -04:00 zatwierdzone przez GitHub
commit 0b4927965a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
3 zmienionych plików z 116 dodań i 118 usunięć

Wyświetl plik

@ -92,9 +92,9 @@ class camPathChunk:
# name this as _points so nothing external accesses it directly
# for 3 axes, this is only storage of points. For N axes, here go the sampled points
if len(inpoints)==0:
self._points = np.empty(shape=(0,3))
self.points = np.empty(shape=(0,3))
else:
self._points = np.array(inpoints)
self.points = np.array(inpoints)
self.poly = None # get polygon just in time
self.simppoly = None
if startpoints:
@ -120,30 +120,30 @@ class camPathChunk:
self.zend = 0 #
def update_poly(self):
if len(self._points) > 2:
self.poly = sgeometry.Polygon(self._points[:,0:2])
if len(self.points) > 2:
self.poly = sgeometry.Polygon(self.points[:,0:2])
else:
self.poly = sgeometry.Polygon()
def get_point(self,n):
return self._points[n].tolist()
return self.points[n].tolist()
def get_points(self):
return self._points.tolist()
return self.points.tolist()
def get_points_np(self):
return self._points
return self.points
def set_points(self,points):
self._points=np.array(points)
self.points=np.array(points)
def count(self):
return len(self._points)
return len(self.points)
def copy(self):
nchunk = camPathChunk(inpoints=self._points.copy(), startpoints=self.startpoints, endpoints=self.endpoints, rotations=self.rotations)
nchunk = camPathChunk(inpoints=self.points.copy(), startpoints=self.startpoints, endpoints=self.endpoints, rotations=self.rotations)
nchunk.closed = self.closed
nchunk.children = self.children
nchunk.parents = self.parents
@ -152,7 +152,7 @@ class camPathChunk:
return nchunk
def shift(self, x, y, z):
self._points = self._points + np.array([x,y,z])
self.points = self.points + np.array([x,y,z])
for i, p in enumerate(self.startpoints):
self.startpoints[i] = (p[0] + x, p[1] + y, p[2] + z)
for i, p in enumerate(self.endpoints):
@ -160,43 +160,43 @@ class camPathChunk:
def setZ(self, z,if_bigger=False):
if if_bigger:
self._points[:,2]=z if z>self._points[:,2] else self._points[:,2]
self.points[:,2]=z if z>self.points[:,2] else self.points[:,2]
else:
self._points[:,2]=z
self.points[:,2]=z
def offsetZ(self, z):
self._points[:,2]+=z
self.points[:,2]+=z
def flipX(self, x_centre):
self._points[:,0]= x_centre - self._points[:,0]
self.points[:,0]= x_centre - self.points[:,0]
def isbelowZ(self, z):
return np.any(self._points[:,2]<z)
return np.any(self.points[:,2]<z)
def clampZ(self, z):
np.clip(self._points[:,2],z,None,self._points[:,2])
np.clip(self.points[:,2],z,None,self.points[:,2])
def clampmaxZ(self, z):
np.clip(self._points[:,2],None,z,self._points[:,2])
np.clip(self.points[:,2],None,z,self.points[:,2])
def dist(self, pos, o):
if self.closed:
dist_sq = (pos[0]-self._points[:,0])**2 + (pos[1]-self._points[:,1])**2
dist_sq = (pos[0]-self.points[:,0])**2 + (pos[1]-self.points[:,1])**2
return sqrt(np.min(dist_sq))
else:
if o.movement.type == 'MEANDER':
d1 = dist2d(pos, self._points[0])
d2 = dist2d(pos, self._points[-1])
d1 = dist2d(pos, self.points[0])
d2 = dist2d(pos, self.points[-1])
# if d2<d1:
# ch.points.reverse()
return min(d1, d2)
else:
return dist2d(pos, self._points[0])
return dist2d(pos, self.points[0])
def distStart(self, pos, o):
return dist2d(pos, self._points[0])
return dist2d(pos, self.points[0])
def xyDistanceWithin(self,other,cutoff):
@ -207,7 +207,7 @@ class camPathChunk:
if not self.poly.is_empty and not other.poly.is_empty:
return self.poly.dwithin(other.poly,cutoff)
else:
return _internalXyDistanceTo(self._points,other._points,cutoff)<cutoff
return _internalXyDistanceTo(self.points,other.points,cutoff)<cutoff
# if cutoff is set, then the first distance < cutoff is returned
@ -227,21 +227,21 @@ class camPathChunk:
else: # this is the old method, preferably should be replaced in most cases except parallel
# where this method works probably faster.
# print('warning, sorting will be slow due to bad parenting in parentChildDist')
return _internalXyDistanceTo(self._points,other._points,cutoff)
return _internalXyDistanceTo(self.points,other.points,cutoff)
def adaptdist(self, pos, o):
# reorders chunk so that it starts at the closest point to pos.
if self.closed:
dist_sq = (pos[0]-self._points[:,0])**2 + (pos[1]-self._points[:,1])**2
dist_sq = (pos[0]-self.points[:,0])**2 + (pos[1]-self.points[:,1])**2
point_idx = np.argmin(dist_sq)
new_points = np.concatenate((self._points[point_idx:],self._points[:point_idx+1]))
self._points=new_points
new_points = np.concatenate((self.points[point_idx:],self.points[:point_idx+1]))
self.points=new_points
else:
if o.movement.type == 'MEANDER':
d1 = dist2d(pos, self._points[0])
d2 = dist2d(pos, self._points[-1])
d1 = dist2d(pos, self.points[0])
d2 = dist2d(pos, self.points[-1])
if d2 < d1:
self.points=np.flip(self._points,axis=0)
self.points=np.flip(self.points,axis=0)
def getNextClosest(self, o, pos):
# finds closest chunk that can be milled, when inside sorting hierarchy.
@ -281,31 +281,31 @@ class camPathChunk:
def getLength(self):
# computes length of the chunk - in 3d
point_differences=self._points[0:-1,:] - self._points[1:,:]
point_differences=self.points[0:-1,:] - self.points[1:,:]
distances=np.linalg.norm(point_differences,axis=1)
self.length = np.sum(distances)
def reverse(self):
self._points=np.flip(self._points,axis=0)
self.points=np.flip(self.points,axis=0)
self.startpoints.reverse()
self.endpoints.reverse()
self.rotations.reverse()
def pop(self, index):
print("WARNING: Popping from chunk is slow",self,index)
self._points=np.concatenate((self._points[0:index],self._points[index+1:]),axis=0)
self.points=np.concatenate((self.points[0:index],self.points[index+1:]),axis=0)
if len(self.startpoints) > 0:
self.startpoints.pop(index)
self.endpoints.pop(index)
self.rotations.pop(index)
def dedupePoints(self):
if len(self._points)>1:
keep_points=np.empty(self._points.shape[0],dtype=bool)
if len(self.points)>1:
keep_points=np.empty(self.points.shape[0],dtype=bool)
keep_points[0]=True
diff_points=np.sum((self._points[1:]-self._points[:1])**2,axis=1)
diff_points=np.sum((self.points[1:]-self.points[:1])**2,axis=1)
keep_points[1:]=diff_points>0.000000001
self._points=self._points[keep_points,:]
self.points=self.points[keep_points,:]
def insert(self,at_index,point,startpoint=None, endpoint=None, rotation=None):
@ -313,7 +313,7 @@ class camPathChunk:
def append(self, point, startpoint=None, endpoint=None, rotation=None,at_index=None):
if at_index is None:
self._points=np.concatenate((self._points,np.array([point])))
self.points=np.concatenate((self.points,np.array([point])))
if startpoint is not None:
self.startpoints.append(startpoint)
if endpoint is not None:
@ -321,7 +321,7 @@ class camPathChunk:
if rotation is not None:
self.rotations.append(rotation)
else:
self._points=np.concatenate((self._points[0:at_index],np.array([point]),self._points[at_index:]))
self.points=np.concatenate((self.points[0:at_index],np.array([point]),self.points[at_index:]))
if startpoint is not None:
self.startpoints[at_index:at_index]=[startpoint]
if endpoint is not None:
@ -333,7 +333,7 @@ class camPathChunk:
if len(points)==0:
return
if at_index is None:
self._points=np.concatenate((self._points,np.array(points)))
self.points=np.concatenate((self.points,np.array(points)))
if startpoints is not None:
self.startpoints.extend(startpoints)
if endpoints is not None:
@ -341,7 +341,7 @@ class camPathChunk:
if rotations is not None:
self.rotations.extend(rotations)
else:
self._points=np.concatenate((self._points[0:at_index],np.array(points),self._points[at_index:]))
self.points=np.concatenate((self.points[0:at_index],np.array(points),self.points[at_index:]))
if startpoints is not None:
self.startpoints[at_index:at_index]=startpoints
if endpoints is not None:
@ -351,9 +351,9 @@ class camPathChunk:
def clip_points(self,minx,maxx,miny,maxy):
""" remove any points outside this range """
included_values= (self._points[:,0]>=minx) and ((self._points[:,0]<=maxx)
and (self._points[:,1]>=maxy) and (self._points[:,1]<=maxy))
self._points=self._points[included_values]
included_values= (self.points[:,0]>=minx) and ((self.points[:,0]<=maxx)
and (self.points[:,1]>=maxy) and (self.points[:,1]<=maxy))
self.points=self.points[included_values]
def rampContour(self, zstart, zend, o):
@ -372,14 +372,14 @@ class camPathChunk:
while endpoint is None and not (znew == zend and i == 0): #
# for i,s in enumerate(ch.points):
# print(i, znew, zend, len(ch.points))
s = self._points[i]
s = self.points[i]
if i > 0:
s2 = self._points[i - 1]
s2 = self.points[i - 1]
ltraveled += dist2d(s, s2)
ratio = ltraveled / ramplength
elif rounds > 0 and i == 0:
s2 = self._points[-1]
s2 = self.points[-1]
ltraveled += dist2d(s, s2)
ratio = ltraveled / ramplength
else:
@ -395,7 +395,7 @@ class camPathChunk:
if zend == o.min.z and endpoint is None and self.closed:
endpoint = i + 1
if endpoint == len(self._points):
if endpoint == len(self.points):
endpoint = 0
# print(endpoint,len(ch.points))
# else:
@ -405,7 +405,7 @@ class camPathChunk:
if endpoint is not None:
break
i += 1
if i >= len(self._points):
if i >= len(self.points):
i = 0
rounds += 1
# if not o.use_layers:
@ -414,15 +414,15 @@ class camPathChunk:
i = endpoint
started = False
# print('finaliz')
if i == len(self._points):
if i == len(self.points):
i = 0
while i != endpoint or not started:
started = True
s = self._points[i]
s = self.points[i]
chunk_points.append((s[0], s[1], s[2]))
# print(i,endpoint)
i += 1
if i == len(self._points):
if i == len(self.points):
i = 0
# ramp out
if o.movement.ramp_out and (not o.use_layers or not o.first_down or (o.first_down and endpoint is not None)):
@ -430,13 +430,13 @@ class camPathChunk:
# i=endpoint
while z < o.maxz:
if i == len(self._points):
if i == len(self.points):
i = 0
s1 = self._points[i]
s1 = self.points[i]
i2 = i - 1
if i2 < 0:
i2 = len(self._points) - 1
s2 = self._points[i2]
i2 = len(self.points) - 1
s2 = self.points[i2]
l = dist2d(s1, s2)
znew = z + tan(o.movement.ramp_out_angle) * l
if znew > o.maxz:
@ -452,12 +452,12 @@ class camPathChunk:
i += 1
# TODO: convert to numpy properly
self._points = np.array(chunk_points)
self.points = np.array(chunk_points)
def rampZigZag(self, zstart, zend, o):
# TODO: convert to numpy properly
if zend==None:
zend = self._points[0][2]
zend = self.points[0][2]
chunk_points = []
# print(zstart,zend)
if zend < zstart: # this check here is only for stupid setup,
@ -476,23 +476,23 @@ class camPathChunk:
turns = ceil(zigzaglength / self.length)
ramplength = turns * self.length * 2.0
zigzaglength = self.length
ramppoints = self._points.tolist()
ramppoints = self.points.tolist()
else:
zigzagtraveled = 0.0
haspoints = False
ramppoints = [(self._points[0][0], self._points[0][1], self._points[0][2])]
ramppoints = [(self.points[0][0], self.points[0][1], self.points[0][2])]
i = 1
while not haspoints:
# print(i,zigzaglength,zigzagtraveled)
p1 = ramppoints[-1]
p2 = self._points[i]
p2 = self.points[i]
d = dist2d(p1, p2)
zigzagtraveled += d
if zigzagtraveled >= zigzaglength or i + 1 == len(self._points):
if zigzagtraveled >= zigzaglength or i + 1 == len(self.points):
ratio = 1 - (zigzagtraveled - zigzaglength) / d
if (i + 1 == len(
self._points)): # this condition is for a rare case of combined layers+bridges+ramps..
self.points)): # this condition is for a rare case of combined layers+bridges+ramps..
ratio = 1
v = p1 + ratio * (p2 - p1)
ramppoints.append(v.tolist())
@ -505,7 +505,7 @@ class camPathChunk:
ramppoints.extend(negramppoints[1:])
traveled = 0.0
chunk_points.append((self._points[0][0], self._points[0][1], max(self._points[0][2], zstart)))
chunk_points.append((self.points[0][0], self.points[0][1], max(self.points[0][2], zstart)))
for r in range(turns):
for p in range(0, len(ramppoints)):
p1 = chunk_points[-1]
@ -518,13 +518,13 @@ class camPathChunk:
# below surface in the case of 3d paths
# chunks = setChunksZ([ch],zend)
chunk_points.extend(self._points.tolist())
chunk_points.extend(self.points.tolist())
######################################
# ramp out - this is the same thing, just on the other side..
if o.movement.ramp_out:
zstart = o.maxz
zend = self._points[-1][2]
zend = self.points[-1][2]
if zend < zstart: # again, sometimes a chunk could theoretically end above the starting level.
stepdown = zstart - zend
@ -539,24 +539,24 @@ class camPathChunk:
turns = ceil(zigzaglength / self.length)
ramplength = turns * self.length * 2.0
zigzaglength = self.length
ramppoints = self._points.tolist()
ramppoints = self.points.tolist()
ramppoints.reverse() # revert points here, we go the other way.
else:
zigzagtraveled = 0.0
haspoints = False
ramppoints = [(self._points[-1][0], self._points[-1][1], self._points[-1][2])]
i = len(self._points) - 2
ramppoints = [(self.points[-1][0], self.points[-1][1], self.points[-1][2])]
i = len(self.points) - 2
while not haspoints:
# print(i,zigzaglength,zigzagtraveled)
p1 = ramppoints[-1]
p2 = self._points[i]
p2 = self.points[i]
d = dist2d(p1, p2)
zigzagtraveled += d
if zigzagtraveled >= zigzaglength or i + 1 == len(self._points):
if zigzagtraveled >= zigzaglength or i + 1 == len(self.points):
ratio = 1 - (zigzagtraveled - zigzaglength) / d
if (i + 1 == len(
self._points)): # this condition is for a rare case of
self.points)): # this condition is for a rare case of
# combined layers+bridges+ramps...
ratio = 1
# print((ratio,zigzaglength))
@ -583,26 +583,26 @@ class camPathChunk:
znew = zstart - stepdown * ratio
chunk_points.append((p2[0], p2[1], max(p2[2], znew)))
# max value here is so that it doesn't go below surface in the case of 3d paths
self._points = np.array(chunk_points)
self.points = np.array(chunk_points)
# modify existing path start point
def changePathStart(self, o):
if o.profile_start > 0:
newstart = o.profile_start
chunkamt = len(self._points)
chunkamt = len(self.points)
newstart = newstart % chunkamt
self._points=np.concatenate((self._points[newstart:],self._points[:newstart]))
self.points=np.concatenate((self.points[newstart:],self.points[:newstart]))
def breakPathForLeadinLeadout(self, o):
iradius = o.lead_in
oradius = o.lead_out
if iradius + oradius > 0:
chunkamt = len(self._points)
chunkamt = len(self.points)
for i in range(chunkamt - 1):
apoint = self._points[i]
bpoint = self._points[i + 1]
apoint = self.points[i]
bpoint = self.points[i + 1]
bmax = bpoint[0] - apoint[0]
bmay = bpoint[1] - apoint[1]
segmentLength = math.hypot(bmax, bmay) # find segment length
@ -612,7 +612,7 @@ class camPathChunk:
# add point on the line here
newpointx = (bpoint[0] + apoint[0]) / 2 # average of the two x points to find center
newpointy = (bpoint[1] + apoint[1]) / 2 # average of the two y points to find center
self._points=np.concatenate((self._points[:i+1],np.array([[newpointx, newpointy, apoint[2]]]),self._points[i+1:]))
self.points=np.concatenate((self.points[:i+1],np.array([[newpointx, newpointy, apoint[2]]]),self.points[i+1:]))
def leadContour(self, o):
perimeterDirection = 1 # 1 is clockwise, 0 is CCW
@ -630,8 +630,8 @@ class camPathChunk:
print("path direction is counterclockwise")
iradius = o.lead_in
oradius = o.lead_out
start = self._points[0]
nextp = self._points[1]
start = self.points[0]
nextp = self.points[1]
rpoint = Rotate_pbyp(start, nextp, math.pi / 2)
dx = rpoint[0] - start[0]
dy = rpoint[1] - start[1]
@ -651,9 +651,9 @@ class camPathChunk:
chunk_points.insert(0, arc_p)
# glue rest of the path to the arc
chunk_points.extend(self._points.tolist())
# for i in range(len(self._points)):
# chunk_points.append(self._points[i])
chunk_points.extend(self.points.tolist())
# for i in range(len(self.points)):
# chunk_points.append(self.points[i])
# add lead out arc to the end
if round(o.lead_in, 6) > 0.0:
@ -662,7 +662,7 @@ class camPathChunk:
arc_p = Rotate_pbyp(arc_c, start, iangle)
chunk_points.append(arc_p)
self._points = np.array(chunk_points)
self.points = np.array(chunk_points)
def chunksCoherency(chunks):
@ -673,14 +673,14 @@ def chunksCoherency(chunks):
# but also means that some parts detected by cavity algorithm won't be milled
nchunks = []
for chunk in chunks:
if len(chunk._points) > 2:
if len(chunk.points) > 2:
nchunk = camPathChunkBuilder()
# doesn't check for 1 point chunks here, they shouldn't get here at all.
lastvec = Vector(chunk._points[1]) - Vector(chunk._points[0])
for i in range(0, len(chunk._points) - 1):
nchunk.points.append(chunk._points[i])
vec = Vector(chunk._points[i + 1]) - Vector(chunk._points[i])
lastvec = Vector(chunk.points[1]) - Vector(chunk.points[0])
for i in range(0, len(chunk.points) - 1):
nchunk.points.append(chunk.points[i])
vec = Vector(chunk.points[i + 1]) - Vector(chunk.points[i])
angle = vec.angle(lastvec, vec)
# print(angle,i)
if angle > 1.07: # 60 degrees is maximum toleration for pencil paths.
@ -689,7 +689,7 @@ def chunksCoherency(chunks):
nchunk = camPathChunkBuilder()
lastvec = vec
if len(nchunk_points) > 4: # this is a testing threshold
nchunk._points=np.array(nchunk_points)
nchunk.points=np.array(nchunk_points)
nchunks.append(nchunk)
return nchunks
@ -765,8 +765,8 @@ def _optimize_internal(points,keep_points,e,protect_vertical,protect_vertical_li
def optimizeChunk(chunk, operation):
if len(chunk._points) > 2:
points = chunk._points
if len(chunk.points) > 2:
points = chunk.points
naxispoints = False
if len(chunk.startpoints) > 0:
startpoints = chunk.startpoints
@ -783,7 +783,7 @@ def optimizeChunk(chunk, operation):
_optimize_internal(points,keep_points,operation.optimisation.optimize_threshold * 0.000001,protect_vertical,operation.movement.protect_vertical_limit)
# now do numpy select by boolean array
chunk._points=points[keep_points]
chunk.points=points[keep_points]
if naxispoints:
# list comprehension so we don't have to do tons of appends
chunk.startpoints=[chunk.startpoints[i] for i,b in enumerate(keep_points) if b==True]
@ -802,7 +802,7 @@ def limitChunks(chunks, o,
nch = camPathChunkBuilder()
nch1 = None
closed = True
for s in ch._points:
for s in ch.points:
sampled = o.ambient.contains(sgeometry.Point(s[0], s[1]))
if not sampled and len(nch.points) > 0:
nch.closed = False
@ -814,11 +814,11 @@ def limitChunks(chunks, o,
elif sampled:
nch.points.append(s)
prevsampled = sampled
if len(nch.points) > 2 and closed and ch.closed and np.array_equal(ch._points[0] ,ch._points[-1]):
if len(nch.points) > 2 and closed and ch.closed and np.array_equal(ch.points[0] ,ch.points[-1]):
nch.closed = True
elif ch.closed and nch1 is not None and len(nch.points) > 1 and np.array_equal(nch.points[-1], nch1._points[0]):
elif ch.closed and nch1 is not None and len(nch.points) > 1 and np.array_equal(nch.points[-1], nch1.points[0]):
# here adds beginning of closed chunk to the end, if the chunks were split during limiting
nch.points.extend(nch1._points.tolist())
nch.points.extend(nch1.points.tolist())
nchunks.remove(nch1)
print('joining stuff')
if len(nch.points) > 0:
@ -878,9 +878,9 @@ def parentChild(parents, children, o):
def chunksToShapely(chunks): # this does more cleve chunks to Poly with hierarchies... ;)
# print ('analyzing paths')
for ch in chunks: # first convert chunk to poly
if len(ch._points) > 2:
if len(ch.points) > 2:
# pchunk=[]
ch.poly = sgeometry.Polygon(ch._points[:,0:2])
ch.poly = sgeometry.Polygon(ch.points[:,0:2])
if not ch.poly.is_valid:
ch.poly = sgeometry.Polygon()
else:
@ -924,7 +924,7 @@ def chunksToShapely(chunks): # this does more cleve chunks to Poly with hierarc
tolerance = 0.0000003
newPoints = []
for pt in ch._points:
for pt in ch.points:
toleranceXok = True
toleranceYok = True
if lastPt is not None:
@ -950,8 +950,8 @@ def chunksToShapely(chunks): # this does more cleve chunks to Poly with hierarc
if not toleranceXok and not toleranceYok:
newPoints.pop()
ch._points = np.array(newPoints)
ch.poly = sgeometry.Polygon(ch._points)
ch.points = np.array(newPoints)
ch.poly = sgeometry.Polygon(ch.points)
try:
ch.parents[0].poly = ch.parents[0].poly.difference(ch.poly)
@ -963,7 +963,7 @@ def chunksToShapely(chunks): # this does more cleve chunks to Poly with hierarc
tolerance = 0.0000003
newPoints = []
for pt in ch.parents[0]._points:
for pt in ch.parents[0].points:
toleranceXok = True
toleranceYok = True
# print( '{0:.9f}, {0:.9f}, {0:.9f}'.format(pt[0], pt[1], pt[2]) )
@ -992,8 +992,8 @@ def chunksToShapely(chunks): # this does more cleve chunks to Poly with hierarc
newPoints.pop()
# print('starting and ending points too close, removing ending point')
ch.parents[0]._points = np.array(newPoints)
ch.parents[0].poly = sgeometry.Polygon(ch.parents[0]._points)
ch.parents[0].points = np.array(newPoints)
ch.parents[0].poly = sgeometry.Polygon(ch.parents[0].points)
ch.parents[0].poly = ch.parents[0].poly.difference(
ch.poly) # sgeometry.Polygon( ch.parents[0].poly, ch.poly)
@ -1162,7 +1162,7 @@ def shapelyToChunks(p, zlevel): #
def chunkToShapely(chunk):
p = spolygon.Polygon(chunk._points)
p = spolygon.Polygon(chunk.points)
return p
@ -1171,9 +1171,9 @@ def chunksRefine(chunks, o):
for ch in chunks:
# print('before',len(ch))
newchunk = []
v2 = Vector(ch._points[0])
v2 = Vector(ch.points[0])
# print(ch.points)
for s in ch._points:
for s in ch.points:
v1 = Vector(s)
v = v1 - v2
@ -1194,7 +1194,7 @@ def chunksRefine(chunks, o):
newchunk.append(s)
v2 = v1
ch._points = np.array(newchunk)
ch.points = np.array(newchunk)
return chunks
@ -1203,9 +1203,9 @@ def chunksRefineThreshold(chunks, distance, limitdistance):
"""add extra points in between for chunks. For medial axis strategy only !"""
for ch in chunks:
newchunk = []
v2 = Vector(ch._points[0])
v2 = Vector(ch.points[0])
for s in ch._points:
for s in ch.points:
v1 = Vector(s)
v = v1 - v2
@ -1234,6 +1234,6 @@ def chunksRefineThreshold(chunks, distance, limitdistance):
newchunk.append(s)
v2 = v1
ch._points = np.array(newchunk)
ch.points = np.array(newchunk)
return chunks

Wyświetl plik

@ -266,9 +266,7 @@ def prepareBulletCollision(o):
if active_collection in collisionob.users_collection:
active_collection.objects.unlink(collisionob)
# call this twice or else blender doesn't update physics. No idea why, but just leave
# this double call to avoid bad things
getCutterBullet(o)
getCutterBullet(o)
# machine objects scaling up to simulation scale

Wyświetl plik

@ -110,7 +110,7 @@ async def oclResampleChunks(operation, chunks_to_resample,use_cached_mesh):
tmp_chunks.append(camPathChunk(inpoints=[]))
for chunk, i_start, i_length in chunks_to_resample:
tmp_chunks[0].extend(chunk.get_points_np()[i_start:i_start+i_length])
print(i_start,i_length,len(tmp_chunks[0]._points))
print(i_start,i_length,len(tmp_chunks[0].points))
samples = await ocl_sample(operation, tmp_chunks,use_cached_mesh=use_cached_mesh)