forked from bartvdbraak/blender
2.5
Transform editbones
This commit is contained in:
parent
a6c0b968ba
commit
a8f8bf1dc5
@ -1830,7 +1830,7 @@ void ED_armature_to_edit(Object *ob)
|
||||
/* adjust bone roll to align Z axis with vector
|
||||
* vec is in local space and is normalized
|
||||
*/
|
||||
float rollBoneToVector(EditBone *bone, float new_up_axis[3])
|
||||
float ED_rollBoneToVector(EditBone *bone, float new_up_axis[3])
|
||||
{
|
||||
float mat[3][3], nor[3], up_axis[3], vec[3];
|
||||
float roll;
|
||||
|
@ -92,6 +92,9 @@ int ED_do_pose_selectbuffer(struct Scene *scene, struct Base *base, unsigned int
|
||||
short hits, short extend);
|
||||
void mouse_armature(struct bContext *C, short mval[2], int extend);
|
||||
|
||||
float ED_rollBoneToVector(EditBone *bone, float new_up_axis[3]);
|
||||
|
||||
void transform_armature_mirror_update(struct Object *obedit);
|
||||
|
||||
/* poseobject.c */
|
||||
void ED_armature_exit_posemode(struct Base *base);
|
||||
|
@ -1021,25 +1021,29 @@ static void createTransPose(bContext *C, TransInfo *t, Object *ob)
|
||||
|
||||
static void createTransArmatureVerts(bContext *C, TransInfo *t)
|
||||
{
|
||||
// TRANSFORM_FIX_ME
|
||||
#if 0
|
||||
EditBone *ebo;
|
||||
bArmature *arm= t->obedit->data;
|
||||
ListBase *edbo = arm->edbo;
|
||||
TransData *td;
|
||||
float mtx[3][3], smtx[3][3], delta[3], bonemat[3][3];
|
||||
|
||||
t->total = 0;
|
||||
for (ebo=G.edbo.first;ebo;ebo=ebo->next) {
|
||||
if(ebo->layer & arm->layer) {
|
||||
if (t->mode==TFM_BONESIZE) {
|
||||
for (ebo = edbo->first; ebo; ebo = ebo->next)
|
||||
{
|
||||
if(ebo->layer & arm->layer)
|
||||
{
|
||||
if (t->mode==TFM_BONESIZE)
|
||||
{
|
||||
if (ebo->flag & BONE_SELECTED)
|
||||
t->total++;
|
||||
}
|
||||
else if (t->mode==TFM_BONE_ROLL) {
|
||||
else if (t->mode==TFM_BONE_ROLL)
|
||||
{
|
||||
if (ebo->flag & BONE_SELECTED)
|
||||
t->total++;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
if (ebo->flag & BONE_TIPSEL)
|
||||
t->total++;
|
||||
if (ebo->flag & BONE_ROOTSEL)
|
||||
@ -1055,13 +1059,15 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
|
||||
|
||||
td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransEditBone");
|
||||
|
||||
for (ebo=G.edbo.first;ebo;ebo=ebo->next){
|
||||
ebo->oldlength= ebo->length; // length==0.0 on extrude, used for scaling radius of bone points
|
||||
for (ebo = edbo->first; ebo; ebo = ebo->next)
|
||||
{
|
||||
ebo->oldlength = ebo->length; // length==0.0 on extrude, used for scaling radius of bone points
|
||||
|
||||
if(ebo->layer & arm->layer) {
|
||||
if (t->mode==TFM_BONE_ENVELOPE) {
|
||||
|
||||
if (ebo->flag & BONE_ROOTSEL){
|
||||
if (t->mode==TFM_BONE_ENVELOPE)
|
||||
{
|
||||
if (ebo->flag & BONE_ROOTSEL)
|
||||
{
|
||||
td->val= &ebo->rad_head;
|
||||
td->ival= *td->val;
|
||||
|
||||
@ -1077,7 +1083,8 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
|
||||
|
||||
td++;
|
||||
}
|
||||
if (ebo->flag & BONE_TIPSEL){
|
||||
if (ebo->flag & BONE_TIPSEL)
|
||||
{
|
||||
td->val= &ebo->rad_tail;
|
||||
td->ival= *td->val;
|
||||
VECCOPY (td->center, ebo->tail);
|
||||
@ -1094,14 +1101,17 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
|
||||
}
|
||||
|
||||
}
|
||||
else if (t->mode==TFM_BONESIZE) {
|
||||
else if (t->mode==TFM_BONESIZE)
|
||||
{
|
||||
if (ebo->flag & BONE_SELECTED) {
|
||||
if(arm->drawtype==ARM_ENVELOPE) {
|
||||
if(arm->drawtype==ARM_ENVELOPE)
|
||||
{
|
||||
td->loc= NULL;
|
||||
td->val= &ebo->dist;
|
||||
td->ival= ebo->dist;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// abusive storage of scale in the loc pointer :)
|
||||
td->loc= &ebo->xwidth;
|
||||
VECCOPY (td->iloc, td->loc);
|
||||
@ -1125,8 +1135,10 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
|
||||
td++;
|
||||
}
|
||||
}
|
||||
else if (t->mode==TFM_BONE_ROLL) {
|
||||
if (ebo->flag & BONE_SELECTED) {
|
||||
else if (t->mode==TFM_BONE_ROLL)
|
||||
{
|
||||
if (ebo->flag & BONE_SELECTED)
|
||||
{
|
||||
td->loc= NULL;
|
||||
td->val= &(ebo->roll);
|
||||
td->ival= ebo->roll;
|
||||
@ -1140,8 +1152,10 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
|
||||
td++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ebo->flag & BONE_TIPSEL){
|
||||
else
|
||||
{
|
||||
if (ebo->flag & BONE_TIPSEL)
|
||||
{
|
||||
VECCOPY (td->iloc, ebo->tail);
|
||||
VECCOPY (td->center, td->iloc);
|
||||
td->loc= ebo->tail;
|
||||
@ -1166,7 +1180,8 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
|
||||
|
||||
td++;
|
||||
}
|
||||
if (ebo->flag & BONE_ROOTSEL){
|
||||
if (ebo->flag & BONE_ROOTSEL)
|
||||
{
|
||||
VECCOPY (td->iloc, ebo->head);
|
||||
VECCOPY (td->center, td->iloc);
|
||||
td->loc= ebo->head;
|
||||
@ -1191,7 +1206,6 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ********************* meta elements ********* */
|
||||
|
@ -421,30 +421,7 @@ void recalcData(TransInfo *t)
|
||||
}
|
||||
}
|
||||
else if (t->obedit) {
|
||||
if (t->obedit->type == OB_MESH) {
|
||||
if(t->spacetype==SPACE_IMAGE) {
|
||||
flushTransUVs(t);
|
||||
if (G.sima->flag & SI_LIVE_UNWRAP)
|
||||
unwrap_lscm_live_re_solve();
|
||||
} else {
|
||||
EditMesh *em = ((Mesh *)t->obedit->data)->edit_mesh
|
||||
/* mirror modifier clipping? */
|
||||
if(t->state != TRANS_CANCEL) {
|
||||
if ((G.qual & LR_CTRLKEY)==0) {
|
||||
/* Only retopo if not snapping, Note, this is the only case of G.qual being used, but we have no T_SHIFT_MOD - Campbell */
|
||||
retopo_do_all();
|
||||
}
|
||||
clipMirrorModifier(t, t->obedit);
|
||||
}
|
||||
if((t->options & CTX_NO_MIRROR) == 0 && (G.scene->toolsettings->editbutflag & B_MESH_X_MIRROR))
|
||||
editmesh_apply_to_mirror(t);
|
||||
|
||||
DAG_object_flush_update(G.scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
|
||||
|
||||
recalc_editnormals(em);
|
||||
}
|
||||
}
|
||||
else if ELEM(t->obedit->type, OB_CURVE, OB_SURF) {
|
||||
if ELEM(t->obedit->type, OB_CURVE, OB_SURF) {
|
||||
Nurb *nu= editNurb.first;
|
||||
DAG_object_flush_update(G.scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
|
||||
|
||||
@ -463,14 +440,68 @@ void recalcData(TransInfo *t)
|
||||
retopo_do_all();
|
||||
}
|
||||
}
|
||||
else if(t->obedit->type==OB_ARMATURE){ /* no recalc flag, does pose */
|
||||
else if(t->obedit->type==OB_LATTICE) {
|
||||
DAG_object_flush_update(G.scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
|
||||
|
||||
if(editLatt->flag & LT_OUTSIDE) outside_lattice(editLatt);
|
||||
}
|
||||
else {
|
||||
DAG_object_flush_update(G.scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
|
||||
}
|
||||
}
|
||||
else if( (t->flag & T_POSE) && t->poseobj) {
|
||||
Object *ob= t->poseobj;
|
||||
bArmature *arm= ob->data;
|
||||
|
||||
/* old optimize trick... this enforces to bypass the depgraph */
|
||||
if (!(arm->flag & ARM_DELAYDEFORM)) {
|
||||
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); /* sets recalc flags */
|
||||
}
|
||||
else
|
||||
where_is_pose(ob);
|
||||
}
|
||||
else if(G.f & G_PARTICLEEDIT) {
|
||||
flushTransParticles(t);
|
||||
}
|
||||
#endif
|
||||
if (t->spacetype==SPACE_NODE) {
|
||||
flushTransNodes(t);
|
||||
}
|
||||
else if (t->obedit) {
|
||||
if (t->obedit->type == OB_MESH) {
|
||||
if(t->spacetype==SPACE_IMAGE) {
|
||||
flushTransUVs(t);
|
||||
/* TRANSFORM_FIX_ME */
|
||||
// if (G.sima->flag & SI_LIVE_UNWRAP)
|
||||
// unwrap_lscm_live_re_solve();
|
||||
} else {
|
||||
EditMesh *em = ((Mesh*)t->obedit->data)->edit_mesh;
|
||||
/* mirror modifier clipping? */
|
||||
if(t->state != TRANS_CANCEL) {
|
||||
/* TRANSFORM_FIX_ME */
|
||||
// if ((G.qual & LR_CTRLKEY)==0) {
|
||||
// /* Only retopo if not snapping, Note, this is the only case of G.qual being used, but we have no T_SHIFT_MOD - Campbell */
|
||||
// retopo_do_all();
|
||||
// }
|
||||
clipMirrorModifier(t, t->obedit);
|
||||
}
|
||||
if((t->options & CTX_NO_MIRROR) == 0 && (t->scene->toolsettings->editbutflag & B_MESH_X_MIRROR))
|
||||
editmesh_apply_to_mirror(t);
|
||||
|
||||
DAG_object_flush_update(t->scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
|
||||
|
||||
recalc_editnormals(em);
|
||||
}
|
||||
}
|
||||
else if(t->obedit->type==OB_ARMATURE) { /* no recalc flag, does pose */
|
||||
bArmature *arm= t->obedit->data;
|
||||
ListBase *edbo = arm->edbo;
|
||||
EditBone *ebo;
|
||||
TransData *td = t->data;
|
||||
int i;
|
||||
|
||||
/* Ensure all bones are correctly adjusted */
|
||||
for (ebo=G.edbo.first; ebo; ebo=ebo->next){
|
||||
for (ebo = edbo->first; ebo; ebo = ebo->next){
|
||||
|
||||
if ((ebo->flag & BONE_CONNECTED) && ebo->parent){
|
||||
/* If this bone has a parent tip that has been moved */
|
||||
@ -531,68 +562,15 @@ void recalcData(TransInfo *t)
|
||||
Mat3MulVecfl(t->mat, up_axis);
|
||||
}
|
||||
|
||||
ebo->roll = rollBoneToVector(ebo, up_axis);
|
||||
ebo->roll = ED_rollBoneToVector(ebo, up_axis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(arm->flag & ARM_MIRROR_EDIT)
|
||||
transform_armature_mirror_update();
|
||||
transform_armature_mirror_update(t->obedit);
|
||||
|
||||
}
|
||||
else if(t->obedit->type==OB_LATTICE) {
|
||||
DAG_object_flush_update(G.scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
|
||||
|
||||
if(editLatt->flag & LT_OUTSIDE) outside_lattice(editLatt);
|
||||
}
|
||||
else {
|
||||
DAG_object_flush_update(G.scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
|
||||
}
|
||||
}
|
||||
else if( (t->flag & T_POSE) && t->poseobj) {
|
||||
Object *ob= t->poseobj;
|
||||
bArmature *arm= ob->data;
|
||||
|
||||
/* old optimize trick... this enforces to bypass the depgraph */
|
||||
if (!(arm->flag & ARM_DELAYDEFORM)) {
|
||||
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); /* sets recalc flags */
|
||||
}
|
||||
else
|
||||
where_is_pose(ob);
|
||||
}
|
||||
else if(G.f & G_PARTICLEEDIT) {
|
||||
flushTransParticles(t);
|
||||
}
|
||||
#endif
|
||||
if (t->spacetype==SPACE_NODE) {
|
||||
flushTransNodes(t);
|
||||
}
|
||||
else if (t->obedit) {
|
||||
if (t->obedit->type == OB_MESH) {
|
||||
if(t->spacetype==SPACE_IMAGE) {
|
||||
flushTransUVs(t);
|
||||
/* TRANSFORM_FIX_ME */
|
||||
// if (G.sima->flag & SI_LIVE_UNWRAP)
|
||||
// unwrap_lscm_live_re_solve();
|
||||
} else {
|
||||
EditMesh *em = ((Mesh*)t->obedit->data)->edit_mesh;
|
||||
/* mirror modifier clipping? */
|
||||
if(t->state != TRANS_CANCEL) {
|
||||
/* TRANSFORM_FIX_ME */
|
||||
// if ((G.qual & LR_CTRLKEY)==0) {
|
||||
// /* Only retopo if not snapping, Note, this is the only case of G.qual being used, but we have no T_SHIFT_MOD - Campbell */
|
||||
// retopo_do_all();
|
||||
// }
|
||||
clipMirrorModifier(t, t->obedit);
|
||||
}
|
||||
if((t->options & CTX_NO_MIRROR) == 0 && (t->scene->toolsettings->editbutflag & B_MESH_X_MIRROR))
|
||||
editmesh_apply_to_mirror(t);
|
||||
|
||||
DAG_object_flush_update(t->scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
|
||||
|
||||
recalc_editnormals(em);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(base= FIRSTBASE; base; base= base->next) {
|
||||
@ -1026,10 +1004,10 @@ void calculateCenter(TransInfo *t)
|
||||
case V3D_ACTIVE:
|
||||
{
|
||||
/* set median, and if if if... do object center */
|
||||
#if 0 // TRANSFORM_FIX_ME
|
||||
EditSelection ese;
|
||||
/* EDIT MODE ACTIVE EDITMODE ELEMENT */
|
||||
|
||||
#if 0 // TRANSFORM_FIX_ME
|
||||
if (t->obedit && t->obedit->type == OB_MESH && EM_get_actSelection(&ese)) {
|
||||
EM_editselection_center(t->center, &ese);
|
||||
calculateCenter2D(t);
|
||||
|
Loading…
Reference in New Issue
Block a user