Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/drawobject.c
| Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | |||||
| typedef struct drawDMEdgesSelInterp_userData { | typedef struct drawDMEdgesSelInterp_userData { | ||||
| BMesh *bm; | BMesh *bm; | ||||
| unsigned char *baseCol, *selCol; | unsigned char *baseCol, *selCol; | ||||
| unsigned char *lastCol; | unsigned char *lastCol; | ||||
| } drawDMEdgesSelInterp_userData; | } drawDMEdgesSelInterp_userData; | ||||
| typedef struct drawDMEdgesWeightedInterp_userData { | |||||
campbellbarton: result of `DM_get_weight_user()` can go here too. | |||||
| BMesh *bm; | |||||
| int cd_dvert_offset; | |||||
| int defgroup_tot; | |||||
| int vgroup_index; | |||||
| char weight_user; | |||||
| float alert_color[3]; | |||||
| } drawDMEdgesWeightedInterp_userData; | |||||
| typedef struct drawDMFacesSel_userData { | typedef struct drawDMFacesSel_userData { | ||||
| #ifdef WITH_FREESTYLE | #ifdef WITH_FREESTYLE | ||||
| unsigned char *cols[4]; | unsigned char *cols[4]; | ||||
| #else | #else | ||||
| unsigned char *cols[3]; | unsigned char *cols[3]; | ||||
| #endif | #endif | ||||
| DerivedMesh *dm; | DerivedMesh *dm; | ||||
| ▲ Show 20 Lines • Show All 2,207 Lines • ▼ Show 20 Lines | |||||
| /* Draw edges with color interpolated based on selection */ | /* Draw edges with color interpolated based on selection */ | ||||
| static DMDrawOption draw_dm_edges_sel_interp__setDrawOptions(void *userData, int index) | static DMDrawOption draw_dm_edges_sel_interp__setDrawOptions(void *userData, int index) | ||||
| { | { | ||||
| if (BM_elem_flag_test(BM_edge_at_index(((void **)userData)[0], index), BM_ELEM_HIDDEN)) | if (BM_elem_flag_test(BM_edge_at_index(((void **)userData)[0], index), BM_ELEM_HIDDEN)) | ||||
| return DM_DRAW_OPTION_SKIP; | return DM_DRAW_OPTION_SKIP; | ||||
| else | else | ||||
| return DM_DRAW_OPTION_NORMAL; | return DM_DRAW_OPTION_NORMAL; | ||||
| } | } | ||||
| static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int index, float t) | static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int index, float t) | ||||
| { | { | ||||
| drawDMEdgesSelInterp_userData *data = userData; | drawDMEdgesSelInterp_userData *data = userData; | ||||
| BMEdge *eed = BM_edge_at_index(((void **)userData)[0], index); | BMEdge *eed = BM_edge_at_index(((void **)userData)[0], index); | ||||
| unsigned char **cols = userData; | unsigned char **cols = userData; | ||||
| unsigned int col0_id = (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT)) ? 2 : 1; | unsigned int col0_id = (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT)) ? 2 : 1; | ||||
| unsigned int col1_id = (BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) ? 2 : 1; | unsigned int col1_id = (BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)) ? 2 : 1; | ||||
| unsigned char *col0 = cols[col0_id]; | unsigned char *col0 = cols[col0_id]; | ||||
| Show All 18 Lines | static void draw_dm_edges_sel_interp__setDrawInterpOptions(void *userData, int index, float t) | ||||
| } | } | ||||
| if (data->lastCol != col_pt) { | if (data->lastCol != col_pt) { | ||||
| data->lastCol = col_pt; | data->lastCol = col_pt; | ||||
| glColor4ubv(col_pt); | glColor4ubv(col_pt); | ||||
| } | } | ||||
| } | } | ||||
| static void bm_color_from_weight(float col[3], BMVert *vert, drawDMEdgesWeightedInterp_userData *data) | |||||
| { | |||||
| MDeformVert *dvert = BM_ELEM_CD_GET_VOID_P(vert, data->cd_dvert_offset); | |||||
| float weight = defvert_find_weight(dvert, data->vgroup_index); | |||||
| if (weight == 0.0f) | |||||
Not Done Inline ActionsThe mesh either has deform weights or not. This check should be moved into draw_dm_edges_sel_interp or even earlier. campbellbarton: The mesh either has deform weights or not. This check should be moved into… | |||||
| { | |||||
| if (data->weight_user == OB_DRAW_GROUPUSER_ACTIVE || | |||||
| data->weight_user == OB_DRAW_GROUPUSER_ALL && defvert_is_weight_zero(dvert, data->defgroup_tot)) { | |||||
| col[0] = data->alert_color[0]; | |||||
| col[1] = data->alert_color[1]; | |||||
| col[2] = data->alert_color[2]; | |||||
| return; | |||||
| } | |||||
| } | |||||
| weight_to_rgb(col, weight); | |||||
| } | |||||
| static void draw_dm_edges_weighted_interp__setDrawInterpOptions(void *userData, int index, float t) | |||||
| { | |||||
| drawDMEdgesWeightedInterp_userData *data = userData; | |||||
| BMEdge *eed = BM_edge_at_index(((void **)userData)[0], index); | |||||
| float from_col[3]; | |||||
| float to_col[3]; | |||||
| float col_blend[3]; | |||||
| bm_color_from_weight(from_col, eed->v1, data); | |||||
| bm_color_from_weight(to_col, eed->v2, data); | |||||
| interp_v3_v3v3_slerp_safe(col_blend, from_col, to_col, t); | |||||
Not Done Inline ActionsThis is incorrect, It should interpolate between the 2 colors if its not 0.0 or 1.0. As selection does. You should be able to check this is working with subsurf+cage. campbellbarton: This is incorrect, It should interpolate between the 2 colors if its not 0.0 or 1.0. As… | |||||
| glColor3fv(col_blend); | |||||
| } | |||||
| static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol) | static void draw_dm_edges_sel_interp(BMEditMesh *em, DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol) | ||||
| { | { | ||||
| drawDMEdgesSelInterp_userData data; | drawDMEdgesSelInterp_userData data; | ||||
| data.bm = em->bm; | data.bm = em->bm; | ||||
| data.baseCol = baseCol; | data.baseCol = baseCol; | ||||
| data.selCol = selCol; | data.selCol = selCol; | ||||
| data.lastCol = NULL; | data.lastCol = NULL; | ||||
| dm->drawMappedEdgesInterp(dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_sel_interp__setDrawInterpOptions, &data); | dm->drawMappedEdgesInterp(dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_sel_interp__setDrawInterpOptions, &data); | ||||
| } | } | ||||
| static void draw_dm_edges_weighted_interp(BMEditMesh *em, DerivedMesh *dm, const char weight_user, char vertex_unreferenced[4]) | |||||
| { | |||||
| drawDMEdgesWeightedInterp_userData data; | |||||
| data.bm = em->bm; | |||||
| Object *ob = em->ob; | |||||
| data.cd_dvert_offset = CustomData_get_offset(&data.bm->vdata, CD_MDEFORMVERT); | |||||
| data.defgroup_tot = BLI_countlist(&ob->defbase); | |||||
| data.vgroup_index = ob->actdef - 1; | |||||
| data.weight_user = weight_user; | |||||
| data.alert_color[0] = ((float)vertex_unreferenced[0]) / 256.0f; | |||||
| data.alert_color[1] = ((float)vertex_unreferenced[1]) / 256.0f; | |||||
| data.alert_color[2] = ((float)vertex_unreferenced[2]) / 256.0f; | |||||
| glEnable(GL_BLEND); | |||||
| dm->drawMappedEdgesInterp(dm, draw_dm_edges_sel_interp__setDrawOptions, draw_dm_edges_weighted_interp__setDrawInterpOptions, &data); | |||||
| glDisable(GL_BLEND); | |||||
| } | |||||
| /* Draw only seam edges */ | /* Draw only seam edges */ | ||||
| static DMDrawOption draw_dm_edges_seams__setDrawOptions(void *userData, int index) | static DMDrawOption draw_dm_edges_seams__setDrawOptions(void *userData, int index) | ||||
| { | { | ||||
| BMEdge *eed = BM_edge_at_index(userData, index); | BMEdge *eed = BM_edge_at_index(userData, index); | ||||
| if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SEAM)) | if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_elem_flag_test(eed, BM_ELEM_SEAM)) | ||||
| return DM_DRAW_OPTION_NORMAL; | return DM_DRAW_OPTION_NORMAL; | ||||
| else | else | ||||
| ▲ Show 20 Lines • Show All 396 Lines • ▼ Show 20 Lines | else { | ||||
| selCol[3] = 255; | selCol[3] = 255; | ||||
| if (!sel_only) wireCol[3] = 255; | if (!sel_only) wireCol[3] = 255; | ||||
| } | } | ||||
| if (ts->selectmode == SCE_SELECT_FACE) { | if (ts->selectmode == SCE_SELECT_FACE) { | ||||
| draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act); | draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act); | ||||
| } | } | ||||
| else if ((me->drawflag & ME_DRAWEDGES) || (ts->selectmode & SCE_SELECT_EDGE)) { | else if ((me->drawflag & ME_DRAWEDGES) || (ts->selectmode & SCE_SELECT_EDGE)) { | ||||
| if (cageDM->drawMappedEdgesInterp && (ts->selectmode & SCE_SELECT_VERTEX)) { | if (cageDM->drawMappedEdgesInterp && | ||||
| ((ts->selectmode & SCE_SELECT_VERTEX) || (me->drawflag & ME_DRAWEIGHT))) | |||||
| { | |||||
| bool has_weights = CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT); | |||||
| glShadeModel(GL_SMOOTH); | glShadeModel(GL_SMOOTH); | ||||
| bool draw_weights = has_weights && | |||||
| (me->drawflag & ME_DRAWEIGHT) && | |||||
| ((v3d->drawtype == OB_WIRE) || | |||||
| (v3d->flag2 & V3D_SOLID_MATCAP) || | |||||
| ((v3d->flag2 & V3D_OCCLUDE_WIRE) && (v3d->drawtype > OB_WIRE)) | |||||
| ); | |||||
| if (draw_weights && em->ob->actdef > 0) | |||||
| draw_dm_edges_weighted_interp(em, cageDM, scene->toolsettings->weightuser, UI_GetTheme()->tv3d.vertex_unreferenced); | |||||
| else | |||||
| draw_dm_edges_sel_interp(em, cageDM, wireCol, selCol); | draw_dm_edges_sel_interp(em, cageDM, wireCol, selCol); | ||||
| glShadeModel(GL_FLAT); | glShadeModel(GL_FLAT); | ||||
| } | } | ||||
| else { | else { | ||||
| draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act); | draw_dm_edges_sel(em, cageDM, wireCol, selCol, actCol, eed_act); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (!sel_only) { | if (!sel_only) { | ||||
| ▲ Show 20 Lines • Show All 5,239 Lines • Show Last 20 Lines | |||||
result of DM_get_weight_user() can go here too.