[Bf-python] some questions

Willian Padovani Germano wgermano at ig.com.br
Sat May 17 05:53:30 CEST 2003


Hi, guignot : )

On Fri, 2003-05-16 at 18:41, guignot wrote:
(...)
> An Object class has a struct Material **mat member. Where can I get the 
> number of materials ?

Probably "int BLI_countlist (ListBase *listbase)" is the function you're
looking for.  It's declared in source/blender/blenlib/BLI_blenlib.h and
defined right there, in intern/util.c .  I guess 
BLI_countlist (&(G.main->mat)) will do the job for you.  Haven't tested,
though.  Anyway, it's not difficult to do that, and checking the code
for the BLI function is useful. LisBase and ID are key structs in
Blender's internals, you know.

> Suppose the Object has a data pointer which points to a Mesh for 
> instance. The Mesh has itself a struct Material **mat member.
> Which is the "good" material ? The Object's one, or the Meshe's ? How 
> many materials has the Mesh?

In Blender materials can "belong" either to a mesh object or to its mesh
data.  There's even a button in Blender to let you choose what you
prefer.  The bpython API also let you choose which one you want the
material list to belong to.

Are you working on the Material module?  If so, please tell us to
prevent wasted efforts, in case someone else is working / would work on
it.

> Last but not least, the Material class has a Material *ren ? What is 
> this pointer supposed to point to ?

Blender's own renderer uses it.  That's all I know, except that it is
itself used to hold a struct Material, so probably it is a Material
modified to the renderer's needs/taste.

> Sorry to bother you with these questions, but I heard many programmers 
> (jms for instance) complaining about the difficulty to access an 
> object's material.

No problem.  Buuut, since I've been playing the boring guy ; ), these
questions are related to Blender itself, so more people can answer (and
benefit from the answers) if we send them to the main committer's list.

Ah, in another email you mentioned that "bad call to addqueue".  I get
those, sometimes.  Did a little research -- not enough -- weeks ago, but
I already forgot what I saw.  It's the update part of Blender, windows
and events.  Let's see again...

It's from source/blender/src/editscreen.c, in addqueue_ext function. 
The msg happens when the short variable win < 4 or when areawinar[win]
is NULL.  So printing win, areawinar and maybe some other variables
inside the error block, along with "bad call ..." should gives us more
insight.  There are 2 lines in that same file like this:

areawinar[sa->win]= sa; /* otherwise addqueue does not work */

So, or it may happen in Blender sometimes, depending on e. g. where the
mouse was at the moment, or there's a bug somewhere, where they forgot
to set areawinar[somewin] to something !NULL or to set win >= 4, of
course.  Wanna play with this bug ?

This is another one for the committer's list ... If you don't find an
obvious bug, they (Ton?) may know the reason for the error msg.

--
Willian, wgermano at ig.com.br




More information about the Bf-python mailing list