Merge branch 'blender-v3.2-release'
This commit is contained in:
commit
e07ac34b3f
|
@ -730,6 +730,21 @@ enum {
|
|||
SCULPT_MASK_LAYER_CALC_LOOP = (1 << 1),
|
||||
};
|
||||
|
||||
/* paint_vertex.cc */
|
||||
|
||||
/**
|
||||
* Fills the object's active color atribute layer with the fill color.
|
||||
*
|
||||
* \param[in] ob: The object.
|
||||
* \param[in] fill_color: The fill color.
|
||||
* \param[in] only_selected: Limit the fill to selected faces or vertices.
|
||||
*
|
||||
* \return #true if successful.
|
||||
*/
|
||||
bool BKE_object_attributes_active_color_fill(struct Object *ob,
|
||||
const float fill_color[4],
|
||||
bool only_selected);
|
||||
|
||||
/* paint_canvas.cc */
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "BKE_lib_id.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_object_deform.h"
|
||||
#include "BKE_paint.h"
|
||||
#include "BKE_report.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
@ -221,6 +222,9 @@ static int geometry_color_attribute_add_exec(bContext *C, wmOperator *op)
|
|||
AttributeDomain domain = (AttributeDomain)RNA_enum_get(op->ptr, "domain");
|
||||
CustomDataLayer *layer = BKE_id_attribute_new(id, name, type, domain, op->reports);
|
||||
|
||||
float color[4];
|
||||
RNA_float_get_array(op->ptr, "color", color);
|
||||
|
||||
if (layer == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
@ -231,6 +235,8 @@ static int geometry_color_attribute_add_exec(bContext *C, wmOperator *op)
|
|||
BKE_id_attributes_render_color_set(id, layer);
|
||||
}
|
||||
|
||||
BKE_object_attributes_active_color_fill(ob, color, false);
|
||||
|
||||
DEG_id_tag_update(id, ID_RECALC_GEOMETRY);
|
||||
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
|
||||
|
||||
|
@ -353,6 +359,7 @@ static void geometry_color_attribute_add_ui(bContext *UNUSED(C), wmOperator *op)
|
|||
uiItemR(layout, op->ptr, "name", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, op->ptr, "domain", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
|
||||
uiItemR(layout, op->ptr, "data_type", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
|
||||
uiItemR(layout, op->ptr, "color", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
void GEOMETRY_OT_color_attribute_add(wmOperatorType *ot)
|
||||
|
@ -399,6 +406,13 @@ void GEOMETRY_OT_color_attribute_add(wmOperatorType *ot)
|
|||
CD_PROP_COLOR,
|
||||
"Data Type",
|
||||
"Type of data stored in attribute");
|
||||
|
||||
static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
|
||||
prop = RNA_def_float_color(
|
||||
ot->srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
|
||||
RNA_def_property_subtype(prop, PROP_COLOR_GAMMA);
|
||||
RNA_def_property_float_array_default(prop, default_color);
|
||||
}
|
||||
|
||||
static int geometry_color_attribute_set_render_exec(bContext *C, wmOperator *op)
|
||||
|
|
|
@ -4144,43 +4144,77 @@ static bool vertex_color_set(Object *ob, ColorPaint4f paintcol_in, Color *color_
|
|||
return true;
|
||||
}
|
||||
|
||||
static int vertex_color_set_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
/**
|
||||
* Fills the object's active color atribute layer with the fill color.
|
||||
*
|
||||
* \param[in] ob: The object.
|
||||
* \param[in] fill_color: The fill color.
|
||||
* \param[in] only_selected: Limit the fill to selected faces or vertices.
|
||||
*
|
||||
* \return #true if successful.
|
||||
*/
|
||||
static bool paint_object_attributes_active_color_fill_ex(Object *ob,
|
||||
ColorPaint4f fill_color,
|
||||
bool only_selected = true)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
Mesh *me = BKE_object_get_original_mesh(obact);
|
||||
|
||||
// uint paintcol = vpaint_get_current_color(scene, scene->toolsettings->vpaint, false);
|
||||
ColorPaint4f paintcol = vpaint_get_current_col<ColorPaint4f, FloatTraits, ATTR_DOMAIN_POINT>(
|
||||
scene, scene->toolsettings->vpaint, false);
|
||||
|
||||
bool ok = false;
|
||||
|
||||
Mesh *me = BKE_object_get_original_mesh(ob);
|
||||
if (!me) {
|
||||
return false;
|
||||
}
|
||||
CustomDataLayer *layer = BKE_id_attributes_active_color_get(&me->id);
|
||||
if (!layer) {
|
||||
return false;
|
||||
}
|
||||
/* Store original #Mesh.editflag.*/
|
||||
const decltype(me->editflag) editflag = me->editflag;
|
||||
if (!only_selected) {
|
||||
me->editflag &= ~ME_EDIT_PAINT_FACE_SEL;
|
||||
me->editflag &= ~ME_EDIT_PAINT_VERT_SEL;
|
||||
}
|
||||
AttributeDomain domain = BKE_id_attribute_domain(&me->id, layer);
|
||||
|
||||
bool ok = false;
|
||||
if (domain == ATTR_DOMAIN_POINT) {
|
||||
if (layer->type == CD_PROP_COLOR) {
|
||||
ok = vertex_color_set<ColorPaint4f, FloatTraits, ATTR_DOMAIN_POINT>(
|
||||
obact, paintcol, static_cast<ColorPaint4f *>(layer->data));
|
||||
ob, fill_color, static_cast<ColorPaint4f *>(layer->data));
|
||||
}
|
||||
else if (layer->type == CD_PROP_BYTE_COLOR) {
|
||||
ok = vertex_color_set<ColorPaint4b, ByteTraits, ATTR_DOMAIN_POINT>(
|
||||
obact, paintcol, static_cast<ColorPaint4b *>(layer->data));
|
||||
ob, fill_color, static_cast<ColorPaint4b *>(layer->data));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (layer->type == CD_PROP_COLOR) {
|
||||
ok = vertex_color_set<ColorPaint4f, FloatTraits, ATTR_DOMAIN_CORNER>(
|
||||
obact, paintcol, static_cast<ColorPaint4f *>(layer->data));
|
||||
ob, fill_color, static_cast<ColorPaint4f *>(layer->data));
|
||||
}
|
||||
else if (layer->type == CD_PROP_BYTE_COLOR) {
|
||||
ok = vertex_color_set<ColorPaint4b, ByteTraits, ATTR_DOMAIN_CORNER>(
|
||||
obact, paintcol, static_cast<ColorPaint4b *>(layer->data));
|
||||
ob, fill_color, static_cast<ColorPaint4b *>(layer->data));
|
||||
}
|
||||
}
|
||||
/* Restore #Mesh.editflag. */
|
||||
me->editflag = editflag;
|
||||
return ok;
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
extern "C" bool BKE_object_attributes_active_color_fill(Object *ob,
|
||||
const float fill_color[4],
|
||||
bool only_selected)
|
||||
{
|
||||
return paint_object_attributes_active_color_fill_ex(ob, ColorPaint4f(fill_color), only_selected);
|
||||
}
|
||||
|
||||
static int vertex_color_set_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
|
||||
// uint paintcol = vpaint_get_current_color(scene, scene->toolsettings->vpaint, false);
|
||||
ColorPaint4f paintcol = vpaint_get_current_col<ColorPaint4f, FloatTraits, ATTR_DOMAIN_POINT>(
|
||||
scene, scene->toolsettings->vpaint, false);
|
||||
|
||||
if (paint_object_attributes_active_color_fill_ex(obact, paintcol)) {
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obact);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
|
|
@ -185,14 +185,7 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = {
|
|||
[GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE] =
|
||||
{
|
||||
.name = "GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE",
|
||||
#ifdef __APPLE__
|
||||
/* GPUShaderCreateInfo is disabled on MacOS due to mismatch with OCIO shader. See
|
||||
* T95052 for more details. */
|
||||
.vert = datatoc_gpu_shader_2D_image_vert_glsl,
|
||||
.frag = datatoc_gpu_shader_image_overlays_merge_frag_glsl,
|
||||
#else
|
||||
.create_info = "gpu_shader_2D_image_overlays_merge",
|
||||
#endif
|
||||
},
|
||||
[GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE] =
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue