Skip to content

Commit

Permalink
more refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
theyareonit committed Sep 16, 2024
1 parent 73425c9 commit 9452ea8
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,20 @@ void updateInputQueueAndTime(int stepCount) {
double lastDFactor = 0.0;
while (true) {
InputEvent front;
if (!inputQueueCopy.empty()) {
front = inputQueueCopy.front();
if (front.time.QuadPart - lastFrameTime.QuadPart < stepDelta.QuadPart * (i + 1)) {
double dFactor = static_cast<double>((front.time.QuadPart - lastFrameTime.QuadPart) % stepDelta.QuadPart) / stepDelta.QuadPart;
stepQueue.emplace(Step{ front, std::clamp(dFactor - lastDFactor, SMALLEST_FLOAT, 1.0), false });
lastDFactor = dFactor;
inputQueueCopy.pop();
continue;
}
bool empty = inputQueueCopy.empty();
if (!empty) front = inputQueueCopy.front();

if (!empty && front.time.QuadPart - lastFrameTime.QuadPart < stepDelta.QuadPart * (i + 1)) {
double dFactor = static_cast<double>((front.time.QuadPart - lastFrameTime.QuadPart) % stepDelta.QuadPart) / stepDelta.QuadPart;
stepQueue.emplace(Step{ front, std::clamp(dFactor - lastDFactor, SMALLEST_FLOAT, 1.0), false });
inputQueueCopy.pop();
lastDFactor = dFactor;
continue;
}
else {
stepQueue.emplace(Step{ EMPTY_INPUT, std::max(SMALLEST_FLOAT, 1.0 - lastDFactor), true });
break;
}
front = nextInput;
stepQueue.emplace(Step{ front, std::max(SMALLEST_FLOAT, 1.0 - lastDFactor), true });
break;
}
}
}
Expand Down

0 comments on commit 9452ea8

Please sign in to comment.