1#include "ObjectPropeller.hh"
3#include "game/field/ObjectDirector.hh"
9 : ObjectCollidable(params), m_angle(0.0f) {
10 m_blades.fill(
nullptr);
14ObjectPropeller::~ObjectPropeller() {
15 for (
auto *&blade : m_blades) {
21void ObjectPropeller::init() {
23 m_angVel =
static_cast<f32
>(
static_cast<s16
>(m_mapObj->setting(0)));
24 if (m_mapObj->setting(1) == 1) {
28 m_rotMat.makeR(m_rot);
29 m_rotMat.setBase(3, m_pos);
30 m_axis = m_rotMat.base(2);
34void ObjectPropeller::calc() {
35 m_angle += m_angVel * 0.5f;
36 m_curRot = EGG::Matrix34f::ident;
38 m_transform = m_curRot.multiplyTo(m_rotMat);
39 m_flags.setBit(eFlags::Matrix);
40 m_transform.setBase(3, m_pos);
44void ObjectPropeller::createCollision() {
45 ObjectCollidable::createCollision();
47 const auto &colCenter = collisionCenter();
48 const auto &flowTable = ObjectDirector::Instance()->flowTable();
49 const auto ¶ms = flowTable.set(flowTable.slot(
id()))->params.cylinder;
50 f32 radius =
static_cast<f32
>(parse<s16>(params.radius));
51 f32 height =
static_cast<f32
>(parse<s16>(params.height));
53 for (
auto *&blade : m_blades) {
54 blade =
new ObjectCollisionCylinder(radius, height, colCenter);
59void ObjectPropeller::calcCollisionTransform() {
60 constexpr f32 BLADE_LENGTH = 250.0f;
62 for (u32 i = 0; i < m_blades.size(); ++i) {
64 mat.
setBase(3, EGG::Vector3f::zero);
73 auto *&blade = m_blades[i];
74 blade->transform(mat, m_scale);
79f32 ObjectPropeller::getCollisionRadius()
const {
80 const auto &flowTable = ObjectDirector::Instance()->flowTable();
81 const auto ¶ms = flowTable.set(flowTable.slot(
id()))->params.box;
82 f32 z = m_scale.z *
static_cast<f32
>(parse<s16>(params.z));
83 f32 x = m_scale.x *
static_cast<f32
>(parse<s16>(params.x));
85 return 5.0f * std::max(z, x);
94 bool hasCol = lhs->check(*m_blades[0], dist0);
95 hasCol = hasCol || lhs->check(*m_blades[1], dist1);
96 hasCol = hasCol || lhs->check(*m_blades[2], dist2);
98 dist = dist0 + dist1 + dist2;
Matrix34f multiplyTo(const Matrix34f &rhs) const
Multiplies two matrices.
void setBase(size_t col, const Vector3f &base)
Sets one column of a matrix.
Vector3f base(size_t col) const
Get a particular column from a matrix.
void setAxisRotation(f32 angle, const Vector3f &axis)
Rotates the matrix about an axis.
The base class that all objects' collision inherits from.
f32 normalise()
Normalizes the vector and returns the original length.