From 31ff8123ee4930934e64116f1fc62f9f43995809 Mon Sep 17 00:00:00 2001 From: Alexander Scheurer Date: Mon, 25 May 2020 22:14:06 +0200 Subject: [PATCH] Extension SceneNode.ShallowCopy() --- src/Engine/Core/Scene/SceneExtensions.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Engine/Core/Scene/SceneExtensions.cs b/src/Engine/Core/Scene/SceneExtensions.cs index ed46f3cd9..ae373b24f 100644 --- a/src/Engine/Core/Scene/SceneExtensions.cs +++ b/src/Engine/Core/Scene/SceneExtensions.cs @@ -544,6 +544,24 @@ public static void FpsView(this Transform tc, float angleHorz, float angleVert, tc.Rotation.x = angleVert; } + /// + /// This creates a shallow copy of this SceneNode with the abillity to be copied into a derived class. It does not connect the resullting copy with this SceneNodes parent. + /// + /// Target type + /// + /// + public static TOut ShallowCopy(this SceneNode sn) + where TOut : SceneNode, new() + { + TOut tout = new TOut(); + + tout.Name = sn.Name; + tout.Components = sn.Components; + tout.Children = sn.Children; + + return tout; + } + /// /// Reference space for rotation. ///