[Bf-committers] BMesh, EditBMesh, EditDerivedBMesh, and CD layers…

Bastien Montagne montagne29 at wanadoo.fr
Fri Oct 18 13:06:04 CEST 2013


Hi devs,

This mail is mainly addressed to Campbell, who is our bmesh expert, but 
I think it may interest others as well? Anyway, I’m facing currently a 
bug in my loop normals work that I can’t really understand. I suspect 
I’m doing something wrong, but could not find examples in similar code 
to understand what to do, and if we do have some doc about bmesh, I 
found nothing about how CD layers are handled - looking to the code, it 
seems pretty complex (esp. the interactions between bmesh, editbmesh and 
editderivedbmesh)... :/

So, this two-lines patch (against trunk) is enough to crash Blender in 
Edit mode as soon as you add or remove geometry: 
http://www.pasteall.org/46610/diff

Note that all 'array-like' layers (normal, but also sticky, mcol, 
shapekey…) crash, while all single-values (be it int or float - bweight, 
crease etc.) do not crash. Crash happens in mempool 
(BLI_mempool_alloc(), pool->free->next has aberrant values), so this is 
likely a mem overwrite, yet gcc's sanitize build does not say anything 
until the segfault.

So questions are:
1) Is adding a CD layer this way over an EditDerivedBMesh illegal? In 
which case, how are we supposed to process?
2) Does anyone know if we have written doc about CD layers handling in 
the bmesh area?

Regards,
Bastien


More information about the Bf-committers mailing list