Emitter: Use std::array where applicable

Makes the data more strongly-typed and prevents implicit array->pointer
decay
This commit is contained in:
Lioncash
2019-09-07 20:19:47 -04:00
parent 0be0ca2911
commit 29e7d8bc1e
9 changed files with 63 additions and 58 deletions

View File

@@ -2,10 +2,12 @@
namespace amuse {
static void Cross(Vector3f& out, const Vector3f& a, const Vector3f& b) {
out[0] = a[1] * b[2] - a[2] * b[1];
out[1] = a[2] * b[0] - a[0] * b[2];
out[2] = a[0] * b[1] - a[1] * b[0];
static constexpr Vector3f Cross(const Vector3f& a, const Vector3f& b) {
return {
a[1] * b[2] - a[2] * b[1],
a[2] * b[0] - a[0] * b[2],
a[0] * b[1] - a[1] * b[0],
};
}
void Listener::setVectors(const float* pos, const float* dir, const float* heading, const float* up) {
@@ -16,11 +18,9 @@ void Listener::setVectors(const float* pos, const float* dir, const float* headi
m_up[i] = up[i];
}
Normalize(m_heading);
Normalize(m_up);
Cross(m_right, m_heading, m_up);
Normalize(m_right);
m_heading = Normalize(m_heading);
m_up = Normalize(m_up);
m_right = Normalize(Cross(m_heading, m_up));
m_dirty = true;
}