mirror of
https://github.com/encounter/Petari.git
synced 2026-03-30 11:34:15 -07:00
e8794553c5
DiskTorusGravity.o Matched all remaining functions in the above files and both forms of `TRot3f::mult33`. The `mult33` functions and `mult33inline` should be returned to since they likely are the same function. As of right now, `mult33inline` is used to define the single argument form of `mult33` but not the double argument form. Added some extra paired single TVec3f inlines Provided comments explaining what `MR::makeAxisVerticalZX` and `MR::calcPerpendicularFootToLineInside` do
56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
#include "Game/Gravity.hpp"
|
|
#include "Game/Util.hpp"
|
|
|
|
WireGravity::WireGravity() {
|
|
mCount = 0;
|
|
}
|
|
|
|
void WireGravity::setPointListSize(u32 numPoints) {
|
|
mPoints.init(numPoints);
|
|
mCount = 0;
|
|
}
|
|
|
|
void WireGravity::addPoint(const TVec3f &rPoint) {
|
|
mPoints.mArr[mCount++] = rPoint;
|
|
}
|
|
|
|
bool WireGravity::calcOwnGravityVector(TVec3f *pDest, f32 *pScalar, const TVec3f &rPos) const {
|
|
|
|
f32 distance = -1.0f;
|
|
TVec3f pointOfAttraction;
|
|
for(s32 i = 0; i < mCount - 1; i++) {
|
|
|
|
// unused
|
|
TVec3f wireBegin(mPoints.mArr[i]);
|
|
TVec3f wireEnd(mPoints.mArr[i + 1]);
|
|
|
|
|
|
TVec3f positionProjectedOntoWire;
|
|
MR::calcPerpendicFootToLineInside(&positionProjectedOntoWire, rPos, mPoints.mArr[i], mPoints.mArr[i + 1]);
|
|
|
|
f32 squareDistance = rPos.squareDistancePS(positionProjectedOntoWire);
|
|
if(squareDistance < distance || distance < 0.0f) {
|
|
|
|
pointOfAttraction = positionProjectedOntoWire;
|
|
distance = squareDistance;
|
|
|
|
}
|
|
}
|
|
|
|
if(!isInRangeSquare(distance)) {
|
|
return false;
|
|
}
|
|
|
|
if(distance >= 0.0f) {
|
|
|
|
TVec3f gravity(pointOfAttraction);
|
|
gravity.subInline4(rPos);
|
|
|
|
MR::separateScalarAndDirection(pScalar, pDest, gravity);
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|