Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Blending matrices

  1. #11

    Blending matrices

    Only the last row defines position, lineary interpolating w components makes no sense

  2. #12

    Blending matrices

    scaling?
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  3. #13

    Blending matrices

    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.

  4. #14

    Blending matrices

    Quote Originally Posted by User137
    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:
    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));
    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).

  5. #15

    Blending matrices

    Lifepower,
    Delphi 2005-2006 have inline functions :)

  6. #16

    Blending matrices

    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]

  7. #17

    Blending matrices

    Quote Originally Posted by XProger
    Lifepower,
    Delphi 2005-2006 have inline functions
    I know.

    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.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •