Add object rendering toggle

This commit is contained in:
Jarrod Doyle 2024-09-07 08:10:14 +01:00
parent 963ab721cd
commit a6e667e1da
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 20 additions and 1 deletions

View File

@ -29,6 +29,8 @@ public partial class Mission : Node3D
} }
} }
private const string OBJECT_MODELS_GROUP = "ObjectModels";
[Export(PropertyHint.GlobalFile, "*.mis")] [Export(PropertyHint.GlobalFile, "*.mis")]
public string FileName { get; set; } public string FileName { get; set; }
[Export] [Export]
@ -94,10 +96,14 @@ public partial class Mission : Node3D
{ {
Build = true; Build = true;
} }
if (keyEvent.Keycode == Key.O) if (keyEvent.Keycode == Key.L)
{ {
ToggleLightmap(); ToggleLightmap();
} }
if (keyEvent.Keycode == Key.O)
{
ToggleObjectRendering();
}
} }
} }
@ -127,6 +133,17 @@ public partial class Mission : Node3D
} }
} }
public void ToggleObjectRendering()
{
// It might be "better" to use a parent node and just toggle that, but
// the performance of this is completely fine so we'll stick with it
foreach (var node in GetTree().GetNodesInGroup(OBJECT_MODELS_GROUP))
{
var node3d = node as Node3D;
node3d.Visible = !node3d.Visible;
}
}
public void ToggleLightmap() public void ToggleLightmap()
{ {
if (_lmLayerMask == Vector2I.Zero) if (_lmLayerMask == Vector2I.Zero)
@ -309,6 +326,8 @@ public partial class Mission : Node3D
} }
} }
model.AddToGroup(OBJECT_MODELS_GROUP);
AddChild(model); AddChild(model);
} }
} }