Sculpt: more brush engine stuff
* Setting sculpt paint color from the palette works again. * Fixed various defaults.
This commit is contained in:
parent
fa8195ba55
commit
45f45d9e07
|
@ -109,7 +109,10 @@ struct ImBuf *BKE_brush_gen_radial_control_imbuf(struct Brush *br,
|
|||
|
||||
const float *BKE_brush_color_get(const struct Scene *scene, const struct Brush *brush);
|
||||
const float *BKE_brush_secondary_color_get(const struct Scene *scene, const struct Brush *brush);
|
||||
void BKE_brush_color_set(struct Scene *scene, struct Brush *brush, const float color[3]);
|
||||
void BKE_brush_color_set(struct Scene *scene,
|
||||
struct Brush *brush,
|
||||
const float color[3],
|
||||
const bool use_brush_channels);
|
||||
|
||||
int BKE_brush_size_get(const struct Scene *scene,
|
||||
const struct Brush *brush,
|
||||
|
|
|
@ -79,6 +79,13 @@ struct Sculpt;
|
|||
BKE_brush_channelset_set_int(chset, MAKE_BUILTIN_CH_NAME(channel), val)
|
||||
#define BRUSHSET_SET_BOOL(chset, channel, val) BRUSHSET_SET_INT(chset, channel, (val) ? 1 : 0)
|
||||
|
||||
#define BRUSHSET_GET_VECTOR(chset, channel, out, mapdata) \
|
||||
BKE_brush_channelset_get_vector(chset, MAKE_BUILTIN_CH_NAME(channel), out, mapdata)
|
||||
#define BRUSHSET_SET_VECTOR(chset, channel, out, mapdata) \
|
||||
BKE_brush_channelset_set_vector(chset, MAKE_BUILTIN_CH_NAME(channel), out)
|
||||
#define BRUSHSET_GET_FINAL_VECTOR(child, parent, channel, out, mapdata) \
|
||||
BKE_brush_channelset_get_final_vector(child, parent, MAKE_BUILTIN_CH_NAME(channel), out, mapdata)
|
||||
|
||||
//#define DEBUG_CURVE_MAPPING_ALLOC
|
||||
#ifdef DEBUG_CURVE_MAPPING_ALLOC
|
||||
void namestack_push(const char *name);
|
||||
|
|
|
@ -2473,10 +2473,32 @@ const float *BKE_brush_secondary_color_get(const struct Scene *scene, const stru
|
|||
return (ups->flag & UNIFIED_PAINT_COLOR) ? ups->secondary_rgb : brush->secondary_rgb;
|
||||
}
|
||||
|
||||
void BKE_brush_color_set(struct Scene *scene, struct Brush *brush, const float color[3])
|
||||
void BKE_brush_color_set(struct Scene *scene,
|
||||
struct Brush *brush,
|
||||
const float color[3],
|
||||
const bool use_brush_channels)
|
||||
{
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
|
||||
if (use_brush_channels) {
|
||||
BrushChannel *ch;
|
||||
|
||||
ch = BRUSHSET_LOOKUP(brush->channels, color);
|
||||
|
||||
if ((ch->flag & BRUSH_CHANNEL_INHERIT) && scene->toolsettings->sculpt &&
|
||||
scene->toolsettings->sculpt->channels) {
|
||||
BrushChannel *pch = BRUSHSET_LOOKUP(scene->toolsettings->sculpt->channels, color);
|
||||
|
||||
if (pch) {
|
||||
ch = pch;
|
||||
}
|
||||
}
|
||||
|
||||
if (ch) {
|
||||
copy_v3_v3(ch->vector, color);
|
||||
}
|
||||
}
|
||||
|
||||
if (ups->flag & UNIFIED_PAINT_COLOR) {
|
||||
copy_v3_v3(ups->rgb, color);
|
||||
}
|
||||
|
|
|
@ -291,7 +291,7 @@ MAKE_BOOL(cloth_pin_simulation_boundary, "Pin Simulation Boundary",
|
|||
"create a softer transition with unaffected areas", false)
|
||||
|
||||
MAKE_FLOAT(boundary_offset, "Boundary Origin Offset",
|
||||
"Offset of the boundary origin in relation to the brush radius", 0.05f, 0.0f, 1.0f)
|
||||
"Offset of the boundary origin in relation to the brush radius", 0.05f, 0.0f, 10.0f)
|
||||
MAKE_ENUM(boundary_deform_type, "Deformation", "Deformation type that is used in the brush", BRUSH_BOUNDARY_DEFORM_BEND, _({
|
||||
{BRUSH_BOUNDARY_DEFORM_BEND, "BEND", "NONE", "Bend", ""},
|
||||
{BRUSH_BOUNDARY_DEFORM_EXPAND, "EXPAND", "NONE", "Expand", ""},
|
||||
|
@ -431,6 +431,17 @@ MAKE_BOOL(mtex_use_rake, "Rake", "", false)
|
|||
MAKE_BOOL(mtex_use_random, "Random", "", false)
|
||||
MAKE_FLOAT(mtex_random_angle, "Random Angle", "Brush texture random angle", 0.0f, 0.0f, M_PI*2.0f)
|
||||
MAKE_FLOAT(mtex_angle, "Angle", "", 0.0f, 0.0f, M_PI*2.0f)
|
||||
MAKE_FLOAT_EX(height, "Brush Height", "Affectable height of brush (layer height for layer tool, i.e.)", 0.05f, 0.0f, 1.0f, 0.0f, 0.2f, false)
|
||||
MAKE_BOOL(use_space_attenuation, "Adjust Strength for Spacing",
|
||||
"Automatically adjust strength to give consistent results for different spacings", true)
|
||||
MAKE_ENUM(elastic_deform_type, "Deformation", "Deformation type that is used in the brush", BRUSH_ELASTIC_DEFORM_GRAB_TRISCALE, _({
|
||||
{BRUSH_ELASTIC_DEFORM_GRAB, "GRAB", "NONE", "Grab", ""},
|
||||
{BRUSH_ELASTIC_DEFORM_GRAB_BISCALE, "GRAB_BISCALE", "NONE", "Bi-Scale Grab", ""},
|
||||
{BRUSH_ELASTIC_DEFORM_GRAB_TRISCALE, "GRAB_TRISCALE", "NONE", "Tri-Scale Grab", ""},
|
||||
{BRUSH_ELASTIC_DEFORM_SCALE, "SCALE", "NONE", "Scale", ""},
|
||||
{BRUSH_ELASTIC_DEFORM_TWIST, "TWIST", "NONE", "Twist", ""},
|
||||
{-1}
|
||||
}))
|
||||
|
||||
//MAKE_FLOAT3_EX
|
||||
/* clang-format on */
|
||||
|
|
|
@ -1135,6 +1135,9 @@ int BKE_brush_channel_get_vector(BrushChannel *ch, float out[4], BrushMappingDat
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
copy_v4_v4(out, ch->vector);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
|
|
@ -319,6 +319,8 @@ static BrushSettingsMap brush_settings_map[] = {
|
|||
DEF(snake_hook_deform_type, snake_hook_deform_type, INT, INT)
|
||||
DEF(tip_roundness, tip_roundness, FLOAT, FLOAT)
|
||||
DEF(tip_scale_x, tip_scale_x, FLOAT, FLOAT)
|
||||
DEF(height, height, FLOAT, FLOAT)
|
||||
DEF(elastic_deform_type, elastic_deform_type, INT, INT)
|
||||
};
|
||||
|
||||
static const int brush_settings_map_len = ARRAY_SIZE(brush_settings_map);
|
||||
|
@ -382,6 +384,7 @@ BrushFlagMap brush_flags_map[] = {
|
|||
DEF(flag2, use_pose_ik_anchored, BRUSH_POSE_IK_ANCHORED)
|
||||
DEF(flag2, use_connected_only, BRUSH_USE_CONNECTED_ONLY)
|
||||
DEF(flag2, use_pose_lock_rotation, BRUSH_POSE_USE_LOCK_ROTATION)
|
||||
DEF(flag, use_space_attenuation, BRUSH_SPACE_ATTEN)
|
||||
};
|
||||
|
||||
int brush_flags_map_len = ARRAY_SIZE(brush_flags_map);
|
||||
|
@ -789,14 +792,15 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
|
|||
ADDCH(concave_mask_factor);
|
||||
|
||||
ADDCH(dyntopo_disabled);
|
||||
ADDCH(dyntopo_detail_mode)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
ADDCH(dyntopo_mode)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
ADDCH(dyntopo_detail_range)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
ADDCH(dyntopo_detail_percent)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
ADDCH(dyntopo_detail_size)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
ADDCH(dyntopo_constant_detail)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
ADDCH(dyntopo_spacing)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
ADDCH(dyntopo_radius_scale)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
|
||||
ADDCH(dyntopo_detail_mode);
|
||||
ADDCH(dyntopo_mode)->flag;
|
||||
ADDCH(dyntopo_detail_range);
|
||||
ADDCH(dyntopo_detail_percent);
|
||||
ADDCH(dyntopo_detail_size);
|
||||
ADDCH(dyntopo_constant_detail);
|
||||
ADDCH(dyntopo_spacing);
|
||||
ADDCH(dyntopo_radius_scale);
|
||||
|
||||
ADDCH(accumulate);
|
||||
ADDCH(original_normal);
|
||||
|
@ -807,6 +811,10 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
|
|||
ADDCH(preserve_faceset_boundary);
|
||||
ADDCH(hard_edge_mode);
|
||||
ADDCH(grab_silhouette);
|
||||
ADDCH(height);
|
||||
ADDCH(use_persistent);
|
||||
|
||||
ADDCH(use_space_attenuation);
|
||||
|
||||
ADDCH(projection);
|
||||
ADDCH(boundary_smooth);
|
||||
|
@ -972,6 +980,7 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
|
|||
SHOWWRK(surface_smooth_shape_preservation);
|
||||
SHOWWRK(surface_smooth_current_vertex);
|
||||
SHOWWRK(surface_smooth_iterations);
|
||||
SHOWWRK(projection);
|
||||
break;
|
||||
case SCULPT_TOOL_SCRAPE:
|
||||
case SCULPT_TOOL_FILL:
|
||||
|
@ -993,6 +1002,7 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
|
|||
break;
|
||||
case SCULPT_TOOL_LAYER:
|
||||
SHOWWRK(use_persistent);
|
||||
SHOWWRK(height);
|
||||
break;
|
||||
case SCULPT_TOOL_CLOTH:
|
||||
SHOWWRK(cloth_deform_type);
|
||||
|
@ -1006,13 +1016,14 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
|
|||
SHOWWRK(cloth_constraint_softbody_strength);
|
||||
SHOWWRK(cloth_use_collision);
|
||||
SHOWWRK(cloth_pin_simulation_boundary);
|
||||
SHOWWRK(elastic_deform_type);
|
||||
|
||||
break;
|
||||
case SCULPT_TOOL_BOUNDARY:
|
||||
SHOWWRK(boundary_offset);
|
||||
SHOWWRK(boundary_deform_type);
|
||||
SHOWWRK(boundary_falloff_type);
|
||||
|
||||
SHOWWRK(deform_target);
|
||||
break;
|
||||
case SCULPT_TOOL_CREASE:
|
||||
SHOWWRK(crease_pinch_factor);
|
||||
|
@ -1021,6 +1032,7 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
|
|||
SHOWWRK(crease_pinch_factor);
|
||||
SHOWWRK(rake_factor);
|
||||
SHOWWRK(snake_hook_deform_type);
|
||||
SHOWWRK(elastic_deform_type);
|
||||
break;
|
||||
case SCULPT_TOOL_PAINT:
|
||||
SHOWWRK(color);
|
||||
|
@ -1046,6 +1058,8 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
|
|||
SHOWWRK(use_pose_lock_rotation);
|
||||
SHOWWRK(pose_deform_type);
|
||||
SHOWWRK(pose_origin_type);
|
||||
SHOWWRK(deform_target);
|
||||
SHOWWRK(elastic_deform_type);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -1067,6 +1081,15 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
|
|||
|
||||
BKE_brush_builtin_patch(brush, tool);
|
||||
|
||||
GETCH(dyntopo_detail_mode)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
GETCH(dyntopo_mode)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
GETCH(dyntopo_detail_range)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
GETCH(dyntopo_detail_percent)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
GETCH(dyntopo_detail_size)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
GETCH(dyntopo_constant_detail)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
GETCH(dyntopo_spacing)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
GETCH(dyntopo_radius_scale)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
|
||||
GETCH(strength)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
GETCH(radius)->flag |= BRUSH_CHANNEL_INHERIT;
|
||||
|
||||
|
@ -1106,6 +1129,7 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
|
|||
GETCH(spacing)->fvalue = 10;
|
||||
GETCH(strength)->fvalue = 1.0f;
|
||||
GETCH(dyntopo_disabled)->ivalue = 1;
|
||||
BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
|
||||
break;
|
||||
case SCULPT_TOOL_SMEAR:
|
||||
BRUSHSET_SET_FLOAT(chset, spacing, 5.0f);
|
||||
|
@ -1115,6 +1139,12 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
|
|||
BRUSHSET_SET_BOOL(chset, dyntopo_disabled, true);
|
||||
break;
|
||||
|
||||
case SCULPT_TOOL_LAYER:
|
||||
BRUSHSET_SET_FLOAT(chset, height, 0.05f);
|
||||
BRUSHSET_SET_FLOAT(chset, hardness, 0.35f);
|
||||
BRUSHSET_SET_FLOAT(chset, strength, 1.0f);
|
||||
BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
|
||||
break;
|
||||
case SCULPT_TOOL_SLIDE_RELAX:
|
||||
GETCH(spacing)->fvalue = 10;
|
||||
GETCH(strength)->fvalue = 1.0f;
|
||||
|
@ -1139,11 +1169,22 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
|
|||
GETCH(normal_radius_factor)->fvalue = 1.0f;
|
||||
GETCH(spacing)->fvalue = 6;
|
||||
GETCH(hardness)->fvalue = 0.5;
|
||||
BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
|
||||
break;
|
||||
case SCULPT_TOOL_CLAY_THUMB:
|
||||
BRUSHSET_SET_FLOAT(chset, strength, 1.0f);
|
||||
BRUSHSET_SET_FLOAT(chset, spacing, 6.0f);
|
||||
BRUSHSET_SET_FLOAT(chset, normal_radius_factor, 1.0f);
|
||||
BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
|
||||
BRUSHSET_LOOKUP(chset, radius)->mappings[BRUSH_MAPPING_PRESSURE].flag |=
|
||||
BRUSH_MAPPING_ENABLED;
|
||||
break;
|
||||
case SCULPT_TOOL_CLAY_STRIPS: {
|
||||
GETCH(radius)->mappings[BRUSH_MAPPING_PRESSURE].flag |= BRUSH_MAPPING_ENABLED;
|
||||
GETCH(strength)->mappings[BRUSH_MAPPING_PRESSURE].flag |= BRUSH_MAPPING_ENABLED;
|
||||
|
||||
BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
|
||||
|
||||
GETCH(tip_roundness)->fvalue = 0.18f;
|
||||
GETCH(normal_radius_factor)->fvalue = 1.35f;
|
||||
GETCH(strength)->fvalue = 0.8f;
|
||||
|
@ -1168,11 +1209,28 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
|
|||
|
||||
break;
|
||||
}
|
||||
case SCULPT_TOOL_SMOOTH:
|
||||
BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
|
||||
BRUSHSET_SET_FLOAT(chset, spacing, 5.0f);
|
||||
BRUSHSET_SET_FLOAT(chset, strength, 0.3f);
|
||||
|
||||
ADDCH(surface_smooth_shape_preservation);
|
||||
ADDCH(surface_smooth_current_vertex);
|
||||
ADDCH(surface_smooth_iterations);
|
||||
break;
|
||||
case SCULPT_TOOL_THUMB:
|
||||
ADDCH(elastic_deform_type);
|
||||
BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
|
||||
BRUSHSET_LOOKUP(chset, strength)->mappings[BRUSH_MAPPING_PRESSURE].flag &=
|
||||
~BRUSH_MAPPING_ENABLED;
|
||||
break;
|
||||
case SCULPT_TOOL_MULTIPLANE_SCRAPE:
|
||||
ADDCH(use_multiplane_scrape_dynamic);
|
||||
ADDCH(show_multiplane_scrape_planes_preview);
|
||||
|
||||
GETCH(strength)->fvalue = 0.7f;
|
||||
GETCH(normal_radius_factor)->fvalue = 0.7f;
|
||||
|
||||
ADDCH(multiplane_scrape_angle);
|
||||
GETCH(spacing)->fvalue = 5.0f;
|
||||
break;
|
||||
|
@ -1190,18 +1248,39 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
|
|||
GETCH(accumulate)->ivalue = true;
|
||||
break;
|
||||
case SCULPT_TOOL_ROTATE:
|
||||
BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
|
||||
GETCH(strength)->fvalue = 1.0;
|
||||
GETCH(dyntopo_disabled)->ivalue = true;
|
||||
break;
|
||||
case SCULPT_TOOL_CLOTH:
|
||||
BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
|
||||
GETCH(radius)->mappings[BRUSH_MAPPING_PRESSURE].flag &= ~BRUSH_MAPPING_ENABLED;
|
||||
GETCH(strength)->mappings[BRUSH_MAPPING_PRESSURE].flag &= ~BRUSH_MAPPING_ENABLED;
|
||||
ADDCH(elastic_deform_type);
|
||||
break;
|
||||
case SCULPT_TOOL_ELASTIC_DEFORM:
|
||||
ADDCH(elastic_deform_type);
|
||||
break;
|
||||
case SCULPT_TOOL_SNAKE_HOOK:
|
||||
GETCH(dyntopo_mode)->ivalue = DYNTOPO_LOCAL_COLLAPSE | DYNTOPO_SUBDIVIDE;
|
||||
GETCH(dyntopo_mode)->flag = BRUSH_CHANNEL_INHERIT_IF_UNSET;
|
||||
GETCH(strength)->fvalue = 1.0f;
|
||||
ADDCH(elastic_deform_type);
|
||||
|
||||
break;
|
||||
case SCULPT_TOOL_DRAW_FACE_SETS:
|
||||
BRUSHSET_SET_FLOAT(chset, strength, 0.5f);
|
||||
BRUSHSET_LOOKUP(chset, strength)->mappings[BRUSH_MAPPING_PRESSURE].flag &=
|
||||
~BRUSH_MAPPING_ENABLED;
|
||||
BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
|
||||
break;
|
||||
case SCULPT_TOOL_BOUNDARY:
|
||||
BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
|
||||
ADDCH(elastic_deform_type);
|
||||
break;
|
||||
case SCULPT_TOOL_POSE:
|
||||
BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
|
||||
ADDCH(elastic_deform_type);
|
||||
break;
|
||||
default: {
|
||||
// implement me!
|
||||
|
|
|
@ -2312,6 +2312,7 @@ static bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root)
|
|||
BMLoop *l = e_root->l;
|
||||
BMLoop **ls = NULL;
|
||||
BMFace **fs = NULL;
|
||||
BLI_array_staticdeclare(fs, 32);
|
||||
BLI_array_staticdeclare(ls, 5);
|
||||
int minfs = INT_MAX;
|
||||
|
||||
|
@ -2370,9 +2371,14 @@ static bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root)
|
|||
}
|
||||
|
||||
if (!bad && BLI_array_len(fs2) < minfs) {
|
||||
BLI_array_clear(fs);
|
||||
BLI_array_reserve(fs, BLI_array_len(fs2));
|
||||
|
||||
if (BLI_array_len(fs2) > 0) {
|
||||
memcpy(fs, fs2, sizeof(*fs) * BLI_array_len(fs2));
|
||||
}
|
||||
|
||||
minfs = BLI_array_len(fs2);
|
||||
fs = BLI_array_alloca(fs, BLI_array_len(fs2));
|
||||
memcpy(fs, fs2, sizeof(*fs) * BLI_array_len(fs2));
|
||||
}
|
||||
|
||||
BLI_array_free(fs2);
|
||||
|
@ -2384,6 +2390,7 @@ static bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root)
|
|||
nupdateflag = nupdateflag | PBVH_UpdateNormals | PBVH_UpdateTris | PBVH_RebuildDrawBuffers;
|
||||
|
||||
if (!fs) {
|
||||
BLI_array_free(stack);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2466,6 +2473,9 @@ static bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root)
|
|||
BLI_array_free(es);
|
||||
}
|
||||
|
||||
BLI_array_free(fs);
|
||||
BLI_array_free(stack);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1371,29 +1371,6 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
|
||||
BKE_brush_builtin_create(brush, brush->sculpt_tool);
|
||||
BKE_brush_channelset_compat_load(brush->channels, brush, true);
|
||||
|
||||
// check that dyntopo settings are ok
|
||||
// some helper macros. . .
|
||||
|
||||
#ifdef GETCH
|
||||
# undef GETCH
|
||||
#endif
|
||||
|
||||
#define GETCH(n) BKE_brush_channelset_lookup(brush->channels, #n)
|
||||
|
||||
/*
|
||||
float detail_range;
|
||||
float detail_percent;
|
||||
float detail_size;
|
||||
float constant_detail;
|
||||
short flag, mode;
|
||||
int inherit;
|
||||
int spacing;
|
||||
float radius_scale;
|
||||
|
||||
*/
|
||||
|
||||
#undef GETCH
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -6262,17 +6262,20 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
|
|||
}
|
||||
else {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
bool use_channels = mode == PAINT_MODE_SCULPT;
|
||||
|
||||
bool updated = false;
|
||||
|
||||
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
|
||||
RNA_property_float_get_array(&but->rnapoin, but->rnaprop, color);
|
||||
BKE_brush_color_set(scene, brush, color);
|
||||
BKE_brush_color_set(scene, brush, color, use_channels);
|
||||
updated = true;
|
||||
}
|
||||
else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) {
|
||||
RNA_property_float_get_array(&but->rnapoin, but->rnaprop, color);
|
||||
IMB_colormanagement_scene_linear_to_srgb_v3(color);
|
||||
BKE_brush_color_set(scene, brush, color);
|
||||
BKE_brush_color_set(scene, brush, color, use_channels);
|
||||
updated = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1043,13 +1043,16 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
bool use_channels = mode == PAINT_MODE_SCULPT;
|
||||
|
||||
if ((event->type == data->launch_event) && (event->val == KM_RELEASE)) {
|
||||
if (data->show_cursor) {
|
||||
paint->flags |= PAINT_SHOW_BRUSH;
|
||||
}
|
||||
|
||||
if (data->sample_palette) {
|
||||
BKE_brush_color_set(scene, brush, data->initcolor);
|
||||
BKE_brush_color_set(scene, brush, data->initcolor, use_channels);
|
||||
RNA_boolean_set(op->ptr, "palette", true);
|
||||
}
|
||||
WM_cursor_modal_restore(CTX_wm_window(C));
|
||||
|
@ -1059,7 +1062,6 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
const bool use_sample_texture = (mode == PAINT_MODE_TEXTURE_3D) &&
|
||||
!RNA_boolean_get(op->ptr, "merged");
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BKE_brush.h"
|
||||
#include "BKE_brush_engine.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_lib_id.h"
|
||||
|
@ -257,14 +258,24 @@ static int palette_color_add_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
color = BKE_palette_color_add(palette);
|
||||
palette->active_color = BLI_listbase_count(&palette->colors) - 1;
|
||||
|
||||
if (ELEM(mode,
|
||||
PAINT_MODE_TEXTURE_3D,
|
||||
PAINT_MODE_TEXTURE_2D,
|
||||
PAINT_MODE_VERTEX,
|
||||
PAINT_MODE_SCULPT)) {
|
||||
if (ELEM(mode, PAINT_MODE_TEXTURE_3D, PAINT_MODE_TEXTURE_2D, PAINT_MODE_VERTEX)) {
|
||||
copy_v3_v3(color->rgb, BKE_brush_color_get(scene, brush));
|
||||
color->value = 0.0;
|
||||
}
|
||||
else if (mode == PAINT_MODE_SCULPT) {
|
||||
Sculpt *sd = scene->toolsettings ? scene->toolsettings->sculpt : NULL;
|
||||
|
||||
float val[4];
|
||||
if (sd && sd->channels) {
|
||||
BRUSHSET_GET_FINAL_VECTOR(brush->channels, sd->channels, color, val, NULL);
|
||||
}
|
||||
else {
|
||||
BRUSHSET_GET_VECTOR(brush->channels, color, val, NULL);
|
||||
}
|
||||
|
||||
copy_v3_v3(color->rgb, val);
|
||||
color->value = 0.0;
|
||||
}
|
||||
else if (mode == PAINT_MODE_WEIGHT) {
|
||||
zero_v3(color->rgb);
|
||||
color->value = brush->weight;
|
||||
|
|
|
@ -479,6 +479,9 @@ void paint_sample_color(
|
|||
SpaceImage *sima = CTX_wm_space_image(C);
|
||||
const View3D *v3d = CTX_wm_view3d(C);
|
||||
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
bool use_channels = mode == PAINT_MODE_SCULPT;
|
||||
|
||||
if (v3d && texpaint_proj) {
|
||||
/* first try getting a color directly from the mesh faces if possible */
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
|
@ -555,7 +558,7 @@ void paint_sample_color(
|
|||
}
|
||||
else {
|
||||
linearrgb_to_srgb_v3_v3(rgba_f, rgba_f);
|
||||
BKE_brush_color_set(scene, br, rgba_f);
|
||||
BKE_brush_color_set(scene, br, rgba_f, use_channels);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -567,7 +570,7 @@ void paint_sample_color(
|
|||
else {
|
||||
float rgba_f[3];
|
||||
rgb_uchar_to_float(rgba_f, rgba);
|
||||
BKE_brush_color_set(scene, br, rgba_f);
|
||||
BKE_brush_color_set(scene, br, rgba_f, use_channels);
|
||||
}
|
||||
}
|
||||
BKE_image_release_ibuf(image, ibuf, NULL);
|
||||
|
@ -594,7 +597,7 @@ void paint_sample_color(
|
|||
copy_v3_v3(color->rgb, rgba_f);
|
||||
}
|
||||
else {
|
||||
BKE_brush_color_set(scene, br, rgba_f);
|
||||
BKE_brush_color_set(scene, br, rgba_f, use_channels);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -610,7 +613,7 @@ void paint_sample_color(
|
|||
copy_v3_v3(color->rgb, rgba_f);
|
||||
}
|
||||
else {
|
||||
BKE_brush_color_set(scene, br, rgba_f);
|
||||
BKE_brush_color_set(scene, br, rgba_f, use_channels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12612,11 +12612,14 @@ static int sculpt_sample_color_modal(bContext *C, wmOperator *op, const wmEvent
|
|||
|
||||
SampleColorCustomData *sccd = (SampleColorCustomData *)op->customdata;
|
||||
|
||||
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
|
||||
bool use_channels = mode == PAINT_MODE_SCULPT;
|
||||
|
||||
/* Finish operation on release. */
|
||||
if (event->val == KM_RELEASE) {
|
||||
float color_srgb[3];
|
||||
copy_v3_v3(color_srgb, sccd->sampled_color);
|
||||
BKE_brush_color_set(scene, brush, sccd->sampled_color);
|
||||
BKE_brush_color_set(scene, brush, sccd->sampled_color, use_channels);
|
||||
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
|
||||
ED_region_draw_cb_exit(region->type, sccd->draw_handle);
|
||||
ED_region_tag_redraw(region);
|
||||
|
|
|
@ -840,6 +840,8 @@ static void sculpt_boundary_falloff_factor_init(
|
|||
const int totvert = SCULPT_vertex_count_get(ss);
|
||||
BKE_curvemapping_init(brush->curve);
|
||||
|
||||
int boundary_type = SCULPT_get_int(ss, boundary_falloff_type, sd, brush);
|
||||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
if (boundary->edit_info[i].num_propagation_steps != -1) {
|
||||
boundary->edit_info[i].strength_factor = BKE_brush_curve_strength(
|
||||
|
@ -863,7 +865,7 @@ static void sculpt_boundary_falloff_factor_init(
|
|||
float falloff_distance = 0.0f;
|
||||
float direction = 1.0f;
|
||||
|
||||
switch (SCULPT_get_int(ss, boundary_falloff_type, sd, brush)) {
|
||||
switch (boundary_type) {
|
||||
case BRUSH_BOUNDARY_FALLOFF_RADIUS:
|
||||
falloff_distance = boundary_distance;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue