Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-06-10 00:28:08 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-06-10 00:28:08 +0400
commiteabb30a2367808c163a90d658c5be586530098ec (patch)
treee3d1a20fad111127c3c20c3450b003553b171db5 /source
parent28add50083204e99121c5290242652ccd3fcca9e (diff)
patch [#35631] Active element for Lattice
by Kevin Mackay (yakca) Was one of our TODO's from the wiki.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_lattice.h1
-rw-r--r--source/blender/blenkernel/intern/lattice.c20
-rw-r--r--source/blender/editors/object/object_lattice.c18
-rw-r--r--source/blender/editors/object/object_vgroup.c8
-rw-r--r--source/blender/editors/space_view3d/drawobject.c20
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c8
-rw-r--r--source/blender/editors/transform/transform_conversions.c8
-rw-r--r--source/blender/editors/transform/transform_generics.c9
-rw-r--r--source/blender/editors/transform/transform_manipulator.c24
-rw-r--r--source/blender/makesdna/DNA_lattice_types.h6
10 files changed, 100 insertions, 22 deletions
diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h
index b195af18a8e..b0bf9513814 100644
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@ -75,6 +75,7 @@ void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]);
void BKE_lattice_modifiers_calc(struct Scene *scene, struct Object *ob);
struct MDeformVert *BKE_lattice_deform_verts_get(struct Object *lattice);
+struct BPoint *BKE_lattice_active_point_get(struct Lattice *lt);
void BKE_lattice_minmax(struct Lattice *lt, float min[3], float max[3]);
void BKE_lattice_center_median(struct Lattice *lt, float cent[3]);
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index dac6ba4a0f3..feb82a34708 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -168,6 +168,7 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
lt->pntsv = vNew;
lt->pntsw = wNew;
+ lt->actbp = LT_ACTBP_NONE;
MEM_freeN(lt->def);
lt->def = MEM_callocN(lt->pntsu * lt->pntsv * lt->pntsw * sizeof(BPoint), "lattice bp");
@@ -192,6 +193,7 @@ Lattice *BKE_lattice_add(Main *bmain, const char *name)
lt->def = MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */
BKE_lattice_resize(lt, 2, 2, 2, NULL); /* creates a uniform lattice */
+ lt->actbp = LT_ACTBP_NONE;
return lt;
}
@@ -1012,6 +1014,24 @@ struct MDeformVert *BKE_lattice_deform_verts_get(struct Object *oblatt)
return lt->dvert;
}
+struct BPoint *BKE_lattice_active_point_get(Lattice *lt)
+{
+ BLI_assert(GS(lt->id.name) == ID_LT);
+
+ if (lt->editlatt) {
+ lt = lt->editlatt->latt;
+ }
+
+ BLI_assert(lt->actbp < lt->pntsu * lt->pntsv * lt->pntsw);
+
+ if ((lt->actbp != LT_ACTBP_NONE) && (lt->actbp < lt->pntsu * lt->pntsv * lt->pntsw)) {
+ return &lt->def[lt->actbp];
+ }
+ else {
+ return NULL;
+ }
+}
+
void BKE_lattice_center_median(struct Lattice *lt, float cent[3])
{
int i, numVerts;
diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c
index 9d3b2b7272d..d3537051861 100644
--- a/source/blender/editors/object/object_lattice.c
+++ b/source/blender/editors/object/object_lattice.c
@@ -154,6 +154,7 @@ void load_editLatt(Object *obedit)
lt->typeu = editlt->typeu;
lt->typev = editlt->typev;
lt->typew = editlt->typew;
+ lt->actbp = editlt->actbp;
}
if (lt->dvert) {
@@ -180,7 +181,8 @@ void ED_setflagsLatt(Object *obedit, int flag)
bp = lt->editlatt->latt->def;
a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
-
+ lt->editlatt->latt->actbp = LT_ACTBP_NONE;
+
while (a--) {
if (bp->hide == 0) {
bp->f1 = flag;
@@ -224,6 +226,7 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op)
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 = LT_ACTBP_NONE;
while (a--) {
if (bp->hide == 0) {
@@ -642,8 +645,10 @@ bool mouse_lattice(bContext *C, const int mval[2], bool extend, bool deselect, b
{
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 +666,13 @@ bool mouse_lattice(bContext *C, const int mval[2], bool extend, bool deselect, b
bp->f1 |= SELECT;
}
+ if (bp->f1 & SELECT) {
+ lt->actbp = bp - lt->def;
+ }
+ else {
+ lt->actbp = LT_ACTBP_NONE;
+ }
+
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data);
return true;
@@ -673,7 +685,7 @@ bool mouse_lattice(bContext *C, const int mval[2], bool extend, bool deselect, b
typedef struct UndoLattice {
BPoint *def;
- int pntsu, pntsv, pntsw;
+ int pntsu, pntsv, pntsw, actbp;
} UndoLattice;
static void undoLatt_to_editLatt(void *data, void *edata, void *UNUSED(obdata))
@@ -683,6 +695,7 @@ static void undoLatt_to_editLatt(void *data, void *edata, void *UNUSED(obdata))
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))
@@ -694,6 +707,7 @@ static void *editLatt_to_undoLatt(void *edata, void *UNUSED(obdata))
ult->pntsu = editlatt->latt->pntsu;
ult->pntsv = editlatt->latt->pntsv;
ult->pntsw = editlatt->latt->pntsw;
+ ult->actbp = editlatt->latt->actbp;
return ult;
}
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 437bea07069..54ef65ab3fb 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -65,6 +65,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_object_deform.h"
#include "BKE_object.h"
+#include "BKE_lattice.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -1108,7 +1109,7 @@ static void vgroup_select_verts(Object *ob, int select)
if (lt->dvert) {
MDeformVert *dv;
- BPoint *bp;
+ BPoint *bp, *actbp = BKE_lattice_active_point_get(lt);
int a, tot;
dv = lt->dvert;
@@ -1117,7 +1118,10 @@ static void vgroup_select_verts(Object *ob, int select)
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 (actbp && bp == actbp) lt->actbp = LT_ACTBP_NONE;
+ }
}
}
}
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 662437b72b9..7df05cc1692 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -1847,13 +1847,15 @@ static void drawspeaker(Scene *UNUSED(scene), View3D *UNUSED(v3d), RegionView3D
glDisable(GL_BLEND);
}
-static void lattice_draw_verts(Lattice *lt, DispList *dl, short sel)
+static void lattice_draw_verts(Lattice *lt, DispList *dl, BPoint *actbp, short sel)
{
BPoint *bp = lt->def;
float *co = dl ? dl->verts : NULL;
int u, v, w;
- UI_ThemeColor(sel ? TH_VERTEX_SELECT : TH_VERTEX);
+ const int color = sel ? TH_VERTEX_SELECT : TH_VERTEX;
+ UI_ThemeColor(color);
+
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
bglBegin(GL_POINTS);
@@ -1865,7 +1867,13 @@ static void lattice_draw_verts(Lattice *lt, DispList *dl, short sel)
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 == 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);
}
}
@@ -1954,10 +1962,12 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob)
glShadeModel(GL_FLAT);
if (is_edit) {
+ BPoint *actbp = BKE_lattice_active_point_get(lt);
+
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
- lattice_draw_verts(lt, dl, 0);
- lattice_draw_verts(lt, dl, 1);
+ lattice_draw_verts(lt, dl, actbp, 0);
+ lattice_draw_verts(lt, dl, actbp, 1);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
}
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index c864a3a78b4..d243f355b5c 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -1015,6 +1015,14 @@ static int snap_curs_to_active(bContext *C, wmOperator *UNUSED(op))
mul_m4_v3(obedit->obmat, curs);
}
+ else if (obedit->type == OB_LATTICE) {
+ BPoint *actbp = BKE_lattice_active_point_get(obedit->data);
+
+ if (actbp) {
+ copy_v3_v3(curs, actbp->vec);
+ mul_m4_v3(obedit->obmat, curs);
+ }
+ }
}
else {
if (obact) {
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index f0abd0743ac..2b99405c749 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -91,6 +91,7 @@
#include "BKE_editmesh.h"
#include "BKE_tracking.h"
#include "BKE_mask.h"
+#include "BKE_lattice.h"
#include "BIK_api.h"
@@ -1554,7 +1555,7 @@ static void createTransLatticeVerts(TransInfo *t)
{
Lattice *latt = ((Lattice *)t->obedit->data)->editlatt->latt;
TransData *td = NULL;
- BPoint *bp;
+ BPoint *bp, *actbp = BKE_lattice_active_point_get(latt);
float mtx[3][3], smtx[3][3];
int a;
int count = 0, countsel = 0;
@@ -1589,7 +1590,10 @@ static void createTransLatticeVerts(TransInfo *t)
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 (actbp && bp == actbp) td->flag |= TD_ACTIVE;
+ }
else td->flag = 0;
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index abd19bc3121..a2957263ba9 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1641,6 +1641,15 @@ void calculateCenter(TransInfo *t)
break;
}
}
+ else if (t->obedit && t->obedit->type == OB_LATTICE) {
+ BPoint *actbp = BKE_lattice_active_point_get(t->obedit->data);
+
+ if (actbp) {
+ copy_v3_v3(t->center, actbp->vec);
+ calculateCenter2D(t);
+ break;
+ }
+ }
} /* END EDIT MODE ACTIVE ELEMENT */
calculateCenterMedian(t);
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index f336fc4651b..d1d40689a4a 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -65,6 +65,7 @@
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_editmesh.h"
+#include "BKE_lattice.h"
#include "BIF_gl.h"
@@ -469,18 +470,23 @@ int calc_manipulator_stats(const bContext *C)
}
}
else if (obedit->type == OB_LATTICE) {
+ Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
BPoint *bp;
- Lattice *lt = obedit->data;
- 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 = BKE_lattice_active_point_get(lt))) {
+ calc_tw_center(scene, bp->vec);
+ totsel++;
+ }
+ else {
+ bp = lt->def;
+ a = lt->pntsu * lt->pntsv * lt->pntsw;
+ while (a--) {
+ if (bp->f1 & SELECT) {
+ calc_tw_center(scene, bp->vec);
+ totsel++;
+ }
+ bp++;
}
- bp++;
}
}
diff --git a/source/blender/makesdna/DNA_lattice_types.h b/source/blender/makesdna/DNA_lattice_types.h
index 1b4bd53151b..500b4ab88c3 100644
--- a/source/blender/makesdna/DNA_lattice_types.h
+++ b/source/blender/makesdna/DNA_lattice_types.h
@@ -56,8 +56,8 @@ typedef struct Lattice {
short pntsu, pntsv, pntsw, flag;
short opntsu, opntsv, opntsw, pad2;
char typeu, typev, typew, pad3;
- int pad;
-
+ int actbp; /* active element index, unset with LT_ACTBP_NONE */
+
float fu, fv, fw, du, dv, dw;
struct BPoint *def;
@@ -85,5 +85,7 @@ typedef struct Lattice {
#define LT_INDEX(lt, u, v, w) ((w) * ((lt)->pntsu * (lt)->pntsv) + ((v) * (lt)->pntsu) + (u))
+#define LT_ACTBP_NONE -1
+
#endif