diff options
Diffstat (limited to 'source/blender/editors')
39 files changed, 407 insertions, 448 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 3d7178a4114..1649744ba8d 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -206,16 +206,16 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa * - only use group colors if allowed to, and if actually feasible */ if (showGroupColors && (grp) && (grp->customCol)) { - unsigned char cp[3]; + uchar cp[3]; if (indent == 2) { - copy_v3_v3_char((char *)cp, grp->cs.solid); + copy_v3_v3_uchar(cp, grp->cs.solid); } else if (indent == 1) { - copy_v3_v3_char((char *)cp, grp->cs.select); + copy_v3_v3_uchar(cp, grp->cs.select); } else { - copy_v3_v3_char((char *)cp, grp->cs.active); + copy_v3_v3_uchar(cp, grp->cs.active); } /* copy the colors over, transforming from bytes to floats */ @@ -850,10 +850,10 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[ /* highlight only for active */ if (ale->flag & AGRP_ACTIVE) { - copy_v3_v3_char((char *)cp, agrp->cs.select); + copy_v3_v3_uchar(cp, agrp->cs.select); } else { - copy_v3_v3_char((char *)cp, agrp->cs.solid); + copy_v3_v3_uchar(cp, agrp->cs.solid); } /* copy the colors over, transforming from bytes to floats */ diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index e59e5d6a878..c9c4a67644e 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -561,87 +561,6 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure return GP_STROKEADD_INVALID; } -/* simplify a stroke (in buffer) before storing it - * - applies a reverse Chaikin filter - * - code adapted from etch-a-ton branch - */ -static void gp_stroke_simplify(tGPsdata *p) -{ - bGPdata *gpd = p->gpd; - tGPspoint *old_points = (tGPspoint *)gpd->runtime.sbuffer; - short num_points = gpd->runtime.sbuffer_used; - short flag = gpd->runtime.sbuffer_sflag; - short i, j; - - /* only simplify if simplification is enabled, and we're not doing a straight line */ - if (!(U.gp_settings & GP_PAINT_DOSIMPLIFY) || (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT)) { - return; - } - - /* don't simplify if less than 4 points in buffer */ - if ((num_points <= 4) || (old_points == NULL)) { - return; - } - - /* clear buffer (but don't free mem yet) so that we can write to it - * - firstly set sbuffer to NULL, so a new one is allocated - * - secondly, reset flag after, as it gets cleared auto - */ - gpd->runtime.sbuffer = NULL; - gp_session_validatebuffer(p); - gpd->runtime.sbuffer_sflag = flag; - -/* macro used in loop to get position of new point - * - used due to the mixture of datatypes in use here - */ -#define GP_SIMPLIFY_AVPOINT(offs, sfac) \ - { \ - co[0] += (float)(old_points[offs].x * sfac); \ - co[1] += (float)(old_points[offs].y * sfac); \ - pressure += old_points[offs].pressure * sfac; \ - time += old_points[offs].time * sfac; \ - } \ - (void)0 - - /* XXX Here too, do not lose start and end points! */ - gp_stroke_addpoint( - p, &old_points->x, old_points->pressure, p->inittime + (double)old_points->time); - for (i = 0, j = 0; i < num_points; i++) { - if (i - j == 3) { - float co[2], pressure, time; - float mco[2]; - - /* initialize values */ - co[0] = 0.0f; - co[1] = 0.0f; - pressure = 0.0f; - time = 0.0f; - - /* using macro, calculate new point */ - GP_SIMPLIFY_AVPOINT(j, -0.25f); - GP_SIMPLIFY_AVPOINT(j + 1, 0.75f); - GP_SIMPLIFY_AVPOINT(j + 2, 0.75f); - GP_SIMPLIFY_AVPOINT(j + 3, -0.25f); - - /* set values for adding */ - mco[0] = co[0]; - mco[1] = co[1]; - - /* ignore return values on this... assume to be ok for now */ - gp_stroke_addpoint(p, mco, pressure, p->inittime + (double)time); - - j += 2; - } - } - gp_stroke_addpoint(p, - &old_points[num_points - 1].x, - old_points[num_points - 1].pressure, - p->inittime + (double)old_points[num_points - 1].time); - - /* free old buffer */ - MEM_freeN(old_points); -} - /* make a new stroke from the buffer data */ static void gp_stroke_newfrombuffer(tGPsdata *p) { @@ -1466,9 +1385,6 @@ static void gp_paint_strokeend(tGPsdata *p) /* check if doing eraser or not */ if ((p->gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0) { - /* simplify stroke before transferring? */ - gp_stroke_simplify(p); - /* transfer stroke to frame */ gp_stroke_newfrombuffer(p); } diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index 1a7422cd174..8e4d2655ef0 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -1283,7 +1283,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) /* Init multi-edit falloff curve data before doing anything, * so we won't have to do it again later. */ if (gso->is_multiframe) { - curvemapping_initialize(ts->gp_sculpt.cur_falloff); + BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff); } /* initialise custom data for brushes */ diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c index 698e508a2a5..86de9a75a56 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@ -1003,7 +1003,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op) if (ipo_settings->type == GP_IPO_CURVEMAP) { /* custom curvemap */ if (ipo_settings->custom_ipo) { - factor = curvemapping_evaluateF(ipo_settings->custom_ipo, 0, factor); + factor = BKE_curvemapping_evaluateF(ipo_settings->custom_ipo, 0, factor); } else { BKE_report(op->reports, RPT_ERROR, "Custom interpolation curve does not exist"); diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index a271274fa71..06ff0e744b9 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -476,7 +476,7 @@ static void gp_brush_jitter(bGPdata *gpd, { float tmp_pressure = pressure; if (brush->gpencil_settings->draw_jitter > 0.0f) { - float curvef = curvemapping_evaluateF(brush->gpencil_settings->curve_jitter, 0, pressure); + float curvef = BKE_curvemapping_evaluateF(brush->gpencil_settings->curve_jitter, 0, pressure); tmp_pressure = curvef * brush->gpencil_settings->draw_sensitivity; } /* exponential value */ @@ -671,7 +671,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure /* store settings */ /* pressure */ if (brush->gpencil_settings->flag & GP_BRUSH_USE_PRESSURE) { - float curvef = curvemapping_evaluateF( + float curvef = BKE_curvemapping_evaluateF( brush->gpencil_settings->curve_sensitivity, 0, pressure); pt->pressure = curvef * brush->gpencil_settings->draw_sensitivity; } @@ -695,7 +695,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure /* apply randomness to pressure */ if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) && (brush->gpencil_settings->draw_random_press > 0.0f)) { - float curvef = curvemapping_evaluateF( + float curvef = BKE_curvemapping_evaluateF( brush->gpencil_settings->curve_sensitivity, 0, pressure); float tmp_pressure = curvef * brush->gpencil_settings->draw_sensitivity; if (BLI_rng_get_float(p->rng) > 0.5f) { @@ -731,7 +731,8 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure /* color strength */ if (brush->gpencil_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) { - float curvef = curvemapping_evaluateF(brush->gpencil_settings->curve_strength, 0, pressure); + float curvef = BKE_curvemapping_evaluateF( + brush->gpencil_settings->curve_strength, 0, pressure); float tmp_pressure = curvef * brush->gpencil_settings->draw_sensitivity; pt->strength = tmp_pressure * brush->gpencil_settings->draw_strength; @@ -1809,9 +1810,9 @@ static void gp_init_drawing_brush(bContext *C, tGPsdata *p) changed = true; } /* be sure curves are initializated */ - curvemapping_initialize(paint->brush->gpencil_settings->curve_sensitivity); - curvemapping_initialize(paint->brush->gpencil_settings->curve_strength); - curvemapping_initialize(paint->brush->gpencil_settings->curve_jitter); + BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_sensitivity); + BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_strength); + BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_jitter); /* assign to temp tGPsdata */ p->brush = paint->brush; diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index 816517d6ef9..25913fe821a 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -704,13 +704,13 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) gp_session_validatebuffer(tgpi); gp_init_colors(tgpi); if (gset->flag & GP_SCULPT_SETT_FLAG_PRIMITIVE_CURVE) { - curvemapping_initialize(ts->gp_sculpt.cur_primitive); + BKE_curvemapping_initialize(ts->gp_sculpt.cur_primitive); } if (tgpi->brush->gpencil_settings->flag & GP_BRUSH_USE_JITTER_PRESSURE) { - curvemapping_initialize(tgpi->brush->gpencil_settings->curve_jitter); + BKE_curvemapping_initialize(tgpi->brush->gpencil_settings->curve_jitter); } if (tgpi->brush->gpencil_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) { - curvemapping_initialize(tgpi->brush->gpencil_settings->curve_strength); + BKE_curvemapping_initialize(tgpi->brush->gpencil_settings->curve_strength); } /* get an array of depths, far depths are blended */ @@ -834,7 +834,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) /* normalize value to evaluate curve */ if (gset->flag & GP_SCULPT_SETT_FLAG_PRIMITIVE_CURVE) { float value = (float)i / (gps->totpoints - 1); - curve_pressure = curvemapping_evaluateF(gset->cur_primitive, 0, value); + curve_pressure = BKE_curvemapping_evaluateF(gset->cur_primitive, 0, value); pressure = curve_pressure; } @@ -844,7 +844,8 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) float jitter; if (brush->gpencil_settings->flag & GP_BRUSH_USE_JITTER_PRESSURE) { - jitter = curvemapping_evaluateF(brush->gpencil_settings->curve_jitter, 0, curve_pressure); + jitter = BKE_curvemapping_evaluateF( + brush->gpencil_settings->curve_jitter, 0, curve_pressure); jitter *= brush->gpencil_settings->draw_sensitivity; } else { @@ -890,7 +891,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) /* color strength */ if (brush->gpencil_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) { - float curvef = curvemapping_evaluateF( + float curvef = BKE_curvemapping_evaluateF( brush->gpencil_settings->curve_strength, 0, curve_pressure); strength *= curvef * brush->gpencil_settings->draw_sensitivity; strength *= brush->gpencil_settings->draw_strength; diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index a475e43755c..2a0f16a4bbf 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -1396,13 +1396,13 @@ void ED_gpencil_add_defaults(bContext *C, Object *ob) /* ensure multiframe falloff curve */ if (ts->gp_sculpt.cur_falloff == NULL) { - ts->gp_sculpt.cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + ts->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff; - curvemapping_initialize(gp_falloff_curve); - curvemap_reset(gp_falloff_curve->cm, - &gp_falloff_curve->clipr, - CURVE_PRESET_GAUSS, - CURVEMAP_SLOPE_POSITIVE); + BKE_curvemapping_initialize(gp_falloff_curve); + BKE_curvemap_reset(gp_falloff_curve->cm, + &gp_falloff_curve->clipr, + CURVE_PRESET_GAUSS, + CURVEMAP_SLOPE_POSITIVE); } } diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 204011fe46a..6af74332dc5 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -465,7 +465,6 @@ int ED_view3d_backbuf_sample_size_clamp(struct ARegion *ar, const float dist); void ED_view3d_select_id_validate(struct ViewContext *vc); -uint *ED_view3d_select_id_read(int xmin, int ymin, int xmax, int ymax, uint *r_buf_len); uint *ED_view3d_select_id_read_rect(const struct rcti *rect, uint *r_buf_len); bool ED_view3d_autodist(struct Depsgraph *depsgraph, diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h index 1f15fa3bd4d..db8afccbe2d 100644 --- a/source/blender/editors/include/UI_interface_icons.h +++ b/source/blender/editors/include/UI_interface_icons.h @@ -75,7 +75,7 @@ void UI_icon_draw_ex(float x, float aspect, float alpha, float desaturate, - const char mono_color[4], + const uchar mono_color[4], const bool mono_border); void UI_icon_draw_desaturate(float x, diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 6a36bf364a3..76630de96db 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1736,7 +1736,7 @@ void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rec /* backdrop */ UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_3ubAlpha( - true, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f, (uchar *)wcol->inner, 255); + true, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f, wcol->inner, 255); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); @@ -1771,7 +1771,7 @@ void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rec GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor3ubv((uchar *)wcol->inner); + immUniformColor3ubv(wcol->inner); GPU_blend(true); GPU_line_smooth(true); @@ -1831,7 +1831,7 @@ static void gl_shaded_color_get_fl(const uchar *color, int shade, float r_color[ rgb_uchar_to_float(r_color, color_shaded); } -static void gl_shaded_color(uchar *color, int shade) +static void gl_shaded_color(const uchar *color, int shade) { uchar color_shaded[3]; gl_shaded_color_get(color, shade, color_shaded); @@ -1914,10 +1914,10 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons } else { if (cumap->flag & CUMA_DO_CLIP) { - gl_shaded_color_get_fl((uchar *)wcol->inner, -20, color_backdrop); + gl_shaded_color_get_fl(wcol->inner, -20, color_backdrop); immUniformColor3fv(color_backdrop); immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); - immUniformColor3ubv((uchar *)wcol->inner); + immUniformColor3ubv(wcol->inner); immRectf(pos, rect->xmin + zoomx * (cumap->clipr.xmin - offsx), rect->ymin + zoomy * (cumap->clipr.ymin - offsy), @@ -1925,19 +1925,19 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons rect->ymin + zoomy * (cumap->clipr.ymax - offsy)); } else { - rgb_uchar_to_float(color_backdrop, (const uchar *)wcol->inner); + rgb_uchar_to_float(color_backdrop, wcol->inner); immUniformColor3fv(color_backdrop); immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); } /* grid, every 0.25 step */ - gl_shaded_color((uchar *)wcol->inner, -16); + gl_shaded_color(wcol->inner, -16); ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 0.25f); /* grid, every 1.0 step */ - gl_shaded_color((uchar *)wcol->inner, -24); + gl_shaded_color(wcol->inner, -24); ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 1.0f); /* axes */ - gl_shaded_color((uchar *)wcol->inner, -50); + gl_shaded_color(wcol->inner, -50); immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, rect->xmin, rect->ymin + zoomy * (-offsy)); immVertex2f(pos, rect->xmax, rect->ymin + zoomy * (-offsy)); @@ -1997,7 +1997,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons immUnbindProgram(); if (cuma->table == NULL) { - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); } CurveMapPoint *cmp = cuma->table; @@ -2026,7 +2026,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons GPU_blend(true); /* Curve filled. */ - immUniformColor3ubvAlpha((uchar *)wcol->item, 128); + immUniformColor3ubvAlpha(wcol->item, 128); GPU_polygon_smooth(true); immBegin(GPU_PRIM_TRI_STRIP, (CM_TABLE * 2 + 2) + 4); immVertex2f(pos, line_range.xmin, rect->ymin); @@ -2044,7 +2044,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons /* Curve line. */ GPU_line_width(1.0f); - immUniformColor3ubvAlpha((uchar *)wcol->item, 255); + immUniformColor3ubvAlpha(wcol->item, 255); GPU_line_smooth(true); immBegin(GPU_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2); immVertex2f(pos, line_range.xmin, line_range.ymin); @@ -2099,7 +2099,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor3ubv((uchar *)wcol->outline); + immUniformColor3ubv(wcol->outline); imm_draw_box_wire_2d(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); immUnbindProgram(); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 245277c8d22..52933a89045 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2386,8 +2386,8 @@ static void ui_but_copy_curvemapping(uiBut *but) { if (but->poin != NULL) { but_copypaste_curve_alive = true; - curvemapping_free_data(&but_copypaste_curve); - curvemapping_copy_data(&but_copypaste_curve, (CurveMapping *)but->poin); + BKE_curvemapping_free_data(&but_copypaste_curve); + BKE_curvemapping_copy_data(&but_copypaste_curve, (CurveMapping *)but->poin); } } @@ -2399,8 +2399,8 @@ static void ui_but_paste_curvemapping(bContext *C, uiBut *but) } button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - curvemapping_free_data((CurveMapping *)but->poin); - curvemapping_copy_data((CurveMapping *)but->poin, &but_copypaste_curve); + BKE_curvemapping_free_data((CurveMapping *)but->poin); + BKE_curvemapping_copy_data((CurveMapping *)but->poin, &but_copypaste_curve); button_activate_state(C, but, BUTTON_STATE_EXIT); } } @@ -2588,7 +2588,7 @@ static void ui_but_paste(bContext *C, uiBut *but, uiHandleButtonData *data, cons void ui_but_clipboard_free(void) { - curvemapping_free_data(&but_copypaste_curve); + BKE_curvemapping_free_data(&but_copypaste_curve); } /** \} */ @@ -6479,7 +6479,7 @@ static bool ui_numedit_but_CURVE(uiBlock *block, } } - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); if (moved_point) { data->draglastx = evtx; @@ -6559,8 +6559,8 @@ static int ui_do_but_CURVE( float f_xy[2]; BLI_rctf_transform_pt_v(&cumap->curr, &but->rect, f_xy, m_xy); - curvemap_insert(cuma, f_xy[0], f_xy[1]); - curvemapping_changed(cumap, false); + BKE_curvemap_insert(cuma, f_xy[0], f_xy[1]); + BKE_curvemapping_changed(cumap, false); changed = true; } @@ -6597,8 +6597,8 @@ static int ui_do_but_CURVE( if (dist_squared_to_line_segment_v2(m_xy, f_xy_prev, f_xy) < dist_min_sq) { BLI_rctf_transform_pt_v(&cumap->curr, &but->rect, f_xy, m_xy); - curvemap_insert(cuma, f_xy[0], f_xy[1]); - curvemapping_changed(cumap, false); + BKE_curvemap_insert(cuma, f_xy[0], f_xy[1]); + BKE_curvemapping_changed(cumap, false); changed = true; @@ -6672,7 +6672,7 @@ static int ui_do_but_CURVE( } } else { - curvemapping_changed(cumap, true); /* remove doubles */ + BKE_curvemapping_changed(cumap, true); /* remove doubles */ BKE_paint_invalidate_cursor_overlay(scene, view_layer, cumap); } } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 7584a43a790..e9aa18394fa 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -403,7 +403,7 @@ static void vicon_handletype_auto_clamp_draw(int x, int y, int w, int h, float a static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNUSED(alpha)) { bTheme *btheme = UI_GetTheme(); - ThemeWireColor *cs = &btheme->tarm[index]; + const ThemeWireColor *cs = &btheme->tarm[index]; /* Draw three bands of color: One per color * x-----a-----b-----c @@ -420,15 +420,15 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU /* XXX: Include alpha into this... */ /* normal */ - immUniformColor3ubv((uchar *)cs->solid); + immUniformColor3ubv(cs->solid); immRecti(pos, x, y, a, y + h); /* selected */ - immUniformColor3ubv((uchar *)cs->select); + immUniformColor3ubv(cs->select); immRecti(pos, a, y, b, y + h); /* active */ - immUniformColor3ubv((uchar *)cs->active); + immUniformColor3ubv(cs->active); immRecti(pos, b, y, c, y + h); immUnbindProgram(); @@ -1782,7 +1782,7 @@ static void icon_draw_size(float x, enum eIconSizes size, int draw_size, const float desaturate, - const char mono_rgba[4], + const uchar mono_rgba[4], const bool mono_border) { bTheme *btheme = UI_GetTheme(); @@ -2270,7 +2270,7 @@ void UI_icon_draw_ex(float x, float aspect, float alpha, float desaturate, - const char mono_color[4], + const uchar mono_color[4], const bool mono_border) { int draw_size = get_draw_size(ICON_SIZE_ICON); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 215b0c3c410..8adb82a22c8 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -721,7 +721,7 @@ void ui_draw_aligned_panel(uiStyle *style, (block->aspect * U.inv_dpi_fac), 1.0f, 0.0f, - (const char *)col_title, + col_title, false); GPU_blend(false); } diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index f10702f3f3b..6aad9e41e7d 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -174,10 +174,10 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar) ui_draw_tooltip_background(UI_style_get(), NULL, &bbox); /* set background_color */ - rgb_uchar_to_float(background_color, (const uchar *)theme->inner); + rgb_uchar_to_float(background_color, theme->inner); /* calculate normal_color */ - rgb_uchar_to_float(main_color, (const uchar *)theme->text); + rgb_uchar_to_float(main_color, theme->text); copy_v3_v3(active_color, main_color); copy_v3_v3(normal_color, main_color); copy_v3_v3(python_color, main_color); @@ -396,11 +396,23 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is else { /* Note, this is an exceptional case, we could even remove it * however there have been reports of tooltips failing, so keep it for now. */ - expr_result = BLI_strdup("Internal error!"); + expr_result = BLI_strdup(IFACE_("Internal error!")); is_error = true; } if (expr_result != NULL) { + /* NOTE: This is a very weak hack to get a valid translation most of the time... + * Proper way to do would be to get i18n context from the item, somehow. */ + const char *label_str = CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, expr_result); + if (label_str == expr_result) { + label_str = IFACE_(expr_result); + } + + if (label_str != expr_result) { + MEM_freeN(expr_result); + expr_result = BLI_strdup(label_str); + } + uiTooltipField *field = text_field_add(data, &(uiTooltipFormat){ .style = UI_TIP_STYLE_NORMAL, @@ -437,7 +449,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is else { /* Note, this is an exceptional case, we could even remove it * however there have been reports of tooltips failing, so keep it for now. */ - expr_result = BLI_strdup("Internal error!"); + expr_result = BLI_strdup(TIP_("Internal error!")); is_error = true; } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index fb8c2f59748..37eb1770f68 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -3723,15 +3723,15 @@ static void curvemap_buttons_setclip(bContext *UNUSED(C), void *cumap_v, void *U { CurveMapping *cumap = cumap_v; - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); } static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v) { CurveMapping *cumap = cumap_v; - curvemap_remove(cumap->cm + cumap->cur, SELECT); - curvemapping_changed(cumap, false); + BKE_curvemap_remove(cumap->cm + cumap->cur, SELECT); + BKE_curvemapping_changed(cumap, false); rna_update_cb(C, cb_v, NULL); } @@ -3829,7 +3829,7 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v) return block; } -/* only for curvemap_tools_dofunc */ +/* only for BKE_curvemap_tools_dofunc */ enum { UICURVE_FUNC_RESET_NEG, UICURVE_FUNC_RESET_POS, @@ -3849,35 +3849,35 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) switch (event) { case UICURVE_FUNC_RESET_NEG: case UICURVE_FUNC_RESET_POS: /* reset */ - curvemap_reset(cuma, - &cumap->clipr, - cumap->preset, - (event == UICURVE_FUNC_RESET_NEG) ? CURVEMAP_SLOPE_NEGATIVE : - CURVEMAP_SLOPE_POSITIVE); - curvemapping_changed(cumap, false); + BKE_curvemap_reset(cuma, + &cumap->clipr, + cumap->preset, + (event == UICURVE_FUNC_RESET_NEG) ? CURVEMAP_SLOPE_NEGATIVE : + CURVEMAP_SLOPE_POSITIVE); + BKE_curvemapping_changed(cumap, false); break; case UICURVE_FUNC_RESET_VIEW: cumap->curr = cumap->clipr; break; case UICURVE_FUNC_HANDLE_VECTOR: /* set vector */ - curvemap_handle_set(cuma, HD_VECT); - curvemapping_changed(cumap, false); + BKE_curvemap_handle_set(cuma, HD_VECT); + BKE_curvemapping_changed(cumap, false); break; case UICURVE_FUNC_HANDLE_AUTO: /* set auto */ - curvemap_handle_set(cuma, HD_AUTO); - curvemapping_changed(cumap, false); + BKE_curvemap_handle_set(cuma, HD_AUTO); + BKE_curvemapping_changed(cumap, false); break; case UICURVE_FUNC_HANDLE_AUTO_ANIM: /* set auto-clamped */ - curvemap_handle_set(cuma, HD_AUTO_ANIM); - curvemapping_changed(cumap, false); + BKE_curvemap_handle_set(cuma, HD_AUTO_ANIM); + BKE_curvemapping_changed(cumap, false); break; case UICURVE_FUNC_EXTEND_HOZ: /* extend horiz */ cuma->flag &= ~CUMA_EXTEND_EXTRAPOLATE; - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); break; case UICURVE_FUNC_EXTEND_EXP: /* extend extrapolate */ cuma->flag |= CUMA_EXTEND_EXTRAPOLATE; - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); break; } ED_undo_push(C, "CurveMap tools"); @@ -4041,7 +4041,7 @@ static void curvemap_buttons_redraw(bContext *C, void *UNUSED(arg1), void *UNUSE static void curvemap_buttons_update(bContext *C, void *arg1_v, void *cumap_v) { CurveMapping *cumap = cumap_v; - curvemapping_changed(cumap, true); + BKE_curvemapping_changed(cumap, true); rna_update_cb(C, arg1_v, NULL); } @@ -4052,14 +4052,14 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v) cumap->preset = CURVE_PRESET_LINE; for (a = 0; a < CM_TOT; a++) { - curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); + BKE_curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); } cumap->black[0] = cumap->black[1] = cumap->black[2] = 0.0f; cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f; - curvemapping_set_black_white(cumap, NULL, NULL); + BKE_curvemapping_set_black_white(cumap, NULL, NULL); - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); rna_update_cb(C, cb_v, NULL); } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 55ec10b03dc..9c4d628cec5 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1135,7 +1135,7 @@ static void shape_preset_trias_from_rect_checkmark(uiWidgetTrias *tria, const rc /* prepares shade colors */ static void shadecolors4( - char coltop[4], char coldown[4], const char *color, short shadetop, short shadedown) + uchar coltop[4], uchar coldown[4], const uchar *color, short shadetop, short shadedown) { coltop[0] = CLAMPIS(color[0] + shadetop, 0, 255); coltop[1] = CLAMPIS(color[1] + shadetop, 0, 255); @@ -1149,8 +1149,8 @@ static void shadecolors4( } static void round_box_shade_col4_r(uchar r_col[4], - const char col1[4], - const char col2[4], + const uchar col1[4], + const uchar col2[4], const float fac) { const int faci = unit_float_to_uchar_clamp(fac); @@ -1352,15 +1352,14 @@ static void widgetbase_draw_ex(uiWidgetBase *wtb, if (wtb->draw_inner) { if (wcol->shaded == 0) { /* simple fill */ - inner_col1[0] = inner_col2[0] = (uchar)wcol->inner[0]; - inner_col1[1] = inner_col2[1] = (uchar)wcol->inner[1]; - inner_col1[2] = inner_col2[2] = (uchar)wcol->inner[2]; - inner_col1[3] = inner_col2[3] = (uchar)wcol->inner[3]; + inner_col1[0] = inner_col2[0] = wcol->inner[0]; + inner_col1[1] = inner_col2[1] = wcol->inner[1]; + inner_col1[2] = inner_col2[2] = wcol->inner[2]; + inner_col1[3] = inner_col2[3] = wcol->inner[3]; } else { /* gradient fill */ - shadecolors4( - (char *)inner_col1, (char *)inner_col2, wcol->inner, wcol->shadetop, wcol->shadedown); + shadecolors4(inner_col1, inner_col2, wcol->inner, wcol->shadetop, wcol->shadedown); } } @@ -1436,7 +1435,7 @@ static int ui_but_draw_menu_icon(const uiBut *but) /* icons have been standardized... and this call draws in untransformed coordinates */ static void widget_draw_icon( - const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, const char mono_color[4]) + const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, const uchar mono_color[4]) { float xs = 0.0f, ys = 0.0f; float aspect, height; @@ -1510,8 +1509,8 @@ static void widget_draw_icon( } /* Get theme color. */ - char color[4] = {mono_color[0], mono_color[1], mono_color[2], mono_color[3]}; - bool has_theme = UI_icon_get_theme_color(icon, (uchar *)color); + uchar color[4] = {mono_color[0], mono_color[1], mono_color[2], mono_color[3]}; + bool has_theme = UI_icon_get_theme_color(icon, color); /* to indicate draggable */ if (but->dragpoin && (but->flag & UI_ACTIVE)) { @@ -1548,7 +1547,7 @@ static void widget_draw_submenu_tria(const uiBut *but, float col[4]; rctf tria_rect; - rgba_uchar_to_float(col, (const uchar *)wcol->text); + rgba_uchar_to_float(col, wcol->text); col[3] *= 0.8f; BLI_rctf_init(&tria_rect, xs, xs + tria_width, ys, ys + tria_height); @@ -2099,7 +2098,7 @@ static void widget_draw_text(const uiFontStyle *fstyle, immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor4ubv((uchar *)wcol->item); + immUniformColor4ubv(wcol->item); immRecti(pos, rect->xmin + selsta_draw, rect->ymin + 2, @@ -2214,7 +2213,7 @@ static void widget_draw_text(const uiFontStyle *fstyle, UI_fontstyle_draw_ex(fstyle, rect, drawstr + but->ofs, - (uchar *)wcol->text, + wcol->text, &(struct uiFontStyleDraw_Params){ .align = align, }, @@ -2250,7 +2249,7 @@ static void widget_draw_text(const uiFontStyle *fstyle, rect->xmin + font_xofs + ul_advance, rect->ymin + font_yofs, 0.0f); - BLF_color4ubv(fstyle->uifont_id, (uchar *)wcol->text); + BLF_color4ubv(fstyle->uifont_id, wcol->text); BLF_draw(fstyle->uifont_id, "_", 2); if (fstyle->kerning == 1) { @@ -2263,8 +2262,8 @@ static void widget_draw_text(const uiFontStyle *fstyle, /* part text right aligned */ if (drawstr_right) { - char col[4]; - copy_v4_v4_char(col, wcol->text); + uchar col[4]; + copy_v4_v4_uchar(col, wcol->text); if (but->drawflag & UI_BUT_HAS_SHORTCUT) { col[3] *= 0.5f; } @@ -2273,7 +2272,7 @@ static void widget_draw_text(const uiFontStyle *fstyle, UI_fontstyle_draw(fstyle, rect, drawstr_right, - (const uchar *)col, + col, &(struct uiFontStyleDraw_Params){ .align = UI_STYLE_TEXT_RIGHT, }); @@ -2476,7 +2475,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, /* ************ button callbacks, state ***************** */ -static void widget_state_blend(char cp[3], const char cpstate[3], const float fac) +static void widget_state_blend(uchar cp[3], const uchar cpstate[3], const float fac) { if (fac != 0.0f) { cp[0] = (int)((1.0f - fac) * cp[0] + fac * cpstate[0]); @@ -2502,18 +2501,18 @@ static void ui_widget_color_disabled(uiWidgetType *wt) wt->wcol_theme = &wcol_theme_s; } -static void rgb_tint(char cp[3], int tint) +static void rgb_tint(uchar cp[3], int tint) { cp[0] = clamp_i(cp[0] + tint, 0, 255); cp[1] = clamp_i(cp[1] + tint, 0, 255); cp[2] = clamp_i(cp[2] + tint, 0, 255); } -static void rgb_ensure_contrast(char cp[3], const char cp_other[3], int contrast) +static void rgb_ensure_contrast(uchar cp[3], const uchar cp_other[3], int contrast) { BLI_assert(contrast > 0); - const int item_value = rgb_to_grayscale_byte((const uchar *)cp); - const int inner_value = rgb_to_grayscale_byte((const uchar *)cp_other); + const int item_value = rgb_to_grayscale_byte(cp); + const int inner_value = rgb_to_grayscale_byte(cp_other); const int delta = item_value - inner_value; if (delta >= 0) { if (contrast > delta) { @@ -2527,16 +2526,16 @@ static void rgb_ensure_contrast(char cp[3], const char cp_other[3], int contrast } } -static void widget_active_color(char cp[3]) +static void widget_active_color(uchar cp[3]) { cp[0] = cp[0] >= 240 ? 255 : cp[0] + 15; cp[1] = cp[1] >= 240 ? 255 : cp[1] + 15; cp[2] = cp[2] >= 240 ? 255 : cp[2] + 15; } -static const char *widget_color_blend_from_flags(const uiWidgetStateColors *wcol_state, - int state, - int drawflag) +static const uchar *widget_color_blend_from_flags(const uiWidgetStateColors *wcol_state, + int state, + int drawflag) { if (drawflag & UI_BUT_ANIMATED_CHANGED) { return wcol_state->inner_changed_sel; @@ -2573,15 +2572,15 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) wt->wcol = *(wt->wcol_theme); - const char *color_blend = widget_color_blend_from_flags(wcol_state, state, drawflag); + const uchar *color_blend = widget_color_blend_from_flags(wcol_state, state, drawflag); if (state & UI_SELECT) { - copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); if (color_blend != NULL) { widget_state_blend(wt->wcol.inner, color_blend, wcol_state->blend); } - copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); + copy_v3_v3_uchar(wt->wcol.text, wt->wcol.text_sel); if (state & UI_SELECT) { SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown); @@ -2598,7 +2597,7 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) } if (state & UI_BUT_REDALERT) { - char red[4] = {255, 0, 0}; + uchar red[4] = {255, 0, 0}; if (wt->draw) { widget_state_blend(wt->wcol.inner, red, 0.4f); } @@ -2609,13 +2608,13 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) if (state & UI_BUT_DRAG_MULTI) { /* the button isn't SELECT but we're editing this so draw with sel color */ - copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown); widget_state_blend(wt->wcol.text, wt->wcol.text_sel, 0.85f); } if (state & UI_BUT_NODE_ACTIVE) { - char blue[4] = {86, 128, 194}; + uchar blue[4] = {86, 128, 194}; widget_state_blend(wt->wcol.inner, blue, 0.3f); } } @@ -2628,13 +2627,12 @@ static void widget_state_numslider(uiWidgetType *wt, int state, int drawflag) /* call this for option button */ widget_state(wt, state, drawflag); - const char *color_blend = widget_color_blend_from_flags(wcol_state, state, drawflag); + const uchar *color_blend = widget_color_blend_from_flags(wcol_state, state, drawflag); if (color_blend != NULL) { /* Set the slider 'item' so that it reflects state settings too. * De-saturate so the color of the slider doesn't conflict with the blend color, * which can make the color hard to see when the slider is set to full (see T66102). */ - wt->wcol.item[0] = wt->wcol.item[1] = wt->wcol.item[2] = rgb_to_grayscale_byte( - (const uchar *)wt->wcol.item); + wt->wcol.item[0] = wt->wcol.item[1] = wt->wcol.item[2] = rgb_to_grayscale_byte(wt->wcol.item); widget_state_blend(wt->wcol.item, color_blend, wcol_state->blend); rgb_ensure_contrast(wt->wcol.item, wt->wcol.inner, 30); } @@ -2654,10 +2652,10 @@ static void widget_state_option_menu(uiWidgetType *wt, int state, int drawflag) /* if not selected we get theme from menu back */ if (state & UI_SELECT) { - copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text_sel); + copy_v3_v3_uchar(wt->wcol.text, btheme->tui.wcol_menu_back.text_sel); } else { - copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text); + copy_v3_v3_uchar(wt->wcol.text, btheme->tui.wcol_menu_back.text); } } @@ -2682,13 +2680,13 @@ static void widget_state_pie_menu_item(uiWidgetType *wt, int state, int UNUSED(d widget_state_blend(wt->wcol.text, wt->wcol.text_sel, 0.5f); /* draw the backdrop at low alpha, helps navigating with keys * when disabled items are active */ - copy_v4_v4_char(wt->wcol.inner, wt->wcol.item); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.item); wt->wcol.inner[3] = 64; } else { /* regular active */ if (state & (UI_SELECT | UI_ACTIVE)) { - copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); + copy_v3_v3_uchar(wt->wcol.text, wt->wcol.text_sel); } else if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { /* regular disabled */ @@ -2696,10 +2694,10 @@ static void widget_state_pie_menu_item(uiWidgetType *wt, int state, int UNUSED(d } if (state & UI_SELECT) { - copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); } else if (state & UI_ACTIVE) { - copy_v4_v4_char(wt->wcol.inner, wt->wcol.item); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.item); } } } @@ -2714,13 +2712,13 @@ static void widget_state_menu_item(uiWidgetType *wt, int state, int UNUSED(drawf widget_state_blend(wt->wcol.text, wt->wcol.text_sel, 0.5f); /* draw the backdrop at low alpha, helps navigating with keys * when disabled items are active */ - copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); wt->wcol.inner[3] = 64; } else { /* regular active */ if (state & UI_ACTIVE) { - copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); + copy_v3_v3_uchar(wt->wcol.text, wt->wcol.text_sel); } else if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { /* regular disabled */ @@ -2728,7 +2726,7 @@ static void widget_state_menu_item(uiWidgetType *wt, int state, int UNUSED(drawf } if (state & UI_ACTIVE) { - copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); } } } @@ -2965,7 +2963,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const GPU_blend(true); GPU_line_smooth(true); - immUniformColor3ubv((uchar *)wcol->outline); + immUniformColor3ubv(wcol->outline); imm_draw_circle_wire_2d(pos, centx, centy, radius, tot); immUnbindProgram(); @@ -3347,7 +3345,7 @@ static void widget_numbut_draw( wtb_zone.draw_emboss = false; wcol_zone = *wcol; - copy_v3_v3_char(wcol_zone.item, wcol->text); + copy_v3_v3_uchar(wcol_zone.item, wcol->text); if (state & UI_STATE_ACTIVE_LEFT) { widget_active_color(wcol_zone.inner); } @@ -3367,7 +3365,7 @@ static void widget_numbut_draw( wtb_zone.tria1.type = ROUNDBOX_TRIA_ARROWS; wcol_zone = *wcol; - copy_v3_v3_char(wcol_zone.item, wcol->text); + copy_v3_v3_uchar(wcol_zone.item, wcol->text); if (state & UI_STATE_ACTIVE_RIGHT) { widget_active_color(wcol_zone.inner); } @@ -3386,7 +3384,7 @@ static void widget_numbut_draw( wtb_zone.draw_emboss = false; wcol_zone = *wcol; - copy_v3_v3_char(wcol_zone.item, wcol->text); + copy_v3_v3_uchar(wcol_zone.item, wcol->text); if (!(state & (UI_STATE_ACTIVE_LEFT | UI_STATE_ACTIVE_RIGHT))) { widget_active_color(wcol_zone.inner); } @@ -3466,7 +3464,7 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s else { SWAP(short, wcol->shadetop, wcol->shadedown); - copy_v4_v4_char(wcol->inner, wcol->item); + copy_v4_v4_uchar(wcol->inner, wcol->item); if (wcol->shadetop > wcol->shadedown) { wcol->shadetop += 20; /* XXX violates themes... */ @@ -3613,7 +3611,7 @@ static void widget_progressbar( widgetbase_draw(&wtb, wcol); /* "slider" bar color */ - copy_v3_v3_char(wcol->inner, wcol->item); + copy_v3_v3_uchar(wcol->inner, wcol->item); widgetbase_draw(&wtb_bar, wcol); /* raise text a bit */ @@ -3626,12 +3624,12 @@ static void widget_nodesocket( { uiWidgetBase wtb; int radi = 5; - char old_inner[3], old_outline[3]; + uchar old_inner[3], old_outline[3]; widget_init(&wtb); - copy_v3_v3_char(old_inner, wcol->inner); - copy_v3_v3_char(old_outline, wcol->outline); + copy_v3_v3_uchar(old_inner, wcol->inner); + copy_v3_v3_uchar(old_outline, wcol->outline); wcol->inner[0] = but->col[0]; wcol->inner[1] = but->col[1]; @@ -3652,8 +3650,8 @@ static void widget_nodesocket( round_box_edges(&wtb, UI_CNR_ALL, rect, (float)radi); widgetbase_draw(&wtb, wcol); - copy_v3_v3_char(wcol->inner, old_inner); - copy_v3_v3_char(wcol->outline, old_outline); + copy_v3_v3_uchar(wcol->inner, old_inner); + copy_v3_v3_uchar(wcol->outline, old_outline); } static void widget_numslider( @@ -3662,7 +3660,7 @@ static void widget_numslider( uiWidgetBase wtb, wtb1; rcti rect1; float offs, toffs; - char outline[3]; + uchar outline[3]; widget_init(&wtb); widget_init(&wtb1); @@ -3679,9 +3677,9 @@ static void widget_numslider( if (!(state & UI_STATE_TEXT_INPUT)) { int roundboxalign_slider = roundboxalign; - copy_v3_v3_char(outline, wcol->outline); - copy_v3_v3_char(wcol->outline, wcol->item); - copy_v3_v3_char(wcol->inner, wcol->item); + copy_v3_v3_uchar(outline, wcol->outline); + copy_v3_v3_uchar(wcol->outline, wcol->item); + copy_v3_v3_uchar(wcol->inner, wcol->item); if (!(state & UI_SELECT)) { SWAP(short, wcol->shadetop, wcol->shadedown); @@ -3723,7 +3721,7 @@ static void widget_numslider( widgetbase_set_uniform_discard_factor(&wtb1, factor_discard); widgetbase_draw(&wtb1, wcol); - copy_v3_v3_char(wcol->outline, outline); + copy_v3_v3_uchar(wcol->outline, outline); if (!(state & UI_SELECT)) { SWAP(short, wcol->shadetop, wcol->shadedown); @@ -3788,7 +3786,7 @@ static void widget_swatch( ui_block_cm_to_display_space_v3(but->block, col); } - rgba_float_to_uchar((uchar *)wcol->inner, col); + rgba_float_to_uchar(wcol->inner, col); const bool show_alpha_checkers = (wcol->inner[3] < 255); wcol->shaded = 0; @@ -3923,9 +3921,9 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int const float rad = wcol->roundness * U.widget_unit; if (state & UI_ACTIVE) { - copy_v4_v4_char(wcol->inner, wcol->inner_sel); - copy_v3_v3_char(wcol->text, wcol->text_sel); - copy_v3_v3_char(wcol->outline, wcol->inner); + copy_v4_v4_uchar(wcol->inner, wcol->inner_sel); + copy_v3_v3_uchar(wcol->text, wcol->text_sel); + copy_v3_v3_uchar(wcol->outline, wcol->inner); } else { wcol->inner[3] *= 1.0f - back[3]; @@ -4061,15 +4059,15 @@ static void widget_state_label(uiWidgetType *wt, int state, int drawflag) /* call this for option button */ widget_state(wt, state, drawflag); if (state & UI_SELECT) { - UI_GetThemeColor3ubv(TH_TEXT_HI, (uchar *)wt->wcol.text); + UI_GetThemeColor3ubv(TH_TEXT_HI, wt->wcol.text); } else { - UI_GetThemeColor3ubv(TH_TEXT, (uchar *)wt->wcol.text); + UI_GetThemeColor3ubv(TH_TEXT, wt->wcol.text); } } if (state & UI_BUT_REDALERT) { - char red[4] = {255, 0, 0}; + uchar red[4] = {255, 0, 0}; widget_state_blend(wt->wcol.text, red, 0.4f); } } @@ -4092,11 +4090,11 @@ static void widget_box( { uiWidgetBase wtb; float rad; - char old_col[3]; + uchar old_col[3]; widget_init(&wtb); - copy_v3_v3_char(old_col, wcol->inner); + copy_v3_v3_uchar(old_col, wcol->inner); /* abuse but->hsv - if it's non-zero, use this color as the box's background */ if (but->col[3]) { @@ -4111,7 +4109,7 @@ static void widget_box( widgetbase_draw(&wtb, wcol); - copy_v3_v3_char(wcol->inner, old_col); + copy_v3_v3_uchar(wcol->inner, old_col); } static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) @@ -4175,12 +4173,10 @@ static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundbox #ifdef USE_TAB_SHADED_HIGHLIGHT /* create outline highlight colors */ if (is_active) { - interp_v3_v3v3_uchar( - theme_col_tab_highlight, (uchar *)wcol->inner_sel, (uchar *)wcol->outline, 0.2f); + interp_v3_v3v3_uchar(theme_col_tab_highlight, wcol->inner_sel, wcol->outline, 0.2f); } else { - interp_v3_v3v3_uchar( - theme_col_tab_highlight, (uchar *)wcol->inner, (uchar *)wcol->outline, 0.12f); + interp_v3_v3v3_uchar(theme_col_tab_highlight, wcol->inner, wcol->outline, 0.12f); } #endif @@ -4202,7 +4198,7 @@ static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundbox #ifdef USE_TAB_SHADED_HIGHLIGHT /* draw outline (3d look) */ - ui_draw_but_TAB_outline(rect, rad, theme_col_tab_highlight, (uchar *)wcol->inner); + ui_draw_but_TAB_outline(rect, rad, theme_col_tab_highlight, wcol->inner); #endif #ifndef USE_TAB_SHADED_HIGHLIGHT @@ -4819,7 +4815,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct uiWidgetType wt_back = *wt; uiWidgetType *wt_temp = widget_type(UI_WTYPE_MENU_ITEM); wt_temp->state(wt_temp, state, drawflag); - copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); wt->wcol.inner[3] = 128; wt->wcol.roundness = 0.5f; ui_draw_roundbox(&rect_orig, @@ -4845,7 +4841,7 @@ static void ui_draw_clip_tri(uiBlock *block, rcti *rect, uiWidgetType *wt) { if (block) { float draw_color[4]; - uchar *color = (uchar *)wt->wcol.text; + const uchar *color = wt->wcol.text; draw_color[0] = ((float)color[0]) / 255.0f; draw_color[1] = ((float)color[1]) / 255.0f; @@ -4913,7 +4909,7 @@ static void ui_draw_popover_back_impl(const uiWidgetColors *wcol, if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) { uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor4ubv((uchar *)wcol->inner); + immUniformColor4ubv(wcol->inner); GPU_blend(true); immBegin(GPU_PRIM_TRIS, 3); if (direction == UI_DIR_DOWN) { @@ -4958,8 +4954,8 @@ static void draw_disk_shaded(float start, float radius_int, float radius_ext, int subd, - const char col1[4], - const char col2[4], + const uchar col1[4], + const uchar col2[4], bool shaded) { const float radius_ext_scale = (0.5f / radius_ext); /* 1 / (2 * radius_ext) */ @@ -4979,7 +4975,7 @@ static void draw_disk_shaded(float start, } else { immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor4ubv((uchar *)col1); + immUniformColor4ubv(col1); } immBegin(GPU_PRIM_TRI_STRIP, subd * 2); @@ -5032,7 +5028,7 @@ void ui_draw_pie_center(uiBlock *block) GPU_blend(true); if (btheme->tui.wcol_pie_menu.shaded) { - char col1[4], col2[4]; + uchar col1[4], col2[4]; shadecolors4(col1, col2, btheme->tui.wcol_pie_menu.inner, @@ -5060,7 +5056,7 @@ void ui_draw_pie_center(uiBlock *block) if (!(block->pie_data.flags & UI_PIE_INVALID_DIR)) { if (btheme->tui.wcol_pie_menu.shaded) { - char col1[4], col2[4]; + uchar col1[4], col2[4]; shadecolors4(col1, col2, btheme->tui.wcol_pie_menu.inner_sel, @@ -5090,7 +5086,7 @@ void ui_draw_pie_center(uiBlock *block) GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor4ubv((uchar *)btheme->tui.wcol_pie_menu.outline); + immUniformColor4ubv(btheme->tui.wcol_pie_menu.outline); imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, pie_radius_internal, subd); imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, pie_radius_external, subd); @@ -5102,7 +5098,7 @@ void ui_draw_pie_center(uiBlock *block) float pie_confirm_radius = U.dpi_fac * (pie_radius_internal + U.pie_menu_confirm); float pie_confirm_external = U.dpi_fac * (pie_radius_internal + U.pie_menu_confirm + 7.0f); - const char col[4] = {UNPACK3(btheme->tui.wcol_pie_menu.text_sel), 64}; + const uchar col[4] = {UNPACK3(btheme->tui.wcol_pie_menu.text_sel), 64}; draw_disk_shaded(angle - range / 2.0f, range, pie_confirm_radius, @@ -5144,7 +5140,7 @@ static void ui_draw_widget_back_color(uiWidgetTypeEnum type, rcti rect_copy = *rect; wt->state(wt, 0, 0); if (color) { - rgba_float_to_uchar((uchar *)wt->wcol.inner, color); + rgba_float_to_uchar(wt->wcol.inner, color); } wt->draw(&wt->wcol, &rect_copy, 0, UI_CNR_ALL); } @@ -5222,7 +5218,7 @@ void ui_draw_menu_item( UI_fontstyle_draw(fstyle, rect, drawstr, - (uchar *)wt->wcol.text, + wt->wcol.text, &(struct uiFontStyleDraw_Params){ .align = UI_STYLE_TEXT_LEFT, }); @@ -5235,7 +5231,7 @@ void ui_draw_menu_item( UI_fontstyle_draw(fstyle, rect, cpoin + 1, - (uchar *)wt->wcol.text, + wt->wcol.text, &(struct uiFontStyleDraw_Params){ .align = UI_STYLE_TEXT_RIGHT, }); @@ -5303,7 +5299,7 @@ void ui_draw_preview_item( UI_fontstyle_draw(fstyle, &trect, drawstr, - (uchar *)wt->wcol.text, + wt->wcol.text, &(struct uiFontStyleDraw_Params){ .align = UI_STYLE_TEXT_CENTER, }); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 7db872b46b7..98a6b8fb6c4 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -83,12 +83,12 @@ void ui_resources_free(void) const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) { ThemeSpace *ts = NULL; - static char error[4] = {240, 0, 240, 255}; - static char alert[4] = {240, 60, 60, 255}; - static char headerdesel[4] = {0, 0, 0, 255}; - static char back[4] = {0, 0, 0, 255}; - static char setting = 0; - const char *cp = error; + static uchar error[4] = {240, 0, 240, 255}; + static uchar alert[4] = {240, 60, 60, 255}; + static uchar headerdesel[4] = {0, 0, 0, 255}; + static uchar back[4] = {0, 0, 0, 255}; + static uchar setting = 0; + const uchar *cp = error; /* ensure we're not getting a color after running BKE_blender_userdef_free */ BLI_assert(BLI_findindex(&U.themes, theme_active) != -1); @@ -186,7 +186,7 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) cp = ts->button; } - copy_v4_v4_char(back, cp); + copy_v4_v4_uchar(back, cp); if (!ED_region_is_overlap(spacetype, theme_regionid)) { back[3] = 255; } @@ -903,7 +903,7 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) break; case TH_ICON_FUND: { /* Development fund icon color is not part of theme. */ - static const char red[4] = {204, 48, 72, 255}; + static const uchar red[4] = {204, 48, 72, 255}; cp = red; break; } diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index 79aafc6978f..0a5db782892 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -495,12 +495,16 @@ static int data_transfer_exec(bContext *C, wmOperator *op) NULL, false, op->reports)) { + + if (data_type == DT_TYPE_LNOR && use_create) { + ((Mesh *)ob_dst->data)->flag |= ME_AUTOSMOOTH; + } + + DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY); changed = true; } } - DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY); - if (reverse_transfer) { SWAP(Object *, ob_src, ob_dst); } diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index acd7126e56a..55a71ee8989 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -1177,9 +1177,9 @@ static int render_shutter_curve_preset_exec(bContext *C, wmOperator *op) cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; mblur_shutter_curve->preset = preset; - curvemap_reset( + BKE_curvemap_reset( cm, &mblur_shutter_curve->clipr, mblur_shutter_curve->preset, CURVEMAP_SLOPE_POS_NEG); - curvemapping_changed(mblur_shutter_curve, false); + BKE_curvemapping_changed(mblur_shutter_curve, false); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 9b380ad5db1..b6601807443 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -723,35 +723,33 @@ static void shader_preview_updatejob(void *spv) { ShaderPreview *sp = spv; - if (sp->id) { - if (sp->pr_method == PR_NODE_RENDER) { - if (GS(sp->id->name) == ID_MA) { - Material *mat = (Material *)sp->id; + if (sp->pr_method == PR_NODE_RENDER) { + if (GS(sp->id->name) == ID_MA) { + Material *mat = (Material *)sp->id; - if (sp->matcopy && mat->nodetree && sp->matcopy->nodetree) { - ntreeLocalSync(sp->matcopy->nodetree, mat->nodetree); - } + if (sp->matcopy && mat->nodetree && sp->matcopy->nodetree) { + ntreeLocalSync(sp->matcopy->nodetree, mat->nodetree); } - else if (GS(sp->id->name) == ID_TE) { - Tex *tex = (Tex *)sp->id; + } + else if (GS(sp->id->name) == ID_TE) { + Tex *tex = (Tex *)sp->id; - if (sp->texcopy && tex->nodetree && sp->texcopy->nodetree) { - ntreeLocalSync(sp->texcopy->nodetree, tex->nodetree); - } + if (sp->texcopy && tex->nodetree && sp->texcopy->nodetree) { + ntreeLocalSync(sp->texcopy->nodetree, tex->nodetree); } - else if (GS(sp->id->name) == ID_WO) { - World *wrld = (World *)sp->id; + } + else if (GS(sp->id->name) == ID_WO) { + World *wrld = (World *)sp->id; - if (sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree) { - ntreeLocalSync(sp->worldcopy->nodetree, wrld->nodetree); - } + if (sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree) { + ntreeLocalSync(sp->worldcopy->nodetree, wrld->nodetree); } - else if (GS(sp->id->name) == ID_LA) { - Light *la = (Light *)sp->id; + } + else if (GS(sp->id->name) == ID_LA) { + Light *la = (Light *)sp->id; - if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree) { - ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree); - } + if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree) { + ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree); } } } @@ -946,57 +944,80 @@ static void shader_preview_startjob(void *customdata, short *stop, short *do_upd *do_update = true; } +static void preview_id_copy_free(ID *id) +{ + struct IDProperty *properties; + /* get rid of copied ID */ + properties = IDP_GetProperties(id, false); + if (properties) { + IDP_FreePropertyContent_ex(properties, false); + MEM_freeN(properties); + } + switch (GS(id->name)) { + case ID_MA: + BKE_material_free((Material *)id); + break; + case ID_TE: + BKE_texture_free((Tex *)id); + break; + case ID_LA: + BKE_light_free((Light *)id); + break; + case ID_WO: + BKE_world_free((World *)id); + break; + default: + BLI_assert(!"ID type preview not supported."); + break; + } + MEM_freeN(id); +} + static void shader_preview_free(void *customdata) { ShaderPreview *sp = customdata; Main *pr_main = sp->pr_main; + ID *main_id_copy = NULL; + ID *sub_id_copy = NULL; if (sp->matcopy) { - sp->id_copy = (ID *)sp->matcopy; + main_id_copy = (ID *)sp->matcopy; BLI_remlink(&pr_main->materials, sp->matcopy); } if (sp->texcopy) { - sp->id_copy = (ID *)sp->texcopy; + BLI_assert(main_id_copy == NULL); + main_id_copy = (ID *)sp->texcopy; BLI_remlink(&pr_main->textures, sp->texcopy); } if (sp->worldcopy) { - sp->id_copy = (ID *)sp->worldcopy; + /* worldcopy is also created for material with `Preview World` enabled */ + if (main_id_copy) { + sub_id_copy = (ID *)sp->worldcopy; + } + else { + main_id_copy = (ID *)sp->worldcopy; + } BLI_remlink(&pr_main->worlds, sp->worldcopy); } if (sp->lampcopy) { - sp->id_copy = (ID *)sp->lampcopy; + BLI_assert(main_id_copy == NULL); + main_id_copy = (ID *)sp->lampcopy; BLI_remlink(&pr_main->lights, sp->lampcopy); } - if (sp->id_copy) { + if (main_id_copy || sp->id_copy) { /* node previews */ shader_preview_updatejob(sp); } - if (sp->id_copy && sp->own_id_copy) { - struct IDProperty *properties; - /* get rid of copied ID */ - properties = IDP_GetProperties(sp->id_copy, false); - if (properties) { - IDP_FreePropertyContent_ex(properties, false); - MEM_freeN(properties); + if (sp->own_id_copy) { + if (sp->id_copy) { + preview_id_copy_free(sp->id_copy); + } + if (main_id_copy) { + preview_id_copy_free(main_id_copy); } - switch (GS(sp->id_copy->name)) { - case ID_MA: - BKE_material_free((Material *)sp->id_copy); - break; - case ID_TE: - BKE_texture_free((Tex *)sp->id_copy); - break; - case ID_LA: - BKE_light_free((Light *)sp->id_copy); - break; - case ID_WO: - BKE_world_free((World *)sp->id_copy); - break; - default: - BLI_assert(!"ID type preview not supported."); - break; + if (sub_id_copy) { + preview_id_copy_free(sub_id_copy); } - MEM_freeN(sp->id_copy); } MEM_freeN(sp); @@ -1301,12 +1322,7 @@ static void icon_preview_free(void *customdata) IconPreview *ip = (IconPreview *)customdata; if (ip->id_copy) { - /* Feels a bit hacky just to reuse shader_preview_free() */ - ShaderPreview *sp = MEM_callocN(sizeof(ShaderPreview), "Icon ShaderPreview"); - sp->id_copy = ip->id_copy; - sp->own_id_copy = true; - shader_preview_free(sp); - ip->id_copy = NULL; + preview_id_copy_free(ip->id_copy); } BLI_freelistN(&ip->sizes); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 576baf5794b..65e10f98753 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -460,7 +460,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) } buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex"); - curvemapping_initialize(br->curve); + BKE_curvemapping_initialize(br->curve); LoadTexData data = { .br = br, diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index e5527e7210d..342d0b6e820 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -1695,7 +1695,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps, ca3 = ps->cavities[lt_vtri[2]]; ca_mask = w[0] * ca1 + w[1] * ca2 + w[2] * ca3; - ca_mask = curvemapping_evaluateF(ps->cavity_curve, 0, ca_mask); + ca_mask = BKE_curvemapping_evaluateF(ps->cavity_curve, 0, ca_mask); CLAMP(ca_mask, 0.0f, 1.0f); mask *= ca_mask; } @@ -5092,6 +5092,22 @@ static void image_paint_partial_redraw_expand(ImagePaintPartialRedraw *cell, cell->y2 = max_ii(cell->y2, (int)projPixel->y_px + 1); } +static void copy_original_alpha_channel(ProjPixel *pixel, bool is_floatbuf) +{ + /* Use the original alpha channel data instead of the modified one */ + if (is_floatbuf) { + /* slightly more involved case since floats are in premultiplied space we need + * to make sure alpha is consistent, see T44627 */ + float rgb_straight[4]; + premul_to_straight_v4_v4(rgb_straight, pixel->pixel.f_pt); + rgb_straight[3] = pixel->origColor.f_pt[3]; + straight_to_premul_v4_v4(pixel->pixel.f_pt, rgb_straight); + } + else { + pixel->pixel.ch_pt[3] = pixel->origColor.ch_pt[3]; + } +} + /* Run this for single and multi-threaded painting. */ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), void *ph_v, @@ -5263,17 +5279,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), } if (lock_alpha) { - if (is_floatbuf) { - /* slightly more involved case since floats are in premultiplied space we need - * to make sure alpha is consistent, see T44627 */ - float rgb_straight[4]; - premul_to_straight_v4_v4(rgb_straight, projPixel->pixel.f_pt); - rgb_straight[3] = projPixel->origColor.f_pt[3]; - straight_to_premul_v4_v4(projPixel->pixel.f_pt, rgb_straight); - } - else { - projPixel->pixel.ch_pt[3] = projPixel->origColor.ch_pt[3]; - } + copy_original_alpha_channel(projPixel, is_floatbuf); } last_partial_redraw_cell = last_projIma->partRedrawRect + projPixel->bb_cell_index; @@ -5478,17 +5484,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), } if (lock_alpha) { - if (is_floatbuf) { - /* slightly more involved case since floats are in premultiplied space we need - * to make sure alpha is consistent, see T44627 */ - float rgb_straight[4]; - premul_to_straight_v4_v4(rgb_straight, projPixel->pixel.f_pt); - rgb_straight[3] = projPixel->origColor.f_pt[3]; - straight_to_premul_v4_v4(projPixel->pixel.f_pt, rgb_straight); - } - else { - projPixel->pixel.ch_pt[3] = projPixel->origColor.ch_pt[3]; - } + copy_original_alpha_channel(projPixel, is_floatbuf); } } @@ -5504,11 +5500,17 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), for (node = smearPixels; node; node = node->next) { /* this wont run for a float image */ projPixel = node->link; *projPixel->pixel.uint_pt = ((ProjPixelClone *)projPixel)->clonepx.uint; + if (lock_alpha) { + copy_original_alpha_channel(projPixel, false); + } } for (node = smearPixels_f; node; node = node->next) { projPixel = node->link; copy_v4_v4(projPixel->pixel.f_pt, ((ProjPixelClone *)projPixel)->clonepx.f); + if (lock_alpha) { + copy_original_alpha_channel(projPixel, true); + } } BLI_memarena_free(smearArena); @@ -5518,11 +5520,17 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), for (node = softenPixels; node; node = node->next) { /* this wont run for a float image */ projPixel = node->link; *projPixel->pixel.uint_pt = projPixel->newColor.uint; + if (lock_alpha) { + copy_original_alpha_channel(projPixel, false); + } } for (node = softenPixels_f; node; node = node->next) { projPixel = node->link; copy_v4_v4(projPixel->pixel.f_pt, projPixel->newColor.f); + if (lock_alpha) { + copy_original_alpha_channel(projPixel, true); + } } BLI_memarena_free(softenArena); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index f073877ebcf..6144f5751f2 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -784,9 +784,9 @@ PaintStroke *paint_stroke_new(bContext *C, ups->average_stroke_counter = 0; /* initialize here to avoid initialization conflict with threaded strokes */ - curvemapping_initialize(br->curve); + BKE_curvemapping_initialize(br->curve); if (p->flags & PAINT_USE_CAVITY_MASK) { - curvemapping_initialize(p->cavity_curve); + BKE_curvemapping_initialize(p->cavity_curve); } BKE_paint_set_overlay_override(br->overlay_flags); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index 1dc28328244..72fc08cc38d 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -796,7 +796,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) VPaint *wp = ts->wpaint; struct Brush *brush = BKE_paint_brush(&wp->paint); - curvemapping_initialize(brush->curve); + BKE_curvemapping_initialize(brush->curve); data.brush = brush; data.weightpaint = BKE_brush_weight_get(scene, brush); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index eeda7a7aeaf..3567625819f 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2308,7 +2308,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) /* XXX - this shouldn't be necessary, but sculpting crashes in blender2.8 otherwise * initialize before threads so they can do curve mapping */ - curvemapping_initialize(brush->curve); + BKE_curvemapping_initialize(brush->curve); /* threaded loop over nodes */ SculptThreadedTaskData data = { @@ -4604,7 +4604,7 @@ static void sculpt_update_cache_invariants( brush = br; cache->saved_smooth_size = BKE_brush_size_get(scene, brush); BKE_brush_size_set(scene, brush, size); - curvemapping_initialize(brush->curve); + BKE_curvemapping_initialize(brush->curve); } } } diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 36cc3605273..91ed9057667 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -497,7 +497,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm op->customdata = data; - curvemapping_initialize(ts->uvsculpt->paint.brush->curve); + BKE_curvemapping_initialize(ts->uvsculpt->paint.brush->curve); if (data) { int counter = 0, i; diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 829a78b2bfa..ccd0a2bfd79 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -385,10 +385,10 @@ void ED_space_image_scopes_update(const struct bContext *C, } } - scopes_update(&sima->scopes, - ibuf, - use_view_settings ? &scene->view_settings : NULL, - &scene->display_settings); + BKE_scopes_update(&sima->scopes, + ibuf, + use_view_settings ? &scene->view_settings : NULL, + &scene->display_settings); } bool ED_space_image_show_render(SpaceImage *sima) diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 374a58d1808..1aa8c4c988b 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -3217,10 +3217,10 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event int point = RNA_enum_get(op->ptr, "point"); if (point == 1) { - curvemapping_set_black_white(curve_mapping, NULL, info->linearcol); + BKE_curvemapping_set_black_white(curve_mapping, NULL, info->linearcol); } else if (point == 0) { - curvemapping_set_black_white(curve_mapping, info->linearcol, NULL); + BKE_curvemapping_set_black_white(curve_mapping, info->linearcol, NULL); } WM_event_add_notifier(C, NC_WINDOW, NULL); } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 7ff075bf819..17f808f727d 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -131,7 +131,7 @@ static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sce BKE_imageuser_default(&simage->iuser); simage->iuser.flag = IMA_SHOW_STEREO | IMA_ANIM_ALWAYS; - scopes_new(&simage->scopes); + BKE_scopes_new(&simage->scopes); simage->sample_line_hist.height = 100; /* tool header */ @@ -179,7 +179,7 @@ static void image_free(SpaceLink *sl) { SpaceImage *simage = (SpaceImage *)sl; - scopes_free(&simage->scopes); + BKE_scopes_free(&simage->scopes); } /* spacetype; init callback, add handlers */ @@ -197,7 +197,7 @@ static SpaceLink *image_duplicate(SpaceLink *sl) /* clear or remove stuff from old */ - scopes_new(&simagen->scopes); + BKE_scopes_new(&simagen->scopes); return (SpaceLink *)simagen; } diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index 108803a865f..24d3008b1e7 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -35,8 +35,6 @@ #include "GPU_immediate.h" #include "GPU_state.h" -#include "BKE_text.h" - #include "textview.h" static void console_font_begin(const int font_id, const int lheight) @@ -78,8 +76,8 @@ static void console_draw_sel(const char *str, const unsigned char bg_sel[4]) { if (sel[0] <= str_len_draw && sel[1] >= 0) { - const int sta = txt_utf8_offset_to_column(str, max_ii(sel[0], 0)); - const int end = txt_utf8_offset_to_column(str, min_ii(sel[1], str_len_draw)); + const int sta = BLI_str_utf8_offset_to_column(str, max_ii(sel[0], 0)); + const int end = BLI_str_utf8_offset_to_column(str, min_ii(sel[1], str_len_draw)); GPU_blend(true); GPU_blend_set_func_separate( @@ -156,7 +154,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, } /* last part */ - ofs += txt_utf8_column_to_offset(str + ofs, (int)floor((float)cdc->mval[0] / cdc->cwidth)); + ofs += BLI_str_utf8_offset_from_column(str + ofs, + (int)floor((float)cdc->mval[0] / cdc->cwidth)); CLAMP(ofs, 0, str_len); *cdc->pos_pick += str_len - ofs; diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 8c36d4ae2bd..e4881a6f13d 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -2407,9 +2407,9 @@ static void tselem_draw_layer_collection_enable_icon( /* restrict column clip... it has been coded by simply overdrawing, * doesn't work for buttons */ - char color[4]; + uchar color[4]; int icon = RNA_property_ui_icon(exclude_prop); - if (UI_icon_get_theme_color(icon, (uchar *)color)) { + if (UI_icon_get_theme_color(icon, color)) { UI_icon_draw_ex(x, y, icon, U.inv_dpi_fac, alpha, 0.0f, color, true); } else { @@ -2467,8 +2467,8 @@ static void tselem_draw_icon(uiBlock *block, /* restrict column clip... it has been coded by simply overdrawing, * doesn't work for buttons */ - char color[4]; - if (UI_icon_get_theme_color(data.icon, (uchar *)color)) { + uchar color[4]; + if (UI_icon_get_theme_color(data.icon, color)) { UI_icon_draw_ex(x, y, data.icon, U.inv_dpi_fac, alpha, 0.0f, color, true); } else { diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index ea815bd5456..07350b5269e 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -2076,9 +2076,11 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) scene->r.cfra + scene->ed->over_ofs; uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); - immUniformColor3f(0.2f, 0.2f, 0.2f); + immUniform1f("dash_width", 20.0f * U.pixelsize); + immUniform1f("dash_factor", 0.5f); + immUniformThemeColor(TH_CFRAME); immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, cfra_over, v2d->cur.ymin); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index c03b804aa2c..9dc8dfa93b6 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -240,7 +240,7 @@ void wrap_offset( } max = wrap_width(st, ar); - cursin = txt_utf8_offset_to_column(linein->line, cursin); + cursin = BLI_str_utf8_offset_to_column(linein->line, cursin); while (linep) { start = 0; @@ -323,7 +323,7 @@ void wrap_offset_in_line( end = max; chop = 1; *offc = 0; - cursin = txt_utf8_offset_to_column(linein->line, cursin); + cursin = BLI_str_utf8_offset_to_column(linein->line, cursin); for (i = 0, j = 0; linein->line[j]; j += BLI_str_utf8_size_safe(linein->line + j)) { int columns = BLI_str_utf8_char_width_safe(linein->line + j); /* = 1 for tab */ @@ -1400,7 +1400,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi linep = startl; c = startc; - fc = txt_utf8_offset_to_index(linep->line, startc); + fc = BLI_str_utf8_offset_to_index(linep->line, startc); endl = NULL; endc = -1; find = -b; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 7c4a403d43d..a8af9c73bf2 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1827,7 +1827,7 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, const bool sel) if (j >= oldc) { if (ch == '\0') { - *charp = txt_utf8_column_to_offset((*linep)->line, start); + *charp = BLI_str_utf8_offset_from_column((*linep)->line, start); } loop = 0; break; @@ -1843,7 +1843,7 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, const bool sel) } else if (ch == ' ' || ch == '-' || ch == '\0') { if (j >= oldc) { - *charp = txt_utf8_column_to_offset((*linep)->line, start); + *charp = BLI_str_utf8_offset_from_column((*linep)->line, start); loop = 0; break; } diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 39cbc67f996..d16d90fae01 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -263,30 +263,6 @@ int ED_view3d_backbuf_sample_size_clamp(ARegion *ar, const float dist) return (int)min_ff(ceilf(dist), (float)max_ii(ar->winx, ar->winx)); } -/* reads full rect, converts indices */ -uint *ED_view3d_select_id_read(int xmin, int ymin, int xmax, int ymax, uint *r_buf_len) -{ - if (UNLIKELY((xmin > xmax) || (ymin > ymax))) { - return NULL; - } - - const rcti rect = { - .xmin = xmin, - .xmax = xmax + 1, - .ymin = ymin, - .ymax = ymax + 1, - }; - - uint buf_len; - uint *buf = ED_view3d_select_id_read_rect(&rect, &buf_len); - - if (r_buf_len) { - *r_buf_len = buf_len; - } - - return buf; -} - /* *********************** */ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 973c1c0b7f7..98203a7e316 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4607,6 +4607,10 @@ static void applyRotationValue(TransInfo *t, } axis_angle_normalized_to_mat3(mat, axis, angle); + /* Counter for needed updates (when we need to update to non-default matrix, + * we also need another update on next iteration to go back to default matrix, + * hence the '2' value used here, instead of a mere boolean). */ + short do_update_matrix = 0; FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; @@ -4623,6 +4627,9 @@ static void applyRotationValue(TransInfo *t, if (t->con.applyRot) { t->con.applyRot(t, tc, td, axis, NULL); angle_final = angle * td->factor; + /* Even though final angle might be identical to orig value, + * we have to update the rotation matrix in that case... */ + do_update_matrix = 2; } else if (t->flag & T_PROP_EDIT) { angle_final = angle * td->factor; @@ -4645,11 +4652,17 @@ static void applyRotationValue(TransInfo *t, axis_angle_normalized_to_mat3(mat, axis, angle_progress); ElementRotation(t, tc, td, mat, t->around); } - axis_angle_normalized_to_mat3(mat, axis, angle_final); + do_update_matrix = 2; } else if (angle_final != angle) { + do_update_matrix = 2; + } + + if (do_update_matrix > 0) { axis_angle_normalized_to_mat3(mat, axis, angle_final); + do_update_matrix--; } + ElementRotation(t, tc, td, mat, t->around); } } @@ -9449,7 +9462,7 @@ static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR]) } } -static void applyTimeTranslateValue(TransInfo *t) +static void applyTimeTranslateValue(TransInfo *t, float value) { Scene *scene = t->scene; int i; @@ -9458,7 +9471,6 @@ static void applyTimeTranslateValue(TransInfo *t) const double secf = FPS; float deltax, val /* , valprev */; - t->values_final[0] = t->values[0]; FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; @@ -9476,7 +9488,7 @@ static void applyTimeTranslateValue(TransInfo *t) /* check if any need to apply nla-mapping */ if (adt && (t->spacetype != SPACE_SEQ)) { - deltax = t->values_final[0]; + deltax = value; if (autosnap == SACTSNAP_TSTEP) { deltax = (float)(floor(((double)deltax / secf) + 0.5) * secf); @@ -9529,7 +9541,7 @@ static void applyTimeTranslate(TransInfo *t, const int mval[2]) t->values_final[0] = t->vec[0]; headerTimeTranslate(t, str); - applyTimeTranslateValue(t); + applyTimeTranslateValue(t, t->values_final[0]); recalcData(t); @@ -9637,20 +9649,17 @@ static void headerTimeSlide(TransInfo *t, const float sval, char str[UI_MAX_DRAW BLI_snprintf(str, UI_MAX_DRAW_STR, TIP_("TimeSlide: %s"), &tvec[0]); } -static void applyTimeSlideValue(TransInfo *t, float sval) +static void applyTimeSlideValue(TransInfo *t, float sval, float cval) { int i; const float *range = t->custom.mode.data; float minx = range[0]; float maxx = range[1]; - t->values_final[0] = t->values[0]; /* set value for drawing black line */ if (t->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; - float cvalf = t->values_final[0]; - - saction->timeslide = cvalf; + saction->timeslide = cval; } /* It doesn't matter whether we apply to t->data or @@ -9663,7 +9672,6 @@ static void applyTimeSlideValue(TransInfo *t, float sval) * (this is only valid when not in NLA) */ AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; - float cval = t->values_final[0]; /* only apply to data if in range */ if ((sval > minx) && (sval < maxx)) { @@ -9724,7 +9732,7 @@ static void applyTimeSlide(TransInfo *t, const int mval[2]) t->values_final[0] = (maxx - minx) * t->vec[0] / 2.0f + sval[0]; headerTimeSlide(t, sval[0], str); - applyTimeSlideValue(t, sval[0]); + applyTimeSlideValue(t, sval[0], t->values_final[0]); recalcData(t); @@ -9796,14 +9804,13 @@ static void headerTimeScale(TransInfo *t, char str[UI_MAX_DRAW_STR]) BLI_snprintf(str, UI_MAX_DRAW_STR, TIP_("ScaleX: %s"), &tvec[0]); } -static void applyTimeScaleValue(TransInfo *t) +static void applyTimeScaleValue(TransInfo *t, float value) { Scene *scene = t->scene; int i; const short autosnap = getAnimEdit_SnapMode(t); const double secf = FPS; - t->values_final[0] = t->values[0]; FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; @@ -9815,7 +9822,7 @@ static void applyTimeScaleValue(TransInfo *t) */ AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; float startx = CFRA; - float fac = t->values_final[0]; + float fac = value; if (autosnap == SACTSNAP_TSTEP) { fac = (float)(floor((double)fac / secf + 0.5) * secf); @@ -9851,7 +9858,7 @@ static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2])) t->values_final[0] = t->vec[0]; headerTimeScale(t, str); - applyTimeScaleValue(t); + applyTimeScaleValue(t, t->values_final[0]); recalcData(t); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 4eccf4c5071..ef9d23d1db8 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -9049,7 +9049,7 @@ static void createTransGPencil(bContext *C, TransInfo *t) /* initialize falloff curve */ if (is_multiedit) { - curvemapping_initialize(ts->gp_sculpt.cur_falloff); + BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff); } /* First Pass: Count the number of data-points required for the strokes, diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 6f06f8639bd..67bd107ab49 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -573,11 +573,11 @@ static bool raycastEditMesh(SnapObjectContext *sctx, BVHTreeFromEditMesh *treedata = sod->bvh_trees[2]; - BVHCache *em_bvh_cache = ((Mesh *)em->ob->data)->runtime.bvh_cache; + BVHCache **em_bvh_cache = &((Mesh *)em->ob->data)->runtime.bvh_cache; if (sctx->callbacks.edit_mesh.test_face_fn == NULL) { /* The tree is owned by the Mesh and may have been freed since we last used! */ - if (!bvhcache_has_tree(em_bvh_cache, treedata->tree)) { + if (treedata->tree && !bvhcache_has_tree(*em_bvh_cache, treedata->tree)) { free_bvhtree_from_editmesh(treedata); } } @@ -605,7 +605,7 @@ static bool raycastEditMesh(SnapObjectContext *sctx, else { /* Only cache if bvhtree is created without a mask. * This helps keep a standardized bvhtree in cache. */ - bvh_cache = &em_bvh_cache; + bvh_cache = em_bvh_cache; } bvhtree_from_editmesh_looptri_ex( @@ -1382,6 +1382,13 @@ static short snap_mesh_edge_verts_mixed(SnapObjectContext *sctx, }; SnapObjectData *sod = BLI_ghash_lookup(sctx->cache.object_map, ob); + if (sod == NULL) { + /* The object is in edit mode, and the key used + * was the object referenced in BMEditMesh */ + BMEditMesh *em = BKE_editmesh_from_object(ob); + sod = BLI_ghash_lookup(sctx->cache.object_map, em->ob); + } + BLI_assert(sod != NULL); if (sod->type == SNAP_MESH) { @@ -2188,7 +2195,7 @@ static short snapEditMesh(SnapObjectContext *sctx, return 0; } - BVHCache *em_bvh_cache = ((Mesh *)em->ob->data)->runtime.bvh_cache; + BVHCache **em_bvh_cache = &((Mesh *)em->ob->data)->runtime.bvh_cache; if (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) { if (sod->bvh_trees[0] == NULL) { @@ -2198,7 +2205,7 @@ static short snapEditMesh(SnapObjectContext *sctx, if (sctx->callbacks.edit_mesh.test_vert_fn == NULL) { /* The tree is owned by the Mesh and may have been freed since we last used! */ - if (!bvhcache_has_tree(em_bvh_cache, treedata_vert->tree)) { + if (treedata_vert->tree && !bvhcache_has_tree(*em_bvh_cache, treedata_vert->tree)) { free_bvhtree_from_editmesh(treedata_vert); } } @@ -2220,7 +2227,7 @@ static short snapEditMesh(SnapObjectContext *sctx, MEM_freeN(verts_mask); } else { - bvhtree_from_editmesh_verts(treedata_vert, em, 0.0f, 2, 6, &em_bvh_cache); + bvhtree_from_editmesh_verts(treedata_vert, em, 0.0f, 2, 6, em_bvh_cache); } } } @@ -2233,7 +2240,7 @@ static short snapEditMesh(SnapObjectContext *sctx, if (sctx->callbacks.edit_mesh.test_edge_fn == NULL) { /* The tree is owned by the Mesh and may have been freed since we last used! */ - if (!bvhcache_has_tree(em_bvh_cache, treedata_edge->tree)) { + if (treedata_edge->tree && !bvhcache_has_tree(*em_bvh_cache, treedata_edge->tree)) { free_bvhtree_from_editmesh(treedata_edge); } } @@ -2255,7 +2262,7 @@ static short snapEditMesh(SnapObjectContext *sctx, MEM_freeN(edges_mask); } else { - bvhtree_from_editmesh_edges(treedata_edge, em, 0.0f, 2, 6, &em_bvh_cache); + bvhtree_from_editmesh_edges(treedata_edge, em, 0.0f, 2, 6, em_bvh_cache); } } } diff --git a/source/blender/editors/util/select_buffer_utils.c b/source/blender/editors/util/select_buffer_utils.c index 2201ee5cec2..fa03f8d1514 100644 --- a/source/blender/editors/util/select_buffer_utils.c +++ b/source/blender/editors/util/select_buffer_utils.c @@ -55,9 +55,12 @@ */ uint *ED_select_buffer_bitmap_from_rect(const uint bitmap_len, const rcti *rect) { + rcti rect_px = *rect; + rect_px.xmax += 1; + rect_px.ymax += 1; + uint buf_len; - const uint *buf = ED_view3d_select_id_read( - rect->xmin, rect->ymin, rect->xmax, rect->ymax, &buf_len); + const uint *buf = ED_view3d_select_id_read_rect(&rect_px, &buf_len); if (buf == NULL) { return NULL; } @@ -91,12 +94,14 @@ uint *ED_select_buffer_bitmap_from_circle(const uint bitmap_len, return NULL; } - const int xmin = center[0] - radius; - const int xmax = center[0] + radius; - const int ymin = center[1] - radius; - const int ymax = center[1] + radius; + const rcti rect = { + .xmin = center[0] - radius, + .xmax = center[0] + radius + 1, + .ymin = center[1] - radius, + .ymax = center[1] + radius + 1, + }; - const uint *buf = ED_view3d_select_id_read(xmin, ymin, xmax, ymax, NULL); + const uint *buf = ED_view3d_select_id_read_rect(&rect, NULL); if (buf == NULL) { return NULL; } @@ -152,10 +157,13 @@ uint *ED_select_buffer_bitmap_from_poly(const uint bitmap_len, return NULL; } + rcti rect_px = *rect; + rect_px.xmax += 1; + rect_px.ymax += 1; + struct PolyMaskData poly_mask_data; uint buf_len; - const uint *buf = ED_view3d_select_id_read( - rect->xmin, rect->ymin, rect->xmax, rect->ymax, &buf_len); + const uint *buf = ED_view3d_select_id_read_rect(&rect_px, &buf_len); if (buf == NULL) { return NULL; } @@ -164,10 +172,10 @@ uint *ED_select_buffer_bitmap_from_poly(const uint bitmap_len, poly_mask_data.px = buf_mask; poly_mask_data.width = (rect->xmax - rect->xmin) + 1; - BLI_bitmap_draw_2d_poly_v2i_n(rect->xmin, - rect->ymin, - rect->xmax + 1, - rect->ymax + 1, + BLI_bitmap_draw_2d_poly_v2i_n(rect_px.xmin, + rect_px.ymin, + rect_px.xmax, + rect_px.ymax, poly, poly_len, ed_select_buffer_mask_px_cb, @@ -205,8 +213,15 @@ uint *ED_select_buffer_bitmap_from_poly(const uint bitmap_len, */ uint ED_select_buffer_sample_point(const int center[2]) { + const rcti rect = { + .xmin = center[0], + .xmax = center[0] + 1, + .ymin = center[1], + .ymax = center[1] + 1, + }; + uint buf_len; - uint *buf = ED_view3d_select_id_read(center[0], center[1], center[0], center[1], &buf_len); + uint *buf = ED_view3d_select_id_read_rect(&rect, &buf_len); BLI_assert(0 != buf_len); uint ret = buf[0]; MEM_freeN(buf); |