Compare commits

...

2 Commits

Author SHA1 Message Date
Phillip Stephens 7eaafd5cc4 Add missing CPathCamera files 2024-03-18 16:01:45 -07:00
Phillip Stephens 953c5e1edf Initial CPathCamera 2024-03-18 16:00:25 -07:00
6 changed files with 193 additions and 16 deletions

View File

@ -1438,7 +1438,7 @@ GetKnotPosition__11CBallCameraCFi = .text:0x8005D084; // type:function size:0x54
GetKnotT__13CCameraSplineCFi = .text:0x8005D0D8; // type:function size:0x24 scope:global
CalculateKnots__13CCameraSplineFRCQ24rstl48vector<11SConnection,Q24rstl17rmemory_allocator>R13CStateManager = .text:0x8005D0FC; // type:function size:0x3B4 scope:global
__as__Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>FRCQ24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator> = .text:0x8005D4B0; // type:function size:0xF4 scope:global
Initialise__13CCameraSplineFRCQ24rstl48vector<11SConnection,Q24rstl17rmemory_allocator>R13CStateManager = .text:0x8005D5A4; // type:function size:0x44 scope:global
Initialise__13CCameraSplineF9TUniqueIdRCQ24rstl48vector<11SConnection,Q24rstl17rmemory_allocator>R13CStateManager = .text:0x8005D5A4; // type:function size:0x44 scope:global
__dt__13CCameraSplineFv = .text:0x8005D5E8; // type:function size:0x178 scope:global
__ct__13CCameraSplineFb = .text:0x8005D760; // type:function size:0x50 scope:global
Reset__13CCameraSpringFv = .text:0x8005D7B0; // type:function size:0x44 scope:global
@ -6929,7 +6929,7 @@ ClampToClosedDoor__11CPathCameraFR13CStateManager = .text:0x8012DD3C; // type:fu
MoveAlongSpline__11CPathCameraFfR13CStateManager = .text:0x8012DE30; // type:function size:0x3D8 scope:global
Reset__11CPathCameraFRC12CTransform4fR13CStateManager = .text:0x8012E208; // type:function size:0x4A0 scope:global
__dt__11CPathCameraFv = .text:0x8012E6A8; // type:function size:0x70 scope:global
__ct__11CPathCameraF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbbbbbfffffffQ211CPathCamera22EInitialSplinePosition = .text:0x8012E718; // type:function size:0x17C scope:global
__ct__11CPathCameraF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbfffffUlQ211CPathCamera22EInitialSplinePosition = .text:0x8012E718; // type:function size:0x17C scope:global
__sinit_CPathCamera_cpp = .text:0x8012E894; // type:function size:0x78 scope:local
fn_8012E90C = .text:0x8012E90C; // type:function size:0x4
AddRipple__11CFluidPlaneFRC7CRippleRC12CScriptWaterR13CStateManager = .text:0x8012E910; // type:function size:0x54 scope:global
@ -18268,7 +18268,7 @@ __vt__11CBCCoverCmd = .data:0x803E0B8C; // type:object size:0xC scope:global
__vt__14CBCWallHangCmd = .data:0x803E0B98; // type:object size:0x48 scope:global
lbl_803E0BE0 = .data:0x803E0BE0; // type:object size:0x18
__vt__17CScriptCoverPoint = .data:0x803E0BF8; // type:object size:0x6C scope:global
lbl_803E0C68 = .data:0x803E0C68; // type:object size:0x78
__vt__11CPathCamera = .data:0x803E0C68; // type:object size:0x78
lbl_803E0CE0 = .data:0x803E0CE0; // type:object size:0x20
__vt__19CScriptGrapplePoint = .data:0x803E0D00; // type:object size:0x6C scope:global
__vt__19CHUDBillboardEffect = .data:0x803E0D70; // type:object size:0x6C scope:global

View File

@ -1438,7 +1438,7 @@ GetKnotPosition__11CBallCameraCFi = .text:0x8005D100; // type:function size:0x54
GetKnotT__13CCameraSplineCFi = .text:0x8005D154; // type:function size:0x24 scope:global
CalculateKnots__13CCameraSplineFRCQ24rstl48vector<11SConnection,Q24rstl17rmemory_allocator>R13CStateManager = .text:0x8005D178; // type:function size:0x3B4 scope:global
__as__Q24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator>FRCQ24rstl45vector<9TUniqueId,Q24rstl17rmemory_allocator> = .text:0x8005D52C; // type:function size:0xF4 scope:global
Initialise__13CCameraSplineFRCQ24rstl48vector<11SConnection,Q24rstl17rmemory_allocator>R13CStateManager = .text:0x8005D620; // type:function size:0x44 scope:global
Initialise__13CCameraSplineF9TUniqueIdRCQ24rstl48vector<11SConnection,Q24rstl17rmemory_allocator>R13CStateManager = .text:0x8005D620; // type:function size:0x44 scope:global
__dt__13CCameraSplineFv = .text:0x8005D664; // type:function size:0x178 scope:global
__ct__13CCameraSplineFb = .text:0x8005D7DC; // type:function size:0x50 scope:global
Reset__13CCameraSpringFv = .text:0x8005D82C; // type:function size:0x44 scope:global
@ -6931,7 +6931,7 @@ ClampToClosedDoor__11CPathCameraFR13CStateManager = .text:0x8012DDB8; // type:fu
MoveAlongSpline__11CPathCameraFfR13CStateManager = .text:0x8012DEAC; // type:function size:0x3D8 scope:global
Reset__11CPathCameraFRC12CTransform4fR13CStateManager = .text:0x8012E284; // type:function size:0x4A0 scope:global
__dt__11CPathCameraFv = .text:0x8012E724; // type:function size:0x70 scope:global
__ct__11CPathCameraF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbbbbbfffffffQ211CPathCamera22EInitialSplinePosition = .text:0x8012E794; // type:function size:0x17C scope:global
__ct__11CPathCameraF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbfffffUlQ211CPathCamera22EInitialSplinePosition = .text:0x8012E794; // type:function size:0x17C scope:global
__sinit_CPathCamera_cpp = .text:0x8012E910; // type:function size:0x78 scope:global
nullsub_209 = .text:0x8012E988; // type:function size:0x4 scope:global
AddRipple__11CFluidPlaneFRC7CRippleRC12CScriptWaterR13CStateManager = .text:0x8012E98C; // type:function size:0x54 scope:global
@ -18321,7 +18321,7 @@ __vt__11CBCCoverCmd = .data:0x803E0D6C; // type:object size:0xC scope:global
__vt__14CBCWallHangCmd = .data:0x803E0D78; // type:object size:0x48 scope:global
lbl_803E0BE0 = .data:0x803E0DC0; // type:object size:0x18 scope:global
__vt__17CScriptCoverPoint = .data:0x803E0DD8; // type:object size:0x70 scope:global
lbl_803E0C68 = .data:0x803E0E48; // type:object size:0x78 scope:global
__vt__11CPathCamera = .data:0x803E0E48; // type:object size:0x78 scope:global
lbl_803E0CE0 = .data:0x803E0EC0; // type:object size:0x20 scope:global
__vt__19CScriptGrapplePoint = .data:0x803E0EE0; // type:object size:0x6C scope:global
__vt__19CHUDBillboardEffect = .data:0x803E0F50; // type:object size:0x70 scope:global

View File

@ -7,8 +7,10 @@
#include "Kyoto/Math/CVector3f.hpp"
#include "MetroidPrime/CEntityInfo.hpp"
#include "rstl/vector.hpp"
class CStateManager;
class CCameraSpline {
public:
CCameraSpline(bool closedLoop);
@ -16,6 +18,8 @@ public:
// tODO
void Initialise(TUniqueId, const rstl::vector<SConnection>&, CStateManager&);
private:
rstl::vector< CVector3f > x4_positions;
rstl::vector< TUniqueId > x14_wpTracker;

View File

@ -0,0 +1,44 @@
#ifndef _CPATHCAMERA
#define _CPATHCAMERA
#include "MetroidPrime/Cameras/CCameraSpline.hpp"
#include "MetroidPrime/Cameras/CGameCamera.hpp"
class CPathCamera : public CGameCamera {
public:
enum EInitialSplinePosition {
kISP_BallCamBasis,
kISP_Negative,
kISP_Positive,
kISP_ClampBasis,
};
CPathCamera(TUniqueId uid, const rstl::string& name, const CEntityInfo& info,
const CTransform4f& xf, bool active, float lengthExtent, float filterMag,
float filterProportion, float minEaseDist, float maxEaseDist, u32 flags,
EInitialSplinePosition initPos);
~CPathCamera();
void Accept(IVisitor& visitor) override;
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override;
void Think(float dt, CStateManager& mgr) override;
void Render(const CStateManager& mgr) const override;
void ProcessInput(const CFinalInput& input, CStateManager& mgr) override;
void Reset(const CTransform4f& xf, CStateManager& mgr) override;
CTransform4f MoveAlongSpline(float dt, CStateManager& mgr);
void ClampToClosedDoor(CStateManager& mgr);
private:
CCameraSpline x188_spline;
float x1d4_pos;
float x1d8_time;
float x1dc_lengthExtent;
float x1e0_filterMag;
float x1e4_filterProportion;
EInitialSplinePosition x1e8_initPos;
u32 x1ec_flags;
float x1f0_minEaseDist;
float x1f4_maxEaseDist;
};
#endif // _CPATHCAMERA

View File

@ -178,19 +178,43 @@ void* SMediumAllocPuddle::FindFreeEntry(uint numBlocks) {
}
void SMediumAllocPuddle::Free(const void* ptr) {
uint r28 = 0;
uint r29 = x8_bookKeeping[((uint)ptr - (uint)x0_mainData.get()) / 32];
x14_numBlocks += r29;
x18_numAllocs--;
uchar* bookKeepingStart = x8_bookKeeping;
uchar* block = &x8_bookKeeping[((uint)ptr - (uint)x0_mainData.get()) / 32];
uint blockOffset = ((uint)ptr - (uint)x0_mainData.get()) / 32;
uint blockCount = x8_bookKeeping[blockOffset];
if (xc_cachedBookKeepingAddr == block) {
r28 = 1;
x14_numBlocks += blockCount;
--x18_numAllocs;
uchar* bookKeepingStart = x8_bookKeeping;
uchar* cachedBookKeep = bookKeepingStart + blockOffset;
uchar* block = bookKeepingStart + blockOffset;
uchar* bookKeepingPtr = block;
if (block > bookKeepingStart && block[-1] & 0x80) {
if ((block[-1] & 0x60)) {
blockOffset = (((0x40 - (block[-1] & 0x60)) != 0) / 32) + 1;
} else if ((block[-1] & 0x60) == 0x60ul) {
blockOffset = 3;
} else {
blockOffset = block[-2] + (block[-1] & 0x7f) * 256;
}
bookKeepingPtr = block - ((ushort)blockOffset);
blockOffset = (ushort)(blockCount + ((ushort)blockOffset));
}
if (block > bookKeepingStart) {
if ((block[-1] & 0x80) != 0) {
uint blockCount2 = blockOffset;
uchar* ptr1 = block + blockCount;
if (ptr1 < bookKeepingStart + x1c_numEntries && (ptr1[0] & 0x80) != 0) {
blockOffset = GetBlockOffset(ptr1, bookKeepingStart + GetNumEntries());
blockCount2 += blockOffset;
}
InitBookKeeping(bookKeepingPtr, blockCount2);
if (cachedBookKeep == block) {
if (bookKeepingPtr != bookKeepingStart) {
xc_cachedBookKeepingAddr = nullptr;
} else {
xc_cachedBookKeepingAddr = bookKeepingPtr - bookKeepingPtr[-1];
}
}
}

View File

@ -0,0 +1,105 @@
#include "MetroidPrime/Cameras/CPathCamera.hpp"
#include "MetroidPrime/Cameras/CCameraManager.hpp"
#include "MetroidPrime/TCastTo.hpp"
// #include "MetroidPrime/ScriptObjects/CScriptDoor.hpp"
CPathCamera::CPathCamera(TUniqueId uid, const rstl::string& name, const CEntityInfo& info,
const CTransform4f& xf, bool active, float lengthExtent, float filterMag,
float filterProportion, float minEaseDist, float maxEaseDist, u32 flags,
EInitialSplinePosition initPos)
: CGameCamera(uid, active, name, info, xf, CCameraManager::DefaultThirdPersonFov(),
CCameraManager::DefaultNearPlane(), CCameraManager::DefaultFarPlane(),
CCameraManager::DefaultAspect(), kInvalidUniqueId, false, 0)
, x188_spline(flags & 1)
, x1d4_pos(0.f)
, x1d8_time(0.f)
, x1dc_lengthExtent(lengthExtent)
, x1e0_filterMag(filterMag)
, x1e4_filterProportion(filterProportion)
, x1e8_initPos(initPos)
, x1ec_flags(flags)
, x1f0_minEaseDist(minEaseDist)
, x1f4_maxEaseDist(maxEaseDist) {}
CPathCamera::~CPathCamera() {}
void CPathCamera::Reset(const CTransform4f&, CStateManager& mgr) {}
CTransform4f CPathCamera::MoveAlongSpline(float t, CStateManager& mgr) {
return CTransform4f::Identity();
}
void CPathCamera::ClampToClosedDoor(CStateManager& mgr) {
/*
if (TCastToConstPtr<CScriptDoor> door =
mgr.GetObjectById(mgr.GetCameraManager()->GetBallCamera()->GetTooCloseActorId())) {
if (!door->IsOpen() && CBallCamera::IsBallNearDoor(GetTranslation(), mgr)) {
x1d4_pos = (x1d4_pos > x1d8_time) ? x1d8_time - x1dc_lengthExtent : x1d8_time +
x1dc_lengthExtent;
SetTranslation(x188_spline.GetInterpolatedSplinePointByLength(x1d4_pos).origin);
}
}
*/
}
void CPathCamera::Think(float dt, CStateManager& mgr) {
#if 0
if (!GetActive())
return;
if (mgr.GetCameraManager()->GetPathCameraId() != GetUniqueId())
return;
if (x188_spline.GetSize() <= 0)
return;
zeus::CTransform xf = GetTransform();
zeus::CVector3f ballLook = mgr.GetCameraManager()->GetBallCamera()->GetLookPos();
if ((x1ec_flags & 0x10)) {
if (const CScriptCameraHint* hint = mgr.GetCameraManager()->GetCameraHint(mgr))
ballLook.z() = hint->GetTranslation().z();
}
if (!mgr.GetPlayer().GetVelocity().canBeNormalized() && (ballLook - GetTranslation()).canBeNormalized()) {
if (x1ec_flags & 4)
SetTransform(x188_spline.GetInterpolatedSplinePointByLength(x1d4_pos));
else
SetTransform(zeus::lookAt(GetTranslation(), ballLook));
return;
}
xf = MoveAlongSpline(dt, mgr);
SetTranslation(xf.origin);
if (x1ec_flags & 0x20)
ClampToClosedDoor(mgr);
CVector3f tmp = ballLook - GetTranslation();
tmp.SetZ(0.f);
if (tmp.CanBeNormalized())
SetTransform(zeus::lookAt(GetTranslation(), ballLook));
if (x1ec_flags & 4)
SetTransform(xf);
#endif
}
void CPathCamera::ProcessInput(const CFinalInput&, CStateManager& mgr) {
// Empty
}
void CPathCamera::Accept(IVisitor& visitor) override { visitor.Visit(*this); }
void CPathCamera::Render(const CStateManager& mgr) const {
}
void CPathCamera::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
CGameCamera::AcceptScriptMsg(msg, uid, mgr);
if (!GetActive() || msg != kSM_InitializedInArea) {
return;
}
x188_spline.Initialise(GetUniqueId(), GetConnectionList(), mgr);
}