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

Sync frame 2 #47

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions source/egg/math/Vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ Vector3f Vector3f::minimize(const Vector3f &rhs) const {
return out;
}

Vector3f Vector3f::proj(const Vector3f &rhs) const {
return rhs * rhs.dot(*this);
}

Vector3f Vector3f::rej(const Vector3f &rhs) const {
return *this - proj(rhs);
}

std::pair<Vector3f, Vector3f> Vector3f::projAndRej(const Vector3f &rhs) {
return std::pair(proj(rhs), rej(rhs));
}
Comment on lines +103 to +105
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need this immediately... We will undoubtedly need it soon, probably for frame 3. Want to keep anyway?

Copy link
Owner

Choose a reason for hiding this comment

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

Sure, less diff noise later.


void Vector3f::read(Stream &stream) {
x = stream.read_f32();
y = stream.read_f32();
Expand Down
3 changes: 3 additions & 0 deletions source/egg/math/Vector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ struct Vector3f {
f32 normalise();
Vector3f maximize(const Vector3f &rhs) const;
Vector3f minimize(const Vector3f &rhs) const;
Vector3f proj(const Vector3f &rhs) const;
Vector3f rej(const Vector3f &rhs) const;
std::pair<Vector3f, Vector3f> projAndRej(const Vector3f &rhs);

void read(Stream &stream);

Expand Down
10 changes: 10 additions & 0 deletions source/game/kart/KartDynamics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ void KartDynamics::calc(f32 dt, f32 maxSpeed, bool /*air*/) {

m_mainRot.normalise();
m_fullRot.normalise();

m_totalForce.setZero();
}

const EGG::Vector3f &KartDynamics::pos() const {
Expand All @@ -48,6 +50,10 @@ const EGG::Quatf &KartDynamics::fullRot() const {
return m_fullRot;
}

const EGG::Vector3f &KartDynamics::extVel() const {
return m_extVel;
}

void KartDynamics::setPos(const EGG::Vector3f &pos) {
m_pos = pos;
}
Expand All @@ -72,4 +78,8 @@ void KartDynamics::setExtraRot(const EGG::Quatf &q) {
m_extraRot = q;
}

void KartDynamics::setExtVel(const EGG::Vector3f &v) {
m_extVel = v;
}

} // namespace Kart
2 changes: 2 additions & 0 deletions source/game/kart/KartDynamics.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ public:
const EGG::Vector3f &pos() const;
const EGG::Vector3f &velocity() const;
const EGG::Quatf &fullRot() const;
const EGG::Vector3f &extVel() const;

void setPos(const EGG::Vector3f &pos);
void setGravity(f32 gravity);
void setMainRot(const EGG::Quatf &q);
void setFullRot(const EGG::Quatf &q);
void setSpecialRot(const EGG::Quatf &q);
void setExtraRot(const EGG::Quatf &q);
void setExtVel(const EGG::Vector3f &v);

private:
// These are the only vars needed in setInitialPhysicsValues
Expand Down
6 changes: 5 additions & 1 deletion source/game/kart/KartMove.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Kart {

KartMove::KartMove() : m_scale(1.0f, 1.0f, 1.0f) {}
KartMove::KartMove() : m_smoothedUp(EGG::Vector3f::ey), m_scale(1.0f, 1.0f, 1.0f) {}

void KartMove::setInitialPhysicsValues(const EGG::Vector3f &pos, const EGG::Vector3f &angles) {
EGG::Quatf quaternion;
Expand Down Expand Up @@ -53,4 +53,8 @@ f32 KartMove::hardSpeedLimit() const {
return m_hardSpeedLimit;
}

const EGG::Vector3f &KartMove::smoothedUp() const {
return m_smoothedUp;
}

} // namespace Kart
2 changes: 2 additions & 0 deletions source/game/kart/KartMove.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ public:

const EGG::Vector3f &scale() const;
f32 hardSpeedLimit() const;
const EGG::Vector3f &smoothedUp() const;

private:
EGG::Vector3f m_smoothedUp;
EGG::Vector3f m_scale;
f32 m_hardSpeedLimit;
};
Expand Down
4 changes: 4 additions & 0 deletions source/game/kart/KartObjectProxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ const EGG::Quatf &KartObjectProxy::fullRot() const {
return dynamics()->fullRot();
}

bool KartObjectProxy::isBike() const {
return param()->isBike();
}

Abstract::List *KartObjectProxy::list() const {
return s_list;
}
Expand Down
1 change: 1 addition & 0 deletions source/game/kart/KartObjectProxy.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public:

const EGG::Vector3f &pos() const;
const EGG::Quatf &fullRot() const;
bool isBike() const;

Abstract::List *list() const;

Expand Down
11 changes: 11 additions & 0 deletions source/game/kart/KartSub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ void KartSub::calcPass0() {

move()->calc();

// Pertains to startslides / leaning in stage 0 and 1
EGG::Vector3f killExtVel = dynamics()->extVel();
if (isBike()) {
killExtVel = killExtVel.rej(move()->smoothedUp());
} else {
killExtVel.x = 0.0f;
killExtVel.z = 0.0f;
}

dynamics()->setExtVel(killExtVel);

f32 maxSpeed = move()->hardSpeedLimit();
physics()->calc(DT, maxSpeed, scale(), !state()->isGround());
}
Expand Down
2 changes: 1 addition & 1 deletion source/test/TestDirector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool TestDirector::init() {

bool TestDirector::calc() {
// Check if we're out of frames
constexpr u16 TARGET_FRAME = 1;
constexpr u16 TARGET_FRAME = 2;
assert(TARGET_FRAME <= m_frameCount);
if (++m_currentFrame > TARGET_FRAME) {
return false;
Expand Down
Loading