3#include "../structs/common.hpp"
6namespace BspParser::Internal {
7 inline Structs::Vector xyz(
const Structs::Vector4& v) {
8 return {.x = v.x, .y = v.y, .z = v.z};
11 inline Structs::Vector2 add(
const Structs::Vector2& a,
const Structs::Vector2& b) {
12 return Structs::Vector2{
18 template <
typename... T>
19 Structs::Vector add(
const T&... args)
20 requires(... && std::same_as<Structs::Vector, T>)
22 return Structs::Vector{
29 inline Structs::Vector2 sub(
const Structs::Vector2& a,
const Structs::Vector2& b) {
30 return Structs::Vector2{
36 inline Structs::Vector sub(
const Structs::Vector& a,
const Structs::Vector& b) {
37 return Structs::Vector{
44 inline Structs::Vector2 mul(
const Structs::Vector2& a,
const float b) {
45 return Structs::Vector2{
51 inline Structs::Vector mul(
const Structs::Vector& a,
const float b) {
52 return Structs::Vector{
59 inline Structs::Vector div(
const Structs::Vector& a,
const float b) {
60 return Structs::Vector{
67 inline float dot(
const Structs::Vector& a,
const Structs::Vector& b) {
68 return a.x * b.x + a.y * b.y + a.z * b.z;
71 inline Structs::Vector cross(
const Structs::Vector& a,
const Structs::Vector& b) {
72 return Structs::Vector{
73 .x = a.y * b.z - a.z * b.y,
74 .y = a.z * b.x - a.x * b.z,
75 .z = a.x * b.y - a.y * b.x,
79 inline float length(
const Structs::Vector& v) {
80 return std::sqrt(dot(v, v));
83 inline Structs::Vector normalise(
const Structs::Vector& v) {
84 return div(v, length(v));
87 inline Structs::Vector lerp(
const Structs::Vector& a,
const Structs::Vector& b,
const float t) {
88 return Structs::Vector{
89 .x = a.x + (b.x - a.x) * t,
90 .y = a.y + (b.y - a.y) * t,
91 .z = a.z + (b.z - a.z) * t,