Continued work on CActor

This commit is contained in:
2022-08-15 00:51:06 -04:00
parent 16514e942e
commit 09dfe946fc
97 changed files with 234 additions and 159 deletions

View File

@@ -8,6 +8,13 @@ public:
CSfxHandle() : value(0) {}
CSfxHandle(u32 value) : value(value) {}
// GetIndex__10CSfxHandleCFv
// NullHandle__10CSfxHandleFv
// mRefCount__10CSfxHandle ??
bool operator==(const CSfxHandle& other) { return value == other.value; }
operator bool() const { return value != 0; }
private:
u32 value;
};

View File

@@ -3,9 +3,12 @@
#include "types.h"
#include "Kyoto/Audio/CSfxHandle.hpp"
class CSfxManager {
public:
static void Update(f32 dt);
static void RemoveEmitter(CSfxHandle handle);
};
#endif

View File

@@ -8,6 +8,7 @@ public:
CAABox() {
// TODO
}
CAABox(const CVector3f& min, const CVector3f& max);// : min(min), max(max) {}
static CAABox mskInvertedBox;
static CAABox mskNullBox;

View File

@@ -101,13 +101,34 @@ inline bool operator!=(const CVector3f& lhs, const CVector3f& rhs) {
return lhs.GetX() != rhs.GetX() || lhs.GetY() != rhs.GetY() || lhs.GetZ() != rhs.GetZ();
}
inline CVector3f operator-(const CVector3f& lhs, const CVector3f& rhs) {
return CVector3f(lhs.GetX() - rhs.GetX(), lhs.GetY() - rhs.GetY(), lhs.GetZ() - rhs.GetZ());
f32 x = lhs.GetX() - rhs.GetX();
f32 y = lhs.GetY() - rhs.GetY();
f32 z = lhs.GetZ() - rhs.GetZ();
return CVector3f(x, y, z);
}
inline CVector3f operator+(const CVector3f& lhs, const CVector3f& rhs) {
return CVector3f(lhs.GetX() + rhs.GetX(), lhs.GetY() + rhs.GetY(), lhs.GetZ() + rhs.GetZ());
f32 x = lhs.GetX() + rhs.GetX();
f32 y = lhs.GetY() + rhs.GetY();
f32 z = lhs.GetZ() + rhs.GetZ();
return CVector3f(x, y, z);
}
inline CVector3f operator*(const CVector3f& vec, f32 f) {
f32 x = vec.GetX() * f;
f32 y = vec.GetY() * f;
f32 z = vec.GetZ() * f;
return CVector3f(x, y, z);
}
inline CVector3f operator/(const CVector3f& vec, f32 f) {
f32 x = vec.GetX() / f;
f32 y = vec.GetY() / f;
f32 z = vec.GetZ() / f;
return CVector3f(x, y, z);
}
inline CVector3f operator-(const CVector3f& vec) {
f32 x = -vec.GetX();
f32 y = -vec.GetY();
f32 z = -vec.GetZ();
return CVector3f(x, y, z);
}
inline CVector3f operator*(const CVector3f& vec, f32 f) { return CVector3f(vec.GetX() * f, vec.GetY() * f, vec.GetZ() * f); }
inline CVector3f operator/(const CVector3f& vec, f32 f) { return CVector3f(vec.GetX() / f, vec.GetY() / f, vec.GetZ() / f); }
inline CVector3f operator-(const CVector3f& vec) { return CVector3f(-vec.GetX(), -vec.GetY(), -vec.GetZ()); }
#endif // __CVECTOR3F_HPP__

View File

@@ -9,8 +9,8 @@
#include "MetroidPrime/CEntity.hpp"
#include "MetroidPrime/CModelData.hpp"
#include "MetroidPrime/CModelFlags.hpp"
#include "MetroidPrime/CSfxHandle.hpp"
#include "Kyoto/Audio/CSfxHandle.hpp"
#include "Kyoto/Graphics/CColor.hpp"
#include "Kyoto/Math/CAABox.hpp"
#include "Kyoto/Math/CTransform4f.hpp"
@@ -189,11 +189,6 @@ enum EUserEventType {
kUE_EffectOff = 34,
};
// class CBoolPOINode;
// class CInt32POINode;
// class CParticlePOINode;
// class CSoundPOINode;
class CActor : public CEntity {
public:
enum EThermalFlags {
@@ -235,7 +230,7 @@ public:
virtual void FluidFXThink(EFluidState, CScriptWater&, CStateManager&);
virtual void OnScanStateChanged(EScanState, CStateManager&);
virtual CAABox GetSortingBounds(const CStateManager&) const;
virtual void DoUserAnimEvent(CStateManager&, const CInt32POINode&, EUserEventType, float dt);
virtual void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt);
SAdvancementDeltas UpdateAnimation(float dt, CStateManager& mgr, bool advTree);
@@ -244,24 +239,17 @@ public:
void UpdateSfxEmitters();
void RemoveEmitter();
void SetModelData(const CModelData& modelData);
const CTransform4f& GetTransform() const { return x34_transform; }
CVector3f GetTranslation() const { return x34_transform.GetTranslation(); }
bool GetMuted() const { return xe5_26_muted; }
bool HasAnimation() const { return x64_modelData && x64_modelData->GetAnimationData(); }
// const CBoolPOINode* GetBoolPOIList(s32& count) {
// return HasAnimation() ? x64_modelData->GetAnimationData()->GetBoolPOIList(count) : nullptr;
// }
// const CInt32POINode* GetInt32POIList(s32& count) {
// return HasAnimation() ? x64_modelData->GetAnimationData()->GetInt32POIList(count) : nullptr;
// }
// const CParticlePOINode* GetParticlePOIList(s32& count) {
// return HasAnimation() ? x64_modelData->GetAnimationData()->GetParticlePOIList(count) : nullptr;
// }
// const CSoundPOINode* GetSoundPOIList(s32& count) {
// return HasAnimation() ? x64_modelData->GetAnimationData()->GetSoundPOIList(count) : nullptr;
// }
bool HasModelData() const { return x64_modelData && (x64_modelData->GetAnimationData() || x64_modelData->HasNormalModel()); }
CModelData* GetModelData() const { return x64_modelData.get(); }
CAnimData* AnimationData() { return GetModelData()->GetAnimationData(); }
const CAnimData* GetAnimationData() const { return GetModelData()->GetAnimationData(); }
f32 GetAverageAnimVelocity(s32 anim);
protected:
CTransform4f x34_transform;

View File

@@ -36,20 +36,21 @@ public:
}
s32 GetCharacterIndex() const { return x204_charIdx; }
f32 GetAverageVelocity(s32 idx) const;
const CBoolPOINode* GetBoolPOIList(s32& count) {
const CBoolPOINode* GetBoolPOIList(s32& count) const {
count = x20c_passedBoolCount;
return mBoolPOINodes.data();
}
const CInt32POINode* GetInt32POIList(s32& count) {
const CInt32POINode* GetInt32POIList(s32& count) const {
count = x210_passedIntCount;
return mInt32POINodes.data();
}
const CParticlePOINode* GetParticlePOIList(s32& count) {
const CParticlePOINode* GetParticlePOIList(s32& count) const {
count = x214_passedParticleCount;
return mParticlePOINodes.data();
}
const CSoundPOINode* GetSoundPOIList(s32& count) {
const CSoundPOINode* GetSoundPOIList(s32& count) const {
count = x218_passedSoundCount;
return mSoundPOINodes.data();
}
@@ -171,10 +172,10 @@ private:
f32 x200_speedScale;
s32 x204_charIdx;
s32 x208_defaultAnim;
u32 x20c_passedBoolCount;
u32 x210_passedIntCount;
u32 x214_passedParticleCount;
u32 x218_passedSoundCount;
s32 x20c_passedBoolCount;
s32 x210_passedIntCount;
s32 x214_passedParticleCount;
s32 x218_passedSoundCount;
s32 x21c_particleLightIdx;
bool x220_24_animating : 1;
bool x220_25_loop : 1;

View File

@@ -3,9 +3,9 @@
#include "types.h"
#include "MetroidPrime/CSfxHandle.hpp"
#include "MetroidPrime/TGameTypes.hpp"
#include "Kyoto/Audio/CSfxHandle.hpp"
#include "Kyoto/Math/CAABox.hpp"
#include "Kyoto/Math/CVector2i.hpp"
#include "Kyoto/Math/CVector3f.hpp"

View File

@@ -6,14 +6,15 @@
#include "MetroidPrime/TGameTypes.hpp"
#include "Kyoto/Graphics/CColor.hpp"
#include "Kyoto/Math/CVector3f.hpp"
#include "Kyoto/Math/CTransform4f.hpp"
#include "Kyoto/Math/CVector3f.hpp"
#include "Kyoto/TToken.hpp"
#include "rstl/auto_ptr.hpp"
#include "rstl/optional_object.hpp"
#include "rstl/pair.hpp"
class CAABox;
class CAnimData;
class CModel;
@@ -27,11 +28,13 @@ CHECK_SIZEOF(SAdvancementDeltas, 0x1c)
class CModelData {
public:
// TODO these probably aren't real
bool IsStaticModel() const { return xc_animData.get() == nullptr && !x1c_normalModel; }
bool HasNormalModel() const { return x1c_normalModel; }
CModelData() {
// TODO
}
CModelData();
// __ct__10CModelDataFRC8CAnimRes
// __ct__10CModelDataFRC10CStaticRes
CModelData(const CModelData& other);
~CModelData();
@@ -39,6 +42,10 @@ public:
void AdvanceParticles(const CTransform4f& xf, float dt, CStateManager& mgr);
CAnimData* GetAnimationData() const { return xc_animData.get(); }
CAABox GetBounds(const CTransform4f& xf) const;
CAABox GetBounds() const;
bool IsNull() const { return xc_animData.get() == nullptr && !x1c_normalModel; }
void SetXRayModel(const rstl::pair< CAssetId, CAssetId >& assets);
void SetInfraModel(const rstl::pair< CAssetId, CAssetId >& assets);

View File

@@ -8,21 +8,23 @@
#include "rstl/string.hpp"
#define POITYPE_LOOP 0
#define POITYPE_EMPTYBOOL 1
#define POITYPE_EMPTYINT32 2
#define POITYPE_SOUNDINT32 4
#define POITYPE_PARTICLE 5
#define POITYPE_USEREVENT 6
#define POITYPE_RANDRATE 7
#define POITYPE_SOUND 8
enum EPOIType {
kPT_Loop = 0,
kPT_EmptyBool = 1,
kPT_EmptyInt32 = 2,
kPT_SoundInt32 = 4,
kPT_Particle = 5,
kPT_UserEvent = 6,
kPT_RandRate = 7,
kPT_Sound = 8,
};
class CPOINode {
public:
virtual ~CPOINode();
const rstl::string& GetString() const { return x8_name; }
s32 GetPoiType() const { return x18_type; }
EPOIType GetPoiType() const { return static_cast< EPOIType >(x18_type); }
const CCharAnimTime& GetTime() const { return x1c_time; }
f32 GetWeight() const { return x2c_weight; }
s32 GetCharacterIndex() const { return x30_charIdx; }
@@ -31,7 +33,7 @@ public:
protected:
u16 x4_;
rstl::string x8_name;
s16 x18_type;
u16 x18_type;
CCharAnimTime x1c_time;
s32 x24_index;
bool x28_unique;

View File

@@ -12,8 +12,8 @@ public:
single_ptr() : x0_ptr(nullptr) {}
single_ptr(T* ptr) : x0_ptr(ptr) {}
~single_ptr() { delete x0_ptr; }
T* get() { return x0_ptr; }
const T* get() const { return x0_ptr; }
T* get() const { return x0_ptr; }
// const T* get() const { return x0_ptr; }
T* operator->() { return x0_ptr; }
const T* operator->() const { return x0_ptr; }
void operator=(T* ptr) {