mirror of
https://github.com/doldecomp/sms.git
synced 2026-11-07 09:06:00 -10:00
TVec3 but no UB (#382)
* TVec3 but no UB * formatting * TMario::pulling closer * Small fixes
This commit is contained in:
1 parent
3e70d1ba1f
commit
d9521bbb35
25 files changed
+180
-183
No files matched your search
@@ -358,10 +358,12 @@ void CLBPolarToCross(const Vec& origin, Vec* out, f32 radius, s16 vAngle,
|
||||
void CLBRevisionLookatByAngleX(s16 vAngleMin, s16 vAngleMax, const Vec& origin,
|
||||
Vec* inOut);
|
||||
|
||||
void CLBRotatePosAndUp(s16, s16, const JGeometry::TVec3<f32>&,
|
||||
const JGeometry::TVec3<f32>&,
|
||||
const JGeometry::TVec3<f32>&, JGeometry::TVec3<f32>*,
|
||||
JGeometry::TVec3<f32>*);
|
||||
void CLBRotatePosAndUp(s16 pitch_angle, s16 yaw_angle,
|
||||
const JGeometry::TVec3<f32>& pitch_axis,
|
||||
const JGeometry::TVec3<f32>& yaw_axis,
|
||||
const JGeometry::TVec3<f32>& pivot,
|
||||
JGeometry::TVec3<f32>* in_out_pos,
|
||||
JGeometry::TVec3<f32>* in_out_up);
|
||||
|
||||
inline void CLBScreenFPosToSPos(JGeometry::TVec2<s16>* out,
|
||||
const JGeometry::TVec2<f32>& in)
|
||||
|
||||
@@ -116,6 +116,12 @@ public:
|
||||
}
|
||||
const TPathNode& getCurrentTarget() const { return mCurrentTarget; }
|
||||
const TPathNode& getGoal() const { return mGoal; }
|
||||
f32 getCurrentTargetDistance() const
|
||||
{
|
||||
JGeometry::TVec3<f32> delta = mCurrentTarget.getPoint();
|
||||
delta -= mPosition;
|
||||
return delta.length();
|
||||
}
|
||||
f32 getGoalDistance() const
|
||||
{
|
||||
JGeometry::TVec3<f32> delta = mGoal.getPoint();
|
||||
|
||||
@@ -121,7 +121,9 @@ struct TBGWallCheckRecord {
|
||||
// fabricated
|
||||
const JGeometry::TVec3<f32>& getCenter() const { return mCenter; }
|
||||
int getMaxResults() const { return mMaxResults; }
|
||||
TBGCheckData* getResultWall(int index) const { return mResultWalls[index]; }
|
||||
|
||||
public:
|
||||
/* 0x0 */ JGeometry::TVec3<f32> mCenter;
|
||||
/* 0xC */ f32 mRadius;
|
||||
/* 0x10 */ int mMaxResults;
|
||||
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
if (1.0f - fVar13 <= TUtil<f32>::epsilon()) {
|
||||
fVar92 = 1.0f - param_2;
|
||||
} else {
|
||||
fVar11 = acosf(fVar13);
|
||||
fVar11 = acosf(fVar13);
|
||||
f32 fVar12 = sinf(fVar11);
|
||||
|
||||
fVar92 = sinf((1.0f - param_2) * fVar11) / fVar12;
|
||||
@@ -204,9 +204,8 @@ public:
|
||||
if (bVar9)
|
||||
fVar93 = -fVar93;
|
||||
|
||||
this->set(
|
||||
fVar92 * q1.x + fVar93 * q2.x, fVar92 * q1.y + fVar93 * q2.y,
|
||||
fVar92 * q1.z + fVar93 * q2.z, fVar92 * q1.w + fVar93 * q2.w);
|
||||
this->set(fVar92 * q1.x + fVar93 * q2.x, fVar92 * q1.y + fVar93 * q2.y,
|
||||
fVar92 * q1.z + fVar93 * q2.z, fVar92 * q1.w + fVar93 * q2.w);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -67,18 +67,18 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
// fabricated and fake and UB but it makes things match??
|
||||
friend const TVec3& operator-(TVec3 fst, const TVec3& snd)
|
||||
friend TVec3 operator-(const TVec3& fst, const TVec3& snd)
|
||||
{
|
||||
fst -= snd;
|
||||
return fst;
|
||||
TVec3 result = fst;
|
||||
result -= snd;
|
||||
return result;
|
||||
}
|
||||
|
||||
// fabricated and fake and UB but it makes things match??
|
||||
friend const TVec3& operator+(TVec3 fst, const TVec3& snd)
|
||||
friend TVec3 operator+(const TVec3& fst, const TVec3& snd)
|
||||
{
|
||||
fst += snd;
|
||||
return fst;
|
||||
TVec3 result = fst;
|
||||
result += snd;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -217,30 +217,32 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
// fabricated and fake and UB but it makes things match??
|
||||
friend const TVec3& operator-(TVec3 fst, const TVec3& snd)
|
||||
friend TVec3 operator-(const TVec3& fst, const TVec3& snd)
|
||||
{
|
||||
fst -= snd;
|
||||
return fst;
|
||||
TVec3 result = fst;
|
||||
result -= snd;
|
||||
return result;
|
||||
}
|
||||
|
||||
// fabricated and fake and UB but it makes things match??
|
||||
friend const TVec3& operator+(TVec3 fst, const TVec3& snd)
|
||||
friend TVec3 operator+(const TVec3& fst, const TVec3& snd)
|
||||
{
|
||||
fst += snd;
|
||||
return fst;
|
||||
TVec3 result = fst;
|
||||
result += snd;
|
||||
return result;
|
||||
}
|
||||
|
||||
// @fabricated
|
||||
friend TVec3 operator*(TVec3 fst, f32 snd)
|
||||
friend TVec3 operator*(const TVec3& fst, f32 snd)
|
||||
{
|
||||
fst *= snd;
|
||||
return fst;
|
||||
TVec3 result = fst;
|
||||
result *= snd;
|
||||
return result;
|
||||
}
|
||||
friend TVec3 operator/(TVec3 fst, f32 snd)
|
||||
|
||||
friend TVec3 operator/(const TVec3& fst, f32 snd)
|
||||
{
|
||||
fst /= snd;
|
||||
return fst;
|
||||
TVec3 result = fst;
|
||||
result /= snd;
|
||||
return result;
|
||||
}
|
||||
|
||||
f32 dot(const TVec3& other) const
|
||||
|
||||
+1
-3
@@ -209,12 +209,10 @@ JGeometry::TVec3<f32> TBoidLeader::calcForces(const TBoid* boid) const
|
||||
force.normalize();
|
||||
|
||||
if (0.0f < mFleeRadius) {
|
||||
f32 tmp = mFleeRadius;
|
||||
|
||||
JGeometry::TVec3<f32> away = boid->mPosition;
|
||||
away -= mFleeTarget.getPoint();
|
||||
f32 d2 = away.squared();
|
||||
if (0.0f < d2 && d2 < tmp * tmp) {
|
||||
if (0.0f < d2 && d2 < mFleeRadius * mFleeRadius) {
|
||||
away.setLength(mFleeStrength);
|
||||
force = away;
|
||||
}
|
||||
|
||||
+16
-17
@@ -131,26 +131,25 @@ void CLBRevisionLookatByAngleX(s16 vAngleMin, s16 vAngleMax, const Vec& origin,
|
||||
CLBPolarToCross(origin, inOut, radius, vAngle, hAngle);
|
||||
}
|
||||
|
||||
void CLBRotatePosAndUp(s16 sAngle1, s16 sAngle2,
|
||||
const JGeometry::TVec3<f32>& axis1,
|
||||
const JGeometry::TVec3<f32>& axis2,
|
||||
const JGeometry::TVec3<f32>& offset,
|
||||
JGeometry::TVec3<f32>* param_6,
|
||||
JGeometry::TVec3<f32>* param_7)
|
||||
|
||||
void CLBRotatePosAndUp(s16 pitch_angle, s16 yaw_angle,
|
||||
const JGeometry::TVec3<f32>& pitch_axis,
|
||||
const JGeometry::TVec3<f32>& yaw_axis,
|
||||
const JGeometry::TVec3<f32>& pivot,
|
||||
JGeometry::TVec3<f32>* in_out_pos,
|
||||
JGeometry::TVec3<f32>* in_out_up)
|
||||
{
|
||||
f32 angle1 = sAngle1 * SHORTANGLE_TO_DEGREES * DEGREES_TO_RADIANS;
|
||||
f32 angle2 = sAngle2 * SHORTANGLE_TO_DEGREES * DEGREES_TO_RADIANS;
|
||||
f32 pitch = pitch_angle * SHORTANGLE_TO_DEGREES * DEGREES_TO_RADIANS;
|
||||
f32 yaw = yaw_angle * SHORTANGLE_TO_DEGREES * DEGREES_TO_RADIANS;
|
||||
|
||||
JGeometry::TVec3<f32> v1 = *param_6 - offset;
|
||||
RotateAboutAxis(axis1, -angle1, &v1);
|
||||
*param_6 = offset + v1;
|
||||
RotateAboutAxis(axis1, -angle1, param_7);
|
||||
JGeometry::TVec3<f32> relativePos = *in_out_pos - pivot;
|
||||
RotateAboutAxis(pitch_axis, -pitch, &relativePos);
|
||||
*in_out_pos = pivot + relativePos;
|
||||
RotateAboutAxis(pitch_axis, -pitch, in_out_up);
|
||||
|
||||
JGeometry::TVec3<f32> v2 = *param_6 - offset;
|
||||
RotateAboutAxis(axis2, -angle2, &v2);
|
||||
*param_6 = offset + v2;
|
||||
RotateAboutAxis(axis2, -angle2, param_7);
|
||||
relativePos = *in_out_pos - pivot;
|
||||
RotateAboutAxis(yaw_axis, -yaw, &relativePos);
|
||||
*in_out_pos = pivot + relativePos;
|
||||
RotateAboutAxis(yaw_axis, -yaw, in_out_up);
|
||||
}
|
||||
|
||||
bool CLBIsPointInCube(const Vec& param_1, const Vec& param_2,
|
||||
|
||||
@@ -47,8 +47,8 @@ void BHSCalcRevisionDistXZByRotateZ(f32 direction, f32 degreeZ,
|
||||
{
|
||||
JGeometry::TVec2<f32> offset(revisionScale * degreeZ, 0.0f);
|
||||
s16 angle = CLBDegToShortAngle(direction);
|
||||
f32 s = JMASSin(angle);
|
||||
f32 c = JMASCos(angle);
|
||||
f32 s = JMASSin(angle);
|
||||
*x = offset.x * c + offset.y * s;
|
||||
*z = -offset.x * s + offset.y * c;
|
||||
}
|
||||
|
||||
@@ -145,8 +145,7 @@ void TEMario::checkCollision()
|
||||
for (s32 i = 0; i < mColCount; ++i) {
|
||||
switch (mCollisions[i]->mActorType) {
|
||||
case ACTOR_TYPE_MARIO: {
|
||||
if (JGeometry::TVec3<f32>(mPosition - mCollisions[i]->getPosition())
|
||||
.length()
|
||||
if ((mPosition - mCollisions[i]->getPosition()).length()
|
||||
< mEnemyMario->mAttackRange) {
|
||||
mCollisions[i]->receiveMessage(this, HIT_MESSAGE_ATTACK);
|
||||
}
|
||||
@@ -154,9 +153,7 @@ void TEMario::checkCollision()
|
||||
|
||||
case ACTOR_TYPE_GESO_SURF_BOARD: {
|
||||
if (!mEnemyMario->checkStatusType(MARIO_STATUS_FLAG_UNK10000)) {
|
||||
if (JGeometry::TVec3<f32>(mCollisions[i]->getPosition()
|
||||
- mPosition)
|
||||
.length()
|
||||
if ((mCollisions[i]->getPosition() - mPosition).length()
|
||||
< (mCollisions[i]->getAttackRadius()
|
||||
+ mEnemyMario->getDamageRadius())) {
|
||||
mEnemyMario->changePlayerStatus(MARIO_STATUS_SURF, 0,
|
||||
|
||||
+8
-17
@@ -496,14 +496,15 @@ void TSpineEnemy::zigzagToCurPathNode(f32 march_speed, f32 turn_speed,
|
||||
|
||||
f32 f29 = angle * unk124->unk10;
|
||||
|
||||
f32 dVar9 = (mCurrentTarget.getPoint() - mPosition).length();
|
||||
f32 dVar9 = getCurrentTargetDistance();
|
||||
|
||||
f32 dVar13 = MsWrap(dVar9, 0.0f, cycle);
|
||||
|
||||
dVar13 *= 360.0f * (1.0f / cycle);
|
||||
dVar13 += getPhaseShift();
|
||||
|
||||
f29 *= MsSin(dVar13);
|
||||
cycle = 360.0f * (1.0f / cycle);
|
||||
f32 phaseShift = getPhaseShift();
|
||||
dVar13 *= cycle;
|
||||
phaseShift = dVar13 + phaseShift;
|
||||
f29 *= MsSin(phaseShift);
|
||||
|
||||
JGeometry::TVec3<f32> local_58 = mCurrentTarget.getPoint();
|
||||
local_58 -= mPosition;
|
||||
@@ -512,17 +513,7 @@ void TSpineEnemy::zigzagToCurPathNode(f32 march_speed, f32 turn_speed,
|
||||
f32 fVar1 = MsAngleDiff(dVar12, mRotation.y);
|
||||
f32 fVar2 = fVar1;
|
||||
|
||||
f32 fVar3;
|
||||
if (turn_speed >= 90.0f) {
|
||||
fVar3 = 0.0f;
|
||||
} else {
|
||||
f32 s = MsSin(turn_speed);
|
||||
if (s == 0.0f) {
|
||||
fVar3 = 100000.0f;
|
||||
} else {
|
||||
fVar3 = march_speed * MsSin(90.0f - turn_speed * 0.5f) / s;
|
||||
}
|
||||
}
|
||||
f32 fVar3 = calcMinimumTurnRadius(march_speed, turn_speed);
|
||||
|
||||
if (dVar9 > fVar3 * 2.0f) {
|
||||
if (fVar1 > 0.0f) {
|
||||
@@ -551,7 +542,7 @@ void TSpineEnemy::doShortCut()
|
||||
if (mGoalPath.size() <= 0)
|
||||
return;
|
||||
|
||||
if ((mCurrentTarget.getPoint() - mPosition).length() < getBodyRadius()) {
|
||||
if (getCurrentTargetDistance() < getBodyRadius()) {
|
||||
switchNextGoalPathNode();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ void TEnemyAttachment::bind()
|
||||
TBGWallCheckRecord local_48(local_1C.x, local_1C.y + mHeadHeight,
|
||||
local_1C.z, 2.0f * mBodyRadius, 1, 0);
|
||||
if (gpMap->isTouchedWallsAndMoveXZ(&local_48))
|
||||
behaveToHitWall(local_48.mResultWalls[0]);
|
||||
behaveToHitWall(local_48.getResultWall(0));
|
||||
|
||||
mPosition = local_1C;
|
||||
mPositionDelta = local_1C - mPosition;
|
||||
|
||||
@@ -1112,7 +1112,7 @@ void TEnemyMario::findRunAwayNearestNode()
|
||||
JGeometry::TVec3<f32> point;
|
||||
TGraphWeb* graph = mEMario->getTracer()->getGraph();
|
||||
graph->getGraphNode(i).getPoint(&point);
|
||||
f32 distance = JGeometry::TVec3<f32>(point - mPosition).length();
|
||||
f32 distance = (point - mPosition).length();
|
||||
if (distance < nearestDistance) {
|
||||
secondDistance = nearestDistance;
|
||||
secondIndex = nearestIndex;
|
||||
@@ -1127,8 +1127,8 @@ void TEnemyMario::findRunAwayNearestNode()
|
||||
}
|
||||
}
|
||||
|
||||
if (JGeometry::TVec3<f32>(mPosition - nearestPoint).length()
|
||||
< JGeometry::TVec3<f32>(mPosition - secondPoint).length()) {
|
||||
if ((mPosition - nearestPoint).length()
|
||||
< (mPosition - secondPoint).length()) {
|
||||
mRunAwayNodeIndex = nearestIndex;
|
||||
} else {
|
||||
mRunAwayNodeIndex = secondIndex;
|
||||
|
||||
+10
-6
@@ -226,14 +226,18 @@ void TWalker::bind(TLiveActor* param_1)
|
||||
f32 dVar18
|
||||
= calcFarthestVertex(pTVar14, enemy->mPosition, local_94);
|
||||
f32 fVar4 = (enemy->getWallRadius()) * 2.0f + dVar18;
|
||||
|
||||
// TODO: the vector arithmetic is still wrong here!
|
||||
if (enemy->mGoalPath.empty()) {
|
||||
enemy->pushGoalPathNode(enemy->mPosition
|
||||
- normal * enemy->getWallRadius()
|
||||
+ local_94 * fVar4);
|
||||
JGeometry::TVec3<f32> tangentOffset = local_94 * fVar4;
|
||||
JGeometry::TVec3<f32> wallPoint;
|
||||
wallPoint = enemy->mPosition - normal * enemy->getWallRadius();
|
||||
enemy->pushGoalPathNode(wallPoint + tangentOffset);
|
||||
} else {
|
||||
enemy->mCurrentTarget = TPathNode(
|
||||
enemy->mPosition - normal * enemy->getWallRadius()
|
||||
+ local_94 * fVar4);
|
||||
JGeometry::TVec3<f32> tangentOffset = local_94 * fVar4;
|
||||
JGeometry::TVec3<f32> wallPoint;
|
||||
wallPoint = enemy->mPosition - normal * enemy->getWallRadius();
|
||||
enemy->mCurrentTarget = TPathNode(wallPoint + tangentOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -344,8 +344,8 @@ f32 TMapWire::getPosInWire(const JGeometry::TVec3<f32>& point) const
|
||||
JGeometry::TVec3<f32> perpPoint
|
||||
= MsPerpendicFootToLineR(flatStart, flatEnd, point);
|
||||
|
||||
f32 totalLength = JGeometry::TVec3<f32>(flatEnd - flatStart).length();
|
||||
f32 partialLength = JGeometry::TVec3<f32>(perpPoint - flatStart).length();
|
||||
f32 totalLength = (flatEnd - flatStart).length();
|
||||
f32 partialLength = (perpPoint - flatStart).length();
|
||||
return partialLength / totalLength;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,8 +44,7 @@ f32 TMapWireActor::getPosInWire() const
|
||||
|
||||
JGeometry::TVec3<f32> foot = MsPerpendicFootToLineR(start, end, mPosition);
|
||||
|
||||
return JGeometry::TVec3<f32>(foot - start).length()
|
||||
/ JGeometry::TVec3<f32>(end - start).length();
|
||||
return (foot - start).length() / (end - start).length();
|
||||
}
|
||||
|
||||
void TMapWireActor::getTipPoints(JGeometry::TVec3<f32>* start,
|
||||
|
||||
@@ -796,7 +796,7 @@ void TPinnaCoaster::control()
|
||||
MtxPtr mtx = getModel()->getAnmMtx(0);
|
||||
mPosition.set(mtx[0][3], mtx[1][3], mtx[2][3]);
|
||||
|
||||
f32 speed = JGeometry::TVec3<f32>(mPosition - unk140).length();
|
||||
f32 speed = (mPosition - unk140).length();
|
||||
if (switchSnd)
|
||||
SMSGetMSound()->startSoundActorWithInfo(MSD_SE_OBJ_JET_COASTER,
|
||||
&mPosition, nullptr, speed, 0,
|
||||
|
||||
+39
-36
@@ -116,49 +116,52 @@ void TMapObjPlane::updateCheckData(int x, int z)
|
||||
mCollision->getCheckData(x, z, 1)->setVertex(local_58, local_4c, local_40);
|
||||
}
|
||||
|
||||
// fabricated
|
||||
static inline void calcTriangleNormal(JGeometry::TVec3<f32>& normal,
|
||||
const JGeometry::TVec3<f32>& a,
|
||||
const JGeometry::TVec3<f32>& b,
|
||||
const JGeometry::TVec3<f32>& c)
|
||||
{
|
||||
JGeometry::TVec3<f32> edge1;
|
||||
JGeometry::TVec3<f32> edge2;
|
||||
edge1.sub(b, c);
|
||||
edge2.set(a);
|
||||
edge2.sub(b);
|
||||
normal.cross(edge2, edge1);
|
||||
normal.normalize();
|
||||
}
|
||||
|
||||
void TMapObjPlane::calcNrm(int x, int z)
|
||||
{
|
||||
if (x < 0 || mExtents <= x || z < 0 || mExtents <= z)
|
||||
return;
|
||||
|
||||
f32 fVar1 = unkFC;
|
||||
f32 fVar7 = -unkFC;
|
||||
JGeometry::TVec3<f32> center(0.0f, heightAt(x, z), 0.0f);
|
||||
int northZ = MsWrap(z - 1, 0, mExtents);
|
||||
JGeometry::TVec3<f32> north(0.0f, heightAt(x, northZ), -unkFC);
|
||||
int southZ = MsWrap(z + 1, 0, mExtents);
|
||||
JGeometry::TVec3<f32> south(0.0f, heightAt(x, southZ), unkFC);
|
||||
int westX = MsWrap(x - 1, 0, mExtents);
|
||||
JGeometry::TVec3<f32> west(-unkFC, heightAt(westX, z), 0.0f);
|
||||
int eastX = MsWrap(x + 1, 0, mExtents);
|
||||
JGeometry::TVec3<f32> east(unkFC, heightAt(eastX, z), 0.0f);
|
||||
|
||||
f32 h00 = heightAt(x, z);
|
||||
f32 h0N = heightAt(x, MsWrap(z - 1, 0, mExtents));
|
||||
f32 h0P = heightAt(x, MsWrap(z + 1, 0, mExtents));
|
||||
f32 hN0 = heightAt(MsWrap(x - 1, 0, mExtents), z);
|
||||
f32 hP0 = heightAt(MsWrap(x + 1, 0, mExtents), z);
|
||||
JGeometry::TVec3<f32> northWest;
|
||||
JGeometry::TVec3<f32> northEast;
|
||||
JGeometry::TVec3<f32> southWest;
|
||||
JGeometry::TVec3<f32> southEast;
|
||||
calcTriangleNormal(northWest, north, west, center);
|
||||
calcTriangleNormal(northEast, east, north, center);
|
||||
calcTriangleNormal(southWest, west, south, center);
|
||||
calcTriangleNormal(southEast, south, east, center);
|
||||
|
||||
// TODO: figure out the inlines here. Definitely some subtracting and
|
||||
// cross producting is occurring.
|
||||
|
||||
JGeometry::TVec3<f32> local_9c;
|
||||
local_9c.x = (h0N - hN0) * 0.0f - (fVar7 - 0.0f) * (hN0 - h00);
|
||||
local_9c.y = (fVar7 - 0.0f) * (fVar7 - 0.0f) - (0.0f - fVar7) * 0.0f;
|
||||
local_9c.z = (0.0f - fVar7) * (hN0 - h00) - (h0N - hN0) * (fVar7 - 0.0f);
|
||||
local_9c.normalize();
|
||||
|
||||
JGeometry::TVec3<f32> local_a8;
|
||||
local_a8.x = (hP0 - h0N) * (fVar7 - 0.0f) - (0.0f - fVar7) * (h0N - h00);
|
||||
local_a8.z = (fVar1 - 0.0f) * (h0N - h00) - (hP0 - h0N) * 0.0f;
|
||||
local_a8.y = (0.0f - fVar7) * 0.0f - (fVar1 - 0.0f) * (fVar7 - 0.0f);
|
||||
local_a8.normalize();
|
||||
|
||||
JGeometry::TVec3<f32> local_b4;
|
||||
local_b4.x = (hN0 - h0P) * (fVar1 - 0.0f) - (0.0f - fVar1) * (h0P - h00);
|
||||
local_b4.z = (fVar7 - 0.0f) * (h0P - h00) - (hN0 - h0P) * 0.0f;
|
||||
local_b4.y = (0.0f - fVar1) * 0.0f - (fVar7 - 0.0f) * (fVar1 - 0.0f);
|
||||
local_b4.normalize();
|
||||
|
||||
JGeometry::TVec3<f32> local_c0;
|
||||
local_c0.x = (h0P - hP0) * 0.0f - h0N * (hP0 - h00);
|
||||
local_c0.y = h0N * h0N - (0.0f - fVar1) * 0.0f;
|
||||
local_c0.z = (0.0f - fVar1) * (hP0 - h00) - (h0P - hP0) * h0N;
|
||||
local_c0.normalize();
|
||||
|
||||
mNormalMap[x + z * mExtents] = local_9c + local_a8 + local_b4 + local_c0;
|
||||
mNormalMap[x + z * mExtents].scale(0.25f);
|
||||
JGeometry::TVec3<f32>& normal = mNormalMap[x + z * mExtents];
|
||||
JGeometry::TVec3<f32> northNormal;
|
||||
northNormal = northWest + northEast;
|
||||
JGeometry::TVec3<f32> partialNormal;
|
||||
partialNormal = northNormal + southWest;
|
||||
normal = partialNormal + southEast;
|
||||
normal.scale(0.25f);
|
||||
}
|
||||
|
||||
void TMapObjPlane::movement() { }
|
||||
|
||||
+16
-10
@@ -5,11 +5,20 @@
|
||||
#include <NPC/NpcNerve.hpp>
|
||||
#include <Camera/cameralib.hpp>
|
||||
|
||||
// fabricated
|
||||
static inline f32 squareDistanceXZ(const JGeometry::TVec3<f32>& point,
|
||||
const JGeometry::TVec3<f32>& origin)
|
||||
{
|
||||
return JGeometry::TVec3<f32>(point.x - origin.x, 0.0f, point.z - origin.z)
|
||||
.squared();
|
||||
}
|
||||
|
||||
bool TBaseNPC::isCanWalk() const
|
||||
{
|
||||
bool result = true;
|
||||
// TODO: TVec3::sub should use set internally I guess?
|
||||
if ((mCurrentTarget.getPoint() - mPosition).squared() < CLBSquared(10.0f))
|
||||
bool result = true;
|
||||
JGeometry::TVec3<f32> point = mCurrentTarget.getPoint();
|
||||
f32 squareToGoal = squareDistanceXZ(point, mPosition);
|
||||
if (squareToGoal < CLBSquared(10.0f))
|
||||
result = false;
|
||||
return result;
|
||||
}
|
||||
@@ -28,14 +37,11 @@ void TBaseNPC::execWalk(bool param_1)
|
||||
if (checkActionFlag(NPC_ACTION_RUN))
|
||||
fVar1 = 6.0f;
|
||||
|
||||
SMS_GoRotate(mPosition, getCurrentTarget().getPoint(), fVar1, &mRotation.y);
|
||||
SMS_GoRotate(mPosition, getCurrentTarget().getPoint(), fVar1,
|
||||
&mRotation.y);
|
||||
|
||||
// TODO: vector math is borked
|
||||
JGeometry::TVec3<f32> local_54 = getCurrentTarget().getPoint();
|
||||
local_54 -= mPosition;
|
||||
JGeometry::TVec3<f32> copy = local_54;
|
||||
|
||||
f32 angle = MsGetRotFromZaxisY(copy);
|
||||
Vec v = getCurrentTarget().getPoint() - mPosition;
|
||||
f32 angle = MsGetRotFromZaxisY(v);
|
||||
if (MsWrap(abs(mRotation.y - angle), 0.0f, 360.0f) < 0.001f)
|
||||
offUnk1DA(UNK1DA_FLAG_UNK1);
|
||||
|
||||
|
||||
@@ -152,11 +152,7 @@ void TMarioCap::perform(u32 cue, JDrama::TGraphics* graphics)
|
||||
|
||||
bool doTremble = false;
|
||||
|
||||
// Missing a copy of TVec3, i still suspect that operations should
|
||||
// do a copy
|
||||
f32 distance = JGeometry::TVec3<f32>(mMario->mPosition
|
||||
- mMario->mPrevPosition)
|
||||
.length();
|
||||
f32 distance = (mMario->mPosition - mMario->mPrevPosition).length();
|
||||
if (mMario->mStatus == MARIO_STATUS_SURF && distance > 20.0f) {
|
||||
doTremble = true;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ bool TMario::isTakeSituation(THitActor* object)
|
||||
return false;
|
||||
}
|
||||
|
||||
f32 dist = JGeometry::TVec3<f32>(object->mPosition - mPosition).length();
|
||||
f32 dist = (object->mPosition - mPosition).length();
|
||||
if (dist > mAttackRadius + object->getDamageRadius()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -740,7 +740,7 @@ void TMario::sleepingEffectKill()
|
||||
|
||||
void TMario::toroccoEffect()
|
||||
{
|
||||
f32 dist = JGeometry::TVec3<f32>(mPosition - mToroccoPos).length();
|
||||
f32 dist = (mPosition - mToroccoPos).length();
|
||||
|
||||
JPABaseEmitter* emitter = gpMarioParticleManager->emitAndBindToMtxPtr(
|
||||
PARTICLE_MS_TORO_WIND, mTorocco->getModel()->getAnmMtx(0), 1, this);
|
||||
|
||||
@@ -678,7 +678,7 @@ void TMario::soundHitBound() { }
|
||||
|
||||
void TMario::soundTorocco()
|
||||
{
|
||||
f32 len = JGeometry::TVec3<f32>(mPosition - mToroccoPos).length();
|
||||
f32 len = (mPosition - mToroccoPos).length();
|
||||
SMSGetMSound()->startSoundActorWithInfo(MSD_SE_OBJ_JET_COASTER, &mPosition,
|
||||
nullptr, len, 0, 0, nullptr, 0, 4);
|
||||
}
|
||||
|
||||
+23
-23
@@ -355,7 +355,7 @@ BOOL TMario::moveRoof()
|
||||
if (mInput & 0x20)
|
||||
return changePlayerStatus(MARIO_STATUS_WAIT_ROOF, mStatusArg, false);
|
||||
|
||||
f32 dist = JGeometry::TVec3<f32>(mPosition - mPrevPosition).length();
|
||||
f32 dist = (mPosition - mPrevPosition).length();
|
||||
dist *= mHangRoofParams.mAnmMult.get();
|
||||
if (mStatusArg & 1)
|
||||
setAnimation(ANIM_LADDER_HANG_MOVE_L, dist);
|
||||
@@ -692,7 +692,7 @@ BOOL TMario::wireMove(f32 param_1)
|
||||
mWirePosRatio = margin;
|
||||
clean = false;
|
||||
}
|
||||
if (clean)
|
||||
if (clean == true)
|
||||
mWirePosRatio += delta;
|
||||
return clean;
|
||||
}
|
||||
@@ -1163,7 +1163,19 @@ void TMario::getCurrentPullParams(f32* outV, f32* outH)
|
||||
}
|
||||
}
|
||||
|
||||
void TMario::setPullingAnm(const JGeometry::TVec3<f32>&, f32) { }
|
||||
void TMario::setPullingAnm(const JGeometry::TVec3<f32>& delta, f32 anim_rate)
|
||||
{
|
||||
s16 ang = matan(delta.z, delta.x);
|
||||
s16 adff = ang - mFaceAngle.y;
|
||||
if (adff >= -0x2000 && adff <= 0x2000)
|
||||
setAnimation(ANIM_HOLD_DRAG, anim_rate);
|
||||
if (adff <= -0x6000 || adff >= 0x6000)
|
||||
setAnimation(ANIM_HOLD_BACK, anim_rate);
|
||||
if (adff > -0x6000 && adff < -0x2000)
|
||||
setAnimation(ANIM_HOLD_MOVE_R, anim_rate);
|
||||
if (adff > 0x2000 && adff < 0x6000)
|
||||
setAnimation(ANIM_HOLD_MOVE_L, anim_rate);
|
||||
}
|
||||
|
||||
BOOL TMario::pulling()
|
||||
{
|
||||
@@ -1212,9 +1224,8 @@ BOOL TMario::pulling()
|
||||
pos.z += rateV * (cosF * JMASCos(backAngle))
|
||||
+ rateH * (sinF * JMASSin(backAngle));
|
||||
|
||||
if (mHeldObject->moveRequest(pos) == 1) {
|
||||
if (mHeldObject->moveRequest(pos) == 1)
|
||||
mPosition = pos;
|
||||
}
|
||||
|
||||
stopProcess();
|
||||
|
||||
@@ -1230,31 +1241,20 @@ BOOL TMario::pulling()
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: this should be storing the delta via the constructor and not
|
||||
// assignment operator, but it is not clear how to achieve that
|
||||
JGeometry::TVec3<f32> delta;
|
||||
if ((mHeldObject->getActorType() == ACTOR_TYPE_BOSS_GESSO_TENTACLE
|
||||
? true
|
||||
: false)
|
||||
|| (mHeldObject->getActorType() == ACTOR_TYPE_BOSS_UNK8 ? true
|
||||
: false)) {
|
||||
if (getHeldObject()->isActorType(ACTOR_TYPE_BOSS_GESSO_TENTACLE)
|
||||
|| getHeldObject()->isActorType(ACTOR_TYPE_BOSS_UNK8)) {
|
||||
delta = pos - mPrevPosition;
|
||||
} else {
|
||||
delta = mPosition - mPrevPosition;
|
||||
}
|
||||
|
||||
f32 len = delta.length();
|
||||
if (len < 1.0f) {
|
||||
if (delta.length() < 1.0f) {
|
||||
setAnimation(ANIM_HOLD_WAIT, animRate);
|
||||
} else {
|
||||
s16 ang = matan(delta.z, delta.x);
|
||||
s16 adff = ang - mFaceAngle.y;
|
||||
if (adff >= -0x2000 && adff <= 0x2000)
|
||||
setAnimation(ANIM_HOLD_DRAG, animRate);
|
||||
if (adff <= -0x6000 || adff >= 0x6000)
|
||||
setAnimation(ANIM_HOLD_BACK, animRate);
|
||||
if (adff > -0x6000 && adff < -0x2000)
|
||||
setAnimation(ANIM_HOLD_MOVE_R, animRate);
|
||||
if (adff > 0x2000 && adff < 0x6000)
|
||||
setAnimation(ANIM_HOLD_MOVE_L, animRate);
|
||||
setPullingAnm(delta, animRate);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1416,7 +1416,7 @@ BOOL TMario::fenceMove()
|
||||
hDot = unk2F4.x - unk300.x;
|
||||
if ((s16)((182.04445f * unk30C) - (f32)mFaceAngle.y) != 0)
|
||||
hDot = -hDot;
|
||||
dist = JGeometry::TVec3<f32>(unk2F4 - unk300).length();
|
||||
dist = (unk2F4 - unk300).length();
|
||||
}
|
||||
|
||||
f32 absH = hDot;
|
||||
|
||||
@@ -664,8 +664,7 @@ void TYoshi::emitTongue()
|
||||
int tries = 0;
|
||||
do {
|
||||
mTongue->movement();
|
||||
// TODO: dumb but matches?
|
||||
if (JGeometry::TVec3<f32>(mTongue->mTipPos - pos).length() > unk90)
|
||||
if ((mTongue->mTipPos - pos).length() > unk90)
|
||||
break;
|
||||
++tries;
|
||||
} while (tries < 10);
|
||||
|
||||
@@ -1214,16 +1214,6 @@ static void evAppear8RedCoinsAndTimer(TSpcTypedInterp<TEventWatcher>* interp,
|
||||
interp->push();
|
||||
}
|
||||
|
||||
// fabricated and wrong
|
||||
JGeometry::TVec3<f32> rotateY(JGeometry::TVec3<f32> vec, s16 angleY)
|
||||
{
|
||||
f32 x = vec.x * JMASCos(angleY) + vec.z * JMASSin(angleY);
|
||||
f32 z = -vec.x * JMASSin(angleY) + vec.z * JMASCos(angleY);
|
||||
vec.x = x;
|
||||
vec.z = z;
|
||||
return JGeometry::TVec3<f32>(vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
static void evWarpFrontToMario(TSpcTypedInterp<TEventWatcher>* interp,
|
||||
u32 arg_num)
|
||||
{
|
||||
@@ -1231,11 +1221,15 @@ static void evWarpFrontToMario(TSpcTypedInterp<TEventWatcher>* interp,
|
||||
TLiveActor* actor = (TLiveActor*)interp->pop().getDataInt();
|
||||
|
||||
s16 angleY = SMS_GetMarioAngleY();
|
||||
|
||||
// TODO: codegen very wrong
|
||||
actor->mPosition = SMS_GetMarioPos()
|
||||
+ rotateY(JGeometry::TVec3<f32>(0.0f, 0.0f, 400.0f),
|
||||
SMS_GetMarioAngleY());
|
||||
Vec offset;
|
||||
offset.x = 0.0f;
|
||||
offset.y = 0.0f;
|
||||
offset.z = 400.0f;
|
||||
u16 rotationY = SMS_GetMarioAngleY();
|
||||
f32 x = offset.x;
|
||||
offset.x = x * JMASCos(rotationY) + offset.z * JMASSin(rotationY);
|
||||
offset.z = -x * JMASSin(rotationY) + offset.z * JMASCos(rotationY);
|
||||
actor->mPosition = SMS_GetMarioPos() + offset;
|
||||
actor->mRotation.y = SHORTANGLE2DEG((s16)(angleY - 0x8000));
|
||||
|
||||
interp->push();
|
||||
|
||||
Reference in new issue
Block a user