diff options
author | Campbell Barton <ideasman42@gmail.com> | 2006-02-07 06:58:57 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2006-02-07 06:58:57 +0300 |
commit | 02a9f2cf3012962aeaa944a761122f11d3815e72 (patch) | |
tree | 6c8846292a74408e04fe8bf4dbcbb877db3ab907 /release | |
parent | caf383a3a826c0f49635ddca51a653a903a2e490 (diff) |
works with free verts and a bit faster
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/uv_relax.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/release/scripts/uv_relax.py b/release/scripts/uv_relax.py index 2db0104e308..f3b6143b7ce 100644 --- a/release/scripts/uv_relax.py +++ b/release/scripts/uv_relax.py @@ -75,37 +75,37 @@ def main(): relaxEdgeDict= {} relaxVertList= [relaxVert(v) for v in me.verts] - tempVertUVList = [list() for v in me.verts] + tempVertUVList = [Vector(0,0,0) for v in me.verts] # Z is an int for scaling the first 2 values. for f in me.faces: for i in xrange(len(f.v)): v1,v2= f.v[i], f.v[i-1] key= sortPair(v1.index, v2.index) + rv1= relaxVertList[v1.index] + rv2= relaxVertList[v2.index] try: # Do nothing if we exist. tmpEdge= relaxEdgeDict[key] except: - tmpEdge= relaxEdgeDict[key]= relaxEdge(relaxVertList[key[0]],relaxVertList[key[1]]) + tmpEdge= relaxEdgeDict[key]= relaxEdge(rv1,rv2) # Add the edges to the face. - rv1= relaxVertList[v1.index] - rv2= relaxVertList[v2.index] rv1.edges.append(tmpEdge) rv2.edges.append(tmpEdge) - + # Will get to all v1's no need to add both per edge. rv1.bfaces.append( (f, i) ) - tempVertUVList[v1.index].append(f.uv[i]) + tempVertUVList[v1.index].x += f.uv[i].x + tempVertUVList[v1.index].y += f.uv[i].y + tempVertUVList[v1.index].z+=1 if f.uvSel[i]: rv1.sel= True # Now average UV's into the relaxVerts for i, rv in enumerate(relaxVertList): - tempUV = Vector(0,0) - - for uv in tempVertUVList[i]: - tempUV+= uv - tempUV= tempUV * (1/float(len(tempVertUVList[i]))) - rv.uv= tempUV + if tempVertUVList[i].z > 0: + newUV= tempVertUVList[i] * (1/tempVertUVList[i].z) + rv.uv.x= newUV.x + rv.uv.y= newUV.y del tempVertUVList # Loop while the button is held, so clicking on a menu wont immediatly exit. |