16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-17 23:39:18 +02:00

Replace interpolate with std::lerp and glm::mix

This commit is contained in:
docentYT
2026-05-02 01:31:38 +02:00
parent 362338ee5e
commit 3628eb0fc3
21 changed files with 108 additions and 116 deletions

View File

@@ -19,6 +19,11 @@ struct world_vertex {
glm::vec3 normal;
glm::vec2 texture;
static world_vertex lerp(world_vertex const &a, world_vertex const &b, double factor)
{
return static_cast<world_vertex>((a * (1.0f - factor)) + (b * factor));
}
// overloads
// operator+
template <typename Scalar_>
@@ -55,7 +60,7 @@ struct world_vertex {
void
set_half( world_vertex const &Vertex1, world_vertex const &Vertex2 ) {
*this =
interpolate(
world_vertex::lerp(
Vertex1,
Vertex2,
0.5 ); }
@@ -63,7 +68,7 @@ struct world_vertex {
void
set_from_x( world_vertex const &Vertex1, world_vertex const &Vertex2, double const X ) {
*this =
interpolate(
world_vertex::lerp(
Vertex1,
Vertex2,
( X - Vertex1.position.x ) / ( Vertex2.position.x - Vertex1.position.x ) ); }
@@ -71,7 +76,7 @@ struct world_vertex {
void
set_from_z( world_vertex const &Vertex1, world_vertex const &Vertex2, double const Z ) {
*this =
interpolate(
world_vertex::lerp(
Vertex1,
Vertex2,
( Z - Vertex1.position.z ) / ( Vertex2.position.z - Vertex1.position.z ) ); }