66 std::optional<Library *> ,
72 const Brush *brush_src = (
const Brush *)id_src;
163 bool force_local, force_copy;
185 else if (force_copy) {
188 brush_new->
id.
us = 0;
393 Brush *brush =
reinterpret_cast<Brush *
>(asset_ptr);
397 constexpr std::array mode_map{
398 std::tuple{
"use_paint_sculpt",
OB_MODE_SCULPT,
"sculpt_brush_type"},
403 std::tuple{
"use_paint_uv_sculpt",
OB_MODE_EDIT,
"image_brush_type"},
414 for (
const auto &[prop_name, mode, tool_prop_name] : mode_map) {
416 if (!(brush->
ob_mode & mode)) {
490#define FROM_DEFAULT(member) \
491 memcpy((void *)&brush->member, (void *)&brush_def->member, sizeof(brush->member))
492#define FROM_DEFAULT_PTR(member) memcpy(brush->member, brush_def->member, sizeof(brush->member))
537#undef FROM_DEFAULT_PTR
551 else if (
ELEM(ob_mode,
566 brush->
gpencil_settings = MEM_cnew<BrushGpencilSettings>(
"BrushGpencilSettings");
631 if (brush->ob_mode & ob_mode) {
641 Brush def = blender::dna::shallow_zero_initialize();
644#define BR_TEST(field, t) \
645 if (br->field != def.field) { \
646 printf("br->" #field " = %" #t ";\n", br->field); \
650#define BR_TEST_FLAG(_f) \
651 if ((br->flag & _f) && !(def.flag & _f)) { \
652 printf("br->flag |= " #_f ";\n"); \
654 else if (!(br->flag & _f) && (def.flag & _f)) { \
655 printf("br->flag &= ~" #_f ";\n"); \
659#define BR_TEST_FLAG_OVERLAY(_f) \
660 if ((br->overlay_flags & _f) && !(def.overlay_flags & _f)) { \
661 printf("br->overlay_flags |= " #_f ";\n"); \
663 else if (!(br->overlay_flags & _f) && (def.overlay_flags & _f)) { \
664 printf("br->overlay_flags &= ~" #_f ";\n"); \
708 BR_TEST(smooth_stroke_radius, d);
709 BR_TEST(smooth_stroke_factor, f);
720 BR_TEST(topology_rake_factor, f);
722 BR_TEST(crease_pinch_factor, f);
726 BR_TEST(texture_sample_bias, f);
727 BR_TEST(texture_overlay_alpha, d);
781 const float point[3],
787 float intensity = 1.0;
790 if (mtex ==
nullptr || mtex->
tex ==
nullptr) {
799 float rotation = -mtex->
rot;
800 const float point_2d[2] = {
point[0],
point[1]};
807 if (rotation > 0.001f || rotation < -0.001f) {
829 float rotation = -mtex->
rot;
830 const float point_2d[2] = {
point[0],
point[1]};
831 float x = 0.0f,
y = 0.0f;
832 float invradius = 1.0f;
870 if (rotation > 0.001f || rotation < -0.001f) {
906 float rgba[4], intensity;
912 float rotation = -mtex->
rot;
913 const float point_2d[2] = {
point[0],
point[1]};
920 if (rotation > 0.001f || rotation < -0.001f) {
942 float rotation = -mtex->
rot;
943 const float point_2d[2] = {
point[0],
point[1]};
944 float x = 0.0f,
y = 0.0f;
945 float invradius = 1.0f;
983 if (rotation > 0.001f || rotation < -0.001f) {
998 CLAMP(intensity, 0.0f, 1.0f);
1148 brush->
alpha = alpha;
1204 float scale = new_brush_size;
1206 if (old_brush_size != 0) {
1207 scale /=
float(old_brush_size);
1209 (*unprojected_radius) *= scale;
1213 float new_unprojected_radius,
1214 float old_unprojected_radius)
1216 float scale = new_unprojected_radius;
1218 if (old_unprojected_radius != 0) {
1219 scale /= new_unprojected_radius;
1221 (*r_brush_size) =
int(
float(*r_brush_size) * scale);
1247 jitterpos[0] =
pos[0] + 2 * rand_pos[0] * diameter * spread;
1248 jitterpos[1] =
pos[1] + 2 * rand_pos[1] * diameter * spread;
1268 const float brush_radius,
1277 const float distance = distances[i];
1288 const float distance = distances[i];
1293 const float factor = 1.0f -
distance * radius_rcp;
1294 factors[i] *= factor * factor;
1300 const float distance = distances[i];
1305 const float factor = 1.0f -
distance * radius_rcp;
1306 factors[i] *= 3.0f * factor * factor - 2.0f * factor * factor * factor;
1312 const float distance = distances[i];
1317 const float factor = 1.0f -
distance * radius_rcp;
1318 factors[i] *=
pow3f(factor) * (factor * (factor * 6.0f - 15.0f) + 10.0f);
1324 const float distance = distances[i];
1329 const float factor = 1.0f -
distance * radius_rcp;
1330 factors[i] *=
sqrtf(factor);
1336 const float distance = distances[i];
1341 const float factor = 1.0f -
distance * radius_rcp;
1342 factors[i] *= factor;
1351 const float distance = distances[i];
1356 const float factor = 1.0f -
distance * radius_rcp;
1357 factors[i] *=
sqrtf(2 * factor - factor * factor);
1363 const float distance = distances[i];
1368 const float factor = 1.0f -
distance * radius_rcp;
1369 factors[i] *= factor * factor * factor * factor;
1375 const float distance = distances[i];
1380 const float factor = 1.0f -
distance * radius_rcp;
1381 factors[i] *= factor * (2.0f - factor);
1391 const float brush_radius)
1394 float strength = 1.0f;
1396 if (p >= brush_radius) {
1400 p = p / brush_radius;
1411 strength = 3.0f * p * p - 2.0f * p * p * p;
1414 strength =
pow3f(p) * (p * (p * 6.0f - 15.0f) + 10.0f);
1417 strength =
sqrtf(p);
1426 strength =
sqrtf(2 * p - p * p);
1429 strength = p * p * p * p;
1432 strength = p * (2.0f - p);
1448 CLAMP(strength, 0.0f, 1.0f);
1456 const bool use_secondary,
1460 if (mtex->
tex ==
nullptr) {
1464 const float step = 2.0 / side;
1469 for (
y = -1.0, iy = 0; iy < side; iy++,
y += step) {
1470 for (
x = -1.0, ix = 0; ix < side; ix++,
x += step) {
1471 const float co[3] = {
x,
y, 0.0f};
1474 float rgba_dummy[4];
1477 rect[iy * side + ix] = intensity;
1486 ImBuf *im = MEM_cnew<ImBuf>(
"radial control texture");
1488 int half = side / 2;
1492 float *rect_float = (
float *)
MEM_callocN(
sizeof(
float) * side * side,
"radial control rect");
1495 im->
x = im->
y = side;
1499 if (display_gradient || have_texture) {
1500 for (
int i = 0; i < side; i++) {
1501 for (
int j = 0; j < side; j++) {
1516 switch (paint_mode) {
void BKE_asset_metadata_idprop_ensure(AssetMetaData *asset_data, IDProperty *prop)
bool BKE_bpath_foreach_path_fixed_process(BPathForeachPathData *bpath_data, char *path, size_t path_maxncpy)
Low-level operations for grease pencil.
@ IDTYPE_FLAGS_NO_ANIMDATA
@ IDTYPE_FLAGS_NO_MEMFILE_UNDO
void BKE_id_delete(Main *bmain, void *idv) ATTR_NONNULL()
void BKE_lib_id_expand_local(Main *bmain, ID *id, int flags)
void id_fake_user_set(ID *id)
bool BKE_lib_id_make_local(Main *bmain, ID *id, int flags)
void BKE_lib_id_make_local_generic_action_define(Main *bmain, ID *id, int flags, bool *r_force_local, bool *r_force_copy)
ID * BKE_id_copy(Main *bmain, const ID *id)
void * BKE_id_new(Main *bmain, short type, const char *name)
void BKE_lib_id_clear_library_data(Main *bmain, ID *id, int flags)
@ LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR
@ LIB_ID_MAKELOCAL_FULL_LIBRARY
void BKE_id_blend_write(BlendWriter *writer, ID *id)
#define BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data_, func_call_)
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
bool BKE_library_ID_is_indirectly_used(Main *bmain, void *idv)
@ ID_REMAP_SKIP_INDIRECT_USAGE
void void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, int remap_flags) ATTR_NONNULL(1
General operations, lookup, etc. for materials.
std::optional< int > BKE_paint_get_brush_type_from_obmode(const Brush *brush, const eObjectMode ob_mode)
bool BKE_paint_use_unified_color(const ToolSettings *tool_settings, const Paint *paint)
CurveMapping * BKE_sculpt_default_cavity_curve()
void BKE_previewimg_blend_write(BlendWriter *writer, const PreviewImage *prv)
void BKE_previewimg_free(PreviewImage **prv)
void BKE_previewimg_blend_read(BlendDataReader *reader, PreviewImage *prv)
void BKE_previewimg_id_copy(ID *new_id, const ID *old_id)
void BKE_texture_mtex_foreach_id(struct LibraryForeachIDData *data, struct MTex *mtex)
#define BLI_assert_unreachable()
#define LISTBASE_FOREACH(type, var, list)
MINLINE float pow2f(float x)
MINLINE float square_f(float a)
MINLINE float pow3f(float x)
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v4(float r[4])
struct RNG * BLI_rng_new(unsigned int seed)
void BLI_rng_srandom(struct RNG *rng, unsigned int seed) ATTR_NONNULL(1)
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define BLO_write_id_struct(writer, struct_name, id_address, id)
#define BLO_write_struct(writer, struct_name, data_ptr)
#define BLO_read_struct(reader, struct_name, ptr_p)
#define BLT_I18NCONTEXT_ID_BRUSH
ID and Library types, which are fundamental for SDNA.
#define ID_EXTRA_USERS(id)
#define ID_IS_LINKED(_id)
#define ID_REAL_USERS(id)
#define ID_NEW_SET(_id, _idn)
@ SCULPT_BRUSH_TYPE_DRAW_SHARP
@ SCULPT_BRUSH_TYPE_PINCH
@ SCULPT_BRUSH_TYPE_CLAY_THUMB
@ SCULPT_BRUSH_TYPE_MULTIPLANE_SCRAPE
@ SCULPT_BRUSH_TYPE_CREASE
@ SCULPT_BRUSH_TYPE_LAYER
@ SCULPT_BRUSH_TYPE_FLATTEN
@ SCULPT_BRUSH_TYPE_PAINT
@ SCULPT_BRUSH_TYPE_SCRAPE
@ SCULPT_BRUSH_TYPE_INFLATE
@ SCULPT_BRUSH_TYPE_CLAY_STRIPS
@ GP_BRUSH_MATERIAL_PINNED
@ GP_BRUSH_USE_JITTER_PRESSURE
@ BRUSH_INVERSE_SMOOTH_PRESSURE
@ BRUSH_MASK_PRESSURE_RAMP
@ BRUSH_MASK_PRESSURE_CUTOFF
@ BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_RADIUS
@ BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE
@ BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE
@ BRUSH_OVERLAY_SECONDARY
@ BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE
#define MAX_BRUSH_PIXEL_RADIUS
@ CUMA_EXTEND_EXTRAPOLATE
#define DNA_struct_default_get(struct_name)
@ OB_MODE_VERTEX_GREASE_PENCIL
@ OB_MODE_PAINT_GREASE_PENCIL
@ OB_MODE_SCULPT_GREASE_PENCIL
@ OB_MODE_WEIGHT_GREASE_PENCIL
@ UNIFIED_PAINT_BRUSH_LOCK_SIZE
@ UNIFIED_PAINT_INPUT_SAMPLES
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], ColorSpace *colorspace)
ImBuf * IMB_dupImBuf(const ImBuf *ibuf1)
void IMB_assign_float_buffer(ImBuf *ibuf, float *buffer_data, ImBufOwnership ownership)
Contains defines and structs used throughout the imbuf module.
@ IB_DO_NOT_TAKE_OWNERSHIP
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
void BKE_brush_jitter_pos(const Scene &scene, const Brush &brush, const float pos[2], float jitterpos[2])
void BKE_brush_weight_set(const Scene *scene, Brush *brush, float value)
const MTex * BKE_brush_mask_texture_get(const Brush *brush, const eObjectMode object_mode)
float BKE_brush_curve_strength_clamped(const Brush *br, float p, const float len)
static void brush_defaults(Brush *brush)
bool BKE_brush_use_alpha_pressure(const Brush *brush)
void BKE_brush_randomize_texture_coords(UnifiedPaintSettings *ups, bool mask)
float BKE_brush_weight_get(const Scene *scene, const Brush *brush)
float BKE_brush_curve_strength(const eBrushCurvePreset preset, const CurveMapping *cumap, const float distance, const float brush_radius)
float BKE_brush_unprojected_radius_get(const Scene *scene, const Brush *brush)
static void brush_blend_write(BlendWriter *writer, ID *id, const void *id_address)
#define BR_TEST(field, t)
int BKE_brush_size_get(const Scene *scene, const Brush *brush)
static void brush_free_data(ID *id)
static AssetTypeInfo AssetType_BR
static void brush_blend_read_after_liblink(BlendLibReader *, ID *id)
const MTex * BKE_brush_color_texture_get(const Brush *brush, const eObjectMode object_mode)
void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojected_radius)
Brush * BKE_brush_first_search(Main *bmain, const eObjectMode ob_mode)
void BKE_brush_size_set(Scene *scene, Brush *brush, int size)
static void brush_foreach_id(ID *id, LibraryForeachIDData *data)
#define FROM_DEFAULT(member)
#define BR_TEST_FLAG_OVERLAY(_f)
const float * BKE_brush_secondary_color_get(const Scene *scene, const Paint *paint, const Brush *brush)
void BKE_brush_alpha_set(Scene *scene, Brush *brush, float alpha)
bool BKE_brush_use_size_pressure(const Brush *brush)
void BKE_brush_input_samples_set(const Scene *scene, Brush *brush, int value)
static void brush_init_data(ID *id)
bool BKE_brush_has_cube_tip(const Brush *brush, PaintMode paint_mode)
static void brush_make_local(Main *bmain, ID *id, const int flags)
static void brush_copy_data(Main *, std::optional< Library * >, ID *id_dst, const ID *id_src, const int flag)
void BKE_brush_init_curves_sculpt_settings(Brush *brush)
Brush * BKE_brush_add(Main *bmain, const char *name, const eObjectMode ob_mode)
void BKE_brush_system_init()
#define FROM_DEFAULT_PTR(member)
ImBuf * BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary, bool display_gradient)
static bool brush_gen_texture(const Brush *br, const int side, const bool use_secondary, float *rect)
void BKE_brush_color_set(Scene *scene, const Paint *paint, Brush *brush, const float color[3])
void BKE_brush_curve_preset(Brush *b, eCurveMappingPreset preset)
static void brush_blend_read_data(BlendDataReader *reader, ID *id)
void BKE_brush_calc_curve_factors(const eBrushCurvePreset preset, const CurveMapping *cumap, const blender::Span< float > distances, const float brush_radius, const blender::MutableSpan< float > factors)
bool BKE_brush_sculpt_has_secondary_color(const Brush *brush)
void BKE_brush_init_gpencil_settings(Brush *brush)
float BKE_brush_sample_masktex(const Scene *scene, Brush *br, const float point[2], const int thread, ImagePool *pool)
static void brush_foreach_path(ID *id, BPathForeachPathData *bpath_data)
void BKE_brush_scale_size(int *r_brush_size, float new_unprojected_radius, float old_unprojected_radius)
float BKE_brush_alpha_get(const Scene *scene, const Brush *brush)
const float * BKE_brush_color_get(const Scene *scene, const Paint *paint, const Brush *brush)
void BKE_brush_debug_print_state(Brush *br)
bool BKE_brush_delete(Main *bmain, Brush *brush)
bool BKE_brush_use_locked_size(const Scene *scene, const Brush *brush)
void BKE_brush_scale_unprojected_radius(float *unprojected_radius, int new_brush_size, int old_brush_size)
static void brush_asset_metadata_ensure(void *asset_ptr, AssetMetaData *asset_data)
void BKE_brush_tag_unsaved_changes(Brush *brush)
void BKE_brush_system_exit()
int BKE_brush_input_samples_get(const Scene *scene, const Brush *brush)
float BKE_brush_sample_tex_3d(const Scene *scene, const Brush *br, const MTex *mtex, const float point[3], float rgba[4], const int thread, ImagePool *pool)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
constexpr int64_t size() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void IMB_freeImBuf(ImBuf *)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline float4 mask(const int4 mask, const float4 a)
std::unique_ptr< IDProperty, IDPropertyDeleter > create_bool(StringRefNull prop_name, bool value, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_BOOLEAN, set its name and value.
std::unique_ptr< IDProperty, IDPropertyDeleter > create(StringRefNull prop_name, int32_t value, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_INT, set its name and value.
float distance(float a, float b)
static ePaintOverlayControlFlags overlay_flags
struct CurveMapping * curve_parameter_falloff
struct CurveMapping * curve_sensitivity
struct CurveMapping * curve_strength
struct CurveMapping * curve_jitter
struct CurveMapping * curve_rand_pressure
struct CurveMapping * curve_rand_strength
struct CurveMapping * curve_rand_saturation
struct CurveMapping * curve_rand_hue
struct CurveMapping * curve_rand_uv
struct Material * material
struct Material * material_alt
struct CurveMapping * curve_rand_value
struct ImBuf * icon_imbuf
struct ColorBand * gradient
float stencil_dimension[2]
struct CurveMapping * curve
float texture_sample_bias
float mask_stencil_pos[2]
struct BrushGpencilSettings * gpencil_settings
struct Brush * toggle_brush
struct CurveMapping * automasking_cavity_curve
struct BrushCurvesSculptSettings * curves_sculpt_settings
float mask_stencil_dimension[2]
struct PaintCurve * paint_curve
ImBufFloatBuffer float_buffer
struct ToolSettings * toolsettings
char do_linear_conversion
float size_pressure_value
struct ColorSpace * colorspace
bool RE_texture_evaluate(const MTex *mtex, const float vec[3], const int thread, ImagePool *pool, const bool skip_load_image, const bool texnode_preview, float *r_intensity, float r_rgba[4])