From 3155c6737832c54310c70ecaaf8667d0362de5e8 Mon Sep 17 00:00:00 2001 From: rodri Date: Thu, 26 Sep 2024 15:22:02 +0000 Subject: implement a parser for a model(6). get rid of the libobj dependency. --- render.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index 5a4f5b6..cc5a201 100644 --- a/render.c +++ b/render.c @@ -4,7 +4,6 @@ #include #include #include -#include "libobj/obj.h" #include "graphics.h" #include "internal.h" @@ -155,7 +154,7 @@ _barycoords(Triangle2 t, Point2 p) Point3 v = crossvec3(Vec3(p0p2.x, p0p1.x, pp0.x), Vec3(p0p2.y, p0p1.y, pp0.y)); /* handle degenerate triangles—i.e. the ones where every point lies on the same line */ - if(fabs(v.z) < 1e-5) + if(fabs(v.z) < ε1) return Pt3(-1,-1,-1,1); return Pt3(1 - (v.x + v.y)/v.z, v.y/v.z, v.x/v.z, 1); } @@ -262,7 +261,7 @@ rasterize(Rastertask *task) /* interpolate z⁻¹ and get actual z */ pcz = flerp(prim->v[0].p.w, prim->v[1].p.w, perc); - pcz = 1.0/(pcz < 1e-5? 1e-5: pcz); + pcz = 1.0/(pcz < ε1? ε1: pcz); /* perspective-correct attribute interpolation */ perc *= prim->v[0].p.w * pcz; @@ -314,7 +313,7 @@ discard: /* interpolate z⁻¹ and get actual z */ pcz = fberp(prim->v[0].p.w, prim->v[1].p.w, prim->v[2].p.w, bc); - pcz = 1.0/(pcz < 1e-5? 1e-5: pcz); + pcz = 1.0/(pcz < ε1? ε1: pcz); /* perspective-correct attribute interpolation */ bc = modulapt3(bc, Vec3(prim->v[0].p.w*pcz, -- cgit v1.2.3