@@ -34,28 +34,35 @@ public override void Draw(RenderContext gameTime)
34
34
var renderUIElement = spriteStateKeyPair . Value ;
35
35
renderUIElement . Enabled = uiComponent . Enabled ;
36
36
37
- if ( renderUIElement . Enabled )
38
- {
39
- // TODO GRAPHICS REFACTOR: Proper bounding box.
40
- //renderSprite.BoundingBox = new BoundingBoxExt(new Vector3(float.NegativeInfinity), new Vector3(float.PositiveInfinity));
37
+ if ( ! renderUIElement . Enabled )
38
+ continue ;
41
39
42
- // Copy values from ECS to render object
43
- renderUIElement . WorldMatrix = uiComponent . Entity . Transform . WorldMatrix ;
40
+ // TODO GRAPHICS REFACTOR: Proper bounding box.
41
+ //renderSprite.BoundingBox = new BoundingBoxExt(new Vector3(float.NegativeInfinity), new Vector3(float.PositiveInfinity)) ;
44
42
45
- renderUIElement . RenderGroup = uiComponent . RenderGroup ;
43
+ // Copy values from ECS to render object
44
+ renderUIElement . WorldMatrix = uiComponent . Entity . Transform . WorldMatrix ;
45
+
46
+ renderUIElement . Page = uiComponent . Page ;
47
+ renderUIElement . Sampler = uiComponent . Sampler ;
48
+ renderUIElement . IsFullScreen = uiComponent . IsFullScreen ;
49
+ renderUIElement . Resolution = uiComponent . Resolution ;
50
+ renderUIElement . Size = uiComponent . Size ;
51
+ renderUIElement . ResolutionStretch = uiComponent . ResolutionStretch ;
52
+ renderUIElement . IsBillboard = uiComponent . IsBillboard ;
53
+ renderUIElement . SnapText = uiComponent . SnapText ;
54
+ renderUIElement . IsFixedSize = uiComponent . IsFixedSize ;
46
55
47
- renderUIElement . Page = uiComponent . Page ;
48
- renderUIElement . Sampler = uiComponent . Sampler ;
49
- renderUIElement . IsFullScreen = uiComponent . IsFullScreen ;
50
- renderUIElement . Resolution = uiComponent . Resolution ;
51
- renderUIElement . Size = uiComponent . Size ;
52
- renderUIElement . ResolutionStretch = uiComponent . ResolutionStretch ;
53
- renderUIElement . IsBillboard = uiComponent . IsBillboard ;
54
- renderUIElement . SnapText = uiComponent . SnapText ;
55
- renderUIElement . IsFixedSize = uiComponent . IsFixedSize ;
56
+ if ( renderUIElement . RenderGroup != uiComponent . RenderGroup )
57
+ {
58
+ renderUIElement . RenderGroup = uiComponent . RenderGroup ;
56
59
57
- UIRoots . Add ( renderUIElement ) ;
60
+ // Forces VisibilityGroup.ReevaluateActiveRenderStages for this render object since RenderGroup is used for render stage selection
61
+ VisibilityGroup . RenderObjects . Remove ( renderUIElement ) ;
62
+ VisibilityGroup . RenderObjects . Add ( renderUIElement ) ;
58
63
}
64
+
65
+ UIRoots . Add ( renderUIElement ) ;
59
66
}
60
67
}
61
68
@@ -71,12 +78,18 @@ protected override void OnEntityComponentRemoved(Entity entity, UIComponent uiCo
71
78
72
79
protected override RenderUIElement GenerateComponentData ( Entity entity , UIComponent component )
73
80
{
74
- return new RenderUIElement { Source = component } ;
81
+ return new RenderUIElement
82
+ {
83
+ Source = component ,
84
+ // RenderGroup must be up to date from the start as VisibilityGroup.ReevaluateActiveRenderStages
85
+ // reads from it for this objects' initial render stage
86
+ RenderGroup = component . RenderGroup
87
+ } ;
75
88
}
76
89
77
90
protected override bool IsAssociatedDataValid ( Entity entity , UIComponent component , RenderUIElement associatedData )
78
91
{
79
- return associatedData . Source == component ;
92
+ return associatedData . Source == component && component . RenderGroup == associatedData . RenderGroup ;
80
93
}
81
94
}
82
95
}
0 commit comments