Fix T45802: View Lock w/ Curve-Parent fails

This commit is contained in:
Campbell Barton 2015-08-17 14:26:27 +10:00
parent c58757006d
commit ce2d342df5
Notes: blender-bot 2023-02-14 19:45:25 +01:00
Referenced by issue #45802, Camera parented to curve incorrectly updates when "lock to view" is ON and “camera parent lock” is OFF
1 changed files with 29 additions and 10 deletions

View File

@ -2082,17 +2082,26 @@ void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4])
/* extern */
int enable_cu_speed = 1;
static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
/**
* \param scene: Used when curve cache needs to be calculated, or for dupli-frame time.
* \return success if \a mat is set.
*/
static bool ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
{
Curve *cu;
Curve *cu = par->data;
float vec[4], dir[3], quat[4], radius, ctime;
unit_m4(mat);
cu = par->data;
if (par->curve_cache == NULL) /* only happens on reload file, but violates depsgraph still... fix! */
/* only happens on reload file, but violates depsgraph still... fix! */
if (par->curve_cache == NULL) {
if (scene == NULL) {
return false;
}
BKE_displist_make_curveTypes(scene, par, 0);
if (par->curve_cache->path == NULL) return;
}
if (par->curve_cache->path == NULL) {
return false;
}
/* catch exceptions: curve paths used as a duplicator */
if (enable_cu_speed) {
@ -2112,6 +2121,11 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
CLAMP(ctime, 0.0f, 1.0f);
}
else {
/* For dupli-frames only */
if (scene == NULL) {
return false;
}
ctime = BKE_scene_frame_get(scene);
if (cu->pathlen) {
ctime /= cu->pathlen;
@ -2120,6 +2134,8 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
CLAMP(ctime, 0.0f, 1.0f);
}
unit_m4(mat);
/* vec: 4 items! */
if (where_on_path(par, ctime, vec, dir, (cu->flag & CU_FOLLOW) ? quat : NULL, &radius, NULL)) {
@ -2153,6 +2169,8 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
copy_v3_v3(mat[3], vec);
}
return true;
}
static void ob_parbone(Object *ob, Object *par, float mat[4][4])
@ -2369,8 +2387,9 @@ void BKE_object_get_parent_matrix(Scene *scene, Object *ob, Object *par, float p
case PAROBJECT:
ok = 0;
if (par->type == OB_CURVE) {
if (scene && ((Curve *)par->data)->flag & CU_PATH) {
ob_parcurve(scene, ob, par, tmat);
if ((((Curve *)par->data)->flag & CU_PATH) &&
(ob_parcurve(scene, ob, par, tmat)))
{
ok = 1;
}
}