[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11732] trunk/blender/source/blender/ python/api2_2x: added face sorting to mesh so you can do mesh.faces.sort(.. .)

Campbell Barton cbarton at metavr.com
Mon Aug 20 15:09:16 CEST 2007

Joe Eagar wrote:
> Campbell Barton wrote:
>> Revision: 11732
>>           http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11732
>> Author:   campbellbarton
>> Date:     2007-08-20 12:08:59 +0200 (Mon, 20 Aug 2007)
>> Log Message:
>> -----------
>> added face sorting to mesh so you can do mesh.faces.sort(...)
>> uses list sorting internally so is exactly the same as list sorting.
> Hrm.  Wouldn't it be better to use the C standard function qsort?
> Joe
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers

it would be faster but then we'd also have to re-impliment pythons list 
sort function for mesh faces.

It a lot easier not to, just internally make into a python list, sort 
them with pythons list sort function and then apply the changes to the mesh.

the sort functions only useful in this case when args/keywords are passed.
Like ...
me.faces.sort(lambda a,b: cmp(a.cent*matrix, b.cent*matrix))

me.faces.sort(key = lambda a: a.no.z)

and Id rather not re-impliment this in the mesh api, its a fairly 
obscure function I added for Briggs, and if it was a lot of work/code it 
would not have been worth the effort IMHO.

Of course if many scripts ended up sorting (and it slowed down exporters 
for instance) then it would be worth having our own implementation that 
used qsort directly.

Campbell J Barton (ideasman42)

More information about the Bf-committers mailing list