|
Blender
V2.93
|
#include <math.h>#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "MEM_guardedalloc.h"#include "BLI_blenlib.h"#include "BLI_ghash.h"#include "BLI_hash.h"#include "BLI_lasso_2d.h"#include "BLI_math.h"#include "BLI_rand.h"#include "BLI_utildefines.h"#include "BLT_translation.h"#include "PIL_time.h"#include "DNA_brush_types.h"#include "DNA_collection_types.h"#include "DNA_gpencil_types.h"#include "DNA_material_types.h"#include "DNA_meshdata_types.h"#include "DNA_object_types.h"#include "DNA_scene_types.h"#include "DNA_screen_types.h"#include "DNA_space_types.h"#include "DNA_view3d_types.h"#include "BKE_action.h"#include "BKE_brush.h"#include "BKE_collection.h"#include "BKE_colortools.h"#include "BKE_context.h"#include "BKE_deform.h"#include "BKE_gpencil.h"#include "BKE_gpencil_curve.h"#include "BKE_gpencil_geom.h"#include "BKE_main.h"#include "BKE_material.h"#include "BKE_object.h"#include "BKE_paint.h"#include "BKE_tracking.h"#include "WM_api.h"#include "WM_toolsystem.h"#include "WM_types.h"#include "RNA_access.h"#include "RNA_define.h"#include "RNA_enum_types.h"#include "UI_resources.h"#include "UI_view2d.h"#include "ED_clip.h"#include "ED_gpencil.h"#include "ED_object.h"#include "ED_screen.h"#include "ED_select_utils.h"#include "ED_transform_snap_object_context.h"#include "ED_view3d.h"#include "GPU_immediate.h"#include "GPU_immediate_util.h"#include "GPU_state.h"#include "DEG_depsgraph.h"#include "DEG_depsgraph_query.h"#include "gpencil_intern.h"Go to the source code of this file.
Get the active Grease Pencil data-block
Definition at line 293 of file gpencil_utils.c.
References C, ED_annotation_data_get_pointers(), and NULL.
Referenced by annotation_actframe_delete_poll(), ED_annotation_draw_2dimage(), ED_annotation_draw_view2d(), gpencil_actframe_delete_exec(), gpencil_active_layer_annotation_poll(), gpencil_layer_move_exec(), and gpencil_layer_remove_exec().
Definition at line 270 of file gpencil_utils.c.
References blender::compositor::area(), ED_annotation_data_get_pointers_direct(), NULL, and scene.
Referenced by screen_ctx_active_annotation_layer(), and screen_ctx_annotation_data().
| bGPdata** ED_annotation_data_get_pointers | ( | const bContext * | C, |
| PointerRNA * | r_ptr | ||
| ) |
Get pointer to active Grease Pencil data-block, and an RNA-pointer to trace back to whatever owns it.
Definition at line 252 of file gpencil_utils.c.
References blender::compositor::area(), C, CTX_data_scene(), CTX_wm_area(), CTX_wm_screen(), ED_annotation_data_get_pointers_direct(), and scene.
Referenced by annotation_draw_poll(), annotation_session_initdata(), ED_annotation_data_get_active(), gpencil_add_annotation_poll(), gpencil_data_add_exec(), gpencil_data_add_poll(), gpencil_data_unlink_exec(), gpencil_data_unlink_poll(), and gpencil_layer_add_exec().
| bGPdata** ED_annotation_data_get_pointers_direct | ( | ID * | screen_id, |
| ScrArea * | area, | ||
| Scene * | scene, | ||
| PointerRNA * | r_ptr | ||
| ) |
Get pointer to active Grease Pencil data-block for annotations, and an RNA-pointer to trace back to whatever owns it, when context info is not available.
Definition at line 138 of file gpencil_utils.c.
References blender::compositor::area(), BKE_tracking_track_get_active(), ED_space_clip_get_clip(), MovieClip::gpd, bNodeTree::gpd, Scene::gpd, SpaceSeq::gpd, SpaceImage::gpd, MovieTrackingTrack::gpd, SpaceClip::gpencil_src, MovieClip::id, bNodeTree::id, Scene::id, SpaceNode::nodetree, NULL, RNA_id_pointer_create(), RNA_MovieTrackingTrack, RNA_pointer_create(), RNA_SpaceImageEditor, RNA_SpaceSequenceEditor, SC_GPENCIL_SRC_TRACK, scene, SPACE_CLIP, SPACE_IMAGE, SPACE_INFO, SPACE_NODE, SPACE_PROPERTIES, SPACE_SEQ, SPACE_TOPBAR, SPACE_VIEW3D, and MovieClip::tracking.
Referenced by ED_annotation_data_get_active_direct(), ED_annotation_data_get_pointers(), and screen_ctx_annotation_data_owner().
Definition at line 1567 of file gpencil_utils.c.
References BKE_brush_gpencil_paint_presets(), BKE_curvemap_reset(), BKE_curvemapping_add(), BKE_curvemapping_init(), BKE_gpencil_object_material_ensure_from_active_input_toolsettings(), BKE_paint_ensure(), Paint::brush, C, CurveMapping::clipr, CurveMapping::cm, CTX_data_main(), CTX_data_tool_settings(), GP_Sculpt_Settings::cur_falloff, CURVE_PRESET_GAUSS, CURVEMAP_SLOPE_POSITIVE, ToolSettings::gp_paint, ToolSettings::gp_sculpt, Brush::gpencil_settings, NULL, and GpPaint::paint.
Referenced by ED_gpencil_add_object(), and object_gpencil_add_exec().
Definition at line 1554 of file gpencil_utils.c.
References C, ED_gpencil_add_defaults(), ED_object_add_type(), NULL, OB_GPENCIL, and rot.
Referenced by blender::io::gpencil::GpencilImporter::create_object(), gpencil_bake_mesh_animation_exec(), gpencil_session_initdata(), image_to_gpencil_exec(), object_convert_exec(), and trace_initialize_job_data().
| void ED_gpencil_brush_draw_eraser | ( | Brush * | brush, |
| int | x, | ||
| int | y | ||
| ) |
Definition at line 1842 of file gpencil_utils.c.
References GPU_blend(), GPU_BLEND_ALPHA, GPU_BLEND_NONE, GPU_COMP_F32, GPU_FETCH_FLOAT, GPU_line_smooth(), GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR, GPU_SHADER_2D_UNIFORM_COLOR, GPU_vertformat_attr_add(), GPU_viewport_size_get_f(), imm_draw_circle_fill_2d(), imm_draw_circle_wire_2d(), immBindBuiltinProgram(), immUnbindProgram(), immUniform1f(), immUniform1i(), immUniform2f(), immUniformColor4f(), immUniformColor4ub(), immVertexFormat(), max_ii(), Brush::size, x, and y.
Referenced by gpencil_brush_cursor_draw().
Get the active Grease Pencil data-block
Definition at line 279 of file gpencil_utils.c.
References C, CTX_data_active_object(), Object::data, NULL, OB_GPENCIL, and Object::type.
Referenced by gpencil_actframe_delete_all_exec(), gpencil_actframe_delete_all_poll(), gpencil_actframe_delete_exec(), gpencil_actframe_delete_poll(), gpencil_blank_frame_add_exec(), gpencil_brush_cursor_draw(), gpencil_circle_select_exec(), gpencil_cutter_lasso_select(), gpencil_cutter_poll(), gpencil_cyclical_set_curve_edit_poll_property(), gpencil_delete_selected_points(), gpencil_delete_selected_strokes(), gpencil_duplicate_exec(), gpencil_editmode_toggle_exec(), gpencil_editmode_toggle_poll(), gpencil_frame_clean_fill_exec(), gpencil_frame_clean_loose_exec(), gpencil_frame_duplicate_exec(), gpencil_generic_select_exec(), gpencil_hide_exec(), gpencil_interpolate_reverse_exec(), gpencil_interpolate_reverse_poll(), gpencil_isolate_layer_exec(), gpencil_layer_copy_exec(), gpencil_layer_move_exec(), gpencil_layer_remove_exec(), gpencil_lock_all_exec(), gpencil_lock_layer_exec(), gpencil_material_isolate_exec(), gpencil_material_lock_unsused_exec(), gpencil_material_select_exec(), gpencil_merge_layer_exec(), gpencil_paintmode_toggle_exec(), gpencil_paintmode_toggle_poll(), gpencil_reveal_exec(), gpencil_reveal_poll(), gpencil_sculpt_brush_init(), gpencil_sculptmode_toggle_exec(), gpencil_sculptmode_toggle_poll(), gpencil_select_all_exec(), gpencil_select_all_poll(), gpencil_select_alternate_exec(), gpencil_select_exec(), gpencil_select_first_exec(), gpencil_select_grouped_exec(), gpencil_select_last_exec(), gpencil_select_less_exec(), gpencil_select_linked_exec(), gpencil_select_more_exec(), gpencil_select_poll(), gpencil_select_same_layer(), gpencil_select_same_material(), gpencil_select_vertex_color_exec(), gpencil_set_active_material_exec(), gpencil_snap_cursor_to_sel(), gpencil_snap_to_cursor(), gpencil_snap_to_grid(), gpencil_stroke_apply_thickness_exec(), gpencil_stroke_arrange_exec(), gpencil_stroke_caps_set_exec(), gpencil_stroke_change_color_exec(), gpencil_stroke_cyclical_set_exec(), gpencil_stroke_flip_exec(), gpencil_stroke_join_exec(), gpencil_stroke_sample_exec(), gpencil_stroke_separate_exec(), gpencil_stroke_simplify_exec(), gpencil_stroke_simplify_fixed_exec(), gpencil_stroke_smooth_exec(), gpencil_stroke_split_exec(), gpencil_stroke_subdivide_exec(), gpencil_stroke_trim_exec(), gpencil_strokes_copy_exec(), gpencil_strokes_paste_poll(), gpencil_strokes_reproject_exec(), gpencil_subdivide_curve_edit_poll_property(), gpencil_unlock_all_exec(), gpencil_vertexmode_toggle_exec(), gpencil_vertexmode_toggle_poll(), gpencil_vertexpaint_brush_init(), gpencil_weightmode_toggle_exec(), gpencil_weightmode_toggle_poll(), gpencil_weightpaint_brush_init(), and viewRedrawForce().
Definition at line 263 of file gpencil_utils.c.
References blender::compositor::area(), ED_gpencil_data_get_pointers_direct(), and NULL.
Referenced by ED_gpencil_data_get_active_evaluated(), screen_ctx_active_gpencil_frame(), screen_ctx_active_gpencil_layer(), screen_ctx_editable_gpencil_layers(), screen_ctx_editable_gpencil_strokes(), screen_ctx_gpencil_data(), and screen_ctx_visible_gpencil_layers().
Get the evaluated copy of the active Grease Pencil data-block (where applicable)
Definition at line 306 of file gpencil_utils.c.
References blender::compositor::area(), C, CTX_data_active_object(), CTX_data_ensure_evaluated_depsgraph(), CTX_wm_area(), DEG_get_evaluated_object(), depsgraph, and ED_gpencil_data_get_active_direct().
| bGPdata** ED_gpencil_data_get_pointers | ( | const bContext * | C, |
| PointerRNA * | r_ptr | ||
| ) |
Get pointer to active Grease Pencil data-block, and an RNA-pointer to trace back to whatever owns it.
Definition at line 240 of file gpencil_utils.c.
References blender::compositor::area(), C, CTX_data_active_object(), CTX_wm_area(), and ED_gpencil_data_get_pointers_direct().
Referenced by ED_undo_gpencil_step(), and gpencil_session_initdata().
| bGPdata** ED_gpencil_data_get_pointers_direct | ( | ScrArea * | area, |
| Object * | ob, | ||
| PointerRNA * | r_ptr | ||
| ) |
Get pointer to active Grease Pencil data-block, and an RNA-pointer to trace back to whatever owns it, when context info is not available.
Definition at line 104 of file gpencil_utils.c.
References blender::compositor::area(), Object::data, Object::id, NULL, OB_GPENCIL, RNA_id_pointer_create(), SPACE_INFO, SPACE_PROPERTIES, SPACE_TOPBAR, SPACE_VIEW3D, and Object::type.
Referenced by ED_gpencil_data_get_active_direct(), ED_gpencil_data_get_pointers(), and screen_ctx_gpencil_data_owner().
| bool ED_gpencil_data_owner_is_annotation | ( | PointerRNA * | owner_ptr | ) |
Utility to check whether the r_ptr output of ED_gpencil_data_get_pointers() is for annotation usage.
Definition at line 323 of file gpencil_utils.c.
References RNA_Object, and PointerRNA::type.
Referenced by annotation_session_initdata(), and gpencil_session_initdata().
| void ED_gpencil_drawing_reference_get | ( | const Scene * | scene, |
| const Object * | ob, | ||
| char | align_flag, | ||
| float | r_vec[3] | ||
| ) |
Get drawing reference point for conversion or projection of the stroke
| r_vec | Reference point found |
Definition at line 1030 of file gpencil_utils.c.
References add_v3_v3(), BKE_gpencil_layer_active_get(), copy_v3_v3(), Scene::cursor, Object::data, GP_PROJECT_CURSOR, GP_PROJECT_VIEWSPACE, bGPDlayer::layer_mat, View3DCursor::location, NULL, OB_GPENCIL, Object::obmat, scene, and Object::type.
Referenced by ED_gpencil_stroke_reproject(), gpencil_get_3d_reference(), gpencil_point_xy_to_3d(), gpencil_primitive_update_strokes(), gpencil_sbuffer_stroke_ensure(), gpencil_stroke_convertcoords_tpoint(), and gpencil_stroke_from_buffer().
| void ED_gpencil_fill_vertex_color_set | ( | ToolSettings * | ts, |
| Brush * | brush, | ||
| bGPDstroke * | gps | ||
| ) |
Definition at line 2880 of file gpencil_utils.c.
References BrushGpencilSettings::brush_draw_mode, copy_v3_v3(), GP_BRUSH_MODE_MATERIAL, GP_BRUSH_MODE_VERTEXCOLOR, Brush::gpencil_settings, GPENCIL_USE_VERTEX_COLOR_FILL, Brush::rgb, srgb_to_linearrgb_v4(), bGPDstroke::vert_color_fill, BrushGpencilSettings::vertex_factor, and zero_v4().
Referenced by gpencil_primitive_set_initdata(), gpencil_stroke_from_buffer(), and gpencil_stroke_newfrombuffer().
| bool ED_gpencil_frame_has_selected_stroke | ( | const bGPDframe * | gpf | ) |
Definition at line 548 of file gpencil_utils.c.
References GP_STROKE_SELECT, LISTBASE_FOREACH, and bGPDframe::strokes.
Referenced by ED_gpencil_layer_has_selected_stroke().
Definition at line 334 of file gpencil_utils.c.
References bGPDlayer::actframe, BKE_gpencil_layer_active_get(), Object::data, bGPDframe::framenum, OB_GPENCIL, and Object::type.
Referenced by draw_selected_name().
| void ED_gpencil_init_random_settings | ( | Brush * | brush, |
| const int | mval[2], | ||
| GpRandomSettings * | random_settings | ||
| ) |
Definition at line 2922 of file gpencil_utils.c.
References BLI_hash_int_01(), BLI_hash_int_2d(), ceil(), BrushGpencilSettings::draw_random_press, BrushGpencilSettings::draw_random_strength, Brush::gpencil_settings, GpRandomSettings::hsv, PIL_check_seconds_timer(), GpRandomSettings::pressure, BrushGpencilSettings::random_hue, BrushGpencilSettings::random_saturation, BrushGpencilSettings::random_value, seed, GpRandomSettings::strength, GpRandomSettings::uv, BrushGpencilSettings::uv_random, and zero_v3().
Referenced by gpencil_draw_invoke(), and gpencil_primitive_invoke().
| bool ED_gpencil_layer_has_selected_stroke | ( | const bGPDlayer * | gpl, |
| const bool | is_multiedit | ||
| ) |
Definition at line 559 of file gpencil_utils.c.
References bGPDlayer::actframe, ED_gpencil_frame_has_selected_stroke(), ListBase::first, bGPDlayer::frames, GP_FRAME_SELECT, and bGPDframe::next.
Referenced by gpencil_stroke_separate_exec().
| const EnumPropertyItem* ED_gpencil_layers_enum_itemf | ( | bContext * | C, |
| PointerRNA * | UNUSEDptr, | ||
| PropertyRNA * | UNUSEDprop, | ||
| bool * | r_free | ||
| ) |
Definition at line 395 of file gpencil_utils.c.
References C, CTX_data_gpencil_data(), DummyRNA_DEFAULT_items, ELEM, ListBase::first, bGPDlayer::flag, GP_LAYER_ACTIVE, EnumPropertyItem::identifier, bGPDlayer::info, bGPdata::layers, bGPDlayer::next, NULL, RNA_enum_item_add(), and RNA_enum_item_end().
| const EnumPropertyItem* ED_gpencil_layers_with_new_enum_itemf | ( | bContext * | C, |
| PointerRNA * | UNUSEDptr, | ||
| PropertyRNA * | UNUSEDprop, | ||
| bool * | r_free | ||
| ) |
Definition at line 433 of file gpencil_utils.c.
References BLI_listbase_count(), C, CTX_data_gpencil_data(), DummyRNA_DEFAULT_items, ELEM, bGPDlayer::flag, GP_LAYER_ACTIVE, bGPDlayer::info, ListBase::last, bGPdata::layers, NULL, bGPDlayer::prev, RNA_enum_item_add(), RNA_enum_item_add_separator(), and RNA_enum_item_end().
| const EnumPropertyItem* ED_gpencil_material_enum_itemf | ( | bContext * | C, |
| PointerRNA * | UNUSEDptr, | ||
| PropertyRNA * | UNUSEDprop, | ||
| bool * | r_free | ||
| ) |
Definition at line 486 of file gpencil_utils.c.
References BKE_object_material_get(), C, CTX_data_active_object(), DummyRNA_DEFAULT_items, ELEM, PreviewImage::icon_id, Material::id, ID::name, NULL, Material::preview, RNA_enum_item_add(), RNA_enum_item_end(), and Object::totcol.
| void ED_gpencil_point_vertex_color_set | ( | ToolSettings * | ts, |
| Brush * | brush, | ||
| bGPDspoint * | pt, | ||
| tGPspoint * | tpt | ||
| ) |
Definition at line 2896 of file gpencil_utils.c.
References BrushGpencilSettings::brush_draw_mode, copy_v3_v3(), GP_BRUSH_MODE_MATERIAL, GP_BRUSH_MODE_VERTEXCOLOR, Brush::gpencil_settings, GPENCIL_USE_VERTEX_COLOR_STROKE, NULL, Brush::rgb, srgb_to_linearrgb_v4(), tGPspoint::vert_color, bGPDspoint::vert_color, BrushGpencilSettings::vertex_factor, and zero_v4().
Referenced by gpencil_primitive_update_strokes(), gpencil_stroke_from_buffer(), and gpencil_stroke_newfrombuffer().
| void ED_gpencil_project_point_to_plane | ( | const Scene * | scene, |
| const Object * | ob, | ||
| bGPDlayer * | gpl, | ||
| const RegionView3D * | rv3d, | ||
| const float | origin[3], | ||
| const int | axis, | ||
| bGPDspoint * | pt | ||
| ) |
Reproject given point to a plane locked to axis to avoid stroke offset
| pt | Point to affect (used for input & output). |
Definition at line 1322 of file gpencil_utils.c.
References add_v3_v3(), add_v3_v3v3(), copy_m4_m4(), copy_v3_v3(), Scene::cursor, ED_view3d_global_to_vector(), GP_LOCKAXIS_CURSOR, GP_PROJECT_CURSOR, ToolSettings::gp_sculpt, ToolSettings::gpencil_v3d_align, isect_line_plane_v3(), bGPDlayer::layer_mat, loc_eul_size_to_mat4(), bGPDlayer::location, View3DCursor::location, GP_Sculpt_Settings::lock_axis, mul_mat3_m4_v3(), mul_v3_fl(), NULL, OB_GPENCIL, Object::obmat, View3DCursor::rotation_euler, scene, Scene::toolsettings, Object::type, vn, bGPDspoint::x, and zero_v3().
Referenced by ED_gpencil_stroke_reproject(), gpencil_primitive_update_strokes(), and gpencil_stroke_addpoint().
| void ED_gpencil_project_stroke_to_plane | ( | const Scene * | scene, |
| const Object * | ob, | ||
| const RegionView3D * | rv3d, | ||
| bGPDlayer * | gpl, | ||
| bGPDstroke * | gps, | ||
| const float | origin[3], | ||
| const int | axis | ||
| ) |
Reproject all points of the stroke to a plane locked to axis to avoid stroke offset
Definition at line 1100 of file gpencil_utils.c.
References add_v3_v3(), add_v3_v3v3(), copy_m4_m4(), copy_v3_v3(), Scene::cursor, ED_view3d_global_to_vector(), GP_LOCKAXIS_CURSOR, GP_PROJECT_CURSOR, ToolSettings::gp_sculpt, ToolSettings::gpencil_v3d_align, invert_m4_m4(), isect_line_plane_v3(), bGPDlayer::layer_invmat, bGPDlayer::layer_mat, loc_eul_size_to_mat4(), bGPDlayer::location, View3DCursor::location, GP_Sculpt_Settings::lock_axis, mul_mat3_m4_v3(), mul_v3_fl(), NULL, OB_GPENCIL, Object::obmat, bGPDstroke::points, bGPDlayer::rotation, View3DCursor::rotation_euler, bGPDlayer::scale, scene, Scene::toolsettings, bGPDstroke::totpoints, Object::type, vn, bGPDspoint::x, and zero_v3().
Referenced by gpencil_primitive_update_strokes(), gpencil_reproject_toplane(), and gpencil_stroke_from_buffer().
| void ED_gpencil_project_stroke_to_view | ( | bContext * | C, |
| bGPDlayer * | gpl, | ||
| bGPDstroke * | gps | ||
| ) |
Definition at line 1063 of file gpencil_utils.c.
References BKE_gpencil_layer_transform_matrix_get(), C, CTX_data_active_object(), CTX_data_ensure_evaluated_depsgraph(), CTX_data_scene(), depsgraph, gpencil_point_conversion_init(), gpencil_point_to_parent_space(), gpencil_point_to_xy_fl(), gpencil_point_xy_to_3d(), invert_m4_m4(), mul_m4_v3(), NULL, bGPDstroke::points, scene, and bGPDspoint::x.
Referenced by gpencil_primitive_update_strokes(), gpencil_stroke_from_buffer(), and gpencil_stroke_newfrombuffer().
| void ED_gpencil_projected_2d_bound_box | ( | GP_SpaceConversion * | gsc, |
| bGPDstroke * | gps, | ||
| const float | diff_mat[4][4], | ||
| float | r_min[2], | ||
| float | r_max[2] | ||
| ) |
Definition at line 3109 of file gpencil_utils.c.
References BKE_boundbox_init_from_minmax(), bGPDstroke::boundbox_max, bGPDstroke::boundbox_min, bounds(), copy_v3_v3(), gpencil_point_to_parent_space(), gpencil_point_to_xy_fl(), INIT_MINMAX2, minmax_v2v2_v2(), SWAP, BoundBox::vec, and bGPDspoint::x.
Referenced by ED_gpencil_stroke_check_collision(), and gpencil_zoom_level_set().
Definition at line 1504 of file gpencil_utils.c.
References BKE_gpencil_layer_transform_matrix_get(), BKE_pose_channel_find_name(), copy_m4_m4(), copy_v3_v3(), depsgraph, ELEM, equals_m4m4(), invert_m4_m4(), bGPdata::layers, LISTBASE_FOREACH, mul_m4_m4m4(), mul_m4_v3(), NULL, Object::obmat, PARBONE, PAROBJECT, PARSKEL, bPoseChannel::pose_mat, sub_v3_v3(), bGPDspoint::x, and zero_v3().
Referenced by gpencil_editmode_toggle_exec().
| tGPspoint* ED_gpencil_sbuffer_ensure | ( | tGPspoint * | buffer_array, |
| int * | buffer_size, | ||
| int * | buffer_used, | ||
| const bool | clear | ||
| ) |
Ensure the tGPspoint buffer (while drawing stroke) size is enough to save all points of the stroke.
Definition at line 2807 of file gpencil_utils.c.
References clear(), GP_STROKE_BUFFER_CHUNK, MEM_callocN, MEM_recallocN, and NULL.
Referenced by annotation_session_validatebuffer(), annotation_stroke_addpoint(), gpencil_add_arc_points(), gpencil_add_guide_points(), gpencil_primitive_update_strokes(), gpencil_session_validatebuffer(), and gpencil_stroke_addpoint().
Definition at line 2845 of file gpencil_utils.c.
References bGPdata_Runtime::cp_points, Object::data, bGPdata::runtime, bGPdata_Runtime::sbuffer, bGPdata_Runtime::sbuffer_sflag, bGPdata_Runtime::sbuffer_size, bGPdata_Runtime::sbuffer_used, and bGPdata_Runtime::tot_cp_points.
Referenced by gpencil_primitive_update_strokes(), and gpencil_stroke_addpoint().
| void ED_gpencil_sbuffer_vertex_color_set | ( | Depsgraph * | depsgraph, |
| Object * | ob, | ||
| ToolSettings * | ts, | ||
| Brush * | brush, | ||
| Material * | material, | ||
| float | random_color[3], | ||
| float | pen_pressure | ||
| ) |
Definition at line 3049 of file gpencil_utils.c.
References BrushGpencilSettings::brush_draw_mode, copy_v3_v3(), copy_v4_v4(), Object::data, DEG_get_evaluated_id(), depsgraph, GP_BRUSH_MODE_MATERIAL, GP_BRUSH_MODE_VERTEXCOLOR, Material::gp_style, gpencil_sbuffer_vertex_color_random(), Brush::gpencil_settings, GPENCIL_USE_VERTEX_COLOR_FILL, GPENCIL_USE_VERTEX_COLOR_STROKE, Object::id, material, bGPdata_Runtime::matid, NULL, Brush::rgb, bGPdata::runtime, bGPdata_Runtime::sbuffer, bGPdata_Runtime::sbuffer_used, srgb_to_linearrgb_v4(), tGPspoint::vert_color, bGPdata_Runtime::vert_color_fill, and BrushGpencilSettings::vertex_factor.
Referenced by gpencil_primitive_update_strokes(), gpencil_session_validatebuffer(), and gpencil_stroke_addpoint().
| void ED_gpencil_select_curve_toggle_all | ( | bContext * | C, |
| int | action | ||
| ) |
Definition at line 2719 of file gpencil_utils.c.
References bGPDcurve_point::bezt, BEZT_DESEL_ALL, BEZT_SEL_ALL, BEZT_SEL_INVERT, BKE_gpencil_stroke_editcurve_update(), BKE_gpencil_stroke_geometry_update(), BKE_gpencil_stroke_select_index_reset(), BKE_gpencil_stroke_select_index_set(), C, CTX_data_active_object(), bGPDcurve::curve_points, Object::data, bGPDcurve_point::flag, bGPDcurve::flag, GP_CURVE_POINT_SELECT, GP_CURVE_SELECT, GP_EDITABLE_CURVES_BEGIN, GP_EDITABLE_CURVES_END, GP_EDITABLE_STROKES_BEGIN, GP_EDITABLE_STROKES_END, GP_STROKE_NEEDS_CURVE_UPDATE, GP_STROKE_SELECT, NULL, SEL_DESELECT, SEL_INVERT, SEL_SELECT, SEL_TOGGLE, bGPdata::select_last_index, and bGPDcurve::tot_curve_points.
Referenced by gpencil_circle_select_exec(), and gpencil_select_all_exec().
| int ED_gpencil_select_stroke_segment | ( | bGPdata * | gpd, |
| bGPDlayer * | gpl, | ||
| bGPDstroke * | gps, | ||
| bGPDspoint * | pt, | ||
| bool | select, | ||
| bool | insert, | ||
| const float | scale, | ||
| float | r_hita[3], | ||
| float | r_hitb[3] | ||
| ) |
Definition at line 2423 of file gpencil_utils.c.
References bGPDlayer::actframe, BKE_gpencil_stroke_2d_flat_ref(), BLI_ghash_free(), BLI_ghash_insert(), BLI_ghash_ptr_new(), BLI_ghashIterator_getValue(), BLI_listbase_count(), CLAMP_MAX, CLAMP_MIN, copy_v2_v2(), bGPDspoint::flag, float(), GHASH_ITER, GP_SPOINT_SELECT, gpencil_calc_factor(), gpencil_check_collision(), gpencil_insert_point(), bGPDlayer_Runtime::gpl_orig, if(), insert(), interp_v3_v3v3(), LISTBASE_FOREACH, MEM_callocN, MEM_dupallocN, MEM_mallocN, MEM_SAFE_FREE, NULL, bGPDstroke::points, bGPDlayer::runtime, select(), bGPDstroke::totpoints, and bGPDspoint::x.
Referenced by gpencil_cutter_lasso_select(), gpencil_generic_stroke_select(), gpencil_select_exec(), and gpencil_stroke_do_circle_sel().
| void ED_gpencil_select_toggle_all | ( | bContext * | C, |
| int | action | ||
| ) |
Definition at line 2621 of file gpencil_utils.c.
References BKE_gpencil_stroke_select_index_reset(), BKE_gpencil_stroke_select_index_set(), C, CTX_data_active_object(), CTX_DATA_BEGIN, CTX_DATA_END, Object::data, ED_gpencil_stroke_can_use(), bGPDspoint::flag, bGPDstroke::flag, GP_SPOINT_SELECT, GP_STROKE_SELECT, LISTBASE_FOREACH, bGPDstroke::next, bGPDstroke::points, SEL_DESELECT, SEL_INVERT, SEL_SELECT, SEL_TOGGLE, and bGPdata::select_last_index.
Referenced by gpencil_circle_select_exec(), and gpencil_select_all_exec().
Definition at line 2106 of file gpencil_utils.c.
References C, ED_gpencil_toggle_brush_cursor(), bGPdata::flag, GP_DATA_STROKE_EDITMODE, GP_DATA_STROKE_PAINTMODE, GP_DATA_STROKE_SCULPTMODE, GP_DATA_STROKE_VERTEXMODE, GP_DATA_STROKE_WEIGHTMODE, NULL, OB_MODE_EDIT_GPENCIL, OB_MODE_PAINT_GPENCIL, OB_MODE_SCULPT_GPENCIL, OB_MODE_VERTEX_GPENCIL, and OB_MODE_WEIGHT_GPENCIL.
Referenced by gpencil_convert_old_files_exec(), gpencil_editmode_toggle_exec(), gpencil_paintmode_toggle_exec(), gpencil_sculptmode_toggle_exec(), gpencil_vertexmode_toggle_exec(), and gpencil_weightmode_toggle_exec().
| bool ED_gpencil_stroke_can_use | ( | const bContext * | C, |
| const bGPDstroke * | gps | ||
| ) |
Definition at line 607 of file gpencil_utils.c.
References blender::compositor::area(), C, CTX_wm_area(), and ED_gpencil_stroke_can_use_direct().
Referenced by createTransGPencil_curves(), createTransGPencil_strokes(), ED_gpencil_select_toggle_all(), ED_gpencil_vgroup_assign(), ED_gpencil_vgroup_deselect(), ED_gpencil_vgroup_remove(), ED_gpencil_vgroup_select(), ED_transform_calc_gizmo_stats(), gpencil_add_verts_to_dgroups(), gpencil_brush_clone_add(), gpencil_brush_clone_init(), gpencil_cutter_lasso_select(), gpencil_delete_selected_points(), gpencil_delete_selected_strokes(), gpencil_duplicate_exec(), gpencil_extract_palette_from_vertex(), gpencil_extrude_exec(), gpencil_frame_clean_fill_exec(), gpencil_frame_clean_loose_exec(), gpencil_interpolate_seq_exec(), gpencil_lock_layer_exec(), gpencil_material_lock_unsused_exec(), gpencil_material_select_exec(), gpencil_material_to_vertex_exec(), gpencil_move_to_layer_exec(), gpencil_reveal_select_frame(), gpencil_sculpt_brush_do_frame(), gpencil_sculpt_brush_init(), gpencil_select_same_layer(), gpencil_selected_hue_table(), gpencil_snap_to_cursor(), gpencil_snap_to_grid(), gpencil_stroke_arrange_exec(), gpencil_stroke_caps_set_exec(), gpencil_stroke_change_color_exec(), gpencil_stroke_cyclical_set_exec(), gpencil_stroke_flip_exec(), gpencil_stroke_join_exec(), gpencil_stroke_pair_table(), gpencil_stroke_points_centroid(), gpencil_stroke_reset_vertex_color_exec(), gpencil_stroke_separate_exec(), gpencil_stroke_split_exec(), gpencil_stroke_trim_exec(), gpencil_strokes_copy_exec(), gpencil_strokes_paste_exec(), gpencil_vertexpaint_brightness_contrast_exec(), gpencil_vertexpaint_brush_do_frame(), gpencil_vertexpaint_hsv_exec(), gpencil_vertexpaint_invert_exec(), gpencil_vertexpaint_levels_exec(), gpencil_vertexpaint_set_exec(), gpencil_weightpaint_brush_do_frame(), and is_any_stroke_selected().
| bool ED_gpencil_stroke_can_use_direct | ( | const ScrArea * | area, |
| const bGPDstroke * | gps | ||
| ) |
Definition at line 582 of file gpencil_utils.c.
References blender::compositor::area(), ELEM, bGPDstroke::flag, GP_STROKE_2DIMAGE, GP_STROKE_2DSPACE, GP_STROKE_3DSPACE, NULL, SPACE_IMAGE, SPACE_PROPERTIES, and SPACE_VIEW3D.
Referenced by annotation_stroke_doeraser(), ED_gpencil_stroke_can_use(), gpencil_stroke_doeraser(), and screen_ctx_editable_gpencil_strokes().
| bool ED_gpencil_stroke_check_collision | ( | GP_SpaceConversion * | gsc, |
| bGPDstroke * | gps, | ||
| const float | mouse[2], | ||
| const int | radius, | ||
| const float | diff_mat[4][4] | ||
| ) |
Definition at line 3143 of file gpencil_utils.c.
References BKE_gpencil_stroke_boundingbox_calc(), BLI_rcti_isect(), bGPDstroke::boundbox_min, ceil(), ED_gpencil_projected_2d_bound_box(), is_zero_v3(), NULL, and sqrt().
Referenced by ED_gpencil_stroke_nearest_to_ends(), gpencil_sculpt_brush_do_frame(), gpencil_stroke_doeraser(), gpencil_vertexpaint_select_stroke(), and gpencil_weightpaint_select_stroke().
| void ED_gpencil_stroke_close_by_distance | ( | bGPDstroke * | gps, |
| const float | threshold | ||
| ) |
Definition at line 3376 of file gpencil_utils.c.
References BKE_gpencil_stroke_close(), bGPDstroke::flag, GP_STROKE_CYCLIC, len_squared_v3v3(), NULL, bGPDstroke::points, bGPDstroke::totpoints, and bGPDspoint::x.
Referenced by gpencil_primitive_interaction_end(), and gpencil_stroke_newfrombuffer().
| bGPDstroke* ED_gpencil_stroke_join_and_trim | ( | bGPdata * | gpd, |
| bGPDframe * | gpf, | ||
| bGPDstroke * | gps, | ||
| bGPDstroke * | gps_dst, | ||
| const int | pt_index | ||
| ) |
Definition at line 3306 of file gpencil_utils.c.
References BKE_gpencil_free_stroke(), BKE_gpencil_stroke_delete_tagged_points(), BKE_gpencil_stroke_join(), BKE_gpencil_stroke_merge_distance(), BKE_gpencil_stroke_segment_length(), BLI_assert, BLI_remlink(), bGPDspoint::flag, bGPDstroke::flag, GP_SPOINT_SELECT, GP_SPOINT_TAG, GP_STROKE_CYCLIC, GP_STROKE_TAG, bGPDstroke::next, NULL, bGPDstroke::points, bGPDframe::strokes, and bGPDstroke::totpoints.
Referenced by gpencil_primitive_interaction_end(), and gpencil_stroke_newfrombuffer().
| bool ED_gpencil_stroke_material_editable | ( | Object * | ob, |
| const bGPDlayer * | gpl, | ||
| const bGPDstroke * | gps | ||
| ) |
Definition at line 614 of file gpencil_utils.c.
References BKE_gpencil_material_settings(), bGPDlayer::flag, MaterialGPencilStyle::flag, GP_LAYER_UNLOCK_COLOR, GP_MATERIAL_HIDE, GP_MATERIAL_LOCKED, bGPDstroke::mat_nr, and NULL.
Referenced by createTransGPencil_curves(), createTransGPencil_strokes(), ED_gpencil_stroke_nearest_to_ends(), ED_gpencil_update_color_uv(), gpencil_cutter_lasso_select(), gpencil_delete_selected_points(), gpencil_extract_palette_from_vertex(), gpencil_interpolate_seq_exec(), gpencil_material_select_exec(), gpencil_material_to_vertex_exec(), gpencil_move_to_layer_exec(), gpencil_sculpt_brush_do_frame(), gpencil_selected_hue_table(), gpencil_snap_to_cursor(), gpencil_snap_to_grid(), gpencil_stroke_arrange_exec(), gpencil_stroke_change_color_exec(), gpencil_stroke_doeraser(), gpencil_stroke_flip_exec(), gpencil_stroke_join_exec(), gpencil_stroke_pair_table(), gpencil_stroke_points_centroid(), gpencil_stroke_separate_exec(), gpencil_stroke_split_exec(), gpencil_vertexpaint_brush_do_frame(), gpencil_weightpaint_brush_do_frame(), and screen_ctx_editable_gpencil_strokes().
| bool ED_gpencil_stroke_material_visible | ( | Object * | ob, |
| const bGPDstroke * | gps | ||
| ) |
Definition at line 632 of file gpencil_utils.c.
References BKE_gpencil_material_settings(), MaterialGPencilStyle::flag, GP_MATERIAL_HIDE, bGPDstroke::mat_nr, and NULL.
| bGPDstroke* ED_gpencil_stroke_nearest_to_ends | ( | bContext * | C, |
| GP_SpaceConversion * | gsc, | ||
| bGPDlayer * | gpl, | ||
| bGPDframe * | gpf, | ||
| bGPDstroke * | gps, | ||
| const float | radius, | ||
| int * | r_index | ||
| ) |
Definition at line 3216 of file gpencil_utils.c.
References BKE_gpencil_layer_transform_matrix_get(), C, CTX_data_active_object(), CTX_data_ensure_evaluated_depsgraph(), depsgraph, ED_gpencil_stroke_check_collision(), ED_gpencil_stroke_material_editable(), gpencil_point_to_parent_space(), gpencil_point_to_xy_fl(), len_squared_v2v2(), LISTBASE_FOREACH, NULL, bGPDstroke::points, bGPDframe::strokes, and bGPDstroke::totpoints.
Referenced by gpencil_primitive_interaction_end(), and gpencil_stroke_newfrombuffer().
| bool ED_gpencil_stroke_point_is_inside | ( | bGPDstroke * | gps, |
| GP_SpaceConversion * | gsc, | ||
| int | mouse[2], | ||
| const float | diff_mat[4][4] | ||
| ) |
Check if a point is inside of the stroke.
| gps | Stroke to check. |
| gsc | Space conversion data. |
| mouse | Mouse position. |
| diff_mat | View matrix. |
Definition at line 3178 of file gpencil_utils.c.
References BLI_lasso_boundbox(), BLI_lasso_is_point_inside(), BLI_rcti_isect_pt(), ELEM, gpencil_point_to_parent_space(), gpencil_point_to_xy(), len, MEM_mallocN, MEM_SAFE_FREE, NULL, bGPDstroke::points, bGPDstroke::totpoints, and V2D_IS_CLIPPED.
Referenced by gpencil_generic_stroke_select(), and gpencil_vertexpaint_select_stroke().
| void ED_gpencil_stroke_reproject | ( | Depsgraph * | depsgraph, |
| const GP_SpaceConversion * | gsc, | ||
| SnapObjectContext * | sctx, | ||
| bGPDlayer * | gpl, | ||
| bGPDframe * | gpf, | ||
| bGPDstroke * | gps, | ||
| const eGP_ReprojectModes | mode, | ||
| const bool | keep_original | ||
| ) |
Definition at line 1179 of file gpencil_utils.c.
References GP_SpaceConversion::area, BKE_gpencil_layer_transform_matrix_get(), BKE_gpencil_stroke_duplicate(), BKE_gpencil_stroke_select_index_reset(), BLI_addtail(), BLI_assert, copy_v3_v3(), Scene::cursor, depsgraph, ED_gpencil_drawing_reference_get(), ED_gpencil_project_point_to_plane(), ED_transform_snap_object_project_ray(), ED_view3d_win_to_ray_clipped(), ELEM, ListBase::first, bGPDspoint::flag, bGPDstroke::flag, GP_REPROJECT_CURSOR, GP_REPROJECT_FRONT, GP_REPROJECT_SIDE, GP_REPROJECT_TOP, GP_REPROJECT_VIEW, GP_SPOINT_SELECT, GP_STROKE_3DSPACE, GP_STROKE_SELECT, gpencil_apply_parent_point(), gpencil_point_to_parent_space(), gpencil_point_to_xy_fl(), gpencil_point_xy_to_3d(), ToolSettings::gpencil_v3d_align, invert_m4_m4(), bGPDlayer::layer_invmat, bGPDlayer::layer_mat, loc_eul_size_to_mat4(), bGPDlayer::location, View3DCursor::location, mul_m4_v3(), normal, GP_SpaceConversion::ob, bGPDstroke::points, GP_SpaceConversion::region, ARegion::regiondata, bGPDlayer::rotation, bGPDlayer::scale, GP_SpaceConversion::scene, SNAP_ALL, SPACE_VIEW3D, ScrArea::spacedata, ScrArea::spacetype, bGPDframe::strokes, Scene::toolsettings, and bGPDspoint::x.
Referenced by gpencil_strokes_reproject_exec().
| void ED_gpencil_tag_scene_gpencil | ( | Scene * | scene | ) |
Tag all scene grease pencil object to update.
Definition at line 2860 of file gpencil_utils.c.
References DEG_id_tag_update(), bGPdata::flag, FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN, FOREACH_COLLECTION_OBJECT_RECURSIVE_END, FOREACH_SCENE_COLLECTION_BEGIN, FOREACH_SCENE_COLLECTION_END, GP_DATA_CACHE_IS_DIRTY, bGPdata::id, Scene::id, ID_RECALC_COPY_ON_WRITE, ID_RECALC_GEOMETRY, ID_RECALC_TRANSFORM, NA_EDITED, NC_GPENCIL, NULL, OB_GPENCIL, scene, and WM_main_add_notifier().
| void ED_gpencil_toggle_brush_cursor | ( | bContext * | C, |
| bool | enable, | ||
| void * | customdata | ||
| ) |
Definition at line 2078 of file gpencil_utils.c.
References C, CTX_data_scene(), ToolSettings::gp_sculpt, gpencil_brush_cursor_draw(), gpencil_brush_cursor_poll(), NULL, GP_Sculpt_Settings::paintcursor, RGN_TYPE_ANY, scene, SPACE_TYPE_ANY, Scene::toolsettings, WM_paint_cursor_activate(), and WM_paint_cursor_end().
Referenced by ED_editors_init(), ED_gpencil_setup_modes(), ed_object_select_pick(), ed_undo_step_post(), ed_undo_step_pre(), gpencil_draw_apply(), gpencil_draw_exit(), gpencil_draw_invoke(), gpencil_draw_modal(), gpencil_draw_toggle_eraser_cursor(), and gpencil_guide_event_handling().
| void ED_gpencil_tpoint_to_point | ( | ARegion * | region, |
| float | origin[3], | ||
| const tGPspoint * | tpt, | ||
| bGPDspoint * | pt | ||
| ) |
Convert 2d tGPspoint to 3d bGPDspoint.
Definition at line 2195 of file gpencil_utils.c.
References copy_v3_v3(), gpencil_stroke_convertcoords(), tGPspoint::pressure, bGPDspoint::pressure, tGPspoint::strength, bGPDspoint::strength, tGPspoint::uv_fac, bGPDspoint::uv_fac, tGPspoint::uv_rot, bGPDspoint::uv_rot, bGPDspoint::vert_color, bGPDspoint::x, and zero_v4().
Referenced by gpencil_primitive_update_strokes(), gpencil_sbuffer_stroke_ensure(), and gpencil_stroke_addpoint().
Recalculate UV for any stroke using the material.
Definition at line 2215 of file gpencil_utils.c.
References BKE_gpencil_layer_is_editable(), BKE_gpencil_material(), BKE_gpencil_stroke_uv_update(), DEG_id_tag_update(), ED_gpencil_stroke_material_editable(), ListBase::first, bGPdata::id, ID_RECALC_GEOMETRY, ID_RECALC_TRANSFORM, bGPdata::layers, LISTBASE_FOREACH, NULL, OB_GPENCIL, and Main::objects.
Definition at line 1599 of file gpencil_utils.c.
References Object::actdef, BKE_defvert_ensure_index(), BKE_gpencil_dvert_ensure(), BLI_findlink(), C, CTX_DATA_BEGIN, CTX_DATA_END, Object::data, Object::defbase, ED_gpencil_stroke_can_use(), bGPDspoint::flag, GP_FRAME_SELECT, GP_SPOINT_SELECT, GP_STROKE_SELECT, GPENCIL_MULTIEDIT_SESSIONS_ON, bGPDframe::next, NULL, and MDeformWeight::weight.
Referenced by gpencil_vertex_group_assign_exec().
Definition at line 1761 of file gpencil_utils.c.
References Object::actdef, BKE_defvert_find_index(), BLI_findlink(), C, CTX_DATA_BEGIN, CTX_DATA_END, Object::data, Object::defbase, ED_gpencil_stroke_can_use(), bGPDspoint::flag, GP_FRAME_SELECT, GP_SPOINT_SELECT, GPENCIL_MULTIEDIT_SESSIONS_ON, bGPDframe::next, and NULL.
Referenced by gpencil_vertex_group_deselect_exec().
Definition at line 1653 of file gpencil_utils.c.
References Object::actdef, BKE_defvert_find_index(), BKE_defvert_remove_group(), BLI_findlink(), C, CTX_DATA_BEGIN, CTX_DATA_END, Object::data, Object::defbase, ED_gpencil_stroke_can_use(), bGPDspoint::flag, GP_FRAME_SELECT, GP_SPOINT_SELECT, GPENCIL_MULTIEDIT_SESSIONS_ON, bGPDframe::next, NULL, and MDeformVert::totweight.
Referenced by gpencil_vertex_group_remove_from_exec().
Definition at line 1706 of file gpencil_utils.c.
References Object::actdef, BKE_defvert_find_index(), BKE_gpencil_stroke_select_index_set(), BLI_findlink(), C, CTX_DATA_BEGIN, CTX_DATA_END, Object::data, Object::defbase, ED_gpencil_stroke_can_use(), bGPDspoint::flag, GP_FRAME_SELECT, GP_SPOINT_SELECT, GP_STROKE_SELECT, GPENCIL_MULTIEDIT_SESSIONS_ON, bGPDframe::next, and NULL.
Referenced by gpencil_vertex_group_select_exec().
| bool gpencil_active_brush_poll | ( | bContext * | C | ) |
Definition at line 380 of file gpencil_utils.c.
References Paint::brush, C, CTX_data_tool_settings(), ToolSettings::gp_paint, NULL, and GpPaint::paint.
| bool gpencil_active_layer_poll | ( | bContext * | C | ) |
Definition at line 367 of file gpencil_utils.c.
References BKE_gpencil_layer_active_get(), C, CTX_data_active_object(), Object::data, NULL, OB_GPENCIL, and Object::type.
Referenced by GPENCIL_OT_frame_clean_duplicate(), GPENCIL_OT_frame_clean_fill(), GPENCIL_OT_frame_clean_loose(), GPENCIL_OT_frame_duplicate(), GPENCIL_OT_hide(), GPENCIL_OT_layer_active(), GPENCIL_OT_layer_change(), GPENCIL_OT_layer_duplicate(), GPENCIL_OT_layer_isolate(), GPENCIL_OT_layer_mask_remove(), GPENCIL_OT_layer_merge(), GPENCIL_OT_layer_move(), GPENCIL_OT_layer_remove(), GPENCIL_OT_lock_layer(), GPENCIL_OT_material_lock_unused(), GPENCIL_OT_recalc_geometry(), GPENCIL_OT_stroke_apply_thickness(), GPENCIL_OT_stroke_arrange(), GPENCIL_OT_stroke_caps_set(), GPENCIL_OT_stroke_change_color(), GPENCIL_OT_stroke_cyclical_set(), GPENCIL_OT_stroke_enter_editcurve_mode(), GPENCIL_OT_stroke_flip(), GPENCIL_OT_stroke_join(), GPENCIL_OT_stroke_simplify(), GPENCIL_OT_stroke_simplify_fixed(), GPENCIL_OT_stroke_subdivide(), and GPENCIL_OT_stroke_trim().
| bool gpencil_add_poll | ( | bContext * | C | ) |
Definition at line 355 of file gpencil_utils.c.
References C, CTX_data_active_object(), Object::data, NULL, and return().
Referenced by GPENCIL_OT_blank_frame_add(), GPENCIL_OT_layer_add(), and GPENCIL_OT_layer_mask_add().
| void gpencil_apply_parent | ( | Depsgraph * | depsgraph, |
| Object * | obact, | ||
| bGPDlayer * | gpl, | ||
| bGPDstroke * | gps | ||
| ) |
Change position relative to parent object
Definition at line 714 of file gpencil_utils.c.
References BKE_gpencil_layer_transform_matrix_get(), copy_v3_v3(), depsgraph, invert_m4_m4(), mul_v3_m4v3(), bGPDstroke::points, bGPDstroke::totpoints, and bGPDspoint::x.
Referenced by gpencil_stroke_newfrombuffer().
| void gpencil_apply_parent_point | ( | Depsgraph * | depsgraph, |
| Object * | obact, | ||
| bGPDlayer * | gpl, | ||
| bGPDspoint * | pt | ||
| ) |
Change point position relative to parent object
Definition at line 737 of file gpencil_utils.c.
References BKE_gpencil_layer_transform_matrix_get(), copy_v3_v3(), depsgraph, invert_m4_m4(), mul_v3_m4v3(), and bGPDspoint::x.
Referenced by ED_gpencil_stroke_reproject(), gpencil_primitive_update_strokes(), gpencil_snap_to_cursor(), gpencil_snap_to_grid(), gpencil_stroke_from_buffer(), and gpencil_stroke_newfrombuffer().
|
static |
Helper callback for drawing the cursor itself.
Definition at line 1894 of file gpencil_utils.c.
References Brush::add_col, BKE_gpencil_object_material_from_brush_get(), BKE_paint_get_active_from_context(), Paint::brush, C, copy_v3_v3(), CTX_data_active_object(), CTX_data_scene(), CTX_wm_region(), ED_gpencil_brush_draw_eraser(), ED_gpencil_data_get_active(), BrushGpencilSettings::flag, bGPdata::flag, Paint::flags, GP_BRUSH_STABILIZE_MOUSE, GP_BRUSH_STABILIZE_MOUSE_TEMP, GP_DATA_STROKE_PAINTMODE, ToolSettings::gp_paint, GP_SCULPT_FLAG_INVERT, GP_SCULPT_FLAG_TMP_INVERT, ToolSettings::gp_sculptpaint, Material::gp_style, ToolSettings::gp_vertexpaint, ToolSettings::gp_weightpaint, GPAINT_TOOL_DRAW, GPAINT_TOOL_ERASE, GPAINT_TOOL_TINT, gpencil_check_cursor_region(), GPENCIL_PAINT_MODE, GPENCIL_SCULPT_MODE, Brush::gpencil_settings, Brush::gpencil_tool, GPENCIL_VERTEX_MODE, GPENCIL_WEIGHT_MODE, GPU_blend(), GPU_BLEND_ALPHA, GPU_BLEND_NONE, GPU_COMP_F32, GPU_FETCH_FLOAT, GPU_line_smooth(), GPU_PRIM_LINES, GPU_SHADER_2D_UNIFORM_COLOR, GPU_vertformat_attr_add(), imm_draw_circle_fill_2d(), imm_draw_circle_wire_2d(), immBegin(), immBindBuiltinProgram(), immEnd(), immUnbindProgram(), immUniformColor4f(), immVertex2f(), immVertexFormat(), mul_v3_v3fl(), NULL, GpPaint::paint, GpVertexPaint::paint, GpSculptPaint::paint, GpWeightPaint::paint, PAINT_SHOW_BRUSH, pos, Brush::rgb, bGPdata::runtime, bGPdata_Runtime::sbuffer_used, scene, BrushGpencilSettings::sculpt_flag, Brush::size, MaterialGPencilStyle::stroke_rgba, Brush::sub_col, Scene::toolsettings, ARegion::winrct, x, rcti::xmin, y, and rcti::ymin.
Referenced by ED_gpencil_toggle_brush_cursor().
|
static |
Definition at line 1883 of file gpencil_utils.c.
References C, and WM_toolsystem_active_tool_is_brush().
Referenced by ED_gpencil_toggle_brush_cursor().
|
static |
Definition at line 2404 of file gpencil_utils.c.
References interp_v2_v2v2(), len_squared_v2v2(), and v1.
Referenced by ED_gpencil_select_stroke_segment().
|
static |
Definition at line 2249 of file gpencil_utils.c.
References BLI_ghash_lookup(), copy_v2_v2(), equals_v2v2(), float(), isect_seg_seg_v2_point(), bGPDstroke::totpoints, and zero_v2().
Referenced by ED_gpencil_select_stroke_segment().
|
static |
Definition at line 1814 of file gpencil_utils.c.
References blender::compositor::area(), BLI_rcti_isect_pt_v(), C, CTX_data_active_object(), CTX_wm_area(), CTX_wm_region(), ELEM, Object::mode, NULL, OB_MODE_PAINT_GPENCIL, OB_MODE_SCULPT_GPENCIL, OB_MODE_VERTEX_GPENCIL, OB_MODE_WEIGHT_GPENCIL, ARegion::regiontype, RGN_TYPE_WINDOW, SPACE_VIEW3D, and ARegion::winrct.
Referenced by gpencil_brush_cursor_draw().
|
static |
Definition at line 2301 of file gpencil_utils.c.
References copy_v3_v3(), copy_v4_v4(), bGPDstroke::dvert, MDeformVert::dw, bGPDspoint::flag, MEM_dupallocN, MEM_SAFE_FREE, NULL, bGPDspoint::pressure, bGPDspoint::strength, bGPDspoint::time, MDeformVert::totweight, bGPDspoint::uv_fac, bGPDspoint::uv_rot, bGPDspoint::vert_color, and bGPDspoint::x.
Referenced by gpencil_insert_point().
|
static |
Definition at line 2334 of file gpencil_utils.c.
References BKE_gpencil_stroke_geometry_update(), copy_v3_v3(), bGPDstroke::dvert, ELEM, bGPDspoint::flag, GP_SPOINT_SELECT, GP_SPOINT_TAG, gpencil_copy_points(), MEM_dupallocN, MEM_recallocN, MEM_SAFE_FREE, NULL, bGPDstroke::points, bGPDstroke::totpoints, and bGPDspoint::x.
Referenced by ED_gpencil_select_stroke_segment().
| void gpencil_point_3d_to_xy | ( | const GP_SpaceConversion * | gsc, |
| const short | flag, | ||
| const float | pt[3], | ||
| float | xy[2] | ||
| ) |
generic based on gpencil_point_to_xy_fl
Definition at line 879 of file gpencil_utils.c.
References GP_SpaceConversion::area, BLI_assert, BLI_rctf_size_x(), BLI_rctf_size_y(), ED_view3d_project_float_global(), float(), GP_STROKE_2DSPACE, GP_STROKE_3DSPACE, GP_SpaceConversion::mat, mul_m4_v3(), NULL, GP_SpaceConversion::region, SPACE_VIEW3D, ScrArea::spacetype, GP_SpaceConversion::subrect, UI_view2d_view_to_region_clip(), GP_SpaceConversion::v2d, V2D_IS_CLIPPED, V3D_PROJ_RET_OK, V3D_PROJ_TEST_NOP, ARegion::winx, ARegion::winy, rctf::xmin, and rctf::ymin.
Referenced by gpencil_origin_get(), gpencil_sculpt_rotation_eval_get(), and gpencil_uv_transform_init().
| void gpencil_point_conversion_init | ( | bContext * | C, |
| GP_SpaceConversion * | r_gsc | ||
| ) |
Init settings for stroke point space conversions
| r_gsc | [out] The space conversion settings struct, populated with necessary params |
Definition at line 654 of file gpencil_utils.c.
References blender::compositor::area(), GP_SpaceConversion::area, C, CTX_data_active_object(), CTX_data_ensure_evaluated_depsgraph(), CTX_data_scene(), CTX_wm_area(), CTX_wm_region(), CTX_wm_space_data(), CTX_wm_window(), depsgraph, ED_view3d_calc_camera_border(), ED_view3d_depth_override(), GP_SpaceConversion::mat, NULL, GP_SpaceConversion::ob, RegionView3D::persp, GP_SpaceConversion::region, ARegion::regiondata, RV3D_CAMOB, scene, GP_SpaceConversion::scene, SPACE_VIEW3D, GP_SpaceConversion::subrect, GP_SpaceConversion::subrect_data, unit_m4(), GP_SpaceConversion::v2d, ARegion::v2d, V3D_DEPTH_NO_GPENCIL, view3d_operator_needs_opengl(), and view3d_region_operator_needs_opengl().
Referenced by ED_gpencil_project_stroke_to_view(), gpencil_circle_select_exec(), gpencil_cutter_lasso_select(), gpencil_generic_stroke_select(), gpencil_interpolate_seq_exec(), gpencil_interpolate_set_init_values(), gpencil_primitive_init(), gpencil_sculpt_brush_init(), gpencil_select_exec(), gpencil_session_init_fill(), gpencil_strokes_reproject_exec(), gpencil_uv_transform_init(), gpencil_vertexpaint_brush_init(), and gpencil_weightpaint_brush_init().
| void gpencil_point_to_parent_space | ( | const bGPDspoint * | pt, |
| const float | diff_mat[4][4], | ||
| bGPDspoint * | r_pt | ||
| ) |
Convert point to parent space
| pt | Original point | |
| diff_mat | Matrix with the difference between original parent matrix | |
| [out] | r_pt | Pointer to new point after apply matrix |
Definition at line 701 of file gpencil_utils.c.
References copy_v3_v3(), mul_v3_m4v3(), and bGPDspoint::x.
Referenced by ED_gpencil_project_stroke_to_view(), ED_gpencil_projected_2d_bound_box(), ED_gpencil_stroke_nearest_to_ends(), ED_gpencil_stroke_point_is_inside(), ED_gpencil_stroke_reproject(), gpencil_sculpt_brush_do_stroke(), gpencil_select_exec(), gpencil_stroke_do_circle_sel(), gpencil_stroke_eraser_dostroke(), gpencil_stroke_need_flip(), gpencil_test_lasso(), gpencil_vertexpaint_select_stroke(), and gpencil_weightpaint_select_stroke().
| void gpencil_point_to_xy | ( | const GP_SpaceConversion * | gsc, |
| const bGPDstroke * | gps, | ||
| const bGPDspoint * | pt, | ||
| int * | r_x, | ||
| int * | r_y | ||
| ) |
Convert a Grease Pencil coordinate (i.e. can be 2D or 3D) to screenspace (2D)
| [out] | r_x | The screen-space x-coordinate of the point |
| [out] | r_y | The screen-space y-coordinate of the point |
Definition at line 764 of file gpencil_utils.c.
References GP_SpaceConversion::area, BLI_assert, BLI_rctf_size_x(), BLI_rctf_size_y(), ED_view3d_project_int_global(), bGPDstroke::flag, GP_STROKE_2DSPACE, GP_STROKE_3DSPACE, GP_SpaceConversion::mat, mul_m4_v3(), NULL, GP_SpaceConversion::region, SPACE_VIEW3D, ScrArea::spacetype, GP_SpaceConversion::subrect, UI_view2d_view_to_region_clip(), GP_SpaceConversion::v2d, V2D_IS_CLIPPED, V3D_PROJ_RET_OK, V3D_PROJ_TEST_NOP, ARegion::winx, ARegion::winy, bGPDspoint::x, rctf::xmin, bGPDspoint::y, and rctf::ymin.
Referenced by ED_gpencil_stroke_point_is_inside().
| void gpencil_point_to_xy_fl | ( | const GP_SpaceConversion * | gsc, |
| const bGPDstroke * | gps, | ||
| const bGPDspoint * | pt, | ||
| float * | r_x, | ||
| float * | r_y | ||
| ) |
Convert a Grease Pencil coordinate (i.e. can be 2D or 3D) to screenspace (2D).
Just like gpencil_point_to_xy(), except the resulting coordinates are floats not ints. Use this version to solve "stair-step" artifacts which may arise when roundtripping the calculations.
| r_x | The screen-space x-coordinate of the point. |
| r_y | The screen-space y-coordinate of the point. |
Definition at line 819 of file gpencil_utils.c.
References GP_SpaceConversion::area, BLI_assert, BLI_rctf_size_x(), BLI_rctf_size_y(), ED_view3d_project_float_global(), bGPDstroke::flag, float(), GP_STROKE_2DSPACE, GP_STROKE_3DSPACE, GP_SpaceConversion::mat, mul_m4_v3(), NULL, GP_SpaceConversion::region, SPACE_VIEW3D, ScrArea::spacetype, GP_SpaceConversion::subrect, UI_view2d_view_to_region_clip(), GP_SpaceConversion::v2d, V2D_IS_CLIPPED, V3D_PROJ_RET_OK, V3D_PROJ_TEST_NOP, ARegion::winx, ARegion::winy, bGPDspoint::x, rctf::xmin, bGPDspoint::y, and rctf::ymin.
Referenced by ED_gpencil_project_stroke_to_view(), ED_gpencil_projected_2d_bound_box(), ED_gpencil_stroke_nearest_to_ends(), ED_gpencil_stroke_reproject(), and gpencil_stroke_need_flip().
| bool gpencil_point_xy_to_3d | ( | const GP_SpaceConversion * | gsc, |
| Scene * | scene, | ||
| const float | screen_co[2], | ||
| float | r_out[3] | ||
| ) |
Project screenspace coordinates to 3D-space
For use with editing tools where it is easier to perform the operations in 2D, and then later convert the transformed points back to 3D.
| screen_co | The screenspace 2D coordinates to convert to |
| r_out | The resulting 3D coordinates of the input point |
Definition at line 948 of file gpencil_utils.c.
References copy_v2_v2(), ED_gpencil_drawing_reference_get(), ED_view3d_calc_zfac(), ED_view3d_project_float_global(), ED_view3d_win_to_delta(), ToolSettings::gpencil_v3d_align, NULL, GP_SpaceConversion::ob, GP_SpaceConversion::region, ARegion::regiondata, scene, sub_v2_v2v2(), sub_v3_v3v3(), Scene::toolsettings, V3D_PROJ_RET_OK, V3D_PROJ_TEST_NOP, and zero_v3().
Referenced by ED_gpencil_project_stroke_to_view(), and ED_gpencil_stroke_reproject().
|
static |
Definition at line 2967 of file gpencil_utils.c.
References add_v3_v3(), BKE_curvemapping_evaluateF(), BLI_hash_int_01(), BLI_hash_int_2d(), ceil(), CLAMP3, BrushGpencilSettings::curve_rand_hue, BrushGpencilSettings::curve_rand_saturation, BrushGpencilSettings::curve_rand_value, BrushGpencilSettings::flag, BrushGpencilSettings::flag2, GP_BRUSH_GROUP_RANDOM, GP_BRUSH_USE_HUE_AT_STROKE, GP_BRUSH_USE_HUE_RAND_PRESS, GP_BRUSH_USE_SAT_AT_STROKE, GP_BRUSH_USE_SAT_RAND_PRESS, GP_BRUSH_USE_VAL_AT_STROKE, GP_BRUSH_USE_VAL_RAND_PRESS, Brush::gpencil_settings, hsv_to_rgb_v(), PIL_check_seconds_timer(), BrushGpencilSettings::random_hue, BrushGpencilSettings::random_saturation, BrushGpencilSettings::random_value, rgb_to_hsv_v(), bGPdata::runtime, bGPdata_Runtime::sbuffer_used, seed, tGPspoint::vert_color, tGPspoint::x, tGPspoint::y, and zero_v3().
Referenced by ED_gpencil_sbuffer_vertex_color_set().
|
static |
Helper to convert 2d to 3d for simple drawing buffer.
Definition at line 2167 of file gpencil_utils.c.
References copy_v3_v3(), ED_view3d_calc_zfac(), ED_view3d_project_float_global(), ED_view3d_win_to_delta(), float(), NULL, ARegion::regiondata, sub_v2_v2v2(), sub_v3_v3v3(), V3D_PROJ_RET_OK, V3D_PROJ_TEST_NOP, tGPspoint::x, tGPspoint::y, and zero_v3().
Referenced by ED_gpencil_tpoint_to_point().
| void gpencil_stroke_convertcoords_tpoint | ( | Scene * | scene, |
| ARegion * | region, | ||
| Object * | ob, | ||
| const tGPspoint * | point2D, | ||
| float * | depth, | ||
| float | r_out[3] | ||
| ) |
Convert tGPspoint (temporary 2D/screenspace point data used by GP modal operators) to 3D coordinates.
| point2D | The screen-space 2D point data to convert. |
| depth | Depth array (via ED_view3d_autodist_depth()). |
| r_out | The resulting 2D point data. |
Definition at line 985 of file gpencil_utils.c.
References ED_gpencil_drawing_reference_get(), ED_view3d_autodist_simple(), ED_view3d_calc_zfac(), ED_view3d_project_float_global(), ED_view3d_win_to_delta(), ToolSettings::gpencil_v3d_align, NULL, ARegion::regiondata, round_v2i_v2fl(), scene, sub_v2_v2v2(), sub_v3_v3v3(), Scene::toolsettings, V3D_PROJ_RET_OK, V3D_PROJ_TEST_NOP, tGPspoint::x, tGPspoint::y, and zero_v3().
| bool gpencil_stroke_inside_circle | ( | const float | mval[2], |
| int | rad, | ||
| int | x0, | ||
| int | y0, | ||
| int | x1, | ||
| int | y1 | ||
| ) |
Check whether a given stroke segment is inside a circular brush
| mval | The current screen-space coordinates (midpoint) of the brush |
| rad | The radius of the brush |
| x0,y0 | The screen-space x and y coordinates of the start of the stroke segment |
| x1,y1 | The screen-space x and y coordinates of the end of the stroke segment |
Definition at line 531 of file gpencil_utils.c.
References edge_inside_circle(), and y1.
Referenced by annotation_stroke_eraser_dostroke(), gpencil_sculpt_brush_do_stroke(), gpencil_stroke_eraser_dostroke(), gpencil_vertexpaint_select_stroke(), and gpencil_weightpaint_select_stroke().
| void gpencil_subdivide_stroke | ( | bGPdata * | gpd, |
| bGPDstroke * | gps, | ||
| const int | subdivide | ||
| ) |
Subdivide a stroke once, by adding a point half way between each pair of existing points
| gpd | Datablock |
| gps | Stroke data |
| subdivide | Number of times to subdivide |
Definition at line 1410 of file gpencil_utils.c.
References BKE_gpencil_stroke_geometry_update(), CLAMP, copy_v3_v3(), copy_v4_v4(), bGPDstroke::dvert, MDeformVert::dw, bGPDspoint::flag, GPENCIL_STRENGTH_MIN, interp_v3_v3v3(), interp_v4_v4v4(), interpf(), MEM_dupallocN, MEM_recallocN, MEM_SAFE_FREE, next, NULL, bGPDstroke::points, bGPDspoint::pressure, bGPDspoint::strength, bGPDspoint::time, bGPDstroke::totpoints, MDeformVert::totweight, bGPDspoint::uv_fac, bGPDspoint::uv_rot, bGPDspoint::vert_color, and bGPDspoint::x.
Referenced by gpencil_stroke_newfrombuffer().