我正在尝试优化游戏中的内存使用量。这个结构的大量内容占用了大量内存:
/// <summary>
/// Represents a keyframe in an animation track.
/// </summary>
public struct BoneKeyframe
{
/// <summary>
/// Creats a new BoneKeyframe.
/// </summary>
/// <param name="transform">The transform for the keyframe.</param>
/// <param name="time">The time in ticks for the keyframe.</param>
public BoneKeyframe(Matrix transform, long time)
{
this.Transform = transform;
this.Time = time;
}
/// <summary>
/// The transform for the keyframe.
/// </summary>
public readonly Matrix Transform;
/// <summary>
/// The time for the keyframe.
/// </summary>
public readonly long Time;
}
我想用自定义类/结构替换Transform成员。 它应该包含一个可选的翻译Vector3,可选的缩放Vector3和一个旋转四元数(Vector4)。 我如何设计它以使其变得尽可能紧凑......重点是减少BoneKeyFrame数组的总大小。