1#include "Game/AreaObj/AreaForm.hpp"
2#include "JSystem/JMath/JMath.hpp"
3#include "Game/Util.hpp"
5AreaFormCube::AreaFormCube(
int a1) {
10 mTranslation.z = 0.0f;
17 mBounding.mMin.x = 0.0f;
18 mBounding.mMin.y = 0.0f;
19 mBounding.mMin.z = 0.0f;
20 mBounding.mMax.x = 0.0f;
21 mBounding.mMax.y = 0.0f;
22 mBounding.mMax.z = 0.0f;
26 MR::getJMapInfoTrans(rIter, &mTranslation);
27 MR::getJMapInfoRotate(rIter, &mRotation);
28 MR::getJMapInfoScale(rIter, &mScale);
32bool AreaFormCube::isInVolume(
const TVec3f &rPos)
const {
37 pos.multTranspose(rPos, transpose);
41 if (transpose.x >= mBounding.mMin.x && transpose.y >= mBounding.mMin.y && transpose.z >= mBounding.mMin.z && transpose.x < mBounding.mMax.x && transpose.y < mBounding.mMax.y && transpose.z < mBounding.mMax.z) {
48void AreaFormCube::calcWorldPos(TVec3f *pPos)
const {
50 _4->mult(mTranslation, *pPos);
54 pPos->set<f32>(mTranslation);
59void AreaFormCube::calcWorldBox(TDirBox3f *pBox)
const {
63 pBox->_0.x = pos.mMtx[0][0];
64 pBox->_C.x = pos.mMtx[0][1];
65 pBox->_18.x = pos.mMtx[0][2];
66 pBox->_24.x = pos.mMtx[0][3];
67 pBox->_0.y = pos.mMtx[1][0];
68 pBox->_C.y = pos.mMtx[1][1];
69 pBox->_18.y = pos.mMtx[1][2];
70 pBox->_24.y = pos.mMtx[1][3];
71 pBox->_0.z = pos.mMtx[2][0];
72 pBox->_C.z = pos.mMtx[2][1];
73 pBox->_18.z = pos.mMtx[2][2];
74 pBox->_24.z = pos.mMtx[2][3];
76 JMathInlineVEC::PSVECSubtract(mBounding.mMax.toCVec(), mBounding.mMin.toCVec(), pBox->_30.toVec());
77 pos.mult(mBounding.mMin, pBox->_24);
80void AreaFormCube::calcLocalPos(TVec3f *pPos,
const TVec3f &a2)
const {
82 calcWorldMtx(&worldMtx);
83 worldMtx.multTranspose(a2, *pPos);
86f32 AreaFormCube::getBaseSize() {
93void AreaFormCube::updateBoxParam() {
94 MR::makeMtxRotate(_48, mRotation.x, mRotation.y, mRotation.z);
96 f32 v3 = (0.5f * (-mScale.x * 1000.0f));
97 f32 v5 = (0.5f * (-mScale.y * 1000.0f));
98 f32 v6 = (0.5f * (-mScale.z * 1000.0f));
100 _48[0][3] = mTranslation.x;
101 _48[1][3] = mTranslation.y;
102 _48[2][3] = mTranslation.z;
104 TVec3f v10(v3, v5, v6);
106 f32 v20 = (0.5f * (mScale.x * 1000.0f));
107 f32 v21 = (0.5f * (mScale.y * 1000.0f));
108 f32 v22 = (0.5f * (mScale.z * 1000.0f));
110 TVec3f v9(v20, v21, v22);
118 f32 v7 = mScale.y * 1000.0f;
129void AreaFormCube::calcWorldMtx(
register TPos3f *pPos)
const {
133 return pPos->concat(*_4, (
const TSMtxf&)*_48);
137 psq_l f0, 0x48(cube), 0, 0
138 psq_l f1, 0x50(cube), 0, 0
139 psq_l f2, 0x58(cube), 0, 0
140 psq_l f3, 0x60(cube), 0, 0
141 psq_l f4, 0x68(cube), 0, 0
142 psq_l f5, 0x70(cube), 0, 0
143 psq_st f0, 0(pPos), 0, 0
144 psq_st f1, 8(pPos), 0, 0
145 psq_st f2, 0x10(pPos), 0, 0
146 psq_st f3, 0x18(pPos), 0, 0
147 psq_st f4, 0x20(pPos), 0, 0
148 psq_st f5, 0x28(pPos), 0, 0
152AreaFormSphere::AreaFormSphere() {
154 mTranslation.x = 0.0f;
155 mTranslation.y = 0.0f;
156 mTranslation.z = 0.0f;
160void AreaFormSphere::calcUpVec(TVec3f *pOut)
const {
162 _4->mult33(mUp, *pOut);
170void AreaFormSphere::calcPos(TVec3f *pOut)
const {
172 _4->mult(mTranslation, *pOut);
175 pOut->set<f32>(mTranslation);
179bool AreaFormSphere::isInVolume(
const TVec3f &rVector)
const {
183 TVec3f thing(rVector);
184 JMathInlineVEC::PSVECSubtract(thing.toCVec(), pos.toCVec(), thing.toVec());
185 return PSVECMag(thing.toCVec()) < _14;
188AreaFormBowl::AreaFormBowl() {
190 mTranslation.x = 0.0f;
191 mTranslation.y = 0.0f;
192 mTranslation.z = 0.0f;
197 MR::getJMapInfoTrans(rIter, &mTranslation);
200 rIter.getValue<f32>(
"scale_x", &scale_x);
205 MR::getJMapInfoRotate(rIter, &rotation);
209bool AreaFormBowl::isInVolume(
const TVec3f &rPos)
const {
211 JMathInlineVEC::PSVECSubtract(pos.toCVec(), mTranslation.toCVec(), pos.toVec());
213 if (PSVECMag((
const Vec*)&pos) > _20) {
217 TVec3f other_pos(rPos);
218 PSVECSubtract((
const Vec*)&other_pos, (
const Vec*)&mTranslation, (Vec*)&other_pos);
219 return other_pos.dot(mUp) < 0.0f;
222void AreaFormBowl::calcUpVec(
const TVec3f &rPos) {
223 TVec3f up(0.0f, 1.0f, 0.0f);
226 MR::makeMtxTR(mtx, 0.0f, 0.0f, 0.0f, rPos.x, rPos.y, rPos.z);
227 PSMTXMultVec(mtx, (
const Vec*)&up, (Vec*)&up);
231AreaFormCylinder::AreaFormCylinder() {
233 mTranslation.x = 0.0f;
234 mTranslation.y = 0.0f;
235 mTranslation.z = 0.0f;
243void AreaFormCylinder::calcPos(TVec3f *pPos)
const {
245 _4->mult(mTranslation, *pPos);
249 pPos->set<f32>(mTranslation);
252void AreaFormCylinder::calcCenterPos(TVec3f *pCenterPos)
const {
257 pCenterPos->add((upVec * _24) * 0.5f);
260void AreaFormCylinder::calcUpVec(TVec3f *pUpVec)
const {
262 _4->mult33(mRotation, *pUpVec);
263 MR::normalize(pUpVec);
266 pUpVec->set<f32>(mRotation);
270bool AreaFormCylinder::isInVolume(
const TVec3f &rVec)
const {
277 TVec3f stack_8(rVec);
278 JMathInlineVEC::PSVECSubtract((
const Vec*)&stack_8, (
const Vec*)&pos, (Vec*)&stack_8);
279 f32 v6 = MR::vecKillElement(stack_8, up, &stack_8);
280 f32 v7 = PSVECMag((
const Vec*)&stack_8);
284 if (MR::isInRange(v6, 0.0f, _24) && (v7 < _20)) {
294void AreaFormCylinder::calcDir(
const TVec3f &a1) {
299 MtxPtr mtx_x = MR::tmpMtxRotXDeg(a1.x);
300 PSMTXMultVec(mtx_x, (
const Vec*)&mRotation, (Vec*)&mRotation);
301 MtxPtr mtx_y = MR::tmpMtxRotYDeg(a1.y);
302 PSMTXMultVec(mtx_y, (
const Vec*)&mRotation, (Vec*)&mRotation);
303 MtxPtr mtx_z = MR::tmpMtxRotYDeg(a1.z);
304 PSMTXMultVec(mtx_z, (
const Vec*)&mRotation, (Vec*)&mRotation);
305 PSVECMag((
const Vec*)&mRotation);
306 PSVECNormalize((
const Vec*)&mRotation, (Vec*)&mRotation);
310 MR::getJMapInfoTrans(rIter, &mTranslation);
313 rIter.getValue<f32>(
"scale_x", &scale_x);
319 MR::getJMapInfoRotate(rIter, &rotation);
321 TVec3f butts(0.0f, 1.0f, 0.0f);
324 MR::makeMtxTR(mtx, 0.0f, 0.0f, 0.0f, rotation.x, rotation.y, rotation.z);
325 PSMTXMultVec(mtx, (
const Vec*)&butts, (Vec*)&butts);
330 MR::getJMapInfoTrans(rIter, &mTranslation);
333 MR::getJMapInfoRotate(rIter, &rotate);
337 rIter.getValue<f32>(
"scale_x", &temp);
342 rIter.getValue<f32>(
"scale_y", &temp);