Add Vec2, Vec3 and Vec4 structs (incomplete)
This commit is contained in:
35
engine/include/nova/math/vec2.h
Normal file
35
engine/include/nova/math/vec2.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <nova/pragma.h>
|
||||||
|
#include <nova/types.h>
|
||||||
|
|
||||||
|
namespace Nova {
|
||||||
|
NOVA_BEGIN_ALLOW_ANONYMOUS_TYPES
|
||||||
|
|
||||||
|
template<typename T = f32>
|
||||||
|
struct Vec2 {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
T x, y;
|
||||||
|
};
|
||||||
|
struct {
|
||||||
|
T u, v;
|
||||||
|
};
|
||||||
|
struct {
|
||||||
|
T width, height;
|
||||||
|
};
|
||||||
|
T data[2];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using iVec2 = Vec2<i32>;
|
||||||
|
using uVec2 = Vec2<u32>;
|
||||||
|
|
||||||
|
NOVA_END_ALLOW_ANONYMOUS_TYPES
|
||||||
|
} // namespace Nova
|
||||||
32
engine/include/nova/math/vec3.h
Normal file
32
engine/include/nova/math/vec3.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <nova/pragma.h>
|
||||||
|
#include <nova/types.h>
|
||||||
|
|
||||||
|
namespace Nova {
|
||||||
|
NOVA_BEGIN_ALLOW_ANONYMOUS_TYPES
|
||||||
|
|
||||||
|
template<typename T = f32>
|
||||||
|
struct Vec3 {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
T x, y, z;
|
||||||
|
};
|
||||||
|
struct {
|
||||||
|
T r, g, b;
|
||||||
|
};
|
||||||
|
T data[3];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using iVec3 = Vec3<i32>;
|
||||||
|
using uVec3 = Vec3<u32>;
|
||||||
|
|
||||||
|
NOVA_END_ALLOW_ANONYMOUS_TYPES
|
||||||
|
} // namespace Nova
|
||||||
32
engine/include/nova/math/vec4.h
Normal file
32
engine/include/nova/math/vec4.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <nova/pragma.h>
|
||||||
|
#include <nova/types.h>
|
||||||
|
|
||||||
|
namespace Nova {
|
||||||
|
NOVA_BEGIN_ALLOW_ANONYMOUS_TYPES
|
||||||
|
|
||||||
|
template<typename T = f32>
|
||||||
|
struct Vec4 {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
T x, y, z, w;
|
||||||
|
};
|
||||||
|
struct {
|
||||||
|
T r, g, b, a;
|
||||||
|
};
|
||||||
|
T data[4];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
using iVec4 = Vec4<i32>;
|
||||||
|
using uVec4 = Vec4<u32>;
|
||||||
|
|
||||||
|
NOVA_END_ALLOW_ANONYMOUS_TYPES
|
||||||
|
} // namespace Nova
|
||||||
Reference in New Issue
Block a user