static unsafe void TransformVertices(byte[] vertices, MeshData.MeshGeometryFormat format, Matrix4 matrix, Quaternion rotation) { fixed(byte *ptr = vertices) { int count = vertices.Length / format.vertexSize; for (int i = 0; i < count; i++) { byte * vertexStart = ptr + i * format.vertexSize; Vector3F *posPtr = (Vector3F *)(vertexStart + format.positionOffset); * posPtr = (*posPtr * matrix).ToVector3F(); Vector3F *normalPtr = (Vector3F *)(vertexStart + format.normalOffset); * normalPtr = (*normalPtr * rotation).ToVector3F(); Vector4F *tangentPtr = (Vector4F *)(vertexStart + format.tangentOffset); * tangentPtr = new Vector4F(((*tangentPtr).ToVector3F() * rotation).ToVector3F(), (*tangentPtr).W); } } }
public static void StoreToVector(this Vector128 <float> vector, Vector3F *destination) => vector.ToVector3D(&destination->X);
public static Vector128 <float> ToVector128(Vector3F *p) => Vector.FromVector3D((float *)p);