// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. using System; using System.Runtime.InteropServices; namespace FlaxEngine { partial class Spline { private BezierCurve.Keyframe[] _keyframes; /// /// Gets or sets the spline keyframes collection. /// [Unmanaged] [Tooltip("Spline keyframes collection.")] [EditorOrder(10), EditorDisplay("Spline"), Collection(CanReorderItems = false)] public BezierCurve.Keyframe[] SplineKeyframes { get { var count = SplinePointsCount; if (_keyframes == null || _keyframes.Length != count) _keyframes = new BezierCurve.Keyframe[count]; #if !BUILD_RELEASE if (System.Runtime.CompilerServices.Unsafe.SizeOf.Keyframe>() != Transform.SizeInBytes * 3 + sizeof(float)) throw new Exception("Invalid size of BezierCurve keyframe " + System.Runtime.CompilerServices.Unsafe.SizeOf.Keyframe>() + " bytes."); #endif Internal_GetKeyframes(__unmanagedPtr, _keyframes); return _keyframes; } set { if (value == null) value = Utils.GetEmptyArray.Keyframe>(); _keyframes = null; Internal_SetKeyframes(__unmanagedPtr, value); } } /// /// Gets the spline keyframe. /// /// The spline point index. /// The keyframe. public BezierCurve.Keyframe GetSplineKeyframe(int index) { return SplineKeyframes[index]; } /// /// Sets the spline keyframe. /// /// The spline point index. /// The keyframe. public void SetSplineKeyframe(int index, BezierCurve.Keyframe keyframe) { SetSplineLocalTransform(index, keyframe.Value, false); SetSplineLocalTangent(index, keyframe.Value + keyframe.TangentIn, true, false); SetSplineLocalTangent(index, keyframe.Value + keyframe.TangentOut, false); } } }