ref: 0f3b1baebbaa1dbcfed0ba25850f70dd6ce30e4e
parent: 47bc8df891685fc08689f31c0694bef693709e9b
author: rodri <rgl@antares-labs.eu>
date: Fri Jul 25 10:17:16 EDT 2025
add a Camera.invproj property
--- a/camera.c
+++ b/camera.c
@@ -187,6 +187,9 @@
break;
default: sysfatal("unknown projection type");
}
+
+ memmove(c->invproj, c->proj, sizeof(Matrix3));
+ invm3(c->invproj);
}
void
--- a/graphics.h
+++ b/graphics.h
@@ -403,8 +403,9 @@
struct {
double n, f; /* near and far clipping planes */
} clip;
- Matrix3 proj; /* VCS to clip space xform */
Projection projtype;
+ Matrix3 proj; /* VCS to clip space xform */
+ Matrix3 invproj; /* clip space to VCS xform */
int cullmode;
uint rendopts;
--- a/xform.c
+++ b/xform.c
@@ -100,12 +100,9 @@
Point3
ndc2vcs(Camera *c, Point3 p)
{
- Matrix3 invproj;
Point3 np;
- memmove(invproj, c->proj, sizeof(Matrix3));
- invm3(invproj);
- np = xform3(p, invproj);
+ np = xform3(p, c->invproj);
np.w = np.w == 0? 0: 1.0/np.w;
np.x *= np.w;
np.y *= np.w;
--
⑨