[Bf-python] Transforming a mesh C-, amazing speed increase of exporters.

Jonathan Merritt j.merritt at pgrad.unimelb.edu.au
Sun Feb 6 03:23:05 CET 2005


Yann Vernier wrote:

># Use iterators so that "list" doesn't consume much memory
>from itertools import imap, repeat
>verts=list(imap(Mathutils.VecMultMat, verts, repeat(M)))
># The call to list() is to get a list from the iterator
>  
>

Cool! - I like this last one a lot! :-)  Since repeat() and VecMultMat() 
are both implemented in C, there shouldn't be too much extra overhead.

I guess the problem here is that an argument could be made that every 
operation that can be done on a single vertex or a single face or a 
single whatever, could be created as a one-off batch operation on the 
parent object (as Cam has done).  I can see that this one operation may 
deserve its own shortcut, but surely there must be other worthwhile 
candidates too?  It just seems a bit arbitrary to add in this one 
"special case".  Surely the aim should always be to keep the API as 
small as possible, while maintaining the same level of "reasonable 
functionality".

You make a very good point about having to extend the memory used by the 
vectors though.  Why not first try adding a method to allow multiplying 
a matrix by a 3-member vector.  The homogeneous 4th coordinate will 
almost invariably be either 1.0 or 0.0 in all the situations I can think 
of, and will tend to be a  uniform value for most sets of vectors (eg: 
1.0 for points, 0.0 for vectors, etc...).  Then you can overcome the 
problem of having to extend the dimension of all the vectors you're 
operating on, and you don't have to introduce a batch operation.

-- 
Jonathan Merritt BE(Mech)/BSc
PhD Student - Equine Biomechanics
The University of Melbourne
Veterinary Clinical Centre, Werribee




More information about the Bf-python mailing list