Loading [MathJax]/jax/output/HTML-CSS/config.js
A reimplementation of Mario Kart Wii's physics engine in C++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages Concepts
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 const EGG::Vector3f &speed) {
16 m_translation = speed;
17
18 if (scale.x != 1.0f) {
19 m_scaledPos = m_pos * scale.x;
20 m_scaledRadius = m_radius * scale.x;
21 }
22
23 m_worldPos = mat.multVector(m_scaledPos);
24 m_center = m_worldPos - speed;
25}
26
28const EGG::Vector3f &ObjectCollisionSphere::getSupport(const EGG::Vector3f &v) const {
29 // if (!m_hasColDir)
30 // return m_worldPos;
31
32 return m_worldPos.dot(v) > m_center.dot(v) ? m_worldPos : m_center;
33}
34
35} // 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:220
Pertains to collision.
A 3D float vector.
Definition Vector.hh:83
f32 dot(const Vector3f &rhs) const
The dot product between two vectors.
Definition Vector.hh:182