rename and update to archimap.

Mainly syntax optimizations and cleaned up parts.
This commit is contained in:
Campbell Barton 2006-07-12 09:55:09 +00:00
parent fec1ebaca3
commit 6d972220ac

@ -174,28 +174,32 @@ def boundsIsland(faces):
# print len(faces), minx, maxx, miny , maxy # print len(faces), minx, maxx, miny , maxy
for f in faces: for f in faces:
for uv in f.uv: for uv in f.uv:
minx = min(minx, uv[0]) x= uv.x
maxx = max(maxx, uv[0]) y= uv.y
if x<minx: minx= x
miny = min(miny, uv[1]) if y<miny: miny= y
maxy = max(maxy, uv[1]) if x>maxx: maxx= x
if y>maxy: maxy= y
return minx, miny, maxx, maxy return minx, miny, maxx, maxy
"""
def boundsEdgeLoop(edges): def boundsEdgeLoop(edges):
minx = maxx = edges[0][0] # Set initial bounds. minx = maxx = edges[0][0] # Set initial bounds.
miny = maxy = edges[0][1] miny = maxy = edges[0][1]
# print len(faces), minx, maxx, miny , maxy # print len(faces), minx, maxx, miny , maxy
for ed in edges: for ed in edges:
for pt in ed: for pt in ed:
minx = min(minx, pt[0]) print 'ass'
maxx = max(maxx, pt[0]) x= pt[0]
y= pt[1]
miny = min(miny, pt[1]) if x<minx: x= minx
maxy = max(maxy, pt[1]) if y<miny: y= miny
if x>maxx: x= maxx
if y>maxy: y= maxy
return minx, miny, maxx, maxy return minx, miny, maxx, maxy
"""
# Turns the islands into a list of unpordered edges (Non internal) # Turns the islands into a list of unpordered edges (Non internal)
# Onlt for UV's # Onlt for UV's
@ -329,12 +333,12 @@ def testNewVecLs2DRotIsBetter(vecs, mat=-1, bestAreaSoFar = -1):
# Do this allong the way # Do this allong the way
if mat != -1: if mat != -1:
v = vecs[i] = v*mat v = vecs[i] = v*mat
x= v.x
minx = min(minx, v.x) y= v.y
maxx = max(maxx, v.x) if x<minx: minx= x
if y<miny: miny= y
miny = min(miny, v.y) if x>maxx: maxx= x
maxy = max(maxy, v.y) if y>maxy: maxy= y
# Spesific to this algo, bail out if we get bigger then the current area # Spesific to this algo, bail out if we get bigger then the current area
if bestAreaSoFar != -1 and (maxx-minx) * (maxy-miny) > bestAreaSoFar: if bestAreaSoFar != -1 and (maxx-minx) * (maxy-miny) > bestAreaSoFar:
@ -457,12 +461,11 @@ def mergeUvIslands(islandList, islandListArea):
w, h = maxx-minx, maxy-miny w, h = maxx-minx, maxy-miny
totFaceArea = 0 totFaceArea = 0
fIdx = len(islandList[islandIdx])
while fIdx: for fIdx, f in enumerate(islandList[islandIdx]):
fIdx-=1
f = islandList[islandIdx][fIdx]
f.uv = [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. totFaceArea += islandListArea[islandIdx][fIdx] # Use Cached area. dont recalculate.
islandBoundsArea = w*h islandBoundsArea = w*h
efficiency = abs(islandBoundsArea - totFaceArea) efficiency = abs(islandBoundsArea - totFaceArea)
@ -829,14 +832,12 @@ def packLinkedUvs(faceGroups, faceGroupsArea, me):
def VectoMat(vec): def VectoMat(vec):
a3 = Vector(vec) # copy the vector
a3 = Vector(vec)
a3.normalize() a3.normalize()
up = Vector([0,0,1]) up = Vector(0,0,1)
if abs(DotVecs(a3, up)) == 1.0: if abs(DotVecs(a3, up)) == 1.0:
up = Vector([0,1,0]) up = Vector(0,1,0)
a1 = CrossVecs(a3, up) a1 = CrossVecs(a3, up)
a1.normalize() a1.normalize()
@ -931,15 +932,10 @@ def main():
SELECT_FLAG = Mesh.FaceFlags['SELECT'] SELECT_FLAG = Mesh.FaceFlags['SELECT']
time1 = sys.time() time1 = sys.time()
for ob in obList: for ob in obList:
# Only meshes
if ob.getType() != 'Mesh':
continue
me = ob.getData(mesh=1) me = ob.getData(mesh=1)
if not me.faceUV: # Mesh has no UV Coords, dont bother. if not me.faceUV: # Mesh has no UV Coords, dont bother.
continue me.faceUV= True
if USER_ONLY_SELECTED_FACES: if USER_ONLY_SELECTED_FACES:
meshFaces = [f for f in me.faces if f.flag & SELECT_FLAG] meshFaces = [f for f in me.faces if f.flag & SELECT_FLAG]
@ -971,7 +967,7 @@ def main():
else: else:
# Store all here # Store all here
faceListProps.append( [f, area, Vector(f.no)] ) faceListProps.append( [f, area, f.no] )
del meshFaces del meshFaces
@ -1037,7 +1033,7 @@ def main():
# Now weight the vector to all its faces, will give a more direct projection # Now weight the vector to all its faces, will give a more direct projection
# if the face its self was not representive of the normal from surrounding faces. # if the face its self was not representive of the normal from surrounding faces.
averageVec = Vector([0,0,0]) averageVec = Vector(0,0,0)
for fprop in newProjectFacePropList: for fprop in newProjectFacePropList:
averageVec += (fprop[2] * fprop[1]) # / len(newProjectFacePropList) averageVec += (fprop[2] * fprop[1]) # / len(newProjectFacePropList)