[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51368] trunk/blender/source/blender/ modifiers/intern/MOD_particlesystem.c: Fix/workaround #32846, dupli group + particle instances gets messed up in Cycles viewport rendering .

Lukas Toenne lukas.toenne at googlemail.com
Tue Oct 16 16:55:36 CEST 2012


Revision: 51368
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51368
Author:   lukastoenne
Date:     2012-10-16 14:55:36 +0000 (Tue, 16 Oct 2012)
Log Message:
-----------
Fix/workaround #32846, dupli group + particle instances gets messed up in Cycles viewport rendering.

Caused by modifier updates during dupli-list generation. The dupli-list generation temporarily changes the ob->obmat matrix, which in turn leads to wrong particle states if used for reset. Skip the particle update if no timestep is performed or initialization required.

Proper solution for this problem would be to avoid changing the object data (= particles) state altogether in modifiers, which are usually only writing to DM data and not touching the object or base mesh. This would require a well designed physics framework and integrating it into current particles is close to impossible.

Modified Paths:
--------------
    trunk/blender/source/blender/modifiers/intern/MOD_particlesystem.c

Modified: trunk/blender/source/blender/modifiers/intern/MOD_particlesystem.c
===================================================================
--- trunk/blender/source/blender/modifiers/intern/MOD_particlesystem.c	2012-10-16 14:35:37 UTC (rev 51367)
+++ trunk/blender/source/blender/modifiers/intern/MOD_particlesystem.c	2012-10-16 14:55:36 UTC (rev 51368)
@@ -44,6 +44,7 @@
 #include "BKE_material.h"
 #include "BKE_modifier.h"
 #include "BKE_particle.h"
+#include "BKE_scene.h"
 
 #include "MOD_util.h"
 
@@ -130,6 +131,7 @@
 	ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
 	ParticleSystem *psys = NULL;
 	int needsFree = 0;
+	float cfra = BKE_scene_frame_get(md->scene);
 
 	if (ob->particlesystem.first)
 		psys = psmd->psys;
@@ -188,9 +190,16 @@
 		psmd->totdmface = psmd->dm->getNumTessFaces(psmd->dm);
 	}
 
-	psmd->flag &= ~eParticleSystemFlag_psys_updated;
-	particle_system_update(md->scene, ob, psys);
-	psmd->flag |= eParticleSystemFlag_psys_updated;
+	/* skip the particle update if no timestep is performed or initialization required.
+	 * XXX this is a workaround for bug #32846, which is caused by modifier updates
+	 * during dupli-list generation (in cycles). The dupli-list generation can temporarily change
+	 * the ob->obmat matrix, which in turn leads to wrong particle states if used for reset ...
+	 */
+	if (psys->cfra != cfra || psys->recalc) {
+		psmd->flag &= ~eParticleSystemFlag_psys_updated;
+		particle_system_update(md->scene, ob, psys);
+		psmd->flag |= eParticleSystemFlag_psys_updated;
+	}
 }
 
 /* disabled particles in editmode for now, until support for proper derivedmesh




More information about the Bf-blender-cvs mailing list