#undef _CHECK_WRITE
+void raster_draw_model(raster_t* p, const model_t* model)
+{
+#if VERBOSITY >= 4
+#define PROGRESS_FMT "\033[80D\033[2K %s\t %9d / %d"
+ int tri;
+#endif
+
+ model_transformation(model, &p->model);
+ p->dirty = true;
+ raster_material(p, model_specular(model), model_shininess(model));
+ IF_RENDER_PROGRESS(tri = 0);
+ for (const list_t* ti = model_geometry(model); ti; ti = ti->link) {
+#if VERBOSITY >= 4
+ if (++tri % 100 == 0) {
+ printf(PROGRESS_FMT, model_name(model), tri, model_size(model));
+ fflush(stdout);
+ }
+#endif
+ raster_draw_tri(p, (tri_t*)ti->val);
+ }
+#if VERBOSITY >= 4
+ printf(PROGRESS_FMT"\n", model_name(model), tri, model_size(model));
+#endif
+}
+
+
/*
* See if the triangle is at all visible in the viewport. Also, minimize the
* rectangle around the area that includes the triangle.
{
#if LIGHTING
color_t color = COLOR_BLACK;
+ color.a = vert.c.a;
for (list_t* i = p->lights; i; i = i->link) {
light_t light = *(light_t*)i->val;
vec_t mpos = vert.v;
#if LIGHTING >= 1
tri_t tl = tri_transform(*triangle, p->model);
-#if !PRE_NORMALS
- tl.a.n = tl.b.n = tl.c.n = vec_normalize(tri_normal(tl));
-#endif
#endif
#if LIGHTING == 1
if (S(-1.0) < v.z && v.z < *n) {
#endif
color_t* c = p->pixels + y * p->w + x;
+ color_t newC;
#if LIGHTING == 2 || (!LIGHTING && SMOOTH_COLOR)
- *c = color_interp2(color1, color2, color3, b);
+ newC = color_interp2(color1, color2, color3, b);
#elif LIGHTING == 3 && SMOOTH_COLOR
- *c = _do_phong_lighting(p, tri_interp(tl, b));
+ newC = _do_phong_lighting(p, tri_interp(tl, b));
#elif LIGHTING == 3 && !SMOOTH_COLOR
vert_t d = vert_new(tri_point(t, b));
d.c = tri_color(t);
d.n = tri_normal2(t, b);
- *c = _do_phong_lighting(p, d);
+ newC = _do_phong_lighting(p, d);
+#else
+ newC = color;
+#endif
+
+#if BLENDING
+ *c = color_blend(*c, newC);
#else
- *c = color;
+ *c = newC;
#endif
#if DEPTH_TEST