Fix CScriptSound favoring the right speaker, cleanup CBallCamera, update amuse

This commit is contained in:
Phillip Stephens 2020-10-24 16:00:39 -07:00
parent b963ce1e85
commit fdd41d87c4
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
6 changed files with 334 additions and 198 deletions

File diff suppressed because it is too large Load Diff

View File

@ -150,12 +150,12 @@ private:
zeus::CVector3f x35c_splineIntermediatePos; zeus::CVector3f x35c_splineIntermediatePos;
TUniqueId x368_obscuringObjectId = kInvalidUniqueId; TUniqueId x368_obscuringObjectId = kInvalidUniqueId;
ESplineState x36c_splineState = ESplineState::Invalid; ESplineState x36c_splineState = ESplineState::Invalid;
bool x370_24_reevalSplineEnd : 1; bool x370_24_reevalSplineEnd : 1 = false;
float x374_splineCtrl = 0.f; float x374_splineCtrl = 0.f;
float x378_splineCtrlRange; float x378_splineCtrlRange;
CCameraSpline x37c_camSpline{false}; CCameraSpline x37c_camSpline{false};
CMaterialList x3c8_collisionExcludeList = {EMaterialTypes::NoStepLogic}; CMaterialList x3c8_collisionExcludeList = {EMaterialTypes::NoStepLogic};
bool x3d0_24_camBehindFloorOrWall : 1; bool x3d0_24_camBehindFloorOrWall : 1 = false;
float x3d4_elevInterpTimer = 0.f; float x3d4_elevInterpTimer = 0.f;
float x3d8_elevInterpStart = 0.f; float x3d8_elevInterpStart = 0.f;
TUniqueId x3dc_tooCloseActorId = kInvalidUniqueId; TUniqueId x3dc_tooCloseActorId = kInvalidUniqueId;
@ -202,12 +202,13 @@ private:
void UpdateUsingPathCameras(float dt, CStateManager& mgr); void UpdateUsingPathCameras(float dt, CStateManager& mgr);
zeus::CVector3f GetFixedLookTarget(const zeus::CVector3f& hintToLookDir, CStateManager& mgr) const; zeus::CVector3f GetFixedLookTarget(const zeus::CVector3f& hintToLookDir, CStateManager& mgr) const;
void UpdateUsingFixedCameras(float dt, CStateManager& mgr); void UpdateUsingFixedCameras(float dt, CStateManager& mgr);
zeus::CVector3f ComputeVelocity(const zeus::CVector3f& curVel, const zeus::CVector3f& posDelta) const; [[nodiscard]] zeus::CVector3f ComputeVelocity(const zeus::CVector3f& curVel, const zeus::CVector3f& posDelta) const;
zeus::CVector3f TweenVelocity(const zeus::CVector3f& curVel, const zeus::CVector3f& newVel, float rate, float dt); zeus::CVector3f TweenVelocity(const zeus::CVector3f& curVel, const zeus::CVector3f& newVel, float rate, float dt);
zeus::CVector3f MoveCollisionActor(const zeus::CVector3f& pos, float dt, CStateManager& mgr); zeus::CVector3f MoveCollisionActor(const zeus::CVector3f& pos, float dt, CStateManager& mgr);
void UpdateUsingFreeLook(float dt, CStateManager& mgr); void UpdateUsingFreeLook(float dt, CStateManager& mgr);
zeus::CVector3f InterpolateCameraElevation(const zeus::CVector3f& camPos, float dt); zeus::CVector3f InterpolateCameraElevation(const zeus::CVector3f& camPos, float dt);
zeus::CVector3f CalculateCollidersCentroid(const std::vector<CCameraCollider>& colliderList, int numObscured) const; [[nodiscard]] zeus::CVector3f CalculateCollidersCentroid(const std::vector<CCameraCollider>& colliderList,
int numObscured) const;
zeus::CVector3f ApplyColliders(); zeus::CVector3f ApplyColliders();
void UpdateColliders(const zeus::CTransform& xf, std::vector<CCameraCollider>& colliderList, int& it, int count, void UpdateColliders(const zeus::CTransform& xf, std::vector<CCameraCollider>& colliderList, int& it, int count,
float tolerance, const rstl::reserved_vector<TUniqueId, 1024>& nearList, float dt, float tolerance, const rstl::reserved_vector<TUniqueId, 1024>& nearList, float dt,
@ -218,7 +219,7 @@ private:
float dt, CStateManager& mgr); float dt, CStateManager& mgr);
zeus::CAABox CalculateCollidersBoundingBox(const std::vector<CCameraCollider>& colliderList, zeus::CAABox CalculateCollidersBoundingBox(const std::vector<CCameraCollider>& colliderList,
CStateManager& mgr) const; CStateManager& mgr) const;
int CountObscuredColliders(const std::vector<CCameraCollider>& colliderList) const; [[nodiscard]] int CountObscuredColliders(const std::vector<CCameraCollider>& colliderList) const;
void UpdateCollidersDistances(std::vector<CCameraCollider>& colliderList, float xMag, float zMag, float angOffset); void UpdateCollidersDistances(std::vector<CCameraCollider>& colliderList, float xMag, float zMag, float angOffset);
void UpdateUsingColliders(float dt, CStateManager& mgr); void UpdateUsingColliders(float dt, CStateManager& mgr);
void UpdateUsingSpindleCameras(float dt, CStateManager& mgr); void UpdateUsingSpindleCameras(float dt, CStateManager& mgr);
@ -248,16 +249,16 @@ public:
void ProcessInput(const CFinalInput& input, CStateManager& mgr) override; void ProcessInput(const CFinalInput& input, CStateManager& mgr) override;
void Reset(const zeus::CTransform&, CStateManager& mgr) override; void Reset(const zeus::CTransform&, CStateManager& mgr) override;
void Render(CStateManager& mgr) override; void Render(CStateManager& mgr) override;
EBallCameraBehaviour GetBehaviour() const { return x188_behaviour; } [[nodiscard]] EBallCameraBehaviour GetBehaviour() const { return x188_behaviour; }
EBallCameraState GetState() const { return x400_state; } [[nodiscard]] EBallCameraState GetState() const { return x400_state; }
void SetState(EBallCameraState state, CStateManager& mgr); void SetState(EBallCameraState state, CStateManager& mgr);
void Think(float dt, CStateManager& mgr) override; void Think(float dt, CStateManager& mgr) override;
bool TransitionFromMorphBallState(CStateManager& mgr); bool TransitionFromMorphBallState(CStateManager& mgr);
TUniqueId GetTooCloseActorId() const { return x3dc_tooCloseActorId; } [[nodiscard]] TUniqueId GetTooCloseActorId() const { return x3dc_tooCloseActorId; }
float GetTooCloseActorDistance() const { return x3e0_tooCloseActorDist; } [[nodiscard]] float GetTooCloseActorDistance() const { return x3e0_tooCloseActorDist; }
void TeleportCamera(const zeus::CVector3f& pos, CStateManager& mgr); void TeleportCamera(const zeus::CVector3f& pos, CStateManager& mgr);
void TeleportCamera(const zeus::CTransform& xf, CStateManager& mgr); void TeleportCamera(const zeus::CTransform& xf, CStateManager& mgr);
const zeus::CVector3f& GetLookPos() const { return x1d8_lookPos; } [[nodiscard]] const zeus::CVector3f& GetLookPos() const { return x1d8_lookPos; }
void ResetToTweaks(CStateManager& mgr); void ResetToTweaks(CStateManager& mgr);
void UpdateLookAtPosition(float dt, CStateManager& mgr); void UpdateLookAtPosition(float dt, CStateManager& mgr);
zeus::CTransform UpdateLookDirection(const zeus::CVector3f& dir, CStateManager& mgr); zeus::CTransform UpdateLookDirection(const zeus::CVector3f& dir, CStateManager& mgr);
@ -267,8 +268,8 @@ public:
void ResetPosition(CStateManager& mgr); void ResetPosition(CStateManager& mgr);
void DoorClosed(TUniqueId doorId); void DoorClosed(TUniqueId doorId);
void DoorClosing(TUniqueId doorId); void DoorClosing(TUniqueId doorId);
const zeus::CVector3f& GetLookPosAhead() const { return x1c0_lookPosAhead; } [[nodiscard]] const zeus::CVector3f& GetLookPosAhead() const { return x1c0_lookPosAhead; }
const zeus::CVector3f& GetFixedLookPos() const { return x1cc_fixedLookPos; } [[nodiscard]] const zeus::CVector3f& GetFixedLookPos() const { return x1cc_fixedLookPos; }
static bool IsBallNearDoor(const zeus::CVector3f& pos, CStateManager& mgr); static bool IsBallNearDoor(const zeus::CVector3f& pos, CStateManager& mgr);
}; };

View File

@ -13,11 +13,12 @@ void CCameraSpline::CalculateKnots(TUniqueId cameraId, const std::vector<SConnec
const SConnection* lastConn = nullptr; const SConnection* lastConn = nullptr;
for (const SConnection& conn : connections) { for (const SConnection& conn : connections) {
if (conn.x0_state == EScriptObjectState::CameraPath && conn.x4_msg == EScriptObjectMessage::Follow) if (conn.x0_state == EScriptObjectState::CameraPath && conn.x4_msg == EScriptObjectMessage::Follow) {
lastConn = &conn; lastConn = &conn;
} }
}
if (lastConn) { if (lastConn != nullptr) {
TCastToConstPtr<CScriptCameraWaypoint> waypoint = mgr.ObjectById(mgr.GetIdForScript(lastConn->x8_objId)); TCastToConstPtr<CScriptCameraWaypoint> waypoint = mgr.ObjectById(mgr.GetIdForScript(lastConn->x8_objId));
x14_wpTracker.clear(); x14_wpTracker.clear();
x14_wpTracker.reserve(4); x14_wpTracker.reserve(4);
@ -93,7 +94,7 @@ float CCameraSpline::GetKnotT(size_t idx) const {
float CCameraSpline::CalculateSplineLength() { float CCameraSpline::CalculateSplineLength() {
float ret = 0.f; float ret = 0.f;
x24_t.clear(); x24_t.clear();
if (x4_positions.size() > 0) { if (!x4_positions.empty()) {
zeus::CVector3f prevPoint = x4_positions[0]; zeus::CVector3f prevPoint = x4_positions[0];
float tDiv = 1.f / float(x4_positions.size() - 1); float tDiv = 1.f / float(x4_positions.size() - 1);
for (size_t i = 0; i < x4_positions.size(); ++i) { for (size_t i = 0; i < x4_positions.size(); ++i) {

View File

@ -25,7 +25,7 @@ CScriptSound::CScriptSound(TUniqueId uid, std::string_view name, const CEntityIn
, x10e_vol(vol / 127.f) , x10e_vol(vol / 127.f)
, x110_(w3) , x110_(w3)
, x112_prio(s16(prio)) , x112_prio(s16(prio))
, x114_pan(pan / 64.f - 1.f) , x114_pan(amuse::convertMusyXPanToAmusePan(pan))
, x116_(w6) , x116_(w6)
, x118_pitch(pitch / 8192.f) , x118_pitch(pitch / 8192.f)
, x11c_25_looped(looped) , x11c_25_looped(looped)

View File

@ -26,7 +26,7 @@ class CScriptSound : public CActor {
s16 x110_; s16 x110_;
s16 x112_prio; s16 x112_prio;
float x114_pan; float x114_pan;
bool x116_; short x116_;
float x118_pitch; float x118_pitch;
bool x11c_24_playRequested : 1 = false; bool x11c_24_playRequested : 1 = false;
bool x11c_25_looped : 1; bool x11c_25_looped : 1;

2
amuse

@ -1 +1 @@
Subproject commit fa3188e569be2bebd6a05ada124b7d9ed71008f1 Subproject commit 12752933271d7cf5ba48b8170e23c23c77257244