void Difficulty::GetPlayableData(VectorTN NotesOut, TimingData& BPS, TimingData& VerticalSpeeds, TimingData& Warps, float Drift, double SpeedConstant) { /* We'd like to build the notes' position from 0 to infinity, however the real "zero" position would be the judgment line in other words since "up" is negative relative to 0 and 0 is the judgment line position would actually be judgeline - positiveposition and positiveposition would just be measure * measuresize + fraction * fractionsize In practice, since we use a ms-based model rather than a beat one, we just do regular integration of position = sum(speed_i * duration_i) + speed_current * (time_current - speed_start_time) */ assert(Data != nullptr); ProcessBPS(BPS, Drift); ProcessVSpeeds(BPS, VerticalSpeeds, SpeedConstant); if (!SpeedConstant) // If there is a speed constant having speed changes is not what we want ProcessSpeedVariations(BPS, VerticalSpeeds, Drift); if (SpeedConstant) Warps.clear(); else Warps = Data->Warps; // From here on, we'll just copy the notes out. Otherwise, just leave the processed data. if (!NotesOut) return; for (int KeyIndex = 0; KeyIndex < Channels; KeyIndex++) NotesOut[KeyIndex].clear(); /* For all channels of this difficulty */ for (int KeyIndex = 0; KeyIndex < Channels; KeyIndex++) { int MIdx = 0; /* For each measure of this channel */ for (auto Msr = Data->Measures.begin(); Msr != Data->Measures.end(); ++Msr) { /* For each note in the measure... */ ptrdiff_t total_notes = Msr->Notes[KeyIndex].size(); for (auto Note = 0; Note < total_notes; Note++) { /* Calculate position. (Change this to TrackNote instead of processing?) issue is not having the speed change data there. */ NoteData &CurrentNote = (*Msr).Notes[KeyIndex][Note]; TrackNote NewNote; NewNote.AssignNotedata(CurrentNote); NewNote.AddTime(Drift); float VerticalPosition = IntegrateToTime(VerticalSpeeds, NewNote.GetStartTime()); float HoldEndPosition = IntegrateToTime(VerticalSpeeds, NewNote.GetTimeFinal()); // if upscroll change minus for plus as well as matrix at screengameplay7k if (!CurrentNote.EndTime) NewNote.AssignPosition(VerticalPosition); else NewNote.AssignPosition(VerticalPosition, HoldEndPosition); // Okay, now we want to know what fraction of a beat we're dealing with // this way we can display colored (a la Stepmania) notes. // We should do this before changing time by drift. double cBeat = IntegrateToTime(BPS, NewNote.GetStartTime()); double iBeat = floor(cBeat); double dBeat = (cBeat - iBeat); NewNote.AssignFraction(dBeat); double Wamt = -GetWarpAmountAtTime(CurrentNote.StartTime); NewNote.AddTime(Wamt); if (!SpeedConstant || (NewNote.IsJudgable() && !IsWarpingAt(CurrentNote.StartTime))) NotesOut[KeyIndex].push_back(NewNote); } MIdx++; } // done with the channel - sort it std::stable_sort(NotesOut[KeyIndex].begin(), NotesOut[KeyIndex].end(), [](const TrackNote &A, const TrackNote &B) -> bool { return A.GetVertical() < B.GetVertical(); }); } }
int nSort (const TrackNote &i, const TrackNote &j) { return i.GetStartTime() < j.GetStartTime(); }