Parenting and Deforms:

Parenting an object to some deformer (i.e. Armature, Curve, Lattice) now adds a new modifier if the object is deformable.

The advantages of this over setting PAR_SKEL mode are:
- instead of a hidden 'virtual' modifier, the user has direct feedback about what sort of modifier is being applied to deform
- most of the time in 2.4, whenever a virtual modifier was added, users would inevitably end up clicking "Make Real" on it

Of course, it's still possible to get 'virtual' modifiers by setting the parent type using the menu-property, but this just makes general setup easier.
This commit is contained in:
2009-11-22 12:28:38 +00:00
parent 8e877c1f9f
commit 220669d1fd
4 changed files with 41 additions and 10 deletions

View File

@@ -114,7 +114,7 @@ void key_to_curve(struct KeyBlock *kb, struct Curve *cu, struct ListBase *nurb)
void curve_to_key(struct Curve *cu, struct KeyBlock *kb, struct ListBase *nurb);
/* object_modifier.c */
int ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, int type);
struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, int type);
int ED_object_modifier_remove(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md);

View File

@@ -431,7 +431,7 @@ static void add_hook_object(Scene *scene, Object *obedit, Object *ob, int mode)
hmd = (HookModifierData*) modifier_new(eModifierType_Hook);
BLI_insertlinkbefore(&obedit->modifiers, md, hmd);
sprintf(hmd->modifier.name, "Hook-%s", ob->id.name+2);
BLI_snprintf(hmd->modifier.name, sizeof(hmd->modifier.name), "Hook-%s", ob->id.name+2);
modifier_unique_name(&obedit->modifiers, (ModifierData*)hmd);
hmd->object= ob;

View File

@@ -75,7 +75,7 @@
/******************************** API ****************************/
int ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int type)
ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int type)
{
ModifierData *md=NULL, *new_md=NULL;
ModifierTypeInfo *mti = modifierType_getInfo(type);
@@ -83,7 +83,7 @@ int ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int ty
if(mti->flags&eModifierTypeFlag_Single) {
if(modifiers_findByType(ob, type)) {
BKE_report(reports, RPT_WARNING, "Only one modifier of this type allowed.");
return 0;
return NULL;
}
}
@@ -131,7 +131,7 @@ int ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int ty
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
return 1;
return new_md;
}
int ED_object_modifier_remove(ReportList *reports, Scene *scene, Object *ob, ModifierData *md)

View File

@@ -632,8 +632,6 @@ static int parent_set_exec(bContext *C, wmOperator *op)
ob->partype= PAROBJECT;
what_does_parent(scene, ob, &workob);
ob->partype= PARSKEL;
invert_m4_m4(ob->parentinv, workob.obmat);
}
else {
@@ -646,8 +644,41 @@ static int parent_set_exec(bContext *C, wmOperator *op)
if(partype == PAR_PATH_CONST)
; /* don't do anything here, since this is not technically "parenting" */
if( ELEM(partype, PAR_CURVE, PAR_LATTICE) || pararm )
ob->partype= PARSKEL; /* note, dna define, not operator property */
else if( ELEM(partype, PAR_CURVE, PAR_LATTICE) || pararm )
{
/* partype is now set to PAROBJECT so that invisible 'virtual' modifiers don't need to be created
* NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, creating the virtual modifiers
*/
ob->partype= PAROBJECT; /* note, dna define, not operator property */
//ob->partype= PARSKEL; /* note, dna define, not operator property */
/* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses */
// XXX currently this should only happen for meshes, curves and surfaces - this stuff isn't available for metas yet
if (ELEM4(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT))
{
switch (partype)
{
case PAR_CURVE: /* curve deform */
{
CurveModifierData *cmd= ED_object_modifier_add(op->reports, scene, ob, eModifierType_Curve);
cmd->object= par;
}
break;
case PAR_LATTICE: /* lattice deform */
{
LatticeModifierData *lmd= ED_object_modifier_add(op->reports, scene, ob, eModifierType_Lattice);
lmd->object= par;
}
break;
default: /* armature deform */
{
ArmatureModifierData *amd= ED_object_modifier_add(op->reports, scene, ob, eModifierType_Armature);
amd->object= par;
}
break;
}
}
}
else if (partype == PAR_BONE)
ob->partype= PARBONE; /* note, dna define, not operator property */
else
@@ -657,7 +688,7 @@ static int parent_set_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
DAG_scene_sort(CTX_data_scene(C));
DAG_scene_sort(scene);
ED_anim_dag_flush_update(C);
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);