knife tool: store color once on initializations, de-select only when cutting selected.
This commit is contained in:
parent
617af9d99d
commit
aa02acfe95
@ -71,6 +71,15 @@
|
||||
|
||||
#define KMAXDIST 10 /* max mouse distance from edge before not detecting it */
|
||||
|
||||
typedef struct KnifeColors {
|
||||
unsigned char line[3];
|
||||
unsigned char edge[3];
|
||||
unsigned char curpoint[3];
|
||||
unsigned char curpoint_a[4];
|
||||
unsigned char point[3];
|
||||
unsigned char point_a[4];
|
||||
} KnifeColors;
|
||||
|
||||
/* knifetool operator */
|
||||
typedef struct KnifeVert {
|
||||
BMVert *v; /* non-NULL if this is an original vert */
|
||||
@ -158,13 +167,14 @@ typedef struct knifetool_opdata {
|
||||
|
||||
float projmat[4][4];
|
||||
|
||||
short is_ortho;
|
||||
KnifeColors colors;
|
||||
|
||||
/* operatpr options */
|
||||
char cut_through; /* preference, can be modified at runtime (that feature may go) */
|
||||
char only_select; /* set on initialization */
|
||||
char select_result; /* set on initialization */
|
||||
|
||||
short is_ortho;
|
||||
float clipsta, clipend;
|
||||
|
||||
enum {
|
||||
@ -876,23 +886,19 @@ static void knifetool_draw_angle_snapping(knifetool_opdata *kcd)
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void knife_colors(unsigned char c_line[3],
|
||||
unsigned char c_edge[3],
|
||||
unsigned char c_curpoint[3],
|
||||
unsigned char c_curpoint_a[4],
|
||||
unsigned char c_point[3],
|
||||
unsigned char c_point_a[4]) {
|
||||
/* possible BMESH_TODO: add explicit themes or calculate these by
|
||||
* figuring out constrasting colors with grid / edges / verts
|
||||
* a la UI_make_axis_color */
|
||||
UI_GetThemeColor3ubv(TH_NURB_VLINE, c_line);
|
||||
UI_GetThemeColor3ubv(TH_NURB_ULINE, c_edge);
|
||||
UI_GetThemeColor3ubv(TH_HANDLE_SEL_VECT, c_curpoint);
|
||||
UI_GetThemeColor3ubv(TH_HANDLE_SEL_VECT, c_curpoint_a);
|
||||
c_curpoint_a[3] = 0.4;
|
||||
UI_GetThemeColor3ubv(TH_ACTIVE_SPLINE, c_point);
|
||||
UI_GetThemeColor3ubv(TH_ACTIVE_SPLINE, c_point_a);
|
||||
c_point_a[3] = 0.4;
|
||||
static void knife_init_colors(KnifeColors *colors)
|
||||
{
|
||||
/* possible BMESH_TODO: add explicit themes or calculate these by
|
||||
* figuring out constrasting colors with grid / edges / verts
|
||||
* a la UI_make_axis_color */
|
||||
UI_GetThemeColor3ubv(TH_NURB_VLINE, colors->line);
|
||||
UI_GetThemeColor3ubv(TH_NURB_ULINE, colors->edge);
|
||||
UI_GetThemeColor3ubv(TH_HANDLE_SEL_VECT, colors->curpoint);
|
||||
UI_GetThemeColor3ubv(TH_HANDLE_SEL_VECT, colors->curpoint_a);
|
||||
colors->curpoint_a[3] = 0.4;
|
||||
UI_GetThemeColor3ubv(TH_ACTIVE_SPLINE, colors->point);
|
||||
UI_GetThemeColor3ubv(TH_ACTIVE_SPLINE, colors->point_a);
|
||||
colors->point_a[3] = 0.4;
|
||||
}
|
||||
|
||||
/* modal loop selection drawing callback */
|
||||
@ -900,8 +906,6 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
{
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
knifetool_opdata *kcd = arg;
|
||||
unsigned char c_line[3], c_edge[3], c_curpoint[3], c_point[3];
|
||||
unsigned char c_curpoint_a[4], c_point_a[4];
|
||||
|
||||
if(v3d->zbuf) glDisable(GL_DEPTH_TEST);
|
||||
|
||||
@ -910,13 +914,11 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
glPushMatrix();
|
||||
glMultMatrixf(kcd->ob->obmat);
|
||||
|
||||
knife_colors(c_line, c_edge, c_curpoint, c_curpoint_a, c_point, c_point_a);
|
||||
|
||||
if (kcd->mode == MODE_DRAGGING) {
|
||||
if (kcd->angle_snapping != ANGLE_FREE)
|
||||
knifetool_draw_angle_snapping(kcd);
|
||||
|
||||
glColor3ubv(c_line);
|
||||
glColor3ubv(kcd->colors.line);
|
||||
|
||||
glLineWidth(2.0);
|
||||
|
||||
@ -929,7 +931,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
}
|
||||
|
||||
if (kcd->cur.edge) {
|
||||
glColor3ubv(c_edge);
|
||||
glColor3ubv(kcd->colors.edge);
|
||||
glLineWidth(2.0);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
@ -940,7 +942,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
glLineWidth(1.0);
|
||||
}
|
||||
else if (kcd->cur.vert) {
|
||||
glColor3ubv(c_point);
|
||||
glColor3ubv(kcd->colors.point);
|
||||
glPointSize(11);
|
||||
|
||||
glBegin(GL_POINTS);
|
||||
@ -949,7 +951,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
}
|
||||
|
||||
if (kcd->cur.bmface) {
|
||||
glColor3ubv(c_curpoint);
|
||||
glColor3ubv(kcd->colors.curpoint);
|
||||
glPointSize(9);
|
||||
|
||||
glBegin(GL_POINTS);
|
||||
@ -965,7 +967,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
/* draw any snapped verts first */
|
||||
glColor4ubv(c_point_a);
|
||||
glColor4ubv(kcd->colors.point_a);
|
||||
glPointSize(11);
|
||||
glBegin(GL_POINTS);
|
||||
lh = kcd->linehits;
|
||||
@ -990,7 +992,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
glEnd();
|
||||
|
||||
/* now draw the rest */
|
||||
glColor4ubv(c_curpoint_a);
|
||||
glColor4ubv(kcd->colors.curpoint_a);
|
||||
glPointSize(7);
|
||||
glBegin(GL_POINTS);
|
||||
lh = kcd->linehits;
|
||||
@ -1013,7 +1015,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
if (!kfe->draw)
|
||||
continue;
|
||||
|
||||
glColor3ubv(c_line);
|
||||
glColor3ubv(kcd->colors.line);
|
||||
|
||||
glVertex3fv(kfe->v1->cageco);
|
||||
glVertex3fv(kfe->v2->cageco);
|
||||
@ -1035,7 +1037,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
||||
if (!kfv->draw)
|
||||
continue;
|
||||
|
||||
glColor3ubv(c_point);
|
||||
glColor3ubv(kcd->colors.point);
|
||||
|
||||
glVertex3fv(kfv->cageco);
|
||||
}
|
||||
@ -2655,7 +2657,7 @@ static void knife_make_cuts(knifetool_opdata *kcd)
|
||||
}
|
||||
}
|
||||
|
||||
if (kcd->select_result) {
|
||||
if (kcd->only_select) {
|
||||
EDBM_flag_disable_all(kcd->em, BM_ELEM_SELECT);
|
||||
}
|
||||
|
||||
@ -2845,6 +2847,8 @@ static int knifetool_init(bContext *C, wmOperator *op, int UNUSED(do_cut))
|
||||
knife_pos_data_clear(&kcd->cur);
|
||||
knife_pos_data_clear(&kcd->prev);
|
||||
|
||||
knife_init_colors(&kcd->colors);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user