SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
IKJointCtrl.cpp
1#include "Game/LiveActor/IKJointCtrl.hpp"
2#include "Game/LiveActor/LiveActor.hpp"
3#include "Game/Util.hpp"
4
5#include <algorithm>
6
7void IKJointCtrl::setEndPosition(const TVec3f &rPos, f32 a2) {
8 TVec3f joint_pos;
9 MR::copyJointPos(mActor, _B4, &joint_pos);
10 MR::vecBlend(joint_pos, rPos, &joint_pos, a2);
11 mJoint->update(MR::getJointMtx(mActor, _B0), MR::getJointMtx(mActor, _B2), MR::getJointMtx(mActor, _B4), joint_pos);
12 _A8 = a2;
13}
14
15void IKJointCtrl::setEndDirection(const TVec3f &rDirection, f32 a2) {
16 s32 val = MR::vecBlendSphere(_78, rDirection, &_78, a2);
17
18 if (!val) {
19 MR::turnRandomVector(&_78, _78, 0.0099999998f);
20 }
21
22 _AC = a2;
23}
24
25void IKJointCtrl::endCtrl() {
26 _A8 = 0.0f;
27 _AC = 0.0f;
28}
29
30void IKJointCtrl::setCallBackFunction() {
31 if (_B6) {
32 if (_A8 > 0.0f) {
33 mRootCtrl->registerCallBack();
34 mMiddleCtrl->registerCallBack();
35 }
36 }
37
38 if (_B6) {
39 if (_AC > 0.0f) {
40 mEndCtrl->registerCallBack();
41 }
42 }
43}
44
45bool IKJointCtrl::updateRootJointCallBack(TPos3f *pPos, const JointControllerInfo &rInfo) {
46 pPos->concat(mJoint->_30, _4);
47 return true;
48}
49
50bool IKJointCtrl::updateMiddleJointCallBack(TPos3f *pPos, const JointControllerInfo &rInfo) {
51 pPos->concat(mJoint->_60, _34);
52 return true;
53}
54IKJointCtrlHolder::IKJointCtrlHolder(LiveActor *pActor, u32 count) {
55 mControls = 0;
56 mNumControls = 0;
57 _8 = 0;
58 mActor = pActor;
59 _10 = 1;
60 mControls = new IKJointCtrl*[count];
61 mNumControls = count;
62}
63
64void IKJointCtrlHolder::addCtrl(const IKJointCtrlParam &rParam) {
65 if (mNumControls > _8) {
66 IKJointCtrl* ctrl = new IKJointCtrl(mActor);
67 ctrl->init(rParam);
68 u32 cnt = _8;
69 _8 = cnt + 1;
70 mControls[cnt] = ctrl;
71 }
72}
73
74void IKJointCtrlHolder::setEndPosition(const char *pName, const TVec3f &rPos, f32 a3) {
75 findIKJointCtrl(pName)->setEndPosition(rPos, a3);
76}
77
78void IKJointCtrlHolder::setEndDirection(const char *pName, const TVec3f &rDirection, f32 a3) {
79 findIKJointCtrl(pName)->setEndDirection(rDirection, a3);
80}
81
82#ifdef NON_MATCHING
83// for_each inlines
84void IKJointCtrlHolder::endUpdate() {
85 for_each(mControls, &mControls[mNumControls], mem_fun(&IKJointCtrl::endCtrl));
86 _10 = 1;
87}
88#endif
89
90IKJointCtrl* IKJointCtrlHolder::findIKJointCtrl(const char *pName) {
91 for (u32 i = 0; i < mNumControls; i++) {
92 const char* ctrlName = mControls[i]->mName;
93
94 if (MR::isEqualString(pName, ctrlName)) {
95 return mControls[i];
96 }
97 }
98
99 return 0;
100}
101
102void IKJointCtrl::disableCallBack() {
103 _B6 = 0;
104}
105
106void IKJointCtrl::enableCallBack() {
107 _B6 = 1;
108}
The basis of a drawable actor that can contain states (see: Nerve)
Definition LiveActor.hpp:24