summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2010-10-13 21:47:27 -0700
committerKenneth Graunke <kenneth@whitecape.org>2010-10-21 00:31:16 -0700
commitcac6cddd34fe2b700ce63c67cc3dedd3316e762c (patch)
treee17a33d7824a901f78b9e9d1fae6321079556f8b
parent11fe460ece6259cb1f0e5ab29543c83767354918 (diff)
Refactor out the linear interpolation function (lerp).
Instead of open-coding it.
-rwxr-xr-xsrc/main.cpp11
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);