diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-19 23:12:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-19 23:12:36 +0400 |
commit | b2956ecd00c37836b72637bcda0fbb2c05f35888 (patch) | |
tree | 73b975d85262b9f3dc31b0ac611b3e266a8d0f14 /release/scripts | |
parent | afc56a0b10b52d2c8bdfd44257624d776db72f79 (diff) | |
parent | dc68210c7e432cf313721541e639426dd94f2dfb (diff) |
BMesh Merge
===========
initial merge from BMesh branch,
this replaces the existing mesh format and editmode data structures, for more info see:
http://wiki.blender.org/index.php/Dev:2.6/Source/Modeling/BMesh
this is the work of quite a few developers over the years.
Key Contributors
================
* Geoffrey Bantle (aka) Briggs, original author.
* Joe Eager (aka) joeedh
More recently
* Howard Trickey
* Ender79 aka Ender79 :)
What to Expect
==============
In general blender shouldnt crash on files or totally fail to load scenes,
painting tools etc have been tested to work.
* its quite easy to make the tesselator fail (show holes, missing faces), with non planer ngons.
* most modifiers are working fine but a few had to be re-written - bevel, array - array is much slower, bevel will probably be changed to match trunk soon.
* NavMesh BGE feature isn't functional yet.
* Some UV sticth tools still need porting.
* hair doesnt work right on ngons yet.
* many python scripts will break.
* a python api to BMesh needs to be written still.
(for todo's in code do a searh for BMESH_TODO)
Diffstat (limited to 'release/scripts')
6 files changed, 76 insertions, 58 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 088e239e9a5..c5dc07e493a 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -373,7 +373,8 @@ class Mesh(bpy_types.ID): """ self.vertices.add(len(vertices)) self.edges.add(len(edges)) - self.faces.add(len(faces)) + self.loops.add(sum((len(f) for f in faces))) + self.polygons.add(len(faces)) vertices_flat = [f for v in vertices for f in v] self.vertices.foreach_set("co", vertices_flat) @@ -383,19 +384,15 @@ class Mesh(bpy_types.ID): self.edges.foreach_set("vertices", edges_flat) del edges_flat - def treat_face(f): - if len(f) == 3: - if f[2] == 0: - return f[2], f[0], f[1], 0 - else: - return f[0], f[1], f[2], 0 - elif f[2] == 0 or f[3] == 0: - return f[2], f[3], f[0], f[1] - return f - - faces_flat = [v for f in faces for v in treat_face(f)] - self.faces.foreach_set("vertices_raw", faces_flat) - del faces_flat + # this is different in bmesh + loop_index = 0 + for i, p in enumerate(self.polygons): + f = faces[i] + loop_len = len(f) + p.loop_start = loop_index + p.loop_total = loop_len + p.vertices = f + loop_index += loop_len @property def edge_keys(self): @@ -445,6 +442,20 @@ class MeshFace(StructRNA): ord_ind(verts[3], verts[0]), ) +class MeshPolygon(StructRNA): + __slots__ = () + + @property + def edge_keys(self): + verts = self.vertices[:] + vlen = len(self.vertices) + return [ord_ind(verts[i], verts[(i+1) % vlen]) for i in range(vlen)] + + @property + def loops(self): + start = self.loop_start + end = start + self.loop_total + return range(start, end) class Text(bpy_types.ID): __slots__ = () diff --git a/release/scripts/startup/bl_operators/uvcalc_follow_active.py b/release/scripts/startup/bl_operators/uvcalc_follow_active.py index 748255671dd..0df86a3869e 100644 --- a/release/scripts/startup/bl_operators/uvcalc_follow_active.py +++ b/release/scripts/startup/bl_operators/uvcalc_follow_active.py @@ -30,6 +30,7 @@ def extend(obj, operator, EXTEND_MODE): me = obj.data me_verts = me.vertices + # script will fail without UVs if not me.uv_textures: me.uv_textures.new() @@ -52,17 +53,15 @@ def extend(obj, operator, EXTEND_MODE): ''' def face_edge_vs(vi): - # assume a quad - return [(vi[0], vi[1]), (vi[1], vi[2]), (vi[2], vi[3]), (vi[3], vi[0])] + vlen = len(vi) + return [(vi[i], vi[(i+1) % vlen]) for i in range(vlen)] vidx_source = face_source.vertices vidx_target = face_target.vertices - faceUVsource = me.uv_textures.active.data[face_source.index] - uvs_source = [faceUVsource.uv1, faceUVsource.uv2, faceUVsource.uv3, faceUVsource.uv4] - - faceUVtarget = me.uv_textures.active.data[face_target.index] - uvs_target = [faceUVtarget.uv1, faceUVtarget.uv2, faceUVtarget.uv3, faceUVtarget.uv4] + uv_layer = me.uv_loop_layers.active.data + uvs_source = [uv_layer[i].uv for i in face_source.loops] + uvs_target = [uv_layer[i].uv for i in face_target.loops] # vertex index is the key, uv is the value @@ -135,15 +134,12 @@ def extend(obj, operator, EXTEND_MODE): uvs_vhash_target[edgepair_outer_target[iB]][:] = uvs_vhash_source[edgepair_inner_source[0]] + (uvs_vhash_source[edgepair_inner_source[0]] - uvs_vhash_source[edgepair_outer_source[1]]) uvs_vhash_target[edgepair_outer_target[iA]][:] = uvs_vhash_source[edgepair_inner_source[1]] + (uvs_vhash_source[edgepair_inner_source[1]] - uvs_vhash_source[edgepair_outer_source[0]]) - if not me.uv_textures: - me.uv_textures.new() - - face_act = me.faces.active + face_act = me.polygons.active if face_act == -1: operator.report({'ERROR'}, "No active face") return - face_sel = [f for f in me.faces if len(f.vertices) == 4 and f.select] + face_sel = [f for f in me.polygons if len(f.vertices) == 4 and f.select] face_act_local_index = -1 for i, f in enumerate(face_sel): diff --git a/release/scripts/startup/bl_operators/uvcalc_lightmap.py b/release/scripts/startup/bl_operators/uvcalc_lightmap.py index 3159466c5ca..c7e35943e35 100644 --- a/release/scripts/startup/bl_operators/uvcalc_lightmap.py +++ b/release/scripts/startup/bl_operators/uvcalc_lightmap.py @@ -88,8 +88,8 @@ class prettyface(object): self.children = [] else: # blender face - # self.uv = data.uv - self.uv = data.id_data.uv_textures.active.data[data.index].uv # XXX25 + uv_layer = data.id_data.uv_loop_layers.active.data + self.uv = [uv_layer[i].uv for i in data.loops] # cos = [v.co for v in data] cos = [data.id_data.vertices[v].co for v in data.vertices] # XXX25 @@ -158,7 +158,8 @@ class prettyface(object): I = [i for a, i in angles_co] #~ fuv = f.uv - fuv = f.id_data.uv_textures.active.data[f.index].uv # XXX25 + uv_layer = f.id_data.uv_loop_layers.active.data + fuv = [uv_layer[i].uv for i in f.loops] # XXX25 if self.rot: fuv[I[2]] = p1 @@ -219,15 +220,10 @@ def lightmap_uvpack(meshes, face_groups = [] for me in meshes: - # Add face UV if it does not exist. - # All new faces are selected. - if not me.uv_textures: - me.uv_textures.new() - if PREF_SEL_ONLY: - faces = [f for f in me.faces if f.select] + faces = [f for f in me.polygons if f.select] else: - faces = me.faces[:] + faces = me.polygons[:] if PREF_PACK_IN_ONE: face_groups[0].extend(faces) @@ -237,6 +233,11 @@ def lightmap_uvpack(meshes, if PREF_NEW_UVLAYER: me.uv_textures.new() + # Add face UV if it does not exist. + # All new faces are selected. + if not me.uv_textures: + me.uv_textures.new() + for face_sel in face_groups: print("\nStarting unwrap") @@ -504,7 +505,7 @@ def lightmap_uvpack(meshes, for f in face_sel: # f.image = image - f.id_data.uv_textures.active.data[f.index].image = image # XXX25 + f.id_data.uv_loop_layers.active.data[f.index].image = image # XXX25 for me in meshes: me.update() @@ -528,7 +529,7 @@ def unwrap(operator, context, **kwargs): if obj and obj.type == 'MESH': meshes = [obj.data] else: - meshes = list({me for obj in context.selected_objects if obj.type == 'MESH' for me in (obj.data,) if me.faces and me.library is None}) + meshes = list({me for obj in context.selected_objects if obj.type == 'MESH' for me in (obj.data,) if me.polygons and me.library is None}) if not meshes: operator.report({'ERROR'}, "No mesh object") diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index 622d19a0cfa..1464b83ab95 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -757,12 +757,9 @@ def VectoQuat(vec): class thickface(object): __slost__= "v", "uv", "no", "area", "edge_keys" - def __init__(self, face, uvface, mesh_verts): + def __init__(self, face, uv_layer, mesh_verts): self.v = [mesh_verts[i] for i in face.vertices] - if len(self.v)==4: - self.uv = uvface.uv1, uvface.uv2, uvface.uv3, uvface.uv4 - else: - self.uv = uvface.uv1, uvface.uv2, uvface.uv3 + self.uv = [uv_layer[i].uv for i in face.loops] self.no = face.normal self.area = face.area @@ -892,13 +889,13 @@ def main(context, if not me.uv_textures: # Mesh has no UV Coords, don't bother. me.uv_textures.new() - uv_layer = me.uv_textures.active.data + uv_layer = me.uv_loop_layers.active.data me_verts = list(me.vertices) if USER_ONLY_SELECTED_FACES: - meshFaces = [thickface(f, uv_layer[i], me_verts) for i, f in enumerate(me.faces) if f.select] + meshFaces = [thickface(f, uv_layer, me_verts) for i, f in enumerate(me.polygons) if f.select] else: - meshFaces = [thickface(f, uv_layer[i], me_verts) for i, f in enumerate(me.faces)] + meshFaces = [thickface(f, uv_layer, me_verts) for i, f in enumerate(me.polygons)] if not meshFaces: continue diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 354b70c19c2..9cbb9b92463 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -46,7 +46,11 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): # the mt.type enum is (ab)used for a lookup on function names # ...to avoid lengthy if statements # so each type must have a function here. - + + def NGONINTERP(self, layout, ob, md): + split = layout.split() + split.prop(md, "resolution") + def ARMATURE(self, layout, ob, md): split = layout.split() @@ -122,6 +126,12 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): split.prop(md, "width") split.prop(md, "use_only_vertices") + # BMESH_BRANCH ONLY + split = layout.split() + split.prop(md, "use_even_offset") + split.prop(md, "use_distance_offset") + # END BMESH_BRANCH ONLY + layout.label(text="Limit Method:") layout.row().prop(md, "limit_method", expand=True) if md.limit_method == 'ANGLE': diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 87e4738b70e..c12a94e6637 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -527,11 +527,10 @@ class VIEW3D_MT_select_edit_mesh(Menu): layout.separator() - layout.operator("mesh.select_by_number_vertices", text="Triangles").type = 'TRIANGLES' - layout.operator("mesh.select_by_number_vertices", text="Quads").type = 'QUADS' + layout.operator("mesh.select_by_number_vertices", text = "By Number of Verts") if context.scene.tool_settings.mesh_select_mode[2] == False: layout.operator("mesh.select_non_manifold", text="Non Manifold") - layout.operator("mesh.select_by_number_vertices", text="Loose Verts/Edges").type = 'OTHER' + layout.operator("mesh.select_loose_verts", text = "Loose Verts/Edges") layout.operator("mesh.select_similar", text="Similar") layout.separator() @@ -1502,6 +1501,7 @@ class VIEW3D_MT_edit_mesh(Menu): layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region") layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual") + layout.operator("mesh.dissolve_limited") # BMESH ONLY layout.operator("mesh.duplicate_move") layout.operator("mesh.delete", text="Delete...") @@ -1532,15 +1532,18 @@ class VIEW3D_MT_edit_mesh_specials(Menu): layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("mesh.subdivide", text="Subdivide").smoothness = 0.0 + """ layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0 + """ layout.operator("mesh.merge", text="Merge...") layout.operator("mesh.remove_doubles") + layout.operator("mesh.dissolve_limited") # BMESH ONLY layout.operator("mesh.hide", text="Hide") layout.operator("mesh.reveal", text="Reveal") layout.operator("mesh.select_all").action = 'INVERT' layout.operator("mesh.flip_normals") layout.operator("mesh.vertices_smooth", text="Smooth") - # layout.operator("mesh.bevel", text="Bevel") + layout.operator("mesh.bevel", text="Bevel") layout.operator("mesh.faces_shade_smooth") layout.operator("mesh.faces_shade_flat") layout.operator("mesh.blend_from_shape") @@ -1614,6 +1617,7 @@ class VIEW3D_MT_edit_mesh_vertices(Menu): layout.operator("mesh.rip_move") layout.operator("mesh.split") layout.operator("mesh.separate") + layout.operator("mesh.vert_connect") layout.separator() @@ -1662,6 +1666,10 @@ class VIEW3D_MT_edit_mesh_edges(Menu): layout.separator() + layout.operator("mesh.bridge_edge_loops", text="Bridge Two Edge Loops") + + layout.separator() + layout.operator("TRANSFORM_OT_edge_slide") layout.operator("TRANSFORM_OT_edge_crease") layout.operator("mesh.loop_multi_select", text="Edge Loop").ring = False @@ -1694,11 +1702,6 @@ class VIEW3D_MT_edit_mesh_faces(Menu): layout.separator() - layout.operator("mesh.fgon_make") - layout.operator("mesh.fgon_clear") - - layout.separator() - layout.operator("mesh.quads_convert_to_tris") layout.operator("mesh.tris_convert_to_quads") layout.operator("mesh.edge_flip") @@ -1718,9 +1721,9 @@ class VIEW3D_MT_edit_mesh_faces(Menu): layout.separator() layout.operator_menu_enum("mesh.uvs_rotate", "direction") - layout.operator_menu_enum("mesh.uvs_mirror", "axis") + layout.operator("mesh.uvs_reverse") layout.operator_menu_enum("mesh.colors_rotate", "direction") - layout.operator_menu_enum("mesh.colors_mirror", "axis") + layout.operator("mesh.colors_reverse") class VIEW3D_MT_edit_mesh_normals(Menu): |