Split the add_hook function into two parts (user interaction + actual operations)
This commit is contained in:
@@ -120,7 +120,8 @@ void mirrormenu(void);
|
|||||||
void hookmenu(void); /* object mode hook menu */
|
void hookmenu(void); /* object mode hook menu */
|
||||||
|
|
||||||
|
|
||||||
void add_hook(void);
|
void add_hook_menu(void);
|
||||||
|
void add_hook(int mode);
|
||||||
void hook_select(struct HookModifierData *hmd);
|
void hook_select(struct HookModifierData *hmd);
|
||||||
int hook_getIndexArray(int *tot, int **indexar, char *name, float *cent_r);
|
int hook_getIndexArray(int *tot, int **indexar, char *name, float *cent_r);
|
||||||
|
|
||||||
|
|||||||
@@ -632,14 +632,12 @@ int hook_getIndexArray(int *tot, int **indexar, char *name, float *cent_r)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_hook(void)
|
void add_hook_menu(void)
|
||||||
{
|
{
|
||||||
ModifierData *md = NULL;
|
ModifierData *md = NULL;
|
||||||
HookModifierData *hmd = NULL;
|
HookModifierData *hmd = NULL;
|
||||||
Object *ob=NULL;
|
Object *ob=NULL;
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
if(G.obedit==NULL) return;
|
|
||||||
|
|
||||||
if(modifiers_findByType(G.obedit, eModifierType_Hook))
|
if(modifiers_findByType(G.obedit, eModifierType_Hook))
|
||||||
mode= pupmenu("Hooks %t|Add, To New Empty %x1|Add, To Selected Object %x2|Remove... %x3|Reassign... %x4|Select... %x5|Clear Offset...%x6");
|
mode= pupmenu("Hooks %t|Add, To New Empty %x1|Add, To Selected Object %x2|Remove... %x3|Reassign... %x4|Select... %x5|Clear Offset...%x6");
|
||||||
@@ -649,7 +647,6 @@ void add_hook(void)
|
|||||||
if(mode<1) return;
|
if(mode<1) return;
|
||||||
|
|
||||||
/* preconditions */
|
/* preconditions */
|
||||||
|
|
||||||
if(mode==2) { /* selected object */
|
if(mode==2) { /* selected object */
|
||||||
Base *base= FIRSTBASE;
|
Base *base= FIRSTBASE;
|
||||||
while(base) {
|
while(base) {
|
||||||
@@ -706,11 +703,28 @@ void add_hook(void)
|
|||||||
a++;
|
a++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hmd = (HookModifierData*) md;
|
hmd = (HookModifierData*) md;
|
||||||
ob= hmd->object;
|
ob= hmd->object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* do operations */
|
||||||
|
add_hook(mode);
|
||||||
|
|
||||||
|
allqueue(REDRAWVIEW3D, 0);
|
||||||
|
allqueue(REDRAWBUTSOBJECT, 0);
|
||||||
|
|
||||||
|
BIF_undo_push("Add hook");
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_hook(int mode)
|
||||||
|
{
|
||||||
|
ModifierData *md = NULL;
|
||||||
|
HookModifierData *hmd = NULL;
|
||||||
|
Object *ob=NULL;
|
||||||
|
|
||||||
|
if(G.obedit==NULL) return;
|
||||||
|
|
||||||
/* do it, new hooks or reassign */
|
/* do it, new hooks or reassign */
|
||||||
if(mode==1 || mode==2 || mode==4) {
|
if(mode==1 || mode==2 || mode==4) {
|
||||||
float cent[3];
|
float cent[3];
|
||||||
@@ -718,7 +732,7 @@ void add_hook(void)
|
|||||||
char name[32];
|
char name[32];
|
||||||
|
|
||||||
ok = hook_getIndexArray(&tot, &indexar, name, cent);
|
ok = hook_getIndexArray(&tot, &indexar, name, cent);
|
||||||
|
|
||||||
if(ok==0) {
|
if(ok==0) {
|
||||||
error("Requires selected vertices or active Vertex Group");
|
error("Requires selected vertices or active Vertex Group");
|
||||||
}
|
}
|
||||||
@@ -726,7 +740,7 @@ void add_hook(void)
|
|||||||
|
|
||||||
if(mode==1) {
|
if(mode==1) {
|
||||||
Base *base= BASACT, *newbase;
|
Base *base= BASACT, *newbase;
|
||||||
|
|
||||||
ob= add_object(OB_EMPTY);
|
ob= add_object(OB_EMPTY);
|
||||||
/* set layers OK */
|
/* set layers OK */
|
||||||
newbase= BASACT;
|
newbase= BASACT;
|
||||||
@@ -740,15 +754,15 @@ void add_hook(void)
|
|||||||
BASACT= base;
|
BASACT= base;
|
||||||
}
|
}
|
||||||
/* if mode is 2 or 4, ob has been set */
|
/* if mode is 2 or 4, ob has been set */
|
||||||
|
|
||||||
/* new hook */
|
/* new hook */
|
||||||
if(mode==1 || mode==2) {
|
if(mode==1 || mode==2) {
|
||||||
ModifierData *md = G.obedit->modifiers.first;
|
ModifierData *md = G.obedit->modifiers.first;
|
||||||
|
|
||||||
while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) {
|
while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) {
|
||||||
md = md->next;
|
md = md->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
hmd = (HookModifierData*) modifier_new(eModifierType_Hook);
|
hmd = (HookModifierData*) modifier_new(eModifierType_Hook);
|
||||||
BLI_insertlinkbefore(&G.obedit->modifiers, md, hmd);
|
BLI_insertlinkbefore(&G.obedit->modifiers, md, hmd);
|
||||||
sprintf(hmd->modifier.name, "Hook-%s", ob->id.name+2);
|
sprintf(hmd->modifier.name, "Hook-%s", ob->id.name+2);
|
||||||
@@ -767,7 +781,7 @@ void add_hook(void)
|
|||||||
/* (parentinv ) */
|
/* (parentinv ) */
|
||||||
|
|
||||||
where_is_object(ob);
|
where_is_object(ob);
|
||||||
|
|
||||||
Mat4Invert(ob->imat, ob->obmat);
|
Mat4Invert(ob->imat, ob->obmat);
|
||||||
/* apparently this call goes from right to left... */
|
/* apparently this call goes from right to left... */
|
||||||
Mat4MulSerie(hmd->parentinv, ob->imat, G.obedit->obmat, NULL,
|
Mat4MulSerie(hmd->parentinv, ob->imat, G.obedit->obmat, NULL,
|
||||||
@@ -784,18 +798,14 @@ void add_hook(void)
|
|||||||
}
|
}
|
||||||
else if(mode==6) { /* clear offset */
|
else if(mode==6) { /* clear offset */
|
||||||
where_is_object(ob); /* ob is hook->parent */
|
where_is_object(ob); /* ob is hook->parent */
|
||||||
|
|
||||||
Mat4Invert(ob->imat, ob->obmat);
|
Mat4Invert(ob->imat, ob->obmat);
|
||||||
/* this call goes from right to left... */
|
/* this call goes from right to left... */
|
||||||
Mat4MulSerie(hmd->parentinv, ob->imat, G.obedit->obmat, NULL,
|
Mat4MulSerie(hmd->parentinv, ob->imat, G.obedit->obmat, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
allqueue(REDRAWVIEW3D, 0);
|
|
||||||
allqueue(REDRAWBUTSOBJECT, 0);
|
|
||||||
DAG_scene_sort(G.scene);
|
DAG_scene_sort(G.scene);
|
||||||
|
|
||||||
BIF_undo_push("Add hook");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void make_track(void)
|
void make_track(void)
|
||||||
|
|||||||
@@ -2609,7 +2609,7 @@ void do_view3d_edit_mesh_verticesmenu(void *arg, int event)
|
|||||||
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
|
||||||
break;
|
break;
|
||||||
case 6: /* add hook */
|
case 6: /* add hook */
|
||||||
add_hook();
|
add_hook_menu();
|
||||||
break;
|
break;
|
||||||
case 7: /* rip */
|
case 7: /* rip */
|
||||||
mesh_rip();
|
mesh_rip();
|
||||||
@@ -3195,7 +3195,7 @@ static void do_view3d_edit_curve_controlpointsmenu(void *arg, int event)
|
|||||||
make_parent();
|
make_parent();
|
||||||
break;
|
break;
|
||||||
case 6: /* add hook */
|
case 6: /* add hook */
|
||||||
add_hook();
|
add_hook_menu();
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
separate_nurb();
|
separate_nurb();
|
||||||
|
|||||||
@@ -2009,7 +2009,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
|||||||
if(G.obedit) {
|
if(G.obedit) {
|
||||||
if(G.obedit->type==OB_MESH) {
|
if(G.obedit->type==OB_MESH) {
|
||||||
if(G.qual==LR_CTRLKEY)
|
if(G.qual==LR_CTRLKEY)
|
||||||
add_hook();
|
add_hook_menu();
|
||||||
else if(G.qual==LR_ALTKEY)
|
else if(G.qual==LR_ALTKEY)
|
||||||
reveal_mesh();
|
reveal_mesh();
|
||||||
else if((G.qual==LR_SHIFTKEY))
|
else if((G.qual==LR_SHIFTKEY))
|
||||||
@@ -2019,7 +2019,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
|||||||
}
|
}
|
||||||
else if(G.obedit->type== OB_SURF) {
|
else if(G.obedit->type== OB_SURF) {
|
||||||
if(G.qual==LR_CTRLKEY)
|
if(G.qual==LR_CTRLKEY)
|
||||||
add_hook();
|
add_hook_menu();
|
||||||
else if(G.qual==LR_ALTKEY)
|
else if(G.qual==LR_ALTKEY)
|
||||||
revealNurb();
|
revealNurb();
|
||||||
else if((G.qual==LR_SHIFTKEY))
|
else if((G.qual==LR_SHIFTKEY))
|
||||||
@@ -2029,7 +2029,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
|||||||
}
|
}
|
||||||
else if(G.obedit->type==OB_CURVE) {
|
else if(G.obedit->type==OB_CURVE) {
|
||||||
if(G.qual==LR_CTRLKEY)
|
if(G.qual==LR_CTRLKEY)
|
||||||
add_hook();
|
add_hook_menu();
|
||||||
else if(G.qual==LR_ALTKEY)
|
else if(G.qual==LR_ALTKEY)
|
||||||
revealNurb();
|
revealNurb();
|
||||||
/* should be G.qual==LR_SHIFTKEY, but that is taken fro handles already */
|
/* should be G.qual==LR_SHIFTKEY, but that is taken fro handles already */
|
||||||
@@ -2052,7 +2052,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(G.obedit->type==OB_LATTICE) {
|
else if(G.obedit->type==OB_LATTICE) {
|
||||||
if(G.qual==LR_CTRLKEY) add_hook();
|
if(G.qual==LR_CTRLKEY) add_hook_menu();
|
||||||
}
|
}
|
||||||
else if(G.obedit->type==OB_MBALL) {
|
else if(G.obedit->type==OB_MBALL) {
|
||||||
if(G.qual==LR_ALTKEY)
|
if(G.qual==LR_ALTKEY)
|
||||||
|
|||||||
Reference in New Issue
Block a user