From 45d5773519bdd760d8ac1d8742a9471ebcbf5023 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 2 Feb 2022 12:02:36 +0100 Subject: Cleanup: Use utility function to access original modifier in RNA --- source/blender/makesrna/intern/rna_particle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index fbc7625d815..ff22a7758bb 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -368,7 +368,7 @@ static void rna_ParticleHairKey_co_object_set(ID *id, /* Mark particle system as edited, so then particle_system_update() does not reset the hair * keys from path. This behavior is similar to how particle edit mode sets flags. */ ParticleSystemModifierData *orig_modifier = (ParticleSystemModifierData *) - modifier->modifier.orig_modifier_data; + BKE_modifier_get_original(&modifier->modifier); orig_modifier->psys->flag |= PSYS_EDITED; hair_key_location_object_set(hair_key, object, modifier, particle, co); -- cgit v1.2.3 From c8cca888518182914e6b4f1b98e0f7b861add08d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 2 Feb 2022 12:20:03 +0100 Subject: Fix assert in original modifiers pointer update function The issue was happening with a specific file where the ID management code was not fully copying all modifiers because of the extra check in the `BKE_object_support_modifier_type_check()`. While it is arguable that copy-on-write should be a 1:1 copy there is no real need to maintain the per-modifier pointer to its original. Use its SessionUUID to perform lookup in the original datablock. Downside of this approach is that it is a linear lookup instead of direct pointer access, but the upside is that there is less pointers to manage and that the file with unsupported modifiers does behave correct without any asserts. Differential Revision: https://developer.blender.org/D13993 --- source/blender/makesrna/intern/rna_particle.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index ff22a7758bb..23ec5148f00 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -249,7 +249,8 @@ static void rna_ParticleHairKey_location_object_get(PointerRNA *ptr, float *valu * * Such trickery is needed to allow modification of hair keys in the original object using * evaluated particle and object to access proper hair matrix. */ -static int hair_key_index_get(/*const*/ HairKey *hair_key, +static int hair_key_index_get(const Object *object, + /*const*/ HairKey *hair_key, /*const*/ ParticleSystemModifierData *modifier, /*const*/ ParticleData *particle) { @@ -261,7 +262,7 @@ static int hair_key_index_get(/*const*/ HairKey *hair_key, const int particle_index = particle - particle_system->particles; const ParticleSystemModifierData *original_modifier = (ParticleSystemModifierData *) - BKE_modifier_get_original(&modifier->modifier); + BKE_modifier_get_original(object, &modifier->modifier); const ParticleSystem *original_particle_system = original_modifier->psys; const ParticleData *original_particle = &original_particle_system->particles[particle_index]; @@ -288,7 +289,7 @@ static void hair_key_location_object_set(HairKey *hair_key, NULL; if (hair_mesh != NULL) { - const int hair_key_index = hair_key_index_get(hair_key, modifier, particle); + const int hair_key_index = hair_key_index_get(object, hair_key, modifier, particle); if (hair_key_index == -1) { return; } @@ -368,7 +369,7 @@ static void rna_ParticleHairKey_co_object_set(ID *id, /* Mark particle system as edited, so then particle_system_update() does not reset the hair * keys from path. This behavior is similar to how particle edit mode sets flags. */ ParticleSystemModifierData *orig_modifier = (ParticleSystemModifierData *) - BKE_modifier_get_original(&modifier->modifier); + BKE_modifier_get_original(object, &modifier->modifier); orig_modifier->psys->flag |= PSYS_EDITED; hair_key_location_object_set(hair_key, object, modifier, particle, co); -- cgit v1.2.3