working mouse picking
This commit is contained in:
@@ -135,4 +135,12 @@ typedef Mat4<float> Mat4f;
|
||||
typedef Mat4<int> Mat4i;
|
||||
typedef Mat4<double> Mat4d;
|
||||
|
||||
template<typename T>
|
||||
inline bool operator==(const Mat4<T>& mat, const Mat4<T>& other) {
|
||||
return mat.x0 == other.x0 && mat.y0 == other.y0 && mat.z0 == other.z0 && mat.w0 == other.w0 &&
|
||||
mat.x1 == other.x1 && mat.y1 == other.y1 && mat.z1 == other.z1 && mat.w1 == other.w1 &&
|
||||
mat.x2 == other.x2 && mat.y2 == other.y2 && mat.z2 == other.z2 && mat.w2 == other.w2 &&
|
||||
mat.x3 == other.x3 && mat.y3 == other.y3 && mat.z3 == other.z3 && mat.w3 == other.w3;
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
||||
@@ -20,6 +20,11 @@ Vec3<T> operator- (const Vec3<T>& vect) {
|
||||
return { -vect.x, -vect.y, -vect.z };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Vec4<T> operator- (const Vec4<T>& vect) {
|
||||
return { -vect.x, -vect.y, -vect.z, -vect.w };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Vec3<T> operator+ (const Vec3<T>& vect, const Vec3<T>& other) {
|
||||
return { vect.x + other.x, vect.y + other.y, vect.z + other.y };
|
||||
@@ -70,10 +75,10 @@ T Dot(const Vec4<T>& vect, const Vec4<T>& other) {
|
||||
template<typename T>
|
||||
Vec4<T> Dot(const Mat4<T>& mat, const Vec4<T>& vect) {
|
||||
return {
|
||||
Dot(*reinterpret_cast<const Vec4<T>*>(&mat), vect),
|
||||
Dot(*reinterpret_cast<const Vec4<T>*>(mat.data() + Mat4<T>::MATRIX_SIZE), vect),
|
||||
Dot(*reinterpret_cast<const Vec4<T>*>(mat.data() + 2 * Mat4<T>::MATRIX_SIZE), vect),
|
||||
Dot(*reinterpret_cast<const Vec4<T>*>(mat.data() + 3 * Mat4<T>::MATRIX_SIZE), vect),
|
||||
mat.x0 * vect.x + mat.x1 * vect.y + mat.x2 * vect.z + mat.x3 * vect.w,
|
||||
mat.y0 * vect.x + mat.y1 * vect.y + mat.y2 * vect.z + mat.y3 * vect.w,
|
||||
mat.z0 * vect.x + mat.z1 * vect.y + mat.z2 * vect.z + mat.z3 * vect.w,
|
||||
mat.w0 * vect.x + mat.w1 * vect.y + mat.w2 * vect.z + mat.w3 * vect.w
|
||||
};
|
||||
}
|
||||
|
||||
@@ -84,7 +89,7 @@ Mat4<T> Dot(const Mat4<T>& mat, const Mat4<T>& other) {
|
||||
for (std::size_t i = 0; i < Mat4<T>::MATRIX_SIZE; i++) {
|
||||
for (std::size_t j = 0; j < Mat4<T>::MATRIX_SIZE; j++) {
|
||||
for (std::size_t k = 0; k < Mat4<T>::MATRIX_SIZE; k++) {
|
||||
result.at(i, j) = mat.at(i, k) * other.at(k, j);
|
||||
result.at(i, j) += mat.at(i, k) * other.at(k, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,10 @@ struct Camera {
|
||||
|
||||
Vec3f CamPos;
|
||||
|
||||
Vec3f m_Front {0, -1, 0};
|
||||
|
||||
float m_Yaw = -3.141592653f / 2.0f;
|
||||
constexpr static float m_Pitch = -3.141592653f / 2.0f + 0.0000001f;
|
||||
float m_Pitch = -3.141592653f / 2.0f - 0.0000001f;
|
||||
};
|
||||
|
||||
class Renderer {
|
||||
|
||||
Reference in New Issue
Block a user