forked from bartvdbraak/blender
A few bugfixes:
* #19583: Keying Sets list issues Deleting a Keying Set (or a Keying Set Path) set the active index to 0, but that would mean that the first item would be selected but not visible. * #19590: Keyframing properties of a modifier with more than one of it's type the property will highlight in all - Modifiers now always have a unique name, so renaming a modifier should check that the name is unique. Most of the files changed in this commit were just to make sure that modifiers got unique names when they were created - Modifiers path getter was wrapped a bit wrong (missing the "s around the name) * Constraints Bugs - Constraints renaming now also makes sure the names stay unique - Fixed (or attempted to fix) compiler warnings about some enum declaration for distance constraint
This commit is contained in:
parent
cc4dd3f04e
commit
9ebcd9c5e4
@ -274,6 +274,8 @@ ModifierTypeInfo *modifierType_getInfo (ModifierType type);
|
||||
struct ModifierData *modifier_new(int type);
|
||||
void modifier_free(struct ModifierData *md);
|
||||
|
||||
void modifier_unique_name(struct ListBase *modifiers, struct ModifierData *md);
|
||||
|
||||
void modifier_copyData(struct ModifierData *md, struct ModifierData *target);
|
||||
int modifier_dependsOnTime(struct ModifierData *md);
|
||||
int modifier_supportsMapping(struct ModifierData *md);
|
||||
|
@ -34,6 +34,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "stddef.h"
|
||||
#include "string.h"
|
||||
#include "stdarg.h"
|
||||
#include "math.h"
|
||||
@ -8761,7 +8762,8 @@ ModifierData *modifier_new(int type)
|
||||
{
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(type);
|
||||
ModifierData *md = MEM_callocN(mti->structSize, mti->structName);
|
||||
|
||||
|
||||
// FIXME: we need to make the name always be unique somehow...
|
||||
strcpy(md->name, mti->name);
|
||||
|
||||
md->type = type;
|
||||
@ -8786,6 +8788,15 @@ void modifier_free(ModifierData *md)
|
||||
MEM_freeN(md);
|
||||
}
|
||||
|
||||
void modifier_unique_name(ListBase *modifiers, ModifierData *md)
|
||||
{
|
||||
if (modifiers && md) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
||||
BLI_uniquename(modifiers, md, mti->name, '.', offsetof(ModifierData, name), sizeof(md->name));
|
||||
}
|
||||
}
|
||||
|
||||
int modifier_dependsOnTime(ModifierData *md)
|
||||
{
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
||||
|
@ -142,6 +142,7 @@ void multiresModifier_join(Object *ob)
|
||||
|
||||
mmd = (MultiresModifierData*)modifier_new(eModifierType_Multires);
|
||||
BLI_insertlinkbefore(&base->object->modifiers, md, mmd);
|
||||
modifier_unique_name(&base->object->modifiers, mmd);
|
||||
}
|
||||
|
||||
if(mmd)
|
||||
|
@ -4095,6 +4095,8 @@ static void direct_link_object(FileData *fd, Object *ob)
|
||||
|
||||
BLI_addhead(&ob->modifiers, hmd);
|
||||
BLI_remlink(&ob->hooks, hook);
|
||||
|
||||
modifier_unique_name(&ob->modifiers, hmd);
|
||||
|
||||
MEM_freeN(hook);
|
||||
}
|
||||
@ -7659,6 +7661,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
smd->flags |= eSubsurfModifierFlag_ControlEdges;
|
||||
|
||||
BLI_addtail(&ob->modifiers, smd);
|
||||
|
||||
modifier_unique_name(&ob->modifiers, smd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,9 +177,10 @@ static int remove_active_keyingset_exec (bContext *C, wmOperator *op)
|
||||
|
||||
/* free KeyingSet's data, then remove it from the scene */
|
||||
BKE_keyingset_free(ks);
|
||||
|
||||
BLI_freelinkN(&scene->keyingsets, ks);
|
||||
scene->active_keyingset= 0;
|
||||
|
||||
/* the active one should now be the previously second-to-last one */
|
||||
scene->active_keyingset--;
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -258,8 +259,8 @@ static int remove_active_ks_path_exec (bContext *C, wmOperator *op)
|
||||
BLI_freelinkN(&ks->paths, ksp);
|
||||
}
|
||||
|
||||
/* fix active path index */
|
||||
ks->active_path= 0;
|
||||
/* the active path should now be the previously second-to-last active one */
|
||||
ks->active_path--;
|
||||
}
|
||||
else {
|
||||
BKE_report(op->reports, RPT_ERROR, "No active Keying Set Path to remove");
|
||||
|
@ -458,6 +458,8 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
|
||||
nmd->mode &= ~eModifierMode_Virtual;
|
||||
|
||||
BLI_addhead(&ob->modifiers, nmd);
|
||||
|
||||
modifier_unique_name(&ob->modifiers, nmd);
|
||||
|
||||
ob->partype = PAROBJECT;
|
||||
|
||||
|
@ -848,6 +848,7 @@ void special_editmenu(Scene *scene, View3D *v3d)
|
||||
BooleanModifierData *bmd = NULL;
|
||||
bmd = (BooleanModifierData *)modifier_new(eModifierType_Boolean);
|
||||
BLI_addtail(&ob->modifiers, bmd);
|
||||
modifier_unique_name(&ob->modifiers, bmd);
|
||||
bmd->object = base_select->object;
|
||||
bmd->modifier.mode |= eModifierMode_Realtime;
|
||||
switch(nr){
|
||||
@ -978,9 +979,10 @@ static void object_flip_subdivison_particles(Scene *scene, Object *ob, int *set,
|
||||
}
|
||||
else if(depth == 0 && *set != 0) {
|
||||
SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf);
|
||||
|
||||
|
||||
BLI_addtail(&ob->modifiers, smd);
|
||||
|
||||
modifier_unique_name(&ob->modifiers, smd);
|
||||
|
||||
if (level!=-1) {
|
||||
smd->levels = level;
|
||||
}
|
||||
@ -1197,6 +1199,7 @@ static void copymenu_modifiers(Scene *scene, View3D *v3d, Object *ob)
|
||||
nmd = modifier_new(md->type);
|
||||
modifier_copyData(md, nmd);
|
||||
BLI_addtail(&base->object->modifiers, nmd);
|
||||
modifier_unique_name(&base->object->modifiers, nmd);
|
||||
}
|
||||
|
||||
copy_object_particlesystems(base->object, ob);
|
||||
@ -1220,6 +1223,7 @@ static void copymenu_modifiers(Scene *scene, View3D *v3d, Object *ob)
|
||||
|
||||
mdn = modifier_new(event);
|
||||
BLI_addtail(&base->object->modifiers, mdn);
|
||||
modifier_unique_name(&base->object->modifiers, mdn);
|
||||
|
||||
modifier_copyData(md, mdn);
|
||||
}
|
||||
|
@ -480,6 +480,7 @@ void add_hook(Scene *scene, View3D *v3d, int mode)
|
||||
hmd = (HookModifierData*) modifier_new(eModifierType_Hook);
|
||||
BLI_insertlinkbefore(&obedit->modifiers, md, hmd);
|
||||
sprintf(hmd->modifier.name, "Hook-%s", ob->id.name+2);
|
||||
modifier_unique_name(&obedit->modifiers, hmd);
|
||||
}
|
||||
else if (hmd->indexar) MEM_freeN(hmd->indexar); /* reassign, hook was set */
|
||||
|
||||
|
@ -76,7 +76,7 @@
|
||||
|
||||
int ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int type)
|
||||
{
|
||||
ModifierData *md;
|
||||
ModifierData *md=NULL, *new_md=NULL;
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(type);
|
||||
|
||||
if(mti->flags&eModifierTypeFlag_Single) {
|
||||
@ -87,19 +87,28 @@ int ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int ty
|
||||
}
|
||||
|
||||
if(type == eModifierType_ParticleSystem) {
|
||||
/* don't need to worry about the new modifier's name, since that is set to the number
|
||||
* of particle systems which shouldn't have too many duplicates
|
||||
*/
|
||||
object_add_particle_system(scene, ob);
|
||||
}
|
||||
else {
|
||||
/* get new modifier data to add */
|
||||
new_md= modifier_new(type);
|
||||
|
||||
if(mti->flags&eModifierTypeFlag_RequiresOriginalData) {
|
||||
md = ob->modifiers.first;
|
||||
|
||||
|
||||
while(md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform)
|
||||
md = md->next;
|
||||
|
||||
BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(type));
|
||||
|
||||
BLI_insertlinkbefore(&ob->modifiers, md, new_md);
|
||||
}
|
||||
else
|
||||
BLI_addtail(&ob->modifiers, modifier_new(type));
|
||||
BLI_addtail(&ob->modifiers, new_md);
|
||||
|
||||
/* make sure modifier data has unique name */
|
||||
modifier_unique_name(&ob->modifiers, new_md);
|
||||
|
||||
/* special cases */
|
||||
if(type == eModifierType_Softbody) {
|
||||
@ -111,7 +120,7 @@ int ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int ty
|
||||
else if(type == eModifierType_Collision) {
|
||||
if(!ob->pd)
|
||||
ob->pd= object_add_collision_fields(0);
|
||||
|
||||
|
||||
ob->pd->deflect= 1;
|
||||
DAG_scene_sort(scene);
|
||||
}
|
||||
@ -400,6 +409,7 @@ int ED_object_modifier_copy(ReportList *reports, Object *ob, ModifierData *md)
|
||||
nmd = modifier_new(md->type);
|
||||
modifier_copyData(md, nmd);
|
||||
BLI_insertlink(&ob->modifiers, md, nmd);
|
||||
modifier_unique_name(&ob->modifiers, nmd);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -87,13 +87,6 @@ EnumPropertyItem constraint_ik_type_items[] ={
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
EnumPropertyItem constraint_distance_items[] = {
|
||||
{LIMITDIST_INSIDE, "LIMITDIST_INSIDE", 0, "Inside", ""},
|
||||
{LIMITDIST_OUTSIDE, "LIMITDIST_OUTSIDE", 0, "Outside", ""},
|
||||
{LIMITDIST_ONSURFACE, "LIMITDIST_ONSURFACE", 0, "On Surface", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
#ifdef RNA_RUNTIME
|
||||
|
||||
#include "BKE_action.h"
|
||||
@ -153,6 +146,24 @@ static StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr)
|
||||
}
|
||||
}
|
||||
|
||||
static void rna_Constraint_name_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
bConstraint *con= ptr->data;
|
||||
|
||||
/* copy the new name into the name slot */
|
||||
BLI_strncpy(con->name, value, sizeof(con->name));
|
||||
|
||||
/* make sure name is unique */
|
||||
if (ptr->id.data) {
|
||||
Object *ob= ptr->id.data;
|
||||
ListBase *list= get_active_constraints(ob);
|
||||
|
||||
/* if we have the list, check for unique name, otherwise give up */
|
||||
if (list)
|
||||
unique_constraint_name(con, list);
|
||||
}
|
||||
}
|
||||
|
||||
static char *rna_Constraint_path(PointerRNA *ptr)
|
||||
{
|
||||
Object *ob= ptr->id.data;
|
||||
@ -291,6 +302,14 @@ static void rna_ActionConstraint_minmax_range(PointerRNA *ptr, float *min, float
|
||||
|
||||
#else
|
||||
|
||||
EnumPropertyItem constraint_distance_items[] = {
|
||||
{LIMITDIST_INSIDE, "LIMITDIST_INSIDE", 0, "Inside", ""},
|
||||
{LIMITDIST_OUTSIDE, "LIMITDIST_OUTSIDE", 0, "Outside", ""},
|
||||
{LIMITDIST_ONSURFACE, "LIMITDIST_ONSURFACE", 0, "On Surface", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
static void rna_def_constrainttarget(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
@ -1606,6 +1625,7 @@ void RNA_def_constraint(BlenderRNA *brna)
|
||||
|
||||
/* strings */
|
||||
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Constraint_name_set");
|
||||
RNA_def_property_ui_text(prop, "Name", "");
|
||||
RNA_def_struct_name_property(srna, prop);
|
||||
|
||||
|
@ -114,6 +114,7 @@ static void rna_FluidSettings_update_type(bContext *C, PointerRNA *ptr)
|
||||
sprintf(psmd->modifier.name, "FluidParticleSystem" );
|
||||
psmd->psys= psys;
|
||||
BLI_addtail(&ob->modifiers, psmd);
|
||||
modifier_unique_name(&ob->modifiers, psmd);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -85,6 +85,7 @@ EnumPropertyItem modifier_type_items[] ={
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_modifier.h"
|
||||
|
||||
static void rna_UVProject_projectors_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
@ -164,9 +165,23 @@ static StructRNA* rna_Modifier_refine(struct PointerRNA *ptr)
|
||||
}
|
||||
}
|
||||
|
||||
void rna_Modifier_name_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
ModifierData *md= ptr->data;
|
||||
|
||||
/* copy the new name into the name slot */
|
||||
BLI_strncpy(md->name, value, sizeof(md->name));
|
||||
|
||||
/* make sure the name is truly unique */
|
||||
if (ptr->id.data) {
|
||||
Object *ob= ptr->id.data;
|
||||
modifier_unique_name(&ob->modifiers, md);
|
||||
}
|
||||
}
|
||||
|
||||
static char *rna_Modifier_path(PointerRNA *ptr)
|
||||
{
|
||||
return BLI_sprintfN("modifiers[%s]", ((ModifierData*)ptr->data)->name); // XXX not unique
|
||||
return BLI_sprintfN("modifiers[\"%s\"]", ((ModifierData*)ptr->data)->name);
|
||||
}
|
||||
|
||||
static void rna_Modifier_update(bContext *C, PointerRNA *ptr)
|
||||
@ -1911,6 +1926,7 @@ void RNA_def_modifier(BlenderRNA *brna)
|
||||
|
||||
/* strings */
|
||||
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Modifier_name_set");
|
||||
RNA_def_property_ui_text(prop, "Name", "Modifier name.");
|
||||
RNA_def_struct_name_property(srna, prop);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user