aboutsummaryrefslogtreecommitdiff
path: root/src/o3d/vertex_data.h
diff options
context:
space:
mode:
authorvimene <vincent.menegaux@gmail.com>2024-12-31 03:40:14 +0100
committervimene <vincent.menegaux@gmail.com>2024-12-31 03:40:14 +0100
commitcc6fb8c33637566a7b116d46440e6063f016deea (patch)
tree5cc83f84525507994add57df7dd974e6611d675a /src/o3d/vertex_data.h
parent6b765a85cf81bf4b7162e4c9280dd4054581c611 (diff)
downloadengine-cc6fb8c33637566a7b116d46440e6063f016deea.tar.gz
various improvements
- added quaternions and rewrote all rotations to use them - added transforms to put all object transforms in a single place - added Wavefront .obj file parser - removed frame buffer's abstract class - improved vectors, matrices, triangles, vertices and vertices data by putting all code in header file - added vector's operations - changed from NULL to nullptr - miscellaneous improvements
Diffstat (limited to 'src/o3d/vertex_data.h')
-rw-r--r--src/o3d/vertex_data.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/o3d/vertex_data.h b/src/o3d/vertex_data.h
index b8ed14c..71f42cd 100644
--- a/src/o3d/vertex_data.h
+++ b/src/o3d/vertex_data.h
@@ -3,14 +3,22 @@
namespace engine::o3d {
-class VertexData {
- public:
- static VertexData lerp(const VertexData& vd1, const VertexData& vd2, float b0);
- static VertexData bilerp(const VertexData& vd1, const VertexData& vd2, const VertexData& vd3, float b0, float b1);
+struct VertexData {
+ static constexpr VertexData lerp(const VertexData& vd1, const VertexData& vd2, float b0) {
+ return {
+ b0 * vd1.tx + (1.f - b0) * vd2.tx,
+ b0 * vd1.ty + (1.f - b0) * vd2.ty
+ };
+ }
- float tx, ty;
+ static constexpr VertexData bilerp(const VertexData& vd1, const VertexData& vd2, const VertexData& vd3, float b0, float b1) {
+ return {
+ b0 * vd1.tx + b1 * vd2.tx + (1.f - b0 - b1) * vd3.tx,
+ b0 * vd1.ty + b1 * vd2.ty + (1.f - b0 - b1) * vd3.ty
+ };
+ }
- VertexData(float tx, float ty);
+ float tx, ty;
};
}