meshes look slightly better

This commit is contained in:
opfez 2021-11-13 19:01:37 +01:00
parent 651cfe8c07
commit 59937f3cd5
1 changed files with 3 additions and 1 deletions

4
main.c
View File

@ -429,7 +429,7 @@ fill_top_flat_triangle(rgb canvas[], rgb c, triangle2 tri)
int32_t xl_change = cx < ax ? 1 : -1;
int32_t y;
for (y = cy; y > by; y--) {
for (y = cy-1; y > by; y--) {
eps_r += dx_right;
eps_l += dx_left;
while (eps_r > 0) {
@ -548,6 +548,8 @@ draw_mesh(rgb canvas[], rgb col, camera c, mesh mesh)
v1 = mesh.vertices[mesh.indices[3*i+1]],
v2 = mesh.vertices[mesh.indices[3*i+2]];
if (v0.z > c.znear && v1.z > c.znear && v2.z > c.znear) continue;
vec3 norm = vec3_normalize(vec3_cross(vec3_sub(v1, v0), vec3_sub(v2, v0)));
double x = vec3_dot(vec3_sub(v0, c.pos), norm);