diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2020-03-11 20:02:43 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2020-03-24 12:52:38 +0300 |
commit | 28827b62f7777a51bb4899021b5248486d2a4687 (patch) | |
tree | 84062d3e3643a71fc7a78df8e0026adf76a60fa4 | |
parent | 02f7a6b2bdea4b338b977770c951f8b38d88e4b0 (diff) |
Fix T64573: RNA_path_from_ID_to_property fails for pointcaches
Give pointcaches a proper path function which e.g. also resolves
ALT+click (assign to all selected) not working for anything relating to
pointcaches.
This also cleans up the usage of the 'eModifierTypeFlag_UsesPointCache'
flag (removed from the boolean modifier, added to the softbody modifier).
Maniphest Tasks: T64573
Differential Revision: https://developer.blender.org/D7115
-rw-r--r-- | source/blender/makesrna/intern/rna_object_force.c | 66 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_boolean.c | 2 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_softbody.c | 3 |
3 files changed, 69 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index cd0c28457cf..4a34d1465dd 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -138,6 +138,70 @@ static bool rna_Cache_get_valid_owner_ID(PointerRNA *ptr, Object **ob, Scene **s return (*ob != NULL || *scene != NULL); } +static char *rna_PointCache_path(PointerRNA *ptr) +{ + ModifierData *md; + Object *ob = (Object *)ptr->owner_id; + PointCache *cache = ptr->data; + + for (md = ob->modifiers.first; md; md = md->next) { + const ModifierTypeInfo *mti = modifierType_getInfo(md->type); + + if (!(mti->flags & eModifierTypeFlag_UsesPointCache)) { + continue; + } + + char name_esc[sizeof(md->name) * 2]; + BLI_strescape(name_esc, md->name, sizeof(name_esc)); + + switch (md->type) { + case eModifierType_ParticleSystem: { + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; + if (psmd->psys->pointcache == cache) { + return BLI_sprintfN("modifiers[\"%s\"].particle_system.point_cache", name_esc); + } + break; + } + case eModifierType_DynamicPaint: { + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; + if (pmd->canvas) { + DynamicPaintSurface *surface = pmd->canvas->surfaces.first; + for (; surface; surface = surface->next) { + if (surface->pointcache == cache) { + char name_surface_esc[sizeof(surface->name) * 2]; + BLI_strescape(name_surface_esc, surface->name, sizeof(name_surface_esc)); + return BLI_sprintfN( + "modifiers[\"%s\"].canvas_settings.canvas_surfaces[\"%s\"].point_cache", + name_esc, + name_surface_esc); + } + } + } + break; + } + case eModifierType_Cloth: { + ClothModifierData *clmd = (ClothModifierData *)md; + if (clmd->point_cache == cache) { + return BLI_sprintfN("modifiers[\"%s\"].point_cache", name_esc); + } + break; + } + case eModifierType_Softbody: { + SoftBody *sb = ob->soft; + if (sb && sb->shared->pointcache == cache) { + return BLI_sprintfN("modifiers[\"%s\"].point_cache", name_esc); + } + break; + } + default: { + return BLI_sprintfN("modifiers[\"%s\"].point_cache", name_esc); + break; + } + } + } + return NULL; +} + static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Object *ob = NULL; @@ -865,6 +929,8 @@ static void rna_def_pointcache_common(StructRNA *srna) {0, NULL, 0, NULL, NULL}, }; + RNA_def_struct_path_func(srna, "rna_PointCache_path"); + prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "startframe"); RNA_def_property_range(prop, -MAXFRAME, MAXFRAME); diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index 668fcef5dd2..67610e8cd29 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -351,7 +351,7 @@ ModifierTypeInfo modifierType_Boolean = { /* structName */ "BooleanModifierData", /* structSize */ sizeof(BooleanModifierData), /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_UsesPointCache, + /* flags */ eModifierTypeFlag_AcceptsMesh, /* copyData */ modifier_copyData_generic, diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c index 679fdb634f4..efe6b188fa0 100644 --- a/source/blender/modifiers/intern/MOD_softbody.c +++ b/source/blender/modifiers/intern/MOD_softbody.c @@ -79,7 +79,8 @@ ModifierTypeInfo modifierType_Softbody = { /* structSize */ sizeof(SoftbodyModifierData), /* type */ eModifierTypeType_OnlyDeform, /* flags */ eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_AcceptsLattice | - eModifierTypeFlag_RequiresOriginalData | eModifierTypeFlag_Single, + eModifierTypeFlag_RequiresOriginalData | eModifierTypeFlag_Single | + eModifierTypeFlag_UsesPointCache, /* copyData */ NULL, |