diff options
author | Campbell Barton <ideasman42@gmail.com> | 2006-01-12 06:34:37 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2006-01-12 06:34:37 +0300 |
commit | d498ae51041973d8b75aa45ae02cf7577988200f (patch) | |
tree | 8bf06a506af91d7a372f8dc3065fa333b1c0a68c /release | |
parent | a9e64286a9f875aa71f32ae4a38eb33f59f929dc (diff) |
Fixed a bug in boxpack that archimap not to clear data between uses, and become progressivly slower.
Updated Archimap to set UV's aslists (dont need to convert to tuples anymore)
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/archimap.py | 20 | ||||
-rw-r--r-- | release/scripts/bpymodules/boxpack2d.py | 29 |
2 files changed, 26 insertions, 23 deletions
diff --git a/release/scripts/archimap.py b/release/scripts/archimap.py index aa4733c0286..b1881cf0938 100644 --- a/release/scripts/archimap.py +++ b/release/scripts/archimap.py @@ -443,7 +443,7 @@ def optiRotateUvIsland(faces): # Now write the vectors back to the face UV's i = 0 # count the serialized uv/vectors for f in faces: - f.uv = tuple([uv for uv in uvVecs[i:len(f.v)+i] ]) + f.uv = [uv for uv in uvVecs[i:len(f.v)+i] ] i += len(f.v) @@ -472,7 +472,7 @@ def mergeUvIslands(islandList, islandListArea): while fIdx: fIdx-=1 f = islandList[islandIdx][fIdx] - f.uv = tuple([Vector(uv[0]-minx, uv[1]-miny) for uv in f.uv]) + f.uv = [Vector(uv[0]-minx, uv[1]-miny) for uv in f.uv] totFaceArea += islandListArea[islandIdx][fIdx] # Use Cached area. dont recalculate. islandBoundsArea = w*h efficiency = abs(islandBoundsArea - totFaceArea) @@ -600,7 +600,7 @@ def mergeUvIslands(islandList, islandListArea): targetIsland[0].extend(sourceIsland[0]) while sourceIsland[0]: f = sourceIsland[0].pop() - f.uv = tuple([Vector(uv[0]+boxLeft, uv[1]+boxBottom) for uv in f.uv]) + f.uv = [Vector(uv[0]+boxLeft, uv[1]+boxBottom) for uv in f.uv] # Move edge loop into new and offset. # targetIsland[6].extend(sourceIsland[6]) @@ -832,10 +832,10 @@ def packLinkedUvs(faceGroups, faceGroupsArea, me): if USER_MARGIN: USER_MARGIN_SCALE = 1-(USER_MARGIN*2) for f in islandList[islandIdx]: # Offsetting the UV's so they fit in there packed box, margin - f.uv = tuple([Vector((((uv[0]+xoffset)*xfactor)*USER_MARGIN_SCALE)+USER_MARGIN, (((uv[1]+yoffset)*yfactor)*USER_MARGIN_SCALE)+USER_MARGIN) for uv in f.uv]) + f.uv = [Vector((((uv[0]+xoffset)*xfactor)*USER_MARGIN_SCALE)+USER_MARGIN, (((uv[1]+yoffset)*yfactor)*USER_MARGIN_SCALE)+USER_MARGIN) for uv in f.uv] else: for f in islandList[islandIdx]: # Offsetting the UV's so they fit in there packed box - f.uv = tuple([Vector(((uv[0]+xoffset)*xfactor), ((uv[1]+yoffset)*yfactor)) for uv in f.uv]) + f.uv = [Vector(((uv[0]+xoffset)*xfactor), ((uv[1]+yoffset)*yfactor)) for uv in f.uv] @@ -908,6 +908,12 @@ def main(): else: ob = "Unwrap %i Selected Meshes" + # HACK, loop until mouse is lifted. + ''' + while Window.GetMouseButtons() != 0: + sys.sleep(10) + ''' + if not Draw.PupBlock(ob % len(obList), pup_block): return del ob @@ -970,7 +976,7 @@ def main(): for f in meshFaces: area = faceArea(f) if area <= SMALL_NUM: - f.uv = tuple([Vector(0.0, 0.0)] * len(f.v)) # Assign dummy UV + f.uv = [Vector(0.0, 0.0)] * len(f.v) # Assign dummy UV print 'found zero area face, removing.' else: @@ -1107,7 +1113,7 @@ def main(): # Get the faces UV's from the projected vertex. for f in faceProjectionGroupList[i]: - f.uv = tuple([MatProj * v.co for v in f.v]) + f.uv = [MatProj * v.co for v in f.v] packLinkedUvs(faceProjectionGroupList, faceProjectionGroupListArea, me) diff --git a/release/scripts/bpymodules/boxpack2d.py b/release/scripts/bpymodules/boxpack2d.py index 91424dd44e5..5acfe06e563 100644 --- a/release/scripts/bpymodules/boxpack2d.py +++ b/release/scripts/bpymodules/boxpack2d.py @@ -46,7 +46,7 @@ class vt: # A hack to remember the box() that last intersectec this vert self.intersectCache = ([], [], [], []) -class vertList: +class vertList: def __init__(self, verts=[]): self.verts = verts @@ -59,9 +59,7 @@ class vertList: class box: - global packedVerts def __init__(self, width, height, id=None): - global packedVerts self.id= id @@ -202,7 +200,7 @@ class box: for vIdx in range(4): # (BL,TR,TL,BR): # (BL,TR,TL,BR) / 0,1,2,3 self_v = self.v[vIdx] # shortcut if not (self_v.x == baseVert.x and self_v.y == baseVert.y): - packedVerts.verts.append(self_v) + boxList.packedVerts.verts.append(self_v) else: baseVert.free &= self.v[vIdx].free # make sure the @@ -264,7 +262,9 @@ class box: class boxList: - global packedVerts + # Global vert pool, stores used lists + packedVerts = vertList() # will be vertList() + def __init__(self, boxes): self.boxes = boxes @@ -386,9 +386,6 @@ class boxList: Window.Redraw(1) def pack(self): - global packedVerts - packedVerts = vertList() - self.sortArea() if len(self.boxes) == 0: @@ -401,7 +398,7 @@ class boxList: unpackedboxes = boxList(self.boxes[1:]) # STart with this box - packedVerts.verts.extend(packedboxes.boxes[0].v) + boxList.packedVerts.verts.extend(packedboxes.boxes[0].v) while unpackedboxes.boxes != []: @@ -409,12 +406,12 @@ class boxList: while freeBoxIdx < len(unpackedboxes.boxes): # Sort the verts with this boxes dimensions as a bias, so less poky out bits are made. - packedVerts.sortCorner(unpackedboxes.boxes[freeBoxIdx].width, unpackedboxes.boxes[freeBoxIdx].height) + boxList.packedVerts.sortCorner(unpackedboxes.boxes[freeBoxIdx].width, unpackedboxes.boxes[freeBoxIdx].height) vertIdx = 0 - while vertIdx < len(packedVerts.verts): - baseVert = packedVerts.verts[vertIdx] + while vertIdx < len(boxList.packedVerts.verts): + baseVert = boxList.packedVerts.verts[vertIdx] if baseVert.free != 0: # This will lock the box if its possibel @@ -426,6 +423,9 @@ class boxList: vertIdx +=1 freeBoxIdx +=1 + + boxList.packedVerts.verts = [] # Free the list, so it dosent use ram between runs. + self.width = packedboxes.width self.height = packedboxes.height # All boxes as a list - X/Y/WIDTH/HEIGHT @@ -443,10 +443,6 @@ BLF = 1; TRF = 2; TLF = 4; BRF = 8 quadFlagLs = (BLF,BRF,TLF,TRF) -# Global vert pool, stores used lists -packedVerts = vertList() - - # Packs a list w/h's into box types and places then #Iter times def boxPackIter(boxLs, iter=1, draw=0): iterIdx = 0 @@ -478,4 +474,5 @@ def boxPackIter(boxLs, iter=1, draw=0): bestBoxLs.draw() #print 'best area: %.4f, %.2f%% efficient' % (bestArea, (float(bestBoxLs.boxArea) / (bestArea+0.000001))*100) + return bestBoxLs.width, bestBoxLs.height, bestBoxLs.list()
\ No newline at end of file |