From a00f1cb59a6660d15389bf8d829849a9fcb44d72 Mon Sep 17 00:00:00 2001 From: "Stephen M. McQuay" Date: Wed, 9 May 2012 23:20:23 -0600 Subject: [PATCH] cc: update old verts --- surf/subd/cc.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/surf/subd/cc.py b/surf/subd/cc.py index e6dc6f9..6df68e3 100644 --- a/surf/subd/cc.py +++ b/surf/subd/cc.py @@ -33,11 +33,11 @@ def refine(mesh): e_vert_offset = len(new_vertices) # For each edge, add an edge point. - for cur_edge_id, cur_edge in enumerate(mesh.edges): + for old_edge_id, old_edge in enumerate(mesh.edges): # make mapping from edge -> new_face_vert for later - face_ids_for_edge = mesh.faces_for_edge[cur_edge_id] + face_ids_for_edge = mesh.faces_for_edge[old_edge_id] for fid in face_ids_for_edge: - edge_vids_for[fid].append(cur_edge_id) + edge_vids_for[fid].append(old_edge_id) tmp_verts = [] @@ -46,7 +46,7 @@ def refine(mesh): tmp_verts.extend([new_vertices[f + f_vert_offset] for f in face_ids_for_edge]) # ... and its two original endpoints. - tmp_verts.extend([mesh.vertices[vid] for vid in cur_edge]) + tmp_verts.extend([mesh.vertices[vid] for vid in old_edge]) # centroid == average new_vertices.append(centroid(tmp_verts)) @@ -80,9 +80,9 @@ def refine(mesh): R = centroid(e_verts) # where each edge midpoint is the average of its two endpoint vertices. - # Move each original point to the point (or add it to new_verts) + # **Move** each original point to the point (or add it to new_verts) new_vertex_point = (F + 2 * R + (len(edges) - 3) * new_vertices[new_vid]) / len(edges) - new_vertices.append(new_vertex_point) + new_vertices[new_vid] = new_vertex_point return PolygonMesh(vertices=new_vertices, edges=new_edges, faces=new_faces) @@ -94,4 +94,4 @@ if __name__ == '__main__': cube = json.load(open('blender/samples/cube.json', 'r')) p = PolygonMesh(**cube) q = refine(p) - print q + print json.dumps({'vertices': [list(v) for v in q.vertices]})