void Frame::UpdateOrbitRails(double time, double timestep) { m_oldPos = m_pos; m_oldAngDisplacement = m_angSpeed * timestep; // update frame position and velocity if (m_parent && m_sbody && !IsRotFrame()) { m_pos = m_sbody->orbit.OrbitalPosAtTime(time); vector3d pos2 = m_sbody->orbit.OrbitalPosAtTime(time+timestep); m_vel = (pos2 - m_pos) / timestep; } // temporary test thing else m_pos = m_pos + m_vel * timestep; // update frame rotation double ang = m_angSpeed * timestep; // hmm. cumulative inaccuracy? worse! if (!is_zero_exact(ang)) { // frequently used with e^-10 etc matrix3x3d rot = matrix3x3d::RotateY(-ang); // RotateY is backwards m_orient = m_orient * rot; // angvel always +y } UpdateRootRelativeVars(); // update root-relative pos/vel/orient for (ChildIterator it = m_children.begin(); it != m_children.end(); ++it) (*it)->UpdateOrbitRails(time, timestep); }
void Frame::ClearMovement() { UpdateRootRelativeVars(); m_rootInterpPos = m_rootPos; m_rootInterpOrient = m_rootOrient; m_oldPos = m_interpPos = m_pos; m_interpOrient = m_orient; m_oldAngDisplacement = 0.0; }