/* * Check if the given note can be played. * The pick can't be playing and it needs to be able to perform the preparation animation * unless it is already at the correct string. */ bool APick::CanPlayNote(int32 tick, int32 stringIndex) { return !IsPlaying(tick) && ((IsResting(tick) && CanAnimateFromRest(tick, stringIndex)) || IsOnCorrectString(tick, stringIndex) || CanAnimateFromString(tick, stringIndex)); }
void RigidBody2::Update() { float dt = TheRBManager::Instance()->GetDt(); Vec2f acc = m_forces * m_invMass; m_forces = Vec2f(); const Vec2f GRAVITY(0, -100.0f); // TODO TEMP TEST if (m_invMass > 0) { if (!IsResting()) { acc += GRAVITY; } #ifdef USE_VERLET float t2 = dt * dt; Vec2f diff = m_pos - m_oldPos + acc * t2; m_oldPos = m_pos; m_pos += diff; #else Vec2f oldVel = m_vel; m_vel += acc * dt; m_pos += (oldVel + m_vel) * (0.5f * dt); #endif } /* if (fabs(m_torques) < 0.1f) // TODO { // Ignore small torques m_torques = 0; } */ // TODO Separate moment of inertia float angAcc = m_torques * m_invMass; m_torques = 0; m_angVel += angAcc; // don;t depend on dt : this is a one-off occurrence when a torque is applied // Damp rotation - TODO use dt // m_angVel *= 0.99f; m_rads += m_angVel * dt; }