Only the last row defines position, lineary interpolating w components makes no sense
Only the last row defines position, lineary interpolating w components makes no sense
scaling?
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
Well, it is not just interpolating w components but resetting those values to the matrix. QuaternionToMatrix3 only touches first 3x3 part. If i replace 0..3 to 0..2 it doesn't work, either copying only other i or j row doesn't work. Must have the full matrix initialized.
This will get cleaner when i edit those functions using pointers instead of slowly taking and returning full matrixes and vectors.
You can do that, but you lose elegancy *and* usability. You won't be able to do something like that:Originally Posted by User137
The only real optimization you can do is replacing return values by pointers, but as I said, you won't be able to use functions as parameters to other functions. You won't be able to optimize parameters much, since they are already passed as pointers (notice "const" in declaration).Code:// Delphi 2005 or lower code RawMtx:= MatMul(MatScale(Vector3(0.5, 0.5, 0.5)), MatMul(MatTransl(Vector3(100.0, 50.0, 0.0)), MatRotateX(Pi / 2))); // Delphi 2006 RawMtx:= Vector3(0.5, 0.5, 0.5) * (MatTransl(Vector3(100.0, 50.0, 0.0)) * MatRotateX(Pi / 2));
Lifepower,
Delphi 2005-2006 have inline functions :)
I don't mind usability as long as it needs short code and is faster.
This may be final version:
[pascal]procedure MatrixBlend(dest,m1,m2: PMatrix; s: single);
var q,q1,q2: TVector4; i: integer;
begin
// Initialize matrix
for i:=0 to 3 do dest[i,3]:=m1[i,3];
// Interpolate rotation
MatrixToQuat(m1,@q1);
MatrixToQuat(m2,@q2);
QuatSlerp(@q1,@q2,@q,s);
QuatToMatrix(@q,dest);
for i:=0 to 2 do // Interpolate position
dest[3,i]:=m1[3,i]+s*(m2[3,i]-m1[3,i]);
end;[/pascal]
I know.Originally Posted by XProger
By the way, I've done some tests with Delphi inline functions and most of the time performance was actually dropping when using inline functions. Also, I'm not quite fond of the code generation when it comes to inline functions (somehow inline code is treated as separate in code optimization). They should have implemented macro support instead.
Bookmarks