Skip to content

Commit

Permalink
Sync Logan's rBC3 SC WR
Browse files Browse the repository at this point in the history
  • Loading branch information
malleoz authored and vabold committed May 12, 2024
1 parent a3ded86 commit d7eaa78
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[![Vincent's rMR RTA WR](<https://vabold.github.io/Kinoko/Vincent rMR RTA WR.svg>)](https://www.youtube.com/watch?v=y7t4_xXuD2A)
[![Sosis's rSL RTA WR](<https://vabold.github.io/Kinoko/Sosis rSL RTA WR.svg>)](https://www.youtube.com/watch?v=ahNGAaUzm6s)
[![Logan's MH RTA WR](<https://vabold.github.io/Kinoko/Logan MH RTA WR.svg>)](https://www.youtube.com/watch?v=CellUlOYgnc)
[![Logan's rBC3 RTA WR](<https://vabold.github.io/Kinoko/Logan rBC3 RTA WR.svg>)](https://www.youtube.com/watch?v=vSbSADDEzEs)

Kinoko is a reimplementation of Mario Kart Wii's physics engine in C++. This project is a spiritual continuation of [stblr/Hanachan](https://github.com/stblr/Hanachan). Like Hanachan, the goal of this reimplementation is to reach perfectly accurate ghost replay.

Expand Down
Binary file added samples/rbc3-rta-1-55-715.krkg
Binary file not shown.
Binary file added samples/rbc3-rta-1-55-715.rkg
Binary file not shown.
11 changes: 7 additions & 4 deletions source/egg/math/Quat.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ struct Quatf {
return *this = *this * scalar;
}

/// Though part of this is a vector cross/dot product, FP arithmetic is not associative or
/// commutative. It has to be done in this order.
Quatf operator*(const Quatf &rhs) const {
Vector3f cross = v.cross(rhs.v);
Vector3f scaleLhs = v * rhs.w;
Vector3f scaleRhs = rhs.v * w;
f32 _w = w * rhs.w - v.x * rhs.v.x - v.y * rhs.v.y - v.z * rhs.v.z;
f32 _x = v.y * rhs.v.z + (v.x * rhs.w + w * rhs.v.x) - v.z * rhs.v.y;
f32 _y = v.z * rhs.v.x + (v.y * rhs.w + w * rhs.v.y) - v.x * rhs.v.z;
f32 _z = v.x * rhs.v.y + (v.z * rhs.w + w * rhs.v.z) - v.y * rhs.v.x;

return Quatf(w * rhs.w - v.dot(rhs.v), cross + scaleRhs + scaleLhs);
return Quatf(_w, _x, _y, _z);
}

Quatf &operator*=(const Quatf &q) {
Expand Down
11 changes: 10 additions & 1 deletion source/game/field/KColData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,16 @@ bool KColData::checkCollision(const KCollisionPrism &prism, f32 *distOut, EGG::V
const EGG::Vector3f fnrm = getNrm(prism.fnrm_i);
f32 plane_dist = relativePos.ps_dot(fnrm);
f32 dist_in_plane = m_radius - plane_dist;
if (dist_in_plane <= 0.0f || dist_in_plane >= m_prismThickness) {
if (dist_in_plane <= 0.0f) {
return false;
}

f32 typeDistance = m_prismThickness;
if (type == CollisionCheckType::Edge) {
typeDistance += m_radius;
}

if (dist_in_plane >= typeDistance) {
return false;
}

Expand Down
4 changes: 3 additions & 1 deletion source/game/kart/KartCollide.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void KartCollide::FUN_80572F4C() {

bool resetXZ = fVar1 > 0.0f && state()->isAirtimeOver20() && dynamics()->velocity().y < -50.0f;

FUN_805B72B8(0.01f, fVar1, resetXZ, true);
FUN_805B72B8(0.01f, fVar1, resetXZ, !state()->isJumpPadDisableYsusForce());
}

void KartCollide::FUN_805B72B8(f32 param_1, f32 param_2, bool lockXZ, bool addExtVelY) {
Expand Down Expand Up @@ -361,6 +361,7 @@ void KartCollide::processFloor(CollisionData &collisionData, Hitbox &hitbox,

if (!!(*maskOut & BOOST_RAMP_MASK) &&
colDirector->findClosestCollisionEntry(maskOut, BOOST_RAMP_MASK)) {
closestColEntry = colDirector->closestCollisionEntry();
move()->setRampBoost(true);
state()->setBoostRampType(KCL_VARIANT_TYPE(closestColEntry->attribute));
m_rampBoost = true;
Expand All @@ -383,6 +384,7 @@ void KartCollide::processFloor(CollisionData &collisionData, Hitbox &hitbox,
if (*maskOut & jumpPadMask && colDirector->findClosestCollisionEntry(maskOut, jumpPadMask)) {
if (!state()->isTouchingGround() || !state()->isJumpPad()) {
move()->setPadJump(true);
closestColEntry = colDirector->closestCollisionEntry();
state()->setJumpPadVariant(KCL_VARIANT_TYPE(closestColEntry->attribute));
}
collisionData.bTrickable = true;
Expand Down
6 changes: 3 additions & 3 deletions source/game/kart/KartMove.cc
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,7 @@ bool KartMove::calcPreDrift() {
}
}

if (!state()->isHop() && state()->isSlipdriftCharge()) {
m_hopFrame = 0;
} else {
if (state()->isHop()) {
if (m_hopStickX == 0) {
if (state()->isStickRight()) {
m_hopStickX = -1;
Expand All @@ -456,6 +454,8 @@ bool KartMove::calcPreDrift() {
if (m_hopFrame < 3) {
++m_hopFrame;
}
} else if (state()->isSlipdriftCharge()) {
m_hopFrame = 0;
}

return state()->isHop() || state()->isSlipdriftCharge();
Expand Down
7 changes: 6 additions & 1 deletion source/game/kart/KartState.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ void KartState::calcCollisions() {
static_cast<f32>(collide()->someSoftWallTimer());
f32 nonSusp = collide()->suspBottomHeightNonSoftWall() /
static_cast<f32>(collide()->someNonSoftWallTimer());
m_bSoftWallDrift = (softSusp - nonSusp < 40.0f);

if (softSusp - nonSusp >= 40.0f) {
m_bSoftWallDrift = false;
} else {
softWallCollision = true;
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions testCases.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"Logan rBC3 RTA WR": {
"rkgPath": "samples/rbc3-rta-1-55-715.rkg",
"krkgPath": "samples/rbc3-rta-1-55-715.krkg",
"targetFrame": 7347
},
"Logan MH RTA WR": {
"rkgPath": "samples/mh-rta-1-42-872.rkg",
"krkgPath": "samples/mh-rta-1-42-872.krkg",
Expand Down

0 comments on commit d7eaa78

Please sign in to comment.