Source code for D3DX math functions
Does anyone have the source for the D3DX math functions? Specifically I am look for the source of D3DXVec3Transform and D3DXVec3TransformNormal. I need to know exactly what they do to be able to figure out my mistakes in porting Brett Porter''s ms3d animation code to D3D.
I don''t have the source, but it should be plain vector maths:
VecTransform:
float x = V.x;
float y = V.y;
float z = V.z;
float w = 1;
out.x = x*m._11 + y*m._21 + z*m._31 + w*m._41
out.y = x*m._12 + y*m._22 + z*m._32 + w*m._42
out.z = x*m._13 + y*m._23 + z*m._33 + w*m._43
out.w = x*m._14 + y*m._24 + z*m._34 + w*m._44
VecTransformNormal:
float x = V.x;
float y = V.y;
float z = V.z;
out.x = x*m._11 + y*m._21 + z*m._31
out.y = x*m._12 + y*m._22 + z*m._32
out.z = x*m._13 + y*m._23 + z*m._33
The above should give exactly the same results...
--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
VecTransform:
float x = V.x;
float y = V.y;
float z = V.z;
float w = 1;
out.x = x*m._11 + y*m._21 + z*m._31 + w*m._41
out.y = x*m._12 + y*m._22 + z*m._32 + w*m._42
out.z = x*m._13 + y*m._23 + z*m._33 + w*m._43
out.w = x*m._14 + y*m._24 + z*m._34 + w*m._44
VecTransformNormal:
float x = V.x;
float y = V.y;
float z = V.z;
out.x = x*m._11 + y*m._21 + z*m._31
out.y = x*m._12 + y*m._22 + z*m._32
out.z = x*m._13 + y*m._23 + z*m._33
The above should give exactly the same results...
--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
okonomiyaki: Please take a look at them yourself before giving an answer like that. If you take a good look you''ll notice that some functions are inlined while others aren''t. The two functions I asked for are in the latter category.
s1ca: Thanks. This is what I was thinking too, but I just would like to be sure that that is the case.
s1ca: Thanks. This is what I was thinking too, but I just would like to be sure that that is the case.
quote:s1ca: Thanks. This is what I was thinking too, but I just would like to be sure that that is the case.
The simplest way to check would be to put both functions (D3DX and a hand written one) up against each other and compare the outputs. You could even do an automated check which created random vectors and matrices and do a memcmp() between the results if you were really paranoid
On some CPUs there may be a tiny difference in precision and rounding between the straight C++ code and the version used by D3DX - this is due to the fact that D3DX will use 3DNow!, SSE or SSE2 where present to do some matrix/vector maths.
IIRC there''s a registry key to disable PSGP (Processor Specific Graphics Pipeline) in D3DX to force it to use the straight scalar FPU instructions.
--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement