[Bf-python] Another Mesh question

Chris Want cwant at ualberta.ca
Tue Mar 7 22:21:41 CET 2006


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.

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?

Chris



More information about the Bf-python mailing list