[Bf-python] NMesh and edges informations

Stephane SOPPERA stephane.soppera at wanadoo.fr
Sat Jan 15 01:45:59 CET 2005


Hi,

I'm quite done with storing edges data in NMesh and storing it back in 
blender Mesh.
While doing this, I noticed a new issue.

Currently when one do:
mesh=obj1.getData()
obj2.link(mesh)

mesh is updated, ie it's like in python mesh.update() was called.
The problem with this is that it is not possible to know if edge data 
should be stored or not.
Moreover is seems not usefull to do a mesh.update() if the caller has 
not modified the mesh.

The code of obj2.link() for a mesh is in Mesh_FromPyObject function in 
NMesh.c.

What would seems logical to me is to modify this function to do:
if nmesh->mesh is not null, then don't update the mesh. Just returns it.
if nmesh->mesh is null, that means that the mesh has been created in 
python and not taken from an existing mesh object, then create a Mesh 
from the NMesh using the edges data if available. Actually if NMesh was 
created from scratch and if edges data are there, then that means that 
the user wants to have edge data.

That modification will involve that scripts that rely on obj.link(nmesh) 
to update the mesh will be broken. I don't know if this happens often in 
scripts.

If the modification is not done, then the current bypass to not lose the 
edges data if they exist when linking mesh data to an object is to do:
mesh=obj1.getData()
obj2.link(mesh)
mesh.update(0,1);
This code update the mesh twice, even if the caller don't want it to be 
updated at all. The first update loses edges data, the second one 
recreates them. Moreover obj.link() becomes illogical since it does not 
works the same for meshes as for other object types.

What do you think about that?
Should I do this modification?

Thanks in advance,
Stephane

-- 
Stephane SOPPERA
http://perso.wanadoo.fr/stephane.soppera 





More information about the Bf-python mailing list