[Bf-committers] getMeshDerivedMesh recomputes object->data normals?

Stephane SOPPERA stephane.soppera at wanadoo.fr
Thu Jul 27 21:05:26 CEST 2006


Hi,

I was trying with python Mesh module to give values of vertices normals 
on a newly created mesh.
I noticed that it's impossible and investigated the problem.
Actually after the script is ended, since a new object and a new mesh 
have been created, object_handle_update function calls makeDispListMesh 
for the new object. makeDispListMesh then involves this call stack:
makeDispListMesh
    mesh_build_data
        mesh_calc_modifiers
            getMeshDerivedMesh

and in getMeshDerivedMesh there is a call to mesh_calc_normals with 
mdm->verts=me->verts and vertCos=NULL
This call recomputes the normals for each vertex (me->verts) of the 
original data.
Actually there is also a comment before the code:
            // XXX this is kinda hacky because we shouldn't really be 
editing
            // the mesh here, however, we can't just call 
mesh_build_faceNormals(ob)
            // because in the case when a key is applied to a mesh the 
vertex normals
            // would never be correctly computed.
            mesh_calc_normals(mdm->verts, me->totvert, me->mface, 
me->totface, &mdm->nors);
            mdm->freeNors = 1;

So the consequence of all that is that each time the display mesh is 
generated (this happen at least when an object is created and each time 
the modifier stack is modified), original mesh normals are recomputed 
and their previous value is lost.
Is this a wanted behavior? Or is it a side effect?

Stéphane







More information about the Bf-committers mailing list