summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-07-03 21:27:03 +1000
committerquou <quou@disroot.org>2024-07-03 21:27:03 +1000
commit8706ad19a8b29073afeece115092f03cbbf369c4 (patch)
treed37fabd4e2d7d5f3bb8a899014431aef92103bf9
parent2da353ada0685a4a8780bf8d2f5aa63252c3f0a5 (diff)
persp protects against divide by zero.
-rw-r--r--maths.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/maths.c b/maths.c
index 5ec40d7..db11491 100644
--- a/maths.c
+++ b/maths.c
@@ -229,6 +229,7 @@ int* vec_cpy(int* d, const int* s, int c) {
}
void persp(int* v, int asp) {
+ v[2] += !v[2];
v[0] = ((v[0] << fbits) / v[2]);
v[1] = ((v[1] << fbits) / v[2]) * asp >> fbits;
v[2] = f1;