]> Dogcows Code - chaz/rasterize/blobdiff - raster.c
refactor triangle group into a separate class
[chaz/rasterize] / raster.c
index 766e6ea7ba4ce6cb22ad0b687e5eccd8bc377c0e..2be94da36538c4b31795c9827d5bf6444083e195 100644 (file)
--- 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
This page took 0.018086 seconds and 4 git commands to generate.