c3object: Implements 'hidden' objects
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>
examples/shared/libc3/src/c3object.c
examples/shared/libc3/src/c3object.h

index 1243e0d..69972a3 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 57f16da..b5ec883 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