Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_mask.c
| Show First 20 Lines • Show All 377 Lines • ▼ Show 20 Lines | static SculptGestureContext *sculpt_gesture_init_from_lasso(bContext *C, wmOperator *op) | ||||
| if (!mcoords) { | if (!mcoords) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| ED_view3d_ob_project_mat_get( | ED_view3d_ob_project_mat_get( | ||||
| sgcontext->vc.rv3d, sgcontext->vc.obact, sgcontext->lasso.projviewobjmat); | sgcontext->vc.rv3d, sgcontext->vc.obact, sgcontext->lasso.projviewobjmat); | ||||
| BLI_lasso_boundbox(&sgcontext->lasso.boundbox, mcoords, mcoords_len); | BLI_lasso_boundbox(&sgcontext->lasso.boundbox, mcoords, mcoords_len); | ||||
| sgcontext->lasso.width = sgcontext->lasso.boundbox.xmax - sgcontext->lasso.boundbox.xmin; | const int lasso_width = 1 + sgcontext->lasso.boundbox.xmax - sgcontext->lasso.boundbox.xmin; | ||||
| sgcontext->lasso.mask_px = BLI_BITMAP_NEW( | const int lasso_height = 1 + sgcontext->lasso.boundbox.ymax - sgcontext->lasso.boundbox.ymin; | ||||
| sgcontext->lasso.width * (sgcontext->lasso.boundbox.ymax - sgcontext->lasso.boundbox.ymin), | sgcontext->lasso.width = lasso_width; | ||||
| __func__); | sgcontext->lasso.mask_px = BLI_BITMAP_NEW(lasso_width * lasso_height, __func__); | ||||
| BLI_bitmap_draw_2d_poly_v2i_n(sgcontext->lasso.boundbox.xmin, | BLI_bitmap_draw_2d_poly_v2i_n(sgcontext->lasso.boundbox.xmin, | ||||
| sgcontext->lasso.boundbox.ymin, | sgcontext->lasso.boundbox.ymin, | ||||
| sgcontext->lasso.boundbox.xmax, | sgcontext->lasso.boundbox.xmax, | ||||
| sgcontext->lasso.boundbox.ymax, | sgcontext->lasso.boundbox.ymax, | ||||
| mcoords, | mcoords, | ||||
| mcoords_len, | mcoords_len, | ||||
| sculpt_gesture_lasso_px_cb, | sculpt_gesture_lasso_px_cb, | ||||
| ▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | static bool sculpt_gesture_is_effected_lasso(SculptGestureContext *sgcontext, const float co[3]) | ||||
| LassoGestureData *lasso = &sgcontext->lasso; | LassoGestureData *lasso = &sgcontext->lasso; | ||||
| if (!BLI_rcti_isect_pt(&lasso->boundbox, scr_co_s[0], scr_co_s[1])) { | if (!BLI_rcti_isect_pt(&lasso->boundbox, scr_co_s[0], scr_co_s[1])) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| scr_co_s[0] -= lasso->boundbox.xmin; | scr_co_s[0] -= lasso->boundbox.xmin; | ||||
| scr_co_s[1] -= lasso->boundbox.ymin; | scr_co_s[1] -= lasso->boundbox.ymin; | ||||
| return BLI_BITMAP_TEST_BOOL(lasso->mask_px, scr_co_s[1] * lasso->width + scr_co_s[0]); | const int coord = scr_co_s[1] * lasso->width + scr_co_s[0]; | ||||
| return BLI_BITMAP_TEST_BOOL(lasso->mask_px, coord); | |||||
| } | } | ||||
| static bool sculpt_gesture_is_vertex_effected(SculptGestureContext *sgcontext, PBVHVertexIter *vd) | static bool sculpt_gesture_is_vertex_effected(SculptGestureContext *sgcontext, PBVHVertexIter *vd) | ||||
| { | { | ||||
| float vertex_normal[3]; | float vertex_normal[3]; | ||||
| SCULPT_vertex_normal_get(sgcontext->ss, vd->index, vertex_normal); | SCULPT_vertex_normal_get(sgcontext->ss, vd->index, vertex_normal); | ||||
| float dot = dot_v3v3(sgcontext->view_normal, vertex_normal); | float dot = dot_v3v3(sgcontext->view_normal, vertex_normal); | ||||
| const bool is_effected_front_face = !(sgcontext->front_faces_only && dot < 0.0f); | const bool is_effected_front_face = !(sgcontext->front_faces_only && dot < 0.0f); | ||||
| ▲ Show 20 Lines • Show All 1,015 Lines • Show Last 20 Lines | |||||