From e795ba1529a28ec276a5178fda2025e5ec071bbf Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 10 Dec 2020 10:23:54 +0100 Subject: [PATCH] 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. --- source/blender/blenkernel/intern/object_dupli.c | 15 ++++++++++----- 1 file 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); } }