WIP: Brush assets project #106303

Draft
Julian Eisel wants to merge 352 commits from brush-assets-project into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
29 changed files with 198 additions and 145 deletions
Showing only changes of commit c310969f67 - Show all commits

View File

@ -245,7 +245,9 @@ mark_as_advanced(CPACK_OVERRIDE_PACKAGENAME)
mark_as_advanced(BUILDINFO_OVERRIDE_DATE)
mark_as_advanced(BUILDINFO_OVERRIDE_TIME)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16")
# CMAKE 3.28.2 has issues with the combination of PCH and unity builds, disable for now.
# upstream ticket https://gitlab.kitware.com/cmake/cmake/-/issues/25650
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16" AND NOT ${CMAKE_VERSION} VERSION_EQUAL "3.28.2")
option(WITH_UNITY_BUILD "\
Enable unity build for modules that support it to improve compile times.\n\
WARNING: this option allows files to be built without all necessary headers!\n

View File

@ -1114,14 +1114,13 @@ class USERPREF_PT_theme_text_style(ThemePanel, CenterAlignMixIn, Panel):
layout.separator()
layout.label(text="Widget")
self._ui_font_style(layout, style.widget)
layout.separator()
layout.label(text="Widget Label")
self._ui_font_style(layout, style.widget_label)
layout.separator()
layout.label(text="Widget")
self._ui_font_style(layout, style.widget)
class USERPREF_PT_theme_bone_color_sets(ThemePanel, CenterAlignMixIn, Panel):
bl_label = "Bone Color Sets"

View File

@ -335,7 +335,7 @@ void BKE_image_merge(struct Main *bmain, struct Image *dest, struct Image *sourc
/**
* Scale the image.
*/
bool BKE_image_scale(struct Image *image, int width, int height);
bool BKE_image_scale(struct Image *image, int width, int height, struct ImageUser *iuser);
/**
* Check if texture has alpha `planes == 32 || planes == 16`.

View File

@ -775,7 +775,7 @@ void BKE_image_merge(Main *bmain, Image *dest, Image *source)
}
}
bool BKE_image_scale(Image *image, int width, int height)
bool BKE_image_scale(Image *image, int width, int height, ImageUser *iuser)
{
/* NOTE: We could be clever and scale all imbuf's
* but since some are mipmaps its not so simple. */
@ -783,7 +783,7 @@ bool BKE_image_scale(Image *image, int width, int height)
ImBuf *ibuf;
void *lock;
ibuf = BKE_image_acquire_ibuf(image, nullptr, &lock);
ibuf = BKE_image_acquire_ibuf(image, iuser, &lock);
if (ibuf) {
IMB_scaleImBuf(ibuf, width, height);

View File

@ -790,6 +790,7 @@ void DrawMultiBuf::bind(RecordingState &state,
else {
GPU_memory_barrier(GPU_BARRIER_SHADER_STORAGE);
}
GPU_storagebuf_sync_as_indirect_buffer(command_buf_);
}
GPU_debug_group_end();

View File

@ -644,20 +644,21 @@ static uiBut *add_tab_button(uiBlock &block, StringRefNull name)
const int pad_x = UI_UNIT_X * 0.3f;
const int but_width = std::min(string_width + 2 * pad_x, UI_UNIT_X * 8);
uiBut *but = uiDefBut(&block,
UI_BTYPE_TAB,
0,
name.c_str(),
0,
0,
but_width,
UI_UNIT_Y,
nullptr,
0,
0,
0,
0,
"Enable catalog, making contained assets visible in the asset shelf");
uiBut *but = uiDefBut(
&block,
UI_BTYPE_TAB,
0,
name,
0,
0,
but_width,
UI_UNIT_Y,
nullptr,
0,
0,
0,
0,
TIP_("Enable catalog, making contained assets visible in the asset shelf"));
UI_but_drawflag_enable(but, UI_BUT_ALIGN_DOWN);
UI_but_flag_disable(but, UI_BUT_UNDO);

View File

@ -1010,8 +1010,6 @@ uiBut *uiDefButF(uiBlock *block,
float *poin,
float min,
float max,
float a1,
float a2,
const char *tip);
uiBut *uiDefButI(uiBlock *block,
int type,
@ -1734,6 +1732,9 @@ void UI_but_node_link_set(uiBut *but, bNodeSocket *socket, const float draw_colo
void UI_but_number_step_size_set(uiBut *but, float step_size);
void UI_but_number_precision_set(uiBut *but, float precision);
void UI_but_number_slider_step_size_set(uiBut *but, float step_size);
void UI_but_number_slider_precision_set(uiBut *but, float precision);
void UI_block_func_handle_set(uiBlock *block, uiBlockHandleFunc func, void *arg);
void UI_block_func_butmenu_set(uiBlock *block, uiMenuHandleFunc func, void *arg);
void UI_block_func_set(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2);

View File

@ -641,6 +641,9 @@ static float ui_but_get_float_precision(uiBut *but)
if (but->type == UI_BTYPE_NUM) {
return ((uiButNumber *)but)->precision;
}
if (but->type == UI_BTYPE_NUM_SLIDER) {
return ((uiButNumberSlider *)but)->precision;
}
return but->a2;
}
@ -650,6 +653,9 @@ static float ui_but_get_float_step_size(uiBut *but)
if (but->type == UI_BTYPE_NUM) {
return ((uiButNumber *)but)->step_size;
}
if (but->type == UI_BTYPE_NUM_SLIDER) {
return ((uiButNumberSlider *)but)->step_size;
}
return but->a1;
}
@ -3964,6 +3970,9 @@ static uiBut *ui_but_new(const eButType type)
case UI_BTYPE_NUM:
but = MEM_new<uiButNumber>("uiButNumber");
break;
case UI_BTYPE_NUM_SLIDER:
but = MEM_new<uiButNumberSlider>("uiButNumber");
break;
case UI_BTYPE_COLOR:
but = MEM_new<uiButColor>("uiButColor");
break;
@ -4544,7 +4553,7 @@ static uiBut *ui_def_but_rna(uiBlock *block,
const PropertyType proptype = RNA_property_type(prop);
int icon = 0;
uiMenuCreateFunc func = nullptr;
const bool always_set_a1_a2 = ELEM(type, UI_BTYPE_NUM);
const bool always_set_a1_a2 = ELEM(type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER);
if (ELEM(type, UI_BTYPE_COLOR, UI_BTYPE_HSVCIRCLE, UI_BTYPE_HSVCUBE)) {
BLI_assert(index == -1);
@ -4659,6 +4668,11 @@ static uiBut *ui_def_but_rna(uiBlock *block,
UI_but_number_step_size_set(but, a1);
UI_but_number_precision_set(but, a2);
}
else if (but->type == UI_BTYPE_NUM_SLIDER) {
/* Set default values, can be overridden later. */
UI_but_number_slider_step_size_set(but, a1);
UI_but_number_slider_precision_set(but, a2);
}
but->rnapoin = *ptr;
but->rnaprop = prop;
@ -4710,6 +4724,10 @@ static uiBut *ui_def_but_rna(uiBlock *block,
uiButNumber *number_but = (uiButNumber *)but;
number_but->step_size = ui_get_but_step_unit(but, number_but->step_size);
}
if (type == UI_BTYPE_NUM_SLIDER) {
uiButNumberSlider *number_but = (uiButNumberSlider *)but;
number_but->step_size = ui_get_but_step_unit(but, number_but->step_size);
}
else {
but->a1 = ui_get_but_step_unit(but, but->a1);
}
@ -5049,8 +5067,6 @@ uiBut *uiDefButF(uiBlock *block,
float *poin,
float min,
float max,
float a1,
float a2,
const char *tip)
{
return uiDefBut(block,
@ -5064,8 +5080,8 @@ uiBut *uiDefButF(uiBlock *block,
(void *)poin,
min,
max,
a1,
a2,
0.0f,
0.0f,
tip);
}
uiBut *uiDefButI(uiBlock *block,
@ -6480,6 +6496,25 @@ void UI_but_number_precision_set(uiBut *but, float precision)
BLI_assert(precision > -2);
}
void UI_but_number_slider_step_size_set(uiBut *but, float step_size)
{
uiButNumberSlider *but_number = (uiButNumberSlider *)but;
BLI_assert(but->type == UI_BTYPE_NUM_SLIDER);
but_number->step_size = step_size;
BLI_assert(step_size > 0);
}
void UI_but_number_slider_precision_set(uiBut *but, float precision)
{
uiButNumberSlider *but_number = (uiButNumberSlider *)but;
BLI_assert(but->type == UI_BTYPE_NUM_SLIDER);
but_number->precision = precision;
/* -1 is a valid value, UI code figures out an appropriate precision then. */
BLI_assert(precision > -2);
}
void UI_but_focus_on_enter_event(wmWindow *win, uiBut *but)
{
wmEvent event;

View File

@ -5624,6 +5624,7 @@ static bool ui_numedit_but_SLI(uiBut *but,
const bool snap,
const bool shift)
{
uiButNumberSlider *slider_but = reinterpret_cast<uiButNumberSlider *>(but);
float cursor_x_range, f, tempf, softmin, softmax, softrange;
int temp, lvalue;
bool changed = false;
@ -5655,7 +5656,7 @@ static bool ui_numedit_but_SLI(uiBut *but,
const float size = (is_horizontal) ? BLI_rctf_size_x(&but->rect) :
-BLI_rctf_size_y(&but->rect);
cursor_x_range = size * (but->softmax - but->softmin) /
(but->softmax - but->softmin + but->a1);
(but->softmax - but->softmin + slider_but->step_size);
}
else {
const float ofs = (BLI_rctf_size_y(&but->rect) / 2.0f);

View File

@ -321,8 +321,14 @@ struct uiBut {
/** Derived struct for #UI_BTYPE_NUM */
struct uiButNumber : public uiBut {
float step_size = 0;
float precision = 0;
float step_size = 0.0f;
float precision = 0.0f;
};
/** Derived struct for #UI_BTYPE_NUM_SLIDER */
struct uiButNumberSlider : public uiBut {
float step_size = 0.0f;
float precision = 0.0f;
};
/** Derived struct for #UI_BTYPE_COLOR */

View File

@ -649,9 +649,10 @@ static void ui_item_array(uiLayout *layout,
UI_UNIT_Y);
if (slider && but->type == UI_BTYPE_NUM) {
uiButNumber *number_but = (uiButNumber *)but;
but->a1 = number_but->step_size;
const float step_size = number_but->step_size;
but = ui_but_change_type(but, UI_BTYPE_NUM_SLIDER);
uiButNumberSlider *slider_but = reinterpret_cast<uiButNumberSlider *>(but);
slider_but->step_size = step_size;
}
}
}
@ -719,9 +720,10 @@ static void ui_item_array(uiLayout *layout,
block, ptr, prop, a, str_buf, icon, 0, 0, width_item, UI_UNIT_Y);
if (slider && but->type == UI_BTYPE_NUM) {
uiButNumber *number_but = (uiButNumber *)but;
but->a1 = number_but->step_size;
const float step_size = number_but->step_size;
but = ui_but_change_type(but, UI_BTYPE_NUM_SLIDER);
uiButNumberSlider *slider_but = reinterpret_cast<uiButNumberSlider *>(but);
slider_but->step_size = step_size;
}
if ((toggle == 1) && but->type == UI_BTYPE_CHECKBOX) {
but->type = UI_BTYPE_TOGGLE;
@ -2448,10 +2450,11 @@ void uiItemFullR(uiLayout *layout,
but = uiDefAutoButR(block, ptr, prop, index, name, icon, 0, 0, w, h);
if (slider && but->type == UI_BTYPE_NUM) {
uiButNumber *num_but = (uiButNumber *)but;
but->a1 = num_but->step_size;
uiButNumber *number_but = (uiButNumber *)but;
const float step_size = number_but->step_size;
but = ui_but_change_type(but, UI_BTYPE_NUM_SLIDER);
uiButNumberSlider *slider_but = reinterpret_cast<uiButNumberSlider *>(but);
slider_but->step_size = step_size;
}
if (flag & UI_ITEM_R_CHECKBOX_INVERT) {

View File

@ -623,9 +623,11 @@ static void ui_block_colorpicker(uiBlock *block,
0,
0.0,
0.0,
10,
3,
0,
0,
TIP_("Red"));
UI_but_number_slider_step_size_set(bt, 10);
UI_but_number_slider_precision_set(bt, 3);
UI_but_func_set(bt, ui_colorpicker_rgba_update_cb, bt, nullptr);
bt->custom_data = cpicker;
bt = uiDefButR_prop(block,
@ -641,9 +643,11 @@ static void ui_block_colorpicker(uiBlock *block,
1,
0.0,
0.0,
10,
3,
0,
0,
TIP_("Green"));
UI_but_number_slider_step_size_set(bt, 10);
UI_but_number_slider_precision_set(bt, 3);
UI_but_func_set(bt, ui_colorpicker_rgba_update_cb, bt, nullptr);
bt->custom_data = cpicker;
bt = uiDefButR_prop(block,
@ -659,9 +663,11 @@ static void ui_block_colorpicker(uiBlock *block,
2,
0.0,
0.0,
10,
3,
0,
0,
TIP_("Blue"));
UI_but_number_slider_step_size_set(bt, 10);
UI_but_number_slider_precision_set(bt, 3);
UI_but_func_set(bt, ui_colorpicker_rgba_update_cb, bt, nullptr);
bt->custom_data = cpicker;
@ -683,9 +689,9 @@ static void ui_block_colorpicker(uiBlock *block,
cpicker->hsv_scene_linear,
0.0,
1.0,
10,
3,
TIP_("Hue"));
UI_but_number_slider_step_size_set(bt, 10);
UI_but_number_slider_precision_set(bt, 3);
UI_but_flag_disable(bt, UI_BUT_UNDO);
UI_but_func_set(bt, ui_colorpicker_hsv_update_cb, bt, nullptr);
bt->custom_data = cpicker;
@ -700,9 +706,9 @@ static void ui_block_colorpicker(uiBlock *block,
cpicker->hsv_scene_linear + 1,
0.0,
1.0,
10,
3,
TIP_("Saturation"));
UI_but_number_slider_step_size_set(bt, 10);
UI_but_number_slider_precision_set(bt, 3);
UI_but_flag_disable(bt, UI_BUT_UNDO);
UI_but_func_set(bt, ui_colorpicker_hsv_update_cb, bt, nullptr);
bt->custom_data = cpicker;
@ -718,9 +724,9 @@ static void ui_block_colorpicker(uiBlock *block,
cpicker->hsv_scene_linear + 2,
0.0,
1.0,
10,
3,
TIP_("Lightness"));
UI_but_number_slider_step_size_set(bt, 10);
UI_but_number_slider_precision_set(bt, 3);
}
else {
bt = uiDefButF(block,
@ -734,10 +740,10 @@ static void ui_block_colorpicker(uiBlock *block,
cpicker->hsv_scene_linear + 2,
0.0,
softmax,
10,
3,
CTX_TIP_(BLT_I18NCONTEXT_COLOR, "Value"));
}
UI_but_number_slider_step_size_set(bt, 10);
UI_but_number_slider_precision_set(bt, 3);
UI_but_flag_disable(bt, UI_BUT_UNDO);
bt->hardmax = hardmax; /* Not common but RGB may be over 1.0. */
@ -760,9 +766,11 @@ static void ui_block_colorpicker(uiBlock *block,
3,
0.0,
0.0,
10,
3,
0,
0,
TIP_("Alpha"));
UI_but_number_slider_step_size_set(bt, 10);
UI_but_number_slider_precision_set(bt, 3);
UI_but_func_set(bt, ui_colorpicker_rgba_update_cb, bt, nullptr);
bt->custom_data = cpicker;
}

View File

@ -4314,8 +4314,6 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *region, void *cumap
&cumap->clipr.xmin,
-100.0,
cumap->clipr.xmax,
0,
0,
"");
UI_but_number_step_size_set(bt, 10);
UI_but_number_precision_set(bt, 2);
@ -4330,8 +4328,6 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *region, void *cumap
&cumap->clipr.ymin,
-100.0,
cumap->clipr.ymax,
0,
0,
"");
UI_but_number_step_size_set(bt, 10);
UI_but_number_precision_set(bt, 2);
@ -4346,8 +4342,6 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *region, void *cumap
&cumap->clipr.xmax,
cumap->clipr.xmin,
100.0,
0,
0,
"");
UI_but_number_step_size_set(bt, 10);
UI_but_number_precision_set(bt, 2);
@ -4362,8 +4356,6 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *region, void *cumap
&cumap->clipr.ymax,
cumap->clipr.ymin,
100.0,
0,
0,
"");
UI_but_number_step_size_set(bt, 10);
UI_but_number_precision_set(bt, 2);
@ -4889,8 +4881,6 @@ static void curvemap_buttons_layout(uiLayout *layout,
&cmp->x,
bounds.xmin,
bounds.xmax,
0,
0,
"");
UI_but_number_step_size_set(bt, 1);
UI_but_number_precision_set(bt, 5);
@ -4905,8 +4895,6 @@ static void curvemap_buttons_layout(uiLayout *layout,
&cmp->y,
bounds.ymin,
bounds.ymax,
0,
0,
"");
UI_but_number_step_size_set(bt, 1);
UI_but_number_precision_set(bt, 5);
@ -5533,8 +5521,6 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
selection_x,
bounds.xmin,
bounds.xmax,
0,
0,
"");
UI_but_number_step_size_set(bt, 1);
UI_but_number_precision_set(bt, 5);
@ -5553,8 +5539,6 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
selection_y,
bounds.ymin,
bounds.ymax,
0,
0,
"");
UI_but_number_step_size_set(bt, 1);
UI_but_number_precision_set(bt, 5);

View File

@ -163,8 +163,8 @@ uiBut *uiDefAutoButR(uiBlock *block,
index,
0,
0,
-1,
-1,
0,
0,
nullptr);
}
else {

View File

@ -555,8 +555,6 @@ void uiTemplateMarker(uiLayout *layout,
&cb->marker_pos[0],
-10 * width,
10.0 * width,
0,
0,
TIP_("X-position of marker at frame in screen coordinates"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
@ -571,8 +569,6 @@ void uiTemplateMarker(uiLayout *layout,
&cb->marker_pos[1],
-10 * height,
10.0 * height,
0,
0,
TIP_("Y-position of marker at frame in screen coordinates"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
@ -602,8 +598,6 @@ void uiTemplateMarker(uiLayout *layout,
&cb->track_offset[0],
-10 * width,
10.0 * width,
0,
0,
TIP_("X-offset to parenting point"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
@ -618,8 +612,6 @@ void uiTemplateMarker(uiLayout *layout,
&cb->track_offset[1],
-10 * height,
10.0 * height,
0,
0,
TIP_("Y-offset to parenting point"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
@ -649,8 +641,6 @@ void uiTemplateMarker(uiLayout *layout,
&cb->marker_pat[0],
3.0f,
10.0 * width,
0,
0,
TIP_("Width of marker's pattern in screen coordinates"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
@ -665,8 +655,6 @@ void uiTemplateMarker(uiLayout *layout,
&cb->marker_pat[1],
3.0f,
10.0 * height,
0,
0,
TIP_("Height of marker's pattern in screen coordinates"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
@ -696,8 +684,6 @@ void uiTemplateMarker(uiLayout *layout,
&cb->marker_search_pos[0],
-width,
width,
0,
0,
TIP_("X-position of search at frame relative to marker's position"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
@ -712,8 +698,6 @@ void uiTemplateMarker(uiLayout *layout,
&cb->marker_search_pos[1],
-height,
height,
0,
0,
TIP_("Y-position of search at frame relative to marker's position"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
@ -728,8 +712,6 @@ void uiTemplateMarker(uiLayout *layout,
&cb->marker_search[0],
3.0f,
10.0 * width,
0,
0,
TIP_("Width of marker's search in screen coordinates"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);
@ -744,8 +726,6 @@ void uiTemplateMarker(uiLayout *layout,
&cb->marker_search[1],
3.0f,
10.0 * height,
0,
0,
TIP_("Height of marker's search in screen coordinates"));
UI_but_number_step_size_set(bt, step);
UI_but_number_precision_set(bt, digits);

View File

@ -562,8 +562,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&tfp->ve_median.generic.location[0],
-lim,
lim,
0,
0,
"");
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, RNA_TRANSLATION_PREC_DEFAULT);
@ -579,8 +577,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&tfp->ve_median.generic.location[1],
-lim,
lim,
0,
0,
"");
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, RNA_TRANSLATION_PREC_DEFAULT);
@ -596,8 +592,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&tfp->ve_median.generic.location[2],
-lim,
lim,
0,
0,
"");
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, RNA_TRANSLATION_PREC_DEFAULT);
@ -615,8 +609,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&(tfp->ve_median.curve.b_weight),
0.01,
100.0,
0,
0,
"");
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
@ -685,8 +677,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&ve_median->bv_weight,
0.0,
1.0,
0,
0,
TIP_("Vertex weight used by Bevel modifier"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 2);
@ -702,8 +692,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&ve_median->v_crease,
0.0,
1.0,
0,
0,
TIP_("Weight used by the Subdivision Surface modifier"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 2);
@ -721,8 +709,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&ve_median->skin[0],
0.0,
100.0,
0,
0,
TIP_("X radius used by Skin modifier"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
@ -737,8 +723,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&ve_median->skin[1],
0.0,
100.0,
0,
0,
TIP_("Y radius used by Skin modifier"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
@ -771,8 +755,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&ve_median->be_weight,
0.0,
1.0,
0,
0,
TIP_("Edge weight used by Bevel modifier"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 2);
@ -788,8 +770,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&ve_median->e_crease,
0.0,
1.0,
0,
0,
TIP_("Weight used by the Subdivision Surface modifier"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 2);
@ -866,8 +846,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&ve_median->weight,
0.0,
1.0,
0,
0,
TIP_("Weight used for Soft Body Goal"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
@ -882,8 +860,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&ve_median->radius,
0.0,
100.0,
0,
0,
TIP_("Radius of curve control points"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
@ -898,8 +874,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&ve_median->tilt,
-tilt_limit,
tilt_limit,
0,
0,
TIP_("Tilt of curve control points"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
@ -941,8 +915,6 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
&ve_median->weight,
0.0,
1.0,
0,
0,
TIP_("Weight used for Soft Body Goal"));
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);
@ -1273,8 +1245,6 @@ static void v3d_object_dimension_buts(bContext *C, uiLayout *layout, View3D *v3d
&(tfp->ob_dims[i]),
0.0f,
lim,
0,
0,
"");
UI_but_number_step_size_set(but, 10);
UI_but_number_precision_set(but, 3);
@ -1441,8 +1411,6 @@ static void view3d_panel_vgroup(const bContext *C, Panel *panel)
&vertex_weight,
0.0,
1.0,
0,
0,
"");
UI_but_number_step_size_set(but, 1);
UI_but_number_precision_set(but, 3);

View File

@ -169,8 +169,6 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block)
UI_UNIT_Y,
&uvedit_old_center[0],
UNPACK2(range_xy[0]),
0,
0,
"");
UI_but_number_step_size_set(but, step);
UI_but_number_precision_set(but, digits);
@ -184,8 +182,6 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block)
UI_UNIT_Y,
&uvedit_old_center[1],
UNPACK2(range_xy[1]),
0,
0,
"");
UI_but_number_step_size_set(but, step);
UI_but_number_precision_set(but, digits);

View File

@ -17,7 +17,7 @@
#include "BKE_collection.h"
#include "BKE_curves.hh"
#include "BKE_deform.hh"
#include "BKE_customdata.hh"
#include "BKE_geometry_set_instances.hh"
#include "BKE_instances.hh"
#include "BKE_material.h"
@ -1171,7 +1171,22 @@ static void execute_realize_mesh_tasks(const RealizeInstancesOptions &options,
dst_attribute_writers.append(
dst_attributes.lookup_or_add_for_write_only_span(attribute_id, domain, data_type));
}
const char *active_layer = CustomData_get_active_layer_name(&first_mesh.corner_data,
CD_PROP_FLOAT2);
if (active_layer != nullptr) {
int id = CustomData_get_named_layer(&dst_mesh->corner_data, CD_PROP_FLOAT2, active_layer);
if (id >= 0) {
CustomData_set_layer_active(&dst_mesh->corner_data, CD_PROP_FLOAT2, id);
}
}
const char *render_layer = CustomData_get_render_layer_name(&first_mesh.corner_data,
CD_PROP_FLOAT2);
if (render_layer != nullptr) {
int id = CustomData_get_named_layer(&dst_mesh->corner_data, CD_PROP_FLOAT2, render_layer);
if (id >= 0) {
CustomData_set_layer_render(&dst_mesh->corner_data, CD_PROP_FLOAT2, id);
}
}
/* Actually execute all tasks. */
threading::parallel_for(tasks.index_range(), 100, [&](const IndexRange task_range) {
for (const int task_index : task_range) {

View File

@ -5,6 +5,7 @@
#include "GEO_separate_geometry.hh"
#include "BKE_curves.hh"
#include "BKE_customdata.hh"
#include "BKE_geometry_fields.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_instances.hh"
@ -183,6 +184,27 @@ void separate_geometry(bke::GeometrySet &geometry_set,
std::optional<Mesh *> dst_mesh = separate_mesh_selection(
*mesh, selection, domain, mode, propagation_info);
if (dst_mesh) {
if (*dst_mesh) {
const char *active_layer = CustomData_get_active_layer_name(&mesh->corner_data,
CD_PROP_FLOAT2);
if (active_layer != nullptr) {
int id = CustomData_get_named_layer(
&((*dst_mesh)->corner_data), CD_PROP_FLOAT2, active_layer);
if (id >= 0) {
CustomData_set_layer_active(&((*dst_mesh)->corner_data), CD_PROP_FLOAT2, id);
}
}
const char *render_layer = CustomData_get_render_layer_name(&mesh->corner_data,
CD_PROP_FLOAT2);
if (render_layer != nullptr) {
int id = CustomData_get_named_layer(
&((*dst_mesh)->corner_data), CD_PROP_FLOAT2, render_layer);
if (id >= 0) {
CustomData_set_layer_render(&((*dst_mesh)->corner_data), CD_PROP_FLOAT2, id);
}
}
}
geometry_set.replace_mesh(*dst_mesh);
}
some_valid_domain = true;

View File

@ -326,7 +326,8 @@ void GPU_batch_draw_advanced(
* The argument are expected to be valid for the type of geometry contained by this #GPUBatch
* (index or non-indexed).
*
* A `GPU_BARRIER_COMMAND` memory barrier is automatically added before the call.
* The indirect buffer needs to be synced after filling its contents and before calling this
* function using `GPU_storagebuf_sync_as_indirect_buffer`.
*
* For more info see the GL documentation:
* https://registry.khronos.org/OpenGL-Refpages/gl4/html/glDrawArraysIndirect.xhtml
@ -339,7 +340,8 @@ void GPU_batch_draw_indirect(GPUBatch *batch, GPUStorageBuf *indirect_buf, intpt
* The argument are expected to be valid for the type of geometry contained by this #GPUBatch
* (index or non-indexed).
*
* A `GPU_BARRIER_COMMAND` memory barrier is automatically added before the call.
* The indirect buffer needs to be synced after filling its contents and before calling this
* function using `GPU_storagebuf_sync_as_indirect_buffer`.
*
* For more info see the GL documentation:
* https://registry.khronos.org/OpenGL-Refpages/gl4/html/glMultiDrawArraysIndirect.xhtml

View File

@ -81,6 +81,12 @@ void GPU_storagebuf_read(GPUStorageBuf *ssbo, void *data);
void GPU_storagebuf_copy_sub_from_vertbuf(
GPUStorageBuf *ssbo, GPUVertBuf *src, uint dst_offset, uint src_offset, uint copy_size);
/**
* Ensure the ssbo is ready to be used as an indirect buffer in `GPU_batch_draw_indirect`.
* NOTE: Internallly, this is only required for the OpenGL backend.
*/
void GPU_storagebuf_sync_as_indirect_buffer(GPUStorageBuf *ssbo);
#ifdef __cplusplus
}
#endif

View File

@ -116,4 +116,9 @@ void GPU_storagebuf_read(GPUStorageBuf *ssbo, void *data)
unwrap(ssbo)->read(data);
}
void GPU_storagebuf_sync_as_indirect_buffer(GPUStorageBuf *ssbo)
{
unwrap(ssbo)->sync_as_indirect_buffer();
}
/** \} */

View File

@ -48,6 +48,7 @@ class StorageBuf {
virtual void copy_sub(VertBuf *src, uint dst_offset, uint src_offset, uint copy_size) = 0;
virtual void read(void *data) = 0;
virtual void async_flush_to_host() = 0;
virtual void sync_as_indirect_buffer() = 0;
};
/* Syntactic sugar. */

View File

@ -76,6 +76,7 @@ class MTLStorageBuf : public StorageBuf {
void copy_sub(VertBuf *src, uint dst_offset, uint src_offset, uint copy_size) override;
void read(void *data) override;
void async_flush_to_host() override;
void sync_as_indirect_buffer() override{/* No-Op.*/};
void init();

View File

@ -276,11 +276,7 @@ void GLBatch::draw_indirect(GPUStorageBuf *indirect_buf, intptr_t offset)
GL_CHECK_RESOURCES("Batch");
this->bind();
/* TODO(fclem): Make the barrier and binding optional if consecutive draws are issued. */
dynamic_cast<GLStorageBuf *>(unwrap(indirect_buf))->bind_as(GL_DRAW_INDIRECT_BUFFER);
/* This barrier needs to be here as it only work on the currently bound indirect buffer. */
glMemoryBarrier(GL_COMMAND_BARRIER_BIT);
GLenum gl_type = to_gl(prim_type);
if (elem) {
@ -303,11 +299,7 @@ void GLBatch::multi_draw_indirect(GPUStorageBuf *indirect_buf,
GL_CHECK_RESOURCES("Batch");
this->bind();
/* TODO(fclem): Make the barrier and binding optional if consecutive draws are issued. */
dynamic_cast<GLStorageBuf *>(unwrap(indirect_buf))->bind_as(GL_DRAW_INDIRECT_BUFFER);
/* This barrier needs to be here as it only work on the currently bound indirect buffer. */
glMemoryBarrier(GL_COMMAND_BARRIER_BIT);
GLenum gl_type = to_gl(prim_type);
if (elem) {

View File

@ -183,6 +183,13 @@ void GLStorageBuf::read(void *data)
}
}
void GLStorageBuf::sync_as_indirect_buffer()
{
bind_as(GL_DRAW_INDIRECT_BUFFER);
glMemoryBarrier(GL_COMMAND_BARRIER_BIT);
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
}
/** \} */
} // namespace blender::gpu

View File

@ -38,6 +38,7 @@ class GLStorageBuf : public StorageBuf {
void copy_sub(VertBuf *src, uint dst_offset, uint src_offset, uint copy_size) override;
void read(void *data) override;
void async_flush_to_host() override;
void sync_as_indirect_buffer() override;
/* Special internal function to bind SSBOs to indirect argument targets. */
void bind_as(GLenum target);

View File

@ -36,6 +36,7 @@ class VKStorageBuffer : public StorageBuf, public VKBindableResource {
void copy_sub(VertBuf *src, uint dst_offset, uint src_offset, uint copy_size) override;
void read(void *data) override;
void async_flush_to_host() override;
void sync_as_indirect_buffer() override{/* No-Op.*/};
VkBuffer vk_handle() const
{

View File

@ -10,6 +10,7 @@
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fcntl.h>
#include "DNA_packedFile_types.h"
@ -179,10 +180,21 @@ static void rna_Image_update(Image *image, ReportList *reports)
BKE_image_release_ibuf(image, ibuf, nullptr);
}
static void rna_Image_scale(Image *image, ReportList *reports, int width, int height)
static void rna_Image_scale(
Image *image, ReportList *reports, int width, int height, int frame, int tile_index)
{
if (!BKE_image_scale(image, width, height)) {
BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2);
ImageUser iuser{};
BKE_imageuser_default(&iuser);
iuser.framenr = frame;
if (image->source == IMA_SRC_TILED) {
const ImageTile *tile = static_cast<ImageTile *>(BLI_findlink(&image->tiles, tile_index));
if (tile != nullptr) {
iuser.tile = tile->tile_number;
}
}
if (!BKE_image_scale(image, width, height, &iuser)) {
BKE_reportf(reports, RPT_ERROR, "Image '%s' failed to load image buffer", image->id.name + 2);
return;
}
BKE_image_partial_update_mark_full_update(image);
@ -334,6 +346,9 @@ void RNA_api_image(StructRNA *srna)
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
parm = RNA_def_int(func, "height", 1, 1, INT_MAX, "", "Height", 1, INT_MAX);
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
RNA_def_int(func, "frame", 0, 0, INT_MAX, "Frame", "Frame (for image sequences)", 0, INT_MAX);
RNA_def_int(
func, "tile_index", 0, 0, INT_MAX, "Tile", "Tile index (for tiled images)", 0, INT_MAX);
func = RNA_def_function(srna, "gl_touch", "rna_Image_gl_touch");
RNA_def_function_ui_description(