1#include "Game/MapObj/ClipAreaShape.hpp"
2#include <Game/Util.hpp>
4ClipAreaShape::ClipAreaShape(
const char *pName) : mModelData(nullptr) {
5 mModelData = MR::getJ3DModelData(pName);
8bool ClipAreaShape::isInArea(
const TVec3f &a1, f32 a2,
const TPos3f &a3,
const TVec3f &a4)
const {
9 if (MR::isNearZero(a4.x, 0.001f) || (MR::isNearZero(a4.y, 0.001f) || MR::isNearZero(a4.z, 0.001f))) {
19 srcVec.x = (srcVec.x / a4.x);
20 srcVec.y = (srcVec.y / a4.y);
21 srcVec.z = (srcVec.z / a4.z);
22 return isInArea(srcVec);
25void ClipAreaShape::calcVolumeMatrix(TPos3f *pVolMtx,
const TPos3f &rSrcMtx,
const TVec3f &a3)
const {
26 pVolMtx->set(rSrcMtx);
27 MR::preScaleMtx(pVolMtx->toMtxPtr(), a3);
30void ClipAreaShape::drawVolumeShape(
const TPos3f &rMtx,
const TVec3f &rPos)
const {
33 calcVolumeMatrix(&volMtx, rMtx, rPos);
34 PSMTXConcat(MR::getCameraViewMtx(), *volMtx.toCMtx(), *volMtx.toMtx());
35 GXLoadPosMtxImm(volMtx.toMtxPtr(), 0);
36 MR::drawSimpleModel(mModelData);
39bool ClipAreaShapeSphere::isInArea(
register const TVec3f &rVec)
const {
43 psq_l f1, 0(rVec), 0, 0
44 lfs f0, sphere->mRadius
47 ps_madd f2, f2, f2, f1
48 ps_sum0 f2, f2, f1, f1
56ClipAreaShapeCone::ClipAreaShapeCone(s32 a1) :
ClipAreaShape(
"ClipVolumeSphere") {
62bool ClipAreaShapeCone::isInArea(
const TVec3f &rVec)
const {
63 f32 v3 = (rVec.y / _C);
65 if (!MR::isInRange(v3, 0.0f, 1.0f)) {
73 f32 v23 = ((rVec.x * rVec.x) + (rVec.z * rVec.z));
74 f32 v24 = (v3 * _8) * (v3 * _8);
78bool ClipAreaShape::isInArea(
const TVec3f &)
const {