X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Frasterize;a=blobdiff_plain;f=raster.c;h=2be94da36538c4b31795c9827d5bf6444083e195;hp=766e6ea7ba4ce6cb22ad0b687e5eccd8bc377c0e;hb=09dd89d10e65029f0be313dd463ba1f43cac2fbb;hpb=34efcdbb29b75754fef5066c5999671bc2d2fb12 diff --git a/raster.c b/raster.c index 766e6ea..2be94da 100644 --- a/raster.c +++ b/raster.c @@ -258,6 +258,32 @@ fail: fprintf(stderr, "Cannot write to %s: %s\n", filename, strerror(errno)); #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. @@ -366,9 +392,6 @@ void raster_draw_tri(raster_t* p, const tri_t* triangle) #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