[Bf-python] How should we implement object material access?

Willian Padovani Germano wgermano at ig.com.br
Mon Jun 23 06:14:50 CEST 2003


Hi,

> You may recall that I recently posted an implementation of
> Object_getMaterials().  After running it a few times, I realize that it
> doesn't work.  The material pointers stored in the blender (C) object
> struct are not used (they are always NULL).  Instead, the said material
> pointers are kept in the data portion of a blender object (like Mesh or
> Curve).

Yes, Blender can bind materials both to objects and to object data, as you
said.  There is a button in Blender to define the behavior, default is to
bind to the data.  NMesh.c, I guess, has a comment explaining more about
this.  There are already functions to return a PyList of wrapped materials,
no need to write another one, probably.

> Should we have cases for the different types of data in the
> Object_getMaterials() function or (maybe this is breaking the spec.)
> have seperate getMaterials() functions for each of the types of data
> (e.g. Mesh_getMaterials(), Curve_getMaterials(), etc.) ?

There is a bug in NMesh caused by this issue, I'll get there.  From what I
already saw, it seems NMesh.update() binds materials to objects, even if
they were bound to the data when they were caught, which causes segfaults
when rendering, maybe other problems.  But don't quote me on that, I didn't
investigate yet and I'm on win now - my cvs is in the linux partition.

About what you proposed, there's no Mesh module there, so no
Mesh.getMaterials().  NMesh is there, with its own ways to handle things.
About Curve, it's a new addition, so we can discuss and find the better
alternative, which is probably what you said: create a Curve.getMaterials()
(and Curve.setMaterials() or some way to append materials to a curve).

I'm doing a doc/test pass on other modules, will get to NMesh in a few days,
but you can check how things could be solved (we just can't change the NMesh
or Object API's) before I do, if you want to.

--
Willian, wgermano at ig.com.br




More information about the Bf-python mailing list