[Bf-python] Another Mesh question

Ken Hughes khughes at pacific.edu
Wed Mar 8 00:10:41 CET 2006


Chris Want wrote:
> Ken Hughes wrote:
> 
>> Don't add the faces one at a time; add them all at once.
>>
>> newFaces=[]
>> for i in whateverYouIterateOn:
>>     newFaces.extend([v1,v2,v3])
>> me.faces.extend(newFaces)
> 
> Actually, the newFaces.extend([v1,v2,v3]) should be
> replaced by newFaces.append([v1,v2,v3]) in the above
> code -- using extend made a long list of singletons,
> rather than a list of tuples.

Sorry, I blame it on the flu medication:

> There is one bug I noticed. This works:
> 
> me.faces.extend(newFaces)
> me.vertexColors = 1
> 
> but this causes segfaults:
> 
> me.vertexColors = 1
> me.faces.extend(newFaces)
> 
> Probably setting me.vertexColors = 1 has the
> side effect that it mallocs() the vertex
> colors for all existing faces. Maybe when
> me.faces.extend() is called it should also
> check if me.vertexColors == 1, and malloc()
> any missing vertex colors?

Can't blame this on the medication, although I thought I'd fixed this 
before.  You can't enable vertexColors on a mesh without faces, so if 
you're building from scratch you have to .extend() first.  However, 
.extend() is *supposed to* handle added the extra tface/mcol info when 
the faces exist.

I can't reproduce the segfault here: can you upload an example script to 
the bug tracker?

Ken



More information about the Bf-python mailing list