1#include "ObjectTuribashi.hh"
3#include "game/field/CollisionDirector.hh"
5#include "game/system/RaceManager.hh"
13ObjectTuribashi::~ObjectTuribashi() =
default;
17 KCLTypeMask flags, CollisionInfoPartial *pInfo, KCLTypeMask *pFlagsOut) {
18 return checkSpherePartialImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
23 KCLTypeMask flags, CollisionInfoPartial *pInfo, KCLTypeMask *pFlagsOut) {
24 return checkSpherePartialPushImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
29 KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut) {
30 return checkSphereFullImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
35 KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut) {
36 return checkSphereFullPushImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
40bool ObjectTuribashi::checkSpherePartial(f32 radius,
const EGG::Vector3f &v0,
41 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfoPartial *pInfo,
42 KCLTypeMask *pFlagsOut, u32 timeOffset) {
43 return checkSpherePartialImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
47bool ObjectTuribashi::checkSpherePartialPush(f32 radius,
const EGG::Vector3f &v0,
48 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfoPartial *pInfo,
49 KCLTypeMask *pFlagsOut, u32 timeOffset) {
50 return checkSpherePartialPushImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
55 KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut, u32 timeOffset) {
56 return checkSphereFullImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
60bool ObjectTuribashi::checkSphereFullPush(f32 radius,
const EGG::Vector3f &v0,
61 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut,
63 return checkSphereFullPushImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
68 KCLTypeMask flags, CollisionInfoPartial *pInfo, KCLTypeMask *pFlagsOut) {
69 return checkSpherePartialImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
74 KCLTypeMask flags, CollisionInfoPartial *pInfo, KCLTypeMask *pFlagsOut) {
75 return checkSpherePartialPushImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
80 KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut) {
81 return checkSphereFullImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
86 KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut) {
87 return checkSphereFullPushImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
91bool ObjectTuribashi::checkSphereCachedPartial(f32 radius,
const EGG::Vector3f &v0,
92 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfoPartial *pInfo,
93 KCLTypeMask *pFlagsOut, u32 timeOffset) {
94 return checkSpherePartialImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
98bool ObjectTuribashi::checkSphereCachedPartialPush(f32 radius,
const EGG::Vector3f &v0,
99 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfoPartial *pInfo,
100 KCLTypeMask *pFlagsOut, u32 timeOffset) {
101 return checkSpherePartialPushImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
105bool ObjectTuribashi::checkSphereCachedFull(f32 radius,
const EGG::Vector3f &v0,
106 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut,
108 return checkSphereFullImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
112bool ObjectTuribashi::checkSphereCachedFullPush(f32 radius,
const EGG::Vector3f &v0,
113 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut,
115 return checkSphereFullPushImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
119bool ObjectTuribashi::checkSpherePartialImpl(f32 radius,
const EGG::Vector3f &v0,
120 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfoPartial *pInfo,
121 KCLTypeMask *pFlagsOut, u32 timeOffset) {
122 return checkSphereImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset,
false);
126bool ObjectTuribashi::checkSpherePartialPushImpl(f32 radius,
const EGG::Vector3f &v0,
127 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfoPartial *pInfo,
128 KCLTypeMask *pFlagsOut, u32 timeOffset) {
129 return checkSphereImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset,
true);
133bool ObjectTuribashi::checkSphereFullImpl(f32 radius,
const EGG::Vector3f &v0,
134 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut,
136 return checkSphereImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset,
false);
140bool ObjectTuribashi::checkSphereFullPushImpl(f32 radius,
const EGG::Vector3f &v0,
141 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut,
143 return checkSphereImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset,
true);
154 requires std::is_same_v<T, CollisionInfo> || std::is_same_v<T, CollisionInfoPartial>
156 const EGG::Vector3f & , KCLTypeMask flags, T *pInfo, KCLTypeMask *pFlagsOut,
157 u32 timeOffset,
bool push) {
158 constexpr u16 PERIOD = 160;
159 constexpr f32 HEIGHT = 2000.0f;
163 if ((flags & 1) == 0) {
169 if (EGG::Mathf::abs(deltaPos.z) > HALF_LENGTH || EGG::Mathf::abs(deltaPos.x) > HALF_WIDTH) {
173 const auto *raceMgr = System::RaceManager::Instance();
176 if (raceMgr->isStageReached(System::RaceManager::Stage::Race)) {
177 f32 phase = -deltaPos.z / HALF_LENGTH;
178 f32 lower = phase - 1.0f;
179 f32 higher = 1.0f + phase;
180 u32 t = (timeOffset + raceMgr->timer()) % PERIOD;
181 f32 sin = EGG::Mathf::SinFIdx(RAD2FIDX *
182 (F_PI *
static_cast<f32
>(t * 2) /
static_cast<f32
>(PERIOD) + 0.7f * phase));
183 angle = 0.12f * (higher * (higher * (lower * (lower * sin))));
186 auto [sinfidx, cosfidx] = EGG::Mathf::SinCosFIdx(RAD2FIDX * angle);
188 f32 phase = deltaPos.z / HALF_LENGTH;
189 f32 cos = EGG::Mathf::CosFIdx(RAD2FIDX * (0.5f * (F_PI * (37.0f * phase))));
190 f32 base = HEIGHT * -0.5f;
192 (cosfidx * (-deltaPos.y - base) +
193 (-deltaPos.x * sinfidx +
194 (radius + (EGG::Mathf::abs(30.0f * cos) + 25.0f) +
195 0.156f * deltaPos.z)));
197 if (0.0f >= dist || dist >= 600.0f) {
207 pInfo->bbox.min = pInfo->bbox.min.minimize(scaledY);
208 pInfo->bbox.max = pInfo->bbox.max.maximize(scaledY);
210 if constexpr (std::is_same_v<T, CollisionInfo>) {
211 pInfo->updateFloor(dist,
EGG::Vector3f(sinfidx, cosfidx, 0.0f));
217 auto *colDirector = CollisionDirector::Instance();
219 colDirector->setCurrentCollisionVariant(4);
220 colDirector->setCurrentCollisionTrickable(
false);
@ COL_TYPE_ROAD
Default road.