summaryrefslogtreecommitdiff
path: root/maths.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'maths.cpp')
-rw-r--r--maths.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/maths.cpp b/maths.cpp
index 107f321..4eae44e 100644
--- a/maths.cpp
+++ b/maths.cpp
@@ -57,10 +57,11 @@ m4f m4f::operator*(const m4f& other) const {
v4f m4f::operator*(const v4f& other) const {
return v4f(
- m[0][0] * other.x + m[1][0] * other.y + m[2][0] * other.z + m[3][0] + other.w,
- m[0][1] * other.x + m[1][1] * other.y + m[2][1] * other.z + m[3][1] + other.w,
- m[0][2] * other.x + m[1][2] * other.y + m[2][2] * other.z + m[3][2] + other.w,
- m[0][3] * other.x + m[1][3] * other.y + m[2][3] * other.z + m[3][3] + other.w);
+ m[0][0] * other.x + m[1][0] * other.y + m[2][0] * other.z + m[3][0] * other.w,
+ m[0][1] * other.x + m[1][1] * other.y + m[2][1] * other.z + m[3][1] * other.w,
+ m[0][2] * other.x + m[1][2] * other.y + m[2][2] * other.z + m[3][2] * other.w,
+ m[0][3] * other.x + m[1][3] * other.y + m[2][3] * other.z + m[3][3] * other.w
+ );
}
m4f m4f::translate(m4f m, v3f v) {
@@ -237,7 +238,6 @@ m4f m4f::inverse() {
m4f m4f::transposed() {
m4f r(1.0f);
-
r.m[0][0] = m[0][0];
r.m[1][0] = m[0][1];
r.m[2][0] = m[0][2];
@@ -253,17 +253,16 @@ m4f m4f::transposed() {
r.m[0][3] = m[3][0];
r.m[1][3] = m[3][1];
r.m[2][3] = m[3][2];
- r.m[3][3] = m[3][3];
-
+ r.m[2][3] = m[3][3];
return r;
}
v4f m4f::transform(m4f m, v4f v) {
return v4f(
- m.m[0][0] * v.x + m.m[1][0] * v.y + m.m[2][0] * v.z + m.m[3][0] + v.w,
- m.m[0][1] * v.x + m.m[1][1] * v.y + m.m[2][1] * v.z + m.m[3][1] + v.w,
- m.m[0][2] * v.x + m.m[1][2] * v.y + m.m[2][2] * v.z + m.m[3][2] + v.w,
- m.m[0][3] * v.x + m.m[1][3] * v.y + m.m[2][3] * v.z + m.m[3][3] + v.w);
+ m.m[0][0] * v.x + m.m[1][0] * v.y + m.m[2][0] * v.z + m.m[3][0] * v.w,
+ m.m[0][1] * v.x + m.m[1][1] * v.y + m.m[2][1] * v.z + m.m[3][1] * v.w,
+ m.m[0][2] * v.x + m.m[1][2] * v.y + m.m[2][2] * v.z + m.m[3][2] * v.w,
+ m.m[0][3] * v.x + m.m[1][3] * v.y + m.m[2][3] * v.z + m.m[3][3] * v.w);
}
AABB m4f::transform(m4f m, AABB aabb) {
@@ -284,7 +283,7 @@ AABB m4f::transform(m4f m, AABB aabb) {
};
for (int i = 0; i < 8; i++) {
- v4f point = m4f::transform(m, v4f(corners[i].x, corners[i].y, corners[i].z, 0.0f));
+ v4f point = m4f::transform(m, v4f(corners[i].x, corners[i].y, corners[i].z, 1.0f));
result.min.x = std::min(result.min.x, point.x);
result.min.y = std::min(result.min.y, point.y);