From 761604f9e4815e8f4355637ebb46052314cbed86 Mon Sep 17 00:00:00 2001 From: vimene Date: Wed, 10 Dec 2025 20:40:42 +0100 Subject: renamed .h to .hpp --- src/o3d/camera.h | 24 ------------------------ src/o3d/camera.hpp | 24 ++++++++++++++++++++++++ src/o3d/deriv_vertex.h | 21 --------------------- src/o3d/deriv_vertex.hpp | 21 +++++++++++++++++++++ src/o3d/mesh.cpp | 4 ++-- src/o3d/mesh.h | 24 ------------------------ src/o3d/mesh.hpp | 24 ++++++++++++++++++++++++ src/o3d/obj3d.h | 17 ----------------- src/o3d/obj3d.hpp | 17 +++++++++++++++++ src/o3d/scene.h | 18 ------------------ src/o3d/scene.hpp | 18 ++++++++++++++++++ src/o3d/tri.h | 22 ---------------------- src/o3d/tri.hpp | 22 ++++++++++++++++++++++ src/o3d/tri_deriv.cpp | 6 +++--- src/o3d/tri_deriv.h | 25 ------------------------- src/o3d/tri_deriv.hpp | 25 +++++++++++++++++++++++++ src/o3d/vertex.h | 19 ------------------- src/o3d/vertex.hpp | 19 +++++++++++++++++++ src/o3d/vertex_data.h | 29 ----------------------------- src/o3d/vertex_data.hpp | 29 +++++++++++++++++++++++++++++ 20 files changed, 204 insertions(+), 204 deletions(-) delete mode 100644 src/o3d/camera.h create mode 100644 src/o3d/camera.hpp delete mode 100644 src/o3d/deriv_vertex.h create mode 100644 src/o3d/deriv_vertex.hpp delete mode 100644 src/o3d/mesh.h create mode 100644 src/o3d/mesh.hpp delete mode 100644 src/o3d/obj3d.h create mode 100644 src/o3d/obj3d.hpp delete mode 100644 src/o3d/scene.h create mode 100644 src/o3d/scene.hpp delete mode 100644 src/o3d/tri.h create mode 100644 src/o3d/tri.hpp delete mode 100644 src/o3d/tri_deriv.h create mode 100644 src/o3d/tri_deriv.hpp delete mode 100644 src/o3d/vertex.h create mode 100644 src/o3d/vertex.hpp delete mode 100644 src/o3d/vertex_data.h create mode 100644 src/o3d/vertex_data.hpp (limited to 'src/o3d') diff --git a/src/o3d/camera.h b/src/o3d/camera.h deleted file mode 100644 index 832f473..0000000 --- a/src/o3d/camera.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef O3D_CAMERA_H -#define O3D_CAMERA_H - -#include "math/mat4.h" -#include "math/tform.h" - -using - engine::math::Matrix4, - engine::math::Transform; - -namespace engine::o3d { - -struct Camera { - float fov; - Transform transform; - - constexpr Matrix4 to_mat4(float aspect_ratio, float min_z, float max_z) const & { - return Matrix4::projection(fov, aspect_ratio, min_z, max_z) * transform.to_inverse_mat4(); - } -}; - -} - -#endif // O3D_CAMERA_H diff --git a/src/o3d/camera.hpp b/src/o3d/camera.hpp new file mode 100644 index 0000000..485c825 --- /dev/null +++ b/src/o3d/camera.hpp @@ -0,0 +1,24 @@ +#ifndef O3D_CAMERA_H +#define O3D_CAMERA_H + +#include "math/mat4.hpp" +#include "math/tform.hpp" + +using + engine::math::Matrix4, + engine::math::Transform; + +namespace engine::o3d { + +struct Camera { + float fov; + Transform transform; + + constexpr Matrix4 to_mat4(float aspect_ratio, float min_z, float max_z) const & { + return Matrix4::projection(fov, aspect_ratio, min_z, max_z) * transform.to_inverse_mat4(); + } +}; + +} + +#endif // O3D_CAMERA_H diff --git a/src/o3d/deriv_vertex.h b/src/o3d/deriv_vertex.h deleted file mode 100644 index c435a7e..0000000 --- a/src/o3d/deriv_vertex.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef O3D_DERIV_VERTEX_H -#define O3D_DERIV_VERTEX_H - -#include "math/vector.h" - -namespace engine::o3d { - -using engine::math::Vector4; - -struct DerivedVertex { - Vector4 vertex; - float b0, b1; - - constexpr DerivedVertex div_by_w() const & { - return {vertex.div_by_w(), b0, b1}; - } -}; - -} - -#endif // O3D_DERIV_VERTEX_H diff --git a/src/o3d/deriv_vertex.hpp b/src/o3d/deriv_vertex.hpp new file mode 100644 index 0000000..bc47780 --- /dev/null +++ b/src/o3d/deriv_vertex.hpp @@ -0,0 +1,21 @@ +#ifndef O3D_DERIV_VERTEX_H +#define O3D_DERIV_VERTEX_H + +#include "math/vector.hpp" + +namespace engine::o3d { + +using engine::math::Vector4; + +struct DerivedVertex { + Vector4 vertex; + float b0, b1; + + constexpr DerivedVertex div_by_w() const & { + return {vertex.div_by_w(), b0, b1}; + } +}; + +} + +#endif // O3D_DERIV_VERTEX_H diff --git a/src/o3d/mesh.cpp b/src/o3d/mesh.cpp index 2423e88..c1af5cd 100644 --- a/src/o3d/mesh.cpp +++ b/src/o3d/mesh.cpp @@ -1,8 +1,8 @@ -#include "o3d/mesh.h" +#include "o3d/mesh.hpp" #include #include #include -#include "math/vector.h" +#include "math/vector.hpp" using namespace engine::o3d; diff --git a/src/o3d/mesh.h b/src/o3d/mesh.h deleted file mode 100644 index acc48b5..0000000 --- a/src/o3d/mesh.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef O3D_MESH_H -#define O3D_MESH_H - -#include -#include -#include -#include -#include "math/vector.h" - -namespace engine::o3d { - -using engine::math::Vector3, engine::math::Vector4; - -struct Mesh { - static Mesh plane(float width, float height); - - std::vector vertices; - std::vector normals; - std::vector, 3>> indices; -}; - -} - -#endif // O3D_MESH_H diff --git a/src/o3d/mesh.hpp b/src/o3d/mesh.hpp new file mode 100644 index 0000000..2c3a065 --- /dev/null +++ b/src/o3d/mesh.hpp @@ -0,0 +1,24 @@ +#ifndef O3D_MESH_H +#define O3D_MESH_H + +#include +#include +#include +#include +#include "math/vector.hpp" + +namespace engine::o3d { + +using engine::math::Vector3, engine::math::Vector4; + +struct Mesh { + static Mesh plane(float width, float height); + + std::vector vertices; + std::vector normals; + std::vector, 3>> indices; +}; + +} + +#endif // O3D_MESH_H diff --git a/src/o3d/obj3d.h b/src/o3d/obj3d.h deleted file mode 100644 index 9f407f9..0000000 --- a/src/o3d/obj3d.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef O3D_OBJ3D_H -#define O3D_OBJ3D_H - -#include -#include "math/tform.h" -#include "o3d/mesh.h" - -namespace engine::o3d { - -struct Object3D { - Mesh mesh; - math::Transform transform; -}; - -} - -#endif // O3D_OBJ3D_H diff --git a/src/o3d/obj3d.hpp b/src/o3d/obj3d.hpp new file mode 100644 index 0000000..295d129 --- /dev/null +++ b/src/o3d/obj3d.hpp @@ -0,0 +1,17 @@ +#ifndef O3D_OBJ3D_H +#define O3D_OBJ3D_H + +#include +#include "math/tform.hpp" +#include "o3d/mesh.hpp" + +namespace engine::o3d { + +struct Object3D { + Mesh mesh; + math::Transform transform; +}; + +} + +#endif // O3D_OBJ3D_H diff --git a/src/o3d/scene.h b/src/o3d/scene.h deleted file mode 100644 index 3b9131c..0000000 --- a/src/o3d/scene.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef O3D_SCENE_H -#define O3D_SCENE_H - -#include -#include -#include "o3d/obj3d.h" -#include "o3d/camera.h" - -namespace engine::o3d { - -struct Scene { - Camera camera; - std::vector objs; -}; - -} - -#endif // O3D_SCENE_H diff --git a/src/o3d/scene.hpp b/src/o3d/scene.hpp new file mode 100644 index 0000000..65008ac --- /dev/null +++ b/src/o3d/scene.hpp @@ -0,0 +1,18 @@ +#ifndef O3D_SCENE_H +#define O3D_SCENE_H + +#include +#include +#include "o3d/obj3d.hpp" +#include "o3d/camera.hpp" + +namespace engine::o3d { + +struct Scene { + Camera camera; + std::vector objs; +}; + +} + +#endif // O3D_SCENE_H diff --git a/src/o3d/tri.h b/src/o3d/tri.h deleted file mode 100644 index 4b50f91..0000000 --- a/src/o3d/tri.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef O3D_TRI_H -#define O3D_TRI_H - -#include -#include "o3d/vertex.h" -#include "o3d/tri_deriv.h" - -namespace engine::o3d { - -struct Triangle { - Vertex vertex1; - Vertex vertex2; - Vertex vertex3; - - constexpr TriangleDerived to_derived() const & { - return {{vertex1.vertex, 1.f, 0.f}, {vertex2.vertex, 0.f, 1.f}, {vertex3.vertex, 0.f, 0.f}}; - } -}; - -} - -#endif // O3D_TRI_H diff --git a/src/o3d/tri.hpp b/src/o3d/tri.hpp new file mode 100644 index 0000000..7538d22 --- /dev/null +++ b/src/o3d/tri.hpp @@ -0,0 +1,22 @@ +#ifndef O3D_TRI_H +#define O3D_TRI_H + +#include +#include "o3d/vertex.hpp" +#include "o3d/tri_deriv.hpp" + +namespace engine::o3d { + +struct Triangle { + Vertex vertex1; + Vertex vertex2; + Vertex vertex3; + + constexpr TriangleDerived to_derived() const & { + return {{vertex1.vertex, 1.f, 0.f}, {vertex2.vertex, 0.f, 1.f}, {vertex3.vertex, 0.f, 0.f}}; + } +}; + +} + +#endif // O3D_TRI_H diff --git a/src/o3d/tri_deriv.cpp b/src/o3d/tri_deriv.cpp index a22067e..79e3fb4 100644 --- a/src/o3d/tri_deriv.cpp +++ b/src/o3d/tri_deriv.cpp @@ -1,7 +1,7 @@ -#include "o3d/tri_deriv.h" +#include "o3d/tri_deriv.hpp" #include -#include "math/vector.h" -#include "o3d/deriv_vertex.h" +#include "math/vector.hpp" +#include "o3d/deriv_vertex.hpp" using namespace engine::o3d; diff --git a/src/o3d/tri_deriv.h b/src/o3d/tri_deriv.h deleted file mode 100644 index 16a21f8..0000000 --- a/src/o3d/tri_deriv.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef O3D_TRI_VERTEX_H -#define O3D_TRI_VERTEX_H - -#include -#include "o3d/vertex.h" -#include "o3d/deriv_vertex.h" - -namespace engine::o3d { - -struct TriangleDerived { - DerivedVertex derived_vertex1; - DerivedVertex derived_vertex2; - DerivedVertex derived_vertex3; - - std::vector perspective_crop_xy_out(float x1, float x2, float y1, float y2) const; - std::vector crop_z_out(float z1, float z2) const; - - constexpr TriangleDerived div_by_w() const & { - return {derived_vertex1.div_by_w(), derived_vertex2.div_by_w(), derived_vertex3.div_by_w()}; - } -}; - -} - -#endif // O3D_TRI_VERTEX_H diff --git a/src/o3d/tri_deriv.hpp b/src/o3d/tri_deriv.hpp new file mode 100644 index 0000000..f82bd9b --- /dev/null +++ b/src/o3d/tri_deriv.hpp @@ -0,0 +1,25 @@ +#ifndef O3D_TRI_VERTEX_H +#define O3D_TRI_VERTEX_H + +#include +#include "o3d/vertex.hpp" +#include "o3d/deriv_vertex.hpp" + +namespace engine::o3d { + +struct TriangleDerived { + DerivedVertex derived_vertex1; + DerivedVertex derived_vertex2; + DerivedVertex derived_vertex3; + + std::vector perspective_crop_xy_out(float x1, float x2, float y1, float y2) const; + std::vector crop_z_out(float z1, float z2) const; + + constexpr TriangleDerived div_by_w() const & { + return {derived_vertex1.div_by_w(), derived_vertex2.div_by_w(), derived_vertex3.div_by_w()}; + } +}; + +} + +#endif // O3D_TRI_VERTEX_H diff --git a/src/o3d/vertex.h b/src/o3d/vertex.h deleted file mode 100644 index 438f8b3..0000000 --- a/src/o3d/vertex.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef O3D_VERTEX_H -#define O3D_VERTEX_H - -#include "math/vector.h" -#include "o3d/vertex_data.h" - -namespace engine::o3d { - -using engine::math::Vector3, engine::math::Vector4; - -struct Vertex { - Vector4 vertex; - Vector3 normal; - VertexData data; -}; - -} - -#endif // O3D_VERTEX_H diff --git a/src/o3d/vertex.hpp b/src/o3d/vertex.hpp new file mode 100644 index 0000000..70fca7b --- /dev/null +++ b/src/o3d/vertex.hpp @@ -0,0 +1,19 @@ +#ifndef O3D_VERTEX_H +#define O3D_VERTEX_H + +#include "math/vector.hpp" +#include "o3d/vertex_data.hpp" + +namespace engine::o3d { + +using engine::math::Vector3, engine::math::Vector4; + +struct Vertex { + Vector4 vertex; + Vector3 normal; + VertexData data; +}; + +} + +#endif // O3D_VERTEX_H diff --git a/src/o3d/vertex_data.h b/src/o3d/vertex_data.h deleted file mode 100644 index 22fa76b..0000000 --- a/src/o3d/vertex_data.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef O3D_VERTEX_DATA_H -#define O3D_VERTEX_DATA_H - -#include "math/vector.h" - -using - engine::math::Vector3; - -namespace engine::o3d { - -struct VertexData { - static constexpr VertexData lerp(const VertexData& vd1, const VertexData& vd2, float b0) { - return { - b0 * vd1.world_loc + (1.f - b0) * vd2.world_loc, - }; - } - - static constexpr VertexData bilerp(const VertexData& vd1, const VertexData& vd2, const VertexData& vd3, float b0, float b1) { - return { - b0 * vd1.world_loc + b1 * vd2.world_loc + (1.f - b0 - b1) * vd3.world_loc, - }; - } - - Vector3 world_loc; -}; - -} - -#endif // O3D_VERTEX_DATA_H diff --git a/src/o3d/vertex_data.hpp b/src/o3d/vertex_data.hpp new file mode 100644 index 0000000..0ebc6c9 --- /dev/null +++ b/src/o3d/vertex_data.hpp @@ -0,0 +1,29 @@ +#ifndef O3D_VERTEX_DATA_H +#define O3D_VERTEX_DATA_H + +#include "math/vector.hpp" + +using + engine::math::Vector3; + +namespace engine::o3d { + +struct VertexData { + static constexpr VertexData lerp(const VertexData& vd1, const VertexData& vd2, float b0) { + return { + b0 * vd1.world_loc + (1.f - b0) * vd2.world_loc, + }; + } + + static constexpr VertexData bilerp(const VertexData& vd1, const VertexData& vd2, const VertexData& vd3, float b0, float b1) { + return { + b0 * vd1.world_loc + b1 * vd2.world_loc + (1.f - b0 - b1) * vd3.world_loc, + }; + } + + Vector3 world_loc; +}; + +} + +#endif // O3D_VERTEX_DATA_H -- cgit v1.2.3