diff --git a/solidify/level.c b/solidify/level.c index 077fbce..43175d4 100644 --- a/solidify/level.c +++ b/solidify/level.c @@ -8,6 +8,9 @@ #include "level.h" +#define NEAR 1 + + static void draw_map(GtkWidget *widget, struct face *f) { int x, y, z; @@ -27,19 +30,21 @@ static void draw_map(GtkWidget *widget, struct face *f) continue; } z0 = f->z_ref+f->fx*(x-f->sx/2)+f->fy*(y-f->sy/2); - if (fabs(z-z0) < 1) { + if (fabs(z-z0) < NEAR) { *p++ = 255*fabs(z-z0); *p++ = 255*fabs(z-z0); *p++ = 255; continue; } if (z < z0) { - z = 255.0*(z-z0)/(z0-f->a->min_z); + z = z > z0-2*NEAR ? 255*(z-z0)/NEAR : + 255.0*(z-z0)/(z0-f->a->min_z); *p++ = 255; *p++ = z; *p++ = z; } else { - z = 255.0*(z0-z)/(f->a->max_z-z0); + z = z < z0+2*NEAR ? 255*(z0-z)/NEAR : + 255.0*(z0-z)/(f->a->max_z-z0); *p++ = z; *p++ = 255; *p++ = z;