Cleanup: Make curve deform argument optional

The "dir" argument to `BKE_where_on_path` was only actually
used in a few places. It's easier to see where those are if there
isn't always a dummy argument.
This commit is contained in:
Hans Goudey 2022-04-13 19:22:10 -05:00
parent 0ba061c3bc
commit 8e4c3c6a24
Notes: blender-bot 2023-02-14 08:28:46 +01:00
Referenced by commit af2740abc0, Fix T97718: Crash using "Text on Curve"
Referenced by commit c09c3246eb, Fix T97718: Crash using "Text on Curve"
Referenced by issue #97718, Regression: Crash Using Text on Curve
6 changed files with 24 additions and 22 deletions

View File

@ -295,10 +295,12 @@ bool BKE_where_on_path(const Object *ob,
key_curve_tangent_weights(frac, w, KEY_BSPLINE);
interp_v3_v3v3v3v3(r_dir, p0->vec, p1->vec, p2->vec, p3->vec, w);
if (r_dir) {
interp_v3_v3v3v3v3(r_dir, p0->vec, p1->vec, p2->vec, p3->vec, w);
/* Make compatible with #vec_to_quat. */
negate_v3(r_dir);
/* Make compatible with #vec_to_quat. */
negate_v3(r_dir);
}
//}
const ListBase *nurbs = BKE_curve_editNurbs_get(cu);

View File

@ -405,8 +405,8 @@ static void splineik_evaluate_bone(
if (pchan->bone->length < FLT_EPSILON) {
/* Only move the bone position with zero length bones. */
float bone_pos[4], dir[3], rad;
BKE_where_on_path(ik_data->tar, state->curve_position, bone_pos, dir, NULL, &rad, NULL);
float bone_pos[4], rad;
BKE_where_on_path(ik_data->tar, state->curve_position, bone_pos, NULL, NULL, &rad, NULL);
apply_curve_transform(ik_data, ob, rad, bone_pos, &rad);
@ -445,13 +445,13 @@ static void splineik_evaluate_bone(
/* Step 1: determine the positions for the endpoints of the bone. */
if (point_start < 1.0f) {
float vec[4], dir[3], rad;
float vec[4], rad;
radius = 0.0f;
/* Calculate head position. */
if (point_start == 0.0f) {
/* Start of the path. We have no previous tail position to copy. */
BKE_where_on_path(ik_data->tar, point_start, vec, dir, NULL, &rad, NULL);
BKE_where_on_path(ik_data->tar, point_start, vec, NULL, NULL, &rad, NULL);
}
else {
copy_v3_v3(vec, state->prev_tail_loc);
@ -486,7 +486,7 @@ static void splineik_evaluate_bone(
}
else {
/* Scale to fit curve end position. */
if (BKE_where_on_path(ik_data->tar, point_end, vec, dir, NULL, &rad, NULL)) {
if (BKE_where_on_path(ik_data->tar, point_end, vec, NULL, NULL, &rad, NULL)) {
state->prev_tail_radius = rad;
copy_v3_v3(state->prev_tail_loc, vec);
copy_v3_v3(pose_tail, vec);

View File

@ -1495,7 +1495,7 @@ static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_CURVES_LEGACY)) {
Curve *cu = ct->tar->data;
float vec[4], dir[3], radius;
float vec[4], radius;
float curvetime;
unit_m4(ct->matrix);
@ -1532,7 +1532,7 @@ static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
if (BKE_where_on_path(ct->tar,
curvetime,
vec,
dir,
NULL,
(data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL,
&radius,
NULL)) { /* quat_pt is quat or NULL. */
@ -3886,7 +3886,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
/* get targetmatrix */
if (data->tar->runtime.curve_cache && data->tar->runtime.curve_cache->anim_path_accum_length) {
float vec[4], dir[3], totmat[4][4];
float vec[4], totmat[4][4];
float curvetime;
short clamp_axis;
@ -3969,7 +3969,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
}
/* 3. position on curve */
if (BKE_where_on_path(ct->tar, curvetime, vec, dir, NULL, NULL, NULL)) {
if (BKE_where_on_path(ct->tar, curvetime, vec, NULL, NULL, NULL, NULL)) {
unit_m4(totmat);
copy_v3_v3(totmat[3], vec);

View File

@ -3087,12 +3087,12 @@ void BKE_object_matrix_local_get(struct Object *ob, float r_mat[4][4])
static bool ob_parcurve(Object *ob, Object *par, float r_mat[4][4])
{
Curve *cu = (Curve *)par->data;
float vec[4], dir[3], quat[4], radius, ctime;
float vec[4], quat[4], radius, ctime;
/* NOTE: Curve cache is supposed to be evaluated here already, however there
* are cases where we can not guarantee that. This includes, for example,
* dependency cycles. We can't correct anything from here, since that would
* cause a threading conflicts.
* cause threading conflicts.
*
* TODO(sergey): Some of the legit looking cases like T56619 need to be
* looked into, and maybe curve cache (and other dependencies) are to be
@ -3125,7 +3125,7 @@ static bool ob_parcurve(Object *ob, Object *par, float r_mat[4][4])
/* vec: 4 items! */
if (BKE_where_on_path(
par, ctime, vec, dir, (cu->flag & CU_FOLLOW) ? quat : nullptr, &radius, nullptr)) {
par, ctime, vec, nullptr, (cu->flag & CU_FOLLOW) ? quat : nullptr, &radius, nullptr)) {
if (cu->flag & CU_FOLLOW) {
quat_apply_track(quat, ob->trackflag, ob->upflag);
normalize_qt(quat);

View File

@ -1372,7 +1372,7 @@ static bool vfont_to_curve(Object *ob,
ct = chartransdata;
for (i = 0; i <= slen; i++, ct++) {
float ctime, dtime, vec[4], tvec[4], rotvec[3];
float ctime, dtime, vec[4], rotvec[3];
float si, co;
/* Rotate around center character. */
@ -1392,9 +1392,9 @@ static bool vfont_to_curve(Object *ob,
CLAMP(ctime, 0.0f, 1.0f);
/* Calculate the right loc AND the right rot separately. */
/* `vec`, `tvec` need 4 items. */
BKE_where_on_path(cu->textoncurve, ctime, vec, tvec, NULL, NULL, NULL);
BKE_where_on_path(cu->textoncurve, ctime + dtime, tvec, rotvec, NULL, NULL, NULL);
/* `vec` needs 4 items. */
BKE_where_on_path(cu->textoncurve, ctime, vec, NULL, NULL, NULL, NULL);
BKE_where_on_path(cu->textoncurve, ctime + dtime, NULL, rotvec, NULL, NULL, NULL);
mul_v3_fl(vec, sizefac);

View File

@ -528,13 +528,13 @@ static void OVERLAY_forcefield(OVERLAY_ExtraCallBuffers *cb, Object *ob, ViewLay
case PFIELD_GUIDE:
if (cu && (cu->flag & CU_PATH) && ob->runtime.curve_cache->anim_path_accum_length) {
instdata.size_x = instdata.size_y = instdata.size_z = pd->f_strength;
float pos[4], tmp[3];
BKE_where_on_path(ob, 0.0f, pos, tmp, NULL, NULL, NULL);
float pos[4];
BKE_where_on_path(ob, 0.0f, pos, NULL, NULL, NULL, NULL);
copy_v3_v3(instdata.pos, ob->obmat[3]);
translate_m4(instdata.mat, pos[0], pos[1], pos[2]);
DRW_buffer_add_entry(cb->field_curve, color, &instdata);
BKE_where_on_path(ob, 1.0f, pos, tmp, NULL, NULL, NULL);
BKE_where_on_path(ob, 1.0f, pos, NULL, NULL, NULL, NULL);
copy_v3_v3(instdata.pos, ob->obmat[3]);
translate_m4(instdata.mat, pos[0], pos[1], pos[2]);
DRW_buffer_add_entry(cb->field_sphere_limit, color, &instdata);