My idea write parser c++ math formuls.
This gives easy copy c++ code and read code.
For example(very simple example).
float A = 2.1;
float B = 3;
vec3 C = A*B;
Parser understood float\int\vec2\vec3\vec4 and matrix3(3x3) and matrix4(4x4)
Parser get asm sse text code in output file(and we easy include this file in fasm source):
movss xmm0,[pA]
mulss xmm0,[pB]
pinsrd xmm1, xmm0, 0
pinsrd xmm1, xmm0, 1
pinsrd xmm1, xmm0, 2
;now in xmm1 we have vec3
In future very useful\handful for this:
Vec3 v0v1 = (v1- v0);
Vec3 v0v2 = (v2- v0);
Vec3 pvec = cross (r->dir, v0v2);
float det = dot (v0v1, pvec);
if (det < 0.000001) return -INFINITY;
float invDet = 1.0 / det;
Vec3 tvec = sub (r->orig, v0);
float u = dot (tvec, pvec) * invDet;
if (u < -0.0001 || u > 1.0001) return -INFINITY;
Vec3 qvec = cross (tvec, v0v1);
float v = dot (r->dir, qvec) * invDet;
if (v < -0.0001 || u + v > 1.0001) return -INFINITY;
return dot (v0v2, qvec) * invDet;