@@ -281,10 +281,17 @@ pub trait DrawSession<'a> {
281281
282282pub trait DrawSessionExt {
283283 /// Draw a Drawable, which is potentially masked.
284- fn draw_drawable ( & mut self , as_mask : bool , comps : & World , id : InoxNodeUuid ) ;
284+ fn draw_drawable ( & mut self , puppet : & Puppet , as_mask : bool , comps : & World , id : InoxNodeUuid ) ;
285285
286286 /// Draw one composite. `components` must be referencing `comps`.
287- fn draw_composite ( & mut self , as_mask : bool , comps : & World , components : & CompositeComponents , id : InoxNodeUuid ) ;
287+ fn draw_composite (
288+ & mut self ,
289+ puppet : & Puppet ,
290+ as_mask : bool ,
291+ comps : & World ,
292+ components : & CompositeComponents ,
293+ id : InoxNodeUuid ,
294+ ) ;
288295}
289296
290297pub trait InoxRendererExt {
@@ -296,7 +303,7 @@ pub trait InoxRendererExt {
296303}
297304
298305impl < ' a , T : DrawSession < ' a > > DrawSessionExt for T {
299- fn draw_drawable ( & mut self , as_mask : bool , comps : & World , id : InoxNodeUuid ) {
306+ fn draw_drawable ( & mut self , puppet : & Puppet , as_mask : bool , comps : & World , id : InoxNodeUuid ) {
300307 let drawable_kind = DrawableKind :: new ( id, comps, false ) . expect ( "Node must be a Drawable." ) ;
301308 let masks = match drawable_kind {
302309 DrawableKind :: TexturedMesh ( ref components) => & components. drawable . masks ,
@@ -310,7 +317,7 @@ impl<'a, T: DrawSession<'a>> DrawSessionExt for T {
310317 for mask in & masks. masks {
311318 self . on_begin_mask ( mask) ;
312319
313- self . draw_drawable ( true , comps, mask. source ) ;
320+ self . draw_drawable ( puppet , true , comps, mask. source ) ;
314321 }
315322 self . on_begin_masked_content ( ) ;
316323 }
@@ -319,21 +326,34 @@ impl<'a, T: DrawSession<'a>> DrawSessionExt for T {
319326 DrawableKind :: TexturedMesh ( ref components) => {
320327 self . draw_textured_mesh_content ( as_mask, components, comps. get ( id) . unwrap ( ) , id)
321328 }
322- DrawableKind :: Composite ( ref components) => self . draw_composite ( as_mask, comps, components, id) ,
329+ DrawableKind :: Composite ( ref components) => self . draw_composite ( puppet , as_mask, comps, components, id) ,
323330 }
324331
325332 if has_masks {
326333 self . on_end_mask ( ) ;
327334 }
328335 }
329336
330- fn draw_composite ( & mut self , as_mask : bool , comps : & World , components : & CompositeComponents , id : InoxNodeUuid ) {
337+ fn draw_composite (
338+ & mut self ,
339+ puppet : & Puppet ,
340+ as_mask : bool ,
341+ comps : & World ,
342+ components : & CompositeComponents ,
343+ id : InoxNodeUuid ,
344+ ) {
331345 let render_ctx = comps. get :: < CompositeRenderCtx > ( id) . unwrap ( ) ;
332346 if render_ctx. zsorted_children_list . is_empty ( ) {
333347 // Optimization: Nothing to be drawn, skip context switching
334348 return ;
335349 }
336350
351+ let is_enabled = puppet. nodes . get_node ( id) . unwrap ( ) . enabled ;
352+ if !is_enabled && !as_mask {
353+ // Disabled nodes don't render, but they can still be used as masks.
354+ return ;
355+ }
356+
337357 self . begin_composite_content ( as_mask, components, render_ctx, id) ;
338358
339359 for uuid in & render_ctx. zsorted_children_list {
@@ -371,7 +391,7 @@ impl<T: InoxRenderer> InoxRendererExt for T {
371391 . expect ( "RenderCtx of puppet must be initialized before calling draw()." )
372392 . root_drawables_zsorted
373393 {
374- draw. draw_drawable ( false , & puppet. node_comps , * uuid) ;
394+ draw. draw_drawable ( puppet , false , & puppet. node_comps , * uuid) ;
375395 }
376396
377397 draw. on_end_draw ( puppet) ;
0 commit comments