Skip to content
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
14 changes: 14 additions & 0 deletions include/JSystem/JGeometry/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ namespace JGeometry {
}
return cur;
}

// fabricated - taken from SMS decomp.
// NOTE: both `while` loops are reversed for MKDD, compared to SMS.
static inline T wrap(T t, T l, T r) {
if (l >= r)
return l;

while (t < l)
t += r - l;
while (t >= r)
t -= r - l;

return t;
}
};

typedef TUtil<f32> TUtilf;
Expand Down
13 changes: 0 additions & 13 deletions include/Shiraiwa/Objects/MapObjWanwan.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@

class TMapObjWanwan;

inline f32 normalizeRelativeAngle(f32 angle, f32 min, f32 max) {
if (min >= max) {
return min;
}
for (; angle < min; angle += max - min) {
}

for (; angle >= max; angle -= max - min) {
}

return angle;
}

class TMapObjWanwanPile : public GeographyObj {
public:
TMapObjWanwanPile();
Expand Down
2 changes: 1 addition & 1 deletion src/Shiraiwa/MapObjWanwan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ void TMapObjWanwan::fallDown(s32 nextState, bool p2) {
void TMapObjWanwan::turnTo() {
f32 targetAngle = mAttackAngle;

f32 limit = targetAngle - normalizeRelativeAngle(mRotate, targetAngle - F_PI, targetAngle + F_PI);
f32 limit = targetAngle - JGeometry::TUtilf::wrap(mRotate, targetAngle - F_PI, targetAngle + F_PI);

f32 rotate = _22c;
if (StateObserver::getState() == 1) {
Expand Down
Loading