summaryrefslogtreecommitdiff
path: root/maths.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-07-15 21:07:48 +1000
committerquou <quou@disroot.org>2024-07-15 21:07:48 +1000
commit680cab5cf1778958e7257f19957ac2b5d46d45dc (patch)
tree9e52a98d2661b1b59eac8c9d0976f4566cd88b09 /maths.c
parent1ae53e77cd45416e42b6edcbe0973556a4021b0c (diff)
Update persp and ndc2clip to be more consistent with other maths functions.
Diffstat (limited to 'maths.c')
-rw-r--r--maths.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/maths.c b/maths.c
index 4496a2c..861643a 100644
--- a/maths.c
+++ b/maths.c
@@ -254,13 +254,14 @@ int vec_dot(const int* a, const int* b, int d) {
return r;
}
-void persp(int* v, int asp) {
+int* 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;
+ return v;
}
-void ndc2clip(int* c, int* p) {
+int* ndc2clip(const int* c, int* p) {
register int hw = c[2] >> 1;
register int hh = c[3] >> 1;
p[0] = ((hw << fbits) * p[0]) >> fbits;
@@ -269,4 +270,5 @@ void ndc2clip(int* c, int* p) {
p[1] >>= fbits;
p[0] += hw;
p[1] += hh;
+ return p;
}