Add CBallCamera stubs, more implementations

This commit is contained in:
Jack Andersen 2017-10-08 16:41:50 -10:00
parent d9bb24a204
commit 4c83f521a8
8 changed files with 616 additions and 46 deletions

View File

@ -1,6 +1,11 @@
#include <Runtime/GameGlobalObjects.hpp>
#include "GameGlobalObjects.hpp"
#include "CBallCamera.hpp"
#include "TCastTo.hpp"
#include "CStateManager.hpp"
#include "Collision/CCollisionActor.hpp"
#include "World/CPlayer.hpp"
#include "Input/ControlMapper.hpp"
#include "Camera/CFirstPersonCamera.hpp"
namespace urde
{
@ -32,7 +37,7 @@ CBallCamera::CBallCamera(TUniqueId uid, TUniqueId watchedId, const zeus::CTransf
float fovy, float znear, float zfar, float aspect)
: CGameCamera(uid, true, "Ball Camera",
CEntityInfo(kInvalidAreaId, CEntity::NullConnectionList),
xf, fovy, znear, zfar, aspect, watchedId, false, 0), x37c_camSpline(false),
xf, fovy, znear, zfar, aspect, watchedId, false, 0),
x214_ballCameraSpring(g_tweakBall->GetBallCameraSpringTardis(),
g_tweakBall->GetBallCameraSpringMax(),
g_tweakBall->GetBallCameraSpringConstant()),
@ -45,6 +50,7 @@ CBallCamera::CBallCamera(TUniqueId uid, TUniqueId watchedId, const zeus::CTransf
x250_ballCameraCentroidDistanceSpring(g_tweakBall->GetBallCameraCentroidDistanceSpringTardis(),
g_tweakBall->GetBallCameraCentroidDistanceSpringMax(),
g_tweakBall->GetBallCameraCentroidDistanceSpringConstant()),
x37c_camSpline(false),
x41c_ballCameraChaseSpring(g_tweakBall->GetBallCameraChaseSpringTardis(),
g_tweakBall->GetBallCameraChaseSpringMax(),
g_tweakBall->GetBallCameraChaseSpringConstant()),
@ -71,17 +77,17 @@ CBallCamera::CBallCamera(TUniqueId uid, TUniqueId watchedId, const zeus::CTransf
x18e_24_ = false;
x18e_25_ = false;
x18e_26_ = false;
x18e_27_ = false;
x18e_28_ = false;
x18e_27_nearbyDoorClosed = false;
x18e_28_nearbyDoorClosing = false;
x190_origMinDistance = g_tweakBall->GetBallCameraMinSpeedDistance();
x194_minDistance = g_tweakBall->GetBallCameraMinSpeedDistance();
x190_curMinDistance = g_tweakBall->GetBallCameraMinSpeedDistance();
x194_targetMinDistance = g_tweakBall->GetBallCameraMinSpeedDistance();
x198_maxDistance = g_tweakBall->GetBallCameraMaxSpeedDistance();
x19c_backwardsDistance = g_tweakBall->GetBallCameraBackwardsDistance();
x1a0_elevation = g_tweakBall->GetBallCameraElevation();
x1a4_origAnglePerSecond = g_tweakBall->GetBallCameraAnglePerSecond();
x1a8_anglePerSecond = g_tweakBall->GetBallCameraAnglePerSecond();
x1a4_curAnglePerSecond = g_tweakBall->GetBallCameraAnglePerSecond();
x1a8_targetAnglePerSecond = g_tweakBall->GetBallCameraAnglePerSecond();
x1b4_lookAtOffset = g_tweakBall->GetBallCameraOffset();
x404_chaseElevation = g_tweakBall->GetBallCameraChaseElevation();
@ -96,6 +102,7 @@ CBallCamera::CBallCamera(TUniqueId uid, TUniqueId watchedId, const zeus::CTransf
x468_ = g_tweakBall->x170_;
x47c_failsafeState = std::make_unique<SFailsafeState>();
x480_ = std::make_unique<u32>();
SetupColliders(x264_smallColliders, 2.31f, 2.31f, 0.1f, 3, 2.f, 0.5f, -M_PIF / 2.f);
@ -123,17 +130,488 @@ void CBallCamera::Accept(IVisitor& visitor)
visitor.Visit(this);
}
void CBallCamera::ProcessInput(const CFinalInput&, CStateManager& mgr)
void CBallCamera::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
{
CGameCamera::AcceptScriptMsg(msg, objId, stateMgr);
switch (msg)
{
case EScriptObjectMessage::Registered:
{
x46c_collisionActorId = stateMgr.AllocateUniqueId();
CCollisionActor* colAct = new CCollisionActor(x46c_collisionActorId, GetAreaId(), kInvalidUniqueId,
true, 0.3f, 1.f);
colAct->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid},
{EMaterialTypes::Player,
EMaterialTypes::CameraPassthrough}));
colAct->SetMaterialList({EMaterialTypes::ProjectilePassthrough, EMaterialTypes::ScanPassthrough,
EMaterialTypes::SeeThrough, EMaterialTypes::CameraPassthrough});
colAct->SetTranslation(GetTranslation());
stateMgr.AddObject(colAct);
colAct->SetMovable(false);
CMotionState mState(GetTranslation(), zeus::CNUQuaternion::fromAxisAngle(zeus::CVector3f::skForward, 0.f),
zeus::CVector3f::skZero, zeus::CAxisAngle::sIdentity);
colAct->SetLastNonCollidingState(mState);
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude({},
{EMaterialTypes::Solid,
EMaterialTypes::ProjectilePassthrough,
EMaterialTypes::Player,
EMaterialTypes::Character,
EMaterialTypes::CameraPassthrough}));
RemoveMaterial(EMaterialTypes::Solid, stateMgr);
break;
}
case EScriptObjectMessage::Deleted:
stateMgr.FreeScriptObject(x46c_collisionActorId);
x46c_collisionActorId = kInvalidUniqueId;
break;
default:
break;
}
}
void CBallCamera::Reset(const zeus::CTransform&, CStateManager& mgr)
void CBallCamera::ProcessInput(const CFinalInput& input, CStateManager& mgr)
{
if (input.ControllerIdx() != 0)
return;
if (TCastToConstPtr<CPlayer> player = mgr.GetObjectById(xe8_watchedObject))
{
if (player->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed)
{
switch (x400_state)
{
case EBallCameraState::Two:
if (!ControlMapper::GetDigitalInput(ControlMapper::ECommands::ChaseCamera, input) ||
player->IsInFreeLook())
SetState(EBallCameraState::Zero, mgr);
break;
case EBallCameraState::Three:
if (!player->GetMorphBall()->IsInBoost())
SetState(EBallCameraState::Zero, mgr);
break;
case EBallCameraState::Zero:
if (x18c_25_ && ControlMapper::GetPressInput(ControlMapper::ECommands::ChaseCamera, input))
SetState(EBallCameraState::Two, mgr);
break;
default:
break;
}
if (x18c_26_ && x400_state != EBallCameraState::Three &&
(player->GetMorphBall()->IsInBoost() || player->GetMorphBall()->GetBoostChargeTime() > 0.f))
SetState(EBallCameraState::Three, mgr);
}
}
}
void CBallCamera::Reset(const zeus::CTransform& xf, CStateManager& mgr)
{
x214_ballCameraSpring.Reset();
x228_ballCameraCentroidSpring.Reset();
x23c_ballCameraLookAtSpring.Reset();
x250_ballCameraCentroidDistanceSpring.Reset();
x41c_ballCameraChaseSpring.Reset();
x448_ballCameraBoostSpring.Reset();
zeus::CVector3f desiredPos = FindDesiredPosition(x190_curMinDistance, x1a0_elevation, xf.basis[1], mgr);
if (TCastToConstPtr<CPlayer> player = mgr.GetObjectById(xe8_watchedObject))
{
ResetPosition();
x310_ = x1b4_lookAtOffset;
x31c_ = x1d8_;
if ((x1d8_ - desiredPos).canBeNormalized())
{
TeleportCamera(zeus::lookAt(desiredPos, x1d8_), mgr);
}
else
{
zeus::CTransform camXf = player->CreateTransformFromMovementDirection();
camXf.origin = desiredPos;
TeleportCamera(camXf, mgr);
mgr.GetCameraManager()->SetPlayerCamera(mgr, GetUniqueId());
}
x2e8_ = 0.f;
x2ec_ = 0.f;
x190_curMinDistance = x194_targetMinDistance;
x2fc_ = zeus::CVector3f::skZero;
x2f0_ = zeus::CVector3f::skZero;
x18d_28_ = false;
x308_ = 0.f;
x2dc_ = player->GetBallPosition();
x294_ = GetTranslation();
x2a0_ = zeus::CVector3f::skZero;
x2ac_ = zeus::CVector3f::skZero;
x2b8_ = zeus::CVector3f::skZero;
x2c4_ = 0;
x2c8_ = 0;
x2cc_ = 0;
x2d0_ = 0;
x2d4_ = 0;
x2d8_ = 0;
x32c_ = 1.f;
x18d_25_ = true;
x18d_27_ = true;
Think(0.1f, mgr);
x18d_25_ = false;
x18d_27_ = false;
}
}
void CBallCamera::Render(const CStateManager& mgr) const
{
// Empty
}
void CBallCamera::SetState(EBallCameraState state, CStateManager& mgr)
{
switch (state)
{
case EBallCameraState::Four:
{
zeus::CTransform xf = mgr.GetCameraManager()->GetFirstPersonCamera()->GetTransform();
SetTransform(xf);
TeleportCamera(xf.origin, mgr);
SetFovInterpolation(mgr.GetCameraManager()->GetFirstPersonCamera()->GetFov(),
CCameraManager::ThirdPersonFOV(), 1.f, 0.f);
x36c_ = 0;
}
case EBallCameraState::Zero:
case EBallCameraState::Two:
case EBallCameraState::Three:
mgr.SetGameState(CStateManager::EGameState::Running);
break;
case EBallCameraState::Five:
mgr.GetCameraManager()->SetPlayerCamera(mgr, GetUniqueId());
mgr.SetGameState(CStateManager::EGameState::Running);
SetFovInterpolation(GetFov(), CCameraManager::FirstPersonFOV(), 1.f, 0.f);
x36c_ = 0;
break;
default:
break;
}
x400_state = state;
}
static const CMaterialFilter BallCameraFilter =
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid},
{EMaterialTypes::ProjectilePassthrough, EMaterialTypes::Player, EMaterialTypes::Character,
EMaterialTypes::CameraPassthrough});
void CBallCamera::ResetSpline(CStateManager& mgr)
{
zeus::CVector3f ballPos = mgr.GetPlayer().GetBallPosition();
TUniqueId intersectId = kInvalidUniqueId;
rstl::reserved_vector<TUniqueId, 1024> nearList;
CRayCastResult result = mgr.RayWorldIntersection(intersectId, ballPos, zeus::CVector3f::skDown, 20.f,
BallCameraFilter, nearList);
float downFactor = result.IsValid() ? zeus::clamp(0.f, result.GetT() / 20.f, 1.f) : 1.f;
x36c_ = 1;
x370_24_ = true;
x3d0_24_ = false;
x37c_camSpline.Reset(4);
x37c_camSpline.AddKnot(GetTranslation(), zeus::CVector3f::skForward);
float elevation = x1a0_elevation;
float distance = x190_curMinDistance;
ConstrainElevationAndDistance(elevation, distance, 0.f, mgr);
zeus::CVector3f tmpPoint(x35c_.x, x35c_.y, GetTranslation().z);
x37c_camSpline.AddKnot(tmpPoint, zeus::CVector3f::skForward);
zeus::CVector3f tmpPoint2 = tmpPoint + (x35c_ - GetTranslation()) * (0.5f + downFactor);
x37c_camSpline.AddKnot(tmpPoint2, zeus::CVector3f::skForward);
zeus::CVector3f tmpPoint2Ball = ballPos - tmpPoint2;
if (tmpPoint2Ball.canBeNormalized())
tmpPoint2Ball.normalize();
else
tmpPoint2Ball = mgr.GetPlayer().GetMoveDir();
zeus::CVector3f desiredPosition = FindDesiredPosition(distance, elevation, tmpPoint2Ball, mgr);
x37c_camSpline.AddKnot(desiredPosition, zeus::CVector3f::skForward);
x37c_camSpline.x44_ = x37c_camSpline.CalculateSplineLength();
x3d0_24_ = false;
CMaterialList intersectMat;
x3c8_ = CMaterialList(EMaterialTypes::Floor, EMaterialTypes::Ceiling);
if (!SplineIntersectTest(intersectMat, mgr))
{
if (intersectMat.HasMaterial(EMaterialTypes::Floor) || intersectMat.HasMaterial(EMaterialTypes::Wall))
{
x3d0_24_ = true;
x3c8_ = CMaterialList();
}
}
x374_ = 0.5f * downFactor + 2.f;
x378_ = 2.5f;
}
void CBallCamera::BuildSpline(CStateManager& mgr)
{
}
bool CBallCamera::ShouldResetSpline(CStateManager& mgr) const
{
return false;
}
void CBallCamera::UpdatePlayerMovement(float dt, CStateManager& mgr)
{
}
void CBallCamera::UpdateTransform(const zeus::CVector3f& lookDir, const zeus::CVector3f& pos,
float dt, CStateManager& mgr)
{
}
zeus::CVector3f CBallCamera::ConstrainYawAngle(const CPlayer& player, float f1, float f2, float dt) const
{
return {};
}
void CBallCamera::CheckFailsafe(float dt, CStateManager& mgr)
{
}
void CBallCamera::UpdateObjectTooCloseId(CStateManager& mgr)
{
}
void CBallCamera::UpdateAnglePerSecond(float dt)
{
float delta = x1a8_targetAnglePerSecond - x1a4_curAnglePerSecond;
if (std::fabs(delta) >= M_PIF / 1800.f)
x1a4_curAnglePerSecond += zeus::clamp(-1.f, delta / M_PIF, 1.f) * (10.471975f * dt);
else
x1a4_curAnglePerSecond = x1a8_targetAnglePerSecond;
}
void CBallCamera::UpdateUsingPathCameras(float dt, CStateManager& mgr)
{
}
zeus::CVector3f CBallCamera::GetFixedLookTarget(const zeus::CVector3f& pos, CStateManager& mgr) const
{
return {};
}
void CBallCamera::UpdateUsingFixedCameras(float dt, CStateManager& mgr)
{
}
zeus::CVector3f CBallCamera::ComputeVelocity(const zeus::CVector3f& curVel, const zeus::CVector3f& posDelta) const
{
return {};
}
zeus::CVector3f CBallCamera::TweenVelocity(const zeus::CVector3f& curVel, const zeus::CVector3f& newVel,
float rate, float dt)
{
return {};
}
zeus::CVector3f CBallCamera::MoveCollisionActor(const zeus::CVector3f& pos, float dt, CStateManager& mgr)
{
return {};
}
void CBallCamera::UpdateUsingFreeLook(float dt, CStateManager& mgr)
{
}
zeus::CVector3f CBallCamera::InterpolateCameraElevation(const zeus::CVector3f& camPos) const
{
return {};
}
zeus::CVector3f CBallCamera::CalculateCollidersCentroid(const std::vector<CCameraCollider>& colliderList, int w1) const
{
return {};
}
zeus::CVector3f CBallCamera::ApplyColliders()
{
return {};
}
void CBallCamera::UpdateColliders(const zeus::CTransform& xf, std::vector<CCameraCollider>& colliderList, int& r6,
int r7, float f1, const rstl::reserved_vector<TUniqueId, 1024>& nearList, float f2,
CStateManager& mgr)
{
}
void CBallCamera::AvoidGeometry(const zeus::CTransform& xf, const rstl::reserved_vector<TUniqueId, 1024>& nearList,
float dt, CStateManager& mgr)
{
}
void CBallCamera::AvoidGeometryFull(const zeus::CTransform& xf, const rstl::reserved_vector<TUniqueId, 1024>& nearList,
float dt, CStateManager& mgr)
{
}
zeus::CAABox CBallCamera::CalculateCollidersBoundingBox(const std::vector<CCameraCollider>& colliderList,
CStateManager& mgr) const
{
return {};
}
int CBallCamera::CountObscuredColliders(const std::vector<CCameraCollider>& colliderList) const
{
int ret = 0;
for (const CCameraCollider& c : colliderList)
if (c.x4c_occlusionCount >= 2)
++ret;
return ret;
}
void CBallCamera::UpdateCollidersDistances(std::vector<CCameraCollider>& colliderList, float f1, float f2, float f3)
{
}
void CBallCamera::UpdateUsingColliders(float dt, CStateManager& mgr)
{
}
void CBallCamera::UpdateUsingSpindleCameras(float dt, CStateManager& mgr)
{
}
zeus::CVector3f CBallCamera::ClampElevationToWater(zeus::CVector3f& pos, CStateManager& mgr) const
{
return {};
}
void CBallCamera::UpdateUsingTransitions(float dt, CStateManager& mgr)
{
}
zeus::CTransform CBallCamera::UpdateCameraPositions(float dt, const zeus::CTransform& oldXf,
const zeus::CTransform& newXf)
{
return {};
}
bool CBallCamera::CheckFailsafeFromMorphBallState(CStateManager& mgr) const
{
return false;
}
bool CBallCamera::SplineIntersectTest(CMaterialList& intersectMat, CStateManager& mgr) const
{
return false;
}
bool CBallCamera::IsBallNearDoor(CStateManager& mgr) const
{
return false;
}
void CBallCamera::ActivateFailsafe(float dt, CStateManager& mgr)
{
}
void CBallCamera::ConstrainElevationAndDistance(float& elevation, float& distance, float f1, CStateManager& mgr)
{
}
zeus::CVector3f CBallCamera::FindDesiredPosition(float distance, float elevation,
const zeus::CVector3f& dir, CStateManager& mgr)
{
return {};
}
bool CBallCamera::DetectCollision(const zeus::CVector3f& from, const zeus::CVector3f& to, float margin,
float& d, CStateManager& mgr)
{
return false;
}
void CBallCamera::Think(float dt, CStateManager& mgr)
{
mgr.SetActorAreaId(*this, mgr.GetNextAreaId());
UpdatePlayerMovement(dt, mgr);
TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(x46c_collisionActorId);
if (colAct)
mgr.SetActorAreaId(*colAct, mgr.GetNextAreaId());
switch (mgr.GetPlayer().GetCameraState())
{
default:
if (!x18d_27_)
{
if (colAct)
colAct->SetActive(false);
return;
}
case CPlayer::EPlayerCameraState::Ball:
case CPlayer::EPlayerCameraState::Transitioning:
case CPlayer::EPlayerCameraState::Two:
{
if (colAct)
colAct->SetActive(true);
zeus::CTransform oldXf = x34_transform;
if (mgr.GetPlayer().GetBombJumpCount() != 1)
UpdateLookAtPosition(dt, mgr);
CheckFailsafe(dt, mgr);
UpdateObjectTooCloseId(mgr);
UpdateAnglePerSecond(dt);
switch (x400_state)
{
case EBallCameraState::Zero:
case EBallCameraState::Two:
case EBallCameraState::Three:
switch (x188_behaviour)
{
case EBallCameraBehaviour::Seven:
UpdateUsingPathCameras(dt, mgr);
break;
case EBallCameraBehaviour::Four:
case EBallCameraBehaviour::Five:
UpdateUsingFixedCameras(dt, mgr);
break;
case EBallCameraBehaviour::Six:
case EBallCameraBehaviour::Zero:
case EBallCameraBehaviour::One:
case EBallCameraBehaviour::Two:
if (x36c_)
UpdateUsingFreeLook(dt, mgr);
else
UpdateUsingColliders(dt, mgr);
break;
case EBallCameraBehaviour::Eight:
UpdateUsingSpindleCameras(dt, mgr);
break;
default:
break;
}
break;
case EBallCameraState::Four:
case EBallCameraState::Five:
UpdateUsingTransitions(dt, mgr);
break;
default:
break;
}
SetTransform(ValidateCameraTransform(UpdateCameraPositions(dt, oldXf, x34_transform), oldXf));
break;
}
}
}
bool CBallCamera::TransitionFromMorphBallState(CStateManager& mgr)
@ -156,7 +634,7 @@ void CBallCamera::ResetToTweaks(CStateManager& mgr)
}
void CBallCamera::UpdateLookAtPosition(float offset, CStateManager& mgr)
void CBallCamera::UpdateLookAtPosition(float dt, CStateManager& mgr)
{
}
@ -176,4 +654,18 @@ void CBallCamera::ResetPosition()
}
void CBallCamera::DoorClosed(TUniqueId doorId)
{
if (doorId != x3dc_tooCloseActorId)
return;
x18e_27_nearbyDoorClosed = true;
}
void CBallCamera::DoorClosing(TUniqueId doorId)
{
if (doorId != x3dc_tooCloseActorId)
return;
x18e_28_nearbyDoorClosing = true;
}
}

View File

@ -6,6 +6,7 @@
namespace urde
{
class CPlayer;
class CCameraSpring
{
@ -63,7 +64,18 @@ public:
Eight
};
private:
u32 x188_ = 0;
struct SFailsafeState
{
zeus::CTransform x0_;
zeus::CTransform x30_;
zeus::CVector3f x60_;
zeus::CVector3f x6c_;
zeus::CVector3f x78_;
zeus::CVector3f x84_;
std::vector<zeus::CVector3f> x90_;
};
EBallCameraBehaviour x188_behaviour = EBallCameraBehaviour::Zero;
bool x18c_24_ : 1;
bool x18c_25_ : 1;
bool x18c_26_ : 1;
@ -83,15 +95,15 @@ private:
bool x18e_24_ : 1;
bool x18e_25_ : 1;
bool x18e_26_ : 1;
bool x18e_27_ : 1;
bool x18e_28_ : 1;
float x190_origMinDistance;
float x194_minDistance;
bool x18e_27_nearbyDoorClosed : 1;
bool x18e_28_nearbyDoorClosing : 1;
float x190_curMinDistance;
float x194_targetMinDistance;
float x198_maxDistance;
float x19c_backwardsDistance;
float x1a0_elevation;
float x1a4_origAnglePerSecond;
float x1a8_anglePerSecond;
float x1a4_curAnglePerSecond;
float x1a8_targetAnglePerSecond;
float x1ac_ = 1.5533431f;
float x1b0_ = 1.5533431f;
zeus::CVector3f x1b4_lookAtOffset;
@ -108,39 +120,25 @@ private:
std::vector<CCameraCollider> x264_smallColliders;
std::vector<CCameraCollider> x274_mediumColliders;
std::vector<CCameraCollider> x284_largeColliders;
float x294_ = 0.f;
float x298_ = 0.f;
float x29c_ = 0.f;
float x2a0_ = 0.f;
float x2a4_ = 0.f;
float x2a8_ = 1.f;
float x2ac_ = 0.f;
float x2b0_ = 0.f;
float x2b4_ = 1.f;
float x2b8_ = 0.f;
float x2bc_ = 0.f;
float x2c0_ = 1.f;
zeus::CVector3f x294_;
zeus::CVector3f x2a0_ = zeus::CVector3f::skUp;
zeus::CVector3f x2ac_ = zeus::CVector3f::skUp;
zeus::CVector3f x2b8_ = zeus::CVector3f::skUp;
u32 x2c4_ = 0;
u32 x2c8_ = 0;
u32 x2cc_ = 0;
u32 x2d0_ = 0;
u32 x2d4_ = 0;
u32 x2d8_ = 0;
float x2dc_ = 0.f;
float x2e0_ = 0.f;
float x2e4_ = 0.f;
zeus::CVector3f x2dc_;
float x2e8_ = 0.f;
float x2ec_ = 0.f;
zeus::CVector3f x2f0_;
zeus::CVector3f x2fc_;
float x308_ = 0.f;
float x30c_ = 0.f;
float x310_ = 0.f;
float x314_ = 0.f;
float x318_ = 0.f;
float x31c_ = 0.f;
float x320_ = 0.f;
float x324_ = 0.f;
zeus::CVector3f x310_;
zeus::CVector3f x31c_;
u32 x328_ = 0;
float x32c_ = 1.f;
float x330_ = 0.2f;
@ -153,6 +151,7 @@ private:
u32 x36c_ = 0;
bool x370_24_ : 1;
float x374_ = 0.f;
float x378_;
CCameraSpline x37c_camSpline;
CMaterialList x3c8_ = {EMaterialTypes::Unknown};
bool x3d0_24_ : 1;
@ -180,24 +179,71 @@ private:
CCameraSpring x448_ballCameraBoostSpring;
zeus::CVector3f x45c_;
float x468_;
TUniqueId x46c_ = kInvalidUniqueId;
TUniqueId x46c_collisionActorId = kInvalidUniqueId;
float x470_ = 0.f;
float x474_ = 0.f;
u32 x478_ = 0;
std::unique_ptr<SFailsafeState> x47c_failsafeState;
std::unique_ptr<u32> x480_;
void SetupColliders(std::vector<CCameraCollider>& out, float xMag, float zMag, float radius, int count,
float tardis, float max, float startAngle);
void ResetSpline(CStateManager& mgr);
void BuildSpline(CStateManager& mgr);
bool ShouldResetSpline(CStateManager& mgr) const;
void UpdatePlayerMovement(float dt, CStateManager& mgr);
void UpdateTransform(const zeus::CVector3f& lookDir, const zeus::CVector3f& pos, float dt, CStateManager& mgr);
zeus::CVector3f ConstrainYawAngle(const CPlayer& player, float f1, float f2, float dt) const;
void CheckFailsafe(float dt, CStateManager& mgr);
void UpdateObjectTooCloseId(CStateManager& mgr);
void UpdateAnglePerSecond(float dt);
void UpdateUsingPathCameras(float dt, CStateManager& mgr);
zeus::CVector3f GetFixedLookTarget(const zeus::CVector3f& pos, CStateManager& mgr) const;
void UpdateUsingFixedCameras(float dt, CStateManager& mgr);
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 MoveCollisionActor(const zeus::CVector3f& pos, float dt, CStateManager& mgr);
void UpdateUsingFreeLook(float dt, CStateManager& mgr);
zeus::CVector3f InterpolateCameraElevation(const zeus::CVector3f& camPos) const;
zeus::CVector3f CalculateCollidersCentroid(const std::vector<CCameraCollider>& colliderList, int w1) const;
zeus::CVector3f ApplyColliders();
void UpdateColliders(const zeus::CTransform& xf, std::vector<CCameraCollider>& colliderList, int& r6, int r7,
float f1, const rstl::reserved_vector<TUniqueId, 1024>& nearList, float f2,
CStateManager& mgr);
void AvoidGeometry(const zeus::CTransform& xf, const rstl::reserved_vector<TUniqueId, 1024>& nearList,
float dt, CStateManager& mgr);
void AvoidGeometryFull(const zeus::CTransform& xf, const rstl::reserved_vector<TUniqueId, 1024>& nearList,
float dt, CStateManager& mgr);
zeus::CAABox CalculateCollidersBoundingBox(const std::vector<CCameraCollider>& colliderList,
CStateManager& mgr) const;
int CountObscuredColliders(const std::vector<CCameraCollider>& colliderList) const;
void UpdateCollidersDistances(std::vector<CCameraCollider>& colliderList, float f1, float f2, float f3);
void UpdateUsingColliders(float dt, CStateManager& mgr);
void UpdateUsingSpindleCameras(float dt, CStateManager& mgr);
zeus::CVector3f ClampElevationToWater(zeus::CVector3f& pos, CStateManager& mgr) const;
void UpdateUsingTransitions(float dt, CStateManager& mgr);
zeus::CTransform UpdateCameraPositions(float dt, const zeus::CTransform& oldXf, const zeus::CTransform& newXf);
bool CheckFailsafeFromMorphBallState(CStateManager& mgr) const;
bool SplineIntersectTest(CMaterialList& intersectMat, CStateManager& mgr) const;
bool IsBallNearDoor(CStateManager& mgr) const;
void ActivateFailsafe(float dt, CStateManager& mgr);
void ConstrainElevationAndDistance(float& elevation, float& distance, float f1, CStateManager& mgr);
zeus::CVector3f FindDesiredPosition(float distance, float elevation, const zeus::CVector3f& dir, CStateManager& mgr);
static bool DetectCollision(const zeus::CVector3f& from, const zeus::CVector3f& to, float margin,
float& d, CStateManager& mgr);
public:
CBallCamera(TUniqueId uid, TUniqueId watchedId, const zeus::CTransform& xf,
float fovy, float znear, float zfar, float aspect);
void Accept(IVisitor& visitor);
void ProcessInput(const CFinalInput&, CStateManager& mgr);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr);
void ProcessInput(const CFinalInput& input, CStateManager& mgr);
void Reset(const zeus::CTransform&, CStateManager& mgr);
void Render(const CStateManager& mgr) const;
EBallCameraState GetState() const { return x400_state; }
void SetState(EBallCameraState state, CStateManager& mgr);
void Think(float dt, CStateManager& mgr);
bool TransitionFromMorphBallState(CStateManager& mgr);
TUniqueId GetTooCloseActorId() const { return x3dc_tooCloseActorId; }
float GetX3E0() const { return x3e0_; }
@ -205,12 +251,14 @@ public:
void TeleportCamera(const zeus::CTransform& xf, CStateManager& mgr);
const zeus::CVector3f& GetX1D8() const { return x1d8_; }
void ResetToTweaks(CStateManager& mgr);
void UpdateLookAtPosition(float offset, CStateManager& mgr);
void UpdateLookAtPosition(float dt, CStateManager& mgr);
zeus::CTransform UpdateLookDirection(const zeus::CVector3f& dir, CStateManager& mgr);
void SetX470(float f) { x470_ = f; }
void SetX474(float f) { x474_ = f; }
void ApplyCameraHint(CStateManager& mgr);
void ResetPosition();
void DoorClosed(TUniqueId doorId);
void DoorClosing(TUniqueId doorId);
};
}

View File

@ -23,4 +23,28 @@ void CCameraSpline::CalculateKnots(TUniqueId cameraId, const std::vector<SConnec
//if (waypoint)
}
}
void CCameraSpline::Reset(int size)
{
x4_.clear();
x24_.clear();
x34_.clear();
if (size != 0)
{
x4_.reserve(size);
x24_.reserve(size);
x34_.reserve(size);
}
}
void CCameraSpline::AddKnot(const zeus::CVector3f& v0, const zeus::CVector3f& v1)
{
x4_.push_back(v0);
x34_.push_back(v1);
}
float CCameraSpline::CalculateSplineLength()
{
return 0.f;
}
}

View File

@ -8,6 +8,7 @@ namespace urde
class CStateManager;
class CCameraSpline
{
friend class CBallCamera;
std::vector<zeus::CVector3f> x4_;
std::vector<TUniqueId> x14_;
std::vector<float> x24_;
@ -18,6 +19,9 @@ public:
CCameraSpline(bool);
void CalculateKnots(TUniqueId, const std::vector<SConnection>&, CStateManager&);
void Initialize(TUniqueId, const std::vector<SConnection>&, CStateManager&);
void Reset(int size);
void AddKnot(const zeus::CVector3f& v0, const zeus::CVector3f& v1);
float CalculateSplineLength();
};
}

View File

@ -153,6 +153,7 @@ public:
const CMaterialFilter& GetMaterialFilter() const { return x70_materialFilter; }
void SetMaterialFilter(const CMaterialFilter& filter) { x70_materialFilter = filter; }
const CMaterialList& GetMaterialList() const { return x68_material; }
void SetMaterialList(const CMaterialList& list) { x68_material = list; }
void SetInFluid(bool in, TUniqueId uid);
bool HasModelData() const;
const CSfxHandle& GetSfxHandle() const { return x8c_loopingSfxHandle; }

View File

@ -294,6 +294,8 @@ public:
u32 GetMorphballModelShader() const { return x5c_ballModelShader; }
bool GetBoostEnabled() const { return x1de4_25_boostEnabled; }
void SetBoostEnabed(bool b) { x1de4_25_boostEnabled = b; }
bool IsInBoost() const { return x1de4_24_inBoost; }
float GetBoostChargeTime() const { return x1de8_boostChargeTime; }
static const u8 BallGlowColors[9][3];
static const u8 BallTransFlashColors[9][3];

View File

@ -676,6 +676,7 @@ public:
TUniqueId GetRidingPlatformId() const { return x82e_ridingPlatform; }
const zeus::CVector3f& GetLastVelocity() const { return x794_lastVelocity; }
const zeus::CVector3f& GetMoveDir() const { return x50c_moveDir; }
u32 GetBombJumpCount() const { return x9d0_bombJumpCount; }
};
}

View File

@ -91,10 +91,8 @@ void CScriptDoor::ForceClosed(CStateManager & mgr)
x2a8_26_ = false;
x2a8_25_ = false;
/* TODO: Figure out what goes here this
* mgr.GetCameraManager()->GetBallCamera()->sub_80083118(x8_uid);
* mgr.GetCameraManager()->GetBallCamera()->sub_800830F4(x8_uid);
*/
mgr.GetCameraManager()->GetBallCamera()->DoorClosing(x8_uid);
mgr.GetCameraManager()->GetBallCamera()->DoorClosed(x8_uid);
SetDoorAnimation(EDoorAnimType::Close);
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);