[Bf-python] Mesh Face vert order.

Joe Eagar joeedh at gmail.com
Sun Apr 9 05:33:20 CEST 2006


Ken Hughes wrote:
> Campbell Barton wrote:
>> 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
>
> Yeah, that should have tipped me off.... if vert 3 or 4 is index 0, 
> then it's reordered.  This was to be consistent with zr's 
> "eeekadoodle" rules for faces with only 2 vertices, or at least as I 
> understood them.  If vertex 0 is used in a face, is has to be one of 
> the first two verts.
A *quad's* MFace->v4 can never *ever* be zero, due to the fact that vert 
indices are in range(0-vert_len-1 inclusive), not range(1-vert_len 
inclusive) , yet zero is used for triangle testing.  In other words, 
blender detects if a face is a triangle by testing if MFace->v4 == 0, 
*however* 0 is a valid vertex index ().

Thus, when you add a new quad mface, you must rotate the vert list to 
make sure  ->v4 not equal to zero (there's a function to this, see see 
blenkernel/intern/mesh.c, line 493, test_index_face() ).  The only 
solution I can think to this problem would be to add a flag denoting if 
a face has been rotated.  E.g. if face->flag & ME_ROTATED, you'd then do 
the vert index rotation *backwards* before sending the final face to 
python script.

joeedh



More information about the Bf-python mailing list