diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c index a6e6b30a6b1..8886f892649 100644 --- a/source/blender/draw/engines/eevee/eevee_motion_blur.c +++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c @@ -47,6 +47,11 @@ static struct { extern char datatoc_effect_motion_blur_frag_glsl[]; +typedef struct MotionBlurParent { + struct MotionBlurParent *next, *prev; + Object ob; +} MotionBlurParent; + static void eevee_motion_blur_camera_get_matrix_at_time(Scene *scene, ARegion *region, RegionView3D *rv3d, @@ -56,12 +61,21 @@ static void eevee_motion_blur_camera_get_matrix_at_time(Scene *scene, float r_mat[4][4]) { float obmat[4][4]; + ListBase parents = {NULL, NULL}; /* HACK */ Object cam_cpy = *camera; Camera camdata_cpy = *(Camera *)(camera->data); cam_cpy.data = &camdata_cpy; + Object *parent = cam_cpy.parent; + while (parent) { + MotionBlurParent *mb_parent = MEM_callocN(sizeof(MotionBlurParent), "Motion Blur Parent"); + mb_parent->ob = *parent; + BLI_addtail(&parents, mb_parent); + parent = parent->parent; + } + /* Reset original pointers, so direct evaluation does not attempt to flush * animation back to the original object: otherwise viewport with motion * blur enabled will always loose non-keyed changes. */ @@ -71,11 +85,14 @@ static void eevee_motion_blur_camera_get_matrix_at_time(Scene *scene, const DRWContextState *draw_ctx = DRW_context_state_get(); /* Past matrix */ - /* FIXME : This is a temporal solution that does not take care of parent animations */ /* Recalc Anim manually */ BKE_animsys_evaluate_animdata(&camdata_cpy.id, camdata_cpy.adt, time, ADT_RECALC_ALL, false); BKE_object_where_is_calc_time(draw_ctx->depsgraph, scene, &cam_cpy, time); + LISTBASE_FOREACH (MotionBlurParent *, mb_parent, &parents) { + BKE_object_where_is_calc_time(draw_ctx->depsgraph, scene, &mb_parent->ob, time); + } + /* Compute winmat */ CameraParams params; BKE_camera_params_init(¶ms); @@ -96,6 +113,14 @@ static void eevee_motion_blur_camera_get_matrix_at_time(Scene *scene, normalize_m4_m4(obmat, cam_cpy.obmat); invert_m4(obmat); mul_m4_m4m4(r_mat, params.winmat, obmat); + + LISTBASE_FOREACH (MotionBlurParent *, mb_parent, &parents) { + normalize_m4_m4(obmat, mb_parent->ob.obmat); + invert_m4(obmat); + mul_m4_m4m4(r_mat, r_mat, obmat); + } + + BLI_freelistN(&parents); } static void eevee_create_shader_motion_blur(void)