[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1966] trunk/py/scripts/addons: update for api changes in blender

Campbell Barton ideasman42 at gmail.com
Thu May 26 09:47:45 CEST 2011


Revision: 1966
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1966
Author:   campbellbarton
Date:     2011-05-26 07:47:44 +0000 (Thu, 26 May 2011)
Log Message:
-----------
update for api changes in blender

Modified Paths:
--------------
    trunk/py/scripts/addons/io_scene_obj/import_obj.py
    trunk/py/scripts/addons/object_fracture/fracture_ops.py

Modified: trunk/py/scripts/addons/io_scene_obj/import_obj.py
===================================================================
--- trunk/py/scripts/addons/io_scene_obj/import_obj.py	2011-05-26 01:50:45 UTC (rev 1965)
+++ trunk/py/scripts/addons/io_scene_obj/import_obj.py	2011-05-26 07:47:44 UTC (rev 1966)
@@ -39,190 +39,6 @@
 from bpy_extras.io_utils import load_image, unpack_list, unpack_face_list
 
 
-def BPyMesh_ngon(from_data, indices, PREF_FIX_LOOPS=True):
-    '''
-    Takes a polyline of indices (fgon)
-    and returns a list of face indicie lists.
-    Designed to be used for importers that need indices for an fgon to create from existing verts.
-
-    from_data: either a mesh, or a list/tuple of vectors.
-    indices: a list of indices to use this list is the ordered closed polyline to fill, and can be a subset of the data given.
-    PREF_FIX_LOOPS: If this is enabled polylines that use loops to make multiple polylines are delt with correctly.
-    '''
-
-    if not set:  # Need sets for this, otherwise do a normal fill.
-        PREF_FIX_LOOPS = False
-
-    Vector = mathutils.Vector
-    if not indices:
-        return []
-
-    #    return []
-    def rvec(co):
-        return round(co.x, 6), round(co.y, 6), round(co.z, 6)
-
-    def mlen(co):
-        return abs(co[0]) + abs(co[1]) + abs(co[2])  # manhatten length of a vector, faster then length
-
-    def vert_treplet(v, i):
-        return v, rvec(v), i, mlen(v)
-
-    def ed_key_mlen(v1, v2):
-        if v1[3] > v2[3]:
-            return v2[1], v1[1]
-        else:
-            return v1[1], v2[1]
-
-    if not PREF_FIX_LOOPS:
-        '''
-        Normal single concave loop filling
-        '''
-        if type(from_data) in (tuple, list):
-            verts = [Vector(from_data[i]) for ii, i in enumerate(indices)]
-        else:
-            verts = [from_data.vertices[i].co for ii, i in enumerate(indices)]
-
-        for i in range(len(verts) - 1, 0, -1):  # same as reversed(xrange(1, len(verts))):
-            if verts[i][1] == verts[i - 1][0]:
-                verts.pop(i - 1)
-
-        fill = fill_polygon([verts])
-
-    else:
-        '''
-        Seperate this loop into multiple loops be finding edges that are used twice
-        This is used by lightwave LWO files a lot
-        '''
-
-        if type(from_data) in (tuple, list):
-            verts = [vert_treplet(Vector(from_data[i]), ii) for ii, i in enumerate(indices)]
-        else:
-            verts = [vert_treplet(from_data.vertices[i].co, ii) for ii, i in enumerate(indices)]
-
-        edges = [(i, i - 1) for i in range(len(verts))]
-        if edges:
-            edges[0] = (0, len(verts) - 1)
-
-        if not verts:
-            return []
-
-        edges_used = set()
-        edges_doubles = set()
-        # We need to check if any edges are used twice location based.
-        for ed in edges:
-            edkey = ed_key_mlen(verts[ed[0]], verts[ed[1]])
-            if edkey in edges_used:
-                edges_doubles.add(edkey)
-            else:
-                edges_used.add(edkey)
-
-        # Store a list of unconnected loop segments split by double edges.
-        # will join later
-        loop_segments = []
-
-        v_prev = verts[0]
-        context_loop = [v_prev]
-        loop_segments = [context_loop]
-
-        for v in verts:
-            if v != v_prev:
-                # Are we crossing an edge we removed?
-                if ed_key_mlen(v, v_prev) in edges_doubles:
-                    context_loop = [v]
-                    loop_segments.append(context_loop)
-                else:
-                    if context_loop and context_loop[-1][1] == v[1]:
-                        #raise "as"
-                        pass
-                    else:
-                        context_loop.append(v)
-
-                v_prev = v
-        # Now join loop segments
-
-        def join_seg(s1, s2):
-            if s2[-1][1] == s1[0][1]:
-                s1, s2 = s2, s1
-            elif s1[-1][1] == s2[0][1]:
-                pass
-            else:
-                return False
-
-            # If were stuill here s1 and s2 are 2 segments in the same polyline
-            s1.pop()  # remove the last vert from s1
-            s1.extend(s2)  # add segment 2 to segment 1
-
-            if s1[0][1] == s1[-1][1]:  # remove endpoints double
-                s1.pop()
-
-            s2[:] = []  # Empty this segment s2 so we dont use it again.
-            return True
-
-        joining_segments = True
-        while joining_segments:
-            joining_segments = False
-            segcount = len(loop_segments)
-
-            for j in range(segcount - 1, -1, -1):  # reversed(range(segcount)):
-                seg_j = loop_segments[j]
-                if seg_j:
-                    for k in range(j - 1, -1, -1):  # reversed(range(j)):
-                        if not seg_j:
-                            break
-                        seg_k = loop_segments[k]
-
-                        if seg_k and join_seg(seg_j, seg_k):
-                            joining_segments = True
-
-        loop_list = loop_segments
-
-        for verts in loop_list:
-            while verts and verts[0][1] == verts[-1][1]:
-                verts.pop()
-
-        loop_list = [verts for verts in loop_list if len(verts) > 2]
-        # DONE DEALING WITH LOOP FIXING
-
-        # vert mapping
-        vert_map = [None] * len(indices)
-        ii = 0
-        for verts in loop_list:
-            if len(verts) > 2:
-                for i, vert in enumerate(verts):
-                    vert_map[i + ii] = vert[2]
-                ii += len(verts)
-
-        fill = tesselate_polygon([[v[0] for v in loop] for loop in loop_list])
-        #draw_loops(loop_list)
-        #raise 'done loop'
-        # map to original indices
-        fill = [[vert_map[i] for i in reversed(f)] for f in fill]
-
-    if not fill:
-        print('Warning Cannot scanfill, fallback on a triangle fan.')
-        fill = [[0, i - 1, i] for i in range(2, len(indices))]
-    else:
-        # Use real scanfill.
-        # See if its flipped the wrong way.
-        flip = None
-        for fi in fill:
-            if flip != None:
-                break
-            for i, vi in enumerate(fi):
-                if vi == 0 and fi[i - 1] == 1:
-                    flip = False
-                    break
-                elif vi == 1 and fi[i - 1] == 0:
-                    flip = True
-                    break
-
-        if not flip:
-            for i, fi in enumerate(fill):
-                fill[i] = tuple([ii for ii in reversed(fi)])
-
-    return fill
-
-
 def line_value(line_split):
     '''
     Returns 1 string represneting the value for this line
@@ -616,6 +432,8 @@
     Takes all the data gathered and generates a mesh, adding the new object to new_objects
     deals with fgons, sharp edges and assigning materials
     '''
+    from mesh_utils import ngon_tessellate
+
     if not has_ngons:
         use_ngons = False
 
@@ -675,7 +493,7 @@
             # FGons into triangles
             if has_ngons and len_face_vert_loc_indices > 4:
 
-                ngon_face_indices = BPyMesh_ngon(verts_loc, face_vert_loc_indices)
+                ngon_face_indices = ngon_tessellate(verts_loc, face_vert_loc_indices)
                 faces.extend(
                     [(
                     [face_vert_loc_indices[ngon[0]], face_vert_loc_indices[ngon[1]], face_vert_loc_indices[ngon[2]]],

Modified: trunk/py/scripts/addons/object_fracture/fracture_ops.py
===================================================================
--- trunk/py/scripts/addons/object_fracture/fracture_ops.py	2011-05-26 01:50:45 UTC (rev 1965)
+++ trunk/py/scripts/addons/object_fracture/fracture_ops.py	2011-05-26 07:47:44 UTC (rev 1966)
@@ -231,7 +231,7 @@
          # This checks whether returned shards are non-manifold.
          # Problem is, if org mesh is non-manifold, it will always fail (e.g. with Suzanne).
          # And disabling it does not seem to cause any problem…
-#        elif min(nmesh.edge_face_count) < 2:    # Manifold check
+#        elif min(mesh_utils.edge_face_count(nmesh)) < 2:    # Manifold check
 #            fault = 1
 
         if not fault:



More information about the Bf-extensions-cvs mailing list