From 878b441742390628f731d7d23597395c9a61e9cc Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 12 Oct 2011 12:45:15 -0400 Subject: [PATCH] rework addRing(); consider LBStruct.offset the offset when created --- modes/Tunnel.cc | 15 ++++++++++----- modes/Tunnel.h | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modes/Tunnel.cc b/modes/Tunnel.cc index 1357846..80e9643 100644 --- a/modes/Tunnel.cc +++ b/modes/Tunnel.cc @@ -35,6 +35,12 @@ bool Tunnel::expose (GnomeScreensaver & gs) m_last_ticks = gs.getTicks(); uint64_t ticks = gs.getTicks(); int elapsed = ticks - m_last_ticks; + m_offset += XLATE_RATE * elapsed; + while (m_offset - m_last_ring_offset > RING_LAYER_DIST) + { + m_last_ring_offset += RING_LAYER_DIST; + addRing(m_last_ring_offset); + } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -43,7 +49,7 @@ bool Tunnel::expose (GnomeScreensaver & gs) it++) { glPushMatrix(); - glTranslatef(0, m_offset + it->offset, 0); + glTranslatef(0, m_offset - it->offset, 0); glRotatef(it->trot, 0, 1, 0); glTranslatef(RING_RADIUS, 0, 0); glRotatef(-90.0, 0, 0, 1); @@ -58,14 +64,14 @@ bool Tunnel::expose (GnomeScreensaver & gs) return true; } -void Tunnel::addRing() +void Tunnel::addRing(double offset) { for (int j = 0; j < N_LOGOS_PER_RING; j++) { float zrot = ((j + m_ring_rot_idx) & 0x3) * 90.0; float trot = j * 360.0 / N_LOGOS_PER_RING; LBStruct lbs = { - m_offset, + offset, zrot, trot, {0, 0, 1} @@ -90,8 +96,7 @@ bool Tunnel::configure (GnomeScreensaver & gs) for (int i = 0; i <= N_INITIAL_LAYERS; i++) { - m_offset = (N_INITIAL_LAYERS - i) * RING_LAYER_DIST, - addRing(); + addRing((i - N_INITIAL_LAYERS) * RING_LAYER_DIST); } m_offset = 0.0; diff --git a/modes/Tunnel.h b/modes/Tunnel.h index 0ba1021..673b6c6 100644 --- a/modes/Tunnel.h +++ b/modes/Tunnel.h @@ -23,7 +23,7 @@ class Tunnel : public Mode float spin_axis[3]; } LBStruct; protected: - void addRing(); + void addRing(double offset); LogoBox m_logobox; uint64_t m_last_ticks; std::list m_logos;