diff options
author | Daniel Dunbar <daniel@zuster.org> | 2005-08-14 11:02:51 +0400 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2005-08-14 11:02:51 +0400 |
commit | 0721727887f4ae3e34bf7d37b63be0d8e10bf07d (patch) | |
tree | d2b2146f876f2268dbe54a0285c24ec7b459aaf3 | |
parent | 93aeb6b318a7ec8022e14bba7f9ab98aae0aab6e (diff) |
- added hook "cursor center" feature (sets hook center to cursor position),
gives better control over falloff
- added modifier UI access to hook "select" and "reassign" features
- bug fix, unbroke path-tilt drawing
-rw-r--r-- | source/blender/include/BDR_editobject.h | 3 | ||||
-rw-r--r-- | source/blender/src/buttons_editing.c | 70 | ||||
-rw-r--r-- | source/blender/src/drawobject.c | 2 | ||||
-rw-r--r-- | source/blender/src/editobject.c | 43 |
4 files changed, 96 insertions, 22 deletions
diff --git a/source/blender/include/BDR_editobject.h b/source/blender/include/BDR_editobject.h index f6abd6707f1..2ac7bfa8910 100644 --- a/source/blender/include/BDR_editobject.h +++ b/source/blender/include/BDR_editobject.h @@ -37,6 +37,7 @@ struct Object; struct Tex; struct Material; struct Base; +struct HookModifierData; void add_object_draw(int type); void add_objectLamp(short type); @@ -105,6 +106,8 @@ void mirrormenu(void); void add_hook(void); +void hook_select(struct HookModifierData *hmd); +int hook_getIndexArray(int **indexar, float *cent_r); #endif /* BDR_EDITOBJECT_H */ diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index d984f5bd994..e25ae44b3a5 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -785,6 +785,59 @@ static void modifiers_clearHookOffset(void *ob_v, void *md_v) } } +static void modifiers_cursorHookCenter(void *ob_v, void *md_v) +{ + Object *ob = ob_v; + ModifierData *md = md_v; + HookModifierData *hmd = (HookModifierData*) md; + + if (G.vd) { + float *curs = give_cursor(); + float bmat[3][3], imat[3][3]; + + where_is_object(ob); + + Mat3CpyMat4(bmat, ob->obmat); + Mat3Inv(imat, bmat); + + curs= give_cursor(); + hmd->cent[0]= curs[0]-ob->obmat[3][0]; + hmd->cent[1]= curs[1]-ob->obmat[3][1]; + hmd->cent[2]= curs[2]-ob->obmat[3][2]; + Mat3MulVecfl(imat, hmd->cent); + } +} + +static void modifiers_selectHook(void *ob_v, void *md_v) +{ + Object *ob = ob_v; + ModifierData *md = md_v; + HookModifierData *hmd = (HookModifierData*) md; + + hook_select(hmd); +} + +static void modifiers_reassignHook(void *ob_v, void *md_v) +{ + Object *ob = ob_v; + ModifierData *md = md_v; + HookModifierData *hmd = (HookModifierData*) md; + float cent[3]; + int *indexar, tot = hook_getIndexArray(&indexar, cent); + + if (!tot) { + error("Requires selected vertices"); + } else { + if (hmd->indexar) { + MEM_freeN(hmd->indexar); + } + + VECCOPY(hmd->cent, cent); + hmd->indexar = indexar; + hmd->totindex = tot; + } +} + static void modifiers_convertToReal(void *ob_v, void *md_v) { Object *ob = ob_v; @@ -804,8 +857,8 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco ModifierTypeInfo *mti = modifierType_getInfo(md->type); int isVirtual = md->mode&eModifierMode_Virtual; int x = *xco, y = *yco, color = md->error?TH_REDALERT:TH_BUT_NEUTRAL; - short height = 86; - short width = 295; + int editing = (G.obedit==ob); + short height, width = 295; char str[128]; uiBut *but; @@ -915,6 +968,8 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco height = 46; } else if (md->type==eModifierType_Hook) { height = 86; + if (editing) + height += 20; } else if (md->type==eModifierType_Softbody) { height = 26; } @@ -1005,8 +1060,17 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco uiDefButF(block, NUM, B_MODIFIER_RECALC, "Falloff: ", lx, (cy-=19), 160,19, &hmd->falloff, 0.0, 100.0, 100, 0, "If not zero, the distance from hook where influence ends"); uiDefButF(block, NUMSLI, B_MODIFIER_RECALC, "Force: ", lx, (cy-=19), 160,19, &hmd->force, 0.0, 1.0, 100, 0, "Set relative force of hook"); uiDefIDPoinBut(block, test_obpoin_but, B_CHANGEDEP, "Ob: ", lx, (cy-=19), 160,19, &hmd->object, "Parent Object for hook, also recalculates and clears offset"); - but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Clear offset", lx, (cy-=19), 160,19, NULL, 0.0, 0.0, 0, 0, "Recalculate and clear offset (transform) of hook"); + but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Clear offset", lx, (cy-=19), 80,19, NULL, 0.0, 0.0, 0, 0, "Recalculate and clear offset (transform) of hook"); uiButSetFunc(but, modifiers_clearHookOffset, ob, md); + but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Cursor center", lx+80, cy, 80,19, NULL, 0.0, 0.0, 0, 0, "Sets hook center to cursor position"); + uiButSetFunc(but, modifiers_cursorHookCenter, ob, md); + + if (editing) { + but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Select", lx, (cy-=19), 80,19, NULL, 0.0, 0.0, 0, 0, "Selects effected vertices on mesh"); + uiButSetFunc(but, modifiers_selectHook, ob, md); + but = uiDefBut(block, BUT, B_MODIFIER_RECALC, "Reassign", lx+80, cy, 80,19, NULL, 0.0, 0.0, 0, 0, "Reassigns selected vertices to hook"); + uiButSetFunc(but, modifiers_reassignHook, ob, md); + } } else if (md->type==eModifierType_Softbody) { uiDefBut(block, LABEL, 1, "See Softbody panel.", lx, (cy-=19), 160,19, NULL, 0.0, 0.0, 0, 0, ""); } diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index eed2ce037ee..84689309002 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -2749,7 +2749,7 @@ static void drawnurb(Object *ob, Nurb *nurb, int dt) BIF_ThemeColor(TH_WIRE); glBegin(GL_LINES); for (bl=cu->bev.first,nu=nurb; nu && bl; bl=bl->next,nu=nu->next) { - BevPoint *bevp= (BevPoint *)(&bl+1); + BevPoint *bevp= (BevPoint *)(bl+1); int nr= bl->nr; int skip= nu->resolu/16; diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 419f4ee833b..38b795326c4 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -500,6 +500,28 @@ static void select_editcurve_hook(HookModifierData *hmd) } } +void hook_select(HookModifierData *hmd) +{ + if(G.obedit->type==OB_MESH) select_editmesh_hook(hmd); + else if(G.obedit->type==OB_LATTICE) select_editlattice_hook(hmd); + else if(G.obedit->type==OB_CURVE) select_editcurve_hook(hmd); + else if(G.obedit->type==OB_SURF) select_editcurve_hook(hmd); +} +int hook_getIndexArray(int **indexar, float *cent_r) +{ + switch(G.obedit->type) { + case OB_MESH: + return return_editmesh_indexar(indexar, cent_r); + case OB_CURVE: + case OB_SURF: + return return_editcurve_indexar(indexar, cent_r); + case OB_LATTICE: + return return_editlattice_indexar(indexar, cent_r); + default: + return 0; + } +} + void add_hook(void) { ModifierData *md = NULL; @@ -582,20 +604,8 @@ void add_hook(void) /* do it, new hooks or reassign */ if(mode==1 || mode==2 || mode==4) { - - switch(G.obedit->type) { - case OB_MESH: - tot= return_editmesh_indexar(&indexar, cent); - break; - case OB_CURVE: - case OB_SURF: - tot= return_editcurve_indexar(&indexar, cent); - break; - case OB_LATTICE: - tot= return_editlattice_indexar(&indexar, cent); - break; - } - + tot = hook_getIndexArray(&indexar, cent); + if(tot==0) { error("Requires selected vertices"); } @@ -656,10 +666,7 @@ void add_hook(void) modifier_free(md); } else if(mode==5) { // select - if(G.obedit->type==OB_MESH) select_editmesh_hook(hmd); - else if(G.obedit->type==OB_LATTICE) select_editlattice_hook(hmd); - else if(G.obedit->type==OB_CURVE) select_editcurve_hook(hmd); - else if(G.obedit->type==OB_SURF) select_editcurve_hook(hmd); + hook_select(hmd); } else if(mode==6) { // clear offset where_is_object(ob); // ob is hook->parent |