Elevate lerp to 64 bits

For long lines, the linear interpolation for the current position could
overflow. This is the reason the length resolution is currently so
small, which sets a limit on the minimum pen speed. This change
introduces two 64-bit divisions, but allows for a larger length
resolution and lower pen speeds. The runtime is still pretty minimal.
This commit is contained in:
fruchti 2023-04-08 21:42:18 +02:00
parent cf1514262e
commit 7831fd9b34
2 changed files with 9 additions and 5 deletions

View file

@ -1 +1 @@
333
337

View file

@ -197,11 +197,15 @@ void Output_Tick(void)
Output_CurrentLinePosition += step_length;
unsigned int remaining = Output_CurrentLineLength
- Output_CurrentLinePosition;
position.x = (Output_CurrentLineEnd.x * Output_CurrentLinePosition
+ Output_CurrentLineStart.x * remaining)
position.x = ((long long)Output_CurrentLineEnd.x
* Output_CurrentLinePosition
+ (long long)Output_CurrentLineStart.x
* remaining)
/ Output_CurrentLineLength;
position.y = (Output_CurrentLineEnd.y * Output_CurrentLinePosition
+ Output_CurrentLineStart.y * remaining)
position.y = ((long long)Output_CurrentLineEnd.y
* Output_CurrentLinePosition
+ (long long)Output_CurrentLineStart.y
* remaining)
/ Output_CurrentLineLength;
break;
}