Blender V4.3
BKE_brush.hh File Reference
#include "BLI_span.hh"
#include "DNA_brush_enums.h"
#include "DNA_color_types.h"
#include "DNA_object_enums.h"

Go to the source code of this file.

Functions

void BKE_brush_system_init ()
 
void BKE_brush_system_exit ()
 
BrushBKE_brush_add (Main *bmain, const char *name, eObjectMode ob_mode)
 
bool BKE_brush_delete (Main *bmain, Brush *brush)
 
void BKE_brush_init_gpencil_settings (Brush *brush)
 
void BKE_brush_init_curves_sculpt_settings (Brush *brush)
 
void BKE_brush_tag_unsaved_changes (Brush *brush)
 
BrushBKE_brush_first_search (Main *bmain, eObjectMode ob_mode)
 
void BKE_brush_jitter_pos (const Scene &scene, const Brush &brush, const float pos[2], float jitterpos[2])
 
void BKE_brush_randomize_texture_coords (UnifiedPaintSettings *ups, bool mask)
 
void BKE_brush_curve_preset (Brush *b, enum eCurveMappingPreset preset)
 
void BKE_brush_calc_curve_factors (eBrushCurvePreset preset, const CurveMapping *cumap, blender::Span< float > distances, float brush_radius, blender::MutableSpan< float > factors)
 
float BKE_brush_curve_strength_clamped (const Brush *br, float p, float len)
 
float BKE_brush_curve_strength (eBrushCurvePreset preset, const CurveMapping *cumap, float distance, float brush_radius)
 
float BKE_brush_curve_strength (const Brush *br, float p, float len)
 
float BKE_brush_sample_tex_3d (const Scene *scene, const Brush *br, const MTex *mtex, const float point[3], float rgba[4], int thread, ImagePool *pool)
 
float BKE_brush_sample_masktex (const Scene *scene, Brush *br, const float point[2], int thread, ImagePool *pool)
 
const MTexBKE_brush_mask_texture_get (const Brush *brush, const eObjectMode object_mode)
 
const MTexBKE_brush_color_texture_get (const Brush *brush, const eObjectMode object_mode)
 
ImBufBKE_brush_gen_radial_control_imbuf (Brush *br, bool secondary, bool display_gradient)
 
const floatBKE_brush_color_get (const Scene *scene, const Paint *paint, const Brush *brush)
 
const floatBKE_brush_secondary_color_get (const Scene *scene, const Paint *paint, const Brush *brush)
 
void BKE_brush_color_set (Scene *scene, const Paint *paint, Brush *brush, const float color[3])
 
int BKE_brush_size_get (const Scene *scene, const Brush *brush)
 
void BKE_brush_size_set (Scene *scene, Brush *brush, int size)
 
float BKE_brush_unprojected_radius_get (const Scene *scene, const Brush *brush)
 
void BKE_brush_unprojected_radius_set (Scene *scene, Brush *brush, float unprojected_radius)
 
float BKE_brush_alpha_get (const Scene *scene, const Brush *brush)
 
void BKE_brush_alpha_set (Scene *scene, Brush *brush, float alpha)
 
float BKE_brush_weight_get (const Scene *scene, const Brush *brush)
 
void BKE_brush_weight_set (const Scene *scene, Brush *brush, float value)
 
int BKE_brush_input_samples_get (const Scene *scene, const Brush *brush)
 
void BKE_brush_input_samples_set (const Scene *scene, Brush *brush, int value)
 
bool BKE_brush_use_locked_size (const Scene *scene, const Brush *brush)
 
bool BKE_brush_use_alpha_pressure (const Brush *brush)
 
bool BKE_brush_use_size_pressure (const Brush *brush)
 
bool BKE_brush_sculpt_has_secondary_color (const Brush *brush)
 
void BKE_brush_scale_unprojected_radius (float *unprojected_radius, int new_brush_size, int old_brush_size)
 
void BKE_brush_scale_size (int *r_brush_size, float new_unprojected_radius, float old_unprojected_radius)
 
bool BKE_brush_has_cube_tip (const Brush *brush, PaintMode paint_mode)
 
void BKE_brush_debug_print_state (Brush *br)
 

Detailed Description

General operations for brushes.

Definition in file BKE_brush.hh.

Function Documentation

◆ BKE_brush_add()

Brush * BKE_brush_add ( Main * bmain,
const char * name,
eObjectMode ob_mode )
Note
Resulting brush will have two users: one as a fake user, another is assumed to be used by the caller.

Definition at line 542 of file brush.cc.

References BKE_brush_init_curves_sculpt_settings(), BKE_brush_init_gpencil_settings(), BKE_id_new(), ELEM, ID_BR, Brush::ob_mode, OB_MODE_PAINT_GREASE_PENCIL, OB_MODE_SCULPT_CURVES, OB_MODE_SCULPT_GREASE_PENCIL, OB_MODE_VERTEX_GREASE_PENCIL, and OB_MODE_WEIGHT_GREASE_PENCIL.

◆ BKE_brush_alpha_get()

◆ BKE_brush_alpha_set()

◆ BKE_brush_calc_curve_factors()

◆ BKE_brush_color_get()

◆ BKE_brush_color_set()

void BKE_brush_color_set ( Scene * scene,
const Paint * paint,
Brush * brush,
const float color[3] )

◆ BKE_brush_color_texture_get()

const MTex * BKE_brush_color_texture_get ( const Brush * brush,
const eObjectMode object_mode )

Get the color texture for this given object mode.

This is preferred above using mtex/mask_mtex attributes directly as due to legacy these attributes got switched in sculpt mode.

Definition at line 770 of file brush.cc.

References Brush::mask_mtex, Brush::mtex, and OB_MODE_SCULPT.

Referenced by do_projectpaint_thread().

◆ BKE_brush_curve_preset()

◆ BKE_brush_curve_strength() [1/2]

float BKE_brush_curve_strength ( const Brush * br,
float p,
float len )

Definition at line 1439 of file brush.cc.

References BKE_brush_curve_strength(), Brush::curve, Brush::curve_preset, and len.

◆ BKE_brush_curve_strength() [2/2]

float BKE_brush_curve_strength ( eBrushCurvePreset preset,
const CurveMapping * cumap,
float distance,
float brush_radius )

Uses the brush curve control to find a strength value.

Definition at line 1388 of file brush.cc.

References BKE_curvemapping_evaluateF(), BRUSH_CURVE_CONSTANT, BRUSH_CURVE_CUSTOM, BRUSH_CURVE_INVSQUARE, BRUSH_CURVE_LIN, BRUSH_CURVE_POW4, BRUSH_CURVE_ROOT, BRUSH_CURVE_SHARP, BRUSH_CURVE_SMOOTH, BRUSH_CURVE_SMOOTHER, BRUSH_CURVE_SPHERE, distance(), pow3f(), and sqrtf.

Referenced by blender::ed::sculpt_paint::cloth::add_constraints_for_verts(), blender::ed::sculpt_paint::greasepencil::WeightPaintOperation::add_point_under_brush_to_brush_buffer(), BKE_brush_curve_strength(), BKE_brush_curve_strength_clamped(), blender::ed::sculpt_paint::greasepencil::brush_fill_influence(), blender::ed::sculpt_paint::greasepencil::brush_point_influence(), blender::ed::sculpt_paint::greasepencil::brush_point_influence_mask(), calc_strength(), blender::ed::sculpt_paint::CombOperationExecutor::comb_projected(), blender::ed::sculpt_paint::CombOperationExecutor::comb_spherical(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::compute_piecewise_linear_falloff(), blender::ed::sculpt_paint::PuffOperationExecutor::find_curve_weights_projected(), blender::ed::sculpt_paint::SlideOperationExecutor::find_curves_to_slide(), blender::ed::sculpt_paint::PuffOperationExecutor::find_curves_weights_spherical(), blender::ed::sculpt_paint::SmoothOperationExecutor::find_projected_smooth_factors(), blender::ed::sculpt_paint::SmoothOperationExecutor::find_spherical_smooth_factors(), blender::ed::sculpt_paint::CurvesEffectOperationExecutor::gather_influences_projected(), blender::ed::sculpt_paint::CurvesEffectOperationExecutor::gather_influences_spherical(), blender::ed::sculpt_paint::expand::gradient_value_get(), blender::ed::sculpt_paint::boundary::init_falloff_bmesh(), blender::ed::sculpt_paint::boundary::init_falloff_grids(), blender::ed::sculpt_paint::boundary::init_falloff_mesh(), blender::ed::sculpt_paint::paint_stroke_overlapped_curve(), blender::ed::sculpt_paint::PinchOperationExecutor::pinch_projected(), blender::ed::sculpt_paint::PinchOperationExecutor::pinch_spherical(), blender::ed::sculpt_paint::SnakeHookOperatorExecutor::projected_snake_hook(), blender::ed::sculpt_paint::DensityAddOperationExecutor::sample_projected_with_symmetry(), blender::ed::sculpt_paint::DensityAddOperationExecutor::sample_spherical_with_symmetry(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::soft_eraser(), blender::ed::sculpt_paint::pose::solve_roll_chain(), and blender::ed::sculpt_paint::SnakeHookOperatorExecutor::spherical_snake_hook().

◆ BKE_brush_curve_strength_clamped()

float BKE_brush_curve_strength_clamped ( const Brush * br,
float p,
float len )

◆ BKE_brush_debug_print_state()

◆ BKE_brush_delete()

bool BKE_brush_delete ( Main * bmain,
Brush * brush )

◆ BKE_brush_first_search()

Brush * BKE_brush_first_search ( Main * bmain,
eObjectMode ob_mode )

Definition at line 628 of file brush.cc.

References Main::brushes, and LISTBASE_FOREACH.

◆ BKE_brush_gen_radial_control_imbuf()

ImBuf * BKE_brush_gen_radial_control_imbuf ( Brush * br,
bool secondary,
bool display_gradient )

◆ BKE_brush_has_cube_tip()

◆ BKE_brush_init_curves_sculpt_settings()

void BKE_brush_init_curves_sculpt_settings ( Brush * brush)

◆ BKE_brush_init_gpencil_settings()

◆ BKE_brush_input_samples_get()

int BKE_brush_input_samples_get ( const Scene * scene,
const Brush * brush )

◆ BKE_brush_input_samples_set()

void BKE_brush_input_samples_set ( const Scene * scene,
Brush * brush,
int value )

◆ BKE_brush_jitter_pos()

void BKE_brush_jitter_pos ( const Scene & scene,
const Brush & brush,
const float pos[2],
float jitterpos[2] )

◆ BKE_brush_mask_texture_get()

◆ BKE_brush_randomize_texture_coords()

◆ BKE_brush_sample_masktex()

◆ BKE_brush_sample_tex_3d()

◆ BKE_brush_scale_size()

void BKE_brush_scale_size ( int * r_brush_size,
float new_unprojected_radius,
float old_unprojected_radius )

Scale brush size to reflect a change in the brush's unprojected radius.

Definition at line 1212 of file brush.cc.

References int.

◆ BKE_brush_scale_unprojected_radius()

void BKE_brush_scale_unprojected_radius ( float * unprojected_radius,
int new_brush_size,
int old_brush_size )

Scale unprojected radius to reflect a change in the brush's 2D size.

Definition at line 1200 of file brush.cc.

References float.

◆ BKE_brush_sculpt_has_secondary_color()

◆ BKE_brush_secondary_color_get()

◆ BKE_brush_size_get()

int BKE_brush_size_get ( const Scene * scene,
const Brush * brush )

Definition at line 1075 of file brush.cc.

References UnifiedPaintSettings::flag, Brush::size, size(), UnifiedPaintSettings::size, and UNIFIED_PAINT_SIZE.

Referenced by BKE_brush_jitter_pos(), blender::ed::sculpt_paint::greasepencil::brush_radius(), blender::ed::sculpt_paint::brush_radius_get(), brush_scale_size_exec(), blender::ed::sculpt_paint::filter::cache_init(), blender::ed::sculpt_paint::trim::calculate_depth(), blender::ed::sculpt_paint::min_distance_edit::calculate_points_per_side(), blender::ed::sculpt_paint::dyntopo::dyntopo_detail_size_edit_invoke(), blender::ed::sculpt_paint::CombOperationExecutor::execute(), blender::ed::sculpt_paint::CurvesEffectOperationExecutor::execute(), blender::ed::sculpt_paint::DeleteOperationExecutor::execute(), blender::ed::sculpt_paint::DensitySubtractOperationExecutor::execute(), blender::ed::sculpt_paint::PinchOperationExecutor::execute(), blender::ed::sculpt_paint::PuffOperationExecutor::execute(), blender::ed::sculpt_paint::SelectionPaintOperationExecutor::execute(), blender::ed::sculpt_paint::SlideOperationExecutor::execute(), blender::ed::sculpt_paint::SmoothOperationExecutor::execute(), blender::ed::sculpt_paint::SnakeHookOperatorExecutor::execute(), blender::ed::sculpt_paint::vwpaint::get_brush_alpha_data(), blender::ed::sculpt_paint::greasepencil::WeightPaintOperation::get_brush_settings(), blender::ed::sculpt_paint::grease_pencil_brush_cursor_draw(), blender::ed::sculpt_paint::load_tex(), blender::ed::sculpt_paint::load_tex_cursor(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_draw(), blender::ed::sculpt_paint::paint_brush_update(), blender::ed::sculpt_paint::paint_cursor_context_init(), blender::ed::sculpt_paint::paint_cursor_update_object_space_radius(), blender::ed::sculpt_paint::paint_cursor_update_pixel_radius(), blender::ed::sculpt_paint::paint_cursor_update_unprojected_radius(), blender::ed::sculpt_paint::paint_draw_cursor_overlay(), blender::ed::sculpt_paint::paint_draw_tex_overlay(), paint_proj_new_stroke(), blender::ed::sculpt_paint::paint_space_stroke_spacing(), blender::ed::sculpt_paint::paint_stroke_new(), project_paint_begin(), blender::ed::sculpt_paint::sculpt_calc_radius(), SCULPT_cursor_geometry_info_update(), blender::ed::sculpt_paint::smooth_brush_toggle_on(), blender::ed::sculpt_paint::vwpaint::smooth_brush_toggle_on(), texture_paint_camera_project_exec(), blender::ed::sculpt_paint::vwpaint::update_cache_variants(), blender::ed::sculpt_paint::update_modal_transform(), and blender::ed::sculpt_paint::use_add_density_mode().

◆ BKE_brush_size_set()

◆ BKE_brush_system_exit()

void BKE_brush_system_exit ( )

Definition at line 476 of file brush.cc.

References BLI_rng_free(), and brush_rng.

Referenced by BKE_blender_free().

◆ BKE_brush_system_init()

void BKE_brush_system_init ( )

Definition at line 470 of file brush.cc.

References BLI_rng_new(), BLI_rng_srandom(), and brush_rng.

Referenced by main().

◆ BKE_brush_tag_unsaved_changes()

void BKE_brush_tag_unsaved_changes ( Brush * brush)

Tag a linked brush as having changed settings so an indicator can be displayed to the user, showing that the brush settings differ from the state of the imported brush asset. Call every time a user visible change to the brush is done.

Since this is meant to indicate brushes that are known to differ from the linked source file, tagging is only performed for linked brushes. File local brushes are normal data-blocks that get saved with the file, and don't need special attention by the user.

For convenience, null may be passed for brush.

Definition at line 621 of file brush.cc.

References Brush::has_unsaved_changes, and ID_IS_LINKED.

Referenced by BKE_brush_alpha_set(), BKE_brush_color_set(), BKE_brush_curve_preset(), BKE_brush_input_samples_set(), BKE_brush_size_set(), BKE_brush_unprojected_radius_set(), BKE_brush_weight_set(), BKE_gpencil_brush_material_set(), brush_colors_flip_exec(), brush_scale_size_exec(), brush_sculpt_curves_falloff_preset_exec(), calculateCenterActive(), ED_render_id_flush_update(), blender::ui::greasepencil::eyedropper_set_brush_color(), flushTransPaintCurve(), grab_clone_apply(), grab_clone_modal(), blender::ed::sculpt_paint::grease_pencil_apply_fill(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_modal(), paintcurve_delete_point_exec(), paintcurve_new_exec(), paintcurve_point_add(), paintcurve_slide_invoke(), set_current_brush_texture(), stencil_control_calculate(), stencil_fit_image_aspect_exec(), stencil_reset_transform_exec(), blender::ed::greasepencil::toggle_weight_tool_direction(), and ui_do_but_COLOR().

◆ BKE_brush_unprojected_radius_get()

◆ BKE_brush_unprojected_radius_set()

◆ BKE_brush_use_alpha_pressure()

◆ BKE_brush_use_locked_size()

◆ BKE_brush_use_size_pressure()

◆ BKE_brush_weight_get()

◆ BKE_brush_weight_set()