| @@ -3,10 +3,13 @@ | |||||
| type __HELPER = type helper for __VEC | type __HELPER = type helper for __VEC | ||||
| public | public | ||||
| {$IF __SIZE = 2} | {$IF __SIZE = 2} | ||||
| class function Create(const s: __IMPL.TBaseType): __IMPL.TVector2; static; inline; | |||||
| class function Create(const x, y: __IMPL.TBaseType): __IMPL.TVector2; static; inline; | class function Create(const x, y: __IMPL.TBaseType): __IMPL.TVector2; static; inline; | ||||
| {$ELSEIF __SIZE = 3} | {$ELSEIF __SIZE = 3} | ||||
| class function Create(const s: __IMPL.TBaseType): __IMPL.TVector3; static; inline; | |||||
| class function Create(const x, y, z: __IMPL.TBaseType): __IMPL.TVector3; static; inline; | class function Create(const x, y, z: __IMPL.TBaseType): __IMPL.TVector3; static; inline; | ||||
| {$ELSEIF __SIZE = 4} | {$ELSEIF __SIZE = 4} | ||||
| class function Create(const s: __IMPL.TBaseType): __IMPL.TVector4; static; inline; | |||||
| class function Create(const x, y, z, w: __IMPL.TBaseType): __IMPL.TVector4; static; inline; | class function Create(const x, y, z, w: __IMPL.TBaseType): __IMPL.TVector4; static; inline; | ||||
| {$ELSE} | {$ELSE} | ||||
| {$ERROR only vectors of size 2, 3 or 4 are supported} | {$ERROR only vectors of size 2, 3 or 4 are supported} | ||||
| @@ -451,25 +454,41 @@ | |||||
| function Angle2(const v: __VEC): Double; inline; | function Angle2(const v: __VEC): Double; inline; | ||||
| {$ENDIF} | {$ENDIF} | ||||
| end; | end; | ||||
| operator * (const v: __VEC; const s: __IMPL.TBaseType): __VEC; | |||||
| operator * (const s: __IMPL.TBaseType; const v: __VEC): __VEC; | |||||
| operator * (const v1, v2: __VEC): __IMPL.TBaseType; | |||||
| operator * (const v: __VEC; const s: __IMPL.TBaseType): __VEC; inline; | |||||
| operator * (const s: __IMPL.TBaseType; const v: __VEC): __VEC; inline; | |||||
| operator * (const v1, v2: __VEC): __IMPL.TBaseType; inline; | |||||
| operator / (const v: __VEC; const s: __IMPL.TBaseType): __VEC; inline; | |||||
| {$ENDIF} | {$ENDIF} | ||||
| {$ENDIF} | {$ENDIF} | ||||
| {$ENDIF} | {$ENDIF} | ||||
| {$ELSEIF DEFINED (__VECTOR_HELPER_IMPL)} | {$ELSEIF DEFINED (__VECTOR_HELPER_IMPL)} | ||||
| {$IFDEF __HELPER} | {$IFDEF __HELPER} | ||||
| {$IF __SIZE = 2} | {$IF __SIZE = 2} | ||||
| class function __HELPER.Create(const s: __IMPL.TBaseType): __VEC; | |||||
| begin | |||||
| result := __IMPL.Vector2(s, s); | |||||
| end; | |||||
| class function __HELPER.Create(const x, y: __IMPL.TBaseType): __VEC; | class function __HELPER.Create(const x, y: __IMPL.TBaseType): __VEC; | ||||
| begin | begin | ||||
| result := __IMPL.Vector2(x, y); | result := __IMPL.Vector2(x, y); | ||||
| end; | end; | ||||
| {$ELSEIF __SIZE = 3} | {$ELSEIF __SIZE = 3} | ||||
| class function __HELPER.Create(const s: __IMPL.TBaseType): __VEC; | |||||
| begin | |||||
| result := __IMPL.Vector3(s, s, s); | |||||
| end; | |||||
| class function __HELPER.Create(const x, y, z: __IMPL.TBaseType): __VEC; | class function __HELPER.Create(const x, y, z: __IMPL.TBaseType): __VEC; | ||||
| begin | begin | ||||
| result := __IMPL.Vector3(x, y, z); | result := __IMPL.Vector3(x, y, z); | ||||
| end; | end; | ||||
| {$ELSEIF __SIZE = 4} | {$ELSEIF __SIZE = 4} | ||||
| class function __HELPER.Create(const s: __IMPL.TBaseType): __VEC; | |||||
| begin | |||||
| result := __IMPL.Vector4(s, s, s, s); | |||||
| end; | |||||
| class function __HELPER.Create(const x, y, z, w: __IMPL.TBaseType): __VEC; | class function __HELPER.Create(const x, y, z, w: __IMPL.TBaseType): __VEC; | ||||
| begin | begin | ||||
| result := __IMPL.Vector4(x, y, z, w); | result := __IMPL.Vector4(x, y, z, w); | ||||
| @@ -994,17 +1013,22 @@ | |||||
| operator * (const v: __VEC; const s: __IMPL.TBaseType): __VEC; | operator * (const v: __VEC; const s: __IMPL.TBaseType): __VEC; | ||||
| begin | begin | ||||
| result := __IMPl.Multiply(v, s); | |||||
| result := __IMPL.Multiply(v, s); | |||||
| end; | end; | ||||
| operator * (const s: __IMPL.TBaseType; const v: __VEC): __VEC; | operator * (const s: __IMPL.TBaseType; const v: __VEC): __VEC; | ||||
| begin | begin | ||||
| result := __IMPl.Multiply(v, s); | |||||
| result := __IMPL.Multiply(v, s); | |||||
| end; | end; | ||||
| operator * (const v1, v2: __VEC): __IMPL.TBaseType; | operator * (const v1, v2: __VEC): __IMPL.TBaseType; | ||||
| begin | begin | ||||
| result := __IMPl.Dot(v1, v2); | |||||
| result := __IMPL.Dot(v1, v2); | |||||
| end; | |||||
| operator / (const v: __VEC; const s: __IMPL.TBaseType): __VEC; | |||||
| begin | |||||
| result := __IMPL.Divide(v, s); | |||||
| end; | end; | ||||
| {$ENDIF} | {$ENDIF} | ||||
| {$ENDIF} | {$ENDIF} | ||||