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

Brecht Van Lommel brechtvanlommel at pandora.be
Fri Nov 17 23:14:08 CET 2006


Hi,

Stephane SOPPERA wrote:
> Ben Batt a écrit :
>> Hi Stephane,
>> It looks to me like mdm->verts needs to be a copy of me->verts. I'll
>> have a bit more of a
>> poke around and get back to you.
> Have you found anything?

The code in getMeshDerivedMesh is indeed a hack, but it is not really 
the cause of your problem. Vertex normals are not something that is 
supposed to be written with user defined values, they are automatically 
computed from the vertex coordinates. For example on exiting editmode 
they are overwritten also.

This may be an interesting feature, but the code isn't really there to 
support it. For example on transforming a mesh, the normals would have 
to be transformed as well for the result to look ok.

Brecht.

>> On 8/27/06, Stephane SOPPERA <stephane.soppera at wanadoo.fr> wrote:
>>> Hum... does somebody know something about this issue?
>>>
>>> Stephane SOPPERA a écrit :
>>> > 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