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 /source/blender/editors/object/object_relations.c
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.
Diffstat (limited to 'source/blender/editors/object/object_relations.c')
-rw-r--r--source/blender/editors/object/object_relations.c41
1 files changed, 36 insertions, 5 deletions
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);