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
This commit is contained in:
Philipp Oeser 2020-03-11 18:02:43 +01:00
parent 02f7a6b2bd
commit 28827b62f7
Notes: blender-bot 2023-02-14 02:39:54 +01:00
Referenced by issue #64573, RNA_path_from_ID_to_property fails for pointcaches [thus ALT+click does as well...]
3 changed files with 69 additions and 2 deletions

View File

@ -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);

View File

@ -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,

View File

@ -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,