diff options
Diffstat (limited to 'source/blender/blenkernel')
27 files changed, 805 insertions, 417 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_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index 9ec872f3676..997f1fc82e1 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -197,6 +197,10 @@ void BKE_gpencil_simplify_stroke(struct bGPDstroke *gps, float factor); void BKE_gpencil_simplify_fixed(struct bGPDstroke *gps); void BKE_gpencil_subdivide(struct bGPDstroke *gps, int level, int flag); bool BKE_gpencil_trim_stroke(struct bGPDstroke *gps); +void BKE_gpencil_merge_distance_stroke(struct bGPDframe *gpf, + struct bGPDstroke *gps, + const float threshold, + const bool use_unselected); void BKE_gpencil_stroke_2d_flat(const struct bGPDspoint *points, int totpoints, @@ -212,6 +216,7 @@ void BKE_gpencil_stroke_2d_flat_ref(const struct bGPDspoint *ref_points, void BKE_gpencil_transform(struct bGPdata *gpd, float mat[4][4]); +bool BKE_gpencil_sample_stroke(struct bGPDstroke *gps, const float dist, const bool select); bool BKE_gpencil_smooth_stroke(struct bGPDstroke *gps, int i, float inf); bool BKE_gpencil_smooth_stroke_strength(struct bGPDstroke *gps, int point_index, float influence); bool BKE_gpencil_smooth_stroke_thickness(struct bGPDstroke *gps, int point_index, float influence); diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 28769ba7de9..c0ac71f9c96 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -223,7 +223,7 @@ void BKE_main_id_flag_all(struct Main *bmain, const int flag, const bool value); void BKE_main_id_clear_newpoins(struct Main *bmain); -void BLE_main_id_refcount_recompute(struct Main *bmain, const bool do_linked_only); +void BKE_main_id_refcount_recompute(struct Main *bmain, const bool do_linked_only); void BKE_main_lib_objects_recalc_all(struct Main *bmain); 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/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 4ceae89dfbb..0d94fbe648f 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -372,7 +372,7 @@ static void setup_app_data(bContext *C, * lib_link on local IDs using linked ones. * There is no real way to predict amount of changes here, so we have to fully redo * refcounting . */ - BLE_main_id_refcount_recompute(bmain, true); + BKE_main_id_refcount_recompute(bmain, true); } } 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..ed4c6848751 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1404,6 +1404,313 @@ void BKE_gpencil_dvert_ensure(bGPDstroke *gps) /* ************************************************** */ +static void stroke_defvert_create_nr_list(MDeformVert *dv_list, + int count, + ListBase *result, + int *totweight) +{ + LinkData *ld; + MDeformVert *dv; + MDeformWeight *dw; + int i, j; + int tw = 0; + for (i = 0; i < count; i++) { + dv = &dv_list[i]; + + /* find def_nr in list, if not exist, then create one */ + for (j = 0; j < dv->totweight; j++) { + int found = 0; + dw = &dv->dw[j]; + for (ld = result->first; ld; ld = ld->next) { + if (ld->data == POINTER_FROM_INT(dw->def_nr)) { + found = 1; + break; + } + } + if (!found) { + ld = MEM_callocN(sizeof(LinkData), "def_nr_item"); + ld->data = POINTER_FROM_INT(dw->def_nr); + BLI_addtail(result, ld); + tw++; + } + } + } + + *totweight = tw; +} + +static MDeformVert *stroke_defvert_new_count(int count, int totweight, ListBase *def_nr_list) +{ + int i, j; + LinkData *ld; + MDeformVert *dst = MEM_mallocN(count * sizeof(MDeformVert), "new_deformVert"); + + dst->totweight = totweight; + + for (i = 0; i < count; i++) { + dst[i].dw = MEM_mallocN(sizeof(MDeformWeight) * totweight, "new_deformWeight"); + j = 0; + /* re-assign deform groups */ + for (ld = def_nr_list->first; ld; ld = ld->next) { + dst[i].dw[j].def_nr = POINTER_AS_INT(ld->data); + j++; + } + } + + return dst; +} + +static void stroke_interpolate_deform_weights( + bGPDstroke *gps, int index_from, int index_to, float ratio, MDeformVert *vert) +{ + const MDeformVert *vl = &gps->dvert[index_from]; + const MDeformVert *vr = &gps->dvert[index_to]; + int i; + + for (i = 0; i < vert->totweight; i++) { + float wl = defvert_find_weight(vl, vert->dw[i].def_nr); + float wr = defvert_find_weight(vr, vert->dw[i].def_nr); + vert->dw[i].weight = interpf(wr, wl, ratio); + } +} + +static int stroke_march_next_point(const bGPDstroke *gps, + const int index_next_pt, + const float *current, + const float dist, + float *result, + float *pressure, + float *strength, + float *ratio_result, + int *index_from, + int *index_to) +{ + float remaining_till_next = 0.0f; + float remaining_march = dist; + float step_start[3]; + float point[3]; + int next_point_index = index_next_pt; + bGPDspoint *pt = NULL; + + if (!(next_point_index < gps->totpoints)) { + return -1; + } + + copy_v3_v3(step_start, current); + pt = &gps->points[next_point_index]; + copy_v3_v3(point, &pt->x); + remaining_till_next = len_v3v3(point, step_start); + + while (remaining_till_next < remaining_march) { + remaining_march -= remaining_till_next; + pt = &gps->points[next_point_index]; + copy_v3_v3(point, &pt->x); + copy_v3_v3(step_start, point); + next_point_index++; + if (!(next_point_index < gps->totpoints)) { + next_point_index = gps->totpoints - 1; + break; + } + pt = &gps->points[next_point_index]; + copy_v3_v3(point, &pt->x); + remaining_till_next = len_v3v3(point, step_start); + } + if (remaining_till_next < remaining_march) { + pt = &gps->points[next_point_index]; + copy_v3_v3(result, &pt->x); + *pressure = gps->points[next_point_index].pressure; + *strength = gps->points[next_point_index].strength; + + *index_from = next_point_index - 1; + *index_to = next_point_index; + *ratio_result = 1.0f; + + return 0; + } + else { + float ratio = remaining_march / remaining_till_next; + interp_v3_v3v3(result, step_start, point, ratio); + *pressure = interpf( + gps->points[next_point_index].pressure, gps->points[next_point_index - 1].pressure, ratio); + *strength = interpf( + gps->points[next_point_index].strength, gps->points[next_point_index - 1].strength, ratio); + + *index_from = next_point_index - 1; + *index_to = next_point_index; + *ratio_result = ratio; + + return next_point_index; + } +} + +static int stroke_march_next_point_no_interp(const bGPDstroke *gps, + const int index_next_pt, + const float *current, + const float dist, + float *result) +{ + float remaining_till_next = 0.0f; + float remaining_march = dist; + float step_start[3]; + float point[3]; + int next_point_index = index_next_pt; + bGPDspoint *pt = NULL; + + if (!(next_point_index < gps->totpoints)) { + return -1; + } + + copy_v3_v3(step_start, current); + pt = &gps->points[next_point_index]; + copy_v3_v3(point, &pt->x); + remaining_till_next = len_v3v3(point, step_start); + + while (remaining_till_next < remaining_march) { + remaining_march -= remaining_till_next; + pt = &gps->points[next_point_index]; + copy_v3_v3(point, &pt->x); + copy_v3_v3(step_start, point); + next_point_index++; + if (!(next_point_index < gps->totpoints)) { + next_point_index = gps->totpoints - 1; + break; + } + pt = &gps->points[next_point_index]; + copy_v3_v3(point, &pt->x); + remaining_till_next = len_v3v3(point, step_start); + } + if (remaining_till_next < remaining_march) { + pt = &gps->points[next_point_index]; + copy_v3_v3(result, &pt->x); + return 0; + } + else { + float ratio = remaining_march / remaining_till_next; + interp_v3_v3v3(result, step_start, point, ratio); + return next_point_index; + } +} + +static int stroke_march_count(const bGPDstroke *gps, const float dist) +{ + int point_count = 0; + float point[3]; + int next_point_index = 1; + bGPDspoint *pt = NULL; + + pt = &gps->points[0]; + copy_v3_v3(point, &pt->x); + point_count++; + + while ((next_point_index = stroke_march_next_point_no_interp( + gps, next_point_index, point, dist, point)) > -1) { + point_count++; + if (next_point_index == 0) { + break; /* last point finished */ + } + } + return point_count; +} + +/** + * Resample a stroke + * \param gps: Stroke to sample + * \param dist: Distance of one segment + */ +bool BKE_gpencil_sample_stroke(bGPDstroke *gps, const float dist, const bool select) +{ + bGPDspoint *pt = gps->points; + bGPDspoint *pt1 = NULL; + bGPDspoint *pt2 = NULL; + int i; + LinkData *ld; + ListBase def_nr_list = {0}; + + if (gps->totpoints < 2 || dist < FLT_EPSILON) { + return false; + } + /* TODO: Implement feature point preservation. */ + int count = stroke_march_count(gps, dist); + + bGPDspoint *new_pt = MEM_callocN(sizeof(bGPDspoint) * count, "gp_stroke_points_sampled"); + MDeformVert *new_dv = NULL; + + int result_totweight; + + if (gps->dvert != NULL) { + stroke_defvert_create_nr_list(gps->dvert, count, &def_nr_list, &result_totweight); + new_dv = stroke_defvert_new_count(count, result_totweight, &def_nr_list); + } + + int next_point_index = 1; + i = 0; + float pressure, strength, ratio_result; + int index_from, index_to; + float last_coord[3]; + + /* 1st point is always at the start */ + pt1 = &gps->points[0]; + copy_v3_v3(last_coord, &pt1->x); + pt2 = &new_pt[i]; + copy_v3_v3(&pt2->x, last_coord); + new_pt[i].pressure = pt[0].pressure; + new_pt[i].strength = pt[0].strength; + if (select) { + new_pt[i].flag |= GP_SPOINT_SELECT; + } + i++; + + if (new_dv) { + stroke_interpolate_deform_weights(gps, 0, 0, 0, &new_dv[0]); + } + + /* the rest */ + while ((next_point_index = stroke_march_next_point(gps, + next_point_index, + last_coord, + dist, + last_coord, + &pressure, + &strength, + &ratio_result, + &index_from, + &index_to)) > -1) { + pt2 = &new_pt[i]; + copy_v3_v3(&pt2->x, last_coord); + new_pt[i].pressure = pressure; + new_pt[i].strength = strength; + if (select) { + new_pt[i].flag |= GP_SPOINT_SELECT; + } + + if (new_dv) { + stroke_interpolate_deform_weights(gps, index_from, index_to, ratio_result, &new_dv[i]); + } + + i++; + if (next_point_index == 0) { + break; /* last point finished */ + } + } + + gps->points = new_pt; + gps->totpoints = i; + MEM_freeN(pt); /* original */ + + if (new_dv) { + BKE_gpencil_free_stroke_weights(gps); + while ((ld = BLI_pophead(&def_nr_list))) { + MEM_freeN(ld); + } + gps->dvert = new_dv; + } + + gps->flag |= GP_STROKE_RECALC_GEOMETRY; + gps->tot_triangles = 0; + + return true; +} + /** * Apply smooth to stroke point * \param gps: Stroke to smooth @@ -1632,13 +1939,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; @@ -2006,6 +2313,12 @@ bool BKE_gpencil_close_stroke(bGPDstroke *gps) pt2 = &gps->points[0]; float dist_close = len_v3v3(&pt1->x, &pt2->x); + /* if the distance to close is very small, don't need add points and just enable cyclic. */ + if (dist_close <= dist_avg) { + gps->flag |= GP_STROKE_CYCLIC; + return true; + } + /* Calc number of points required using the average distance. */ int tot_newpoints = MAX2(dist_close / dist_avg, 1); @@ -2022,9 +2335,11 @@ bool BKE_gpencil_close_stroke(bGPDstroke *gps) pt2 = &gps->points[0]; bGPDspoint *pt = &gps->points[old_tot]; for (int i = 1; i < tot_newpoints + 1; i++, pt++) { - float step = ((float)i / (float)tot_newpoints); + float step = (tot_newpoints > 1) ? ((float)i / (float)tot_newpoints) : 0.99f; /* Clamp last point to be near, but not on top of first point. */ - CLAMP(step, 0.0f, 0.99f); + if ((tot_newpoints > 1) && (i == tot_newpoints)) { + step *= 0.99f; + } /* Average point. */ interp_v3_v3v3(&pt->x, &pt1->x, &pt2->x, step); @@ -2056,7 +2371,6 @@ bool BKE_gpencil_close_stroke(bGPDstroke *gps) return true; } - /* Dissolve points in stroke */ void BKE_gpencil_dissolve_points(bGPDframe *gpf, bGPDstroke *gps, const short tag) { @@ -2138,3 +2452,81 @@ void BKE_gpencil_dissolve_points(bGPDframe *gpf, bGPDstroke *gps, const short ta gps->tot_triangles = 0; } } + +/* Merge by distance ------------------------------------- */ +/* Reduce a series of points when the distance is below a threshold. + * Special case for first and last points (both are keeped) for other points, + * the merge point always is at first point. + * \param gpf: Grease Pencil frame + * \param gps: Grease Pencil stroke + * \param threshold: Distance between points + * \param use_unselected: Set to true to analyze all stroke and not only selected points + */ +void BKE_gpencil_merge_distance_stroke(bGPDframe *gpf, + bGPDstroke *gps, + const float threshold, + const bool use_unselected) +{ + bGPDspoint *pt = NULL; + bGPDspoint *pt_next = NULL; + float tagged = false; + /* Use square distance to speed up loop */ + const float th_square = threshold * threshold; + /* Need to have something to merge. */ + if (gps->totpoints < 2) { + return; + } + int i = 0; + int step = 1; + while ((i < gps->totpoints - 1) && (i + step < gps->totpoints)) { + pt = &gps->points[i]; + if (pt->flag & GP_SPOINT_TAG) { + i++; + step = 1; + continue; + } + pt_next = &gps->points[i + step]; + /* Do not recalc tagged points. */ + if (pt_next->flag & GP_SPOINT_TAG) { + step++; + continue; + } + /* Check if contiguous points are selected. */ + if (!use_unselected) { + if (((pt->flag & GP_SPOINT_SELECT) == 0) || ((pt_next->flag & GP_SPOINT_SELECT) == 0)) { + i++; + step = 1; + continue; + } + } + float len_square = len_squared_v3v3(&pt->x, &pt_next->x); + if (len_square <= th_square) { + tagged = true; + if (i != gps->totpoints - 1) { + /* Tag second point for delete. */ + pt_next->flag |= GP_SPOINT_TAG; + } + else { + pt->flag |= GP_SPOINT_TAG; + } + /* Jump to next pair of points, keeping first point segment equals.*/ + step++; + } + else { + /* Analyze next point. */ + i++; + step = 1; + } + } + + /* Always untag extremes. */ + pt = &gps->points[0]; + pt->flag &= ~GP_SPOINT_TAG; + pt = &gps->points[gps->totpoints - 1]; + pt->flag &= ~GP_SPOINT_TAG; + + /* Dissolve tagged points */ + if (tagged) { + BKE_gpencil_dissolve_points(gpf, gps, GP_SPOINT_TAG); + } +} diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 3f095d923b1..de6f5142a19 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1815,7 +1815,7 @@ static int id_refcount_recompute_callback(void *user_data, return IDWALK_RET_NOP; } -void BLE_main_id_refcount_recompute(struct Main *bmain, const bool do_linked_only) +void BKE_main_id_refcount_recompute(struct Main *bmain, const bool do_linked_only) { ID *id; 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..1a3e42a7da2 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); @@ -1977,7 +1933,7 @@ bool txt_replace_char(Text *text, unsigned int add) */ static void txt_select_prefix(Text *text, const char *add) { - int len, num, curc_old; + int len, num, curc_old, selc_old; char *tmp; const int indentlen = strlen(add); @@ -1985,6 +1941,7 @@ static void txt_select_prefix(Text *text, const char *add) BLI_assert(!ELEM(NULL, text->curl, text->sell)); curc_old = text->curc; + selc_old = text->selc; num = 0; while (true) { @@ -2022,19 +1979,24 @@ static void txt_select_prefix(Text *text, const char *add) num++; } } - if (!curc_old) { - text->curc = 0; - } - else { - text->curc = curc_old + indentlen; - } while (num > 0) { text->curl = text->curl->prev; num--; } - /* caller must handle undo */ + /* Keep the cursor left aligned if we don't have a selection. */ + if (curc_old == 0 && !(text->curl == text->sell && curc_old == selc_old)) { + if (text->curl == text->sell) { + if (text->curc == text->selc) { + text->selc = 0; + } + } + text->curc = 0; + } + else { + text->curc = curc_old + indentlen; + } } /** 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) |