Skip to content

Commit

Permalink
chore: Cleanup nlibgeometry
Browse files Browse the repository at this point in the history
  • Loading branch information
intns committed Dec 14, 2024
1 parent 78bb303 commit 1c9422f
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 183 deletions.
33 changes: 22 additions & 11 deletions include/nlib/Geometry.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#ifndef _NLIB_GEOMETRY_H
#define _NLIB_GEOMETRY_H

#include "types.h"
#include "Dolphin/mtx.h"
#include "Vector.h"
#include "nlib/Math.h"
#include "Matrix4f.h"
#include "Vector.h"
#include "types.h"

struct Stream;
struct NTransform3D;
Expand Down Expand Up @@ -359,6 +360,16 @@ struct NTransform3D {
NMatrix4f mMtx; // _00
};

struct NAlphaMode {
enum _ {
Linear = 0,
FadeOut = 1,
FadeIn = 2,
FadeInOut = 3,
FadeOutIn = 4,
};
};

/**
* @brief TODO
*/
Expand All @@ -370,17 +381,17 @@ struct NAlpha {
void reset();
f32 getValue(f32);

// unused/inlined:
void fadeInValue(f32);
void fadeOutValue(f32);
void fadeInOutValue(f32);
void fadeOutInValue(f32);
// inlined
f32 fadeInValue(f32 x);
f32 fadeOutValue(f32 x);
f32 fadeInOutValue(f32 x);
f32 fadeOutInValue(f32 x);

// _00 = VTBL
f32 _04; // _04
f32 _08; // _08
f32 _0C; // _0C
u8 _10; // _10
f32 mValue; // _04
f32 mOffset; // _08
f32 mScale; // _0C, actually named 'period'
u8 mMode; // _10
};

#endif
4 changes: 2 additions & 2 deletions include/nlib/Math.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ f32 remainder(f32, f32);

// unused/inlined:
f32 roundAngle(f32);

inline f32 atan2Vec(Vector3f vec) { return atan2(vec.x, vec.z); }

extern f32 pi;

inline f32 getRandomAngle() { return 2.0f * StdSystem::getRand(1.0f) * pi; }

extern f32 error;
Expand Down Expand Up @@ -54,6 +52,8 @@ struct NMath {
}
return val;
}

static bool isZero(f32 period) { return absolute(period) <= NMathF::error; }
};

typedef NMath<f32> NMathf;
Expand Down
11 changes: 11 additions & 0 deletions include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ typedef volatile f128 vf128;

typedef u32 unknown;

#ifdef __MWERKS__
#define PRINT(...)
#define ERROR(...)
#else
#define PRINT(...) _Print(__VA_ARGS__)
#define ERROR(...) _Error(__VA_ARGS__)
#endif

#define WINDOWS_ONLY_START (#ifdef _WIN32)
#define WINDOWS_ONLY_END (#endif)

#ifndef __cplusplus
typedef u16 wchar_t;
#endif
Expand Down
9 changes: 6 additions & 3 deletions src/plugPikiKando/interactBattle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,26 +482,29 @@ bool InteractSwallow::actPiki(Piki* piki)
return false;
}

bool check = false;
bool isPiki = false;
Stickers stickers(mOwner);
Stickers* stickPtr = &stickers;
for (int i = stickPtr->getFirst(); !stickPtr->isEnd(i); i = stickPtr->getNext(i)) {
Creature* stuck;

// On invalid index, get the first creature
if (i == -1) {
stuck = stickPtr->getCreature(0);
} else {
stuck = stickPtr->getCreature(i);
}

if (stuck == piki) {
check = true;
isPiki = true;
}

if (stuck->isCreatureFlag(CF_StuckToMouth)) {
stuck->isCreatureFlag(CF_StuckToMouth);
}
}

if (!check) {
if (!isPiki) {
Creature* target = mOwner->_180;
while (target) {
target = target->_18C;
Expand Down
Loading

0 comments on commit 1c9422f

Please sign in to comment.