[Bf-python] Mesh Face vert order.

Campbell Barton cbarton at metavr.com
Sun Apr 9 01:10:34 CEST 2006


Ken Hughes wrote:
> Campbell Barton wrote:
>> Hi, just updating openflight import and export.
>> and found a problem-
>> The order of the verts in a face, once added. is changed from that of 
>> the original list.
>> .... 
>
> Cam:
>
> This shouldn't happen, as there is code in MFaceSeq_extend which is 
> supposed to keep track of the original vertex order and assign the 
> verts to the faces in that order.  Upload an example to the bug 
> tracker and I'll see what's going on.
>
> Ken
Ken, did a double ckeck and it is definetly the order changing on 
creation. Though a script that created 100000 random faces did not show 
the error. so Im guessing it only happens with certain mesh connectivity 
situations.

# Error is - showing the different order.

(0, 3, 90, 95) [90, 95, 0, 3]
......
    self.blender_import_face(tri, material[0], material[1])
  File "/root/.blender/scripts/flt_import_mesh_new", line 860, in 
blender_impor t_face
    raise "Error"
Error



# And the script that creates the faces. and raises the error. 
(unoptimal for testing)

        local_vt_indicies= []
        local_uvs= []
        for i in indices:
            # VERTEX
            vi= -1
            v = self.header.vert_pal.blender_verts[i]
            for vt in mesh.verts:
                if v==vt.co:
                    vi=vt.index
                    break
            if vi==-1:
                local_vt_indicies.append(len(mesh.verts))
                mesh.verts.extend([v])
            else:
                local_vt_indicies.append(vi)
           
            # UVs
            vert_desc = self.header.vert_pal.vert_desc_lst[i]
           
            if vert_desc.u != None and vert_desc.v != None:
                local_uvs.append(Blender.Mathutils.Vector(vert_desc.u, 
vert_desc.v))
        facelen= len(mesh.faces)
        mesh.faces.extend( [local_vt_indicies] )
        if facelen!=len(mesh.faces):
            face= mesh.faces[-1]
           
            # CHECK INDICIES ARE THE SAME
            new_indices= tuple([v.index for v in face.v])
            if new_indices != tuple(local_vt_indicies):
                print new_indices, local_vt_indicies
                raise "Error"


Do you want the testing files so you an debug yourself?
- Cam

-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241



More information about the Bf-python mailing list