Commit b3b601b757bc39234632810b07e53196085039a7
authorMichel Pollet <buserror@gmail.com>
Sat, 16 Jun 2012 08:09:13 +0000 (09:09 +0100)
committerMichel Pollet <buserror@gmail.com>
Sat, 16 Jun 2012 08:09:13 +0000 (09:09 +0100)
Turns out everything was there to do it

Signed-off-by: Michel Pollet <buserror@gmail.com>
2 files changed:
examples/shared/libc3/src/c3context.c
examples/shared/libc3/src/c3context.h

index e77122cfcbae981977ebb9d1718b2fc48fd37ab1..8c38fb0d5db9a1941262db145c9302b2b82f1f9b 100644 (file)
@@ -105,13 +105,13 @@ _c3_z_sorter(
        return d1 < d2 ? 1 : d1 > d2 ? -1 : 0;
 }
 
-void
+int
 c3context_project(
                c3context_p c)
 {
        if (!c->root)
-               return;
-
+               return 0;
+       int res = 0;
        /*
         * if the root object is dirty, all the views are also
         * dirty since the geometry has changed
@@ -121,6 +121,7 @@ c3context_project(
                        c->views.e[ci].dirty = 1;
                c3mat4 m = identity3D();
                c3object_project(c->root, &m);
+               res++;
        }
 
        /*
@@ -129,6 +130,7 @@ c3context_project(
         */
        c3context_view_p v = qsort_view = c3context_view_get(c);
        if (v->dirty) {
+               res++;
            c3cam_update_matrix(&v->cam);
 
                c3geometry_array_p  array = &c3context_view_get(c)->projected;
@@ -141,11 +143,20 @@ c3context_project(
                qsort(v->projected.e,
                                v->projected.count, sizeof(v->projected.e[0]),
                        _c3_z_sorter);
-               v->z.min = sqrt(v->z.min);
+               v->z.min = sqrt(v->z.min) * 0.5f;
                v->z.max = sqrt(v->z.max);
 
+               /*
+                * Recalculate the perspective view using the new Z values
+                */
+               v->projection = perspective3D(
+                               v->cam.fov,
+                               v->size.x / v->size.y,
+                               v->z.min, v->z.max);
+
                v->dirty = 0;
        }
+       return res;
 }
 
 void
index 3bce667c86ec4f5c0c80e18de004ed4bb00ff8a7..fc3c4d18652ef929b3328591b6d3bf26999da8d5 100644 (file)
@@ -92,7 +92,7 @@ c3context_dispose(
                c3context_p c);
 
 //! Reproject geometry for dirty objects
-void
+int
 c3context_project(
                c3context_p c);
 //! Draws the context