Commit 15c1e7379018f38a5aed98f60be7e5b6135b1a0f
authorMichel Pollet <buserror@gmail.com>
Fri, 15 Jun 2012 08:19:05 +0000 (09:19 +0100)
committerMichel Pollet <buserror@gmail.com>
Fri, 15 Jun 2012 08:19:05 +0000 (09:19 +0100)
Objects and geometry can be hidden from specific c3context_views
using a bitfield

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

index 1243e0dfaa4259a217adb9809025cbdf97abe87d..69972a310ec329016f2336557c118cf136f68b0e 100644 (file)
@@ -21,6 +21,7 @@
 
 
 #include "c3object.h"
+#include "c3context.h"
 #include "c3driver_object.h"
 
 void
@@ -69,8 +70,16 @@ _c3object_get_geometry(
                const c3driver_object_t * d,
                c3geometry_array_p out)
 {
-       for (int oi = 0; oi < o->geometry.count; oi++)
-               c3geometry_array_add(out, o->geometry.e[oi]);
+       // if this object is not visible in this view, exit
+       // there will be no geometry, so no drawing
+       uint16_t viewmask = (1 << o->context->current);
+       if (o->hidden & viewmask)
+               return;
+       for (int oi = 0; oi < o->geometry.count; oi++) {
+               c3geometry_p g = o->geometry.e[oi];
+               if (!(g->hidden & viewmask))
+                       c3geometry_array_add(out, g);
+       }
        for (int oi = 0; oi < o->objects.count; oi++)
                c3object_get_geometry(o->objects.e[oi], out);
 }
index 57f16daf1086afcffb56f1e6eb0c751d5e27360b..b5ec88383db31b8b55e7acd4b1a5ce4bfbf964dc 100644 (file)
@@ -46,7 +46,7 @@ DECLARE_C_ARRAY(struct c3object_t*, c3object_array, 4);
 typedef struct c3object_t {
        str_p                           name;   //! optional name
        int                                     dirty : 1, 
-                                               visible : 1 /* TODO: Implement visible */;
+                                               hidden : 8 /* hidden bit mask, related to c3context's views */;
        struct c3context_t * context; //! context this object is attached to
        struct c3object_t * parent;             //! Parent object
        const struct c3driver_object_t ** driver;       //! Driver stack