1#include "ObjectHeyhoShip.hh"
7 : ObjectProjectileLauncher(params),
8 m_yAmplitude(static_cast<f32>(static_cast<s16>(params.setting(1)))), m_frame(0) {
9 registerManagedObject();
13ObjectHeyhoShip::~ObjectHeyhoShip() =
default;
16void ObjectHeyhoShip::init() {
17 m_railInterpolator->init(0.0f, 0);
18 m_railInterpolator->setPerPointVelocities(
true);
19 m_pos = m_railInterpolator->curPos();
20 m_flags.setBit(eFlags::Position);
22 const EGG::Vector3f &railTan = m_railInterpolator->curTangentDir();
25 tangent = RotateXZByYaw(F_PI / 2.0f, tangent);
27 if (EGG::Mathf::abs(tangent.y) > 0.1f) {
31 if (tangent.
squaredLength() > std::numeric_limits<f32>::epsilon()) {
34 tangent = EGG::Vector3f::ey;
37 m_framesSinceLastLaunch = 1000;
38 setMatrixTangentTo(EGG::Vector3f::ey, tangent);
42void ObjectHeyhoShip::calc() {
43 if (m_railInterpolator->calc() == RailInterpolator::Status::SegmentEnd) {
44 m_framesSinceLastLaunch = 0;
46 ++m_framesSinceLastLaunch;
53void ObjectHeyhoShip::calcPos() {
54 constexpr f32 PERIOD = 100.0f;
56 m_pos = m_railInterpolator->curPos();
57 m_flags.setBit(eFlags::Position);
59 f32 fidx = DEG2FIDX * (360.0f *
static_cast<f32
>(++m_frame) / PERIOD);
60 m_pos.y = m_yAmplitude * EGG::Mathf::SinFIdx(fidx) + m_pos.y;
f32 squaredLength() const
The dot product between the vector and itself.