[Bf-blender-cvs] [b642b510e11] blender2.8: Fix T55168: missing updates when switching particle system type.

Brecht Van Lommel noreply at git.blender.org
Wed May 23 19:01:36 CEST 2018


Commit: b642b510e110abfe15d37344e67b07f98d73a273
Author: Brecht Van Lommel
Date:   Wed May 23 18:21:35 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBb642b510e110abfe15d37344e67b07f98d73a273

Fix T55168: missing updates when switching particle system type.

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

M	source/blender/blenkernel/intern/object_update.c
M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/makesrna/intern/rna_particle.c

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

diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index bf01c20a8b7..91571e8bf62 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -238,11 +238,6 @@ void BKE_object_handle_data_update(
 		ob->transflag &= ~OB_DUPLIPARTS;
 		psys = ob->particlesystem.first;
 		while (psys) {
-			/* ensure this update always happens even if psys is disabled */
-			if (psys->recalc & PSYS_RECALC_TYPE) {
-				psys_changed_type(ob, psys);
-			}
-
 			if (psys_check_enabled(ob, psys, use_render_params)) {
 				/* check use of dupli objects here */
 				if (psys->part && (psys->part->draw_as == PART_DRAW_REND || use_render_params) &&
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index a7261e0e6ee..6c454cfa0b1 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -4254,9 +4254,6 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o
 	/* to verify if we need to restore object afterwards */
 	psys->flag &= ~PSYS_OB_ANIM_RESTORE;
 
-	if (psys->recalc & PSYS_RECALC_TYPE)
-		psys_changed_type(sim.ob, sim.psys);
-
 	if (psys->recalc & PSYS_RECALC_RESET)
 		psys->totunexist = 0;
 
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index cbd87fb0666..17e9a6604fd 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -585,11 +585,12 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, R
 static void particle_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr, short flag)
 {
 	if (ptr->type == &RNA_ParticleSystem) {
+		Object *ob = ptr->id.data;
 		ParticleSystem *psys = (ParticleSystem *)ptr->data;
-		
+
 		psys->recalc = flag;
 
-		DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+		DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
 	}
 	else
 		DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA | flag);
@@ -618,9 +619,22 @@ static void rna_Particle_reset_dependency(Main *bmain, Scene *scene, PointerRNA
 	rna_Particle_reset(bmain, scene, ptr);
 }
 
-static void rna_Particle_change_type(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_Particle_change_type(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
 {
-	particle_recalc(bmain, scene, ptr, PSYS_RECALC_RESET | PSYS_RECALC_TYPE);
+	ParticleSettings *part = ptr->id.data;
+
+	/* Iterating over all object is slow, but no better solution exists at the moment. */
+	for (Object *ob = bmain->object.first; ob; ob = ob->id.next) {
+		for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
+			if (psys->part == part) {
+				psys_changed_type(ob, psys);
+				psys->recalc |= PSYS_RECALC_RESET;
+				DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
+			}
+		}
+	}
+
+	WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
 	DEG_relations_tag_update(bmain);
 }
 
@@ -734,6 +748,7 @@ static PointerRNA rna_particle_settings_get(PointerRNA *ptr)
 
 static void rna_particle_settings_set(PointerRNA *ptr, PointerRNA value)
 {
+	Object *ob = ptr->id.data;
 	ParticleSystem *psys = (ParticleSystem *)ptr->data;
 	int old_type = 0;
 
@@ -748,8 +763,9 @@ static void rna_particle_settings_set(PointerRNA *ptr, PointerRNA value)
 	if (psys->part) {
 		id_us_plus(&psys->part->id);
 		psys_check_boid_data(psys);
-		if (old_type != psys->part->type)
-			psys->recalc |= PSYS_RECALC_TYPE;
+		if (old_type != psys->part->type) {
+			psys_changed_type(ob, psys);
+		}
 	}
 }
 static void rna_Particle_abspathtime_update(Main *bmain, Scene *scene, PointerRNA *ptr)



More information about the Bf-blender-cvs mailing list