|
|
@@ -64,19 +64,22 @@ namespace MonoGameSceneGraph
|
|
|
/// </summary>
|
|
|
public override void Draw()
|
|
|
{
|
|
|
- // if camera frustum is not defined, draw this node as a regular node
|
|
|
- if (CameraFrustum == null)
|
|
|
+ // if not visible skip
|
|
|
+ if (!IsVisible)
|
|
|
{
|
|
|
- base.Draw();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // if not visible stop here so we won't calculate bounding boxes etc.
|
|
|
- if (!IsVisible)
|
|
|
+ // if camera frustum is not defined, draw this node as a regular node
|
|
|
+ if (CameraFrustum == null)
|
|
|
{
|
|
|
+ base.Draw();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // update transformations (only if needed, testing logic is inside)
|
|
|
+ UpdateTransformations();
|
|
|
+
|
|
|
// check if need to recalculate bounding box
|
|
|
if (_isBoundingBoxDirty)
|
|
|
{
|
|
|
@@ -85,13 +88,24 @@ namespace MonoGameSceneGraph
|
|
|
}
|
|
|
|
|
|
// if this node is out of screen, don't draw it
|
|
|
- if (!_currBoundingBox.Intersects(CameraFrustum))
|
|
|
+ if (CameraFrustum.Contains(_currBoundingBox) == ContainmentType.Disjoint)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// if got here it means this node is in screen and should be rendered. draw it.
|
|
|
- base.Draw();
|
|
|
+
|
|
|
+ // draw all child nodes
|
|
|
+ foreach (Node node in _childNodes)
|
|
|
+ {
|
|
|
+ node.Draw();
|
|
|
+ }
|
|
|
+
|
|
|
+ // draw all child entities
|
|
|
+ foreach (IEntity entity in _childEntities)
|
|
|
+ {
|
|
|
+ entity.Draw(this, _localTransform, _worldTransform);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|