Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/curve/editcurve_paint.c
| Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | struct StrokeElem { | ||||
| /* surface normal, may be zero'd */ | /* surface normal, may be zero'd */ | ||||
| float normal_world[3]; | float normal_world[3]; | ||||
| float normal_local[3]; | float normal_local[3]; | ||||
| float pressure; | float pressure; | ||||
| }; | }; | ||||
| struct CurveDrawData { | struct CurveDrawData { | ||||
| const Depsgraph *depsgraph; | |||||
| short init_event_type; | short init_event_type; | ||||
| short curve_type; | short curve_type; | ||||
| /* projecting 2D into 3D space */ | /* projecting 2D into 3D space */ | ||||
| struct { | struct { | ||||
| /* use a plane or project to the surface */ | /* use a plane or project to the surface */ | ||||
| bool use_plane; | bool use_plane; | ||||
| float plane[4]; | float plane[4]; | ||||
| ▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | static bool stroke_elem_project( | ||||
| RegionView3D *rv3d = cdd->vc.rv3d; | RegionView3D *rv3d = cdd->vc.rv3d; | ||||
| bool is_location_world_set = false; | bool is_location_world_set = false; | ||||
| /* project to 'location_world' */ | /* project to 'location_world' */ | ||||
| if (cdd->project.use_plane) { | if (cdd->project.use_plane) { | ||||
| /* get the view vector to 'location' */ | /* get the view vector to 'location' */ | ||||
| float ray_origin[3], ray_direction[3]; | float ray_origin[3], ray_direction[3]; | ||||
| ED_view3d_win_to_ray(cdd->vc.ar, v3d, mval_fl, ray_origin, ray_direction, false); | ED_view3d_win_to_ray(cdd->depsgraph, cdd->vc.ar, v3d, mval_fl, ray_origin, ray_direction, false); | ||||
| float lambda; | float lambda; | ||||
| if (isect_ray_plane_v3(ray_origin, ray_direction, cdd->project.plane, &lambda, true)) { | if (isect_ray_plane_v3(ray_origin, ray_direction, cdd->project.plane, &lambda, true)) { | ||||
| madd_v3_v3v3fl(r_location_world, ray_origin, ray_direction, lambda); | madd_v3_v3v3fl(r_location_world, ray_origin, ray_direction, lambda); | ||||
| if (r_normal_world) { | if (r_normal_world) { | ||||
| zero_v3(r_normal_world); | zero_v3(r_normal_world); | ||||
| } | } | ||||
| is_location_world_set = true; | is_location_world_set = true; | ||||
| ▲ Show 20 Lines • Show All 387 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke) | static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke) | ||||
| { | { | ||||
| BLI_assert(op->customdata == NULL); | BLI_assert(op->customdata == NULL); | ||||
| struct CurveDrawData *cdd = MEM_callocN(sizeof(*cdd), __func__); | struct CurveDrawData *cdd = MEM_callocN(sizeof(*cdd), __func__); | ||||
| cdd->depsgraph = CTX_data_depsgraph(C); | |||||
| if (is_invoke) { | if (is_invoke) { | ||||
| view3d_set_viewcontext(C, &cdd->vc); | view3d_set_viewcontext(C, &cdd->vc); | ||||
| if (ELEM(NULL, cdd->vc.ar, cdd->vc.rv3d, cdd->vc.v3d, cdd->vc.win, cdd->vc.scene)) { | if (ELEM(NULL, cdd->vc.ar, cdd->vc.rv3d, cdd->vc.v3d, cdd->vc.win, cdd->vc.scene)) { | ||||
| MEM_freeN(cdd); | MEM_freeN(cdd); | ||||
| BKE_report(op->reports, RPT_ERROR, "Unable to access 3D viewport"); | BKE_report(op->reports, RPT_ERROR, "Unable to access 3D viewport"); | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 624 Lines • Show Last 20 Lines | |||||