Skip to content

Commit

Permalink
add UVFace
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Dec 24, 2024
1 parent 59f1303 commit 10491fb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/maths/UVFace.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include <array>
#include <glm/glm.hpp>

#include "UVRegion.hpp"

struct UVFace {
std::array<glm::vec2, 4> points;

UVFace(const UVRegion& region) {
points[0] = {region.u1, region.v1};
points[1] = {region.u2, region.v1};
points[2] = {region.u2, region.v2};
points[3] = {region.u1, region.v2};
}

template<int n>
inline void rotate(int times) {
int times = n % 4;
if (times < 0) {
times += 4;
}
std::array<glm::vec2, 4> temp = points;
points[0] = temp[times];
points[1] = temp[(times + 1) % 4];
points[2] = temp[(times + 2) % 4];
points[3] = temp[(times + 3) % 4];
}
};

0 comments on commit 10491fb

Please sign in to comment.