Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/fcurve.c
| Show First 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | void BKE_fcurves_copy(ListBase *dst, ListBase *src) | ||||
| /* Copy one-by-one. */ | /* Copy one-by-one. */ | ||||
| for (sfcu = src->first; sfcu; sfcu = sfcu->next) { | for (sfcu = src->first; sfcu; sfcu = sfcu->next) { | ||||
| dfcu = BKE_fcurve_copy(sfcu); | dfcu = BKE_fcurve_copy(sfcu); | ||||
| BLI_addtail(dst, dfcu); | BLI_addtail(dst, dfcu); | ||||
| } | } | ||||
| } | } | ||||
| /** Callback used by lib_query to walk over all ID usages (mimics `foreach_id` callback of | /** | ||||
| * `IDTypeInfo` structure). */ | * Callback used by lib_query to walk over all ID usages (mimics `foreach_id` callback of | ||||
| * `IDTypeInfo` structure). | |||||
| */ | |||||
| void BKE_fcurve_foreach_id(FCurve *fcu, LibraryForeachIDData *data) | void BKE_fcurve_foreach_id(FCurve *fcu, LibraryForeachIDData *data) | ||||
| { | { | ||||
| ChannelDriver *driver = fcu->driver; | ChannelDriver *driver = fcu->driver; | ||||
| if (driver != NULL) { | if (driver != NULL) { | ||||
| LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) { | LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) { | ||||
| /* only used targets */ | /* only used targets */ | ||||
| DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) { | DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) { | ||||
| ▲ Show 20 Lines • Show All 1,309 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name F-Curve Calculations | /** \name F-Curve Calculations | ||||
| * \{ */ | * \{ */ | ||||
| /* The length of each handle is not allowed to be more | /** | ||||
| * The length of each handle is not allowed to be more | |||||
| * than the horizontal distance between (v1-v4). | * than the horizontal distance between (v1-v4). | ||||
| * This is to prevent curve loops. | * This is to prevent curve loops. | ||||
| * | * | ||||
| * This function is very similar to BKE_curve_correct_bezpart(), but allows a steeper tangent for | * This function is very similar to BKE_curve_correct_bezpart(), but allows a steeper tangent for | ||||
| * more snappy animations. This is not desired for other areas in which curves are used, though. | * more snappy animations. This is not desired for other areas in which curves are used, though. | ||||
| */ | */ | ||||
| void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2]) | void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2]) | ||||
| { | { | ||||
| Show All 30 Lines | void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2]) | ||||
| if (len2 > len) { | if (len2 > len) { | ||||
| fac = len / len2; | fac = len / len2; | ||||
| v3[0] = (v4[0] - fac * h2[0]); | v3[0] = (v4[0] - fac * h2[0]); | ||||
| v3[1] = (v4[1] - fac * h2[1]); | v3[1] = (v4[1] - fac * h2[1]); | ||||
| } | } | ||||
| } | } | ||||
| /** Find roots of cubic equation (c0 x³ + c1 x² + c2 x + c3) | /** | ||||
| . | |||||
| * Find roots of cubic equation (c0 x³ + c1 x² + c2 x + c3) | |||||
| * \return number of roots in `o`. | * \return number of roots in `o`. | ||||
| * NOTE: it is up to the caller to allocate enough memory for `o`. */ | * | ||||
| * \note it is up to the caller to allocate enough memory for `o`. | |||||
| */ | |||||
| static int solve_cubic(double c0, double c1, double c2, double c3, float *o) | static int solve_cubic(double c0, double c1, double c2, double c3, float *o) | ||||
| { | { | ||||
| double a, b, c, p, q, d, t, phi; | double a, b, c, p, q, d, t, phi; | ||||
| int nr = 0; | int nr = 0; | ||||
| if (c3 != 0.0) { | if (c3 != 0.0) { | ||||
| a = c2 / c3; | a = c2 / c3; | ||||
| b = c1 / c3; | b = c1 / c3; | ||||
| ▲ Show 20 Lines • Show All 967 Lines • Show Last 20 Lines | |||||