diff --git a/solidify/array.c b/solidify/array.c index f0a05aa..d7423e9 100644 --- a/solidify/array.c +++ b/solidify/array.c @@ -83,13 +83,3 @@ void set(struct array *a, int x, int y, int z) a->data[x-a->min_x+(a->max_x-a->min_x+1)*(y-a->min_y)] = z; } } - - -int get_bounded(const struct array *a, int x, int y) -{ - if (x < a->min_x || x > a->max_x) - return UNDEF; - if (y < a->min_y || y > a->max_y) - return UNDEF; - return get(a, x, y); -} diff --git a/solidify/array.h b/solidify/array.h index 0896eaa..0f4dd25 100644 --- a/solidify/array.h +++ b/solidify/array.h @@ -31,7 +31,6 @@ struct array *new_array(void); void free_array(struct array *a); void set(struct array *a, int x, int y, int z); -int get_bounded(const struct array *a, int x, int y); static inline int get(const struct array *a, int x, int y) @@ -39,4 +38,15 @@ static inline int get(const struct array *a, int x, int y) return a->data[(x)-a->min_x+(a->max_x-a->min_x+1)*((y)-a->min_y)]; } + +static inline int get_bounded(const struct array *a, int x, int y) +{ + if (x < a->min_x || x > a->max_x) + return UNDEF; + if (y < a->min_y || y > a->max_y) + return UNDEF; + return get(a, x, y); +} + + #endif /* ARRAY_H */ diff --git a/solidify/overlap.c b/solidify/overlap.c index 960fc47..572495c 100644 --- a/solidify/overlap.c +++ b/solidify/overlap.c @@ -51,7 +51,7 @@ static double r_center(const struct solid *s) static double ramp(int z0, double w0, int z1, double w1) { if (z0 != UNDEF && z1 != UNDEF) - return w0 == 0 && w1 == 0 ? z0 : z0*w0+z1*w1; + return z0*w0+z1*w1; if (z0 == UNDEF && z0 == UNDEF) return UNDEF_F; if (z0 == UNDEF && w0 < w1) @@ -68,9 +68,9 @@ static double zmix(struct face *f, double x, double y) double zx0, zx1; xa = floor(x); - xb = ceil(x); + xb = xa+1; ya = floor(y); - yb = ceil(y); + yb = ya+1; zx0 = ramp( get_bounded(f->a, xa, ya), yb-y, @@ -456,4 +456,17 @@ void overlap(GtkWidget *canvas, struct solid *s) g_signal_connect(G_OBJECT(darea), "motion-notify-event", G_CALLBACK(motion_notify_event), s); +if (0) { +int i; +long t0 = time(NULL); +gtk_widget_show_all(canvas); +for (i = 0; i != 1000; i++) { + rotate(&s->a->m, 100); + draw_image(darea, s, 0); + while (gtk_events_pending()) + gtk_main_iteration(); +} +fprintf(stderr, "%lu\n", time(NULL)-t0); +} + }