[Bf-blender-cvs] [2b042d885af] blender-v2.90-release: EEVEE: Motion Blur: Use evaluated object as key to motion data

Clément Foucault noreply at git.blender.org
Wed Aug 12 18:07:01 CEST 2020


Commit: 2b042d885af1f34be7c223d0aeab6cd3589ad41f
Author: Clément Foucault
Date:   Wed Aug 12 13:52:56 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rB2b042d885af1f34be7c223d0aeab6cd3589ad41f

EEVEE: Motion Blur: Use evaluated object as key to motion data

This fix issues with instanced geometry and modifiers. Since the
depsgraph will duplicate the objects when they have different modifiers,
the evaluated object are garanteed to be unique.

===================================================================

M	source/blender/draw/engines/eevee/eevee_data.c
M	source/blender/draw/engines/eevee/eevee_motion_blur.c
M	source/blender/draw/engines/eevee/eevee_private.h

===================================================================

diff --git a/source/blender/draw/engines/eevee/eevee_data.c b/source/blender/draw/engines/eevee/eevee_data.c
index c475e5287c2..b7db6fef918 100644
--- a/source/blender/draw/engines/eevee/eevee_data.c
+++ b/source/blender/draw/engines/eevee/eevee_data.c
@@ -149,12 +149,20 @@ EEVEE_ObjectMotionData *EEVEE_motion_blur_object_data_get(EEVEE_MotionBlurData *
 }
 
 static EEVEE_GeometryMotionData *motion_blur_geometry_data_get(EEVEE_MotionBlurData *mb,
-                                                               void *key,
+                                                               Object *ob,
                                                                bool hair)
 {
   if (mb->geom == NULL) {
     return NULL;
   }
+  DupliObject *dup = DRW_object_get_dupli(ob);
+  void *key;
+  if (dup) {
+    key = dup->ob;
+  }
+  else {
+    key = ob->data;
+  }
   key = (char *)key + (int)hair;
   EEVEE_GeometryMotionData *geom_step = BLI_ghash_lookup(mb->geom, key);
   if (geom_step == NULL) {
@@ -167,25 +175,12 @@ static EEVEE_GeometryMotionData *motion_blur_geometry_data_get(EEVEE_MotionBlurD
 
 EEVEE_GeometryMotionData *EEVEE_motion_blur_geometry_data_get(EEVEE_MotionBlurData *mb, Object *ob)
 {
-  /* Use original data as key to ensure matching accross update. */
-  return motion_blur_geometry_data_get(mb, DEG_get_original_object(ob)->data, false);
+  return motion_blur_geometry_data_get(mb, ob, false);
 }
 
-EEVEE_GeometryMotionData *EEVEE_motion_blur_hair_data_get(EEVEE_MotionBlurData *mb,
-                                                          Object *ob,
-                                                          ModifierData *md)
+EEVEE_GeometryMotionData *EEVEE_motion_blur_hair_data_get(EEVEE_MotionBlurData *mb, Object *ob)
 {
-  void *key;
-  if (md) {
-    /* Particle system. */
-    key = BKE_modifier_get_original(md);
-  }
-  else {
-    /* Hair object. */
-    key = DEG_get_original_object(ob)->data;
-  }
-
-  return motion_blur_geometry_data_get(mb, key, true);
+  return motion_blur_geometry_data_get(mb, ob, true);
 }
 
 /* View Layer data. */
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index 400b309de07..e3dd4252018 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -289,8 +289,7 @@ void EEVEE_motion_blur_hair_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata),
     /* Store transform  */
     DRW_hair_duplimat_get(ob, psys, md, mb_data->obmat[mb_step]);
 
-    EEVEE_GeometryMotionData *mb_geom = EEVEE_motion_blur_hair_data_get(
-        &effects->motion_blur, ob, md);
+    EEVEE_GeometryMotionData *mb_geom = EEVEE_motion_blur_hair_data_get(&effects->motion_blur, ob);
 
     if (mb_step == MB_CURR) {
       /* Fill missing matrices if the object was hidden in previous or next frame. */
@@ -339,7 +338,8 @@ void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata),
   const bool is_dupli = (ob->base_flag & BASE_FROM_DUPLI) != 0;
   const bool object_moves = is_dupli || has_rigidbody || BKE_object_moves_in_time(ob, true);
 #else
-  /* BKE_object_moves_in_time does not work in some cases. Better  */
+  /* BKE_object_moves_in_time does not work in some cases.
+   * Better detect non moving object after evaluation. */
   const bool object_moves = true;
 #endif
   const bool is_deform = BKE_object_is_deform_modified(DRW_context_state_get()->scene, ob) ||
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 829d26ef876..dcc8ffb4c6f 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -972,9 +972,7 @@ EEVEE_ObjectMotionData *EEVEE_motion_blur_object_data_get(EEVEE_MotionBlurData *
                                                           bool hair);
 EEVEE_GeometryMotionData *EEVEE_motion_blur_geometry_data_get(EEVEE_MotionBlurData *mb,
                                                               Object *ob);
-EEVEE_GeometryMotionData *EEVEE_motion_blur_hair_data_get(EEVEE_MotionBlurData *mb,
-                                                          Object *ob,
-                                                          struct ModifierData *md);
+EEVEE_GeometryMotionData *EEVEE_motion_blur_hair_data_get(EEVEE_MotionBlurData *mb, Object *ob);
 EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_get(Object *ob);
 EEVEE_LightProbeEngineData *EEVEE_lightprobe_data_ensure(Object *ob);
 EEVEE_LightEngineData *EEVEE_light_data_get(Object *ob);



More information about the Bf-blender-cvs mailing list