I am proposing the following changes to the pascal Combine2 & 3 for integer vectors.
function TGLZVector4b.Combine2(constref V2: TGLZVector4b; const F1, F2: Single): TGLZVector4b;
//Var
// va, vb : TGLZVector4b;
// ws : Byte;
begin
//ws:=Self.W; // doing it this way is both inefficient and
//va := Self * F1; // inaccurate with 12 calls to clampbyte
//vb := v2 * F2; // reducing the precision. Also more conversions
//result := va + vb; // from int to float and float to int.
result.X := ClampByte(Round(Self.X * F1 + V2.X * F2));
result.Y := ClampByte(Round(Self.Y * F1 + V2.Y * F2));
result.Z := ClampByte(Round(Self.Z * F1 + V2.Z * F2));
result.W := Self.W;
end;
Benefits:
It is what I think a routine like this should be doing, providing a more accurate integer multiple operations at scale. It does not throw away intermediate partials when calculating the result.
For asm routines we would no longer have to do the trunc.
It is faster in pure pascal with fewer calls to lower routines.
Disadvantage
none that I can see.
I am basing this on the presumption that this in its int form is used in areas like scaling and offsetting a scene object at a distance, Hit tests etc.
Jerome,
I am proposing the following changes to the pascal Combine2 & 3 for integer vectors.
Benefits:
Disadvantage
I am basing this on the presumption that this in its int form is used in areas like scaling and offsetting a scene object at a distance, Hit tests etc.