[Bf-blender-cvs] [5249a813f22] blender-v2.90-release: Fix T78954 EEVEE: Motion Blur: Bug with hair particles on linked objects

Clément Foucault noreply at git.blender.org
Wed Aug 5 22:12:55 CEST 2020


Commit: 5249a813f22f4eb8680666d4a2512acfd1e384be
Author: Clément Foucault
Date:   Wed Aug 5 22:12:47 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rB5249a813f22f4eb8680666d4a2512acfd1e384be

Fix T78954 EEVEE: Motion Blur: Bug with hair particles on linked objects

The cache key for particle system was the original Object data. But this
is incorrect for particle systems as modifiers are not shared.

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

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 87948f403a0..914c869fc91 100644
--- a/source/blender/draw/engines/eevee/eevee_data.c
+++ b/source/blender/draw/engines/eevee/eevee_data.c
@@ -28,6 +28,7 @@
 #include "BLI_memblock.h"
 
 #include "BKE_duplilist.h"
+#include "BKE_modifier.h"
 
 #include "DEG_depsgraph_query.h"
 
@@ -147,28 +148,46 @@ EEVEE_ObjectMotionData *EEVEE_motion_blur_object_data_get(EEVEE_MotionBlurData *
   return ob_step;
 }
 
-EEVEE_GeometryMotionData *EEVEE_motion_blur_geometry_data_get(EEVEE_MotionBlurData *mb,
-                                                              Object *ob,
-                                                              bool hair)
+static EEVEE_GeometryMotionData *motion_blur_geometry_data_get(EEVEE_MotionBlurData *mb,
+                                                               void *key,
+                                                               bool hair)
 {
   if (mb->geom == NULL) {
     return NULL;
   }
-
-  /* Use original data as key to ensure matching accross update. */
-  Object *ob_orig = DEG_get_original_object(ob);
-
-  void *key = (char *)ob_orig->data + hair;
+  key = (char *)key + (int)hair;
   EEVEE_GeometryMotionData *geom_step = BLI_ghash_lookup(mb->geom, key);
   if (geom_step == NULL) {
     geom_step = MEM_callocN(sizeof(EEVEE_GeometryMotionData), __func__);
-    geom_step->type = (hair) ? EEVEE_HAIR_GEOM_MOTION_DATA : EEVEE_MESH_GEOM_MOTION_DATA;
+    geom_step->type = hair ? EEVEE_HAIR_GEOM_MOTION_DATA : EEVEE_MESH_GEOM_MOTION_DATA;
     BLI_ghash_insert(mb->geom, key, geom_step);
   }
-
   return geom_step;
 }
 
+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);
+}
+
+EEVEE_GeometryMotionData *EEVEE_motion_blur_hair_data_get(EEVEE_MotionBlurData *mb,
+                                                          Object *ob,
+                                                          ModifierData *md)
+{
+  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, DEG_get_original_object(ob), true);
+}
+
 /* View Layer data. */
 
 void EEVEE_view_layer_data_free(void *storage)
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index 586ee780f1d..0d55d92ce6f 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -288,8 +288,8 @@ 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_geometry_data_get(
-        &effects->motion_blur, ob, true);
+    EEVEE_GeometryMotionData *mb_geom = EEVEE_motion_blur_hair_data_get(
+        &effects->motion_blur, ob, md);
 
     if (mb_step == MB_CURR) {
       /* Fill missing matrices if the object was hidden in previous or next frame. */
@@ -346,8 +346,8 @@ void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData *UNUSED(sldata),
     /* Store transform  */
     copy_m4_m4(mb_data->obmat[mb_step], ob->obmat);
 
-    EEVEE_GeometryMotionData *mb_geom = EEVEE_motion_blur_geometry_data_get(
-        &effects->motion_blur, ob, false);
+    EEVEE_GeometryMotionData *mb_geom = EEVEE_motion_blur_geometry_data_get(&effects->motion_blur,
+                                                                            ob);
 
     if (mb_step == MB_CURR) {
       GPUBatch *batch = DRW_cache_object_surface_get(ob);
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 51831e5506d..2f54c839d80 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -971,8 +971,10 @@ EEVEE_ObjectMotionData *EEVEE_motion_blur_object_data_get(EEVEE_MotionBlurData *
                                                           Object *ob,
                                                           bool hair);
 EEVEE_GeometryMotionData *EEVEE_motion_blur_geometry_data_get(EEVEE_MotionBlurData *mb,
-                                                              Object *ob,
-                                                              bool hair);
+                                                              Object *ob);
+EEVEE_GeometryMotionData *EEVEE_motion_blur_hair_data_get(EEVEE_MotionBlurData *mb,
+                                                          Object *ob,
+                                                          struct ModifierData *md);
 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