public void Short4_Clamping() { // arrange var short1 = new Short4(Vector4.One * 1234567.0f); var short2 = new Short4(Vector4.One * -1234567.0f); // act var vector1 = short1.ToVector4(); var vector2 = short2.ToVector4(); // assert Assert.Equal(Vector4.One * 0x7FFF, vector1); Assert.Equal(Vector4.One * -0x8000, vector2); }
public void Encode(VertexElement element, Short4 value) { var dstVertex = _Vertex.Slice(element.Offset); if (element.VertexElementFormat == VertexElementFormat.Vector4) { var v4 = value.ToVector4(); System.Runtime.InteropServices.MemoryMarshal.Write(dstVertex, ref v4); return; } if (element.VertexElementFormat == VertexElementFormat.Short4) { System.Runtime.InteropServices.MemoryMarshal.Write(dstVertex, ref value); return; } throw new ArgumentException(nameof(element)); }