CMorphBall Complete

This commit is contained in:
Jack Andersen 2017-09-29 17:45:57 -10:00
parent 5bec8f4d89
commit 484a4900a0
17 changed files with 776 additions and 307 deletions

View File

@ -13,7 +13,9 @@ struct ITweakBall : ITweak
virtual float GetBallForwardBrakingAcceleration(int s) const=0;
virtual float GetBallGravity() const=0;
virtual float GetBallWaterGravity() const=0;
virtual float GetBallSlipFactor(int s) const=0;
virtual float GetMinimumAlignmentSpeed() const=0;
virtual float GetTireness() const=0;
virtual float GetMaxLeanAngle() const=0;
virtual float GetTireToMarbleThresholdSpeed() const=0;
virtual float GetMarbleToTireThresholdSpeed() const=0;

View File

@ -91,8 +91,8 @@ void CTweakBall::read(athena::io::IStreamReader& __dna_reader)
x158_ = __dna_reader.readFloatBig();
/* x1dc_minimumAlignmentSpeed */
x1dc_minimumAlignmentSpeed = __dna_reader.readFloatBig();
/* x1e0_ */
x1e0_ = __dna_reader.readFloatBig();
/* x1e0_tireness */
x1e0_tireness = __dna_reader.readFloatBig();
/* x1ec_maxLeanAngle */
x1ec_maxLeanAngle = __dna_reader.readFloatBig();
/* x1f0_tireToMarbleThresholdSpeed */
@ -311,8 +311,8 @@ void CTweakBall::write(athena::io::IStreamWriter& __dna_writer) const
__dna_writer.writeFloatBig(x158_);
/* x1dc_minimumAlignmentSpeed */
__dna_writer.writeFloatBig(x1dc_minimumAlignmentSpeed);
/* x1e0_ */
__dna_writer.writeFloatBig(x1e0_);
/* x1e0_tireness */
__dna_writer.writeFloatBig(x1e0_tireness);
/* x1ec_maxLeanAngle */
__dna_writer.writeFloatBig(x1ec_maxLeanAngle);
/* x1f0_tireToMarbleThresholdSpeed */
@ -551,8 +551,8 @@ void CTweakBall::read(athena::io::YAMLDocReader& __dna_docin)
x158_ = __dna_docin.readFloat("x158_");
/* x1dc_minimumAlignmentSpeed */
x1dc_minimumAlignmentSpeed = __dna_docin.readFloat("x1dc_minimumAlignmentSpeed");
/* x1e0_ */
x1e0_ = __dna_docin.readFloat("x1e0_");
/* x1e0_tireness */
x1e0_tireness = __dna_docin.readFloat("x1e0_tireness");
/* x1ec_maxLeanAngle */
x1ec_maxLeanAngle = __dna_docin.readFloat("x1ec_maxLeanAngle");
/* x1f0_tireToMarbleThresholdSpeed */
@ -787,8 +787,8 @@ void CTweakBall::write(athena::io::YAMLDocWriter& __dna_docout) const
__dna_docout.writeFloat("x158_", x158_);
/* x1dc_minimumAlignmentSpeed */
__dna_docout.writeFloat("x1dc_minimumAlignmentSpeed", x1dc_minimumAlignmentSpeed);
/* x1e0_ */
__dna_docout.writeFloat("x1e0_", x1e0_);
/* x1e0_tireness */
__dna_docout.writeFloat("x1e0_tireness", x1e0_tireness);
/* x1ec_maxLeanAngle */
__dna_docout.writeFloat("x1ec_maxLeanAngle", x1ec_maxLeanAngle);
/* x1f0_tireToMarbleThresholdSpeed */

View File

@ -56,14 +56,7 @@ struct CTweakBall final : public ITweakBall
float x120_ = 40000.f;
float x124_ = 40000.f;
float x128_ = 40000.f;
float x12c_ = 10000.f;
float x130_ = 10000.f;
float x134_ = 1000.f;
float x138_ = 10000.f;
float x13c_ = 2000.f;
float x140_ = 2000.f;
float x144_ = 2000.f;
float x148_ = 2000.f;
float x12c_ballSlipFactor[8] = { 10000.f, 10000.f, 1000.f, 10000.f, 2000.f, 2000.f, 2000.f, 2000.f };
Value<float> x14c_;
Value<float> x150_;
Value<float> x158_;
@ -97,7 +90,7 @@ struct CTweakBall final : public ITweakBall
Value<float> x1d4_;
Value<float> x1d8_;
Value<float> x1dc_minimumAlignmentSpeed;
Value<float> x1e0_;
Value<float> x1e0_tireness;
Value<float> x1ec_maxLeanAngle;
Value<float> x1f0_tireToMarbleThresholdSpeed;
Value<float> x1f4_marbleToTireThresholdSpeed;
@ -143,7 +136,9 @@ struct CTweakBall final : public ITweakBall
float GetBallForwardBrakingAcceleration(int s) const { return xc4_ballForwardBrakingAcceleration[s]; }
float GetBallGravity() const { return xe4_ballGravity; }
float GetBallWaterGravity() const { return xe8_ballWaterGravity; }
float GetBallSlipFactor(int s) const { return x12c_ballSlipFactor[s]; }
float GetMinimumAlignmentSpeed() const { return x1dc_minimumAlignmentSpeed; }
float GetTireness() const { return x1e0_tireness; }
float GetMaxLeanAngle() const { return x1ec_maxLeanAngle; }
float GetTireToMarbleThresholdSpeed() const { return x1f0_tireToMarbleThresholdSpeed; }
float GetMarbleToTireThresholdSpeed() const { return x1f4_marbleToTireThresholdSpeed; }

View File

@ -3,7 +3,6 @@
#include "specter/specter.hpp"
#include "hecl/CVarManager.hpp"
#include "Runtime/CBasics.hpp"
#include <functional>
#include "ViewManager.hpp"
static logvisor::Module AthenaLog("Athena");

View File

@ -88,6 +88,7 @@ public:
const std::vector<CLight>& GetAreaLights() const { return x0_areaLights; }
const std::vector<CLight>& GetDynamicLights() const { return x144_dynamicLights; }
bool GetIsDirty() const { return x298_24_dirty; }
void SetDirty() { x298_24_dirty = true; }
bool HasShadowLight() const { return x29c_shadowLightArrIdx != -1; }
s32 GetShadowLightArrIndex() const { return x29c_shadowLightArrIdx; }
s32 GetShadowLightIndex() const { return x2a0_shadowLightIdx; }

View File

@ -210,9 +210,9 @@ CCollidableSphere::CCollidableSphere(const zeus::CSphere& sphere, const CMateria
const zeus::CSphere& CCollidableSphere::GetSphere() const { return x10_sphere; }
void CCollidableSphere::SetSphereCenter(const zeus::CVector3f&)
void CCollidableSphere::SetSphereCenter(const zeus::CVector3f& center)
{
/* Remove me? */
x10_sphere.position = center;
}
zeus::CSphere CCollidableSphere::Transform(const zeus::CTransform& xf) const

View File

@ -24,7 +24,7 @@ public:
CCollidableSphere(const zeus::CSphere&, const CMaterialList&);
const zeus::CSphere& GetSphere() const;
void SetSphereCenter(const zeus::CVector3f&);
void SetSphereCenter(const zeus::CVector3f& center);
zeus::CSphere Transform(const zeus::CTransform& xf) const;
virtual u32 GetTableIndex() const;

View File

@ -115,32 +115,6 @@ static const u32 Character2and3Idxs[8][2] =
{30, 31}
};
static const u8 BallGlowColors[9][3] =
{
{0xff, 0xff, 0xff},
{0xff, 0xff, 0xff},
{0xff, 0xff, 0xff},
{0xff, 0xff, 0xff},
{0xff, 0xd5, 0x19},
{0xff, 0xff, 0xff},
{0xff, 0xff, 0xff},
{0xff, 0xff, 0xff},
{0xff, 0xff, 0xff},
};
static const u8 BallAuxGlowColors[9][3] =
{
{0xc2, 0x7e, 0x10},
{0x66, 0xc4, 0xff},
{0x6c, 0xff, 0x61},
{0x33, 0x33, 0xff},
{0xff, 0x20, 0x20},
{0x0, 0x9d, 0xb6},
{0xd3, 0xf1, 0x0},
{0xa6, 0x86, 0xd8},
{0xfb, 0x98, 0x21}
};
CSamusDoll::CSamusDoll(const CDependencyGroup& suitDgrp, const CDependencyGroup& ballDgrp,
CPlayerState::EPlayerSuit suit, CPlayerState::EBeamId beam,
bool hasSpiderBall, bool hasGrappleBeam)
@ -589,7 +563,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha)
flags.x4_color.a = x6c_ballPulseFactor * alpha * itemPulse;
x184_ballModelData->Render(mgr, x10_xf, x24c_actorLights.get(), flags);
const u8* c = BallGlowColors[x1e8_ballGlowColorIdx];
const u8* c = CMorphBall::BallGlowColors[x1e8_ballGlowColorIdx];
zeus::CColor color = {c[0] / 255.f, c[1] / 255.f, c[2] / 255.f, alpha};
x22c_ballInnerGlowGen->SetModulationColor(color);
@ -603,7 +577,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha)
if (x22c_ballInnerGlowGen->GetNumActiveChildParticles() > 1)
{
const u8* c = BallAuxGlowColors[x1e8_ballGlowColorIdx];
const u8* c = CMorphBall::BallAuxGlowColors[x1e8_ballGlowColorIdx];
zeus::CColor color = {c[0] / 255.f, c[1] / 255.f, c[2] / 255.f, alpha};
x22c_ballInnerGlowGen->GetActiveChildParticle(1).SetModulationColor(color);
}

View File

@ -19,5 +19,10 @@ void CMetroidBeta::RenderHitGunEffect() const
}
void CMetroidBeta::RenderHitBallEffect() const
{
}
}
}

View File

@ -17,6 +17,7 @@ public:
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
const CActorParameters& aParms, const CMetroidData& metroidData);
void RenderHitGunEffect() const;
void RenderHitBallEffect() const;
};
}

View File

@ -212,6 +212,18 @@ public:
std::swap(rot, data.x30_irot);
}
}
void DoSpiderBallWarmup(zeus::CVector3f& translation, const zeus::CVector3f& transInc)
{
SetOrientation(zeus::lookAt(zeus::CVector3f::skZero, transInc));
for (int i=0 ; i<6 ; ++i)
{
SetTranslation(translation);
x1d0_26_disableUpdate = true;
Update(0.0);
translation += transInc;
}
}
};
}

View File

@ -159,6 +159,8 @@ public:
}
void Clear() { this->clear(); }
size_t Size() const { return this->size(); }
};
namespace std

View File

@ -480,7 +480,7 @@ SAdvancementDeltas CActor::UpdateAnimation(float dt, CStateManager& mgr, bool ad
return deltas;
}
void CActor::SetActorLights(std::unique_ptr<CActorLights> lights)
void CActor::SetActorLights(std::unique_ptr<CActorLights>&& lights)
{
x90_actorLights = std::move(lights);
xe4_31_lightsDirty = true;

View File

@ -172,8 +172,9 @@ public:
const zeus::CVector3f& position, TAreaId aid, CStateManager& mgr,
bool translateId);
SAdvancementDeltas UpdateAnimation(float, CStateManager&, bool);
void SetActorLights(std::unique_ptr<CActorLights>);
void SetActorLights(std::unique_ptr<CActorLights>&& lights);
const CActorLights* GetActorLights() const { return x90_actorLights.get(); }
CActorLights* ActorLights() { return x90_actorLights.get(); }
bool CanDrawStatic() const;
bool GetE7_29() const { return xe7_29_; }
void SetWorldLightingDirty(bool b) { xe7_28_worldLightingDirty = b; }

File diff suppressed because it is too large Load Diff

View File

@ -44,12 +44,20 @@ public:
One
};
private:
struct CSpiderBallElectricityManager
{
u32 x0_effectIdx;
u32 x4_lifetime;
u32 x8_curFrame = 0;
CSpiderBallElectricityManager(u32 effectIdx, u32 lifetime)
: x0_effectIdx(effectIdx), x4_lifetime(lifetime) {}
};
CPlayer& x0_player;
s32 x4_loadedModelId = -1;
u32 x8_ballGlowColorIdx = 0;
float xc_radius;
zeus::CVector3f x10_;
zeus::CVector3f x1c_;
zeus::CVector3f x10_boostControlForce;
zeus::CVector3f x1c_controlForce;
bool x28_tireMode = false;
float x2c_tireLeanAngle = 0.f;
float x30_ballTiltAngle = 0.f;
@ -67,27 +75,27 @@ private:
zeus::CVector3f x1880_playerToSpiderNormal;
float x188c_spiderPullMovement = 1.f;
zeus::CVector3f x1890_spiderTrackPoint;
zeus::CVector3f x189c_spiderInterpDistBetweenPoints;
zeus::CVector3f x18a8_spiderDistBetweenPoints;
float x18b4_ = 0.f;
float x18b8_ = 0.f;
bool x18bc_ = false;
bool x18bd_ = false;
zeus::CVector3f x189c_spiderInterpBetweenPoints;
zeus::CVector3f x18a8_spiderBetweenPoints;
float x18b4_linVelDamp = 0.f;
float x18b8_angVelDamp = 0.f;
bool x18bc_spiderNearby = false;
bool x18bd_touchingSpider = false;
bool x18be_spiderBallSwinging = false;
bool x18bf_ = true;
bool x18bf_spiderSwingInAir = true;
bool x18c0_isSpiderSurface = false;
zeus::CTransform x18c4_spiderSurfaceTransform;
float x18f4_ = 0.f;
float x18f8_ = 0.f;
float x18f4_spiderSurfacePivotAngle = 0.f;
float x18f8_spiderSurfacePivotTargetAngle = 0.f;
float x18fc_refPullVel = 0.f;
float x1900_playerToSpiderTrackDist = 0.f;
float x1904_swingControlDir = 0.f;
float x1908_swingControlTime = 0.f;
zeus::CVector2f x190c_;
float x1914_ = 0.f;
float x1918_ = 0.f;
zeus::CVector2f x190c_normSpiderSurfaceForces;
float x1914_spiderTrackForceMag = 0.f;
float x1918_spiderViewControlMag = 0.f;
float x191c_damageTimer = 0.f;
bool x1920_ = false;
bool x1920_spiderForcesReset = false;
zeus::CTransform x1924_surfaceToWorld;
bool x1954_isProjectile = false;
std::vector<CToken> x1958_animationTokens;
@ -113,45 +121,44 @@ private:
std::unique_ptr<CElementGen> x19dc_morphBallTransitionFlashGen;
std::unique_ptr<CElementGen> x19e0_effect_morphBallIceBreakGen;
rstl::reserved_vector<std::pair<std::unique_ptr<CParticleSwoosh>, bool>, 32> x19e4_spiderElectricGens;
std::list<u32> x1b6c_;
std::list<CSpiderBallElectricityManager> x1b6c_activeSpiderElectricList;
CRandom16 x1b80_rand = {99};
rstl::reserved_vector<TToken<CGenDescription>, 8> x1b84_wakeEffects;
rstl::reserved_vector<std::unique_ptr<CElementGen>, 8> x1bc8_wakeEffectGens;
std::unique_ptr<CElementGen> x1bcc_[8];
s32 x1c0c_wakeEffectIdx = -1;
TUniqueId x1c10_ballInnerGlowLight = kInvalidUniqueId;
std::unique_ptr<CWorldShadow> x1c14_worldShadow;
std::unique_ptr<CActorLights> x1c18_actorLights;
std::unique_ptr<CRainSplashGenerator> x1c1c_rainSplashGen;
float x1c20_ = 0.f;
float x1c24_ = 0.5f;
float x1c28_ = 1.f;
bool x1c2c_ = false;
float x1c30_ = 0.f;
float x1c34_ = 0.f;
float x1c38_ = 0.f;
TReservedAverage<zeus::CQuaternion, 5> x1c3c_quats = {{}};
TReservedAverage<zeus::CVector3f, 5> x1c90_vecs = {{}};
TReservedAverage<float, 15> x1cd0_ = {{}};
TReservedAverage<zeus::CVector3f, 15> x1d10_ = {{}};
u32 x1dc8_ = 0;
float x1c20_tireFactor = 0.f;
float x1c24_maxTireFactor = 0.5f;
float x1c28_tireInterpSpeed = 1.f;
bool x1c2c_tireInterpolating = false;
float x1c30_boostOverLightFactor = 0.f;
float x1c34_boostLightFactor = 0.f;
float x1c38_spiderLightFactor = 0.f;
TReservedAverage<zeus::CQuaternion, 5> x1c3c_ballOrientAvg = {{}};
TReservedAverage<zeus::CVector3f, 5> x1c90_ballPosAvg = {{}};
TReservedAverage<float, 15> x1cd0_liftSpeedAvg = {{}};
TReservedAverage<zeus::CVector3f, 15> x1d10_liftControlForceAvg = {{}};
u32 x1dc8_failsafeCounter = 0;
zeus::CVector3f x1dcc_;
zeus::CVector3f x1dd8_;
bool x1de4_24_inBoost : 1;
bool x1de4_25_boostEnabled : 1;
float x1de8_boostChargeTime = 0.f;
float x1dec_ = 0.f;
float x1dec_timeNotInBoost = 0.f;
float x1df0_ = 0.f;
float x1df4_boostDrainTime = 0.f;
bool x1df8_24_inHalfPipeMode : 1;
bool x1df8_25_inHalfPipeModeInAir : 1;
bool x1df8_26_touchedHalfPipeRecently : 1;
bool x1df8_27_ballCloseToCollision : 1;
float x1dfc_ = 0.f;
float x1e00_ = 0.f;
float x1e04_ = 0.f;
zeus::CVector3f x1e08_;
zeus::CVector3f x1e14_;
float x1dfc_touchHalfPipeCooldown = 0.f;
float x1e00_disableControlCooldown = 0.f;
float x1e04_touchHalfPipeRecentCooldown = 0.f;
zeus::CVector3f x1e08_prevHalfPipeNormal;
zeus::CVector3f x1e14_halfPipeNormal;
u32 x1e20_ballAnimIdx = 0;
CSfxHandle x1e24_boostSfxHandle;
CSfxHandle x1e28_wallHitSfxHandle;
@ -162,9 +169,9 @@ private:
u32 x1e38_wallSparkFrameCountdown = 0;
EBallBoostState x1e3c_boostState = EBallBoostState::Zero;
EBombJumpState x1e40_bombJumpState = EBombJumpState::Zero;
float x1e44_ = 0.f;
float x1e48_ = 0.f;
float x1e4c_ = 0.f;
float x1e44_damageEffect = 0.f;
float x1e48_damageEffectDecaySpeed = 0.f;
float x1e4c_damageTime = 0.f;
std::unique_ptr<CMorphBallShadow> x1e50_shadow;
void LoadAnimationTokens(const std::string& ancsName);
void InitializeWakeEffects();
@ -174,6 +181,7 @@ private:
static zeus::CVector3f TransformSpiderBallForcesXY(const zeus::CVector2f& forces, CStateManager& mgr);
static zeus::CVector3f TransformSpiderBallForcesXZ(const zeus::CVector2f& forces, CStateManager& mgr);
void ResetSpiderBallForces();
static void PointGenerator(void* ctx, const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn);
public:
CMorphBall(CPlayer& player, float radius);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr);
@ -231,8 +239,8 @@ public:
void ApplyFriction(float);
void DampLinearAndAngularVelocities(float linDamp, float angDamp);
float GetMinimumAlignmentSpeed() const;
void PreRender(CStateManager&, const zeus::CFrustum&);
void Render(const CStateManager&, const CActorLights*) const;
void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum);
void Render(const CStateManager& mgr, const CActorLights* lights) const;
void ResetMorphBallTransitionFlash();
void UpdateMorphBallTransitionFlash(float dt);
void RenderMorphBallTransitionFlash(const CStateManager&) const;
@ -251,25 +259,26 @@ public:
bool BallCloseToCollision(const CStateManager& mgr, float dist, const CMaterialFilter& filter) const;
void CollidedWith(TUniqueId id, const CCollisionInfoList& list, CStateManager& mgr);
bool IsInFrustum(const zeus::CFrustum& frustum) const;
void ComputeLiftForces(const zeus::CVector3f&, const zeus::CVector3f&, const CStateManager&);
void ComputeLiftForces(const zeus::CVector3f& controlForce, const zeus::CVector3f& velocity,
const CStateManager& mgr);
float CalculateSurfaceFriction() const;
void ApplyGravity(CStateManager& mgr);
void SpinToSpeed(float holdMag, zeus::CVector3f torque, float mag);
float ComputeMaxSpeed() const;
void Touch(CActor& actor, CStateManager& mgr);
bool IsClimbable(const CCollisionInfo& cinfo) const;
void FluidFXThink(CActor::EFluidState, CScriptWater&, CStateManager&);
void FluidFXThink(CActor::EFluidState state, CScriptWater& water, CStateManager& mgr);
void LoadMorphBallModel(CStateManager& mgr);
void AddSpiderBallElectricalEffect();
void UpdateSpiderBallElectricalEffects();
void RenderSpiderBallElectricalEffect() const;
void RenderEnergyDrainEffects(const CStateManager&) const;
void RenderEnergyDrainEffects(const CStateManager& mgr) const;
void TouchModel(const CStateManager& mgr) const;
void SetAsProjectile(const CDamageInfo&, const CDamageInfo&);
void SetAsProjectile() { x1954_isProjectile = true; }
EBallBoostState GetBallBoostState() const { return x1e3c_boostState; }
void SetBallBoostState(EBallBoostState state) { x1e3c_boostState = state; }
EBombJumpState GetBombJumpState() const { return x1e40_bombJumpState; }
void TakeDamage(float);
void TakeDamage(float dam);
void DrawBallShadow(const CStateManager& mgr);
void DeleteBallShadow();
void CreateBallShadow();
@ -285,7 +294,9 @@ public:
bool GetBoostEnabled() const { return x1de4_25_boostEnabled; }
void SetBoostEnabed(bool b) { x1de4_25_boostEnabled = b; }
static const u8 BallGlowColors[9][3];
static const u8 BallTransFlashColors[9][3];
static const u8 BallAuxGlowColors[9][3];
};
}

View File

@ -163,6 +163,8 @@ public:
void SetAngularMomentum(const zeus::CAxisAngle& m) { x108_angularMomentum = m; }
const zeus::CVector3f& GetMomentum() const { return x150_momentum; }
const zeus::CVector3f& GetVelocity() const { return x138_velocity; }
const zeus::CAxisAngle& GetAngularImpulse() const { return x180_angularImpulse; }
void SetAngularImpulse(const zeus::CAxisAngle& i) { x180_angularImpulse = i; }
zeus::CVector3f GetTotalForcesWR() const;
void RotateInOneFrameOR(const zeus::CQuaternion& q, float d);
void MoveInOneFrameOR(const zeus::CVector3f& trans, float d);