SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
ParabolicPath.cpp
1#include "Game/Util/ParabolicPath.hpp"
2#include "Game/Util.hpp"
3
4ParabolicPath::ParabolicPath() : mPosition(0, 0, 0), mAxisY(0, 1, 0), mAxisZ(0, 0, 1) {
5 _24 = 0.0f;
6 _28 = 0.0f;
7 _2C = 0.0f;
8}
9
10void ParabolicPath::initFromUpVectorAddHeight(const TVec3f &a1, const TVec3f &a2, const TVec3f &a3, f32 a4) {
11 f32 dot = a3.dot(a2 - a1);
12
13 if (dot < 0.0f) {
14 dot = 0.0f;
15 }
16
17 initFromUpVector(a1, a2, a3, a4 + dot);
18}
19
20/*
21void ParabolicPath::calcPosition(TVec3f *pOutPosition, f32 a2) const {
22 f32 thing = _24 * a2;
23 f32 v5 = (a2 * (_28 + (thing)));
24 TVec3f stack_8 = mAxisZ * (_2C * a2);
25 TVec3f stack_14 = mAxisY * v5;
26 TVec3f stack_20 = mPosition + stack_14;
27 TVec3f stack_2C = stack_20 + stack_8;
28 pOutPosition->set(stack_2C);
29}
30*/
31
32void ParabolicPath::calcDirection(TVec3f *pOutDirection, f32 a2, f32 a3) const {
33 f32 f0;
34 f32 f31;
35
36 if (a2 < a3) {
37 f31 = a3;
38 f0 = 0.0f;
39 }
40 else {
41 f0 = 1.0f;
42 f31 = 1.0f - a3;
43
44 if (a2 > f31) {
45 f0 = a2;
46 f31 = a2 + a3;
47 }
48 }
49
50 TVec3f stack_20;
51 calcPosition(&stack_20, f0);
52 TVec3f stack_14;
53 calcPosition(&stack_14, f31);
54 pOutDirection->set(stack_14 - stack_20);
55 MR::normalizeOrZero(pOutDirection);
56}
57
58f32 ParabolicPath::getTotalLength(s32 a1) const {
59 return getLength(0.0f, 1.0f, a1);
60}
61
62f32 ParabolicPath::calcPathSpeedFromAverageSpeed(f32 speed) const {
63 return speed / getLength(0.0f, 1.0f, 10);
64}