From 15c1e7379018f38a5aed98f60be7e5b6135b1a0f Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Fri, 15 Jun 2012 09:19:05 +0100 Subject: [PATCH] c3object: Implements 'hidden' objects Objects and geometry can be hidden from specific c3context_views using a bitfield Signed-off-by: Michel Pollet --- examples/shared/libc3/src/c3object.c | 13 +++++++++++-- examples/shared/libc3/src/c3object.h | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/shared/libc3/src/c3object.c b/examples/shared/libc3/src/c3object.c index 1243e0d..69972a3 100644 --- a/examples/shared/libc3/src/c3object.c +++ b/examples/shared/libc3/src/c3object.c @@ -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); } diff --git a/examples/shared/libc3/src/c3object.h b/examples/shared/libc3/src/c3object.h index 57f16da..b5ec883 100644 --- a/examples/shared/libc3/src/c3object.h +++ b/examples/shared/libc3/src/c3object.h @@ -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 -- 2.39.5