diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2010-10-13 21:47:27 -0700 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2010-10-21 00:31:16 -0700 |
commit | cac6cddd34fe2b700ce63c67cc3dedd3316e762c (patch) | |
tree | e17a33d7824a901f78b9e9d1fae6321079556f8b | |
parent | 11fe460ece6259cb1f0e5ab29543c83767354918 (diff) |
Refactor out the linear interpolation function (lerp).
Instead of open-coding it.
-rwxr-xr-x | src/main.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index f5ee54a..bdd9393 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -161,6 +161,13 @@ Redisplay(const patch_set_info *info) } +static GLUvec4 +lerp(GLUvec4 p0, GLUvec4 p1, float t) +{ + return (1.0 - t) * p0 + t * p1; +} + + static void update_camera(float total_t) { @@ -187,7 +194,9 @@ update_camera(float total_t) switch (camera_mode) { case camera_linear: - eye = (1.0 - t_segment) * linear_control_points[active_segment] + t_segment * linear_control_points[(active_segment + 1) % ELEMENTS_OF(linear_control_points)]; + eye = lerp(linear_control_points[active_segment], + linear_control_points[(active_segment + 1) % ELEMENTS_OF(linear_control_points)], + t_segment); break; case camera_C0: eye = camera_curves[active_segment].position(t_segment); |