From c69735e24f7c5926ed63ff8c5292be282aa8b240 Mon Sep 17 00:00:00 2001 From: rodri Date: Fri, 14 Jun 2024 15:01:15 +0000 Subject: fix the barycoords routine to avoid reporting false degenerates. added a normals buffer for debugging. --- fb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'fb.c') diff --git a/fb.c b/fb.c index 5077b7d..e0fa2cd 100644 --- a/fb.c +++ b/fb.c @@ -30,6 +30,17 @@ framebufctl_memdraw(Framebufctl *ctl, Memimage *dst) qunlock(ctl); } +static void +framebufctl_drawnormals(Framebufctl *ctl, Image *dst) +{ + Framebuf *fb; + + qlock(ctl); + fb = ctl->getfb(ctl); + loadimage(dst, rectaddpt(fb->r, dst->r.min), (uchar*)fb->nb, Dx(fb->r)*Dy(fb->r)*4); + qunlock(ctl); +} + static void framebufctl_swap(Framebufctl *ctl) { @@ -45,6 +56,7 @@ framebufctl_reset(Framebufctl *ctl) /* address the back buffer—resetting the front buffer is VERBOTEN */ fb = ctl->getbb(ctl); + memset(fb->nb, 0, Dx(fb->r)*Dy(fb->r)*4); memsetd(fb->zb, Inf(-1), Dx(fb->r)*Dy(fb->r)); memset(fb->cb, 0, Dx(fb->r)*Dy(fb->r)*4); } @@ -71,6 +83,7 @@ mkfb(Rectangle r) fb->cb = emalloc(Dx(r)*Dy(r)*4); fb->zb = emalloc(Dx(r)*Dy(r)*sizeof(*fb->zb)); memsetd(fb->zb, Inf(-1), Dx(r)*Dy(r)); + fb->nb = emalloc(Dx(r)*Dy(r)*4); fb->r = r; return fb; } @@ -94,6 +107,7 @@ mkfbctl(Rectangle r) fc->fb[1] = mkfb(r); fc->draw = framebufctl_draw; fc->memdraw = framebufctl_memdraw; + fc->drawnormals = framebufctl_drawnormals; fc->swap = framebufctl_swap; fc->reset = framebufctl_reset; fc->getfb = framebufctl_getfb; -- cgit v1.2.3