diff options
author | Jacques Lucke <jacques@blender.org> | 2020-12-10 12:23:54 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-12-10 12:23:54 +0300 |
commit | e795ba1529a28ec276a5178fda2025e5ec071bbf (patch) | |
tree | f03a5935ee7dbc4c7ddabaee1c06570a26f698f9 /source/blender/blenkernel/intern/object_dupli.c | |
parent | 22959dc86684290e59c8825c7f212622dba4eb5b (diff) |
Geometry Nodes: fix recursive instance transforms
Previously, the transformation of recursive instances did not work as
on would expect. Second-level instances would detach from first-level
instances when the object was moved.
Diffstat (limited to 'source/blender/blenkernel/intern/object_dupli.c')
-rw-r--r-- | source/blender/blenkernel/intern/object_dupli.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index 9a8c560f116..d5434710e23 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -829,13 +829,18 @@ static void make_duplis_instances_component(const DupliContext *ctx) size_to_mat4(scale_matrix, scales[i]); float rotation_matrix[4][4]; eul_to_mat4(rotation_matrix, rotations[i]); - float matrix[4][4]; - mul_m4_m4m4(matrix, rotation_matrix, scale_matrix); - copy_v3_v3(matrix[3], positions[i]); - mul_m4_m4_pre(matrix, ctx->object->obmat); + float instance_offset_matrix[4][4]; + mul_m4_m4m4(instance_offset_matrix, rotation_matrix, scale_matrix); + copy_v3_v3(instance_offset_matrix[3], positions[i]); + float matrix[4][4]; + mul_m4_m4m4(matrix, ctx->object->obmat, instance_offset_matrix); make_dupli(ctx, object, matrix, i); - make_recursive_duplis(ctx, object, matrix, i); + + float space_matrix[4][4]; + mul_m4_m4m4(space_matrix, instance_offset_matrix, object->imat); + mul_m4_m4_pre(space_matrix, ctx->object->obmat); + make_recursive_duplis(ctx, object, space_matrix, i); } } |