MapMgrProg

This commit is contained in:
intns 2024-05-18 01:42:06 +01:00
parent 6a10ec4521
commit 47d964803f
2 changed files with 15 additions and 10 deletions

View File

@ -32,6 +32,8 @@ struct WaterBox;
struct MapMgr : virtual public GenericObjectMgr {
struct BeamCollisionArg {
BeamCollisionArg() { }
BeamCollisionArg(f32 beamRadius, int index, u8 hitSuccess)
{
mBeamRadius = beamRadius;
@ -39,6 +41,14 @@ struct MapMgr : virtual public GenericObjectMgr {
mHitSuccess = hitSuccess;
}
inline void setup(int index, const Vector3f& position, const Vector3f& targetPosition, f32 beamRadius)
{
mIndex = index;
mPosition = position;
mTargetPosition = targetPosition;
mBeamRadius = beamRadius;
}
Vector3f mPosition; // _00
Vector3f mTargetPosition; // _0C
f32 mBeamRadius; // _18

View File

@ -190,18 +190,13 @@ f32 MapMgr::getBestAngle(Vector3f& position, f32 distance, f32 divisor)
// Shoot 16 beams, 22.5 degrees apart from each other (PI / 8)
for (int i = 0; i < 16; i++) {
f32 angle = (PI / 8) * (f32)i;
f32 tanTheta = distance * (f32)tan(divisor);
f32 tanTheta = tanf_kludge(divisor) * distance;
Vector3f offset = Vector3f(distance * sinf(angle), tanTheta, distance * cosf(angle));
Vector3f beamPos = adjustedPos;
offset = offset + beamPos;
Vector3f offset(distance * sinf(angle), tanTheta, distance * cosf(angle));
offset = offset + adjustedPos;
BeamCollisionArg beamArg(10.0f, 0, 0);
beamArg.mIndex = i;
beamArg.mPosition = beamPos;
beamArg.mTargetPosition = offset;
beamArg.mBeamRadius = 10.0f;
BeamCollisionArg beamArg(10.0f, i, 0);
beamArg.setup(i, offset, adjustedPos, 10.0f);
checkBeamCollision(beamArg);
angles[i] = beamArg.mTargetDistance;
}