diff options
author | Ton Roosendaal <ton@blender.org> | 2005-08-19 16:35:15 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-08-19 16:35:15 +0400 |
commit | 9e05d6efb5acb808b43ecb9f8aed9e1fd99eebc8 (patch) | |
tree | a10272e6a06399c5f098afb428443debaefb4431 /source/blender/src/poseobject.c | |
parent | 92731af84f3f2bd77e844c722a69667de1329efd (diff) |
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
Diffstat (limited to 'source/blender/src/poseobject.c')
-rw-r--r-- | source/blender/src/poseobject.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/source/blender/src/poseobject.c b/source/blender/src/poseobject.c index 75a10df9b6c..616089659f7 100644 --- a/source/blender/src/poseobject.c +++ b/source/blender/src/poseobject.c @@ -37,6 +37,8 @@ #include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_constraint_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" @@ -45,6 +47,7 @@ #include "BKE_action.h" #include "BKE_armature.h" #include "BKE_constraint.h" +#include "BKE_deform.h" #include "BKE_depsgraph.h" #include "BKE_displist.h" #include "BKE_global.h" @@ -54,6 +57,7 @@ #include "BIF_editarmature.h" #include "BIF_editaction.h" #include "BIF_editconstraint.h" +#include "BIF_editdeform.h" #include "BIF_gl.h" #include "BIF_graphics.h" #include "BIF_interface.h" @@ -527,6 +531,62 @@ void paste_posebuf (int flip) BIF_undo_push("Paste Action Pose"); } +/* ********************************************** */ + +void pose_adds_vgroups(Object *meshobj) +{ + Object *poseobj= meshobj->parent; + bPoseChannel *pchan; + Bone *bone; + bDeformGroup *dg; + Mesh *me= meshobj->data; + MVert *mvert; + float head[3], tail[3], vec[3], fac; + int i; + + if(poseobj==NULL || (poseobj->flag & OB_POSEMODE)==0) return; + + for(pchan= poseobj->pose->chanbase.first; pchan; pchan= pchan->next) { + bone= pchan->bone; + if(bone->flag & (BONE_SELECTED)) { + + /* check if mesh has vgroups */ + dg= get_named_vertexgroup(meshobj, bone->name); + if(dg==NULL) + dg= add_defgroup_name(meshobj, bone->name); + + /* get the root of the bone in global coords */ + VECCOPY(head, bone->arm_head); + Mat4MulVecfl(poseobj->obmat, head); + + /* get the tip of the bone in global coords */ + VECCOPY(tail, bone->arm_tail); + Mat4MulVecfl(poseobj->obmat, tail); + + /* todo; get the optimal vertices instead of mverts */ + mvert= me->mvert; + for ( i=0 ; i < me->totvert ; i++ , mvert++) { + VECCOPY(vec, mvert->co); + Mat4MulVecfl(meshobj->obmat, vec); + + /* get the distance-factor from the vertex to bone */ + fac= distfactor_to_bone (vec, head, tail, bone->rad_head, bone->rad_tail, bone->dist); + + /* add to vgroup. this call also makes me->dverts */ + if(fac!=0.0f) + add_vert_to_defgroup (meshobj, dg, i, fac, WEIGHT_REPLACE); + else + remove_vert_defgroup (meshobj, dg, i); + } + } + } + + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWBUTSEDIT, 0); + + DAG_object_flush_update(G.scene, meshobj, OB_RECALC_DATA); // and all its relations + +} /* ********************************************** */ |