Blender  V3.3
Classes | Typedefs | Enumerations | Functions | Variables
paint_cursor.c File Reference
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_rect.h"
#include "BLI_task.h"
#include "BLI_utildefines.h"
#include "DNA_brush_types.h"
#include "DNA_color_types.h"
#include "DNA_customdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
#include "DNA_view3d_types.h"
#include "BKE_brush.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_image.h"
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "NOD_texture.h"
#include "WM_api.h"
#include "wm_cursors.h"
#include "IMB_imbuf_types.h"
#include "ED_image.h"
#include "ED_view3d.h"
#include "DEG_depsgraph.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "GPU_state.h"
#include "GPU_texture.h"
#include "UI_resources.h"
#include "paint_intern.h"
#include "sculpt_intern.h"

Go to the source code of this file.

Classes

struct  TexSnapshot
 
struct  CursorSnapshot
 
struct  LoadTexData
 
struct  PaintCursorContext
 

Typedefs

typedef struct TexSnapshot TexSnapshot
 
typedef struct CursorSnapshot CursorSnapshot
 
typedef struct LoadTexData LoadTexData
 
typedef enum PaintCursorDrawingType PaintCursorDrawingType
 
typedef struct PaintCursorContext PaintCursorContext
 

Enumerations

enum  PaintCursorDrawingType { PAINT_CURSOR_CURVE , PAINT_CURSOR_2D , PAINT_CURSOR_3D }
 

Functions

void paint_cursor_delete_textures (void)
 
static int same_tex_snap (TexSnapshot *snap, MTex *mtex, ViewContext *vc, bool col, float zoom)
 
static void make_tex_snap (TexSnapshot *snap, ViewContext *vc, float zoom)
 
static void load_tex_task_cb_ex (void *__restrict userdata, const int j, const TaskParallelTLS *__restrict tls)
 
static int load_tex (Brush *br, ViewContext *vc, float zoom, bool col, bool primary)
 
static void load_tex_cursor_task_cb (void *__restrict userdata, const int j, const TaskParallelTLS *__restrict UNUSED(tls))
 
static int load_tex_cursor (Brush *br, ViewContext *vc, float zoom)
 
static int project_brush_radius (ViewContext *vc, float radius, const float location[3])
 
static bool paint_draw_tex_overlay (UnifiedPaintSettings *ups, Brush *brush, ViewContext *vc, int x, int y, float zoom, const ePaintMode mode, bool col, bool primary)
 
static bool paint_draw_cursor_overlay (UnifiedPaintSettings *ups, Brush *brush, ViewContext *vc, int x, int y, float zoom)
 
static bool paint_draw_alpha_overlay (UnifiedPaintSettings *ups, Brush *brush, ViewContext *vc, int x, int y, float zoom, ePaintMode mode)
 
BLI_INLINE void draw_tri_point (uint pos, const float sel_col[4], const float pivot_col[4], float *co, float width, bool selected)
 
BLI_INLINE void draw_rect_point (uint pos, const float sel_col[4], const float handle_col[4], const float *co, float width, bool selected)
 
BLI_INLINE void draw_bezier_handle_lines (uint pos, const float sel_col[4], BezTriple *bez)
 
static void paint_draw_curve_cursor (Brush *brush, ViewContext *vc)
 
static void paint_cursor_update_unprojected_radius (UnifiedPaintSettings *ups, Brush *brush, ViewContext *vc, const float location[3])
 
static void cursor_draw_point_screen_space (const uint gpuattr, const ARegion *region, const float true_location[3], const float obmat[4][4], const int size)
 
static void cursor_draw_tiling_preview (const uint gpuattr, const ARegion *region, const float true_location[3], Sculpt *sd, Object *ob, const float radius)
 
static void cursor_draw_point_with_symmetry (const uint gpuattr, const ARegion *region, const float true_location[3], Sculpt *sd, Object *ob, const float radius)
 
static void sculpt_geometry_preview_lines_draw (const uint gpuattr, Brush *brush, const bool is_multires, SculptSession *ss)
 
static void SCULPT_layer_brush_height_preview_draw (const uint gpuattr, const Brush *brush, const float rds, const float line_width, const float outline_col[3], const float alpha)
 
static bool paint_use_2d_cursor (ePaintMode mode)
 
static bool paint_cursor_context_init (bContext *C, const int x, const int y, PaintCursorContext *pcontext)
 
static void paint_cursor_update_pixel_radius (PaintCursorContext *pcontext)
 
static void paint_cursor_sculpt_session_update_and_init (PaintCursorContext *pcontext)
 
static void paint_update_mouse_cursor (PaintCursorContext *pcontext)
 
static void paint_draw_2D_view_brush_cursor (PaintCursorContext *pcontext)
 
static void paint_draw_legacy_3D_view_brush_cursor (PaintCursorContext *pcontext)
 
static void paint_draw_3D_view_inactive_brush_cursor (PaintCursorContext *pcontext)
 
static void paint_cursor_update_object_space_radius (PaintCursorContext *pcontext)
 
static void paint_cursor_drawing_setup_cursor_space (PaintCursorContext *pcontext)
 
static void paint_cursor_draw_main_inactive_cursor (PaintCursorContext *pcontext)
 
static void paint_cursor_pose_brush_segments_draw (PaintCursorContext *pcontext)
 
static void paint_cursor_pose_brush_origins_draw (PaintCursorContext *pcontext)
 
static void paint_cursor_preview_boundary_data_pivot_draw (PaintCursorContext *pcontext)
 
static void paint_cursor_preview_boundary_data_update (PaintCursorContext *pcontext, const bool update_previews)
 
static void paint_cursor_draw_3d_view_brush_cursor_inactive (PaintCursorContext *pcontext)
 
static void paint_cursor_cursor_draw_3d_view_brush_cursor_active (PaintCursorContext *pcontext)
 
static void paint_cursor_draw_3D_view_brush_cursor (PaintCursorContext *pcontext)
 
static bool paint_cursor_is_3d_view_navigating (PaintCursorContext *pcontext)
 
static bool paint_cursor_is_brush_cursor_enabled (PaintCursorContext *pcontext)
 
static void paint_cursor_update_rake_rotation (PaintCursorContext *pcontext)
 
static void paint_cursor_check_and_draw_alpha_overlays (PaintCursorContext *pcontext)
 
static void paint_cursor_update_anchored_location (PaintCursorContext *pcontext)
 
static void paint_cursor_setup_2D_drawing (PaintCursorContext *pcontext)
 
static void paint_cursor_setup_3D_drawing (PaintCursorContext *pcontext)
 
static void paint_cursor_restore_drawing_state (void)
 
static void paint_draw_cursor (bContext *C, int x, int y, void *UNUSED(unused))
 
void ED_paint_cursor_start (Paint *p, bool(*poll)(bContext *C))
 

Variables

static TexSnapshot primary_snap = {0}
 
static TexSnapshot secondary_snap = {0}
 
static CursorSnapshot cursor_snap = {0}
 

Typedef Documentation

◆ CursorSnapshot

◆ LoadTexData

typedef struct LoadTexData LoadTexData

◆ PaintCursorContext

◆ PaintCursorDrawingType

◆ TexSnapshot

typedef struct TexSnapshot TexSnapshot

Enumeration Type Documentation

◆ PaintCursorDrawingType

Enumerator
PAINT_CURSOR_CURVE 
PAINT_CURSOR_2D 
PAINT_CURSOR_3D 

Definition at line 1195 of file paint_cursor.c.

Function Documentation

◆ cursor_draw_point_screen_space()

static void cursor_draw_point_screen_space ( const uint  gpuattr,
const ARegion region,
const float  true_location[3],
const float  obmat[4][4],
const int  size 
)
static

◆ cursor_draw_point_with_symmetry()

static void cursor_draw_point_with_symmetry ( const uint  gpuattr,
const ARegion region,
const float  true_location[3],
Sculpt sd,
Object ob,
const float  radius 
)
static

◆ cursor_draw_tiling_preview()

static void cursor_draw_tiling_preview ( const uint  gpuattr,
const ARegion region,
const float  true_location[3],
Sculpt sd,
Object ob,
const float  radius 
)
static

◆ draw_bezier_handle_lines()

BLI_INLINE void draw_bezier_handle_lines ( uint  pos,
const float  sel_col[4],
BezTriple bez 
)

◆ draw_rect_point()

BLI_INLINE void draw_rect_point ( uint  pos,
const float  sel_col[4],
const float  handle_col[4],
const float co,
float  width,
bool  selected 
)

◆ draw_tri_point()

BLI_INLINE void draw_tri_point ( uint  pos,
const float  sel_col[4],
const float  pivot_col[4],
float co,
float  width,
bool  selected 
)

◆ ED_paint_cursor_start()

void ED_paint_cursor_start ( Paint p,
bool(*)(bContext *C poll 
)

◆ load_tex()

static int load_tex ( Brush br,
ViewContext vc,
float  zoom,
bool  col,
bool  primary 
)
static

◆ load_tex_cursor()

static int load_tex_cursor ( Brush br,
ViewContext vc,
float  zoom 
)
static

◆ load_tex_cursor_task_cb()

static void load_tex_cursor_task_cb ( void *__restrict  userdata,
const int  j,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static

Definition at line 363 of file paint_cursor.c.

References BKE_brush_curve_strength_clamped(), buffer, data, float(), len, size(), sqrtf, x, and y.

Referenced by load_tex_cursor().

◆ load_tex_task_cb_ex()

static void load_tex_task_cb_ex ( void *__restrict  userdata,
const int  j,
const TaskParallelTLS *__restrict  tls 
)
static

◆ make_tex_snap()

static void make_tex_snap ( TexSnapshot snap,
ViewContext vc,
float  zoom 
)
static

Definition at line 119 of file paint_cursor.c.

References ViewContext::region, snap(), ARegion::winx, and ARegion::winy.

Referenced by load_tex().

◆ paint_cursor_check_and_draw_alpha_overlays()

static void paint_cursor_check_and_draw_alpha_overlays ( PaintCursorContext pcontext)
static

◆ paint_cursor_context_init()

static bool paint_cursor_context_init ( bContext C,
const int  x,
const int  y,
PaintCursorContext pcontext 
)
static

◆ paint_cursor_cursor_draw_3d_view_brush_cursor_active()

static void paint_cursor_cursor_draw_3d_view_brush_cursor_active ( PaintCursorContext pcontext)
static

◆ paint_cursor_delete_textures()

void paint_cursor_delete_textures ( void  )

◆ paint_cursor_draw_3D_view_brush_cursor()

static void paint_cursor_draw_3D_view_brush_cursor ( PaintCursorContext pcontext)
static

◆ paint_cursor_draw_3d_view_brush_cursor_inactive()

static void paint_cursor_draw_3d_view_brush_cursor_inactive ( PaintCursorContext pcontext)
static

Definition at line 1560 of file paint_cursor.c.

References PaintCursorContext::alpha_overlay_drawn, BKE_sculpt_update_object_for_edit(), PaintCursorContext::brush, BRUSH_CLOTH_SIMULATION_AREA_GLOBAL, BRUSH_GRAB_ACTIVE_VERTEX, PaintCursorContext::C, Brush::cloth_simulation_area_type, CTX_wm_view3d(), cursor_draw_point_screen_space(), cursor_draw_point_with_symmetry(), PaintCursorContext::depsgraph, ED_view3d_draw_setup_view(), SculptSession::expand_cache, Brush::falloff_shape, Brush::flag, GPU_matrix_mul, GPU_matrix_pop(), GPU_matrix_pop_projection(), GPU_matrix_push(), GPU_matrix_push_projection(), immUniformColor3fvAlpha(), ExpandCache::initial_active_vertex, PaintCursorContext::is_cursor_over_mesh, PaintCursorContext::is_multires, len_v3v3(), PaintCursorContext::location, NULL, ViewContext::obact, Object::obmat, PaintCursorContext::outline_alpha, PaintCursorContext::outline_col, PAINT_brush_tool_poll(), paint_cursor_draw_main_inactive_cursor(), paint_cursor_drawing_setup_cursor_space(), paint_cursor_pose_brush_origins_draw(), paint_cursor_pose_brush_segments_draw(), paint_cursor_preview_boundary_data_pivot_draw(), paint_cursor_preview_boundary_data_update(), paint_cursor_update_object_space_radius(), paint_draw_3D_view_inactive_brush_cursor(), paint_draw_legacy_3D_view_brush_cursor(), PAINT_FALLOFF_SHAPE_TUBE, PaintCursorContext::pos, SculptSession::pose_ik_chain_preview, PaintCursorContext::prev_active_vertex_index, PaintCursorContext::radius, PaintCursorContext::region, PaintCursorContext::scene, SCULPT_active_vertex_co_get(), SCULPT_active_vertex_get(), SCULPT_boundary_edges_preview_draw(), SCULPT_boundary_pivot_line_preview_draw(), SCULPT_cloth_simulation_limits_draw(), sculpt_geometry_preview_lines_draw(), SCULPT_geometry_preview_lines_update(), SCULPT_layer_brush_height_preview_draw(), SCULPT_pose_ik_chain_free(), SCULPT_pose_ik_chain_init(), Brush::sculpt_tool, SCULPT_TOOL_BOUNDARY, SCULPT_TOOL_CLOTH, SCULPT_TOOL_GRAB, SCULPT_TOOL_LAYER, SCULPT_TOOL_POSE, SCULPT_vertex_co_for_grab_active_get(), SCULPT_vertex_co_get(), PaintCursorContext::sd, PaintCursorContext::ss, PaintCursorContext::vc, PaintCursorContext::win, ARegion::winrct, PaintCursorContext::wm, wmViewport(), and wmWindowViewport().

Referenced by paint_cursor_draw_3D_view_brush_cursor().

◆ paint_cursor_draw_main_inactive_cursor()

static void paint_cursor_draw_main_inactive_cursor ( PaintCursorContext pcontext)
static

◆ paint_cursor_drawing_setup_cursor_space()

static void paint_cursor_drawing_setup_cursor_space ( PaintCursorContext pcontext)
static

◆ paint_cursor_is_3d_view_navigating()

static bool paint_cursor_is_3d_view_navigating ( PaintCursorContext pcontext)
static

◆ paint_cursor_is_brush_cursor_enabled()

static bool paint_cursor_is_brush_cursor_enabled ( PaintCursorContext pcontext)
static

◆ paint_cursor_pose_brush_origins_draw()

static void paint_cursor_pose_brush_origins_draw ( PaintCursorContext pcontext)
static

◆ paint_cursor_pose_brush_segments_draw()

static void paint_cursor_pose_brush_segments_draw ( PaintCursorContext pcontext)
static

◆ paint_cursor_preview_boundary_data_pivot_draw()

static void paint_cursor_preview_boundary_data_pivot_draw ( PaintCursorContext pcontext)
static

◆ paint_cursor_preview_boundary_data_update()

static void paint_cursor_preview_boundary_data_update ( PaintCursorContext pcontext,
const bool  update_previews 
)
static

◆ paint_cursor_restore_drawing_state()

static void paint_cursor_restore_drawing_state ( void  )
static

Definition at line 1891 of file paint_cursor.c.

References GPU_blend(), GPU_BLEND_NONE, GPU_line_smooth(), and immUnbindProgram().

Referenced by paint_draw_cursor().

◆ paint_cursor_sculpt_session_update_and_init()

static void paint_cursor_sculpt_session_update_and_init ( PaintCursorContext pcontext)
static

◆ paint_cursor_setup_2D_drawing()

static void paint_cursor_setup_2D_drawing ( PaintCursorContext pcontext)
static

◆ paint_cursor_setup_3D_drawing()

static void paint_cursor_setup_3D_drawing ( PaintCursorContext pcontext)
static

◆ paint_cursor_update_anchored_location()

static void paint_cursor_update_anchored_location ( PaintCursorContext pcontext)
static

◆ paint_cursor_update_object_space_radius()

static void paint_cursor_update_object_space_radius ( PaintCursorContext pcontext)
static

◆ paint_cursor_update_pixel_radius()

static void paint_cursor_update_pixel_radius ( PaintCursorContext pcontext)
static

◆ paint_cursor_update_rake_rotation()

static void paint_cursor_update_rake_rotation ( PaintCursorContext pcontext)
static

◆ paint_cursor_update_unprojected_radius()

static void paint_cursor_update_unprojected_radius ( UnifiedPaintSettings ups,
Brush brush,
ViewContext vc,
const float  location[3] 
)
static

◆ paint_draw_2D_view_brush_cursor()

static void paint_draw_2D_view_brush_cursor ( PaintCursorContext pcontext)
static

◆ paint_draw_3D_view_inactive_brush_cursor()

static void paint_draw_3D_view_inactive_brush_cursor ( PaintCursorContext pcontext)
static

◆ paint_draw_alpha_overlay()

static bool paint_draw_alpha_overlay ( UnifiedPaintSettings ups,
Brush brush,
ViewContext vc,
int  x,
int  y,
float  zoom,
ePaintMode  mode 
)
static

◆ paint_draw_cursor()

static void paint_draw_cursor ( bContext C,
int  x,
int  y,
void UNUSEDunused 
)
static

◆ paint_draw_cursor_overlay()

static bool paint_draw_cursor_overlay ( UnifiedPaintSettings ups,
Brush brush,
ViewContext vc,
int  x,
int  y,
float  zoom 
)
static

◆ paint_draw_curve_cursor()

static void paint_draw_curve_cursor ( Brush brush,
ViewContext vc 
)
static

◆ paint_draw_legacy_3D_view_brush_cursor()

static void paint_draw_legacy_3D_view_brush_cursor ( PaintCursorContext pcontext)
static

◆ paint_draw_tex_overlay()

static bool paint_draw_tex_overlay ( UnifiedPaintSettings ups,
Brush brush,
ViewContext vc,
int  x,
int  y,
float  zoom,
const ePaintMode  mode,
bool  col,
bool  primary 
)
static

Definition at line 528 of file paint_cursor.c.

References UnifiedPaintSettings::anchored_initial_mouse, UnifiedPaintSettings::anchored_size, BKE_brush_size_get(), BKE_brush_use_size_pressure(), BLI_rcti_size_x(), BLI_rcti_size_y(), MTex::brush_map_mode, BRUSH_OVERLAY_PRIMARY, BRUSH_OVERLAY_SECONDARY, UnifiedPaintSettings::brush_rotation, UnifiedPaintSettings::brush_rotation_sec, center, col, copy_v3_v3(), UnifiedPaintSettings::draw_anchored, ELEM, GPU_blend(), GPU_BLEND_ALPHA_PREMULT, GPU_color_mask(), GPU_COMP_F32, GPU_DEPTH_NONE, GPU_depth_test(), GPU_FETCH_FLOAT, GPU_matrix_pop(), GPU_matrix_push(), GPU_matrix_rotate_2d(), GPU_matrix_scale_2f(), GPU_matrix_translate_2f(), GPU_matrix_translate_2fv(), GPU_PRIM_TRI_FAN, GPU_SAMPLER_CLAMP_BORDER, GPU_SAMPLER_FILTER, GPU_SAMPLER_REPEAT, GPU_SHADER_2D_IMAGE_COLOR, GPU_texture_unbind(), GPU_vertformat_attr_add(), if(), Brush::imagepaint_tool, immAttr2f(), immBegin(), immBindBuiltinProgram(), immBindTextureSampler(), immEnd(), immUnbindProgram(), immUniformColor4fv(), immVertex2f(), immVertexFormat(), load_tex(), Brush::mask_mtex, Brush::mask_overlay_alpha, Brush::mask_stencil_dimension, Brush::mask_stencil_pos, Brush::mtex, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_VIEW, mul_v4_fl(), Brush::overlay_flags, TexSnapshot::overlay_texture, PAINT_MODE_TEXTURE_3D, PAINT_TOOL_DRAW, pos, primary_snap, quad, RAD2DEGF, ViewContext::region, MTex::rot, ViewContext::scene, secondary_snap, UnifiedPaintSettings::size_pressure_value, state, Brush::stencil_dimension, Brush::stencil_pos, UnifiedPaintSettings::stroke_active, MTex::tex, Brush::texture_overlay_alpha, ARegion::winrct, x, and y.

Referenced by paint_draw_alpha_overlay().

◆ paint_update_mouse_cursor()

static void paint_update_mouse_cursor ( PaintCursorContext pcontext)
static

Definition at line 1401 of file paint_cursor.c.

References PaintCursorContext::win, WM_CURSOR_PAINT, and WM_cursor_set().

Referenced by paint_draw_cursor().

◆ paint_use_2d_cursor()

static bool paint_use_2d_cursor ( ePaintMode  mode)
static

Definition at line 1187 of file paint_cursor.c.

References PAINT_MODE_TEXTURE_3D.

Referenced by paint_cursor_context_init().

◆ project_brush_radius()

static int project_brush_radius ( ViewContext vc,
float  radius,
const float  location[3] 
)
static

◆ same_tex_snap()

static int same_tex_snap ( TexSnapshot snap,
MTex mtex,
ViewContext vc,
bool  col,
float  zoom 
)
static

◆ sculpt_geometry_preview_lines_draw()

static void sculpt_geometry_preview_lines_draw ( const uint  gpuattr,
Brush brush,
const bool  is_multires,
SculptSession ss 
)
static

◆ SCULPT_layer_brush_height_preview_draw()

static void SCULPT_layer_brush_height_preview_draw ( const uint  gpuattr,
const Brush brush,
const float  rds,
const float  line_width,
const float  outline_col[3],
const float  alpha 
)
static

Variable Documentation

◆ cursor_snap

CursorSnapshot cursor_snap = {0}
static

◆ primary_snap

TexSnapshot primary_snap = {0}
static

Definition at line 84 of file paint_cursor.c.

Referenced by load_tex(), paint_cursor_delete_textures(), and paint_draw_tex_overlay().

◆ secondary_snap

TexSnapshot secondary_snap = {0}
static

Definition at line 85 of file paint_cursor.c.

Referenced by load_tex(), paint_cursor_delete_textures(), and paint_draw_tex_overlay().