[Bf-python] Vertex normal bug?

CoDEmanX codemanx at gmx.de
Wed Feb 27 17:43:56 CET 2013


Brecht is right, face normals update automatically, but vertex normals 
don't. Here's some code for the proof (run it on an object which you 
rotated):

import bpy
from bpy import context as C

me1=C.object.to_mesh(C.scene, True, 'PREVIEW', False)
me2=C.object.to_mesh(C.scene, True, 'PREVIEW', False)

me1.transform(C.object.matrix_world)

print("Normal updated?", me1.vertices[0].normal != me2.vertices[0].normal)
me1.update()
print("Normal updated?", me1.vertices[0].normal != me2.vertices[0].normal)



Am 27.02.2013 16:53, schrieb Brecht Van Lommel:
> On Tue, Feb 26, 2013 at 11:25 PM, Ryan Southall
> <R.Southall at brighton.ac.uk> wrote:
>> I have a script that uses
>> Code:
>> mesh = obj.to_mesh(bpy.context.scene, True, 'PREVIEW', calc_tessface=False)
>> mesh.transform(obj.matrix_world)
>>
>> to give me world data for an object obj. This correctly returns world space
>> face normals & position, and vertex position, but incorrect vertex normals.
>> I have to accept first any rotation of the object to get correct vertex
>> normals.
>
> I think you have to call mesh.update() to recalculate the vertex
> normals. This is not done on every operation for performance reasons.
> The face normals are computed on the fly from vertex positions so
> those would be up to date automatically.
>
> Brecht.
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>



More information about the Bf-python mailing list