Slight cleanup

This commit is contained in:
intns 2024-05-15 16:35:28 +01:00
parent 57cc857ce0
commit f249acb999
34 changed files with 137 additions and 157 deletions

View File

@ -16,6 +16,9 @@ inline f32 randFloat() { return (f32)rand() / RAND_MAX; }
inline int randInt(int multiplier) { return multiplier * randFloat(); }
inline f32 randWeightFloat(f32 range) { return (range * (f32)rand()) / RAND_MAX; }
#define RAND_FLOAT_RANGE(origin, deviation) (origin - randFloat() * deviation)
#define RAND_FLOAT_BETWEEN(min, max) (min + randFloat() * (max - min))
#ifdef __cplusplus
};
#endif // ifdef __cplusplus

View File

@ -111,8 +111,8 @@ struct FallState : public State {
// _00 = VTBL
// _00-_10 = State
f32 _10; // _10
f32 _14; // _14
f32 mHorizontalDrag; // _10
f32 mVerticalDrag; // _14
};
struct GrowState : public State {

View File

@ -8,10 +8,8 @@
#include "Vector3.h"
#include "Plane.h"
#define FABS(x) (f32) __fabs(x)
// probably a Vector3.h thing
inline f32 lenVec(const Vector3f& a) { return pikmin2_sqrtf(dot(a, a)); }
inline f32 lenVec(Vector3f& a) { return pikmin2_sqrtf(a.dot(a)); }
// no zero check
inline f32 _normalise(Vector3f* a)

View File

@ -49,7 +49,7 @@ struct Vector3 {
* @param from The starting point of the direction vector.
* @param to The ending point of the direction vector.
*/
static inline f32 getDirectionFromTo(const Vector3& from, Vector3& to)
static inline T getDirectionFromTo(const Vector3& from, Vector3& to)
{
to -= from;
return to.normalise();
@ -77,7 +77,7 @@ struct Vector3 {
return *this;
}
inline void operator=(Vector3<T>& other)
inline void operator=(Vector3& other)
{
x = other.x;
y = other.y;
@ -91,7 +91,7 @@ struct Vector3 {
z = other.z;
}
inline operator Vector2f() const { return Vector2f(x, y); }
inline operator Vector2<T>() const { return Vector2<T>(x, y); }
// /**
// * @fabricated
@ -124,14 +124,14 @@ struct Vector3 {
z = vec.z;
}
inline void set(f32 _x, f32 _y, f32 _z)
inline void set(T _x, T _y, T _z)
{
x = _x;
y = _y;
z = _z;
}
inline void set(f32 xyz) { x = y = z = xyz; }
inline void set(T xyz) { x = y = z = xyz; }
/**
* @fabricated
@ -179,7 +179,7 @@ struct Vector3 {
// return newVector;
// }
inline void operator*=(Matrixf& other);
inline void operator*=(const f32 other)
inline void operator*=(const T other)
{
this->x *= other;
this->y *= other;
@ -221,8 +221,8 @@ struct Vector3 {
inline void scaleXY(const Vector3& other)
{
f32 newVal = this->x * other.x;
this->x = newVal;
T newVal = this->x * other.x;
this->x = newVal;
newVal = this->y * other.y;
this->y = newVal;
@ -258,17 +258,17 @@ struct Vector3 {
return this->normalise();
}
static inline f32 distance(Vector3& a, Vector3& b) { return (a - b).length(); }
static inline T distance(Vector3& a, Vector3& b) { return (a - b).length(); }
inline void sub(Vector3& a, Vector3& b) { set(a.x - b.x, a.y - b.y, a.z - b.z); }
inline f32 absX() { return (f32)absF(x); }
inline f32 absY() { return absF(y); }
inline f32 absZ() { return (f32)absF(z); }
inline T absX() { return (T)absF(x); }
inline T absY() { return absF(y); }
inline T absZ() { return (T)absF(z); }
inline boundedX(f32 bound) { return absX() < bound; }
inline boundedY(f32 bound) { return absY() < bound; }
inline boundedZ(f32 bound) { return absZ() < bound; }
inline boundedX(T bound) { return absX() < bound; }
inline boundedY(T bound) { return absY() < bound; }
inline boundedZ(T bound) { return absZ() < bound; }
/**
* Sets the flat direction from one vector to another.
@ -294,18 +294,18 @@ struct Vector3 {
}
// Squared magnitude
inline f32 sqrMagnitude() const { return this->x * this->x + this->y * this->y + this->z * this->z; }
inline T sqrMagnitude() const { return this->x * this->x + this->y * this->y + this->z * this->z; }
// 2D magnitude
inline f32 sqrMagnitude2D() const { return this->x * this->x + this->z * this->z; }
inline T sqrMagnitude2D() const { return this->x * this->x + this->z * this->z; }
// Quick length
inline f32 qLength() const { return pikmin2_sqrtf(this->sqrMagnitude()); }
inline f32 qLength2D() const { return pikmin2_sqrtf(this->sqrMagnitude2D()); }
inline T qLength() const { return pikmin2_sqrtf(this->sqrMagnitude()); }
inline T qLength2D() const { return pikmin2_sqrtf(this->sqrMagnitude2D()); }
inline f32 qNormalise()
inline T qNormalise()
{
f32 length = this->qLength();
T length = this->qLength();
if (length > 0.0f) {
f32 len = 1.0f / length;
T len = 1.0f / length;
this->x *= len;
this->y *= len;
this->z *= len;
@ -314,33 +314,33 @@ struct Vector3 {
return 0.0f;
}
inline f32 qDistance(Vector3& them)
inline T qDistance(Vector3& them)
{
f32 diffX = this->x - them.x;
f32 diffY = this->y - them.y;
f32 diffZ = this->z - them.z;
T diffX = this->x - them.x;
T diffY = this->y - them.y;
T diffZ = this->z - them.z;
return pikmin2_sqrtf(SQUARE(diffX) + SQUARE(diffY) + SQUARE(diffZ));
}
inline f32 sqrDistanceToSphere(Vector3& them)
inline T sqrDistanceToSphere(Vector3& them)
{
f32 diffX = this->x - them.x;
f32 diffY = this->y - them.y;
f32 diffZ = this->z - them.z;
T diffX = this->x - them.x;
T diffY = this->y - them.y;
T diffZ = this->z - them.z;
return SQUARE(diffX) + SQUARE(diffY) + SQUARE(diffZ);
}
f32 length() const;
f32 distance(Vector3&);
f32 distance2D(Vector3&);
f32 sqrDistance(Vector3&);
f32 sqrDistance2D(Vector3&);
f32 distance(JGeometry::TVec3f&);
f32 normalise();
f32 length2D() const;
f32 normalise2D();
T length() const;
T distance(Vector3&);
T distance2D(Vector3&);
T sqrDistance(Vector3&);
T sqrDistance2D(Vector3&);
T distance(JGeometry::TVec3f&);
T normalise();
T length2D() const;
T normalise2D();
void read(Stream&);
void write(Stream&);
@ -356,25 +356,17 @@ struct Vector3 {
typedef Vector3<f32> Vector3f;
typedef Vector3<int> Vector3i;
/**
* @reifiedAddress{80207BA0}
* @reifiedFile{plugProjectKandoU/itemUjamushi.cpp}
*/
inline Vector3f operator+(const Vector3f& a, const Vector3f& b) { return Vector3f(a.x + b.x, a.y + b.y, a.z + b.z); }
/**
* @reifiedAddress{80207E70}
* @reifiedFile{plugProjectKandoU/itemUjamushi.cpp}
*/
inline Vector3f operator-(const Vector3f& a, const Vector3f& b) { return Vector3f(a.x - b.x, a.y - b.y, a.z - b.z); }
inline Vector3f operator*(const Vector3f& a, const f32 b) { return Vector3f(a.x * b, a.y * b, a.z * b); }
inline Vector3f operator/(const Vector3f& a, const f32 b) { return Vector3f(a.x / b, a.y / b, a.z / b); }
inline Vector3f operator*=(const Vector3f& a, const f32 b) { return Vector3f(a.x * b, a.y * b, a.z * b); }
inline f32 dot(const Vector3f& a, const Vector3f& b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
inline Vector3i operator+(const Vector3i& a, const Vector3i& b) { return Vector3i(a.x + b.x, a.y + b.y, a.z + b.z); }
inline Vector3i operator-(const Vector3i& a, const Vector3i& b) { return Vector3i(a.x - b.x, a.y - b.y, a.z - b.z); }
inline Vector3i operator*(const Vector3i& a, const int b) { return Vector3i(a.x * b, a.y * b, a.z * b); }
inline Vector3i operator/(const Vector3i& a, const int b) { return Vector3i(a.x / b, a.y / b, a.z / b); }
inline Vector3i operator*=(const Vector3i& a, const int b) { return Vector3i(a.x * b, a.y * b, a.z * b); }
inline bool operator==(const Vector3f& a, const Vector3f& b) { return (a.x == b.x && a.y == b.y && a.z == b.z); }
@ -498,20 +490,6 @@ inline f32 _normalise2(Vector3f& diff)
return 0.0f;
}
inline void _normalise(Vector3f& vec)
{
Vector2f sqr(vec.z * vec.z, vec.x * vec.x + vec.y * vec.y);
f32 length = sqr.x + sqr.y;
__sqrtf(length, &length);
if (length > 0.0f) {
f32 norm = 1.0f / length;
vec.x *= norm;
vec.y *= norm;
vec.z *= norm;
}
}
inline void _normaliseScale(Vector3f& vec, f32 scale)
{
Vector2f sqr(vec.z * vec.z, vec.x * vec.x + vec.y * vec.y);

View File

@ -36,7 +36,7 @@ void TTitleLightMgr::setParam_()
= Vector3f(mSetting.mMainParms.mPosX.mValue, mSetting.mMainParms.mPosY.mValue, mSetting.mMainParms.mPosZ.mValue);
Vector3f temp(mSetting.mMainParms.mRotX, mSetting.mMainParms.mRotY, mSetting.mMainParms.mRotZ);
_normalise2(temp);
temp.normalise();
mLightObjMain.mElevation = temp;
setRefValues(mSetting.mMainParms.mLightRange, mSetting.mMainParms.mLightBrightness, mSetting.mMainParms.mCutoffAngle);
@ -45,9 +45,10 @@ void TTitleLightMgr::setParam_()
mLightObjSpec.mColor = Color4(mSetting.mSpecParms.mLightColR, mSetting.mSpecParms.mLightColG, mSetting.mSpecParms.mLightColB,
mSetting.mSpecParms.mLightColA);
Vector3f temp2(mSetting.mSpecParms.mRotX, mSetting.mSpecParms.mRotY, mSetting.mSpecParms.mRotZ);
_normalise(temp2);
mLightObjSpec.mElevation = temp2;
temp.set(mSetting.mSpecParms.mRotX, mSetting.mSpecParms.mRotY, mSetting.mSpecParms.mRotZ);
temp.normalise();
mLightObjSpec.mElevation = temp;
mLightObjSpec.mKScale = mSetting.mSpecParms.mGlossAmount;
}

View File

@ -163,8 +163,8 @@ int ActCrop::exec()
sep.normalise();
Vector3f unitYVel(0.0f, 1.0f, 0.0f);
f32 horizComp = dot(unitXZVel, sep);
f32 yComp = dot(unitYVel, sep);
f32 horizComp = unitXZVel.dot(sep);
f32 yComp = unitYVel.dot(sep);
f32 negYComp = -yComp;
mParent->endStick();

View File

@ -471,7 +471,7 @@ int PikiAI::ActFormation::exec()
Vector3f plateSep = mParent->mNavi->getPosition() - mCPlate->mMaxPositionOffset;
plateSep.normalise();
if (dot(plateSep, naviPikiSep) > 0.0f) {
if (plateSep.dot(naviPikiSep) > 0.0f) {
Vector3f impulse = Vector3f(-naviPikiSep.z, 0.0f, naviPikiSep.x); // f29, f27, f30
if (mSlotID & 1) {
impulse.negate();
@ -497,7 +497,7 @@ int PikiAI::ActFormation::exec()
Vector3f plateSep = mParent->mNavi->getPosition() - mCPlate->mMaxPositionOffset;
plateSep.normalise();
if (dot(plateSep, naviPikiSep) > 0.0f) {
if (plateSep.dot(naviPikiSep) > 0.0f) {
Vector3f impulse = Vector3f(-naviPikiSep.z, 0.0f, naviPikiSep.x); // f29, f27, f30
if (mSlotID & 1) {
impulse.negate();

View File

@ -568,7 +568,7 @@ int ActGotoSlot::exec()
sep *= -1.0f;
f32 dotProd = dot(slotPos, sep);
f32 dotProd = slotPos.dot(sep);
f32 crossThing = (slotPos.z * sep.x) - (slotPos.x * sep.z);
f32 factor = (dotProd >= 1.0f) ? 1.0f : (dotProd <= -1.0f) ? -1.0f : dotProd; // f3
@ -3551,7 +3551,7 @@ void ActPathMove::crInit()
if (dist == 0.0f) {
newPoint = newPoint;
} else {
f32 ratio = dot(sep, pelletSep) / dist;
f32 ratio = sep.dot(pelletSep) / dist;
if (ratio < 0.0f) {
newPoint = newPoint;
} else if (ratio > 1.0f) {
@ -3635,7 +3635,7 @@ bool ActPathMove::crMove()
f32 factor; // f27
if (dist > 0.0f) {
Vector3f diff = pelletPos - point0;
factor = dot(sep, diff) / dist;
factor = sep.dot(diff) / dist;
} else {
factor = 1.0f;
}

View File

@ -290,7 +290,7 @@ void ActTeki::collisionCallback(Game::Piki* piki, Game::CollEvent& event)
// And doesn't logically make sense, mUnusedZeroVector is always Vector3f(0, 0, 0)
// Meaning the dot product is always 0, thus mUnusedDotProduct is always -0.1f
Vector3f sep = currentPos - collidedPos;
f32 dotProd = dot(mUnusedZeroVector, sep);
f32 dotProd = mUnusedZeroVector.dot(sep);
mUnusedDotProduct = dotProd;
if (dotProd > 0.0f) {
mUnusedDotProduct = 0.1f;

View File

@ -730,7 +730,7 @@ void Creature::resolveOneColl(CollPart* source, CollPart* dest, Vector3f& direct
CollEvent destToSrcEvent(op, dest, source);
Vector3f velocityDifference = velAtSource - velAtDest;
f32 sepDot = dot(velocityDifference, collisionNormal);
f32 sepDot = velocityDifference.dot(collisionNormal);
collisionCallback(destToSrcEvent);
CollEvent srcToDestEvent(this, source, dest);

View File

@ -42,8 +42,8 @@ void FSM::init(Item*)
*/
void FallState::init(Item* item, StateArg* arg)
{
_14 = 10.0f - randFloat() * 0.5f; // 9.5-10.5
_10 = _14 * 0.2f; // 1.9-2.1
mVerticalDrag = RAND_FLOAT_RANGE(10.0f, 0.5f); // 9.5-10.5
mHorizontalDrag = mVerticalDrag * 0.2f; // 1.9-2.1
item->mEfxTane->createTanekira_(item->mEfxTane->mEfxPos);
item->mAnimator.startAnim(4, nullptr);
}
@ -52,7 +52,7 @@ void FallState::init(Item* item, StateArg* arg)
* @note Address: 0x801D8DE8
* @note Size: 0x38
*/
void FallState::exec(Item* item) { item->applyAirDrag(sys->getDeltaTime(), _10, _14); }
void FallState::exec(Item* item) { item->applyAirDrag(sys->getDeltaTime(), mHorizontalDrag, mVerticalDrag); }
/**
* @note Address: 0x801D8E20

View File

@ -303,7 +303,7 @@ void NaviStuckState::exec(Navi* navi)
f32 stickMag = _lenVec(stickVals);
if (stickMag > 0.3f) {
f32 dir = dot(stickVals, mPrevStickDirection);
f32 dir = stickVals.dot(mPrevStickDirection);
if (dir < 0.5f) {
mWiggleCounter++;
if (mWiggleCounter > 9) {

View File

@ -200,13 +200,13 @@ Pellet* PelletView::becomePellet(PelletViewArg* viewArg)
Vector3f row1;
viewArg->mMatrix->getRow(0, row1);
vecPtr->x = dot(offset, row1);
vecPtr->x = offset.dot(row1);
Vector3f row2;
viewArg->mMatrix->getRow(1, row2);
vecPtr->y = dot(offset, row2);
vecPtr->y = offset.dot(row2);
Vector3f row3;
viewArg->mMatrix->getRow(2, row3);
vecPtr->z = dot(offset, row3);
vecPtr->z = offset.dot(row3);
position = position + resultVec;
newPellet->setPosition(position, false);
@ -2109,7 +2109,7 @@ void Pellet::update()
if (mPickFlags & 1) {
bool check = (info.mWallTriangle != nullptr);
if (check && (dot(moveVel, info.mWallNormal) > 0.5f)) {
if (check && (moveVel.dot(info.mWallNormal) > 0.5f)) {
check = false;
}
if (check) {
@ -2141,9 +2141,9 @@ void Pellet::update()
if (!(mPickFlags & 1) && (mIsAlwaysCarried == 0)) {
/////// this bit is full of regswaps
Vector3f currVel = *velocityPtr;
f32 dotVelocity = dot(currVel, info.mFloorNormal);
f32 dotVelocity = currVel.dot(info.mFloorNormal);
Vector3f impulse(0.0f, -(_aiConstants->mGravity.mData * sys->mDeltaTime), 0.0f);
f32 dotImpulse = dot(impulse, info.mFloorNormal);
f32 dotImpulse = impulse.dot(info.mFloorNormal);
Vector3f res = info.mFloorNormal * dotVelocity;
res = currVel - res;
@ -2244,7 +2244,7 @@ void Pellet::update()
if (mPickFlags & 1) {
bool check = (info3.mWallTriangle != nullptr);
if (check && (dot(anotherMoveVec, info3.mWallNormal) > 0.5f)) {
if (check && (anotherMoveVec.dot(info3.mWallNormal) > 0.5f)) {
check = false;
}
if (check) {

View File

@ -576,7 +576,7 @@ bool RouteMgr::getNearestEdge(WPEdgeSearchArg& searchArg)
f32 distanceMagnitude = relativePosition.normalise();
Vector3f searchSep = searchArg.mStartPosition - wpPos;
f32 dotProd = dot(relativePosition, searchSep) / distanceMagnitude;
f32 dotProd = relativePosition.dot(searchSep) / distanceMagnitude;
if (distanceMagnitude < 0.1f) {
JUT_PANICLINE(768, "wpA(%d) and wpB(%d) cause singularity !\n", wpA->mIndex, wpB->mIndex);

View File

@ -315,7 +315,7 @@ void TitleState::execVs(VsGameSection* section)
f32 highest = 0.0f;
int vsEditIndex = 0;
for (int i = 0; i < 4; i++) {
f32 stickWeight = dot(directions[i], stickPos);
f32 stickWeight = directions[i].dot(stickPos);
if (stickWeight > highest) {
highest = stickWeight;
vsEditIndex = i; // up = 0, right = 1, down = 2, left = 3

View File

@ -2574,7 +2574,7 @@ void BlackMan::Obj::findNextRoutePoint()
Vector3f sep2 = wp->mPosition - mPosition;
sep2.normalise();
f32 dotProd = dot(crossVec, sep2);
f32 dotProd = crossVec.dot(sep2);
if (dotProd > maxDot) {
maxDot = dotProd;
val = i;

View File

@ -458,9 +458,9 @@ bool BigTreasureElecAttack::update()
Vector3f creaturePos = creature->getPosition();
Vector3f sep = creaturePos - mPosition;
f32 dot1 = dot(crossVec1, sep);
if (absVal(dot1) < 10.0f && absVal(dot(crossVec2, sep)) < 20.0f) {
f32 dotSep = dot(partnerSep, sep);
f32 dot1 = crossVec1.dot(sep);
if (absVal(dot1) < 10.0f && absVal(crossVec2.dot(sep)) < 20.0f) {
f32 dotSep = partnerSep.dot(sep);
if (dotSep > 0.0f && dotSep < dist) {
Vector3f zapDir(dot1 * crossVec1.x, 0.0f, dot1 * crossVec1.z);
zapDir.normalise();

View File

@ -254,7 +254,7 @@ void Obj::wallCallback(const MoveInfo& mvInfo)
f32 speed = velocity.normalise();
// if we're rolling fast enough and hit the wall at a 30 degree angle or more (90 degree = head-on), crash
if (speed > 100.0f && dot(velocity, mvInfo.mWallNormal) < -0.5f) {
if (speed > 100.0f && velocity.dot(mvInfo.mWallNormal) < -0.5f) {
createBodyWallCrashEffect(mvInfo.mWallNormal);
mFsm->transit(this, DANGOMUSHI_Turn, nullptr);
}

View File

@ -409,12 +409,12 @@ void Obj::checkInteract(Obj* partner)
Vector3f creatureSep = creature->getPosition();
creatureSep -= pos;
f32 creatureDot = dot(crossVec, creatureSep); // f3
f32 creatureDot = crossVec.dot(creatureSep); // f3
f32 absDot = absVal(creatureDot); // f4
if (absDot < 10.0f) {
f32 sepDot = dot(sep, creatureSep); // f6
if (sepDot < dist && sepDot > 0.0f && absVal(dot(vec3, creatureSep)) < 15.0f) {
f32 sepDot = sep.dot(creatureSep); // f6
if (sepDot < dist && sepDot > 0.0f && absVal(vec3.dot(creatureSep)) < 15.0f) {
f32 factor = creatureDot / absDot;
Vector3f dir(factor * denkiDir.x, denkiDir.y, factor * denkiDir.z);
InteractDenki denki(this, C_GENERALPARMS.mAttackDamage(), &dir);

View File

@ -293,7 +293,7 @@ void Obj::interactDenkiAttack(Vector3f& position)
Vector3f creaturePos = creature->getPosition();
// Vector3f creatureSep = creaturePos - some other vector of consts;
// f32 dotProd = dot(crossProd, creatureSep);
// f32 dotProd = crossProd.dot(creatureSep);
f32 dotProd = 1.0f;
if (!(dotProd > 0.0f)) { // make sure it's positive
dotProd = -dotProd;

View File

@ -1016,7 +1016,7 @@ bool Obj::windTarget()
if (navi->isAlive()) {
Vector3f naviPos = navi->getPosition();
Vector3f sep = naviPos - vec1;
f32 dotProd = dot(sep, vec2);
f32 dotProd = sep.dot(vec2);
if (dotProd < radius && dotProd > 0.0f) {
// more vector math here.
InteractWind wind(this, 0.0f, &vec2); // not vec2
@ -1032,7 +1032,7 @@ bool Obj::windTarget()
if (piki->isAlive()) {
Vector3f pikiPos = piki->getPosition();
Vector3f sep = pikiPos - vec1;
f32 dotProd = dot(sep, vec2);
f32 dotProd = sep.dot(vec2);
if (dotProd < radius && dotProd > 0.0f) {
// more vector math here.
InteractWind wind(this, 0.0f, &vec2); // not vec2

View File

@ -190,17 +190,17 @@ bool HoudaiShotGunNode::update()
Vector3f creaturePos = target->getPosition();
Vector3f sep = creaturePos - startPos;
f32 dot2 = dot(vec2, sep);
f32 dot2 = vec2.dot(sep);
if (!(absVal(dot2) < radius)) {
continue;
}
f32 dot3 = dot(vec3, sep);
f32 dot3 = vec3.dot(sep);
if (!(absVal(dot3) < radius)) {
continue;
}
f32 dot1 = dot(vec1, sep);
f32 dot1 = vec1.dot(sep);
if (!(dot1 > -radius)) {
continue;
}

View File

@ -229,9 +229,9 @@ bool Obj::isAttackableTarget()
Vector3f creaturePos = creature->getPosition();
Vector3f diff = creaturePos - mPosition;
if (absVal(diff.x) < C_GENERALPARMS.mFov()) {
f32 dotProd = absVal(dot(diff, angles));
f32 dotProd = absVal(diff.dot(angles));
if (dotProd < 15.0f) {
f32 secondDotProd = dot(diff, angles);
f32 secondDotProd = diff.dot(angles);
if (secondDotProd > 15.0f && secondDotProd < C_GENERALPARMS.mSightRadius.mValue) {
return true;
}

View File

@ -1013,7 +1013,7 @@ void Obj::windTarget()
if (navi->isAlive()) {
Vector3f naviPos = navi->getPosition();
Vector3f sep = naviPos - vec1;
f32 dotProd = dot(sep, vec2);
f32 dotProd = sep.dot(vec2);
if (dotProd < radius && dotProd > 0.0f) {
// more vector math here.
InteractWind wind(this, 0.0f, &vec2); // not vec2
@ -1029,7 +1029,7 @@ void Obj::windTarget()
if (piki->isAlive()) {
Vector3f pikiPos = piki->getPosition();
Vector3f sep = pikiPos - vec1;
f32 dotProd = dot(sep, vec2);
f32 dotProd = sep.dot(vec2);
if (dotProd < radius && dotProd > 0.0f) {
// more vector math here.
InteractWind wind(this, 0.0f, &vec2); // not vec2

View File

@ -544,8 +544,8 @@ bool Obj::isAttackableTarget()
if (targetable) {
Vector3f targetPos = target->getPosition();
targetPos -= shotGunPos;
if (absVal(targetPos.y) < 200.0f && absVal(dot(perpDir, targetPos)) < 25.0f) {
f32 dotProd = dot(dir, targetPos);
if (absVal(targetPos.y) < 200.0f && absVal(perpDir.dot(targetPos)) < 25.0f) {
f32 dotProd = dir.dot(targetPos);
if (dotProd > 1.0f && dotProd < C_GENERALPARMS.mSearchDistance.mValue) {
mTargetPosition = target->getPosition();
return true;

View File

@ -180,13 +180,13 @@ bool MiniHoudaiShotGunNode::update()
Vector3f creaturePos = target->getPosition();
Vector3f sep = creaturePos - startPos;
f32 dot2 = dot(vec2, sep);
f32 dot2 = vec2.dot(sep);
if (absVal(dot2) < radius) {
f32 dot3 = dot(vec3, sep);
f32 dot3 = vec3.dot(sep);
if (absVal(dot3) < radius) {
f32 dot1 = dot(vec1, sep);
f32 dot1 = vec1.dot(sep);
if (dot1 > -radius && dot1 < searchRadius) {
if (target->isNavi() || (target->isPiki() && static_cast<Piki*>(target)->isPikmin())) {

View File

@ -839,7 +839,7 @@ bool Obj::suckNavi(f32 offset)
Vector3f sep = naviPos - partPos;
InteractSarai suck(this, 100.0f, nullptr);
slot->mOffset = Vector3f(dot(xVec, sep), dot(yVec, sep), dot(zVec, sep));
slot->mOffset = Vector3f(xVec.dot(sep), yVec.dot(sep), zVec.dot(sep));
if (currNavi->stimulate(suck)) {
mSuckedNavis[i] = currNavi;

View File

@ -495,8 +495,8 @@ Piki* Obj::getAttackPiki(int animIdx)
if (piki->isAlive() && piki->isPikmin() && !piki->isStickToMouth()) {
Vector3f pikiPos = piki->getPosition();
Vector3f sep = pikiPos - snakePos;
f32 dotDir = dot(dir, sep); // f1
f32 dotPerpDir = dot(orthoDir, sep); // f2
f32 dotDir = dir.dot(sep); // f1
f32 dotPerpDir = orthoDir.dot(sep); // f2
for (int i = p1; i < p2; i++) {
if (dotDir < maxDotDirs[i] && dotDir > minDotDirs[i] && dotPerpDir < maxDotPerpDirs[i] && dotPerpDir > minDotPerpDirs[i]
&& sep.y < maxYs[i] && sep.y > minYs[i]) {
@ -961,8 +961,8 @@ Navi* Obj::getAttackNavi(int animIdx)
if (navi->isAlive()) {
Vector3f naviPos = navi->getPosition();
Vector3f sep = naviPos - snakePos;
f32 dotDir = dot(dir, sep); // f1
f32 dotPerpDir = dot(orthoDir, sep); // f2
f32 dotDir = dir.dot(sep); // f1
f32 dotPerpDir = orthoDir.dot(sep); // f2
for (int i = p1; i < p2; i++) {
if (dotDir < maxDotDirs[i] && dotDir > minDotDirs[i] && dotPerpDir < maxDotPerpDirs[i] && dotPerpDir > minDotPerpDirs[i]
&& sep.y < maxYs[i] && sep.y > minYs[i]) {

View File

@ -905,8 +905,8 @@ Piki* Obj::getAttackPiki(int animIdx)
if (piki->isAlive() && piki->isPikmin() && !piki->isStickToMouth()) {
Vector3f pikiPos = piki->getPosition();
Vector3f sep = pikiPos - snakePos;
f32 dotDir = dot(dir, sep); // f1
f32 dotPerpDir = dot(orthoDir, sep); // f2
f32 dotDir = dir.dot(sep); // f1
f32 dotPerpDir = orthoDir.dot(sep); // f2
for (int i = p1; i < p2; i++) {
if (dotDir < maxDotDirs[i] && dotDir > minDotDirs[i] && dotPerpDir < maxDotPerpDirs[i] && dotPerpDir > minDotPerpDirs[i]
&& sep.y < maxYs[i] && sep.y > minYs[i]) {
@ -1371,8 +1371,8 @@ Navi* Obj::getAttackNavi(int animIdx)
if (navi->isAlive()) {
Vector3f naviPos = navi->getPosition();
Vector3f sep = naviPos - snakePos;
f32 dotDir = dot(dir, sep); // f1
f32 dotPerpDir = dot(orthoDir, sep); // f2
f32 dotDir = dir.dot(sep); // f1
f32 dotPerpDir = orthoDir.dot(sep); // f2
for (int i = p1; i < p2; i++) {
if (dotDir < maxDotDirs[i] && dotDir > minDotDirs[i] && dotPerpDir < maxDotPerpDirs[i] && dotPerpDir > minDotPerpDirs[i]
&& sep.y < maxYs[i] && sep.y > minYs[i]) {

View File

@ -281,8 +281,8 @@ bool Obj::isAttackable(bool check)
f32 absY = absVal(diff.y);
if (absY < parms->mGeneral.mAttackRadius()) {
Vector3f angle(cosTheta, 0.0f, sinTheta);
if (absVal(dot(angle, diff)) < parms->mGeneral.mAttackRadius()) {
f32 dotProd = dot(dir, diff);
if (absVal(angle.dot(diff)) < parms->mGeneral.mAttackRadius()) {
f32 dotProd = dir.dot(diff);
if (dotProd < ratio && dotProd > 0.0f) {
if (check) {
interactCreature(creature);

View File

@ -133,9 +133,9 @@ Vector3f CullFrustum::getPosition()
zVec.z = mViewMatrix->mMatrix.structView.zz;
Vector3f position;
position.x = dot(tVec, xVec);
position.y = dot(tVec, yVec);
position.z = dot(tVec, zVec);
position.x = tVec.dot(xVec);
position.y = tVec.dot(yVec);
position.z = tVec.dot(zVec);
return position;
}
@ -164,7 +164,7 @@ void CullFrustum::updatePlanes()
planeVec.y = outVec.y;
planeVec.z = outVec.z;
mObjects[0].mNormal = planeVec;
dist = dot(planeVec, posVec);
dist = planeVec.dot(posVec);
mObjects[0].mOffset = dist;
Vec outVec1;
@ -176,7 +176,7 @@ void CullFrustum::updatePlanes()
planeVec1.y = outVec1.y;
planeVec1.z = outVec1.z;
mObjects[1].mNormal = planeVec1;
mObjects[1].mOffset = dot(planeVec1, posVec);
mObjects[1].mOffset = planeVec1.dot(posVec);
Vec outVec2;
Vector3f planeVec2;
@ -187,7 +187,7 @@ void CullFrustum::updatePlanes()
planeVec2.y = outVec2.y;
planeVec2.z = outVec2.z;
mObjects[2].mNormal = planeVec2;
mObjects[2].mOffset = dot(planeVec2, posVec);
mObjects[2].mOffset = planeVec2.dot(posVec);
Vec outVec3;
Vector3f planeVec3;
@ -198,7 +198,7 @@ void CullFrustum::updatePlanes()
planeVec3.y = outVec3.y;
planeVec3.z = outVec3.z;
mObjects[3].mNormal = planeVec3;
mObjects[3].mOffset = dot(planeVec3, posVec);
mObjects[3].mOffset = planeVec3.dot(posVec);
/*
stwu r1, -0xf0(r1)
mflr r0
@ -467,12 +467,12 @@ void Camera::updatePlanes()
mObjects[4].mNormal = Vector3f(-zVec.x, -zVec.y, -zVec.z);
Vector3f farPlaneVec(mObjects[4].mNormal.x, mObjects[4].mNormal.y, mObjects[4].mNormal.z);
Vector3f farVec = zVec * mProjectionFar + pos;
mObjects[4].mOffset = dot(farPlaneVec, farVec);
mObjects[4].mOffset = farPlaneVec.dot(farVec);
mObjects[5].mNormal = Vector3f(-zVec.x, -zVec.y, -zVec.z);
Vector3f nearPlaneVec(mObjects[5].mNormal.x, mObjects[5].mNormal.y, mObjects[5].mNormal.z);
Vector3f nearVec = zVec * mProjectionNear + pos;
mObjects[5].mOffset = dot(nearPlaneVec, farVec);
mObjects[5].mOffset = nearPlaneVec.dot(farVec);
/*
stwu r1, -0x70(r1)
mflr r0

View File

@ -1007,7 +1007,7 @@ void OBB::determineDivPlane(Sys::VertexTable& vertTable, Sys::TriangleTable& tri
currPlane.mNormal.x = currAxis->x;
currPlane.mNormal.y = currAxis->y;
currPlane.mNormal.z = currAxis->z;
currPlane.mOffset = dot(*currAxis, mPosition);
currPlane.mOffset = *currAxis.dot(mPosition);
// loop through all triangles
for (int j = 0; j < mTriIndexList.mCount; j++) {
@ -1039,7 +1039,7 @@ void OBB::determineDivPlane(Sys::VertexTable& vertTable, Sys::TriangleTable& tri
Vector3f correctAxis = mAxes[axisID];
// divPlane has normal = axis with min cuts, and goes through center/position of box
mDivPlane.mNormal = correctAxis;
mDivPlane.mOffset = dot(correctAxis, mPosition);
mDivPlane.mOffset = correctAxis.dot(mPosition);
/*
stwu r1, -0x80(r1)
mflr r0

View File

@ -92,7 +92,7 @@ bool Tube::collide(Sphere& ball, Vector3f& repulsionVec, f32& posRatio)
Vector3f sep = ball.mPosition - mStartPos;
// calculate scalar projection of sep onto tube
f32 scalarProj = dot(axis, sep) / lenTube;
f32 scalarProj = axis.dot(sep) / lenTube;
// calculate perpendicular distance vector between (center of) tube and (center of) ball
Vector3f perpVec = (diff * scalarProj) + mStartPos - ball.mPosition;
@ -318,7 +318,7 @@ f32 Tube::getPosRatio(const Vector3f& point)
Vector3f sep = point - mStartPos;
// calculate scalar projection of sep onto tube
return dot(axis, sep) / mag;
return axis.dot(sep) / mag;
}
/**
@ -441,7 +441,7 @@ bool Sphere::intersect(Edge& edge, f32& t)
Vector3f sep(mPosition.x - edge.mStartPos.x, mPosition.y - edge.mStartPos.y, mPosition.z - edge.mStartPos.z);
// set t = scalar projection of sep onto edge
t = dot(sep, edgeVec);
t = sep.dot(edgeVec);
// if we're before edge (t < 0) or past edge (t > edgeLen), no intersection
if ((t < 0.0f) || (t > edgeLen)) {
@ -500,7 +500,7 @@ bool Sphere::intersect(Edge& edge, f32& t, Vector3f& intersectPoint)
Vector3f sep(intersectPoint.x - edge.mStartPos.x, intersectPoint.y - edge.mStartPos.y, intersectPoint.z - edge.mStartPos.z);
// set t = scalar projection of sep onto edge
t = dot(sep, edgeVec);
t = sep.dot(edgeVec);
// if we're before edge (t < 0) or past edge (t > edgeLen), no intersection
if ((t < 0.0f) || (t > edgeLen)) {
@ -545,7 +545,7 @@ bool Sphere::intersect(Edge& edge, f32& t, Vector3f& repulsionVec, f32& strength
Vector3f startSep(mPosition.x - edge.mStartPos.x, mPosition.y - edge.mStartPos.y, mPosition.z - edge.mStartPos.z);
// get scalar projection of startSep onto edge
t = dot(startSep, edgeVec);
t = startSep.dot(edgeVec);
// if we're 'before' edge (t < 0) or 'beyond' edge (t > edgeLen), just check end points
if ((t < 0.0f) || (t > edgeLen)) {
@ -808,7 +808,7 @@ bool Triangle::intersect(Edge& edge, f32 cutoff, Vector3f& intersectionPoint)
Vector3f triPlaneNormal(mTrianglePlane.mNormal);
f32 scalarProj = dot(triPlaneNormal, edgeVec);
f32 scalarProj = triPlaneNormal.dot(edgeVec);
// if edge has no length, cannot intersect
if (0.0f == edgeLen) {
@ -826,12 +826,12 @@ bool Triangle::intersect(Edge& edge, f32 cutoff, Vector3f& intersectionPoint)
for (int i = 0; i < 3; i++) {
// project normal onto edge
Vector3f edgePlaneNormal(mEdgePlanes[i].mNormal);
f32 edgePlaneProj = dot(edgePlaneNormal, edgeVec);
f32 edgePlaneProj = edgePlaneNormal.dot(edgeVec);
// check that projection isn't vanishingly small
if (FABS(edgePlaneProj) > 0.01f) {
// check we have an intersection point
f32 edgePlaneRatio = (mEdgePlanes[i].mOffset - dot(edgePlaneNormal, edge.mStartPos)) / edgePlaneProj;
f32 edgePlaneRatio = (mEdgePlanes[i].mOffset - edgePlaneNormal.dot(edge.mStartPos)) / edgePlaneProj;
if ((edgePlaneRatio > -ratio) && (edgePlaneRatio < (1 + ratio))) {
// get intersection point
Vector3f projVec = edgeVec * edgePlaneRatio;
@ -853,7 +853,7 @@ bool Triangle::intersect(Edge& edge, f32 cutoff, Vector3f& intersectionPoint)
// edge not (close to) perpendicular, can just check triangle plane itself
// check if we have an intersection point
f32 triPlaneRatio = (mTrianglePlane.mOffset - dot(triPlaneNormal, edge.mStartPos)) / scalarProj;
f32 triPlaneRatio = (mTrianglePlane.mOffset - triPlaneNormal.dot(edge.mStartPos)) / scalarProj;
if ((triPlaneRatio < -ratio) || (triPlaneRatio > (1 + ratio))) {
// we don't
return false;
@ -889,7 +889,7 @@ bool Sys::Triangle::intersect(Sys::Edge& edge, f32 cutoff, Vector3f& intersectio
Vector3f triPlaneNormal(mTrianglePlane.mNormal);
f32 scalarProj = dot(triPlaneNormal, edgeVec);
f32 scalarProj = triPlaneNormal.dot(edgeVec);
// if edge has no length, cannot intersect
if (0.0f == edgeLen) {
@ -907,12 +907,12 @@ bool Sys::Triangle::intersect(Sys::Edge& edge, f32 cutoff, Vector3f& intersectio
for (int i = 0; i < 3; i++) {
// project normal onto edge
Vector3f edgePlaneNormal(mEdgePlanes[i].mNormal);
f32 edgePlaneProj = dot(edgePlaneNormal, edgeVec);
f32 edgePlaneProj = edgePlaneNormal.dot(edgeVec);
// check that projection isn't vanishingly small
if (FABS(edgePlaneProj) > 0.01f) {
// check we have an intersection point
f32 edgePlaneRatio = (mEdgePlanes[i].mOffset - dot(edgePlaneNormal, edge.mStartPos)) / edgePlaneProj;
f32 edgePlaneRatio = (mEdgePlanes[i].mOffset - edgePlaneNormal.dot(edge.mStartPos)) / edgePlaneProj;
if ((edgePlaneRatio > -ratio) && (edgePlaneRatio < (1 + ratio))) {
// get intersection point
Vector3f projVec = edgeVec * edgePlaneRatio;
@ -936,7 +936,7 @@ bool Sys::Triangle::intersect(Sys::Edge& edge, f32 cutoff, Vector3f& intersectio
// edge not (close to) perpendicular, can just check triangle plane itself
// check if we have an intersection point
f32 triPlaneRatio = (mTrianglePlane.mOffset - dot(triPlaneNormal, edge.mStartPos)) / scalarProj;
f32 triPlaneRatio = (mTrianglePlane.mOffset - triPlaneNormal.dot(edge.mStartPos)) / scalarProj;
if ((triPlaneRatio < -ratio) || (triPlaneRatio > (1 + ratio))) {
// we don't
return false;
@ -3796,7 +3796,7 @@ void TriIndexList::getMinMax(VertexTable& vertTable, TriangleTable& triTable, Ve
vertices[2] = vertTable.mObjects[currTri->mVertices[2]];
for (int j = 0; j < 3; j++) {
f32 testVal = dot(vec1, vertices[j] - vec2);
f32 testVal = vec1.dot(vertices[j] - vec2);
if (testVal > max) {
max = testVal;
}

View File

@ -1943,7 +1943,7 @@ void Graphics::drawCone(Vector3f& start, Vector3f& end, f32 inAngle, int limit)
Vector3f xVec; // f3, f4, f5
Vector3f yVec; // f6, f7, f8
Vector3f yAxis(0.0f, 1.0f, 0.0f);
if (FABS(dot(sep, yAxis)) < 1.0E-7f) {
if (FABS(sep.dot(yAxis)) < 1.0E-7f) {
xVec = cross(yAxis, sep);
xVec.normalise();