diff options
Diffstat (limited to 'source')
124 files changed, 1330 insertions, 1214 deletions
diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index a6eb12c3708..643073b3470 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -34,17 +34,19 @@ struct ImBuf; struct Scopes; struct rctf; -void curvemapping_set_defaults( +void BKE_curvemapping_set_defaults( struct CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy); -struct CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, float maxy); -void curvemapping_free_data(struct CurveMapping *cumap); -void curvemapping_free(struct CurveMapping *cumap); -void curvemapping_copy_data(struct CurveMapping *target, const struct CurveMapping *cumap); -struct CurveMapping *curvemapping_copy(const struct CurveMapping *cumap); -void curvemapping_set_black_white_ex(const float black[3], const float white[3], float r_bwmul[3]); -void curvemapping_set_black_white(struct CurveMapping *cumap, - const float black[3], - const float white[3]); +struct CurveMapping *BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy); +void BKE_curvemapping_free_data(struct CurveMapping *cumap); +void BKE_curvemapping_free(struct CurveMapping *cumap); +void BKE_curvemapping_copy_data(struct CurveMapping *target, const struct CurveMapping *cumap); +struct CurveMapping *BKE_curvemapping_copy(const struct CurveMapping *cumap); +void BKE_curvemapping_set_black_white_ex(const float black[3], + const float white[3], + float r_bwmul[3]); +void BKE_curvemapping_set_black_white(struct CurveMapping *cumap, + const float black[3], + const float white[3]); enum { CURVEMAP_SLOPE_NEGATIVE = 0, @@ -52,56 +54,56 @@ enum { CURVEMAP_SLOPE_POS_NEG = 2, }; -void curvemap_reset(struct CurveMap *cuma, const struct rctf *clipr, int preset, int slope); -void curvemap_remove(struct CurveMap *cuma, const short flag); -bool curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp); -struct CurveMapPoint *curvemap_insert(struct CurveMap *cuma, float x, float y); -void curvemap_handle_set(struct CurveMap *cuma, int type); +void BKE_curvemap_reset(struct CurveMap *cuma, const struct rctf *clipr, int preset, int slope); +void BKE_curvemap_remove(struct CurveMap *cuma, const short flag); +bool BKE_curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp); +struct CurveMapPoint *BKE_curvemap_insert(struct CurveMap *cuma, float x, float y); +void BKE_curvemap_handle_set(struct CurveMap *cuma, int type); -void curvemapping_changed(struct CurveMapping *cumap, const bool rem_doubles); -void curvemapping_changed_all(struct CurveMapping *cumap); +void BKE_curvemapping_changed(struct CurveMapping *cumap, const bool rem_doubles); +void BKE_curvemapping_changed_all(struct CurveMapping *cumap); /* call before _all_ evaluation functions */ -void curvemapping_initialize(struct CurveMapping *cumap); +void BKE_curvemapping_initialize(struct CurveMapping *cumap); /* keep these (const CurveMap) - to help with thread safety */ /* single curve, no table check */ -float curvemap_evaluateF(const struct CurveMap *cuma, float value); +float BKE_curvemap_evaluateF(const struct CurveMap *cuma, float value); /* single curve, with table check */ -float curvemapping_evaluateF(const struct CurveMapping *cumap, int cur, float value); -void curvemapping_evaluate3F(const struct CurveMapping *cumap, - float vecout[3], - const float vecin[3]); -void curvemapping_evaluateRGBF(const struct CurveMapping *cumap, - float vecout[3], - const float vecin[3]); -void curvemapping_evaluate_premulRGB(const struct CurveMapping *cumap, - unsigned char vecout_byte[3], - const unsigned char vecin_byte[3]); -void curvemapping_evaluate_premulRGBF_ex(const struct CurveMapping *cumap, - float vecout[3], - const float vecin[3], - const float black[3], - const float bwmul[3]); -void curvemapping_evaluate_premulRGBF(const struct CurveMapping *cumap, - float vecout[3], - const float vecin[3]); -int curvemapping_RGBA_does_something(const struct CurveMapping *cumap); -void curvemapping_table_RGBA(const struct CurveMapping *cumap, float **array, int *size); +float BKE_curvemapping_evaluateF(const struct CurveMapping *cumap, int cur, float value); +void BKE_curvemapping_evaluate3F(const struct CurveMapping *cumap, + float vecout[3], + const float vecin[3]); +void BKE_curvemapping_evaluateRGBF(const struct CurveMapping *cumap, + float vecout[3], + const float vecin[3]); +void BKE_curvemapping_evaluate_premulRGB(const struct CurveMapping *cumap, + unsigned char vecout_byte[3], + const unsigned char vecin_byte[3]); +void BKE_curvemapping_evaluate_premulRGBF_ex(const struct CurveMapping *cumap, + float vecout[3], + const float vecin[3], + const float black[3], + const float bwmul[3]); +void BKE_curvemapping_evaluate_premulRGBF(const struct CurveMapping *cumap, + float vecout[3], + const float vecin[3]); +int BKE_curvemapping_RGBA_does_something(const struct CurveMapping *cumap); +void BKE_curvemapping_table_RGBA(const struct CurveMapping *cumap, float **array, int *size); /* non-const, these modify the curve */ -void curvemapping_premultiply(struct CurveMapping *cumap, int restore); +void BKE_curvemapping_premultiply(struct CurveMapping *cumap, int restore); void BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings); -void scopes_update(struct Scopes *scopes, - struct ImBuf *ibuf, - const struct ColorManagedViewSettings *view_settings, - const struct ColorManagedDisplaySettings *display_settings); -void scopes_free(struct Scopes *scopes); -void scopes_new(struct Scopes *scopes); +void BKE_scopes_update(struct Scopes *scopes, + struct ImBuf *ibuf, + const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings); +void BKE_scopes_free(struct Scopes *scopes); +void BKE_scopes_new(struct Scopes *scopes); void BKE_color_managed_display_settings_init(struct ColorManagedDisplaySettings *settings); void BKE_color_managed_display_settings_copy(struct ColorManagedDisplaySettings *new_settings, diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index f018e912945..65aa43ced7c 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -59,10 +59,6 @@ void txt_order_cursors(struct Text *text, const bool reverse); int txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case); bool txt_has_sel(struct Text *text); int txt_get_span(struct TextLine *from, struct TextLine *to); -int txt_utf8_offset_to_index(const char *str, int offset); -int txt_utf8_index_to_offset(const char *str, int index); -int txt_utf8_offset_to_column(const char *str, int offset); -int txt_utf8_column_to_offset(const char *str, int column); void txt_move_up(struct Text *text, const bool sel); void txt_move_down(struct Text *text, const bool sel); void txt_move_left(struct Text *text, const bool sel); diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 49855de0591..d91296e0c01 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -960,13 +960,13 @@ void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces, int * } } -void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, - CCGFace **faces, - int numFaces, - CCGVert ***verts, - int *numVerts, - CCGEdge ***edges, - int *numEdges) +void ccgSubSurf__effectedFaceNeighbors(CCGSubSurf *ss, + CCGFace **faces, + int numFaces, + CCGVert ***verts, + int *numVerts, + CCGEdge ***edges, + int *numEdges) { CCGVert **arrayV; CCGEdge **arrayE; @@ -1134,7 +1134,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in cornerIdx = gridSize - 1; ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF); - ccgSubSurf__effectedFaceNeighbours( + ccgSubSurf__effectedFaceNeighbors( ss, effectedF, numEffectedF, &effectedV, &numEffectedV, &effectedE, &numEffectedE); /* zero */ diff --git a/source/blender/blenkernel/intern/CCGSubSurf_intern.h b/source/blender/blenkernel/intern/CCGSubSurf_intern.h index 41a34b65381..51486db1bdc 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf_intern.h +++ b/source/blender/blenkernel/intern/CCGSubSurf_intern.h @@ -306,13 +306,13 @@ struct CCGSubSurf { /* * CCGSubSurf.c * */ void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces, int *freeFaces); -void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, - CCGFace **faces, - int numFaces, - CCGVert ***verts, - int *numVerts, - CCGEdge ***edges, - int *numEdges); +void ccgSubSurf__effectedFaceNeighbors(CCGSubSurf *ss, + CCGFace **faces, + int numFaces, + CCGVert ***verts, + int *numVerts, + CCGEdge ***edges, + int *numEdges); /* * CCGSubSurf_legacy.c * */ diff --git a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c index d8b30c9d4ef..01735b34e5e 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c +++ b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c @@ -1323,7 +1323,7 @@ CCGError ccgSubSurf_updateNormals(CCGSubSurf *ss, CCGFace **effectedF, int numEf int i, numEffectedV, numEffectedE, freeF; ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF); - ccgSubSurf__effectedFaceNeighbours( + ccgSubSurf__effectedFaceNeighbors( ss, effectedF, numEffectedF, &effectedV, &numEffectedV, &effectedE, &numEffectedE); if (ss->calcVertNormals) { @@ -1361,7 +1361,7 @@ CCGError ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **effectedF, i int curLvl, subdivLevels = ss->subdivLevels; ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF); - ccgSubSurf__effectedFaceNeighbours( + ccgSubSurf__effectedFaceNeighbors( ss, effectedF, numEffectedF, &effectedV, &numEffectedV, &effectedE, &numEffectedE); for (curLvl = lvl; curLvl < subdivLevels; curLvl++) { diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 7f1a0e6a744..6267c095618 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1046,24 +1046,25 @@ static void mesh_calc_modifier_final_normals(const Mesh *mesh_input, * since they are needed by drawing code. */ const bool do_poly_normals = ((final_datamask->pmask & CD_MASK_NORMAL) != 0); - if (do_loop_normals) { - /* In case we also need poly normals, add the layer and compute them here - * (BKE_mesh_calc_normals_split() assumes that if that data exists, it is always valid). */ - if (do_poly_normals) { - if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) { - float(*polynors)[3] = CustomData_add_layer( - &mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly); - BKE_mesh_calc_normals_poly(mesh_final->mvert, - NULL, - mesh_final->totvert, - mesh_final->mloop, - mesh_final->mpoly, - mesh_final->totloop, - mesh_final->totpoly, - polynors, - false); - } + /* In case we also need poly normals, add the layer and compute them here + * (BKE_mesh_calc_normals_split() assumes that if that data exists, it is always valid). */ + if (do_poly_normals) { + if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) { + float(*polynors)[3] = CustomData_add_layer( + &mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly); + BKE_mesh_calc_normals_poly(mesh_final->mvert, + NULL, + mesh_final->totvert, + mesh_final->mloop, + mesh_final->mpoly, + mesh_final->totloop, + mesh_final->totpoly, + polynors, + false); } + } + + if (do_loop_normals) { /* Compute loop normals (note: will compute poly and vert normals as well, if needed!) */ BKE_mesh_calc_normals_split(mesh_final); BKE_mesh_tessface_clear(mesh_final); @@ -1536,11 +1537,16 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph, modifier_freeTemporaryData(md); } - /* Yay, we are done. If we have a Mesh and deformed vertices - * need to apply these back onto the Mesh. If we have no + /* Yay, we are done. If we have a Mesh and deformed vertices, + * we need to apply these back onto the Mesh. If we have no * Mesh then we need to build one. */ if (mesh_final == NULL) { - if (deformed_verts == NULL && allow_shared_mesh) { + /* Note: this check on cdmask is a bit dodgy, it handles the issue at stake here (see T68211), + * but other cases might require similar handling? + * Could be a good idea to define a proper CustomData_MeshMask for that then. */ + if (deformed_verts == NULL && allow_shared_mesh && + (final_datamask.lmask & CD_MASK_NORMAL) == 0 && + (final_datamask.pmask & CD_MASK_NORMAL) == 0) { mesh_final = mesh_input; } else { @@ -1653,14 +1659,25 @@ static void editbmesh_calc_modifier_final_normals(const Mesh *mesh_input, * simpler to generate it here as well. */ const bool do_poly_normals = ((final_datamask->pmask & CD_MASK_NORMAL) != 0); - if (do_loop_normals) { - /* In case we also need poly normals, add the layer here, - * then BKE_mesh_calc_normals_split() will fill it. */ - if (do_poly_normals) { - if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) { - CustomData_add_layer(&mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly); - } + /* In case we also need poly normals, add the layer and compute them here + * (BKE_mesh_calc_normals_split() assumes that if that data exists, it is always valid). */ + if (do_poly_normals) { + if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) { + float(*polynors)[3] = CustomData_add_layer( + &mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly); + BKE_mesh_calc_normals_poly(mesh_final->mvert, + NULL, + mesh_final->totvert, + mesh_final->mloop, + mesh_final->mpoly, + mesh_final->totloop, + mesh_final->totpoly, + polynors, + false); } + } + + if (do_loop_normals) { /* Compute loop normals */ BKE_mesh_calc_normals_split(mesh_final); BKE_mesh_tessface_clear(mesh_final); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 984de700ce7..57a7379eeae 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -236,9 +236,9 @@ void action_group_colors_sync(bActionGroup *grp, const bActionGroup *ref_grp) */ else if (grp->cs.solid[0] == 0) { /* define for setting colors in theme below */ - rgba_char_args_set(grp->cs.solid, 0xff, 0x00, 0x00, 255); - rgba_char_args_set(grp->cs.select, 0x81, 0xe6, 0x14, 255); - rgba_char_args_set(grp->cs.active, 0x18, 0xb6, 0xe0, 255); + rgba_uchar_args_set(grp->cs.solid, 0xff, 0x00, 0x00, 255); + rgba_uchar_args_set(grp->cs.select, 0x81, 0xe6, 0x14, 255); + rgba_uchar_args_set(grp->cs.active, 0x18, 0xb6, 0xe0, 255); } } } diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 709f74808a3..b2d3ccfebc3 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -184,9 +184,9 @@ void BKE_brush_init_gpencil_settings(Brush *brush) brush->gpencil_settings->flag |= GP_BRUSH_ENABLE_CURSOR; /* curves */ - brush->gpencil_settings->curve_sensitivity = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); - brush->gpencil_settings->curve_strength = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); - brush->gpencil_settings->curve_jitter = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + brush->gpencil_settings->curve_sensitivity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + brush->gpencil_settings->curve_strength = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + brush->gpencil_settings->curve_jitter = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } /* add a new gp-brush */ @@ -386,8 +386,8 @@ void BKE_brush_gpencil_presets(bContext *C) /* Curve */ custom_curve = brush->gpencil_settings->curve_sensitivity; - curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(custom_curve); + BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(custom_curve); brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INK); /* Ink Noise brush */ @@ -423,8 +423,8 @@ void BKE_brush_gpencil_presets(bContext *C) /* Curve */ custom_curve = brush->gpencil_settings->curve_sensitivity; - curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(custom_curve); + BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(custom_curve); brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INKNOISE); brush->gpencil_settings->gradient_f = 1.0f; @@ -495,8 +495,8 @@ void BKE_brush_gpencil_presets(bContext *C) brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; /* Curve */ custom_curve = brush->gpencil_settings->curve_sensitivity; - curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(custom_curve); + BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(custom_curve); brush_gpencil_curvemap_reset(custom_curve->cm, 4, GPCURVE_PRESET_MARKER); brush->gpencil_settings->gradient_f = 1.0f; @@ -649,14 +649,14 @@ void BKE_brush_copy_data(Main *UNUSED(bmain), brush_dst->preview = NULL; } - brush_dst->curve = curvemapping_copy(brush_src->curve); + brush_dst->curve = BKE_curvemapping_copy(brush_src->curve); if (brush_src->gpencil_settings != NULL) { brush_dst->gpencil_settings = MEM_dupallocN(brush_src->gpencil_settings); - brush_dst->gpencil_settings->curve_sensitivity = curvemapping_copy( + brush_dst->gpencil_settings->curve_sensitivity = BKE_curvemapping_copy( brush_src->gpencil_settings->curve_sensitivity); - brush_dst->gpencil_settings->curve_strength = curvemapping_copy( + brush_dst->gpencil_settings->curve_strength = BKE_curvemapping_copy( brush_src->gpencil_settings->curve_strength); - brush_dst->gpencil_settings->curve_jitter = curvemapping_copy( + brush_dst->gpencil_settings->curve_jitter = BKE_curvemapping_copy( brush_src->gpencil_settings->curve_jitter); } @@ -677,12 +677,12 @@ void BKE_brush_free(Brush *brush) if (brush->icon_imbuf) { IMB_freeImBuf(brush->icon_imbuf); } - curvemapping_free(brush->curve); + BKE_curvemapping_free(brush->curve); if (brush->gpencil_settings != NULL) { - curvemapping_free(brush->gpencil_settings->curve_sensitivity); - curvemapping_free(brush->gpencil_settings->curve_strength); - curvemapping_free(brush->gpencil_settings->curve_jitter); + BKE_curvemapping_free(brush->gpencil_settings->curve_sensitivity); + BKE_curvemapping_free(brush->gpencil_settings->curve_strength); + BKE_curvemapping_free(brush->gpencil_settings->curve_jitter); MEM_SAFE_FREE(brush->gpencil_settings); } @@ -917,15 +917,15 @@ void BKE_brush_curve_preset(Brush *b, eCurveMappingPreset preset) CurveMap *cm = NULL; if (!b->curve) { - b->curve = curvemapping_add(1, 0, 0, 1, 1); + b->curve = BKE_curvemapping_add(1, 0, 0, 1, 1); } cm = b->curve->cm; cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; b->curve->preset = preset; - curvemap_reset(cm, &b->curve->clipr, b->curve->preset, CURVEMAP_SLOPE_NEGATIVE); - curvemapping_changed(b->curve, false); + BKE_curvemap_reset(cm, &b->curve->clipr, b->curve->preset, CURVEMAP_SLOPE_NEGATIVE); + BKE_curvemapping_changed(b->curve, false); } /* Generic texture sampler for 3D painting systems. point has to be either in @@ -1412,7 +1412,7 @@ float BKE_brush_curve_strength(const Brush *br, float p, const float len) switch (br->curve_preset) { case BRUSH_CURVE_CUSTOM: - strength = curvemapping_evaluateF(br->curve, 0, 1.0f - p); + strength = BKE_curvemapping_evaluateF(br->curve, 0, 1.0f - p); break; case BRUSH_CURVE_SHARP: strength = p * p; @@ -1498,7 +1498,7 @@ struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary) int half = side / 2; int i, j; - curvemapping_initialize(br->curve); + BKE_curvemapping_initialize(br->curve); texcache = BKE_brush_gen_texture_cache(br, half, secondary); im->rect_float = MEM_callocN(sizeof(float) * side * side, "radial control rect"); im->x = im->y = side; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index e51d15ee152..8c125d1609b 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -553,6 +553,7 @@ BVHTree *bvhtree_from_editmesh_verts(BVHTreeFromEditMesh *data, /* Save on cache for later use */ /* printf("BVHTree built and saved on cache\n"); */ bvhcache_insert(bvh_cache, data->tree, BVHTREE_FROM_EM_VERTS); + data->cached = true; } BLI_rw_mutex_unlock(&cache_rwlock); } @@ -743,6 +744,7 @@ BVHTree *bvhtree_from_editmesh_edges(BVHTreeFromEditMesh *data, /* Save on cache for later use */ /* printf("BVHTree built and saved on cache\n"); */ bvhcache_insert(bvh_cache, data->tree, BVHTREE_FROM_EM_EDGES); + data->cached = true; } BLI_rw_mutex_unlock(&cache_rwlock); } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index aa5f74c6297..b129bf14bb8 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -48,7 +48,7 @@ /* ***************** operations on full struct ************* */ -void curvemapping_set_defaults( +void BKE_curvemapping_set_defaults( CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy) { int a; @@ -84,18 +84,18 @@ void curvemapping_set_defaults( cumap->changed_timestamp = 0; } -CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, float maxy) +CurveMapping *BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy) { CurveMapping *cumap; cumap = MEM_callocN(sizeof(CurveMapping), "new curvemap"); - curvemapping_set_defaults(cumap, tot, minx, miny, maxx, maxy); + BKE_curvemapping_set_defaults(cumap, tot, minx, miny, maxx, maxy); return cumap; } -void curvemapping_free_data(CurveMapping *cumap) +void BKE_curvemapping_free_data(CurveMapping *cumap) { int a; @@ -115,15 +115,15 @@ void curvemapping_free_data(CurveMapping *cumap) } } -void curvemapping_free(CurveMapping *cumap) +void BKE_curvemapping_free(CurveMapping *cumap) { if (cumap) { - curvemapping_free_data(cumap); + BKE_curvemapping_free_data(cumap); MEM_freeN(cumap); } } -void curvemapping_copy_data(CurveMapping *target, const CurveMapping *cumap) +void BKE_curvemapping_copy_data(CurveMapping *target, const CurveMapping *cumap) { int a; @@ -142,17 +142,19 @@ void curvemapping_copy_data(CurveMapping *target, const CurveMapping *cumap) } } -CurveMapping *curvemapping_copy(const CurveMapping *cumap) +CurveMapping *BKE_curvemapping_copy(const CurveMapping *cumap) { if (cumap) { CurveMapping *cumapn = MEM_dupallocN(cumap); - curvemapping_copy_data(cumapn, cumap); + BKE_curvemapping_copy_data(cumapn, cumap); return cumapn; } return NULL; } -void curvemapping_set_black_white_ex(const float black[3], const float white[3], float r_bwmul[3]) +void BKE_curvemapping_set_black_white_ex(const float black[3], + const float white[3], + float r_bwmul[3]) { int a; @@ -162,7 +164,9 @@ void curvemapping_set_black_white_ex(const float black[3], const float white[3], } } -void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], const float white[3]) +void BKE_curvemapping_set_black_white(CurveMapping *cumap, + const float black[3], + const float white[3]) { if (white) { copy_v3_v3(cumap->white, white); @@ -171,15 +175,15 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con copy_v3_v3(cumap->black, black); } - curvemapping_set_black_white_ex(cumap->black, cumap->white, cumap->bwmul); + BKE_curvemapping_set_black_white_ex(cumap->black, cumap->white, cumap->bwmul); cumap->changed_timestamp++; } /* ***************** operations on single curve ************* */ -/* ********** NOTE: requires curvemapping_changed() call after ******** */ +/* ********** NOTE: requires BKE_curvemapping_changed() call after ******** */ /* remove specified point */ -bool curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point) +bool BKE_curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point) { CurveMapPoint *cmp; int a, b, removed = 0; @@ -209,7 +213,7 @@ bool curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point) } /* removes with flag set */ -void curvemap_remove(CurveMap *cuma, const short flag) +void BKE_curvemap_remove(CurveMap *cuma, const short flag) { CurveMapPoint *cmp = MEM_mallocN((cuma->totpoint) * sizeof(CurveMapPoint), "curve points"); int a, b, removed = 0; @@ -232,7 +236,7 @@ void curvemap_remove(CurveMap *cuma, const short flag) cuma->totpoint -= removed; } -CurveMapPoint *curvemap_insert(CurveMap *cuma, float x, float y) +CurveMapPoint *BKE_curvemap_insert(CurveMap *cuma, float x, float y) { CurveMapPoint *cmp = MEM_callocN((cuma->totpoint + 1) * sizeof(CurveMapPoint), "curve points"); CurveMapPoint *newcmp = NULL; @@ -266,7 +270,7 @@ CurveMapPoint *curvemap_insert(CurveMap *cuma, float x, float y) return newcmp; } -void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope) +void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope) { if (cuma->curve) { MEM_freeN(cuma->curve); @@ -439,7 +443,7 @@ void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope) /** * \param type: eBezTriple_Handle */ -void curvemap_handle_set(CurveMap *cuma, int type) +void BKE_curvemap_handle_set(CurveMap *cuma, int type) { int a; @@ -800,7 +804,7 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr) /* call when you do images etc, needs restore too. also verifies tables */ /* it uses a flag to prevent premul or free to happen twice */ -void curvemapping_premultiply(CurveMapping *cumap, int restore) +void BKE_curvemapping_premultiply(CurveMapping *cumap, int restore) { int a; @@ -841,7 +845,7 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore) for (a = 0; a < 3; a++) { int b; for (b = 0; b <= CM_TABLE; b++) { - cumap->cm[a].table[b].y = curvemap_evaluateF(cumap->cm + 3, cumap->cm[a].table[b].y); + cumap->cm[a].table[b].y = BKE_curvemap_evaluateF(cumap->cm + 3, cumap->cm[a].table[b].y); } copy_v2_v2(cumap->cm[a].premul_ext_in, cumap->cm[a].ext_in); @@ -871,7 +875,7 @@ static int sort_curvepoints(const void *a1, const void *a2) /* ************************ more CurveMapping calls *************** */ /* note; only does current curvemap! */ -void curvemapping_changed(CurveMapping *cumap, const bool rem_doubles) +void BKE_curvemapping_changed(CurveMapping *cumap, const bool rem_doubles) { CurveMap *cuma = cumap->cm + cumap->cur; CurveMapPoint *cmp = cuma->curve; @@ -942,20 +946,20 @@ void curvemapping_changed(CurveMapping *cumap, const bool rem_doubles) } } if (a != cuma->totpoint - 1) { - curvemap_remove(cuma, 2); + BKE_curvemap_remove(cuma, 2); } } curvemap_make_table(cuma, clipr); } -void curvemapping_changed_all(CurveMapping *cumap) +void BKE_curvemapping_changed_all(CurveMapping *cumap) { int a, cur = cumap->cur; for (a = 0; a < CM_TOT; a++) { if (cumap->cm[a].curve) { cumap->cur = a; - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); } } @@ -963,7 +967,7 @@ void curvemapping_changed_all(CurveMapping *cumap) } /* table should be verified */ -float curvemap_evaluateF(const CurveMap *cuma, float value) +float BKE_curvemap_evaluateF(const CurveMap *cuma, float value) { float fi; int i; @@ -990,10 +994,10 @@ float curvemap_evaluateF(const CurveMap *cuma, float value) } /* works with curve 'cur' */ -float curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value) +float BKE_curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value) { const CurveMap *cuma = cumap->cm + cur; - float val = curvemap_evaluateF(cuma, value); + float val = BKE_curvemap_evaluateF(cuma, value); /* account for clipping */ if (cumap->flag & CUMA_DO_CLIP) { @@ -1009,19 +1013,24 @@ float curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value) } /* vector case */ -void curvemapping_evaluate3F(const CurveMapping *cumap, float vecout[3], const float vecin[3]) +void BKE_curvemapping_evaluate3F(const CurveMapping *cumap, float vecout[3], const float vecin[3]) { - vecout[0] = curvemap_evaluateF(&cumap->cm[0], vecin[0]); - vecout[1] = curvemap_evaluateF(&cumap->cm[1], vecin[1]); - vecout[2] = curvemap_evaluateF(&cumap->cm[2], vecin[2]); + vecout[0] = BKE_curvemap_evaluateF(&cumap->cm[0], vecin[0]); + vecout[1] = BKE_curvemap_evaluateF(&cumap->cm[1], vecin[1]); + vecout[2] = BKE_curvemap_evaluateF(&cumap->cm[2], vecin[2]); } /* RGB case, no black/white points, no premult */ -void curvemapping_evaluateRGBF(const CurveMapping *cumap, float vecout[3], const float vecin[3]) +void BKE_curvemapping_evaluateRGBF(const CurveMapping *cumap, + float vecout[3], + const float vecin[3]) { - vecout[0] = curvemap_evaluateF(&cumap->cm[0], curvemap_evaluateF(&cumap->cm[3], vecin[0])); - vecout[1] = curvemap_evaluateF(&cumap->cm[1], curvemap_evaluateF(&cumap->cm[3], vecin[1])); - vecout[2] = curvemap_evaluateF(&cumap->cm[2], curvemap_evaluateF(&cumap->cm[3], vecin[2])); + vecout[0] = BKE_curvemap_evaluateF(&cumap->cm[0], + BKE_curvemap_evaluateF(&cumap->cm[3], vecin[0])); + vecout[1] = BKE_curvemap_evaluateF(&cumap->cm[1], + BKE_curvemap_evaluateF(&cumap->cm[3], vecin[1])); + vecout[2] = BKE_curvemap_evaluateF(&cumap->cm[2], + BKE_curvemap_evaluateF(&cumap->cm[3], vecin[2])); } static void curvemapping_evaluateRGBF_filmlike(const CurveMapping *cumap, @@ -1033,8 +1042,8 @@ static void curvemapping_evaluateRGBF_filmlike(const CurveMapping *cumap, const float v1in = vecin[channel_offset[1]]; const float v2in = vecin[channel_offset[2]]; - const float v0 = curvemap_evaluateF(&cumap->cm[channel_offset[0]], v0in); - const float v2 = curvemap_evaluateF(&cumap->cm[channel_offset[2]], v2in); + const float v0 = BKE_curvemap_evaluateF(&cumap->cm[channel_offset[0]], v0in); + const float v2 = BKE_curvemap_evaluateF(&cumap->cm[channel_offset[2]], v2in); const float v1 = v2 + ((v0 - v2) * (v1in - v2in) / (v0in - v2in)); vecout[channel_offset[0]] = v0; @@ -1042,20 +1051,20 @@ static void curvemapping_evaluateRGBF_filmlike(const CurveMapping *cumap, vecout[channel_offset[2]] = v2; } -/** same as #curvemapping_evaluate_premulRGBF +/** same as #BKE_curvemapping_evaluate_premulRGBF * but black/bwmul are passed as args for the compositor * where they can change per pixel. * - * Use in conjunction with #curvemapping_set_black_white_ex + * Use in conjunction with #BKE_curvemapping_set_black_white_ex * * \param black: Use instead of cumap->black * \param bwmul: Use instead of cumap->bwmul */ -void curvemapping_evaluate_premulRGBF_ex(const CurveMapping *cumap, - float vecout[3], - const float vecin[3], - const float black[3], - const float bwmul[3]) +void BKE_curvemapping_evaluate_premulRGBF_ex(const CurveMapping *cumap, + float vecout[3], + const float vecin[3], + const float black[3], + const float bwmul[3]) { const float r = (vecin[0] - black[0]) * bwmul[0]; const float g = (vecin[1] - black[1]) * bwmul[1]; @@ -1064,9 +1073,9 @@ void curvemapping_evaluate_premulRGBF_ex(const CurveMapping *cumap, switch (cumap->tone) { default: case CURVE_TONE_STANDARD: { - vecout[0] = curvemap_evaluateF(&cumap->cm[0], r); - vecout[1] = curvemap_evaluateF(&cumap->cm[1], g); - vecout[2] = curvemap_evaluateF(&cumap->cm[2], b); + vecout[0] = BKE_curvemap_evaluateF(&cumap->cm[0], r); + vecout[1] = BKE_curvemap_evaluateF(&cumap->cm[1], g); + vecout[2] = BKE_curvemap_evaluateF(&cumap->cm[2], b); break; } case CURVE_TONE_FILMLIKE: { @@ -1088,8 +1097,9 @@ void curvemapping_evaluate_premulRGBF_ex(const CurveMapping *cumap, } else { /* Case 4: r >= g == b */ - copy_v2_fl2( - vecout, curvemap_evaluateF(&cumap->cm[0], r), curvemap_evaluateF(&cumap->cm[1], g)); + copy_v2_fl2(vecout, + BKE_curvemap_evaluateF(&cumap->cm[0], r), + BKE_curvemap_evaluateF(&cumap->cm[1], g)); vecout[2] = vecout[1]; } } @@ -1116,17 +1126,17 @@ void curvemapping_evaluate_premulRGBF_ex(const CurveMapping *cumap, } /* RGB with black/white points and premult. tables are checked */ -void curvemapping_evaluate_premulRGBF(const CurveMapping *cumap, - float vecout[3], - const float vecin[3]) +void BKE_curvemapping_evaluate_premulRGBF(const CurveMapping *cumap, + float vecout[3], + const float vecin[3]) { - curvemapping_evaluate_premulRGBF_ex(cumap, vecout, vecin, cumap->black, cumap->bwmul); + BKE_curvemapping_evaluate_premulRGBF_ex(cumap, vecout, vecin, cumap->black, cumap->bwmul); } /* same as above, byte version */ -void curvemapping_evaluate_premulRGB(const CurveMapping *cumap, - unsigned char vecout_byte[3], - const unsigned char vecin_byte[3]) +void BKE_curvemapping_evaluate_premulRGB(const CurveMapping *cumap, + unsigned char vecout_byte[3], + const unsigned char vecin_byte[3]) { float vecin[3], vecout[3]; @@ -1134,14 +1144,14 @@ void curvemapping_evaluate_premulRGB(const CurveMapping *cumap, vecin[1] = (float)vecin_byte[1] / 255.0f; vecin[2] = (float)vecin_byte[2] / 255.0f; - curvemapping_evaluate_premulRGBF(cumap, vecout, vecin); + BKE_curvemapping_evaluate_premulRGBF(cumap, vecout, vecin); vecout_byte[0] = unit_float_to_uchar_clamp(vecout[0]); vecout_byte[1] = unit_float_to_uchar_clamp(vecout[1]); vecout_byte[2] = unit_float_to_uchar_clamp(vecout[2]); } -int curvemapping_RGBA_does_something(const CurveMapping *cumap) +int BKE_curvemapping_RGBA_does_something(const CurveMapping *cumap) { int a; @@ -1187,7 +1197,7 @@ int curvemapping_RGBA_does_something(const CurveMapping *cumap) return 0; } -void curvemapping_initialize(CurveMapping *cumap) +void BKE_curvemapping_initialize(CurveMapping *cumap) { int a; @@ -1202,7 +1212,7 @@ void curvemapping_initialize(CurveMapping *cumap) } } -void curvemapping_table_RGBA(const CurveMapping *cumap, float **array, int *size) +void BKE_curvemapping_table_RGBA(const CurveMapping *cumap, float **array, int *size) { int a; @@ -1520,10 +1530,10 @@ static void scopes_update_finalize(void *__restrict userdata, void *__restrict u } } -void scopes_update(Scopes *scopes, - ImBuf *ibuf, - const ColorManagedViewSettings *view_settings, - const ColorManagedDisplaySettings *display_settings) +void BKE_scopes_update(Scopes *scopes, + ImBuf *ibuf, + const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) { int a; unsigned int nl, na, nr, ng, nb; @@ -1685,7 +1695,7 @@ void scopes_update(Scopes *scopes, scopes->ok = 1; } -void scopes_free(Scopes *scopes) +void BKE_scopes_free(Scopes *scopes) { if (scopes->waveform_1) { MEM_freeN(scopes->waveform_1); @@ -1705,7 +1715,7 @@ void scopes_free(Scopes *scopes) } } -void scopes_new(Scopes *scopes) +void BKE_scopes_new(Scopes *scopes) { scopes->accuracy = 30.0; scopes->hist.mode = HISTO_MODE_RGB; @@ -1781,7 +1791,7 @@ void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings new_settings->gamma = settings->gamma; if (settings->curve_mapping) { - new_settings->curve_mapping = curvemapping_copy(settings->curve_mapping); + new_settings->curve_mapping = BKE_curvemapping_copy(settings->curve_mapping); } else { new_settings->curve_mapping = NULL; @@ -1791,7 +1801,7 @@ void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings void BKE_color_managed_view_settings_free(ColorManagedViewSettings *settings) { if (settings->curve_mapping) { - curvemapping_free(settings->curve_mapping); + BKE_curvemapping_free(settings->curve_mapping); } } diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 03530fc76b6..1fb25375159 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -117,7 +117,7 @@ static int neighStraightY[8] = {0, 1, 0, -1, 1, 1, -1, -1}; /* brush mesh raycast status */ #define HIT_VOLUME 1 #define HIT_PROXIMITY 2 -/* dynamicPaint_findNeighbourPixel() return codes */ +/* dynamicPaint_findNeighborPixel() return codes */ #define NOT_FOUND -1 #define ON_MESH_EDGE -2 #define OUT_OF_TEXTURE -3 @@ -233,7 +233,7 @@ typedef struct PaintUVPoint { unsigned int v1, v2, v3; /** If this pixel isn't uv mapped to any face, but it's neighboring pixel is. */ - unsigned int neighbour_pixel; + unsigned int neighbor_pixel; } PaintUVPoint; typedef struct ImgSeqFormatData { @@ -2263,7 +2263,7 @@ static void dynamic_paint_create_uv_surface_direct_cb( /* Init per pixel settings */ tPoint->tri_index = -1; - tPoint->neighbour_pixel = -1; + tPoint->neighbor_pixel = -1; tPoint->pixel_index = index; /* Actual pixel center, used when collision is found */ @@ -2377,7 +2377,7 @@ static void dynamic_paint_create_uv_surface_neighbor_cb( const int ind = (tx + u) + w * (ty + v); /* if neighbor has index */ - if (tempPoints[ind].neighbour_pixel == -1 && tempPoints[ind].tri_index != -1) { + if (tempPoints[ind].neighbor_pixel == -1 && tempPoints[ind].tri_index != -1) { float uv[2]; const int i = tempPoints[ind].tri_index; const float *uv1 = mloopuv[mlooptri[i].tri[0]].uv; @@ -2387,13 +2387,13 @@ static void dynamic_paint_create_uv_surface_neighbor_cb( /* tri index */ /* There is a low possibility of actually having a neighbor point which tri is * already set from another neighbor in a separate thread here. - * Checking for both tri_index and neighbour_pixel above reduces that probability + * Checking for both tri_index and neighbor_pixel above reduces that probability * but it remains possible. - * That atomic op (and its memory fence) ensures tPoint->neighbour_pixel is set - * to non--1 *before* its tri_index is set (i.e. that it cannot be used a neighbour). + * That atomic op (and its memory fence) ensures tPoint->neighbor_pixel is set + * to non--1 *before* its tri_index is set (i.e. that it cannot be used a neighbor). */ - tPoint->neighbour_pixel = ind - 1; - atomic_add_and_fetch_uint32(&tPoint->neighbour_pixel, 1); + tPoint->neighbor_pixel = ind - 1; + atomic_add_and_fetch_uint32(&tPoint->neighbor_pixel, 1); tPoint->tri_index = i; /* Now calculate pixel data for this pixel as it was on polygon surface */ @@ -2467,13 +2467,13 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa * px, py : origin pixel x and y * n_index : lookup direction index (use neighX, neighY to get final index) */ -static int dynamic_paint_find_neighbour_pixel(const DynamicPaintCreateUVSurfaceData *data, - const MeshElemMap *vert_to_looptri_map, - const int w, - const int h, - const int px, - const int py, - const int n_index) +static int dynamic_paint_find_neighbor_pixel(const DynamicPaintCreateUVSurfaceData *data, + const MeshElemMap *vert_to_looptri_map, + const int w, + const int h, + const int px, + const int py, + const int n_index) { /* Note: Current method only uses polygon edges to detect neighboring pixels. * -> It doesn't always lead to the optimum pixel but is accurate enough @@ -2494,7 +2494,7 @@ static int dynamic_paint_find_neighbour_pixel(const DynamicPaintCreateUVSurfaceD /* Check if shifted point is on same face -> it's a correct neighbor * (and if it isn't marked as an "edge pixel") */ - if ((tPoint->tri_index == cPoint->tri_index) && (tPoint->neighbour_pixel == -1)) { + if ((tPoint->tri_index == cPoint->tri_index) && (tPoint->neighbor_pixel == -1)) { return (x + w * y); } @@ -2504,7 +2504,7 @@ static int dynamic_paint_find_neighbour_pixel(const DynamicPaintCreateUVSurfaceD * !! Replace with "is uv faces linked" check !! * This should work fine as long as uv island margin is > 1 pixel. */ - if ((tPoint->tri_index != -1) && (tPoint->neighbour_pixel == -1)) { + if ((tPoint->tri_index != -1) && (tPoint->neighbor_pixel == -1)) { return (x + w * y); } @@ -2691,8 +2691,8 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa } /* If final point is an "edge pixel", use it's "real" neighbor instead */ - if (tempPoints[final_index].neighbour_pixel != -1) { - final_index = tempPoints[final_index].neighbour_pixel; + if (tempPoints[final_index].neighbor_pixel != -1) { + final_index = tempPoints[final_index].neighbor_pixel; /* If we ended up to our origin point */ if (final_index == (px + w * py)) { @@ -3016,7 +3016,7 @@ int dynamicPaint_createUVSurface(Scene *scene, ed->n_index[final_index[index]] = n_pos; ed->n_num[final_index[index]] = 0; - if (tempPoints[index].neighbour_pixel != -1) { + if (tempPoints[index].neighbor_pixel != -1) { ed->flags[final_index[index]] |= ADJ_BORDER_PIXEL; total_border++; } @@ -3024,7 +3024,7 @@ int dynamicPaint_createUVSurface(Scene *scene, for (int i = 0; i < 8; i++) { /* Try to find a neighboring pixel in defined direction. * If not found, -1 is returned */ - const int n_target = dynamic_paint_find_neighbour_pixel( + const int n_target = dynamic_paint_find_neighbor_pixel( &data, vert_to_looptri_map, w, h, tx, ty, i); if (n_target >= 0 && n_target != index) { @@ -3084,7 +3084,7 @@ int dynamicPaint_createUVSurface(Scene *scene, const int fidx = final_index[index]; if (tempPoints[index].tri_index != -1) { - int nidx = tempPoints[index].neighbour_pixel; + int nidx = tempPoints[index].neighbor_pixel; fprintf(dump_file, "%d\t%d,%d\t%u\t%d,%d\t%d\t", fidx, @@ -3186,7 +3186,7 @@ int dynamicPaint_createUVSurface(Scene *scene, pPoint->alpha = 1.0f; /* Every pixel that is assigned as "edge pixel" gets blue color */ - if (uvPoint->neighbour_pixel != -1) { + if (uvPoint->neighbor_pixel != -1) { pPoint->color[2] = 1.0f; } /* and every pixel that finally got an polygon gets red color */ diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 731e9aff926..3ae20642b15 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1632,13 +1632,13 @@ float BKE_gpencil_multiframe_falloff_calc( if (gpf->framenum < actnum) { fnum = (float)(gpf->framenum - f_init) / (actnum - f_init); fnum *= 0.5f; - value = curvemapping_evaluateF(cur_falloff, 0, fnum); + value = BKE_curvemapping_evaluateF(cur_falloff, 0, fnum); } /* frames to the left of the active frame */ else if (gpf->framenum > actnum) { fnum = (float)(gpf->framenum - actnum) / (f_end - actnum); fnum *= 0.5f; - value = curvemapping_evaluateF(cur_falloff, 0, fnum + 0.5f); + value = BKE_curvemapping_evaluateF(cur_falloff, 0, fnum + 0.5f); } else { value = 1.0f; diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c index 271bf58fcc6..75c9e0e42a5 100644 --- a/source/blender/blenkernel/intern/light.c +++ b/source/blender/blenkernel/intern/light.c @@ -69,7 +69,7 @@ void BKE_light_init(Light *la) la->coeff_const = 1.0f; la->coeff_lin = 0.0f; la->coeff_quad = 0.0f; - la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); + la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); la->cascade_max_dist = 200.0f; la->cascade_count = 4; la->cascade_exponent = 0.8f; @@ -82,7 +82,7 @@ void BKE_light_init(Light *la) la->att_dist = 40.0f; la->sun_angle = DEG2RADF(0.526f); - curvemapping_initialize(la->curfalloff); + BKE_curvemapping_initialize(la->curfalloff); } Light *BKE_light_add(Main *bmain, const char *name) @@ -108,7 +108,7 @@ Light *BKE_light_add(Main *bmain, const char *name) */ void BKE_light_copy_data(Main *bmain, Light *la_dst, const Light *la_src, const int flag) { - la_dst->curfalloff = curvemapping_copy(la_src->curfalloff); + la_dst->curfalloff = BKE_curvemapping_copy(la_src->curfalloff); if (la_src->nodetree) { /* Note: nodetree is *not* in bmain, however this specific case is handled at lower level @@ -145,7 +145,7 @@ Light *BKE_light_localize(Light *la) Light *lan = BKE_libblock_copy_for_localize(&la->id); - lan->curfalloff = curvemapping_copy(la->curfalloff); + lan->curfalloff = BKE_curvemapping_copy(la->curfalloff); if (la->nodetree) { lan->nodetree = ntreeLocalize(la->nodetree); @@ -167,7 +167,7 @@ void BKE_light_free(Light *la) { BKE_animdata_free((ID *)la, false); - curvemapping_free(la->curfalloff); + BKE_curvemapping_free(la->curfalloff); /* is no lib link block, but light extension */ if (la->nodetree) { diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index 31e6d2e89e5..7bfe5a7c8ff 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -512,13 +512,13 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_add(FreestyleLineStyle *linestyl switch (type) { case LS_MODIFIER_ALONG_STROKE: { LineStyleAlphaModifier_AlongStroke *p = (LineStyleAlphaModifier_AlongStroke *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); break; } case LS_MODIFIER_DISTANCE_FROM_CAMERA: { LineStyleAlphaModifier_DistanceFromCamera *p = (LineStyleAlphaModifier_DistanceFromCamera *) m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->range_min = 0.0f; p->range_max = 10000.0f; break; @@ -527,25 +527,25 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_add(FreestyleLineStyle *linestyl LineStyleAlphaModifier_DistanceFromObject *p = (LineStyleAlphaModifier_DistanceFromObject *) m; p->target = NULL; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->range_min = 0.0f; p->range_max = 10000.0f; break; } case LS_MODIFIER_MATERIAL: { LineStyleAlphaModifier_Material *p = (LineStyleAlphaModifier_Material *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->mat_attr = LS_MODIFIER_MATERIAL_LINE_A; break; } case LS_MODIFIER_TANGENT: { LineStyleAlphaModifier_Tangent *p = (LineStyleAlphaModifier_Tangent *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); break; } case LS_MODIFIER_NOISE: { LineStyleAlphaModifier_Noise *p = (LineStyleAlphaModifier_Noise *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); ((LineStyleAlphaModifier_Noise *)m)->amplitude = 10.0f; ((LineStyleAlphaModifier_Noise *)m)->period = 10.0f; ((LineStyleAlphaModifier_Noise *)m)->seed = 512; @@ -553,14 +553,14 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_add(FreestyleLineStyle *linestyl } case LS_MODIFIER_CREASE_ANGLE: { LineStyleAlphaModifier_CreaseAngle *p = (LineStyleAlphaModifier_CreaseAngle *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); ((LineStyleAlphaModifier_CreaseAngle *)m)->min_angle = 0.0f; ((LineStyleAlphaModifier_CreaseAngle *)m)->max_angle = DEG2RADF(180.0f); break; } case LS_MODIFIER_CURVATURE_3D: { LineStyleAlphaModifier_Curvature_3D *p = (LineStyleAlphaModifier_Curvature_3D *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); ((LineStyleAlphaModifier_Curvature_3D *)m)->min_curvature = 0.0f; ((LineStyleAlphaModifier_Curvature_3D *)m)->max_curvature = 0.5f; break; @@ -588,7 +588,7 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty case LS_MODIFIER_ALONG_STROKE: { LineStyleAlphaModifier_AlongStroke *p = (LineStyleAlphaModifier_AlongStroke *)m; LineStyleAlphaModifier_AlongStroke *q = (LineStyleAlphaModifier_AlongStroke *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; break; } @@ -597,7 +597,7 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty m; LineStyleAlphaModifier_DistanceFromCamera *q = (LineStyleAlphaModifier_DistanceFromCamera *) new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->range_min = p->range_min; q->range_max = p->range_max; @@ -612,7 +612,7 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty id_us_plus(&p->target->id); } q->target = p->target; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->range_min = p->range_min; q->range_max = p->range_max; @@ -621,7 +621,7 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty case LS_MODIFIER_MATERIAL: { LineStyleAlphaModifier_Material *p = (LineStyleAlphaModifier_Material *)m; LineStyleAlphaModifier_Material *q = (LineStyleAlphaModifier_Material *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->mat_attr = p->mat_attr; break; @@ -629,14 +629,14 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty case LS_MODIFIER_TANGENT: { LineStyleAlphaModifier_Tangent *p = (LineStyleAlphaModifier_Tangent *)m; LineStyleAlphaModifier_Tangent *q = (LineStyleAlphaModifier_Tangent *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; break; } case LS_MODIFIER_NOISE: { LineStyleAlphaModifier_Noise *p = (LineStyleAlphaModifier_Noise *)m; LineStyleAlphaModifier_Noise *q = (LineStyleAlphaModifier_Noise *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->amplitude = p->amplitude; q->period = p->period; @@ -646,7 +646,7 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty case LS_MODIFIER_CREASE_ANGLE: { LineStyleAlphaModifier_CreaseAngle *p = (LineStyleAlphaModifier_CreaseAngle *)m; LineStyleAlphaModifier_CreaseAngle *q = (LineStyleAlphaModifier_CreaseAngle *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->min_angle = p->min_angle; q->max_angle = p->max_angle; @@ -655,7 +655,7 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty case LS_MODIFIER_CURVATURE_3D: { LineStyleAlphaModifier_Curvature_3D *p = (LineStyleAlphaModifier_Curvature_3D *)m; LineStyleAlphaModifier_Curvature_3D *q = (LineStyleAlphaModifier_Curvature_3D *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->min_curvature = p->min_curvature; q->max_curvature = p->max_curvature; @@ -676,28 +676,28 @@ int BKE_linestyle_alpha_modifier_remove(FreestyleLineStyle *linestyle, LineStyle } switch (m->type) { case LS_MODIFIER_ALONG_STROKE: - curvemapping_free(((LineStyleAlphaModifier_AlongStroke *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_AlongStroke *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_CAMERA: - curvemapping_free(((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_OBJECT: - curvemapping_free(((LineStyleAlphaModifier_DistanceFromObject *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_DistanceFromObject *)m)->curve); break; case LS_MODIFIER_MATERIAL: - curvemapping_free(((LineStyleAlphaModifier_Material *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_Material *)m)->curve); break; case LS_MODIFIER_TANGENT: - curvemapping_free(((LineStyleAlphaModifier_Tangent *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_Tangent *)m)->curve); break; case LS_MODIFIER_NOISE: - curvemapping_free(((LineStyleAlphaModifier_Noise *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_Noise *)m)->curve); break; case LS_MODIFIER_CREASE_ANGLE: - curvemapping_free(((LineStyleAlphaModifier_CreaseAngle *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_CreaseAngle *)m)->curve); break; case LS_MODIFIER_CURVATURE_3D: - curvemapping_free(((LineStyleAlphaModifier_Curvature_3D *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_Curvature_3D *)m)->curve); break; } BLI_freelinkN(&linestyle->alpha_modifiers, m); @@ -755,7 +755,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line switch (type) { case LS_MODIFIER_ALONG_STROKE: { LineStyleThicknessModifier_AlongStroke *p = (LineStyleThicknessModifier_AlongStroke *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->value_min = 0.0f; p->value_max = 1.0f; break; @@ -763,7 +763,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line case LS_MODIFIER_DISTANCE_FROM_CAMERA: { LineStyleThicknessModifier_DistanceFromCamera *p = (LineStyleThicknessModifier_DistanceFromCamera *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->range_min = 0.0f; p->range_max = 1000.0f; p->value_min = 0.0f; @@ -774,7 +774,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line LineStyleThicknessModifier_DistanceFromObject *p = (LineStyleThicknessModifier_DistanceFromObject *)m; p->target = NULL; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->range_min = 0.0f; p->range_max = 1000.0f; p->value_min = 0.0f; @@ -783,7 +783,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line } case LS_MODIFIER_MATERIAL: { LineStyleThicknessModifier_Material *p = (LineStyleThicknessModifier_Material *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->mat_attr = LS_MODIFIER_MATERIAL_LINE; p->value_min = 0.0f; p->value_max = 1.0f; @@ -798,7 +798,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line } case LS_MODIFIER_TANGENT: { LineStyleThicknessModifier_Tangent *p = (LineStyleThicknessModifier_Tangent *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->min_thickness = 1.0f; p->max_thickness = 10.0f; break; @@ -813,7 +813,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line } case LS_MODIFIER_CREASE_ANGLE: { LineStyleThicknessModifier_CreaseAngle *p = (LineStyleThicknessModifier_CreaseAngle *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->min_angle = 0.0f; p->max_angle = DEG2RADF(180.0f); p->min_thickness = 1.0f; @@ -822,7 +822,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line } case LS_MODIFIER_CURVATURE_3D: { LineStyleThicknessModifier_Curvature_3D *p = (LineStyleThicknessModifier_Curvature_3D *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->min_curvature = 0.0f; p->max_curvature = 0.5f; p->min_thickness = 1.0f; @@ -855,7 +855,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin case LS_MODIFIER_ALONG_STROKE: { LineStyleThicknessModifier_AlongStroke *p = (LineStyleThicknessModifier_AlongStroke *)m; LineStyleThicknessModifier_AlongStroke *q = (LineStyleThicknessModifier_AlongStroke *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->value_min = p->value_min; q->value_max = p->value_max; @@ -866,7 +866,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin (LineStyleThicknessModifier_DistanceFromCamera *)m; LineStyleThicknessModifier_DistanceFromCamera *q = (LineStyleThicknessModifier_DistanceFromCamera *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->range_min = p->range_min; q->range_max = p->range_max; @@ -883,7 +883,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) { id_us_plus((ID *)q->target); } - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->range_min = p->range_min; q->range_max = p->range_max; @@ -894,7 +894,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin case LS_MODIFIER_MATERIAL: { LineStyleThicknessModifier_Material *p = (LineStyleThicknessModifier_Material *)m; LineStyleThicknessModifier_Material *q = (LineStyleThicknessModifier_Material *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->mat_attr = p->mat_attr; q->value_min = p->value_min; @@ -912,7 +912,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin case LS_MODIFIER_TANGENT: { LineStyleThicknessModifier_Tangent *p = (LineStyleThicknessModifier_Tangent *)m; LineStyleThicknessModifier_Tangent *q = (LineStyleThicknessModifier_Tangent *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->min_thickness = p->min_thickness; q->max_thickness = p->max_thickness; @@ -931,7 +931,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin LineStyleThicknessModifier_Curvature_3D *p = (LineStyleThicknessModifier_Curvature_3D *)m; LineStyleThicknessModifier_Curvature_3D *q = (LineStyleThicknessModifier_Curvature_3D *) new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->min_curvature = p->min_curvature; q->max_curvature = p->max_curvature; @@ -942,7 +942,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin case LS_MODIFIER_CREASE_ANGLE: { LineStyleThicknessModifier_CreaseAngle *p = (LineStyleThicknessModifier_CreaseAngle *)m; LineStyleThicknessModifier_CreaseAngle *q = (LineStyleThicknessModifier_CreaseAngle *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->min_angle = p->min_angle; q->max_angle = p->max_angle; @@ -965,21 +965,21 @@ int BKE_linestyle_thickness_modifier_remove(FreestyleLineStyle *linestyle, LineS } switch (m->type) { case LS_MODIFIER_ALONG_STROKE: - curvemapping_free(((LineStyleThicknessModifier_AlongStroke *)m)->curve); + BKE_curvemapping_free(((LineStyleThicknessModifier_AlongStroke *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_CAMERA: - curvemapping_free(((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve); + BKE_curvemapping_free(((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_OBJECT: - curvemapping_free(((LineStyleThicknessModifier_DistanceFromObject *)m)->curve); + BKE_curvemapping_free(((LineStyleThicknessModifier_DistanceFromObject *)m)->curve); break; case LS_MODIFIER_MATERIAL: - curvemapping_free(((LineStyleThicknessModifier_Material *)m)->curve); + BKE_curvemapping_free(((LineStyleThicknessModifier_Material *)m)->curve); break; case LS_MODIFIER_CALLIGRAPHY: break; case LS_MODIFIER_TANGENT: - curvemapping_free(((LineStyleThicknessModifier_Tangent *)m)->curve); + BKE_curvemapping_free(((LineStyleThicknessModifier_Tangent *)m)->curve); break; case LS_MODIFIER_NOISE: break; diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 0e93c80ecb5..4a41ffbfa8c 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -658,15 +658,16 @@ void BKE_paint_cavity_curve_preset(Paint *p, int preset) CurveMap *cm = NULL; if (!p->cavity_curve) { - p->cavity_curve = curvemapping_add(1, 0, 0, 1, 1); + p->cavity_curve = BKE_curvemapping_add(1, 0, 0, 1, 1); } cm = p->cavity_curve->cm; cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; p->cavity_curve->preset = preset; - curvemap_reset(cm, &p->cavity_curve->clipr, p->cavity_curve->preset, CURVEMAP_SLOPE_POSITIVE); - curvemapping_changed(p->cavity_curve, false); + BKE_curvemap_reset( + cm, &p->cavity_curve->clipr, p->cavity_curve->preset, CURVEMAP_SLOPE_POSITIVE); + BKE_curvemapping_changed(p->cavity_curve, false); } eObjectMode BKE_paint_object_mode_from_paintmode(ePaintMode mode) @@ -778,7 +779,7 @@ void BKE_paint_init(Main *bmain, Scene *sce, ePaintMode mode, const char col[3]) void BKE_paint_free(Paint *paint) { - curvemapping_free(paint->cavity_curve); + BKE_curvemapping_free(paint->cavity_curve); MEM_SAFE_FREE(paint->tool_slots); } @@ -789,7 +790,7 @@ void BKE_paint_free(Paint *paint) void BKE_paint_copy(Paint *src, Paint *tar, const int flag) { tar->brush = src->brush; - tar->cavity_curve = curvemapping_copy(src->cavity_curve); + tar->cavity_curve = BKE_curvemapping_copy(src->cavity_curve); tar->tool_slots = MEM_dupallocN(src->tool_slots); if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) { diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 9cc49e39231..da00a044009 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -494,13 +494,13 @@ void BKE_particlesettings_free(ParticleSettings *part) } if (part->clumpcurve) { - curvemapping_free(part->clumpcurve); + BKE_curvemapping_free(part->clumpcurve); } if (part->roughcurve) { - curvemapping_free(part->roughcurve); + BKE_curvemapping_free(part->roughcurve); } if (part->twistcurve) { - curvemapping_free(part->twistcurve); + BKE_curvemapping_free(part->twistcurve); } BKE_partdeflect_free(part->pd); @@ -2060,10 +2060,10 @@ int do_guides(Depsgraph *depsgraph, } if (clumpcurve) { - curvemapping_changed_all(clumpcurve); + BKE_curvemapping_changed_all(clumpcurve); } if (roughcurve) { - curvemapping_changed_all(roughcurve); + BKE_curvemapping_changed_all(roughcurve); } { @@ -2368,22 +2368,22 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx, /* prepare curvemapping tables */ if ((part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && part->clumpcurve) { - ctx->clumpcurve = curvemapping_copy(part->clumpcurve); - curvemapping_changed_all(ctx->clumpcurve); + ctx->clumpcurve = BKE_curvemapping_copy(part->clumpcurve); + BKE_curvemapping_changed_all(ctx->clumpcurve); } else { ctx->clumpcurve = NULL; } if ((part->child_flag & PART_CHILD_USE_ROUGH_CURVE) && part->roughcurve) { - ctx->roughcurve = curvemapping_copy(part->roughcurve); - curvemapping_changed_all(ctx->roughcurve); + ctx->roughcurve = BKE_curvemapping_copy(part->roughcurve); + BKE_curvemapping_changed_all(ctx->roughcurve); } else { ctx->roughcurve = NULL; } if ((part->child_flag & PART_CHILD_USE_TWIST_CURVE) && part->twistcurve) { - ctx->twistcurve = curvemapping_copy(part->twistcurve); - curvemapping_changed_all(ctx->twistcurve); + ctx->twistcurve = BKE_curvemapping_copy(part->twistcurve); + BKE_curvemapping_changed_all(ctx->twistcurve); } else { ctx->twistcurve = NULL; @@ -3719,42 +3719,42 @@ ParticleSettings *BKE_particlesettings_add(Main *bmain, const char *name) void BKE_particlesettings_clump_curve_init(ParticleSettings *part) { - CurveMapping *cumap = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + CurveMapping *cumap = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); cumap->cm[0].curve[0].x = 0.0f; cumap->cm[0].curve[0].y = 1.0f; cumap->cm[0].curve[1].x = 1.0f; cumap->cm[0].curve[1].y = 1.0f; - curvemapping_initialize(cumap); + BKE_curvemapping_initialize(cumap); part->clumpcurve = cumap; } void BKE_particlesettings_rough_curve_init(ParticleSettings *part) { - CurveMapping *cumap = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + CurveMapping *cumap = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); cumap->cm[0].curve[0].x = 0.0f; cumap->cm[0].curve[0].y = 1.0f; cumap->cm[0].curve[1].x = 1.0f; cumap->cm[0].curve[1].y = 1.0f; - curvemapping_initialize(cumap); + BKE_curvemapping_initialize(cumap); part->roughcurve = cumap; } void BKE_particlesettings_twist_curve_init(ParticleSettings *part) { - CurveMapping *cumap = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + CurveMapping *cumap = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); cumap->cm[0].curve[0].x = 0.0f; cumap->cm[0].curve[0].y = 1.0f; cumap->cm[0].curve[1].x = 1.0f; cumap->cm[0].curve[1].y = 1.0f; - curvemapping_initialize(cumap); + BKE_curvemapping_initialize(cumap); part->twistcurve = cumap; } @@ -3780,13 +3780,13 @@ void BKE_particlesettings_copy_data(Main *UNUSED(bmain), part_dst->fluid = MEM_dupallocN(part_src->fluid); if (part_src->clumpcurve) { - part_dst->clumpcurve = curvemapping_copy(part_src->clumpcurve); + part_dst->clumpcurve = BKE_curvemapping_copy(part_src->clumpcurve); } if (part_src->roughcurve) { - part_dst->roughcurve = curvemapping_copy(part_src->roughcurve); + part_dst->roughcurve = BKE_curvemapping_copy(part_src->roughcurve); } if (part_src->twistcurve) { - part_dst->twistcurve = curvemapping_copy(part_src->twistcurve); + part_dst->twistcurve = BKE_curvemapping_copy(part_src->twistcurve); } part_dst->boids = boid_copy_settings(part_src->boids); diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c index b74fd3ff684..3b02e010e7f 100644 --- a/source/blender/blenkernel/intern/particle_child.c +++ b/source/blender/blenkernel/intern/particle_child.c @@ -597,7 +597,8 @@ static float do_clump_level(float result[3], float clump = 0.0f; if (clumpcurve) { - clump = pa_clump * (1.0f - clamp_f(curvemapping_evaluateF(clumpcurve, 0, time), 0.0f, 1.0f)); + clump = pa_clump * + (1.0f - clamp_f(BKE_curvemapping_evaluateF(clumpcurve, 0, time), 0.0f, 1.0f)); interp_v3_v3v3(result, co, par_co, clump); } @@ -714,7 +715,7 @@ static void do_rough_curve(const float loc[3], return; } - fac *= clamp_f(curvemapping_evaluateF(roughcurve, 0, time), 0.0f, 1.0f); + fac *= clamp_f(BKE_curvemapping_evaluateF(roughcurve, 0, time), 0.0f, 1.0f); copy_v3_v3(rco, loc); mul_v3_fl(rco, time); @@ -749,15 +750,15 @@ static void twist_get_axis(const ParticleChildModifierContext *modifier_ctx, } } -static float curvemapping_integrate_clamped(CurveMapping *curve, - float start, - float end, - float step) +static float BKE_curvemapping_integrate_clamped(CurveMapping *curve, + float start, + float end, + float step) { float integral = 0.0f; float x = start; while (x < end) { - float y = curvemapping_evaluateF(curve, 0, x); + float y = BKE_curvemapping_evaluateF(curve, 0, x); y = clamp_f(y, 0.0f, 1.0f); /* TODO(sergey): Clamp last step to end. */ integral += y * step; @@ -804,7 +805,7 @@ static void do_twist(const ParticleChildModifierContext *modifier_ctx, } if (twist_curve != NULL) { const int num_segments = twist_num_segments(modifier_ctx); - angle *= curvemapping_integrate_clamped(twist_curve, 0.0f, time, 1.0f / num_segments); + angle *= BKE_curvemapping_integrate_clamped(twist_curve, 0.0f, time, 1.0f / num_segments); } else { angle *= time; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 5685e5cd05e..31484b59127 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -563,13 +563,13 @@ void psys_thread_context_free(ParticleThreadContext *ctx) BLI_kdtree_3d_free(ctx->tree); if (ctx->clumpcurve != NULL) { - curvemapping_free(ctx->clumpcurve); + BKE_curvemapping_free(ctx->clumpcurve); } if (ctx->roughcurve != NULL) { - curvemapping_free(ctx->roughcurve); + BKE_curvemapping_free(ctx->roughcurve); } if (ctx->twistcurve != NULL) { - curvemapping_free(ctx->twistcurve); + BKE_curvemapping_free(ctx->twistcurve); } } @@ -1958,10 +1958,10 @@ static void sphclassical_density_accum_cb(void *userdata, pfr->data[1] += q / npa->sphdensity; } -static void sphclassical_neighbour_accum_cb(void *userdata, - int index, - const float co[3], - float UNUSED(squared_dist)) +static void sphclassical_neighbor_accum_cb(void *userdata, + int index, + const float co[3], + float UNUSED(squared_dist)) { SPHRangeData *pfr = (SPHRangeData *)userdata; ParticleData *npa = pfr->npsys->particles + index; @@ -2031,7 +2031,7 @@ static void sphclassical_force_cb(void *sphdata_v, pfr.pa = pa; sph_evaluate_func( - NULL, psys, state->co, &pfr, interaction_radius, sphclassical_neighbour_accum_cb); + NULL, psys, state->co, &pfr, interaction_radius, sphclassical_neighbor_accum_cb); pressure = stiffness * (pow7f(pa->sphdensity / rest_density) - 1.0f); /* multiply by mass so that we return a force, not accel */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index b582b4f54bd..1ef93427253 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -176,10 +176,10 @@ ToolSettings *BKE_toolsettings_copy(ToolSettings *toolsettings, const int flag) ts->particle.object = NULL; /* duplicate Grease Pencil interpolation curve */ - ts->gp_interpolate.custom_ipo = curvemapping_copy(ts->gp_interpolate.custom_ipo); + ts->gp_interpolate.custom_ipo = BKE_curvemapping_copy(ts->gp_interpolate.custom_ipo); /* duplicate Grease Pencil multiframe fallof */ - ts->gp_sculpt.cur_falloff = curvemapping_copy(ts->gp_sculpt.cur_falloff); - ts->gp_sculpt.cur_primitive = curvemapping_copy(ts->gp_sculpt.cur_primitive); + ts->gp_sculpt.cur_falloff = BKE_curvemapping_copy(ts->gp_sculpt.cur_falloff); + ts->gp_sculpt.cur_primitive = BKE_curvemapping_copy(ts->gp_sculpt.cur_primitive); return ts; } @@ -212,14 +212,14 @@ void BKE_toolsettings_free(ToolSettings *toolsettings) /* free Grease Pencil interpolation curve */ if (toolsettings->gp_interpolate.custom_ipo) { - curvemapping_free(toolsettings->gp_interpolate.custom_ipo); + BKE_curvemapping_free(toolsettings->gp_interpolate.custom_ipo); } /* free Grease Pencil multiframe falloff curve */ if (toolsettings->gp_sculpt.cur_falloff) { - curvemapping_free(toolsettings->gp_sculpt.cur_falloff); + BKE_curvemapping_free(toolsettings->gp_sculpt.cur_falloff); } if (toolsettings->gp_sculpt.cur_primitive) { - curvemapping_free(toolsettings->gp_sculpt.cur_primitive); + BKE_curvemapping_free(toolsettings->gp_sculpt.cur_primitive); } MEM_freeN(toolsettings); @@ -291,7 +291,7 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons BKE_color_managed_view_settings_copy(&sce_dst->r.bake.im_format.view_settings, &sce_src->r.bake.im_format.view_settings); - curvemapping_copy_data(&sce_dst->r.mblur_shutter_curve, &sce_src->r.mblur_shutter_curve); + BKE_curvemapping_copy_data(&sce_dst->r.mblur_shutter_curve, &sce_src->r.mblur_shutter_curve); /* tool settings */ sce_dst->toolsettings = BKE_toolsettings_copy(sce_dst->toolsettings, flag_subdata); @@ -347,7 +347,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) sce_copy = BKE_scene_add(bmain, sce->id.name + 2); rv = sce_copy->r.views; - curvemapping_free_data(&sce_copy->r.mblur_shutter_curve); + BKE_curvemapping_free_data(&sce_copy->r.mblur_shutter_curve); sce_copy->r = sce->r; sce_copy->r.views = rv; sce_copy->unit = sce->unit; @@ -380,7 +380,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) BKE_color_managed_view_settings_copy(&sce_copy->r.bake.im_format.view_settings, &sce->r.bake.im_format.view_settings); - curvemapping_copy_data(&sce_copy->r.mblur_shutter_curve, &sce->r.mblur_shutter_curve); + BKE_curvemapping_copy_data(&sce_copy->r.mblur_shutter_curve, &sce->r.mblur_shutter_curve); /* viewport display settings */ sce_copy->display = sce->display; @@ -515,7 +515,7 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user) BKE_color_managed_view_settings_free(&sce->view_settings); BKE_previewimg_free(&sce->preview); - curvemapping_free_data(&sce->r.mblur_shutter_curve); + BKE_curvemapping_free_data(&sce->r.mblur_shutter_curve); for (ViewLayer *view_layer = sce->view_layers.first, *view_layer_next; view_layer; view_layer = view_layer_next) { @@ -653,12 +653,12 @@ void BKE_scene_init(Scene *sce) sce->r.unit_line_thickness = 1.0f; mblur_shutter_curve = &sce->r.mblur_shutter_curve; - curvemapping_set_defaults(mblur_shutter_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(mblur_shutter_curve); - curvemap_reset(mblur_shutter_curve->cm, - &mblur_shutter_curve->clipr, - CURVE_PRESET_MAX, - CURVEMAP_SLOPE_POS_NEG); + BKE_curvemapping_set_defaults(mblur_shutter_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(mblur_shutter_curve); + BKE_curvemap_reset(mblur_shutter_curve->cm, + &mblur_shutter_curve->clipr, + CURVE_PRESET_MAX, + CURVEMAP_SLOPE_POS_NEG); sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct"); @@ -704,19 +704,19 @@ void BKE_scene_init(Scene *sce) sce->toolsettings->imapaint.seam_bleed = 2; /* grease pencil multiframe falloff curve */ - sce->toolsettings->gp_sculpt.cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + sce->toolsettings->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_falloff_curve = sce->toolsettings->gp_sculpt.cur_falloff; - curvemapping_initialize(gp_falloff_curve); - curvemap_reset( + BKE_curvemapping_initialize(gp_falloff_curve); + BKE_curvemap_reset( gp_falloff_curve->cm, &gp_falloff_curve->clipr, CURVE_PRESET_GAUSS, CURVEMAP_SLOPE_POSITIVE); - sce->toolsettings->gp_sculpt.cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + sce->toolsettings->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_primitive_curve = sce->toolsettings->gp_sculpt.cur_primitive; - curvemapping_initialize(gp_primitive_curve); - curvemap_reset(gp_primitive_curve->cm, - &gp_primitive_curve->clipr, - CURVE_PRESET_BELL, - CURVEMAP_SLOPE_POSITIVE); + BKE_curvemapping_initialize(gp_primitive_curve); + BKE_curvemap_reset(gp_primitive_curve->cm, + &gp_primitive_curve->clipr, + CURVE_PRESET_BELL, + CURVEMAP_SLOPE_POSITIVE); sce->toolsettings->gp_sculpt.guide.spacing = 20.0f; diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c index aceb8b7e4ad..a7543881dad 100644 --- a/source/blender/blenkernel/intern/seqmodifier.c +++ b/source/blender/blenkernel/intern/seqmodifier.c @@ -293,14 +293,14 @@ static void curves_init_data(SequenceModifierData *smd) { CurvesModifierData *cmd = (CurvesModifierData *)smd; - curvemapping_set_defaults(&cmd->curve_mapping, 4, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_set_defaults(&cmd->curve_mapping, 4, 0.0f, 0.0f, 1.0f, 1.0f); } static void curves_free_data(SequenceModifierData *smd) { CurvesModifierData *cmd = (CurvesModifierData *)smd; - curvemapping_free_data(&cmd->curve_mapping); + BKE_curvemapping_free_data(&cmd->curve_mapping); } static void curves_copy_data(SequenceModifierData *target, SequenceModifierData *smd) @@ -308,7 +308,7 @@ static void curves_copy_data(SequenceModifierData *target, SequenceModifierData CurvesModifierData *cmd = (CurvesModifierData *)smd; CurvesModifierData *cmd_target = (CurvesModifierData *)target; - curvemapping_copy_data(&cmd_target->curve_mapping, &cmd->curve_mapping); + BKE_curvemapping_copy_data(&cmd_target->curve_mapping, &cmd->curve_mapping); } static void curves_apply_threaded(int width, @@ -330,7 +330,7 @@ static void curves_apply_threaded(int width, float *pixel = rect_float + pixel_index; float result[3]; - curvemapping_evaluate_premulRGBF(curve_mapping, result, pixel); + BKE_curvemapping_evaluate_premulRGBF(curve_mapping, result, pixel); if (mask_rect_float) { const float *m = mask_rect_float + pixel_index; @@ -351,7 +351,7 @@ static void curves_apply_threaded(int width, straight_uchar_to_premul_float(tempc, pixel); - curvemapping_evaluate_premulRGBF(curve_mapping, result, tempc); + BKE_curvemapping_evaluate_premulRGBF(curve_mapping, result, tempc); if (mask_rect) { float t[3]; @@ -381,14 +381,14 @@ static void curves_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *m float black[3] = {0.0f, 0.0f, 0.0f}; float white[3] = {1.0f, 1.0f, 1.0f}; - curvemapping_initialize(&cmd->curve_mapping); + BKE_curvemapping_initialize(&cmd->curve_mapping); - curvemapping_premultiply(&cmd->curve_mapping, 0); - curvemapping_set_black_white(&cmd->curve_mapping, black, white); + BKE_curvemapping_premultiply(&cmd->curve_mapping, 0); + BKE_curvemapping_set_black_white(&cmd->curve_mapping, black, white); modifier_apply_threaded(ibuf, mask, curves_apply_threaded, &cmd->curve_mapping); - curvemapping_premultiply(&cmd->curve_mapping, 1); + BKE_curvemapping_premultiply(&cmd->curve_mapping, 1); } static SequenceModifierTypeInfo seqModifier_Curves = { @@ -408,13 +408,13 @@ static void hue_correct_init_data(SequenceModifierData *smd) HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; int c; - curvemapping_set_defaults(&hcmd->curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_set_defaults(&hcmd->curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f); hcmd->curve_mapping.preset = CURVE_PRESET_MID9; for (c = 0; c < 3; c++) { CurveMap *cuma = &hcmd->curve_mapping.cm[c]; - curvemap_reset( + BKE_curvemap_reset( cuma, &hcmd->curve_mapping.clipr, hcmd->curve_mapping.preset, CURVEMAP_SLOPE_POSITIVE); } @@ -426,7 +426,7 @@ static void hue_correct_free_data(SequenceModifierData *smd) { HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; - curvemapping_free_data(&hcmd->curve_mapping); + BKE_curvemapping_free_data(&hcmd->curve_mapping); } static void hue_correct_copy_data(SequenceModifierData *target, SequenceModifierData *smd) @@ -434,7 +434,7 @@ static void hue_correct_copy_data(SequenceModifierData *target, SequenceModifier HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; HueCorrectModifierData *hcmd_target = (HueCorrectModifierData *)target; - curvemapping_copy_data(&hcmd_target->curve_mapping, &hcmd->curve_mapping); + BKE_curvemapping_copy_data(&hcmd_target->curve_mapping, &hcmd->curve_mapping); } static void hue_correct_apply_threaded(int width, @@ -464,15 +464,15 @@ static void hue_correct_apply_threaded(int width, rgb_to_hsv(pixel[0], pixel[1], pixel[2], hsv, hsv + 1, hsv + 2); /* adjust hue, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(curve_mapping, 0, hsv[0]); + f = BKE_curvemapping_evaluateF(curve_mapping, 0, hsv[0]); hsv[0] += f - 0.5f; /* adjust saturation, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(curve_mapping, 1, hsv[0]); + f = BKE_curvemapping_evaluateF(curve_mapping, 1, hsv[0]); hsv[1] *= (f * 2.0f); /* adjust value, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(curve_mapping, 2, hsv[0]); + f = BKE_curvemapping_evaluateF(curve_mapping, 2, hsv[0]); hsv[2] *= (f * 2.f); hsv[0] = hsv[0] - floorf(hsv[0]); /* mod 1.0 */ @@ -506,7 +506,7 @@ static void hue_correct_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImB { HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; - curvemapping_initialize(&hcmd->curve_mapping); + BKE_curvemapping_initialize(&hcmd->curve_mapping); modifier_apply_threaded(ibuf, mask, hue_correct_apply_threaded, &hcmd->curve_mapping); } diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 688af539bbb..74873db179d 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1428,13 +1428,13 @@ static void emit_from_particles(Object *flow_ob, /* prepare curvemapping tables */ if ((psys->part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && psys->part->clumpcurve) { - curvemapping_changed_all(psys->part->clumpcurve); + BKE_curvemapping_changed_all(psys->part->clumpcurve); } if ((psys->part->child_flag & PART_CHILD_USE_ROUGH_CURVE) && psys->part->roughcurve) { - curvemapping_changed_all(psys->part->roughcurve); + BKE_curvemapping_changed_all(psys->part->roughcurve); } if ((psys->part->child_flag & PART_CHILD_USE_TWIST_CURVE) && psys->part->twistcurve) { - curvemapping_changed_all(psys->part->twistcurve); + BKE_curvemapping_changed_all(psys->part->twistcurve); } /* initialize particle cache */ diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index b2ea5b12603..562e2814efa 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -703,50 +703,6 @@ bool txt_cursor_is_line_end(Text *text) /* Cursor movement functions */ /*****************************/ -int txt_utf8_offset_to_index(const char *str, int offset) -{ - int index = 0, pos = 0; - while (pos != offset) { - pos += BLI_str_utf8_size(str + pos); - index++; - } - return index; -} - -int txt_utf8_index_to_offset(const char *str, int index) -{ - int offset = 0, pos = 0; - while (pos != index) { - offset += BLI_str_utf8_size(str + offset); - pos++; - } - return offset; -} - -int txt_utf8_offset_to_column(const char *str, int offset) -{ - int column = 0, pos = 0; - while (pos < offset) { - column += BLI_str_utf8_char_width_safe(str + pos); - pos += BLI_str_utf8_size_safe(str + pos); - } - return column; -} - -int txt_utf8_column_to_offset(const char *str, int column) -{ - int offset = 0, pos = 0, col; - while (*(str + offset) && pos < column) { - col = BLI_str_utf8_char_width_safe(str + offset); - if (pos + col > column) { - break; - } - offset += BLI_str_utf8_size_safe(str + offset); - pos += col; - } - return offset; -} - void txt_move_up(Text *text, const bool sel) { TextLine **linep; @@ -764,9 +720,9 @@ void txt_move_up(Text *text, const bool sel) } if ((*linep)->prev) { - int column = txt_utf8_offset_to_column((*linep)->line, *charp); + int column = BLI_str_utf8_offset_to_column((*linep)->line, *charp); *linep = (*linep)->prev; - *charp = txt_utf8_column_to_offset((*linep)->line, column); + *charp = BLI_str_utf8_offset_from_column((*linep)->line, column); } else { txt_move_bol(text, sel); @@ -794,9 +750,9 @@ void txt_move_down(Text *text, const bool sel) } if ((*linep)->next) { - int column = txt_utf8_offset_to_column((*linep)->line, *charp); + int column = BLI_str_utf8_offset_to_column((*linep)->line, *charp); *linep = (*linep)->next; - *charp = txt_utf8_column_to_offset((*linep)->line, column); + *charp = BLI_str_utf8_offset_from_column((*linep)->line, column); } else { txt_move_eol(text, sel); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 9baa8bd20e1..ad7c5e3f660 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -659,15 +659,15 @@ void BKE_texture_pointdensity_init_data(PointDensity *pd) pd->object = NULL; pd->psys = 0; pd->psys_cache_space = TEX_PD_WORLDSPACE; - pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1); + pd->falloff_curve = BKE_curvemapping_add(1, 0, 0, 1, 1); pd->falloff_curve->preset = CURVE_PRESET_LINE; pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; - curvemap_reset(pd->falloff_curve->cm, - &pd->falloff_curve->clipr, - pd->falloff_curve->preset, - CURVEMAP_SLOPE_POSITIVE); - curvemapping_changed(pd->falloff_curve, false); + BKE_curvemap_reset(pd->falloff_curve->cm, + &pd->falloff_curve->clipr, + pd->falloff_curve->preset, + CURVEMAP_SLOPE_POSITIVE); + BKE_curvemapping_changed(pd->falloff_curve, false); } PointDensity *BKE_texture_pointdensity_add(void) @@ -687,7 +687,7 @@ PointDensity *BKE_texture_pointdensity_copy(const PointDensity *pd, const int UN if (pdn->coba) { pdn->coba = MEM_dupallocN(pdn->coba); } - pdn->falloff_curve = curvemapping_copy(pdn->falloff_curve); /* can be NULL */ + pdn->falloff_curve = BKE_curvemapping_copy(pdn->falloff_curve); /* can be NULL */ return pdn; } @@ -706,7 +706,7 @@ void BKE_texture_pointdensity_free_data(PointDensity *pd) pd->coba = NULL; } - curvemapping_free(pd->falloff_curve); /* can be NULL */ + BKE_curvemapping_free(pd->falloff_curve); /* can be NULL */ } void BKE_texture_pointdensity_free(PointDensity *pd) diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index 03eb2b890cf..3bc3be8b022 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -140,12 +140,18 @@ MINLINE void float_to_byte_dither_v3( #define rgba_float_args_set_ch(col, r, g, b, a) \ rgba_float_args_set(col, (r) / 255.0f, (g) / 255.0f, (b) / 255.0f, (a) / 255.0f) -MINLINE void rgba_char_args_set( - char col[4], const char r, const char g, const char b, const char a); +MINLINE void rgba_uchar_args_set(unsigned char col[4], + const unsigned char r, + const unsigned char g, + const unsigned char b, + const unsigned char a); MINLINE void rgba_float_args_set( float col[4], const float r, const float g, const float b, const float a); -MINLINE void rgba_char_args_test_set( - char col[4], const char r, const char g, const char b, const char a); +MINLINE void rgba_uchar_args_test_set(unsigned char col[4], + const unsigned char r, + const unsigned char g, + const unsigned char b, + const unsigned char a); MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack); void blackbody_temperature_to_rgb_table(float *r_table, int width, float min, float max); diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index c1618061b38..b51a916ba0b 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -642,6 +642,14 @@ void projmat_dimensions(const float projmat[4][4], float *r_near, float *r_far); +void projmat_from_subregion(const float projmat[4][4], + const int win_size[2], + const int x_min, + const int x_max, + const int y_min, + const int y_max, + float r_projmat[4][4]); + int box_clip_bounds_m4(float boundbox[2][3], const float bounds[4], float winmat[4][4]); void box_minmax_bounds_m4(float min[3], float max[3], float boundbox[2][3], float mat[4][4]); diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h index 70586b671b4..0cdd6e94610 100644 --- a/source/blender/blenlib/BLI_string_utf8.h +++ b/source/blender/blenlib/BLI_string_utf8.h @@ -89,6 +89,11 @@ size_t BLI_str_partition_ex_utf8(const char *str, const char **suf, const bool from_right) ATTR_NONNULL(1, 3, 4, 5); +int BLI_str_utf8_offset_to_index(const char *str, int offset); +int BLI_str_utf8_offset_from_index(const char *str, int index); +int BLI_str_utf8_offset_to_column(const char *str, int offset); +int BLI_str_utf8_offset_from_column(const char *str, int column); + #define BLI_UTF8_MAX 6 /* mem */ #define BLI_UTF8_WIDTH_MAX 2 /* columns */ #define BLI_UTF8_ERR ((unsigned int)-1) diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index d7a2d681f33..f5aaddc0ea3 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -225,8 +225,8 @@ MINLINE void srgb_to_linearrgb_uchar4_predivide(float linear[4], const unsigned srgb_to_linearrgb_predivide_v4(linear, fsrgb); } -MINLINE void rgba_char_args_set( - char col[4], const char r, const char g, const char b, const char a) +MINLINE void rgba_uchar_args_set( + uchar col[4], const uchar r, const uchar g, const uchar b, const uchar a) { col[0] = r; col[1] = g; @@ -243,8 +243,8 @@ MINLINE void rgba_float_args_set( col[3] = a; } -MINLINE void rgba_char_args_test_set( - char col[4], const char r, const char g, const char b, const char a) +MINLINE void rgba_uchar_args_test_set( + uchar col[4], const uchar r, const uchar g, const uchar b, const uchar a) { if (col[3] == 0) { col[0] = r; diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 3a562778af7..4726adb2f59 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -4508,6 +4508,50 @@ void projmat_dimensions(const float projmat[4][4], } } +/** + * Creates a projection matrix for a small region of the viewport. + * + * \param projmat: Projection Matrix. + * \param win_size: Viewport Size. + * \param x_min, x_max, y_min, y_max: Coordinates of the subregion. + * \return r_projmat: Resulting Projection Matrix. + */ +void projmat_from_subregion(const float projmat[4][4], + const int win_size[2], + const int x_min, + const int x_max, + const int y_min, + const int y_max, + float r_projmat[4][4]) +{ + float rect_width = (float)(x_max - x_min); + float rect_height = (float)(y_max - y_min); + + float x_fac = (float)((x_min + x_max) - win_size[0]) / rect_width; + float y_fac = (float)((y_min + y_max) - win_size[1]) / rect_height; + + copy_m4_m4(r_projmat, projmat); + r_projmat[0][0] *= (float)win_size[0] / rect_width; + r_projmat[1][1] *= (float)win_size[1] / rect_height; + +#if 0 /* TODO: check if this is more efficient. */ + r_projmat[2][0] -= x_fac * r_projmat[2][3]; + r_projmat[2][1] -= y_fac * r_projmat[2][3]; + + r_projmat[3][0] -= x_fac * r_projmat[3][3]; + r_projmat[3][1] -= y_fac * r_projmat[3][3]; +#else + if (projmat[3][3] == 0.0f) { + r_projmat[2][0] += x_fac; + r_projmat[2][1] += y_fac; + } + else { + r_projmat[3][0] -= x_fac; + r_projmat[3][1] -= y_fac; + } +#endif +} + static void i_multmatrix(float icand[4][4], float Vm[4][4]) { int row, col; diff --git a/source/blender/blenlib/intern/polyfill_2d.c b/source/blender/blenlib/intern/polyfill_2d.c index 575a4a06d6a..31b18079c73 100644 --- a/source/blender/blenlib/intern/polyfill_2d.c +++ b/source/blender/blenlib/intern/polyfill_2d.c @@ -193,7 +193,10 @@ BLI_INLINE eSign signum_enum(float a) */ BLI_INLINE float area_tri_signed_v2_alt_2x(const float v1[2], const float v2[2], const float v3[2]) { - return ((v1[0] * (v2[1] - v3[1])) + (v2[0] * (v3[1] - v1[1])) + (v3[0] * (v1[1] - v2[1]))); + float d2[2], d3[2]; + sub_v2_v2v2(d2, v2, v1); + sub_v2_v2v2(d3, v3, v1); + return (d2[0] * d3[1]) - (d3[0] * d2[1]); } static eSign span_tri_v2_sign(const float v1[2], const float v2[2], const float v3[2]) diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 01412416854..22c23727d76 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -868,3 +868,53 @@ size_t BLI_str_partition_ex_utf8(const char *str, *suf = *sep = NULL; return str_len; } + +/* -------------------------------------------------------------------- */ +/** \name Offset Conversion in Strings + * \{ */ + +int BLI_str_utf8_offset_to_index(const char *str, int offset) +{ + int index = 0, pos = 0; + while (pos != offset) { + pos += BLI_str_utf8_size(str + pos); + index++; + } + return index; +} + +int BLI_str_utf8_offset_from_index(const char *str, int index) +{ + int offset = 0, pos = 0; + while (pos != index) { + offset += BLI_str_utf8_size(str + offset); + pos++; + } + return offset; +} + +int BLI_str_utf8_offset_to_column(const char *str, int offset) +{ + int column = 0, pos = 0; + while (pos < offset) { + column += BLI_str_utf8_char_width_safe(str + pos); + pos += BLI_str_utf8_size_safe(str + pos); + } + return column; +} + +int BLI_str_utf8_offset_from_column(const char *str, int column) +{ + int offset = 0, pos = 0, col; + while (*(str + offset) && pos < column) { + col = BLI_str_utf8_char_width_safe(str + offset); + if (pos + col > column) { + break; + } + offset += BLI_str_utf8_size_safe(str + offset); + pos += col; + } + return offset; +} + +/** \} */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a73ca6e896c..1f9a22eb1d7 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5841,7 +5841,7 @@ static void direct_link_gpencil_modifiers(FileData *fd, ListBase *lb) if (gpmd->curve_thickness) { direct_link_curvemapping(fd, gpmd->curve_thickness); /* initialize the curve. Maybe this could be moved to modififer logic */ - curvemapping_initialize(gpmd->curve_thickness); + BKE_curvemapping_initialize(gpmd->curve_thickness); } } } @@ -9396,8 +9396,8 @@ static void do_versions_userdef(FileData *fd, BlendFileData *bfd) /* Themes for Node and Sequence editor were not using grid color, * but back. we copy this over then. */ for (btheme = user->themes.first; btheme; btheme = btheme->next) { - copy_v4_v4_char(btheme->space_node.grid, btheme->space_node.back); - copy_v4_v4_char(btheme->space_sequencer.grid, btheme->space_sequencer.back); + copy_v4_v4_uchar(btheme->space_node.grid, btheme->space_node.back); + copy_v4_v4_uchar(btheme->space_sequencer.grid, btheme->space_sequencer.back); } } diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 81751a6ed07..6a5cfc45628 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -1555,7 +1555,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) for (sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; - scopes_new(&sima->scopes); + BKE_scopes_new(&sima->scopes); } } } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 3dc79308f64..b61692799ed 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -1103,9 +1103,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) Scene *scene; for (scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) { CurveMapping *curve_mapping = &scene->r.mblur_shutter_curve; - curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(curve_mapping); - curvemap_reset( + BKE_curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(curve_mapping); + BKE_curvemap_reset( curve_mapping->cm, &curve_mapping->clipr, CURVE_PRESET_MAX, CURVEMAP_SLOPE_POS_NEG); } } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 1573f4ed02f..15b4f513050 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1347,12 +1347,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* sculpt brushes */ GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt; if ((gset) && (gset->cur_falloff == NULL)) { - gset->cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(gset->cur_falloff); - curvemap_reset(gset->cur_falloff->cm, - &gset->cur_falloff->clipr, - CURVE_PRESET_GAUSS, - CURVEMAP_SLOPE_POSITIVE); + gset->cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(gset->cur_falloff); + BKE_curvemap_reset(gset->cur_falloff->cm, + &gset->cur_falloff->clipr, + CURVE_PRESET_GAUSS, + CURVEMAP_SLOPE_POSITIVE); } } } @@ -2748,12 +2748,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt; if ((gset) && (gset->cur_primitive == NULL)) { - gset->cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(gset->cur_primitive); - curvemap_reset(gset->cur_primitive->cm, - &gset->cur_primitive->clipr, - CURVE_PRESET_BELL, - CURVEMAP_SLOPE_POSITIVE); + gset->cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(gset->cur_primitive); + BKE_curvemap_reset(gset->cur_primitive->cm, + &gset->cur_primitive->clipr, + CURVE_PRESET_BELL, + CURVEMAP_SLOPE_POSITIVE); } } } @@ -3407,11 +3407,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) ARegion *ar = NULL; if (sl->spacetype == SPACE_CLIP) { if (((SpaceClip *)sl)->view == SC_VIEW_GRAPH) { - ar = do_versions_find_region(regionbase, RGN_TYPE_PREVIEW); + ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_PREVIEW); } } else { - ar = do_versions_find_region(regionbase, RGN_TYPE_WINDOW); + ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_WINDOW); } if (ar != NULL) { @@ -3560,7 +3560,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_TEXT) { ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; - ARegion *ar = do_versions_find_region(regionbase, RGN_TYPE_UI); + ARegion *ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_UI); if (ar) { ar->alignment = RGN_ALIGN_RIGHT; } diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c index 92113723aab..cebe15e2719 100644 --- a/source/blender/blenloader/intern/versioning_cycles.c +++ b/source/blender/blenloader/intern/versioning_cycles.c @@ -231,7 +231,7 @@ static void vector_curve_node_remap(bNode *node) } } - curvemapping_changed_all(mapping); + BKE_curvemapping_changed_all(mapping); } } diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 14230752d1f..fa69892584a 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -268,22 +268,22 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene) /* Be sure curfalloff and primitive are initializated */ ToolSettings *ts = scene->toolsettings; 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); } if (ts->gp_sculpt.cur_primitive == NULL) { - ts->gp_sculpt.cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + ts->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_primitive_curve = ts->gp_sculpt.cur_primitive; - curvemapping_initialize(gp_primitive_curve); - curvemap_reset(gp_primitive_curve->cm, - &gp_primitive_curve->clipr, - CURVE_PRESET_BELL, - CURVEMAP_SLOPE_POSITIVE); + BKE_curvemapping_initialize(gp_primitive_curve); + BKE_curvemap_reset(gp_primitive_curve->cm, + &gp_primitive_curve->clipr, + CURVE_PRESET_BELL, + CURVEMAP_SLOPE_POSITIVE); } /* Correct default startup UV's. */ diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 0f1d7cbf70f..9b6f252f62d 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -2094,8 +2094,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) la->falloff_type = LA_FALLOFF_INVLINEAR; if (la->curfalloff == NULL) { - la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); - curvemapping_initialize(la->curfalloff); + la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); + BKE_curvemapping_initialize(la->curfalloff); } } } diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index e42a9bc9f95..e987a623d0b 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -51,12 +51,12 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) memcpy(btheme, &U_theme_default, sizeof(*btheme)); } -#define FROM_DEFAULT_V4_UCHAR(member) copy_v4_v4_char(btheme->member, U_theme_default.member) +#define FROM_DEFAULT_V4_UCHAR(member) copy_v4_v4_uchar(btheme->member, U_theme_default.member) if (!USER_VERSION_ATLEAST(280, 25)) { - copy_v4_v4_char(btheme->space_action.anim_preview_range, btheme->space_action.anim_active); - copy_v4_v4_char(btheme->space_nla.anim_preview_range, btheme->space_nla.anim_active); - copy_v4_v4_char(btheme->space_graph.anim_preview_range, btheme->space_action.anim_active); + copy_v4_v4_uchar(btheme->space_action.anim_preview_range, btheme->space_action.anim_active); + copy_v4_v4_uchar(btheme->space_nla.anim_preview_range, btheme->space_nla.anim_active); + copy_v4_v4_uchar(btheme->space_graph.anim_preview_range, btheme->space_action.anim_active); } if (!USER_VERSION_ATLEAST(280, 26)) { @@ -102,8 +102,8 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) if (!USER_VERSION_ATLEAST(280, 40)) { FROM_DEFAULT_V4_UCHAR(space_preferences.navigation_bar); - copy_v4_v4_char(btheme->space_preferences.execution_buts, - btheme->space_preferences.navigation_bar); + copy_v4_v4_uchar(btheme->space_preferences.execution_buts, + btheme->space_preferences.navigation_bar); } if (!USER_VERSION_ATLEAST(280, 41)) { diff --git a/source/blender/blentranslation/msgfmt/msgfmt.c b/source/blender/blentranslation/msgfmt/msgfmt.c index 86d55e203d9..215c92f87de 100644 --- a/source/blender/blentranslation/msgfmt/msgfmt.c +++ b/source/blender/blentranslation/msgfmt/msgfmt.c @@ -82,12 +82,12 @@ static char *trim(char *str) return str; } - for (i = 0; i < len && ELEM(str[0], ' ', '\t', '\r','\n'); str++, i++) { + for (i = 0; i < len && ELEM(str[0], ' ', '\t', '\r', '\n'); str++, i++) { /* pass */ } char *end = &str[len - 1 - i]; - for (i = len; i > 0 && ELEM(end[0], ' ', '\t', '\r','\n'); end--, i--) { + for (i = len; i > 0 && ELEM(end[0], ' ', '\t', '\r', '\n'); end--, i--) { /* pass */ } diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp index 45604882992..2a30ee9c574 100644 --- a/source/blender/compositor/nodes/COM_TimeNode.cpp +++ b/source/blender/compositor/nodes/COM_TimeNode.cpp @@ -49,8 +49,8 @@ void TimeNode::convertToOperations(NodeConverter &converter, fac = (context.getFramenumber() - node->custom1) / (float)(node->custom2 - node->custom1); } - curvemapping_initialize((CurveMapping *)node->storage); - fac = curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac); + BKE_curvemapping_initialize((CurveMapping *)node->storage); + fac = BKE_curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac); operation->setValue(clamp_f(fac, 0.0f, 1.0f)); converter.addOperation(operation); diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp index e25ef49cf28..90d3a60abd0 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp @@ -50,7 +50,7 @@ void ColorCurveOperation::initExecution() this->m_inputBlackProgram = this->getInputSocketReader(2); this->m_inputWhiteProgram = this->getInputSocketReader(3); - curvemapping_premultiply(this->m_curveMapping, 0); + BKE_curvemapping_premultiply(this->m_curveMapping, 0); } void ColorCurveOperation::executePixelSampled(float output[4], @@ -73,20 +73,20 @@ void ColorCurveOperation::executePixelSampled(float output[4], /* get our own local bwmul value, * since we can't be threadsafe and use cumap->bwmul & friends */ - curvemapping_set_black_white_ex(black, white, bwmul); + BKE_curvemapping_set_black_white_ex(black, white, bwmul); this->m_inputFacProgram->readSampled(fac, x, y, sampler); this->m_inputImageProgram->readSampled(image, x, y, sampler); if (*fac >= 1.0f) { - curvemapping_evaluate_premulRGBF_ex(cumap, output, image, black, bwmul); + BKE_curvemapping_evaluate_premulRGBF_ex(cumap, output, image, black, bwmul); } else if (*fac <= 0.0f) { copy_v3_v3(output, image); } else { float col[4]; - curvemapping_evaluate_premulRGBF_ex(cumap, col, image, black, bwmul); + BKE_curvemapping_evaluate_premulRGBF_ex(cumap, col, image, black, bwmul); interp_v3_v3v3(output, image, col, *fac); } output[3] = image[3]; @@ -120,9 +120,9 @@ void ConstantLevelColorCurveOperation::initExecution() this->m_inputFacProgram = this->getInputSocketReader(0); this->m_inputImageProgram = this->getInputSocketReader(1); - curvemapping_premultiply(this->m_curveMapping, 0); + BKE_curvemapping_premultiply(this->m_curveMapping, 0); - curvemapping_set_black_white(this->m_curveMapping, this->m_black, this->m_white); + BKE_curvemapping_set_black_white(this->m_curveMapping, this->m_black, this->m_white); } void ConstantLevelColorCurveOperation::executePixelSampled(float output[4], @@ -137,14 +137,14 @@ void ConstantLevelColorCurveOperation::executePixelSampled(float output[4], this->m_inputImageProgram->readSampled(image, x, y, sampler); if (*fac >= 1.0f) { - curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, image); + BKE_curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, image); } else if (*fac <= 0.0f) { copy_v3_v3(output, image); } else { float col[4]; - curvemapping_evaluate_premulRGBF(this->m_curveMapping, col, image); + BKE_curvemapping_evaluate_premulRGBF(this->m_curveMapping, col, image); interp_v3_v3v3(output, image, col, *fac); } output[3] = image[3]; diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp index d84af71d8d8..858931ad46d 100644 --- a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp @@ -34,19 +34,19 @@ CurveBaseOperation::CurveBaseOperation() : NodeOperation() CurveBaseOperation::~CurveBaseOperation() { if (this->m_curveMapping) { - curvemapping_free(this->m_curveMapping); + BKE_curvemapping_free(this->m_curveMapping); this->m_curveMapping = NULL; } } void CurveBaseOperation::initExecution() { - curvemapping_initialize(this->m_curveMapping); + BKE_curvemapping_initialize(this->m_curveMapping); } void CurveBaseOperation::deinitExecution() { if (this->m_curveMapping) { - curvemapping_free(this->m_curveMapping); + BKE_curvemapping_free(this->m_curveMapping); this->m_curveMapping = NULL; } } @@ -55,7 +55,7 @@ void CurveBaseOperation::setCurveMapping(CurveMapping *mapping) { /* duplicate the curve to avoid glitches while drawing, see bug [#32374] */ if (this->m_curveMapping) { - curvemapping_free(this->m_curveMapping); + BKE_curvemapping_free(this->m_curveMapping); } - this->m_curveMapping = curvemapping_copy(mapping); + this->m_curveMapping = BKE_curvemapping_copy(mapping); } diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp index 61ad4248fb0..fae280249de 100644 --- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp @@ -51,15 +51,15 @@ void HueSaturationValueCorrectOperation::executePixelSampled(float output[4], this->m_inputProgram->readSampled(hsv, x, y, sampler); /* adjust hue, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]); + f = BKE_curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]); hsv[0] += f - 0.5f; /* adjust saturation, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(this->m_curveMapping, 1, hsv[0]); + f = BKE_curvemapping_evaluateF(this->m_curveMapping, 1, hsv[0]); hsv[1] *= (f * 2.0f); /* adjust value, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(this->m_curveMapping, 2, hsv[0]); + f = BKE_curvemapping_evaluateF(this->m_curveMapping, 2, hsv[0]); hsv[2] *= (f * 2.0f); hsv[0] = hsv[0] - floorf(hsv[0]); /* mod 1.0 */ diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp index 850aef122f4..6996c7ecb71 100644 --- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp @@ -48,7 +48,7 @@ void VectorCurveOperation::executePixelSampled(float output[4], this->m_inputProgram->readSampled(input, x, y, sampler); - curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, input); + BKE_curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, input); } void VectorCurveOperation::deinitExecution() diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c index dd7f4683ce0..f548bd15bf4 100644 --- a/source/blender/draw/engines/basic/basic_engine.c +++ b/source/blender/draw/engines/basic/basic_engine.c @@ -25,6 +25,7 @@ #include "DRW_render.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "DNA_particle_types.h" @@ -161,13 +162,19 @@ static void basic_cache_populate(void *vedata, Object *ob) } } - struct GPUBatch *geom = DRW_cache_object_surface_get(ob); - if (geom) { - const bool do_cull = (draw_ctx->v3d && - (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING)); - /* Depth Prepass */ - DRW_shgroup_call( - (do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob); + const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d); + const bool do_cull = (draw_ctx->v3d && + (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING)); + DRWShadingGroup *shgrp = (do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp; + + if (use_sculpt_pbvh) { + DRW_shgroup_call_sculpt(shgrp, ob, false, false, false); + } + else { + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); + if (geom) { + DRW_shgroup_call(shgrp, geom, ob); + } } } diff --git a/source/blender/draw/engines/select/select_draw_utils.c b/source/blender/draw/engines/select/select_draw_utils.c index c3615cb5a81..d1d916de84c 100644 --- a/source/blender/draw/engines/select/select_draw_utils.c +++ b/source/blender/draw/engines/select/select_draw_utils.c @@ -179,6 +179,9 @@ static void draw_select_id_mesh(SELECTID_StorageList *stl, DRW_shgroup_call(vert_shgrp, geom_verts, ob); *r_vert_offset = *r_edge_offset + me->totvert; } + else { + *r_vert_offset = *r_edge_offset; + } } void select_id_draw_object(void *vedata, diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 735a0dcf7a0..add49462de1 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -475,7 +475,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) const eGPUTextureFormat nor_tex_format = NORMAL_ENCODING_ENABLED() ? GPU_RG16 : GPU_RGBA32F; const eGPUTextureFormat comp_tex_format = DRW_state_is_image_render() ? GPU_RGBA16F : GPU_R11F_G11F_B10F; - const eGPUTextureFormat col_tex_format = DRW_state_is_image_render() ? GPU_RGBA16F : GPU_RGBA8; + const eGPUTextureFormat col_tex_format = workbench_color_texture_format(wpd); const eGPUTextureFormat id_tex_format = OBJECT_ID_PASS_ENABLED(wpd) ? GPU_R32UI : GPU_R8; e_data.object_id_tx = NULL; diff --git a/source/blender/draw/engines/workbench/workbench_effect_taa.c b/source/blender/draw/engines/workbench/workbench_effect_taa.c index 88f1f30941a..06442060623 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_taa.c +++ b/source/blender/draw/engines/workbench/workbench_effect_taa.c @@ -170,10 +170,10 @@ DRWPass *workbench_taa_create_pass(WORKBENCH_Data *vedata, GPUTexture **color_bu WORKBENCH_TextureList *txl = vedata->txl; WORKBENCH_EffectInfo *effect_info = stl->effects; WORKBENCH_FramebufferList *fbl = vedata->fbl; + const WORKBENCH_PrivateData *wpd = stl->g_data; { - const eGPUTextureFormat hist_buffer_format = DRW_state_is_image_render() ? GPU_RGBA16F : - GPU_RGBA8; + const eGPUTextureFormat hist_buffer_format = workbench_color_texture_format(wpd); DRW_texture_ensure_fullscreen_2d(&txl->history_buffer_tx, hist_buffer_format, 0); DRW_texture_ensure_fullscreen_2d(&txl->depth_buffer_tx, GPU_DEPTH24_STENCIL8, 0); } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 17144c4dc10..255b036eebb 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -381,6 +381,30 @@ BLI_INLINE bool workbench_is_matdata_pass_enabled(WORKBENCH_PrivateData *wpd) workbench_is_in_texture_paint_mode(); } +/** + * Get the default texture format to be used by the color and history buffers. + * + * Use GPU_RGBA16F for final renderings and for drawing textures. This + * allows displaying HDRI textures. Vertex Colors uses GPU_RGBA16 to resolve + * color banding issues (T66100). All other modes use GPU_RGBA8 to reduce + * bandwidth and gpu memory. + */ +BLI_INLINE eGPUTextureFormat workbench_color_texture_format(const WORKBENCH_PrivateData *wpd) +{ + eGPUTextureFormat result; + if (DRW_state_is_image_render() || workbench_is_in_texture_paint_mode() || + TEXTURE_DRAWING_ENABLED(wpd)) { + result = GPU_RGBA16F; + } + else if (VERTEX_COLORS_ENABLED(wpd)) { + result = GPU_RGBA16; + } + else { + result = GPU_RGBA8; + } + return result; +} + /* workbench_deferred.c */ void workbench_deferred_engine_init(WORKBENCH_Data *vedata); void workbench_deferred_engine_free(void); diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c index 96592564632..bb3d3fb2bdb 100644 --- a/source/blender/draw/intern/draw_armature.c +++ b/source/blender/draw/intern/draw_armature.c @@ -694,17 +694,17 @@ static bool set_pchan_color(short colCode, uchar cp[4] = {255}; if (boneflag & BONE_DRAW_ACTIVE) { - copy_v3_v3_char((char *)cp, bcolor->active); + copy_v3_v3_uchar(cp, bcolor->active); if (!(boneflag & BONE_SELECTED)) { cp_shade_color3ub(cp, -80); } } else if (boneflag & BONE_SELECTED) { - copy_v3_v3_char((char *)cp, bcolor->select); + copy_v3_v3_uchar(cp, bcolor->select); } else { /* a bit darker than solid */ - copy_v3_v3_char((char *)cp, bcolor->solid); + copy_v3_v3_uchar(cp, bcolor->solid); cp_shade_color3ub(cp, -50); } @@ -742,16 +742,16 @@ static bool set_pchan_color(short colCode, if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) { uchar cp[4]; if (constflag & PCHAN_HAS_TARGET) { - rgba_char_args_set((char *)cp, 255, 150, 0, 80); + rgba_uchar_args_set(cp, 255, 150, 0, 80); } else if (constflag & PCHAN_HAS_IK) { - rgba_char_args_set((char *)cp, 255, 255, 0, 80); + rgba_uchar_args_set(cp, 255, 255, 0, 80); } else if (constflag & PCHAN_HAS_SPLINEIK) { - rgba_char_args_set((char *)cp, 200, 255, 0, 80); + rgba_uchar_args_set(cp, 200, 255, 0, 80); } else if (constflag & PCHAN_HAS_CONST) { - rgba_char_args_set((char *)cp, 0, 255, 120, 80); + rgba_uchar_args_set(cp, 0, 255, 120, 80); } else { return false; @@ -768,13 +768,13 @@ static bool set_pchan_color(short colCode, uchar cp[4] = {255}; if (boneflag & BONE_DRAW_ACTIVE) { - copy_v3_v3_char((char *)cp, bcolor->active); + copy_v3_v3_uchar(cp, bcolor->active); } else if (boneflag & BONE_SELECTED) { - copy_v3_v3_char((char *)cp, bcolor->select); + copy_v3_v3_uchar(cp, bcolor->select); } else { - copy_v3_v3_char((char *)cp, bcolor->solid); + copy_v3_v3_uchar(cp, bcolor->solid); } rgb_uchar_to_float(fcolor, cp); @@ -798,15 +798,15 @@ static bool set_pchan_color(short colCode, uchar cp[4] = {255}; if (boneflag & BONE_DRAW_ACTIVE) { - copy_v3_v3_char((char *)cp, bcolor->active); + copy_v3_v3_uchar(cp, bcolor->active); cp_shade_color3ub(cp, 10); } else if (boneflag & BONE_SELECTED) { - copy_v3_v3_char((char *)cp, bcolor->select); + copy_v3_v3_uchar(cp, bcolor->select); cp_shade_color3ub(cp, -30); } else { - copy_v3_v3_char((char *)cp, bcolor->solid); + copy_v3_v3_uchar(cp, bcolor->solid); cp_shade_color3ub(cp, -30); } @@ -830,16 +830,16 @@ static bool set_pchan_color(short colCode, if ((constflag) && ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS))) { uchar cp[4]; if (constflag & PCHAN_HAS_TARGET) { - rgba_char_args_set((char *)cp, 255, 150, 0, 255); + rgba_uchar_args_set(cp, 255, 150, 0, 255); } else if (constflag & PCHAN_HAS_IK) { - rgba_char_args_set((char *)cp, 255, 255, 0, 255); + rgba_uchar_args_set(cp, 255, 255, 0, 255); } else if (constflag & PCHAN_HAS_SPLINEIK) { - rgba_char_args_set((char *)cp, 200, 255, 0, 255); + rgba_uchar_args_set(cp, 200, 255, 0, 255); } else if (constflag & PCHAN_HAS_CONST) { - rgba_char_args_set((char *)cp, 0, 255, 120, 255); + rgba_uchar_args_set(cp, 0, 255, 120, 255); } else if (constflag) { DRW_theme_color_get_4ubv(TH_BONE_POSE, cp); @@ -849,7 +849,7 @@ static bool set_pchan_color(short colCode, } else { if (bcolor) { - const char *cp = bcolor->solid; + const uchar *cp = bcolor->solid; rgb_uchar_to_float(fcolor, (uchar *)cp); fcolor[3] = 204.f / 255.f; } diff --git a/source/blender/draw/intern/draw_manager_texture.c b/source/blender/draw/intern/draw_manager_texture.c index 4750a35d784..373810b2f7f 100644 --- a/source/blender/draw/intern/draw_manager_texture.c +++ b/source/blender/draw/intern/draw_manager_texture.c @@ -45,6 +45,7 @@ static bool drw_texture_format_supports_framebuffer(eGPUTextureFormat format) case GPU_RG32F: case GPU_R11F_G11F_B10F: case GPU_RGBA8: + case GPU_RGBA16: case GPU_RGBA16F: case GPU_RGBA32F: case GPU_DEPTH_COMPONENT16: diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 03c615e9b46..6ee2a03c34c 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -1115,6 +1115,10 @@ static void DRW_shgroup_camera_background_images(OBJECT_Shaders *sh_data, Object *ob, RegionView3D *rv3d) { + if (DRW_state_is_select()) { + return; + } + if (!BKE_object_empty_image_frame_is_visible_in_view3d(ob, rv3d)) { return; } 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); diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp index 71cdbafba45..367ad556d02 100644 --- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp +++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp @@ -229,7 +229,7 @@ static PyObject *Freestyle_evaluateColorRamp(PyObject * /*self*/, PyObject *args } #include "DNA_color_types.h" -#include "BKE_colortools.h" /* curvemapping_evaluateF() */ +#include "BKE_colortools.h" /* BKE_curvemapping_evaluateF() */ static char Freestyle_evaluateCurveMappingF___doc__[] = ".. function:: evaluateCurveMappingF(cumap, cur, value)\n" @@ -264,13 +264,13 @@ static PyObject *Freestyle_evaluateCurveMappingF(PyObject * /*self*/, PyObject * return NULL; } cumap = (CurveMapping *)py_srna->ptr.data; - curvemapping_initialize(cumap); + BKE_curvemapping_initialize(cumap); /* disable extrapolation if enabled */ if ((cumap->cm[cur].flag & CUMA_EXTEND_EXTRAPOLATE)) { cumap->cm[cur].flag &= ~(CUMA_EXTEND_EXTRAPOLATE); - curvemapping_changed(cumap, 0); + BKE_curvemapping_changed(cumap, 0); } - return PyFloat_FromDouble(curvemapping_evaluateF(cumap, cur, value)); + return PyFloat_FromDouble(BKE_curvemapping_evaluateF(cumap, cur, value)); } /*-----------------------Freestyle module docstring----------------------------*/ diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c index d56b3217c9f..a3dbcdf23de 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c @@ -81,9 +81,9 @@ static void initData(GpencilModifierData *md) gpmd->object = NULL; gpmd->force = 0.5f; gpmd->falloff_type = eGPHook_Falloff_Smooth; - gpmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + gpmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (gpmd->curfalloff) { - curvemapping_initialize(gpmd->curfalloff); + BKE_curvemapping_initialize(gpmd->curfalloff); } } @@ -93,13 +93,13 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target) HookGpencilModifierData *tgmd = (HookGpencilModifierData *)target; if (tgmd->curfalloff != NULL) { - curvemapping_free(tgmd->curfalloff); + BKE_curvemapping_free(tgmd->curfalloff); tgmd->curfalloff = NULL; } BKE_gpencil_modifier_copyData_generic(md, target); - tgmd->curfalloff = curvemapping_copy(gmd->curfalloff); + tgmd->curfalloff = BKE_curvemapping_copy(gmd->curfalloff); } /* calculate factor of fallof */ @@ -126,7 +126,7 @@ static float gp_hook_falloff(const struct GPHookData_cb *tData, const float len_ switch (tData->falloff_type) { case eGPHook_Falloff_Curve: - fac = curvemapping_evaluateF(tData->curfalloff, 0, fac); + fac = BKE_curvemapping_evaluateF(tData->curfalloff, 0, fac); break; case eGPHook_Falloff_Sharp: fac = fac * fac; @@ -301,7 +301,7 @@ static void freeData(GpencilModifierData *md) HookGpencilModifierData *mmd = (HookGpencilModifierData *)md; if (mmd->curfalloff) { - curvemapping_free(mmd->curfalloff); + BKE_curvemapping_free(mmd->curfalloff); } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c index bf4f45b10af..357e36a06b2 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c @@ -48,9 +48,9 @@ static void initData(GpencilModifierData *md) gpmd->thickness = 2; gpmd->layername[0] = '\0'; gpmd->vgname[0] = '\0'; - gpmd->curve_thickness = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + gpmd->curve_thickness = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (gpmd->curve_thickness) { - curvemapping_initialize(gpmd->curve_thickness); + BKE_curvemapping_initialize(gpmd->curve_thickness); } } @@ -59,7 +59,7 @@ static void freeData(GpencilModifierData *md) ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md; if (gpmd->curve_thickness) { - curvemapping_free(gpmd->curve_thickness); + BKE_curvemapping_free(gpmd->curve_thickness); } } @@ -69,13 +69,13 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target) ThickGpencilModifierData *tgmd = (ThickGpencilModifierData *)target; if (tgmd->curve_thickness != NULL) { - curvemapping_free(tgmd->curve_thickness); + BKE_curvemapping_free(tgmd->curve_thickness); tgmd->curve_thickness = NULL; } BKE_gpencil_modifier_copyData_generic(md, target); - tgmd->curve_thickness = curvemapping_copy(gmd->curve_thickness); + tgmd->curve_thickness = BKE_curvemapping_copy(gmd->curve_thickness); } /* change stroke thickness */ @@ -125,7 +125,7 @@ static void deformStroke(GpencilModifierData *md, if ((mmd->flag & GP_THICK_CUSTOM_CURVE) && (mmd->curve_thickness)) { /* normalize value to evaluate curve */ float value = (float)i / (gps->totpoints - 1); - curvef = curvemapping_evaluateF(mmd->curve_thickness, 0, value); + curvef = BKE_curvemapping_evaluateF(mmd->curve_thickness, 0, value); } pt->pressure += mmd->thickness * weight * curvef; diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 124f1f1ff8a..01b679453a7 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -185,6 +185,7 @@ typedef enum eGPUBuiltinShader { GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR, /* basic image drawing */ GPU_SHADER_2D_IMAGE_LINEAR_TO_SRGB, + GPU_SHADER_2D_IMAGE_RECT_LINEAR_TO_SRGB, GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR, GPU_SHADER_2D_IMAGE_MASK_UNIFORM_COLOR, /** diff --git a/source/blender/gpu/GPU_viewport.h b/source/blender/gpu/GPU_viewport.h index e7600279d6f..00e6e018761 100644 --- a/source/blender/gpu/GPU_viewport.h +++ b/source/blender/gpu/GPU_viewport.h @@ -93,6 +93,7 @@ GPUViewport *GPU_viewport_create(void); void GPU_viewport_bind(GPUViewport *viewport, const rcti *rect); void GPU_viewport_unbind(GPUViewport *viewport); void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect); +void GPU_viewport_draw_to_screen_ex(GPUViewport *viewport, const rcti *rect, bool to_srgb); void GPU_viewport_free(GPUViewport *viewport); GPUViewport *GPU_viewport_create_from_offscreen(struct GPUOffScreen *ofs); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 59b0857c177..6eb8c80c58e 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -136,7 +136,7 @@ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, uint vert_len) /* TODO: Do not allocate these `.msk` and `.col` when they are not used. */ g_vbo_id.msk = GPU_vertformat_attr_add(&format, "msk", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); g_vbo_id.col = GPU_vertformat_attr_add( - &format, "c", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); + &format, "ac", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); } buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_STATIC); } diff --git a/source/blender/gpu/intern/gpu_context.cpp b/source/blender/gpu/intern/gpu_context.cpp index 12a5748b198..93df65006ff 100644 --- a/source/blender/gpu/intern/gpu_context.cpp +++ b/source/blender/gpu/intern/gpu_context.cpp @@ -90,12 +90,7 @@ struct GPUContext { } }; -#if defined(_MSC_VER) && (_MSC_VER == 1800) -# define thread_local __declspec(thread) -thread_local GPUContext *active_ctx = NULL; -#else static thread_local GPUContext *active_ctx = NULL; -#endif static void orphans_add(GPUContext *ctx, std::vector<GLuint> *orphan_list, GLuint id) { diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 3e930d19696..35a479b05c0 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -1015,6 +1015,11 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = { .vert = datatoc_gpu_shader_2D_image_vert_glsl, .frag = datatoc_gpu_shader_image_linear_frag_glsl, }, + [GPU_SHADER_2D_IMAGE_RECT_LINEAR_TO_SRGB] = + { + .vert = datatoc_gpu_shader_2D_image_rect_vert_glsl, + .frag = datatoc_gpu_shader_image_linear_frag_glsl, + }, [GPU_SHADER_2D_IMAGE] = { .vert = datatoc_gpu_shader_2D_image_vert_glsl, diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c index 20e9b42ee05..4f14a0b9fe0 100644 --- a/source/blender/gpu/intern/gpu_viewport.c +++ b/source/blender/gpu/intern/gpu_viewport.c @@ -503,7 +503,7 @@ void GPU_viewport_bind(GPUViewport *viewport, const rcti *rect) } } -void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect) +void GPU_viewport_draw_to_screen_ex(GPUViewport *viewport, const rcti *rect, bool to_srgb) { DefaultFramebufferList *dfbl = viewport->fbl; @@ -530,7 +530,8 @@ void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect) float y1 = rect->ymin; float y2 = rect->ymin + h; - GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR); + GPUShader *shader = GPU_shader_get_builtin_shader( + to_srgb ? GPU_SHADER_2D_IMAGE_RECT_LINEAR_TO_SRGB : GPU_SHADER_2D_IMAGE_RECT_COLOR); GPU_shader_bind(shader); GPU_texture_bind(color, 0); @@ -548,6 +549,11 @@ void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect) GPU_texture_unbind(color); } +void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect) +{ + GPU_viewport_draw_to_screen_ex(viewport, rect, false); +} + void GPU_viewport_unbind(GPUViewport *UNUSED(viewport)) { GPU_framebuffer_restore(); diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index 4509daac81f..36af7ab2571 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -716,7 +716,7 @@ void colormanagement_exit(void) } if (global_glsl_state.curve_mapping) { - curvemapping_free(global_glsl_state.curve_mapping); + BKE_curvemapping_free(global_glsl_state.curve_mapping); } if (global_glsl_state.curve_mapping_settings.lut) { @@ -1029,14 +1029,14 @@ void IMB_colormanagement_init_default_view_settings( static void curve_mapping_apply_pixel(CurveMapping *curve_mapping, float *pixel, int channels) { if (channels == 1) { - pixel[0] = curvemap_evaluateF(curve_mapping->cm, pixel[0]); + pixel[0] = BKE_curvemap_evaluateF(curve_mapping->cm, pixel[0]); } else if (channels == 2) { - pixel[0] = curvemap_evaluateF(curve_mapping->cm, pixel[0]); - pixel[1] = curvemap_evaluateF(curve_mapping->cm, pixel[1]); + pixel[0] = BKE_curvemap_evaluateF(curve_mapping->cm, pixel[0]); + pixel[1] = BKE_curvemap_evaluateF(curve_mapping->cm, pixel[1]); } else { - curvemapping_evaluate_premulRGBF(curve_mapping, pixel, pixel); + BKE_curvemapping_evaluate_premulRGBF(curve_mapping, pixel, pixel); } } @@ -3728,8 +3728,8 @@ ColormanageProcessor *IMB_colormanagement_display_processor_new( global_role_scene_linear); if (applied_view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) { - cm_processor->curve_mapping = curvemapping_copy(applied_view_settings->curve_mapping); - curvemapping_premultiply(cm_processor->curve_mapping, false); + cm_processor->curve_mapping = BKE_curvemapping_copy(applied_view_settings->curve_mapping); + BKE_curvemapping_premultiply(cm_processor->curve_mapping, false); } return cm_processor; @@ -3754,7 +3754,7 @@ ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const char *f void IMB_colormanagement_processor_apply_v4(ColormanageProcessor *cm_processor, float pixel[4]) { if (cm_processor->curve_mapping) { - curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); + BKE_curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); } if (cm_processor->processor) { @@ -3766,7 +3766,7 @@ void IMB_colormanagement_processor_apply_v4_predivide(ColormanageProcessor *cm_p float pixel[4]) { if (cm_processor->curve_mapping) { - curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); + BKE_curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); } if (cm_processor->processor) { @@ -3777,7 +3777,7 @@ void IMB_colormanagement_processor_apply_v4_predivide(ColormanageProcessor *cm_p void IMB_colormanagement_processor_apply_v3(ColormanageProcessor *cm_processor, float pixel[3]) { if (cm_processor->curve_mapping) { - curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); + BKE_curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); } if (cm_processor->processor) { @@ -3870,7 +3870,7 @@ void IMB_colormanagement_processor_apply_byte( void IMB_colormanagement_processor_free(ColormanageProcessor *cm_processor) { if (cm_processor->curve_mapping) { - curvemapping_free(cm_processor->curve_mapping); + BKE_curvemapping_free(cm_processor->curve_mapping); } if (cm_processor->processor) { OCIO_processorRelease(cm_processor->processor); @@ -3899,9 +3899,9 @@ static void curve_mapping_to_ocio_settings(CurveMapping *curve_mapping, { int i; - curvemapping_initialize(curve_mapping); - curvemapping_premultiply(curve_mapping, false); - curvemapping_table_RGBA( + BKE_curvemapping_initialize(curve_mapping); + BKE_curvemapping_premultiply(curve_mapping, false); + BKE_curvemapping_table_RGBA( curve_mapping, &curve_mapping_settings->lut, &curve_mapping_settings->lut_size); for (i = 0; i < 4; i++) { @@ -3964,11 +3964,11 @@ static void update_glsl_display_processor(const ColorManagedViewSettings *view_s * We do this by allocating new curve mapping before freeing ol one. */ if (use_curve_mapping) { - new_curve_mapping = curvemapping_copy(view_settings->curve_mapping); + new_curve_mapping = BKE_curvemapping_copy(view_settings->curve_mapping); } if (global_glsl_state.curve_mapping) { - curvemapping_free(global_glsl_state.curve_mapping); + BKE_curvemapping_free(global_glsl_state.curve_mapping); MEM_freeN(curve_mapping_settings->lut); global_glsl_state.curve_mapping = NULL; curve_mapping_settings->lut = NULL; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index b90f1fd16df..b8914c7a74f 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -116,37 +116,37 @@ typedef struct uiStyle { } uiStyle; typedef struct uiWidgetColors { - char outline[4]; - char inner[4]; - char inner_sel[4]; - char item[4]; - char text[4]; - char text_sel[4]; - char shaded; + unsigned char outline[4]; + unsigned char inner[4]; + unsigned char inner_sel[4]; + unsigned char item[4]; + unsigned char text[4]; + unsigned char text_sel[4]; + unsigned char shaded; char _pad0[7]; short shadetop, shadedown; float roundness; } uiWidgetColors; typedef struct uiWidgetStateColors { - char inner_anim[4]; - char inner_anim_sel[4]; - char inner_key[4]; - char inner_key_sel[4]; - char inner_driven[4]; - char inner_driven_sel[4]; - char inner_overridden[4]; - char inner_overridden_sel[4]; - char inner_changed[4]; - char inner_changed_sel[4]; + unsigned char inner_anim[4]; + unsigned char inner_anim_sel[4]; + unsigned char inner_key[4]; + unsigned char inner_key_sel[4]; + unsigned char inner_driven[4]; + unsigned char inner_driven_sel[4]; + unsigned char inner_overridden[4]; + unsigned char inner_overridden_sel[4]; + unsigned char inner_changed[4]; + unsigned char inner_changed_sel[4]; float blend; char _pad0[4]; } uiWidgetStateColors; typedef struct uiPanelColors { - char header[4]; - char back[4]; - char sub_back[4]; + unsigned char header[4]; + unsigned char back[4]; + unsigned char sub_back[4]; char _pad0[4]; } uiPanelColors; @@ -160,13 +160,13 @@ typedef struct ThemeUI { uiWidgetStateColors wcol_state; - char widget_emboss[4]; + unsigned char widget_emboss[4]; /* fac: 0 - 1 for blend factor, width in pixels */ float menu_shadow_fac; short menu_shadow_width; - char editor_outline[4]; + unsigned char editor_outline[4]; char _pad0[2]; float icon_alpha; @@ -174,28 +174,28 @@ typedef struct ThemeUI { char _pad[4]; /* Axis Colors */ - char xaxis[4], yaxis[4], zaxis[4]; + unsigned char xaxis[4], yaxis[4], zaxis[4]; /* Gizmo Colors. */ - char gizmo_hi[4]; - char gizmo_primary[4]; - char gizmo_secondary[4]; - char gizmo_a[4]; - char gizmo_b[4]; + unsigned char gizmo_hi[4]; + unsigned char gizmo_primary[4]; + unsigned char gizmo_secondary[4]; + unsigned char gizmo_a[4]; + unsigned char gizmo_b[4]; /* Icon Colors. */ /** Scene items. */ - char icon_scene[4]; + unsigned char icon_scene[4]; /** Collection items. */ - char icon_collection[4]; + unsigned char icon_collection[4]; /** Object items. */ - char icon_object[4]; + unsigned char icon_object[4]; /** Object data items. */ - char icon_object_data[4]; + unsigned char icon_object_data[4]; /** Modifier and constraint items. */ - char icon_modifier[4]; + unsigned char icon_modifier[4]; /** Shading related items. */ - char icon_shading[4]; + unsigned char icon_shading[4]; /** Intensity of the border icons. >0 will render an border around themed * icons. */ float icon_border_intensity; @@ -206,216 +206,218 @@ typedef struct ThemeUI { */ typedef struct ThemeSpace { /* main window colors */ - char back[4]; - char back_grad[4]; + unsigned char back[4]; + unsigned char back_grad[4]; char show_back_grad; char _pad0[3]; /** Panel title. */ - char title[4]; - char text[4]; - char text_hi[4]; + unsigned char title[4]; + unsigned char text[4]; + unsigned char text_hi[4]; /* header colors */ /** Region background. */ - char header[4]; + unsigned char header[4]; /** Unused. */ - char header_title[4]; - char header_text[4]; - char header_text_hi[4]; + unsigned char header_title[4]; + unsigned char header_text[4]; + unsigned char header_text_hi[4]; /* region tabs */ - char tab_active[4]; - char tab_inactive[4]; - char tab_back[4]; - char tab_outline[4]; + unsigned char tab_active[4]; + unsigned char tab_inactive[4]; + unsigned char tab_back[4]; + unsigned char tab_outline[4]; /* button/tool regions */ /** Region background. */ - char button[4]; + unsigned char button[4]; /** Panel title. */ - char button_title[4]; - char button_text[4]; - char button_text_hi[4]; + unsigned char button_title[4]; + unsigned char button_text[4]; + unsigned char button_text_hi[4]; /* listview regions */ /** Region background. */ - char list[4]; + unsigned char list[4]; /** Panel title. */ - char list_title[4]; - char list_text[4]; - char list_text_hi[4]; + unsigned char list_title[4]; + unsigned char list_text[4]; + unsigned char list_text_hi[4]; /* navigation bar regions */ /** Region background. */ - char navigation_bar[4]; + unsigned char navigation_bar[4]; /** Region background. */ - char execution_buts[4]; + unsigned char execution_buts[4]; /* note, cannot use name 'panel' because of DNA mapping old files */ uiPanelColors panelcolors; - char shade1[4]; - char shade2[4]; + unsigned char shade1[4]; + unsigned char shade2[4]; - char hilite[4]; - char grid[4]; + unsigned char hilite[4]; + unsigned char grid[4]; - char view_overlay[4]; + unsigned char view_overlay[4]; - char wire[4], wire_edit[4], select[4]; - char lamp[4], speaker[4], empty[4], camera[4]; - char active[4], group[4], group_active[4], transform[4]; - char vertex[4], vertex_select[4], vertex_bevel[4], vertex_unreferenced[4]; - char edge[4], edge_select[4]; - char edge_seam[4], edge_sharp[4], edge_facesel[4], edge_crease[4], edge_bevel[4]; + unsigned char wire[4], wire_edit[4], select[4]; + unsigned char lamp[4], speaker[4], empty[4], camera[4]; + unsigned char active[4], group[4], group_active[4], transform[4]; + unsigned char vertex[4], vertex_select[4], vertex_bevel[4], vertex_unreferenced[4]; + unsigned char edge[4], edge_select[4]; + unsigned char edge_seam[4], edge_sharp[4], edge_facesel[4], edge_crease[4], edge_bevel[4]; /** Solid faces. */ - char face[4], face_select[4]; + unsigned char face[4], face_select[4]; /** selected color. */ - char face_dot[4]; - char extra_edge_len[4], extra_edge_angle[4], extra_face_angle[4], extra_face_area[4]; - char normal[4]; - char vertex_normal[4]; - char loop_normal[4]; - char bone_solid[4], bone_pose[4], bone_pose_active[4]; - char strip[4], strip_select[4]; - char cframe[4]; - char time_keyframe[4], time_gp_keyframe[4]; - char freestyle_edge_mark[4], freestyle_face_mark[4]; - char time_scrub_background[4]; + unsigned char face_dot[4]; + unsigned char extra_edge_len[4], extra_edge_angle[4], extra_face_angle[4], extra_face_area[4]; + unsigned char normal[4]; + unsigned char vertex_normal[4]; + unsigned char loop_normal[4]; + unsigned char bone_solid[4], bone_pose[4], bone_pose_active[4]; + unsigned char strip[4], strip_select[4]; + unsigned char cframe[4]; + unsigned char time_keyframe[4], time_gp_keyframe[4]; + unsigned char freestyle_edge_mark[4], freestyle_face_mark[4]; + unsigned char time_scrub_background[4]; char _pad5[4]; - char nurb_uline[4], nurb_vline[4]; - char act_spline[4], nurb_sel_uline[4], nurb_sel_vline[4], lastsel_point[4]; + unsigned char nurb_uline[4], nurb_vline[4]; + unsigned char act_spline[4], nurb_sel_uline[4], nurb_sel_vline[4], lastsel_point[4]; - char handle_free[4], handle_auto[4], handle_vect[4], handle_align[4], handle_auto_clamped[4]; - char handle_sel_free[4], handle_sel_auto[4], handle_sel_vect[4], handle_sel_align[4], + unsigned char handle_free[4], handle_auto[4], handle_vect[4], handle_align[4], + handle_auto_clamped[4]; + unsigned char handle_sel_free[4], handle_sel_auto[4], handle_sel_vect[4], handle_sel_align[4], handle_sel_auto_clamped[4]; /** Dopesheet. */ - char ds_channel[4], ds_subchannel[4], ds_ipoline[4]; + unsigned char ds_channel[4], ds_subchannel[4], ds_ipoline[4]; /** Keytypes. */ - char keytype_keyframe[4], keytype_extreme[4], keytype_breakdown[4], keytype_jitter[4], + unsigned char keytype_keyframe[4], keytype_extreme[4], keytype_breakdown[4], keytype_jitter[4], keytype_movehold[4]; /** Keytypes. */ - char keytype_keyframe_select[4], keytype_extreme_select[4], keytype_breakdown_select[4], + unsigned char keytype_keyframe_select[4], keytype_extreme_select[4], keytype_breakdown_select[4], keytype_jitter_select[4], keytype_movehold_select[4]; - char keyborder[4], keyborder_select[4]; + unsigned char keyborder[4], keyborder_select[4]; char _pad4[3]; - char console_output[4], console_input[4], console_info[4], console_error[4]; - char console_cursor[4], console_select[4]; + unsigned char console_output[4], console_input[4], console_info[4], console_error[4]; + unsigned char console_cursor[4], console_select[4]; - char vertex_size, outline_width, obcenter_dia, facedot_size; - char noodle_curving; + unsigned char vertex_size, outline_width, obcenter_dia, facedot_size; + unsigned char noodle_curving; /* syntax for textwindow and nodes */ - char syntaxl[4], syntaxs[4]; // in nodespace used for backdrop matte - char syntaxb[4], syntaxn[4]; // in nodespace used for color input - char syntaxv[4], syntaxc[4]; // in nodespace used for converter group - char syntaxd[4], syntaxr[4]; // in nodespace used for distort + unsigned char syntaxl[4], syntaxs[4]; // in nodespace used for backdrop matte + unsigned char syntaxb[4], syntaxn[4]; // in nodespace used for color input + unsigned char syntaxv[4], syntaxc[4]; // in nodespace used for converter group + unsigned char syntaxd[4], syntaxr[4]; // in nodespace used for distort - char nodeclass_output[4], nodeclass_filter[4]; - char nodeclass_vector[4], nodeclass_texture[4]; - char nodeclass_shader[4], nodeclass_script[4]; - char nodeclass_pattern[4], nodeclass_layout[4]; + unsigned char nodeclass_output[4], nodeclass_filter[4]; + unsigned char nodeclass_vector[4], nodeclass_texture[4]; + unsigned char nodeclass_shader[4], nodeclass_script[4]; + unsigned char nodeclass_pattern[4], nodeclass_layout[4]; /** For sequence editor. */ - char movie[4], movieclip[4], mask[4], image[4], scene[4], audio[4]; - char effect[4], transition[4], meta[4], text_strip[4]; + unsigned char movie[4], movieclip[4], mask[4], image[4], scene[4], audio[4]; + unsigned char effect[4], transition[4], meta[4], text_strip[4]; /** For dopesheet - scale factor for size of keyframes (i.e. height of channels). */ float keyframe_scale_fac; - char editmesh_active[4]; + unsigned char editmesh_active[4]; - char handle_vertex[4]; - char handle_vertex_select[4]; + unsigned char handle_vertex[4]; + unsigned char handle_vertex_select[4]; - char handle_vertex_size; + unsigned char handle_vertex_size; - char clipping_border_3d[4]; + unsigned char clipping_border_3d[4]; - char marker_outline[4], marker[4], act_marker[4], sel_marker[4], dis_marker[4], lock_marker[4]; - char bundle_solid[4]; - char path_before[4], path_after[4]; - char camera_path[4]; - char _pad1[2]; + unsigned char marker_outline[4], marker[4], act_marker[4], sel_marker[4], dis_marker[4], + lock_marker[4]; + unsigned char bundle_solid[4]; + unsigned char path_before[4], path_after[4]; + unsigned char camera_path[4]; + unsigned char _pad1[2]; - char gp_vertex_size; - char gp_vertex[4], gp_vertex_select[4]; + unsigned char gp_vertex_size; + unsigned char gp_vertex[4], gp_vertex_select[4]; - char preview_back[4]; - char preview_stitch_face[4]; - char preview_stitch_edge[4]; - char preview_stitch_vert[4]; - char preview_stitch_stitchable[4]; - char preview_stitch_unstitchable[4]; - char preview_stitch_active[4]; + unsigned char preview_back[4]; + unsigned char preview_stitch_face[4]; + unsigned char preview_stitch_edge[4]; + unsigned char preview_stitch_vert[4]; + unsigned char preview_stitch_stitchable[4]; + unsigned char preview_stitch_unstitchable[4]; + unsigned char preview_stitch_active[4]; /** Two uses, for uvs with modifier applied on mesh and uvs during painting. */ - char uv_shadow[4]; + unsigned char uv_shadow[4]; /** Uvs of other objects. */ - char uv_others[4]; + unsigned char uv_others[4]; /** Outliner - filter match. */ - char match[4]; + unsigned char match[4]; /** Outliner - selected item. */ - char selected_highlight[4]; + unsigned char selected_highlight[4]; /** Outliner - selected object. */ - char selected_object[4]; + unsigned char selected_object[4]; /** Outliner - active object. */ - char active_object[4]; + unsigned char active_object[4]; /** Outliner - edited object. */ - char edited_object[4]; + unsigned char edited_object[4]; /** Outliner - row color difference. */ - char row_alternate[4]; + unsigned char row_alternate[4]; /** Skin modifier root color. */ - char skin_root[4]; + unsigned char skin_root[4]; /* NLA */ /** Active Action + Summary Channel. */ - char anim_active[4]; + unsigned char anim_active[4]; /** Active Action = NULL. */ - char anim_non_active[4]; + unsigned char anim_non_active[4]; /** Preview range overlay. */ - char anim_preview_range[4]; + unsigned char anim_preview_range[4]; /** NLA 'Tweaking' action/strip. */ - char nla_tweaking[4]; + unsigned char nla_tweaking[4]; /** NLA - warning color for duplicate instances of tweaking strip. */ - char nla_tweakdupli[4]; + unsigned char nla_tweakdupli[4]; /** NLA "Transition" strips. */ - char nla_transition[4], nla_transition_sel[4]; + unsigned char nla_transition[4], nla_transition_sel[4]; /** NLA "Meta" strips. */ - char nla_meta[4], nla_meta_sel[4]; + unsigned char nla_meta[4], nla_meta_sel[4]; /** NLA "Sound" strips. */ - char nla_sound[4], nla_sound_sel[4]; + unsigned char nla_sound[4], nla_sound_sel[4]; /* info */ - char info_selected[4], info_selected_text[4]; - char info_error[4], info_error_text[4]; - char info_warning[4], info_warning_text[4]; - char info_info[4], info_info_text[4]; - char info_debug[4], info_debug_text[4]; + unsigned char info_selected[4], info_selected_text[4]; + unsigned char info_error[4], info_error_text[4]; + unsigned char info_warning[4], info_warning_text[4]; + unsigned char info_info[4], info_info_text[4]; + unsigned char info_debug[4], info_debug_text[4]; - char paint_curve_pivot[4]; - char paint_curve_handle[4]; + unsigned char paint_curve_pivot[4]; + unsigned char paint_curve_handle[4]; - char metadatabg[4]; - char metadatatext[4]; + unsigned char metadatabg[4]; + unsigned char metadatatext[4]; char _pad2[4]; } ThemeSpace; /* set of colors for use as a custom color set for Objects/Bones wire drawing */ typedef struct ThemeWireColor { - char solid[4]; - char select[4]; - char active[4]; + unsigned char solid[4]; + unsigned char select[4]; + unsigned char active[4]; /** #eWireColor_Flags. */ short flag; @@ -958,6 +960,7 @@ typedef enum eUserpref_UI_Flag2 { USER_UIFLAG2_UNUSED_3 = (1 << 3), /* dirty */ } eUserpref_UI_Flag2; +/** #UserDef.gpu_flag */ typedef enum eUserpref_GPU_Flag { USER_GPU_FLAG_NO_DEPT_PICK = (1 << 0), USER_GPU_FLAG_NO_EDIT_MODE_SMOOTH_WIRE = (1 << 1), @@ -1066,7 +1069,6 @@ typedef enum eText_Draw_Options { * #UserDef.gp_settings */ typedef enum eGP_UserdefSettings { GP_PAINT_UNUSED_0 = (1 << 0), - GP_PAINT_DOSIMPLIFY = (1 << 1), } eGP_UserdefSettings; enum { diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 2484e432795..713ddfa0067 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -1565,7 +1565,7 @@ static void rna_def_brush(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; -static const EnumPropertyItem color_gradient_items[] = { + static const EnumPropertyItem color_gradient_items[] = { {0, "COLOR", 0, "Color", "Paint with a single color"}, {BRUSH_USE_GRADIENT, "GRADIENT", 0, "Gradient", "Paint with a gradient"}, {0, NULL, 0, NULL, NULL}, diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index d221b7005f6..6bfd2b9f63b 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -94,7 +94,7 @@ static void rna_CurveMapping_clip_set(PointerRNA *ptr, bool value) cumap->flag &= ~CUMA_DO_CLIP; } - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); } static void rna_CurveMapping_black_level_set(PointerRNA *ptr, const float *values) @@ -103,7 +103,7 @@ static void rna_CurveMapping_black_level_set(PointerRNA *ptr, const float *value cumap->black[0] = values[0]; cumap->black[1] = values[1]; cumap->black[2] = values[2]; - curvemapping_set_black_white(cumap, NULL, NULL); + BKE_curvemapping_set_black_white(cumap, NULL, NULL); } static void rna_CurveMapping_white_level_set(PointerRNA *ptr, const float *values) @@ -112,7 +112,7 @@ static void rna_CurveMapping_white_level_set(PointerRNA *ptr, const float *value cumap->white[0] = values[0]; cumap->white[1] = values[1]; cumap->white[2] = values[2]; - curvemapping_set_black_white(cumap, NULL, NULL); + BKE_curvemapping_set_black_white(cumap, NULL, NULL); } static void rna_CurveMapping_tone_update(Main *UNUSED(bmain), @@ -368,7 +368,7 @@ static void rna_ColorRampElement_remove(struct ColorBand *coba, static void rna_CurveMap_remove_point(CurveMap *cuma, ReportList *reports, PointerRNA *point_ptr) { CurveMapPoint *point = point_ptr->data; - if (curvemap_remove_point(cuma, point) == false) { + if (BKE_curvemap_remove_point(cuma, point) == false) { BKE_report(reports, RPT_ERROR, "Unable to remove curve point"); return; } @@ -518,7 +518,7 @@ static void rna_ColorManagedViewSettings_use_curves_set(PointerRNA *ptr, bool va view_settings->flag |= COLORMANAGE_VIEW_USE_CURVES; if (view_settings->curve_mapping == NULL) { - view_settings->curve_mapping = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); + view_settings->curve_mapping = BKE_curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); } } else { @@ -669,7 +669,7 @@ static void rna_ColorManagement_update(Main *UNUSED(bmain), Scene *UNUSED(scene) } } -/* this function only exists because #curvemap_evaluateF uses a 'const' qualifier */ +/* this function only exists because #BKE_curvemap_evaluateF uses a 'const' qualifier */ static float rna_CurveMap_evaluateF(struct CurveMap *cuma, ReportList *reports, float value) { if (!cuma->table) { @@ -679,12 +679,12 @@ static float rna_CurveMap_evaluateF(struct CurveMap *cuma, ReportList *reports, "CurveMap table not initialized, call initialize() on CurveMapping owner of the CurveMap"); return 0.0f; } - return curvemap_evaluateF(cuma, value); + return BKE_curvemap_evaluateF(cuma, value); } static void rna_CurveMap_initialize(struct CurveMapping *cumap) { - curvemapping_initialize(cumap); + BKE_curvemapping_initialize(cumap); } #else @@ -729,7 +729,7 @@ static void rna_def_curvemap_points_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_sdna(srna, "CurveMap"); RNA_def_struct_ui_text(srna, "Curve Map Point", "Collection of Curve Map Points"); - func = RNA_def_function(srna, "new", "curvemap_insert"); + func = RNA_def_function(srna, "new", "BKE_curvemap_insert"); RNA_def_function_ui_description(func, "Add point to CurveMap"); parm = RNA_def_float(func, "position", @@ -889,7 +889,7 @@ static void rna_def_curvemapping(BlenderRNA *brna) prop, "White Level", "For RGB curves, the color that white is mapped to"); RNA_def_property_float_funcs(prop, NULL, "rna_CurveMapping_white_level_set", NULL); - func = RNA_def_function(srna, "update", "curvemapping_changed_all"); + func = RNA_def_function(srna, "update", "BKE_curvemapping_changed_all"); RNA_def_function_ui_description(func, "Update curve mapping after making changes"); func = RNA_def_function(srna, "initialize", "rna_CurveMap_initialize"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index ef8b671116a..531ff27798d 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -735,7 +735,7 @@ static void rna_GPencilInterpolateSettings_type_set(PointerRNA *ptr, int value) /* init custom interpolation curve here now the first time it's used */ if ((settings->type == GP_IPO_CURVEMAP) && (settings->custom_ipo == NULL)) { - settings->custom_ipo = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + settings->custom_ipo = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } } diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index c1ef31a80cd..80a4defba00 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1853,7 +1853,8 @@ static void rna_def_editor(BlenderRNA *brna) prop = RNA_def_property(srna, "show_overlay", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "over_flag", SEQ_EDIT_OVERLAY_SHOW); - RNA_def_property_ui_text(prop, "Draw Axes", "Partial overlay on top of the sequencer"); + RNA_def_property_ui_text( + prop, "Show Overlay", "Partial overlay on top of the sequencer with a frame offset"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); prop = RNA_def_property(srna, "use_overlay_lock", PROP_BOOLEAN, PROP_NONE); @@ -1864,7 +1865,7 @@ static void rna_def_editor(BlenderRNA *brna) /* access to fixed and relative frame */ prop = RNA_def_property(srna, "overlay_frame", PROP_INT, PROP_NONE); - RNA_def_property_ui_text(prop, "Overlay Offset", ""); + RNA_def_property_ui_text(prop, "Overlay Offset", "Number of frames to offset"); RNA_def_property_int_funcs( prop, "rna_SequenceEditor_overlay_frame_get", "rna_SequenceEditor_overlay_frame_set", NULL); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index bed06171cbf..38cb3e1d222 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -4590,10 +4590,6 @@ static void rna_def_userdef_edit(BlenderRNA *brna) "Grease Pencil Euclidean Distance", "Distance moved by mouse when drawing stroke to include"); - prop = RNA_def_property(srna, "use_grease_pencil_simplify_stroke", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gp_settings", GP_PAINT_DOSIMPLIFY); - RNA_def_property_ui_text(prop, "Grease Pencil Simplify Stroke", "Simplify the final stroke"); - prop = RNA_def_property(srna, "grease_pencil_eraser_radius", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "gp_eraser"); RNA_def_property_range(prop, 1, 500); diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 72215659915..7ae5fda7111 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -79,7 +79,12 @@ static bool isDisabled(const struct Scene *UNUSED(scene), { ArmatureModifierData *amd = (ArmatureModifierData *)md; - return !amd->object; + /* The object type check is only needed here in case we have a placeholder + * object assigned (because the library containing the armature is missing). + * + * In other cases it should be impossible. + */ + return !amd->object || amd->object->type != OB_ARMATURE; } static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, void *userData) diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index c12fb9c1bd8..2f902db9340 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -49,7 +49,7 @@ static void initData(ModifierData *md) HookModifierData *hmd = (HookModifierData *)md; hmd->force = 1.0; - hmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + hmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); hmd->falloff_type = eHook_Falloff_Smooth; hmd->flag = 0; } @@ -61,7 +61,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla modifier_copyData_generic(md, target, flag); - thmd->curfalloff = curvemapping_copy(hmd->curfalloff); + thmd->curfalloff = BKE_curvemapping_copy(hmd->curfalloff); thmd->indexar = MEM_dupallocN(hmd->indexar); } @@ -88,7 +88,7 @@ static void freeData(ModifierData *md) { HookModifierData *hmd = (HookModifierData *)md; - curvemapping_free(hmd->curfalloff); + BKE_curvemapping_free(hmd->curfalloff); MEM_SAFE_FREE(hmd->indexar); } @@ -174,7 +174,7 @@ static float hook_falloff(const struct HookData_cb *hd, const float len_sq) break; #endif case eHook_Falloff_Curve: - fac = curvemapping_evaluateF(hd->curfalloff, 0, fac); + fac = BKE_curvemapping_evaluateF(hd->curfalloff, 0, fac); break; case eHook_Falloff_Sharp: fac = fac * fac; @@ -262,11 +262,11 @@ static void deformVerts_do(HookModifierData *hmd, if (hmd->curfalloff == NULL) { /* should never happen, but bad lib linking could cause it */ - hmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + hmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } if (hmd->curfalloff) { - curvemapping_initialize(hmd->curfalloff); + BKE_curvemapping_initialize(hmd->curfalloff); } /* Generic data needed for applying per-vertex calculations (initialize all members) */ diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 6441ab69391..7155498c942 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -50,7 +50,7 @@ static void initData(ModifierData *md) { WarpModifierData *wmd = (WarpModifierData *)md; - wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + wmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); wmd->texture = NULL; wmd->strength = 1.0f; wmd->falloff_radius = 1.0f; @@ -65,7 +65,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla modifier_copyData_generic(md, target, flag); - twmd->curfalloff = curvemapping_copy(wmd->curfalloff); + twmd->curfalloff = BKE_curvemapping_copy(wmd->curfalloff); } static void requiredDataMask(Object *UNUSED(ob), @@ -100,7 +100,7 @@ static bool dependsOnTime(ModifierData *md) static void freeData(ModifierData *md) { WarpModifierData *wmd = (WarpModifierData *)md; - curvemapping_free(wmd->curfalloff); + BKE_curvemapping_free(wmd->curfalloff); } static bool isDisabled(const struct Scene *UNUSED(scene), @@ -188,11 +188,11 @@ static void warpModifier_do(WarpModifierData *wmd, } if (wmd->curfalloff == NULL) { /* should never happen, but bad lib linking could cause it */ - wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + wmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } if (wmd->curfalloff) { - curvemapping_initialize(wmd->curfalloff); + BKE_curvemapping_initialize(wmd->curfalloff); } invert_m4_m4(obinv, ob->obmat); @@ -247,7 +247,7 @@ static void warpModifier_do(WarpModifierData *wmd, fac = 1.0f; break; case eWarp_Falloff_Curve: - fac = curvemapping_evaluateF(wmd->curfalloff, 0, fac); + fac = BKE_curvemapping_evaluateF(wmd->curfalloff, 0, fac); break; case eWarp_Falloff_Sharp: fac = fac * fac; diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index 61872cbe464..486d5c90bef 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -72,7 +72,7 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm } if (cmap && falloff_type == MOD_WVG_MAPPING_CURVE) { - curvemapping_initialize(cmap); + BKE_curvemapping_initialize(cmap); } /* Map each weight (vertex) to its new value, accordingly to the chosen mode. */ @@ -83,7 +83,7 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm /* Closely matches PROP_SMOOTH and similar. */ switch (falloff_type) { case MOD_WVG_MAPPING_CURVE: - fac = curvemapping_evaluateF(cmap, 0, fac); + fac = BKE_curvemapping_evaluateF(cmap, 0, fac); break; case MOD_WVG_MAPPING_SHARP: fac = fac * fac; diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index 207c5851602..045ba78fab5 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -57,8 +57,8 @@ static void initData(ModifierData *md) wmd->falloff_type = MOD_WVG_MAPPING_NONE; wmd->default_weight = 0.0f; - wmd->cmap_curve = curvemapping_add(1, 0.0, 0.0, 1.0, 1.0); - curvemapping_initialize(wmd->cmap_curve); + wmd->cmap_curve = BKE_curvemapping_add(1, 0.0, 0.0, 1.0, 1.0); + BKE_curvemapping_initialize(wmd->cmap_curve); wmd->rem_threshold = 0.01f; wmd->add_threshold = 0.01f; @@ -71,7 +71,7 @@ static void initData(ModifierData *md) static void freeData(ModifierData *md) { WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md; - curvemapping_free(wmd->cmap_curve); + BKE_curvemapping_free(wmd->cmap_curve); } static void copyData(const ModifierData *md, ModifierData *target, const int flag) @@ -81,7 +81,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla modifier_copyData_generic(md, target, flag); - twmd->cmap_curve = curvemapping_copy(wmd->cmap_curve); + twmd->cmap_curve = BKE_curvemapping_copy(wmd->cmap_curve); } static void requiredDataMask(Object *UNUSED(ob), diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.c b/source/blender/nodes/composite/nodes/node_composite_curves.c index 7b2e7329432..8d338ba5750 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.c +++ b/source/blender/nodes/composite/nodes/node_composite_curves.c @@ -35,7 +35,7 @@ static void node_composit_init_curves_time(bNodeTree *UNUSED(ntree), bNode *node { node->custom1 = 1; node->custom2 = 250; - node->storage = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } void register_node_type_cmp_curve_time(void) @@ -64,7 +64,7 @@ static bNodeSocketTemplate cmp_node_curve_vec_out[] = { static void node_composit_init_curve_vec(bNodeTree *UNUSED(ntree), bNode *node) { - node->storage = curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); } void register_node_type_cmp_curve_vec(void) @@ -96,7 +96,7 @@ static bNodeSocketTemplate cmp_node_curve_rgb_out[] = { static void node_composit_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode *node) { - node->storage = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); } void register_node_type_cmp_curve_rgb(void) diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c index 7fcaae0bd9c..29cdf28fb2d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c +++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c @@ -36,14 +36,14 @@ static bNodeSocketTemplate cmp_node_huecorrect_out[] = { static void node_composit_init_huecorrect(bNodeTree *UNUSED(ntree), bNode *node) { - CurveMapping *cumapping = node->storage = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + CurveMapping *cumapping = node->storage = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); int c; cumapping->preset = CURVE_PRESET_MID9; for (c = 0; c < 3; c++) { CurveMap *cuma = &cumapping->cm[c]; - curvemap_reset(cuma, &cumapping->clipr, cumapping->preset, CURVEMAP_SLOPE_POSITIVE); + BKE_curvemap_reset(cuma, &cumapping->clipr, cumapping->preset, CURVEMAP_SLOPE_POSITIVE); } /* default to showing Saturation */ diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c index 2ab68e2f7cf..e9a825b5b3f 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.c @@ -47,7 +47,7 @@ void node_free_curves(bNode *node) { - curvemapping_free(node->storage); + BKE_curvemapping_free(node->storage); } void node_free_standard_storage(bNode *node) @@ -59,7 +59,7 @@ void node_free_standard_storage(bNode *node) void node_copy_curves(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node) { - dest_node->storage = curvemapping_copy(src_node->storage); + dest_node->storage = BKE_curvemapping_copy(src_node->storage); } void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), @@ -73,7 +73,7 @@ void *node_initexec_curves(bNodeExecContext *UNUSED(context), bNode *node, bNodeInstanceKey UNUSED(key)) { - curvemapping_initialize(node->storage); + BKE_curvemapping_initialize(node->storage); return NULL; /* unused return */ } diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index 1b96dabac77..baf86951fe0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -47,12 +47,12 @@ static void node_shader_exec_curve_vec(void *UNUSED(data), /* stack order input: vec */ /* stack order output: vec */ nodestack_get_vec(vec, SOCK_VECTOR, in[1]); - curvemapping_evaluate3F(node->storage, out[0]->vec, vec); + BKE_curvemapping_evaluate3F(node->storage, out[0]->vec, vec); } static void node_shader_init_curve_vec(bNodeTree *UNUSED(ntree), bNode *node) { - node->storage = curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); } static int gpu_shader_curve_vec(GPUMaterial *mat, @@ -64,7 +64,7 @@ static int gpu_shader_curve_vec(GPUMaterial *mat, float *array, layer; int size; - curvemapping_table_RGBA(node->storage, &array, &size); + BKE_curvemapping_table_RGBA(node->storage, &array, &size); GPUNodeLink *tex = GPU_color_band(mat, size, array, &layer); return GPU_stack_link(mat, node, "curves_vec", in, out, tex, GPU_constant(&layer)); @@ -111,7 +111,7 @@ static void node_shader_exec_curve_rgb(void *UNUSED(data), /* stack order output: vec */ nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); nodestack_get_vec(vec, SOCK_VECTOR, in[1]); - curvemapping_evaluateRGBF(node->storage, out[0]->vec, vec); + BKE_curvemapping_evaluateRGBF(node->storage, out[0]->vec, vec); if (fac != 1.0f) { interp_v3_v3v3(out[0]->vec, vec, out[0]->vec, fac); } @@ -119,7 +119,7 @@ static void node_shader_exec_curve_rgb(void *UNUSED(data), static void node_shader_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode *node) { - node->storage = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); } static int gpu_shader_curve_rgb(GPUMaterial *mat, @@ -134,8 +134,8 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat, CurveMapping *cumap = node->storage; - curvemapping_initialize(cumap); - curvemapping_table_RGBA(cumap, &array, &size); + BKE_curvemapping_initialize(cumap); + BKE_curvemapping_table_RGBA(cumap, &array, &size); GPUNodeLink *tex = GPU_color_band(mat, size, array, &layer); float ext_rgba[4][4]; diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c index 1087d05d040..2e2687bd50e 100644 --- a/source/blender/nodes/texture/nodes/node_texture_curves.c +++ b/source/blender/nodes/texture/nodes/node_texture_curves.c @@ -39,8 +39,8 @@ static void time_colorfn( fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1); } - curvemapping_initialize(node->storage); - fac = curvemapping_evaluateF(node->storage, 0, fac); + BKE_curvemapping_initialize(node->storage); + fac = BKE_curvemapping_evaluateF(node->storage, 0, fac); out[0] = CLAMPIS(fac, 0.0f, 1.0f); } @@ -58,7 +58,7 @@ static void time_init(bNodeTree *UNUSED(ntree), bNode *node) { node->custom1 = 1; node->custom2 = 250; - node->storage = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } void register_node_type_tex_curve_time(void) @@ -91,7 +91,7 @@ static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, float cin[4]; tex_input_rgba(cin, in[0], p, thread); - curvemapping_evaluateRGBF(node->storage, out, cin); + BKE_curvemapping_evaluateRGBF(node->storage, out, cin); out[3] = cin[3]; } @@ -107,7 +107,7 @@ static void rgb_exec(void *data, static void rgb_init(bNodeTree *UNUSED(ntree), bNode *node) { - node->storage = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); } void register_node_type_tex_curve_rgb(void) diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 50c61dd0061..70bfa76e344 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -1505,6 +1505,10 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, /* calculate combine string length */ totbuf += id_str_size + name_str_size + desc_str_size + 3; /* 3 is for '\0's */ } + else if (item == Py_None) { + /* Only set since the rest is cleared. */ + items[i].identifier = ""; + } else { MEM_freeN(items); PyErr_SetString(PyExc_TypeError, @@ -2979,6 +2983,8 @@ PyDoc_STRVAR( " When an item only contains 4 items they define ``(identifier, name, description, " "number)``.\n" "\n" + " Separators may be added using None instead of a tuple." + "\n" " For dynamic values a callback can be passed which returns a list in\n" " the same format as the static list.\n" " This function must take 2 arguments ``(self, context)``, **context may be None**.\n" diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 8764671ae04..d620cd38b76 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -642,7 +642,7 @@ void RE_FreeRender(Render *re) BLI_freelistN(&re->view_layers); BLI_freelistN(&re->r.views); - curvemapping_free_data(&re->r.mblur_shutter_curve); + BKE_curvemapping_free_data(&re->r.mblur_shutter_curve); /* main dbase can already be invalid now, some database-free code checks it */ re->main = NULL; @@ -772,12 +772,12 @@ static void re_init_resolution(Render *re, Render *source, int winx, int winy, r void render_copy_renderdata(RenderData *to, RenderData *from) { BLI_freelistN(&to->views); - curvemapping_free_data(&to->mblur_shutter_curve); + BKE_curvemapping_free_data(&to->mblur_shutter_curve); *to = *from; BLI_duplicatelist(&to->views, &from->views); - curvemapping_copy_data(&to->mblur_shutter_curve, &from->mblur_shutter_curve); + BKE_curvemapping_copy_data(&to->mblur_shutter_curve, &from->mblur_shutter_curve); } /* what doesn't change during entire render sequence */ diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 75ddf7e0b22..3ede55434b9 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -557,8 +557,8 @@ static float density_falloff(PointDensityRangeData *pdr, int index, float square } if (pdr->density_curve && dist != 0.0f) { - curvemapping_initialize(pdr->density_curve); - density = curvemapping_evaluateF(pdr->density_curve, 0, density / dist) * dist; + BKE_curvemapping_initialize(pdr->density_curve); + density = BKE_curvemapping_evaluateF(pdr->density_curve, 0, density / dist) * dist; } return density; diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 6b3bd1ea24e..ba6a0c4ebe1 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -403,7 +403,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) /* XXX todo, multiline drag draws... but maybe not, more types mixed wont work well */ GPU_blend(true); for (drag = wm->drags.first; drag; drag = drag->next) { - const char text_col[] = {255, 255, 255, 255}; + const uchar text_col[] = {255, 255, 255, 255}; int iconsize = UI_DPI_ICON_SIZE; int padding = 4 * UI_DPI_FAC; @@ -461,7 +461,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) drag_rect_minmax(rect, x, y, x + w, y + iconsize); } else { - UI_fontstyle_draw_simple(fstyle, x, y, wm_drag_name(drag), (uchar *)text_col); + UI_fontstyle_draw_simple(fstyle, x, y, wm_drag_name(drag), text_col); } /* operator name with roundbox */ diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 4024fc628f0..c146097aeb0 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -752,15 +752,14 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) } } -void wm_draw_upside_down(int sizex, int sizey) +void wm_draw_upside_down(int sizex, int sizey, bool to_srgb) { - /* Don't use imm here, this is called from a separate thread with no imm available. */ /* wmOrtho for the screen has this same offset */ const float halfx = GLA_PIXEL_OFS / sizex; const float halfy = GLA_PIXEL_OFS / sizey; - GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR); + GPUShader *shader = GPU_shader_get_builtin_shader(to_srgb ? GPU_SHADER_2D_IMAGE_RECT_LINEAR_TO_SRGB : GPU_SHADER_2D_IMAGE_RECT_COLOR); GPU_shader_bind(shader); glUniform1i(GPU_shader_get_uniform_ensure(shader, "image"), 0); @@ -798,7 +797,7 @@ static void wm_draw_window_upside_down_onscreen(bContext *C, wmWindow *win) glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(texture)); - wm_draw_upside_down(win->sizex, win->sizey); + wm_draw_upside_down(win->sizex, win->sizey, false); glBindTexture(GL_TEXTURE_2D, 0); diff --git a/source/blender/windowmanager/intern/wm_xr.c b/source/blender/windowmanager/intern/wm_xr.c index 4d6dd80fb80..fbe6bf906d1 100644 --- a/source/blender/windowmanager/intern/wm_xr.c +++ b/source/blender/windowmanager/intern/wm_xr.c @@ -362,11 +362,11 @@ static GHOST_ContextHandle wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view if (g_xr_surface->secondary_ghost_ctx && GHOST_isUpsideDownContext(g_xr_surface->secondary_ghost_ctx)) { GPU_texture_bind(texture, 0); - wm_draw_upside_down(draw_view->width, draw_view->height); + wm_draw_upside_down(draw_view->width, draw_view->height, draw_view->expects_srgb_buffer); GPU_texture_unbind(texture); } else { - GPU_viewport_draw_to_screen(viewport, &rect); + GPU_viewport_draw_to_screen_ex(viewport, &rect, draw_view->expects_srgb_buffer); } GPU_viewport_unbind(viewport); diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index f28552916f2..a98c47b11c2 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -98,7 +98,7 @@ void wm_open_init_use_scripts(wmOperator *op, bool use_prefs); /* wm_draw.c */ struct GPUOffScreen; void wm_draw_offscreen_texture_parameters(struct GPUOffScreen *offscreen); -void wm_draw_upside_down(int sizex, int sizey); +void wm_draw_upside_down(int sizex, int sizey, bool to_srgb); #ifdef WITH_OPENXR /* wm_xr.c */ |