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
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-11-22 15:28:38 +0300
committerJoshua Leung <aligorith@gmail.com>2009-11-22 15:28:38 +0300
commit220669d1fd5fe04f50b9fc6413d86015350130e8 (patch)
tree57f37e3dbf28972ff9fd07eefacf5879290bfb4d
parent8e877c1f9ff8d20037299a93dbf8489d2bc9eb98 (diff)
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.
-rw-r--r--source/blender/editors/include/ED_object.h2
-rw-r--r--source/blender/editors/object/object_hook.c2
-rw-r--r--source/blender/editors/object/object_modifier.c6
-rw-r--r--source/blender/editors/object/object_relations.c41
4 files changed, 41 insertions, 10 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index f9cf6edc6ac..8bc7fc8c4d6 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -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);
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index e4b62f58902..d97806cd806 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -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;
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index f65153d09ad..f32d4e7efbd 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -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)
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 7e7b1d99825..dd8d2b4e9cc 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -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);