1#include "ObjectAurora.hh"
3#include "game/field/CollisionDirector.hh"
5#include "game/system/RaceManager.hh"
13ObjectAurora::~ObjectAurora() =
default;
16void ObjectAurora::init() {}
19u32 ObjectAurora::loadFlags()
const {
24void ObjectAurora::createCollision() {}
27void ObjectAurora::calcCollisionTransform() {}
30f32 ObjectAurora::getCollisionRadius()
const {
31 return COLLISION_SIZE.z + 100.0f;
36 KCLTypeMask flags, CollisionInfoPartial *pInfo, KCLTypeMask *pFlagsOut) {
37 return checkSpherePartialImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
42 KCLTypeMask flags, CollisionInfoPartial *pInfo, KCLTypeMask *pFlagsOut) {
43 return checkSpherePartialPushImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
48 KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut) {
49 return checkSphereFullImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
54 KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut) {
55 return checkSphereFullPushImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
60 KCLTypeMask flags, CollisionInfoPartial *pInfo, KCLTypeMask *pFlagsOut, u32 timeOffset) {
61 return checkSpherePartialImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
65bool ObjectAurora::checkSpherePartialPush(f32 radius,
const EGG::Vector3f &v0,
66 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfoPartial *pInfo,
67 KCLTypeMask *pFlagsOut, u32 timeOffset) {
68 return checkSpherePartialPushImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
73 KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut, u32 timeOffset) {
74 return checkSphereFullImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
79 KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut, u32 timeOffset) {
80 return checkSphereFullPushImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
85 KCLTypeMask flags, CollisionInfoPartial *pInfo, KCLTypeMask *pFlagsOut) {
86 return checkSpherePartialImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
91 KCLTypeMask flags, CollisionInfoPartial *pInfo, KCLTypeMask *pFlagsOut) {
92 return checkSpherePartialPushImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
97 KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut) {
98 return checkSphereFullImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
103 KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut) {
104 return checkSphereFullPushImpl(0.0f, v0, v1, flags, pInfo, pFlagsOut, 0);
108bool ObjectAurora::checkSphereCachedPartial(f32 radius,
const EGG::Vector3f &v0,
109 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfoPartial *pInfo,
110 KCLTypeMask *pFlagsOut, u32 timeOffset) {
111 return checkSpherePartialImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
115bool ObjectAurora::checkSphereCachedPartialPush(f32 radius,
const EGG::Vector3f &v0,
116 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfoPartial *pInfo,
117 KCLTypeMask *pFlagsOut, u32 timeOffset) {
118 return checkSpherePartialPushImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
122bool ObjectAurora::checkSphereCachedFull(f32 radius,
const EGG::Vector3f &v0,
123 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut,
125 return checkSphereFullImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
129bool ObjectAurora::checkSphereCachedFullPush(f32 radius,
const EGG::Vector3f &v0,
130 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut,
132 return checkSphereFullPushImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset);
136bool ObjectAurora::checkSpherePartialImpl(f32 radius,
const EGG::Vector3f &v0,
137 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfoPartial *pInfo,
138 KCLTypeMask *pFlagsOut, u32 timeOffset) {
139 return checkSpherePartialImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset,
false);
143bool ObjectAurora::checkSpherePartialPushImpl(f32 radius,
const EGG::Vector3f &v0,
144 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfoPartial *pInfo,
145 KCLTypeMask *pFlagsOut, u32 timeOffset) {
146 return checkSpherePartialImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset,
true);
151 KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut, u32 timeOffset) {
152 return checkSphereFullImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset,
false);
156bool ObjectAurora::checkSphereFullPushImpl(f32 radius,
const EGG::Vector3f &v0,
157 const EGG::Vector3f &v1, KCLTypeMask flags, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut,
159 return checkSphereFullImpl(radius, v0, v1, flags, pInfo, pFlagsOut, timeOffset,
true);
165bool ObjectAurora::checkSpherePartialImpl(f32 radius,
const EGG::Vector3f &v0,
167 KCLTypeMask *pFlagsOut, u32 timeOffset,
bool push) {
170 if (vel.z < 0.0f || vel.z > COLLISION_SIZE.z || EGG::Mathf::abs(vel.x) > COLLISION_SIZE.x) {
178 u32 t = timeOffset + System::RaceManager::Instance()->timer();
183 if (!calcCollision(radius, vel, t, bbox, fnrm, dist)) {
188 pInfo->bbox.min = pInfo->bbox.min.
minimize(bbox);
189 pInfo->bbox.max = pInfo->bbox.max.
maximize(bbox);
193 auto *colDirector = CollisionDirector::Instance();
198 colDirector->setCurrentCollisionVariant(7);
199 colDirector->setCurrentCollisionTrickable(
true);
204 if (vel.z > COLLISION_SIZE.z - 600.0f * 4.0f) {
222 KCLTypeMask *pFlagsOut, u32 timeOffset,
bool push) {
225 if (vel.z < 0.0f || vel.z > COLLISION_SIZE.z || EGG::Mathf::abs(vel.x) > COLLISION_SIZE.x) {
233 u32 t = timeOffset + System::RaceManager::Instance()->timer();
238 if (!calcCollision(radius, vel, t, bbox, fnrm, dist)) {
243 pInfo->bbox.min = pInfo->bbox.min.
minimize(bbox);
244 pInfo->bbox.max = pInfo->bbox.max.
maximize(bbox);
246 pInfo->updateFloor(dist, fnrm);
250 auto *colDirector = CollisionDirector::Instance();
255 colDirector->setCurrentCollisionVariant(7);
256 colDirector->setCurrentCollisionTrickable(
true);
261 if (vel.z > COLLISION_SIZE.z - 600.0f * 4.0f) {
282 constexpr f32 INITIAL_FREQUENCY = 1.0f;
283 constexpr f32 MAX_FREQUENCY = 4.0f;
284 constexpr f32 PHASE_SHIFT_SECONDS = 30.0f;
285 constexpr f32 COLLISION_DISTANCE_THRESHOLD = 600.0f;
286 constexpr f32 UPWARP_THRESHOLD = 300.0f;
287 constexpr f32 UPWARP_DIST_SCALAR = 0.2f;
289 f32 minsNormalized = (
static_cast<f32
>(time) / 60.0f - PHASE_SHIFT_SECONDS) / 60.0f;
290 f32 frequency = std::min(INITIAL_FREQUENCY + minsNormalized * minsNormalized, MAX_FREQUENCY);
291 f32 velPeriod = (F_PI * (2.0f * vel.z)) / COLLISION_SIZE.z;
293 f32 result = EGG::Mathf::SinFIdx(
294 RAD2FIDX * (velPeriod * frequency + (F_PI *
static_cast<f32
>(time) / 50.0f)));
295 result = radius - (vel.y - velPeriod * 80.0f * result);
298 if (result <= 0.0f || result >= COLLISION_DISTANCE_THRESHOLD) {
303 if (result > UPWARP_THRESHOLD) {
304 result *= UPWARP_DIST_SCALAR;
307 fnrm = EGG::Vector3f::ey;
@ COL_TYPE_BOOST_RAMP
Trickable. Variant affects boost duration.
@ COL_TYPE_ROAD2
COL_TYPE_ROAD but with more variants.
@ COL_TYPE_ROTATING_ROAD
Chain Chomp Roulette.
#define KCL_TYPE_FLOOR
0x20E80FFF - Any KCL that the player or items can drive/land on.
Vector3f maximize(const Vector3f &rhs) const
Returns a vector whose elements are the max of the elements of both vectors.
Vector3f minimize(const Vector3f &rhs) const
Returns a vector whose elements are the min of the elements of both vectors.