Hi,

I would like to fix a bug, concerning disconnect/reconnect of hairs on an 
object with a mirror modifier. I already reported it 
(https://developer.blender.org/T54488), but now I also dug a little into the 
relevant code. My findings are, that in the function remap_hair_emitter(), 
which does the main work of reconnecting hair to the mesh, there is a weird 
case decision

        if (target_psmd->dm_final->deformedOnly) {
                /* we don't want to mess up target_psmd->dm when converting to 
global coordinates below */
                dm = target_psmd->dm_final;
        }
        else {
                dm = target_psmd->dm_deformed;
        }

where in my tests the second branch is taken, thus dm_deformed is used for the 
further steps, in particular to build the BVH which is used to search for the 
nearest face to connect the a hair to.

                bvhtree_from_mesh_get(&bvhtree, dm, BVHTREE_FROM_FACES, 2);

It seems that in dm_final the mirrored faces are present, while in dm_deformed 
they are not. Thus was happens is, that the hair on the mirrored side get 
connected to the nearest point of the nearest unmirrored face. The problem goes 
away when removing the case decision and always using dm_final. Checking the 
history, once it worked that way, and was changed to the current situation in 
this commit:

commit 0666de06f3119ff1640f1eb66833cd4feb669209
Date:   Thu Jan 15 18:15:52 2015 +0100

    Fix for particle system copy: This has to make sure the ORIGSPACE data
    layer is available.
    
    Otherwise particle mapping to the new mesh cannot work with subdivided
    and constructively-modified meshes.

I have to admit, that I got lost at that point. I'm not familiar enough with 
the code yet, to understand what really is the idea behind selecting dm_final 
or dm_deformed, and what problem exactly was fixed by that. Would be great if 
someone could explain. How can this bug be fixed without breaking the fix of 
the commit above?

Best regards,

O.
_______________________________________________
Bf-committers mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-committers

Reply via email to