A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectCollisionCylinder.cc
1#include "ObjectCollisionCylinder.hh"
2
3namespace Field {
4
6ObjectCollisionCylinder::ObjectCollisionCylinder(f32 radius, f32 height,
7 const EGG::Vector3f &center)
8 : m_radius(radius), m_height(height), m_pos(center) {
9 m_worldRadius = radius;
10 m_worldHeight = height;
11 m_worldPos = center;
12
13 m_center = center;
14 m_top = center + EGG::Vector3f::ey * height;
15 m_bottom = center - EGG::Vector3f::ey * height;
16}
17
19ObjectCollisionCylinder::~ObjectCollisionCylinder() = default;
20
22void ObjectCollisionCylinder::transform(const EGG::Matrix34f &mat, const EGG::Vector3f &scale,
23 const EGG::Vector3f &speed) {
24 m_translation = speed;
25 m_worldPos = m_pos * scale.x;
26 m_worldHeight = m_height * scale.y;
27 m_worldRadius = m_radius * scale.x;
28
29 m_center = mat.ps_multVector(m_worldPos);
30 m_top = mat.ps_multVector(m_worldPos + EGG::Vector3f::ey * m_worldHeight);
31 m_bottom = mat.ps_multVector(m_worldPos - EGG::Vector3f::ey * m_worldHeight);
32}
33
34} // namespace Field
A 3 x 4 matrix.
Definition Matrix.hh:8
Vector3f ps_multVector(const Vector3f &vec) const
Paired-singles impl. of multVector.
Definition Matrix.cc:232
Pertains to collision.
A 3D float vector.
Definition Vector.hh:83