A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectCollisionSphere.cc
1#include "ObjectCollisionSphere.hh"
2
3namespace Field {
4
6ObjectCollisionSphere::ObjectCollisionSphere(f32 radius, const EGG::Vector3f &center)
7 : m_radius(radius), m_pos(center), m_scaledRadius(radius), m_scaledPos(center),
8 m_worldPos(center) {}
9
11ObjectCollisionSphere::~ObjectCollisionSphere() = default;
12
14void ObjectCollisionSphere::transform(const EGG::Matrix34f &mat, const EGG::Vector3f &scale) {
15 if (scale.x != 1.0f) {
16 m_scaledPos = m_pos * scale.x;
17 m_scaledRadius = m_radius * scale.x;
18 }
19
20 m_worldPos = mat.multVector(m_scaledPos);
21}
22
24void ObjectCollisionSphere::transform(const EGG::Matrix34f &mat, const EGG::Vector3f &scale,
25 const EGG::Vector3f &speed) {
26 m_translation = speed;
27 ObjectCollisionSphere::transform(mat, scale);
28 m_center = m_worldPos - speed;
29}
30
32const EGG::Vector3f &ObjectCollisionSphere::getSupport(const EGG::Vector3f &v) const {
33 // if (!m_hasColDir)
34 // return m_worldPos;
35
36 return m_worldPos.dot(v) > m_center.dot(v) ? m_worldPos : m_center;
37}
38
39} // namespace Field
A 3 x 4 matrix.
Definition Matrix.hh:8
Vector3f multVector(const Vector3f &vec) const
Multiplies a vector by a matrix.
Definition Matrix.cc:212
Pertains to collision.
A 3D float vector.
Definition Vector.hh:88
f32 dot(const Vector3f &rhs) const
The dot product between two vectors.
Definition Vector.hh:187