type
TTwoSingleArray = array [0..1] of single;
// 2D Vector; 32 bit floating point components
{ TXMFLOAT2 }
TXMFLOAT2 = record
class operator Initialize(var AFloat2:TXMFLOAT2);
constructor Create(_x, _y: single);
class operator Explicit(a: TTwoSingleArray): TXMFLOAT2;
case integer of
0: (x: single;
y: single);
1: (f: TTwoSingleArray);
end;
// 2D Vector; 32 bit floating point components aligned on a 16 byte boundary
{$PACKRECORD 16}
{ TXMFLOAT2A }
TXMFLOAT2A = record (TXMFLOAT2)
class operator Initialize (var AFloat2A:TXMFLOAT2A);
constructor Create(_x, _y: single);
class operator Explicit(a: TTwoSingleArray): TXMFLOAT2A;
end;
implementation
{ TXMFLOAT2A }
class operator TXMFLOAT2A.Initialize(var AFloat2A: TXMFLOAT2A);
begin
ZeroMemory(AFloat2A,SizeOf(TXMFLOAT2A));
end;
constructor TXMFLOAT2A.Create(_x, _y: single);
begin
inherited;
end;
class operator TXMFLOAT2A.Explicit(a: TTwoSingleArray): TXMFLOAT2A;
begin
inherited;
end;
{ TXMFLOAT2 }
class operator TXMFLOAT2.Initialize(var AFloat2: TXMFLOAT2);
begin
ZeroMemory(AFloat2,SizeOf(TXMFLOAT2));
end;
constructor TXMFLOAT2.Create(_x, _y: single);
begin
x:=_x;
y:=_y;
end;
class operator TXMFLOAT2.Explicit(a: TTwoSingleArray): TXMFLOAT2;
begin
Result.f:=a;
end;