Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-10-09 13:48:04 +0400
committerJoshua Leung <aligorith@gmail.com>2009-10-09 13:48:04 +0400
commit9ebcd9c5e46c8addd80c8adb97fcee91a1916d57 (patch)
treeeff71904b7fc984a74ed8c36b3b2702fc19fb68e /source
parentcc4dd3f04e150613e8c160e4d58f4a557e59c63c (diff)
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
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_modifier.h2
-rw-r--r--source/blender/blenkernel/intern/modifier.c13
-rw-r--r--source/blender/blenkernel/intern/multires.c1
-rw-r--r--source/blender/blenloader/intern/readfile.c4
-rw-r--r--source/blender/editors/animation/keyingsets.c9
-rw-r--r--source/blender/editors/interface/interface_templates.c2
-rw-r--r--source/blender/editors/object/object_edit.c8
-rw-r--r--source/blender/editors/object/object_hook.c1
-rw-r--r--source/blender/editors/object/object_modifier.c22
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c34
-rw-r--r--source/blender/makesrna/intern/rna_fluidsim.c1
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c18
12 files changed, 94 insertions, 21 deletions
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 27c75126026..9957ced9555 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -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);
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index f36713dd8a9..532c3e5da73 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -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);
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index e7159b82d49..ecffbb3d15f 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -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)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index f2bf8b19bc6..49dae2af168 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -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);
}
}
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index d1ac624ec6f..a044e867d56 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -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");
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index d94d2be3a94..24bff19555f 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -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;
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 268cd3b3542..55f95f451d2 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -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);
}
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index ab7bcbc989d..63182e943bb 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -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 */
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 7f0f1876417..252fdb5522a 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -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;
}
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index e6d8a2f27d7..325318ba34a 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -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);
diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c
index c415b3d716a..5b05948857e 100644
--- a/source/blender/makesrna/intern/rna_fluidsim.c
+++ b/source/blender/makesrna/intern/rna_fluidsim.c
@@ -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 {
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 480abff19cb..b04f0a865ef 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -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);