Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_brush.c
| Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | typedef struct tGP_BrushEditData { | ||||
| /* Current frame */ | /* Current frame */ | ||||
| int cfra; | int cfra; | ||||
| /* Brush Runtime Data: */ | /* Brush Runtime Data: */ | ||||
| /* - position and pressure | /* - position and pressure | ||||
| * - the *_prev variants are the previous values | * - the *_prev variants are the previous values | ||||
| */ | */ | ||||
| int mval[2], mval_prev[2]; | float mval[2], mval_prev[2]; | ||||
| float pressure, pressure_prev; | float pressure, pressure_prev; | ||||
| /* - effect vector (e.g. 2D/3D translation for grab brush) */ | /* - effect vector (e.g. 2D/3D translation for grab brush) */ | ||||
| float dvec[3]; | float dvec[3]; | ||||
| /* - multiframe falloff factor */ | /* - multiframe falloff factor */ | ||||
| float mf_falloff; | float mf_falloff; | ||||
| ▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | static float gp_brush_influence_calc(tGP_BrushEditData *gso, const int radius, const int co[2]) | ||||
| /* use pressure? */ | /* use pressure? */ | ||||
| if (gp_brush->flag & GP_SCULPT_FLAG_USE_PRESSURE) { | if (gp_brush->flag & GP_SCULPT_FLAG_USE_PRESSURE) { | ||||
| influence *= gso->pressure; | influence *= gso->pressure; | ||||
| } | } | ||||
| /* distance fading */ | /* distance fading */ | ||||
| if (gp_brush->flag & GP_SCULPT_FLAG_USE_FALLOFF) { | if (gp_brush->flag & GP_SCULPT_FLAG_USE_FALLOFF) { | ||||
| float distance = (float)len_v2v2_int(gso->mval, co); | int mval_i[2]; | ||||
| round_v2i_v2fl(mval_i, gso->mval); | |||||
| float distance = (float)len_v2v2_int(mval_i, co); | |||||
| float fac; | float fac; | ||||
| CLAMP(distance, 0.0f, (float)radius); | CLAMP(distance, 0.0f, (float)radius); | ||||
| fac = 1.0f - (distance / (float)radius); | fac = 1.0f - (distance / (float)radius); | ||||
| influence *= fac; | influence *= fac; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 316 Lines • ▼ Show 20 Lines | if (gso->sa->spacetype == SPACE_VIEW3D) { | ||||
| /* Convert mouse position to 3D space | /* Convert mouse position to 3D space | ||||
| * See: gpencil_paint.c :: gp_stroke_convertcoords() | * See: gpencil_paint.c :: gp_stroke_convertcoords() | ||||
| */ | */ | ||||
| RegionView3D *rv3d = gso->ar->regiondata; | RegionView3D *rv3d = gso->ar->regiondata; | ||||
| const float *rvec = gso->scene->cursor.location; | const float *rvec = gso->scene->cursor.location; | ||||
| float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL); | float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL); | ||||
| float mval_f[2]; | float mval_f[2]; | ||||
| copy_v2fl_v2i(mval_f, gso->mval); | copy_v2_v2(mval_f, gso->mval); | ||||
| float mval_prj[2]; | float mval_prj[2]; | ||||
| float dvec[3]; | float dvec[3]; | ||||
| if (ED_view3d_project_float_global(gso->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { | if (ED_view3d_project_float_global(gso->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { | ||||
| sub_v2_v2v2(mval_f, mval_prj, mval_f); | sub_v2_v2v2(mval_f, mval_prj, mval_f); | ||||
| ED_view3d_win_to_delta(gso->ar, mval_f, dvec, zfac); | ED_view3d_win_to_delta(gso->ar, mval_f, dvec, zfac); | ||||
| sub_v3_v3v3(gso->dvec, rvec, dvec); | sub_v3_v3v3(gso->dvec, rvec, dvec); | ||||
| ▲ Show 20 Lines • Show All 824 Lines • ▼ Show 20 Lines | static bool gpsculpt_brush_do_stroke( | ||||
| if (gps->totpoints == 1) { | if (gps->totpoints == 1) { | ||||
| bGPDspoint pt_temp; | bGPDspoint pt_temp; | ||||
| gp_point_to_parent_space(gps->points, diff_mat, &pt_temp); | gp_point_to_parent_space(gps->points, diff_mat, &pt_temp); | ||||
| gp_point_to_xy(gsc, gps, &pt_temp, &pc1[0], &pc1[1]); | gp_point_to_xy(gsc, gps, &pt_temp, &pc1[0], &pc1[1]); | ||||
| /* do boundbox check first */ | /* do boundbox check first */ | ||||
| if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) { | if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) { | ||||
| /* only check if point is inside */ | /* only check if point is inside */ | ||||
| if (len_v2v2_int(gso->mval, pc1) <= radius) { | int mval_i[2]; | ||||
| round_v2i_v2fl(mval_i, gso->mval); | |||||
| if (len_v2v2_int(mval_i, pc1) <= radius) { | |||||
| /* apply operation to this point */ | /* apply operation to this point */ | ||||
| changed = apply(gso, gps, 0, radius, pc1); | changed = apply(gso, gps, 0, radius, pc1); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* Loop over the points in the stroke, checking for intersections | /* Loop over the points in the stroke, checking for intersections | ||||
| * - an intersection means that we touched the stroke | * - an intersection means that we touched the stroke | ||||
| ▲ Show 20 Lines • Show All 696 Lines • Show Last 20 Lines | |||||