Index: source/blender/editors/transform/transform_conversions.c =================================================================== --- source/blender/editors/transform/transform_conversions.c (revision 57242) +++ source/blender/editors/transform/transform_conversions.c (working copy) @@ -1589,7 +1589,10 @@ copy_v3_v3(td->iloc, bp->vec); td->loc = bp->vec; copy_v3_v3(td->center, td->loc); - if (bp->f1 & SELECT) td->flag = TD_SELECTED; + if (bp->f1 & SELECT) { + td->flag = TD_SELECTED; + if (bp == latt->actbp) td->flag |= TD_ACTIVE; + } else td->flag = 0; copy_m3_m3(td->smtx, smtx); copy_m3_m3(td->mtx, mtx); Index: source/blender/editors/transform/transform_manipulator.c =================================================================== --- source/blender/editors/transform/transform_manipulator.c (revision 57242) +++ source/blender/editors/transform/transform_manipulator.c (working copy) @@ -469,18 +469,23 @@ } } else if (obedit->type == OB_LATTICE) { - BPoint *bp; Lattice *lt = obedit->data; + BPoint *bp = lt->editlatt->latt->actbp; - bp = lt->editlatt->latt->def; - - a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; - while (a--) { - if (bp->f1 & SELECT) { - calc_tw_center(scene, bp->vec); - totsel++; + if (v3d->around == V3D_ACTIVE && bp) { + calc_tw_center(scene, bp->vec); + totsel++; + } + else { + bp = lt->editlatt->latt->def; + a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; + while (a--) { + if (bp->f1 & SELECT) { + calc_tw_center(scene, bp->vec); + totsel++; + } + bp++; } - bp++; } } Index: source/blender/editors/transform/transform_generics.c =================================================================== --- source/blender/editors/transform/transform_generics.c (revision 57242) +++ source/blender/editors/transform/transform_generics.c (working copy) @@ -1641,6 +1641,15 @@ break; } } + else if (t->obedit && t->obedit->type == OB_LATTICE) { + Lattice *lt = ((Lattice *)(t->obedit->data))->editlatt->latt; + + if (lt->actbp) { + copy_v3_v3(t->center, lt->actbp->vec); + calculateCenter2D(t); + break; + } + } } /* END EDIT MODE ACTIVE ELEMENT */ calculateCenterMedian(t); Index: source/blender/editors/space_view3d/view3d_snap.c =================================================================== --- source/blender/editors/space_view3d/view3d_snap.c (revision 57242) +++ source/blender/editors/space_view3d/view3d_snap.c (working copy) @@ -1015,6 +1015,14 @@ mul_m4_v3(obedit->obmat, curs); } + else if (obedit->type == OB_LATTICE) { + Lattice *lt = ((Lattice *)(obedit->data))->editlatt->latt; + + if (lt->actbp) { + copy_v3_v3(curs, lt->actbp->vec); + mul_m4_v3(obedit->obmat, curs); + } + } } else { if (obact) { Index: source/blender/editors/space_view3d/drawobject.c =================================================================== --- source/blender/editors/space_view3d/drawobject.c (revision 57242) +++ source/blender/editors/space_view3d/drawobject.c (working copy) @@ -1847,13 +1847,16 @@ glDisable(GL_BLEND); } +/* draw verts of lattice in editmode - assumes editlatt exists */ static void lattice_draw_verts(Lattice *lt, DispList *dl, short sel) { BPoint *bp = lt->def; float *co = dl ? dl->verts : NULL; int u, v, w; - UI_ThemeColor(sel ? TH_VERTEX_SELECT : TH_VERTEX); + short color = sel ? TH_VERTEX_SELECT : TH_VERTEX; + UI_ThemeColor(color); + glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); bglBegin(GL_POINTS); @@ -1865,9 +1868,15 @@ int uxt = (u == 0 || u == lt->pntsu - 1); if (!(lt->flag & LT_OUTSIDE) || uxt || vxt || wxt) { if (bp->hide == 0) { - if ((bp->f1 & SELECT) == sel) { + /* check for active BPoint and ensure selected */ + if (bp == lt->editlatt->latt->actbp && bp->f1 == SELECT) { + UI_ThemeColor(TH_LASTSEL_POINT); bglVertex3fv(dl ? co : bp->vec); + UI_ThemeColor(color); } + else if ((bp->f1 & SELECT) == sel) { + bglVertex3fv(dl ? co : bp->vec); + } } } } Index: source/blender/editors/object/object_vgroup.c =================================================================== --- source/blender/editors/object/object_vgroup.c (revision 57242) +++ source/blender/editors/object/object_vgroup.c (working copy) @@ -1117,7 +1117,10 @@ for (a = 0, bp = lt->def; a < tot; a++, bp++, dv++) { if (defvert_find_index(dv, def_nr)) { if (select) bp->f1 |= SELECT; - else bp->f1 &= ~SELECT; + else { + bp->f1 &= ~SELECT; + if (bp == lt->actbp) lt->actbp = NULL; + } } } } Index: source/blender/editors/object/object_lattice.c =================================================================== --- source/blender/editors/object/object_lattice.c (revision 57242) +++ source/blender/editors/object/object_lattice.c (working copy) @@ -102,6 +102,14 @@ lt->editlatt->latt = MEM_dupallocN(lt); lt->editlatt->latt->def = MEM_dupallocN(lt->def); + if (lt->actbp) { + /* get new address for actbp */ + lt->editlatt->latt->actbp = <->editlatt->latt->def[lt->actbp - lt->def]; + } + else { + lt->editlatt->latt->actbp = NULL; + } + if (lt->dvert) { int tot = lt->pntsu * lt->pntsv * lt->pntsw; lt->editlatt->latt->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert"); @@ -145,6 +153,14 @@ lt->def = MEM_dupallocN(editlt->def); + if (editlt->actbp) { + /* get new address for actbp */ + lt->actbp = <->def[editlt->actbp - editlt->def]; + } + else { + lt->actbp = NULL; + } + lt->flag = editlt->flag; lt->pntsu = editlt->pntsu; @@ -176,11 +192,11 @@ Lattice *lt = obedit->data; BPoint *bp; int a; - + bp = lt->editlatt->latt->def; - a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; - + lt->editlatt->latt->actbp = NULL; + while (a--) { if (bp->hide == 0) { bp->f1 = flag; @@ -224,6 +240,7 @@ case SEL_INVERT: bp = lt->editlatt->latt->def; a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; + lt->editlatt->latt->actbp = NULL; while (a--) { if (bp->hide == 0) { @@ -642,8 +659,11 @@ { ViewContext vc; BPoint *bp = NULL; + Lattice *lt; view3d_set_viewcontext(C, &vc); + lt = ((Lattice *)vc.obedit->data)->editlatt->latt; + bp = findnearestLattvert(&vc, mval, TRUE); if (bp) { @@ -661,6 +681,13 @@ bp->f1 |= SELECT; } + if (bp == lt->actbp && bp->f1 != SELECT) { + lt->actbp = NULL; + } + else if (bp->f1 == SELECT) { + lt->actbp = bp; + } + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data); return true; @@ -672,7 +699,7 @@ /******************************** Undo *************************/ typedef struct UndoLattice { - BPoint *def; + BPoint *def, *actbp; int pntsu, pntsv, pntsw; } UndoLattice; @@ -683,6 +710,7 @@ int a = editlatt->latt->pntsu * editlatt->latt->pntsv * editlatt->latt->pntsw; memcpy(editlatt->latt->def, ult->def, a * sizeof(BPoint)); + editlatt->latt->actbp = ult->actbp; } static void *editLatt_to_undoLatt(void *edata, void *UNUSED(obdata)) @@ -691,6 +719,7 @@ EditLatt *editlatt = (EditLatt *)edata; ult->def = MEM_dupallocN(editlatt->latt->def); + ult->actbp = editlatt->latt->actbp; ult->pntsu = editlatt->latt->pntsu; ult->pntsv = editlatt->latt->pntsv; ult->pntsw = editlatt->latt->pntsw; Index: source/blender/makesdna/DNA_lattice_types.h =================================================================== --- source/blender/makesdna/DNA_lattice_types.h (revision 57242) +++ source/blender/makesdna/DNA_lattice_types.h (working copy) @@ -60,7 +60,7 @@ float fu, fv, fw, du, dv, dw; - struct BPoint *def; + struct BPoint *def, *actbp; struct Ipo *ipo DNA_DEPRECATED; /* old animation system, deprecated for 2.5 */ struct Key *key; Index: source/blender/blenkernel/intern/lattice.c =================================================================== --- source/blender/blenkernel/intern/lattice.c (revision 57242) +++ source/blender/blenkernel/intern/lattice.c (working copy) @@ -168,6 +168,7 @@ lt->pntsv = vNew; lt->pntsw = wNew; + lt->actbp = NULL; MEM_freeN(lt->def); lt->def = MEM_callocN(lt->pntsu * lt->pntsv * lt->pntsw * sizeof(BPoint), "lattice bp"); @@ -192,6 +193,7 @@ lt->def = MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */ BKE_lattice_resize(lt, 2, 2, 2, NULL); /* creates a uniform lattice */ + lt->actbp = NULL; return lt; } @@ -213,6 +215,7 @@ } ltn->editlatt = NULL; + ltn->actbp = NULL; return ltn; }