Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectDrivable infrastructure, rDKM bridge, MT net, RR wavy road, BCWii Twisted Way #251

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

JohnP55
Copy link
Contributor

@JohnP55 JohnP55 commented Feb 11, 2025

No description provided.

#include "ObjectTwistedWay.hh"

#include "game/field/CollisionDirector.hh"
#include "game/system/RaceManager.hh"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "game/system/RaceManager.hh"
#include "game/system/RaceManager.hh"

const EGG::Vector3f &relativePos, CollisionInfo *pInfo, KCLTypeMask *pFlagsOut,
bool full, bool push);

f32 m_ac = 1000.0f;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my interpretation

Suggested change
f32 m_ac = 1000.0f;
u32 m_preRaceTimer = 1000;

/// @addr{0x80813cfc}
void ObjectTwistedWay::calc() {
if (!System::RaceManager::Instance()->isStageReached(System::RaceManager::Stage::Race)) {
m_ac++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
m_ac++;
++m_preRaceTimer;

Prefer prefix incrementor for consistency with other files.

/// @addr{0x80813c40}
void ObjectTwistedWay::init() {}

/// @addr{0x80813cfc}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// @addr{0x80813cfc}
/// @addr{0x80813CFC}

/// @addr{0x80814918}
ObjectTwistedWay::~ObjectTwistedWay() = default;

/// @addr{0x80813c40}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// @addr{0x80813c40}
/// @addr{0x80813C40}

}

return true;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal preference, but you don't need an else indentation if you have a guaranteed return in the if-statement above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely missed that, mb

Comment on lines 305 to 309
if (!System::RaceManager::Instance()->isStageReached(System::RaceManager::Stage::Race)) {
frameCount = m_ac;
} else {
frameCount = System::RaceManager::Instance()->timer();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe overkill with the ternary. More importantly, we should only get the pointer here once. Writing the boolean out to a variable avoids recomputing it again in your next if-statement

Suggested change
if (!System::RaceManager::Instance()->isStageReached(System::RaceManager::Stage::Race)) {
frameCount = m_ac;
} else {
frameCount = System::RaceManager::Instance()->timer();
}
auto *raceMgr = System::RaceManager::Instance();
bool raceStarted = raceMgr->isStageReached(System::RaceManager::Stage::Race);
m_frameCount = raceStarted ? raceMgr->timer() : m_ac;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen other cases in Kinoko where an instance getter is called multiple times in a function, for instance CollisionDirector gets re-fetched multiple times per iteration in a couple for loops in KartMove and KartCollide, and BoxColManager gets re-fetched multiple times in a while loop in ObjectDirector::checkKartObjectCollision. Maybe cleaning those up could be a PR?

fnrm *= fnrm.dot(EGG::Vector3f(sinfidx, cosfidx, 0.0f));
fnrm = relativePos - (fnrm + b8Y);

f32 dVar2 = radius + 227.0f - fnrm.length();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic constant

return false;
}

(void)fnrm.normalise();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(void)fnrm.normalise();
fnrm.normalise();

static constexpr s32 PHASE_COUNT = 120;

static constexpr f32 WIDTH = 2000.0f;
static constexpr f32 _B8 = 2000.0f;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple uses of _B8 still, but if it's the same as width, does it make sense to just use WIDTH instead? Or were these left over?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't really figured out what B8 does, but in-game testing doesn't seem to suggest it has anything to do with the width.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants