From f64015ea383cc3ba93a90918ac3dd1d2f66e1e17 Mon Sep 17 00:00:00 2001 From: TakaRikka <38417346+TakaRikka@users.noreply.github.com> Date: Tue, 17 Mar 2026 22:48:37 -0700 Subject: [PATCH] cc debug work (#3133) --- include/SSystem/SComponent/c_bg_s_lin_chk.h | 8 +- include/SSystem/SComponent/c_cc_d.h | 27 +- include/SSystem/SComponent/c_cc_s.h | 2 +- include/SSystem/SComponent/c_m3d_g_aab.h | 24 +- include/SSystem/SComponent/c_m3d_g_cps.h | 6 +- include/SSystem/SComponent/c_m3d_g_cyl.h | 4 +- include/SSystem/SComponent/c_m3d_g_lin.h | 8 +- include/SSystem/SComponent/c_m3d_g_sph.h | 5 +- include/SSystem/SComponent/c_m3d_g_tri.h | 8 +- include/d/d_cc_d.h | 10 +- include/d/d_cc_mass_s.h | 8 +- include/d/d_cc_s.h | 12 +- include/d/d_jnt_col.h | 7 +- src/SSystem/SComponent/c_bg_s_gnd_chk.cpp | 28 +- src/SSystem/SComponent/c_bg_s_lin_chk.cpp | 8 +- src/SSystem/SComponent/c_cc_d.cpp | 206 +++++++-------- src/SSystem/SComponent/c_cc_s.cpp | 87 ++++--- src/SSystem/SComponent/c_m3d.cpp | 148 +++++------ src/d/actor/d_a_tag_sppath.cpp | 4 +- src/d/d_bg_w.cpp | 4 +- src/d/d_cc_d.cpp | 6 +- src/d/d_cc_mass_s.cpp | 161 +++++++----- src/d/d_cc_s.cpp | 267 +++++++++++++++++--- src/d/d_jnt_col.cpp | 4 +- 24 files changed, 675 insertions(+), 377 deletions(-) diff --git a/include/SSystem/SComponent/c_bg_s_lin_chk.h b/include/SSystem/SComponent/c_bg_s_lin_chk.h index 1c0b26c4a5..bf71667131 100644 --- a/include/SSystem/SComponent/c_bg_s_lin_chk.h +++ b/include/SSystem/SComponent/c_bg_s_lin_chk.h @@ -36,7 +36,7 @@ public: void SetHit() { mStts |= STTS_HIT; } u32 ChkHit() const { return mStts & STTS_HIT; } void SetCross(const cXyz& pos) { mLin.SetEnd(pos); } - cXyz* GetCrossP() { return &mLin.GetEndP(); } + cXyz* GetCrossP() { return mLin.GetEndP(); } cM3dGLin* GetLinP() { return &mLin; } bool ChkBackFlag() const { return mBackFlag; } void OnBackFlag() { mBackFlag = true; } @@ -45,13 +45,17 @@ public: bool GetPreWallChk() const { return mPreWallChk; } bool GetPreGroundChk() const { return mPreGroundChk; } bool GetPreRoofChk() const { return mPreRoofChk; } - cXyz* GetStartP() { return &mLin.GetStartP(); } + cXyz* GetStartP() { return mLin.GetStartP(); } void ClrSttsRoofOff() { mStts &= ~STTS_ROOF_OFF; } void SetSttsRoofOff() { mStts |= STTS_ROOF_OFF; } void ClrSttsWallOff() { mStts &= ~STTS_WALL_OFF; } void SetSttsWallOff() { mStts |= STTS_WALL_OFF; } void ClrSttsGroundOff() { mStts &= ~STTS_GROUND_OFF; } void SetSttsGroundOff() { mStts |= STTS_GROUND_OFF; } + void ClearCheckIndex() { ClearPi(); } + bool ChkSttsWallOff() const { return (mStts & STTS_WALL_OFF); } + bool ChkSttsGroundOff() const { return (mStts & STTS_GROUND_OFF); } + bool ChkSttsRoofOff() const { return (mStts & STTS_ROOF_OFF); } }; #endif /* C_BG_S_LIN_CHK_H */ diff --git a/include/SSystem/SComponent/c_cc_d.h b/include/SSystem/SComponent/c_cc_d.h index f80c33b823..3d402d1825 100644 --- a/include/SSystem/SComponent/c_cc_d.h +++ b/include/SSystem/SComponent/c_cc_d.h @@ -188,6 +188,7 @@ public: cXyz* GetCCMoveP() { return &m_cc_move; } fpc_ProcID GetApid() const { return m_apid; } u8 GetDmg() const { return m_dmg; } + void ClrCo() { ClrCcMove(); } }; // Size = 0x1C STATIC_ASSERT(0x1C == sizeof(cCcD_Stts)); @@ -213,7 +214,7 @@ public: void ct(); void SetSPrm(u32 sprm) { mSPrm = sprm; } s32 getSPrm() const { return mSPrm; } - void setRPrm(s32 rprm) { mRPrm = rprm; } + void SetRPrm(u32 rprm) { mRPrm = rprm; } s32 getRPrm() const { return mRPrm; } cCcD_Obj* GetHitObj() { return mHitObj; } const cCcD_Obj* GetHitObj() const { return mHitObj; } @@ -222,6 +223,9 @@ public: void OnSPrmBit(u32 flag) { mSPrm |= flag; } void OffSPrmBit(u32 flag) { mSPrm &= ~flag; } u32 ChkSPrm(u32 prm) const { return MskSPrm(prm) != 0; } + void SetHitObj(cCcD_Obj* pobj) { mHitObj = pobj; } + void ClrRPrm(u32 prm) { mRPrm &= ~prm; } + void ClrObj() { mHitObj = NULL; } void Set(cCcD_SrcObjCommonBase const& src) { mSPrm = src.mSPrm; } }; @@ -240,7 +244,7 @@ public: void ClrHit(); int GetType() const { return mType; } u32 GetGrp() const { return MskSPrm(0x1E); } - bool ChkSet() const { return MskSPrm(1); } + BOOL ChkSet() const { return MskSPrm(1); } u8 GetAtp() const { return mAtp; } u32 MskType(u32 msk) const { return mType & msk; } void SetType(u32 type) { mType = type; } @@ -269,7 +273,7 @@ public: int GetType() const { return mType; } void SetType(u32 type) { mType = type; } u32 GetGrp() const { return MskSPrm(0x1E); } - bool ChkSet() const { return MskSPrm(1); } + BOOL ChkSet() const { return MskSPrm(1); } void ClrSet() { OffSPrmBit(1); } u32 ChkHit() const { return MskRPrm(1); } @@ -289,7 +293,7 @@ public: void SetIGrp(u32); void SetVsGrp(u32); u32 GetGrp() const { return MskSPrm(0x1E); } - bool ChkSet() const { return MskSPrm(1); } + BOOL ChkSet() const { return MskSPrm(1); } u32 GetVsGrp() const { return MskSPrm(0x70); } u32 GetIGrp() const { return MskSPrm(0xE); } u32 ChkNoCrr() const { return MskSPrm(0x100); } @@ -323,10 +327,10 @@ public: u32 GetCoGrp() const { return mObjCo.GetGrp(); } int GetTgType() const { return mObjTg.GetType(); } u32 GetAtType() const { return mObjAt.GetType(); } - bool ChkTgSet() const { return mObjTg.ChkSet(); } - bool ChkAtSet() const { return mObjAt.ChkSet(); } - bool ChkCoSet() const { return mObjCo.ChkSet(); } - u32 ChkCoSameActorHit() const { return mObjCo.ChkCoSameActorHit(); } + BOOL ChkTgSet() const { return mObjTg.ChkSet(); } + BOOL ChkAtSet() const { return mObjAt.ChkSet(); } + BOOL ChkCoSet() const { return mObjCo.ChkSet(); } + u32 ChkCoSameActorHit() { return mObjCo.MskSPrm(0x400); } void OnCoSameActorHit() { mObjCo.OnCoSameActorHit(); } void OffCoSameActorHit() { mObjCo.OffCoSameActorHit(); } u32 GetCoVsGrp() const { return mObjCo.GetVsGrp(); } @@ -334,8 +338,8 @@ public: u8 GetAtAtp() const { return mObjAt.GetAtp(); } u32 ChkAtNoTgHitInfSet() const { return mObjAt.MskSPrm(0x20); } u32 ChkTgNoAtHitInfSet() const { return mObjTg.MskSPrm(0x20); } - u32 ChkCoNoCoHitInfSet() const { return mObjCo.MskSPrm(0x200); } - bool ChkTgNoSlingHitInfSet() const { return mObjTg.MskSPrm(0x40); } + u32 ChkCoNoCoHitInfSet() { return mObjCo.MskSPrm(0x200); } + BOOL ChkTgNoSlingHitInfSet() { return mObjTg.MskSPrm(0x40); } void SetAtHit(cCcD_Obj* obj) { mObjAt.SetHit(obj); } void SetTgHit(cCcD_Obj* obj) { mObjTg.SetHit(obj); } void SetCoHit(cCcD_Obj* obj) { mObjCo.SetHit(obj); } @@ -430,7 +434,6 @@ public: /* vt[21]*/ virtual void getShapeAccess(cCcD_ShapeAttr::Shape*) const; cM3dGAab& GetWorkAab() { return mAab; } - cM3dGAab const& GetWorkAab() const { return mAab; } static cXyz m_virtual_center; }; @@ -456,7 +459,7 @@ public: void SetStts(cCcD_Stts* stts) { mStts = stts; } cCcD_DivideInfo& GetDivideInfo() { return mDivideInfo; } cCcD_DivideInfo* GetPDivideInfo() { return &mDivideInfo; } - int ChkBsRevHit() const { return mFlags & 2; } + int ChkBsRevHit() { return mFlags & 2; } private: /* 0x040 */ int mFlags; diff --git a/include/SSystem/SComponent/c_cc_s.h b/include/SSystem/SComponent/c_cc_s.h index 334f7351d8..4bdf70efd5 100644 --- a/include/SSystem/SComponent/c_cc_s.h +++ b/include/SSystem/SComponent/c_cc_s.h @@ -16,7 +16,7 @@ public: /* 0x1000 */ cCcD_Obj* mpObjCo[0x100]; /* 0x1400 */ cCcD_Obj* mpObj[0x500]; #if DEBUG - /* 0x2800 */ int m_debug_code; + /* 0x2800 */ u32 m_debug_code; #endif /* 0x2800 */ u16 mObjAtCount; /* 0x2802 */ u16 mObjTgCount; diff --git a/include/SSystem/SComponent/c_m3d_g_aab.h b/include/SSystem/SComponent/c_m3d_g_aab.h index b070e776eb..a685efb007 100644 --- a/include/SSystem/SComponent/c_m3d_g_aab.h +++ b/include/SSystem/SComponent/c_m3d_g_aab.h @@ -18,25 +18,25 @@ public: bool CrossY(const cXyz*) const; bool UnderPlaneYUnder(f32) const; bool TopPlaneYUnder(f32) const; - void ClearForMinMax(void); + void ClearForMinMax(); void SetMinMax(const cXyz&); void SetMinMax(const cM3dGAab&); void SetMin(const cXyz&); void SetMax(const cXyz&); void CalcCenter(cXyz*) const; void PlusR(f32); - const cXyz* GetMaxP(void) const { return &mMax; } - cXyz* GetMaxP(void) { return &mMax; } - const cXyz* GetMinP(void) const { return &mMin; } - cXyz* GetMinP(void) { return &mMin; } - const f32 GetMaxX(void) const { return mMax.x; } - const f32 GetMaxY(void) const { return mMax.y; } - const f32 GetMaxZ(void) const { return mMax.z; } - const f32 GetMinX(void) const { return mMin.x; } - const f32 GetMinY(void) const { return mMin.y; } - const f32 GetMinZ(void) const { return mMin.z; } + const cXyz* GetMaxP() const { return &mMax; } + cXyz* GetMaxP() { return &mMax; } + const cXyz* GetMinP() const { return &mMin; } + cXyz* GetMinP() { return &mMin; } + const f32 GetMaxX() const { return mMax.x; } + const f32 GetMaxY() const { return mMax.y; } + const f32 GetMaxZ() const { return mMax.z; } + const f32 GetMinX() const { return mMin.x; } + const f32 GetMinY() const { return mMin.y; } + const f32 GetMinZ() const { return mMin.z; } bool Cross(const cM3dGLin *param_1) const { - return cM3d_Cross_MinMaxBoxLine(GetMinP(), GetMaxP(), (Vec*)¶m_1->GetStartP(), (Vec*)¶m_1->GetEndP()); + return cM3d_Cross_MinMaxBoxLine(GetMinP(), GetMaxP(), param_1->GetStartP(), param_1->GetEndP()); } bool Cross(const cM3dGAab *param_1) const { return cM3d_Cross_AabAab(this, param_1); diff --git a/include/SSystem/SComponent/c_m3d_g_cps.h b/include/SSystem/SComponent/c_m3d_g_cps.h index 5147e02114..f24b352dae 100644 --- a/include/SSystem/SComponent/c_m3d_g_cps.h +++ b/include/SSystem/SComponent/c_m3d_g_cps.h @@ -3,6 +3,7 @@ #include "SSystem/SComponent/c_m3d.h" #include "SSystem/SComponent/c_m3d_g_lin.h" +#include "SSystem/SComponent/c_m3d_g_tri.h" struct cM3dGCpsS { /* 0x00 */ Vec mStart; @@ -14,8 +15,8 @@ class cM3dGCps : public cM3dGLin { public: /* 0x1C */ f32 mRadius; - cM3dGCps(void); - virtual ~cM3dGCps(void); + cM3dGCps(); + virtual ~cM3dGCps(); void Set(const cXyz&, const cXyz&, f32); void Set(const cM3dGCpsS&); void SetCps(const cM3dGCps&); @@ -24,6 +25,7 @@ public: } bool Cross(cM3dGCyl const* cyl, cXyz* xyz) const { return cM3d_Cross_CpsCyl(*this, *cyl, xyz); } bool Cross(cM3dGSph const* sph, cXyz* xyz) const { return cM3d_Cross_CpsSph(*this, *sph, xyz); } + bool Cross(cM3dGTri const& tri, cXyz* xyz) const { return cM3d_Cross_CpsTri(*this, tri, xyz); } void SetR(f32 r) { mRadius = r; } f32 GetR() const { return mRadius; } diff --git a/include/SSystem/SComponent/c_m3d_g_cyl.h b/include/SSystem/SComponent/c_m3d_g_cyl.h index 5d5f3a395b..4983084d83 100644 --- a/include/SSystem/SComponent/c_m3d_g_cyl.h +++ b/include/SSystem/SComponent/c_m3d_g_cyl.h @@ -40,8 +40,8 @@ public: bool Cross(const cM3dGCps* cps, cXyz* xyz) const { return cM3d_Cross_CpsCyl(*cps, *this, xyz); } bool Cross(const cM3dGTri& tri, cXyz* xyz) const { return cM3d_Cross_CylTri(this, &tri, xyz); } - bool Cross(const cM3dGCyl* other, f32* f) const { return cM3d_Cross_CylCyl(this, other, f); } - bool Cross(const cM3dGSph* sph, f32* f) const { return cM3d_Cross_CylSph(this, sph, f); } + bool cross(const cM3dGCyl* other, f32* f) const { return cM3d_Cross_CylCyl(this, other, f); } + bool cross(const cM3dGSph* sph, f32* f) const { return cM3d_Cross_CylSph(this, sph, f); } }; // Size = 0x18 STATIC_ASSERT(0x18 == sizeof(cM3dGCyl)); diff --git a/include/SSystem/SComponent/c_m3d_g_lin.h b/include/SSystem/SComponent/c_m3d_g_lin.h index d6b86ebcf0..fbe65d9b33 100644 --- a/include/SSystem/SComponent/c_m3d_g_lin.h +++ b/include/SSystem/SComponent/c_m3d_g_lin.h @@ -22,13 +22,13 @@ public: void SetEnd(const cXyz&); void set(const Vec& i_start, const Vec& i_end) { SetStartEnd(i_start, i_end); } - const cXyz& GetStartP(void) const { return mStart; } - cXyz& GetStartP(void) { return mStart; } + const cXyz* GetStartP() const { return &mStart; } + cXyz* GetStartP() { return &mStart; } cXyz& GetStart() { return mStart; } const cXyz& GetStart() const { return mStart; } - const cXyz& GetEndP(void) const { return mEnd; } - cXyz& GetEndP(void) { return mEnd; } + const cXyz* GetEndP() const { return &mEnd; } + cXyz* GetEndP() { return &mEnd; } cXyz& GetEnd() { return mEnd; } const cXyz& GetEnd() const { return mEnd; } f32 GetLen() const { return PSVECDistance(&mStart, &mEnd); } diff --git a/include/SSystem/SComponent/c_m3d_g_sph.h b/include/SSystem/SComponent/c_m3d_g_sph.h index b8f868b8a5..9a9248d0a4 100644 --- a/include/SSystem/SComponent/c_m3d_g_sph.h +++ b/include/SSystem/SComponent/c_m3d_g_sph.h @@ -39,9 +39,10 @@ public: f32 GetCY(void) const { return mCenter.y; } f32 GetCZ(void) const { return mCenter.z; } - bool Cross(const cM3dGSph* other, f32* f) const { return cM3d_Cross_SphSph(this, other, f); } + bool cross(const cM3dGSph* other, f32* f) const { return cM3d_Cross_SphSph(this, other, f); } bool Cross(const cM3dGCps* cps, cXyz* xyz) const { return cM3d_Cross_CpsSph(*cps, *this, xyz); } - bool Cross(const cM3dGCyl* cyl, f32* f) const { return cM3d_Cross_CylSph(cyl, this, f); } + bool cross(const cM3dGCyl* cyl, f32* f) const { return cM3d_Cross_CylSph(cyl, this, f); } + bool Cross(const cM3dGTri& tri, cXyz* xyz) const { return cM3d_Cross_SphTri(this, &tri, xyz); } }; // Size = 0x14 STATIC_ASSERT(0x14 == sizeof(cM3dGSph)); diff --git a/include/SSystem/SComponent/c_m3d_g_tri.h b/include/SSystem/SComponent/c_m3d_g_tri.h index 214c1d0285..cd535d66c3 100644 --- a/include/SSystem/SComponent/c_m3d_g_tri.h +++ b/include/SSystem/SComponent/c_m3d_g_tri.h @@ -25,10 +25,10 @@ public: void setPos(const Vec*, const Vec*, const Vec*); void setBg(const Vec*, const Vec*, const Vec*, const cM3dGPla*); void set(const Vec*, const Vec*, const Vec*, const Vec*); - bool Cross(cM3dGCps const& cps, cXyz* xyz) const { return cM3d_Cross_CpsTri(cps, *this, xyz); } - bool Cross(cM3dGCyl const& cyl, cXyz* xyz) const { return this->cross(&cyl, xyz); } - bool Cross(cM3dGSph const& sph, cXyz* xyz) const { return cM3d_Cross_SphTri(&sph, this, xyz); } - bool Cross(cM3dGTri const& other, cXyz* xyz) const { + bool Cross(cM3dGCps const& cps, Vec* xyz) const { return cM3d_Cross_CpsTri(cps, *this, xyz); } + bool Cross(cM3dGCyl const& cyl, Vec* xyz) const { return this->cross(&cyl, xyz); } + bool Cross(cM3dGSph const& sph, Vec* xyz) const { return cM3d_Cross_SphTri(&sph, this, xyz); } + bool Cross(cM3dGTri const& other, Vec* xyz) const { return cM3d_Cross_TriTri(*this, other, xyz); } bool cross(const cM3dGLin* lin, Vec* xyz, bool param_2, bool param_3) const { diff --git a/include/d/d_cc_d.h b/include/d/d_cc_d.h index 7c6b438a4d..1d9b4b5a93 100644 --- a/include/d/d_cc_d.h +++ b/include/d/d_cc_d.h @@ -144,7 +144,7 @@ public: void ClrEffCounter() { mEffCounter = 0; } u32 GetGFlag() const { return mGFlag; } u32 GetRPrm() const { return mRPrm; } - u32 MskSPrm(u32 mask) const { return mGFlag & mask; } + u32 MskSPrm(u32 mask) { return mGFlag & mask; } u32 MskRPrm(u32 mask) const { return mRPrm & mask; } bool ChkSPrm(u32 mask) { return MskSPrm(mask); } void OnSPrm(u32 flag) { mGFlag |= flag; } @@ -173,7 +173,7 @@ public: u8 GetSe() { return mSe; } dCcG_At_Spl GetSpl() { return (dCcG_At_Spl)mSpl; } u8 GetMtrl() { return mMtrl; } - u8 GetHitMark() { return mHitMark; } + int GetHitMark() { return mHitMark; } void SetRVec(cXyz& vec) { mRVec = vec; } void SetHitPos(cXyz& pos) { mHitPos = pos; } cXyz* GetHitPosP() { return &mHitPos; } @@ -203,10 +203,10 @@ public: void SetHitMark(CcG_Tg_HitMark mark) { mHitMark = mark; } s16* GetShieldFrontRangeYAngle() { return mShieldFrontRangeYAngle; } s16 GetShieldRange() { return mShieldRange; } - u8 GetSpl() { return mSpl; } + int GetSpl() { return mSpl; } void SetSpl(dCcG_Tg_Spl tg_spl) { mSpl = tg_spl; } void SetSpl(u8 tg_spl) { mSpl = tg_spl; } - u8 GetHitMark() { return mHitMark; } + int GetHitMark() { return mHitMark; } void SetRVec(cXyz& vec) { mRVec = vec; } cXyz* GetVecP() { return &mVec; } cXyz* GetRVecP() { return &mRVec; } @@ -250,7 +250,7 @@ public: void SetRoomId(int id) { mRoomId = id; } fpc_ProcID GetAtOldApid() { return mAtOldApid; } fpc_ProcID GetTgOldApid() { return mTgOldApid; } - bool ChkNoActor() { return field_0x1C & 1;} + BOOL ChkNoActor() { return field_0x1C & 1;} bool ChkNoneActorPerfTblId() { return field_0x08 == 0xFFFF; } dCcG_At_Spl GetAtSpl() { return (dCcG_At_Spl)mAt; } void SetAtSpl(dCcG_At_Spl spl) { mAt = spl; } diff --git a/include/d/d_cc_mass_s.h b/include/d/d_cc_mass_s.h index c5d6186014..672adb913a 100644 --- a/include/d/d_cc_mass_s.h +++ b/include/d/d_cc_mass_s.h @@ -9,7 +9,7 @@ class dCcMassS_Obj { private: /* 0x00 */ cCcD_Obj* mpObj; /* 0x04 */ u8 mPriority; - /* 0x08 */ dCcMassS_ObjCallback mpCallback; + /* 0x08 */ dCcMassS_ObjCallback mpAreaCheckFunc; /* 0x0C */ cCcD_DivideInfo mDivideInfo; /* 0x1C vtable */ @@ -19,10 +19,10 @@ public: void Set(cCcD_Obj* p_obj, u8 priority, dCcMassS_ObjCallback callback); void Clear(); - cCcD_Obj* GetObj() { return mpObj; } + cCcD_Obj* GetObj() const { return mpObj; } u8 GetPriority() const { return mPriority; } - dCcMassS_ObjCallback GetCallback() const { return mpCallback; } - cCcD_DivideInfo& GetDivideInfo() { return mDivideInfo; } + dCcMassS_ObjCallback GetAreaCheckFunc() const { return mpAreaCheckFunc; } + cCcD_DivideInfo* GetPDivideInfo() { return &mDivideInfo; } }; // Size = 0x20 STATIC_ASSERT(0x20 == sizeof(dCcMassS_Obj)); diff --git a/include/d/d_cc_s.h b/include/d/d_cc_s.h index dbd3c18285..b4d90787ae 100644 --- a/include/d/d_cc_s.h +++ b/include/d/d_cc_s.h @@ -44,6 +44,16 @@ public: virtual void MoveAfterCheck(); virtual void CalcParticleAngle(dCcD_GObjInf*, cCcD_Stts*, cCcD_Stts*, csXyz*); + #if DEBUG + void OnMassAllTimer() { + m_is_mass_all_timer = 1; + } + + void OffMassAllTimer() { + m_is_mass_all_timer = 0; + } + #endif + void SetMass(cCcD_Obj* i_obj, u8 i_priority) { mMass_Mng.Set(i_obj, i_priority); } void SetMassCam(cM3dGCps& i_cps) { mMass_Mng.SetCam(i_cps); } u32 GetMassResultCam() { return mMass_Mng.GetResultCam(); } @@ -70,7 +80,7 @@ public: // /* 0x0000 */ cCcS mCCcS; /* 0x284C */ dCcMassS_Mng mMass_Mng; #if DEBUG - /* 0x2AD0 */ u8 field_0x2ad0; + /* 0x2AD0 */ u8 m_is_mass_all_timer; #endif }; // Size = 0x2AC4 diff --git a/include/d/d_jnt_col.h b/include/d/d_jnt_col.h index c239bf8a69..cc67b7104d 100644 --- a/include/d/d_jnt_col.h +++ b/include/d/d_jnt_col.h @@ -33,7 +33,7 @@ public: void offPassNum(int num) { field_0xc &= ~(1 << num); } bool checkShieldType(int i) { return getType(i) == 3; } - s8 getType(int i) { return mData[i].mType; } + int getType(int i) { return mData[i].mType; } int getJntNum(int i) { return (s16)mData[i].mJntNum; } /* 0x00 */ const dJntColData_c* mData; @@ -64,4 +64,9 @@ public: }; +#if DEBUG +void dJntCol_setDebugHIO(); +void dJntCol_deleteDebugHIO(); +#endif + #endif /* D_D_JNT_COL_H */ diff --git a/src/SSystem/SComponent/c_bg_s_gnd_chk.cpp b/src/SSystem/SComponent/c_bg_s_gnd_chk.cpp index 687bf217fe..8ef7c7fe32 100644 --- a/src/SSystem/SComponent/c_bg_s_gnd_chk.cpp +++ b/src/SSystem/SComponent/c_bg_s_gnd_chk.cpp @@ -5,6 +5,12 @@ #include "SSystem/SComponent/c_bg_s_gnd_chk.h" #include "f_pc/f_pc_manager.h" +#include "JSystem/JUtility/JUTAssert.h" + +#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !isnan(x)); +#define CHECK_FLOAT_RANGE(line, x) JUT_ASSERT(line, -INF < x && x < INF); +#define CHECK_FLOAT_MIN(line, x) JUT_ASSERT(line, -INF < x); +#define CHECK_FLOAT_MAX(line, x) JUT_ASSERT(line, x < INF); cBgS_GndChk::cBgS_GndChk() { m_pos = cXyz::Zero; @@ -15,11 +21,31 @@ cBgS_GndChk::cBgS_GndChk() { cBgS_GndChk::~cBgS_GndChk() {} void cBgS_GndChk::SetPos(Vec const* pos) { - m_pos = *pos; + m_pos.x = pos->x; + m_pos.y = pos->y; + m_pos.z = pos->z; + + CHECK_FLOAT_CLASS(37, m_pos.x); + CHECK_FLOAT_CLASS(38, m_pos.y); + CHECK_FLOAT_CLASS(39, m_pos.z); + + CHECK_FLOAT_RANGE(43, m_pos.x); + CHECK_FLOAT_MIN(44, m_pos.y); + CHECK_FLOAT_MAX(45, m_pos.y); + CHECK_FLOAT_RANGE(46, m_pos.z); } void cBgS_GndChk::SetPos(cXyz const* pos) { m_pos = *pos; + + CHECK_FLOAT_CLASS(59, m_pos.x); + CHECK_FLOAT_CLASS(60, m_pos.y); + CHECK_FLOAT_CLASS(61, m_pos.z); + + CHECK_FLOAT_RANGE(65, m_pos.x); + CHECK_FLOAT_MIN(66, m_pos.y); + CHECK_FLOAT_MAX(67, m_pos.y); + CHECK_FLOAT_RANGE(68, m_pos.z); } void cBgS_GndChk::PreCheck() { diff --git a/src/SSystem/SComponent/c_bg_s_lin_chk.cpp b/src/SSystem/SComponent/c_bg_s_lin_chk.cpp index ddfd9274b6..cb207254ea 100644 --- a/src/SSystem/SComponent/c_bg_s_lin_chk.cpp +++ b/src/SSystem/SComponent/c_bg_s_lin_chk.cpp @@ -28,11 +28,11 @@ void cBgS_LinChk::Set2(cXyz const* startPos, cXyz const* endPos, unsigned int ac field_0x40 = *endPos; SetActorPid(actorPid); mStts &= ~STTS_HIT; - ClearPi(); + ClearCheckIndex(); } void cBgS_LinChk::PreCalc() { - mPreWallChk = !(mStts & STTS_WALL_OFF); - mPreGroundChk = !(mStts & STTS_GROUND_OFF); - mPreRoofChk = !(mStts & STTS_ROOF_OFF); + mPreWallChk = !ChkSttsWallOff(); + mPreGroundChk = !ChkSttsGroundOff(); + mPreRoofChk = !ChkSttsRoofOff(); } diff --git a/src/SSystem/SComponent/c_cc_d.cpp b/src/SSystem/SComponent/c_cc_d.cpp index 7c57b18e0e..da284b6329 100644 --- a/src/SSystem/SComponent/c_cc_d.cpp +++ b/src/SSystem/SComponent/c_cc_d.cpp @@ -217,9 +217,7 @@ void cCcD_Stts::PlusCcMove(f32 x, f32 y, f32 z) { } void cCcD_Stts::ClrCcMove() { - m_cc_move.z = 0.0f; - m_cc_move.y = 0.0f; - m_cc_move.x = 0.0f; + m_cc_move.x = m_cc_move.y = m_cc_move.z = 0.0f; } void cCcD_Stts::PlusDmg(int dmg) { @@ -230,7 +228,8 @@ void cCcD_Stts::PlusDmg(int dmg) { } f32 cCcD_Stts::GetWeightF() const { - return (s32)m_weight; + int weighti = GetWeightUc(); + return weighti; } void cCcD_ObjCommonBase::ct() { @@ -258,17 +257,13 @@ fopAc_ac_c* cCcD_Obj::GetAc() { if (mStts == NULL) { return NULL; } else { - return mStts->GetAc(); + return mStts->GetActor(); } } void cCcD_ShapeAttr::getShapeAccess(cCcD_ShapeAttr::Shape* pshape) const { pshape->_0 = 2; - pshape->_14 = 0.0f; - pshape->_10 = 0.0f; - pshape->_4.z = 0.0f; - pshape->_4.y = 0.0f; - pshape->_4.x = 0.0f; + pshape->_4.x = pshape->_4.y = pshape->_4.z = pshape->_10 = pshape->_14 = 0.0f; } bool cCcD_PntAttr::GetNVec(cXyz const& param_0, cXyz* param_1) const { @@ -320,19 +315,20 @@ bool cCcD_TriAttr::CrossAtTg(const cCcD_TriAttr& other, cXyz* pxyz) const { } void cCcD_TriAttr::CalcAabBox() { - mAab.ClearForMinMax(); - mAab.SetMinMax(mA); - mAab.SetMinMax(mB); - mAab.SetMinMax(mC); + GetWorkAab().ClearForMinMax(); + GetWorkAab().SetMinMax(mA); + GetWorkAab().SetMinMax(mB); + GetWorkAab().SetMinMax(mC); } bool cCcD_TriAttr::GetNVec(const cXyz& param_0, cXyz* pOut) const { if (getPlaneFunc(¶m_0) >= 0.0f) { - *pOut = mNormal; + *pOut = *GetNP(); } else { - *pOut = mNormal; - VECScale(pOut, pOut, -1.0f); + *pOut = *GetNP(); + PSVECScale(pOut, pOut, -1.0f); } + return true; } @@ -361,7 +357,7 @@ bool cCcD_CpsAttr::CrossAtTg(const cCcD_SphAttr& sphAttr, cXyz* pxyz) const { } bool cCcD_CpsAttr::CrossAtTg(const cCcD_TriAttr& triAttr, cXyz* pxyz) const { - if (triAttr.cM3dGTri::Cross(*this, pxyz)) { + if (cM3dGCps::Cross(triAttr, pxyz)) { return true; } else { return false; @@ -399,44 +395,47 @@ bool cCcD_CpsAttr::CrossCo(const cCcD_SphAttr& sphAttr, f32* param_1) const { } void cCcD_CpsAttr::CalcAabBox() { - mAab.ClearForMinMax(); - mAab.SetMinMax(mStart); - mAab.SetMinMax(mEnd); - mAab.PlusR(mRadius); + GetWorkAab().ClearForMinMax(); + GetWorkAab().SetMinMax(*GetStartP()); + GetWorkAab().SetMinMax(*GetEndP()); + GetWorkAab().PlusR(GetR()); } bool cCcD_CpsAttr::GetNVec(const cXyz& param_0, cXyz* param_1) const { - Vec diff; - const cXyz& endP = GetEndP(); - VECSubtract(&endP, &mStart, &diff); + cXyz diff; + PSVECSubtract(GetEndP(), GetStartP(), &diff); - f32 diffLen = VECDotProduct(&diff, &diff); + f32 diffLen = PSVECDotProduct(&diff, &diff); if (cM3d_IsZero(diffLen)) { return false; - } else { - Vec vec1, vec2; - VECSubtract(¶m_0, &mStart, &vec1); - f32 vec1Len = VECDotProduct(&vec1, &diff) / diffLen; - if (vec1Len < 0.0f) { - vec2 = mStart; - } else { - if (vec1Len > 1.0f) { - vec2 = endP; - } else { - VECScale(&diff, &diff, vec1Len); - VECAdd(&diff, &mStart, &vec2); - } - } + } - VECSubtract(¶m_0, &vec2, param_1); - if (cM3d_IsZero(VECMag(param_1))) { - param_1->set(0.0f, 0.0f, 0.0f); - return false; + cXyz vec1; + PSVECSubtract(¶m_0, GetStartP(), &vec1); + f32 vec1Len = PSVECDotProduct(&vec1, &diff) / diffLen; + + cXyz vec2; + if (vec1Len < 0.0f) { + vec2 = *GetStartP(); + } else { + if (vec1Len > 1.0f) { + vec2 = *GetEndP(); } else { - VECNormalize(param_1, param_1); - return true; + PSVECScale(&diff, &diff, vec1Len); + PSVECAdd(&diff, GetStartP(), &vec2); } } + + PSVECSubtract(¶m_0, &vec2, param_1); + if (cM3d_IsZero(PSVECMag(param_1))) { + param_1->x = 0.0f; + param_1->y = 0.0f; + param_1->z = 0.0f; + return false; + } else { + PSVECNormalize(param_1, param_1); + return true; + } } bool cCcD_CylAttr::CrossAtTg(const cCcD_CpsAttr& cpsAttr, cXyz* pxyz) const { @@ -472,7 +471,7 @@ bool cCcD_CylAttr::CrossAtTg(const cCcD_TriAttr& triAttr, cXyz* pxyz) const { } bool cCcD_CylAttr::CrossCo(const cCcD_CylAttr& other, f32* f) const { - if (cM3dGCyl::Cross(&other, f)) { + if (cM3dGCyl::cross(&other, f)) { return true; } else { return false; @@ -480,7 +479,7 @@ bool cCcD_CylAttr::CrossCo(const cCcD_CylAttr& other, f32* f) const { } bool cCcD_CylAttr::CrossCo(const cCcD_SphAttr& sphAttr, f32* f) const { - if (cM3dGCyl::Cross(&sphAttr, f)) { + if (cM3dGCyl::cross(&sphAttr, f)) { return true; } else { return false; @@ -506,51 +505,51 @@ void cCcD_CylAttr::CalcAabBox() { max.x = GetCP()->x + GetR(); max.y = GetCP()->y + GetH(); max.z = GetCP()->z + GetR(); - mAab.Set(&min, &max); + GetWorkAab().Set(&min, &max); } bool cCcD_CylAttr::GetNVec(const cXyz& param_0, cXyz* param_1) const { - Vec vec; - if (GetCP()->y > param_0.y) { - vec = mCenter; + const cXyz* cp = GetCP(); + cXyz vec; + if (cp->y > param_0.y) { + vec = *cp; } else { - if (GetCP()->y + GetH() < param_0.y) { - vec.x = GetCP()->x; - vec.y = GetCP()->y; - vec.z = GetCP()->z; - vec.y = GetCP()->y + GetH(); + if (cp->y + GetH() < param_0.y) { + vec = *cp; + vec.y += GetH(); } else { - vec = mCenter; + vec = *cp; vec.y = param_0.y; } } - VECSubtract(¶m_0, &vec, param_1); - if (cM3d_IsZero(VECMag(param_1))) { - param_1->set(0.0f, 0.0f, 0.0f); + PSVECSubtract(¶m_0, &vec, param_1); + if (cM3d_IsZero(PSVECMag(param_1))) { + param_1->x = 0.0f; + param_1->y = 0.0f; + param_1->z = 0.0f; return false; } else { - VECNormalize(param_1, param_1); + PSVECNormalize(param_1, param_1); return true; } + return false; } void cCcD_CylAttr::getShapeAccess(cCcD_ShapeAttr::Shape* pshape) const { pshape->_0 = 1; - pshape->_4.x = mCenter.x; - pshape->_4.y = mCenter.y; - pshape->_4.z = mCenter.z; - pshape->_10 = mRadius; - pshape->_14 = mHeight; -} -inline bool inlineCross(const cM3dGSph& sph, const cM3dGCps* pcps, cXyz* pxyz) { - return cM3d_Cross_CpsSph(*pcps, sph, pxyz); + const cXyz& center = GetC(); + pshape->_4.x = center.x; + pshape->_4.y = center.y; + pshape->_4.z = center.z; + pshape->_10 = GetR(); + pshape->_14 = GetH(); } bool cCcD_SphAttr::CrossAtTg(const cCcD_CpsAttr& cpsAttr, cXyz* pxyz) const { - if (inlineCross(*this, &cpsAttr, pxyz)) { + if (cM3dGSph::Cross(&cpsAttr, pxyz)) { return true; } else { return false; @@ -574,7 +573,7 @@ bool cCcD_SphAttr::CrossAtTg(const cCcD_SphAttr& sphAttr, cXyz* pxyz) const { } bool cCcD_SphAttr::CrossAtTg(const cCcD_TriAttr& triAttr, cXyz* pxyz) const { - if (triAttr.cM3dGTri::Cross(*this, pxyz)) { + if (cM3dGSph::Cross(triAttr, pxyz)) { return true; } else { return false; @@ -582,7 +581,7 @@ bool cCcD_SphAttr::CrossAtTg(const cCcD_TriAttr& triAttr, cXyz* pxyz) const { } bool cCcD_SphAttr::CrossCo(const cCcD_CylAttr& cylAttr, f32* f) const { - if (cM3dGSph::Cross(&cylAttr, f)) { + if (cM3dGSph::cross(&cylAttr, f)) { return true; } else { return false; @@ -590,7 +589,7 @@ bool cCcD_SphAttr::CrossCo(const cCcD_CylAttr& cylAttr, f32* f) const { } bool cCcD_SphAttr::CrossCo(const cCcD_SphAttr& sphAttr, f32* f) const { - if (cM3dGSph::Cross(&sphAttr, f)) { + if (cM3dGSph::cross(&sphAttr, f)) { return true; } else { return false; @@ -621,37 +620,40 @@ void cCcD_SphAttr::CalcAabBox() { max.y += GetR(); max.z += GetR(); - mAab.Set(&min, &max); + GetWorkAab().Set(&min, &max); } bool cCcD_SphAttr::GetNVec(const cXyz& param_0, cXyz* param_1) const { - param_1->x = param_0.x - mCenter.x; - param_1->y = param_0.y - mCenter.y; - param_1->z = param_0.z - mCenter.z; + const cXyz& center = GetC(); + param_1->x = param_0.x - center.x; + param_1->y = param_0.y - center.y; + param_1->z = param_0.z - center.z; - if (cM3d_IsZero(VECMag(param_1))) { + if (cM3d_IsZero(PSVECMag(param_1))) { param_1->x = 0.0f; param_1->y = 0.0f; param_1->z = 0.0f; return false; } else { - VECNormalize(param_1, param_1); + PSVECNormalize(param_1, param_1); return true; } } void cCcD_SphAttr::getShapeAccess(cCcD_ShapeAttr::Shape* pshape) const { pshape->_0 = 0; - pshape->_4.x = mCenter.x; - pshape->_4.y = mCenter.y; - pshape->_4.z = mCenter.z; - pshape->_10 = mRadius; + + const cXyz& center = GetC(); + pshape->_4.x = center.x; + pshape->_4.y = center.y; + pshape->_4.z = center.z; + pshape->_10 = GetR(); pshape->_14 = 0.0f; } void cCcD_ObjAt::SetHit(cCcD_Obj* pObj) { - mRPrm = 1; - mHitObj = pObj; + SetRPrm(1); + SetHitObj(pObj); } void cCcD_ObjAt::Set(const cCcD_SrcObjAt& src) { @@ -661,8 +663,8 @@ void cCcD_ObjAt::Set(const cCcD_SrcObjAt& src) { } void cCcD_ObjAt::ClrHit() { - mRPrm &= ~1; - mHitObj = NULL; + ClrRPrm(1); + ClrObj(); } void cCcD_ObjTg::Set(const cCcD_SrcObjTg& src) { @@ -671,36 +673,36 @@ void cCcD_ObjTg::Set(const cCcD_SrcObjTg& src) { } void cCcD_ObjTg::SetGrp(u32 grp) { - mSPrm &= ~0x1E; - mSPrm |= grp; + OffSPrmBit(0x1E); + OnSPrmBit(grp); } void cCcD_ObjTg::ClrHit() { - mRPrm &= ~1; - mHitObj = NULL; + ClrRPrm(1); + ClrObj(); } void cCcD_ObjTg::SetHit(cCcD_Obj* pObj) { - mRPrm = 1; - mHitObj = pObj; + SetRPrm(1); + SetHitObj(pObj); } void cCcD_ObjCo::SetHit(cCcD_Obj* pObj) { - mRPrm = 1; - mHitObj = pObj; + SetRPrm(1); + SetHitObj(pObj); } void cCcD_ObjCo::ClrHit() { - mRPrm &= ~1; - mHitObj = NULL; + ClrRPrm(1); + ClrObj(); } void cCcD_ObjCo::SetIGrp(u32 grp) { - mSPrm &= ~0xE; - mSPrm |= grp; + OffSPrmBit(0xE); + OnSPrmBit(grp); } void cCcD_ObjCo::SetVsGrp(u32 grp) { - mSPrm &= ~0x70; - mSPrm |= grp; + OffSPrmBit(0x70); + OnSPrmBit(grp); } diff --git a/src/SSystem/SComponent/c_cc_s.cpp b/src/SSystem/SComponent/c_cc_s.cpp index 5fdd9ea1f8..b3391ee374 100644 --- a/src/SSystem/SComponent/c_cc_s.cpp +++ b/src/SSystem/SComponent/c_cc_s.cpp @@ -31,6 +31,10 @@ void cCcS::Ct() { *obj = NULL; } mObjCount = 0; + + #if DEBUG + m_debug_code = 1234; + #endif } void cCcS::Dt() { @@ -96,9 +100,8 @@ void cCcS::ClrCoHitInf() { if (*obj != NULL) { (*obj)->GetGObjInf()->ClrCoHit(); - cCcD_Stts* stts = (*obj)->GetStts(); - if (stts != NULL) { - stts->ClrCcMove(); + if ((*obj)->GetStts() != NULL) { + (*obj)->GetStts()->ClrCo(); } } } @@ -109,9 +112,8 @@ void cCcS::ClrTgHitInf() { if (*obj != NULL) { (*obj)->GetGObjInf()->ClrTgHit(); - cCcD_Stts* stts = (*obj)->GetStts(); - if (stts != NULL) { - stts->ClrTg(); + if ((*obj)->GetStts() != NULL) { + (*obj)->GetStts()->ClrTg(); } } } @@ -122,9 +124,8 @@ void cCcS::ClrAtHitInf() { if (*obj != NULL) { (*obj)->GetGObjInf()->ClrAtHit(); - cCcD_Stts* stts = (*obj)->GetStts(); - if (stts != NULL) { - stts->ClrAt(); + if ((*obj)->GetStts() != NULL) { + (*obj)->GetStts()->ClrAt(); } } } @@ -153,18 +154,18 @@ void cCcS::ChkAtTg() { continue; cCcD_ShapeAttr* pat_sa = (*pat_obj)->GetShapeAttr(); - JUT_ASSERT(0, pat_sa != NULL); + JUT_ASSERT(338, pat_sa != NULL); for (cCcD_Obj** ptg_obj = mpObjTg; ptg_obj < objTgEnd; ++ptg_obj) { if (*ptg_obj == NULL || !(*ptg_obj)->ChkTgSet()) continue; - if (!(*pat_obj)->GetDivideInfo().Chk((*ptg_obj)->GetDivideInfo())) + if (!(*pat_obj)->GetPDivideInfo()->Chk(*(*ptg_obj)->GetPDivideInfo())) continue; if (ChkNoHitAtTg(*pat_obj, *ptg_obj)) continue; cCcD_ShapeAttr* ptg_sa = (*ptg_obj)->GetShapeAttr(); - JUT_ASSERT(0, ptg_sa != NULL); + JUT_ASSERT(354, ptg_sa != NULL); static cXyz cross; bool didCross = pat_sa->CrossAtTg(*ptg_sa, &cross); @@ -174,9 +175,12 @@ void cCcS::ChkAtTg() { } else if (anyBsRevHit && !didCross) { cCcD_ShapeAttr* pat_sa = (*pat_obj)->GetShapeAttr(); if (pat_sa == NULL) { - cross.set(0.0f, 0.0f, 0.0f); + cross.x = 0.0f; + cross.y = 0.0f; + cross.z = 0.0f; } else { - pat_sa->GetWorkAab().CalcCenter(&cross); + cM3dGAab& aab = pat_sa->GetWorkAab(); + aab.CalcCenter(&cross); } SetAtTgCommonHitInf(*pat_obj, *ptg_obj, &cross); @@ -211,24 +215,22 @@ void cCcS::ChkCo() { continue; cCcD_ShapeAttr* pco1_sa = (*pco1_obj)->GetShapeAttr(); - JUT_ASSERT(0, pco1_sa != NULL); + JUT_ASSERT(444, pco1_sa != NULL); for (cCcD_Obj** pco2_obj = pco1_obj + 1; pco2_obj < objCoEnd; ++pco2_obj) { if (*pco2_obj == NULL || !(*pco2_obj)->ChkCoSet()) continue; - if (!(*pco1_obj)->GetDivideInfo().Chk((*pco2_obj)->GetDivideInfo())) + if (!(*pco1_obj)->GetPDivideInfo()->Chk(*(*pco2_obj)->GetPDivideInfo())) continue; if (ChkNoHitCo(*pco1_obj, *pco2_obj)) continue; cCcD_ShapeAttr* pco2_sa = (*pco2_obj)->GetShapeAttr(); - JUT_ASSERT(0, pco2_sa != NULL); + JUT_ASSERT(456, pco2_sa != NULL); f32 cross_len; if (pco1_sa->CrossCo(*pco2_sa, &cross_len)) { - cXyz& co2_center = pco2_sa->GetCoCP(); - cXyz& co1_center = pco1_sa->GetCoCP(); - SetCoCommonHitInf(*pco1_obj, &co1_center, *pco2_obj, &co2_center, cross_len); + SetCoCommonHitInf(*pco1_obj, &pco1_sa->GetCoCP(), *pco2_obj, &pco2_sa->GetCoCP(), cross_len); } } } @@ -236,7 +238,11 @@ void cCcS::ChkCo() { void cCcS::CalcTgPlusDmg(cCcD_Obj* pat_obj, cCcD_Obj* ptg_obj, cCcD_Stts* pat_stts, cCcD_Stts* ptg_stts) { - ptg_stts->PlusDmg(pat_obj->GetAtAtp()); + UNUSED(ptg_obj); + UNUSED(pat_stts); + + int atp = pat_obj->GetAtAtp(); + ptg_stts->PlusDmg(atp); } void cCcS::SetAtTgCommonHitInf(cCcD_Obj* pat_obj, cCcD_Obj* ptg_obj, cXyz* pcross) { @@ -294,8 +300,8 @@ void cCcS::SetPosCorrect(cCcD_Obj* pco1_obj, cXyz* ppos1, cCcD_Obj* pco2_obj, cX return; if (pco1_obj->GetStts() == NULL || pco2_obj->GetStts() == NULL) return; - if (pco1_obj->GetStts()->GetAc() != NULL && - pco1_obj->GetStts()->GetAc() == pco2_obj->GetStts()->GetAc()) + if (pco1_obj->GetStts()->GetActor() != NULL && + pco1_obj->GetStts()->GetActor() == pco2_obj->GetStts()->GetActor()) return; if (!(fabsf(cross_len) < (1.0f / 125.0f))) { @@ -344,12 +350,12 @@ void cCcS::SetPosCorrect(cCcD_Obj* pco1_obj, cXyz* ppos1, cCcD_Obj* pco2_obj, cX } f32 objDistLen; - Vec vec1; - Vec vec2; + cXyz vec1; + cXyz vec2; Vec objsDist; if (bothCoSph3DCrr) { - VECSubtract(ppos2, ppos1, &objsDist); - objDistLen = VECMag(&objsDist); + PSVECSubtract(ppos2, ppos1, &objsDist); + objDistLen = PSVECMag(&objsDist); } else { objsDist.x = ppos2->x - ppos1->x; objsDist.y = 0; @@ -359,10 +365,11 @@ void cCcS::SetPosCorrect(cCcD_Obj* pco1_obj, cXyz* ppos1, cCcD_Obj* pco2_obj, cX if (!cM3d_IsZero(objDistLen)) { if (bothCoSph3DCrr) { - VECScale(&objsDist, &objsDist, cross_len / objDistLen); + f32 sp1C = cross_len / objDistLen; + PSVECScale(&objsDist, &objsDist, sp1C); obj2Weight *= -1; - VECScale(&objsDist, &vec1, obj2Weight); - VECScale(&objsDist, &vec2, obj1Weight); + PSVECScale(&objsDist, &vec1, obj2Weight); + PSVECScale(&objsDist, &vec2, obj1Weight); } else { f32 pushFactor = cross_len / objDistLen; objsDist.x *= pushFactor; @@ -433,7 +440,7 @@ void cCcS::CalcArea() { for (cCcD_Obj** pset_obj = mpObj; pset_obj < mpObj + mObjCount; ++pset_obj) { if (*pset_obj != NULL) { cCcD_ShapeAttr* pset_sa = (*pset_obj)->GetShapeAttr(); - JUT_ASSERT(0, pset_sa != NULL); + JUT_ASSERT(826, pset_sa != NULL); pset_sa->CalcAabBox(); aab.SetMinMax(pset_sa->GetWorkAab()); @@ -443,10 +450,10 @@ void cCcS::CalcArea() { mDivideArea.SetArea(aab); for (cCcD_Obj** pset_obj = mpObj; pset_obj < mpObj + mObjCount; ++pset_obj) { if (*pset_obj != NULL) { - const cCcD_ShapeAttr* pset_sa = (*pset_obj)->GetShapeAttr(); - JUT_ASSERT(0, pset_sa != NULL); + cCcD_ShapeAttr* pset_sa = (*pset_obj)->GetShapeAttr(); + JUT_ASSERT(839, pset_sa != NULL); - cCcD_DivideInfo* divideInfo = &(*pset_obj)->GetDivideInfo(); + cCcD_DivideInfo* divideInfo = (*pset_obj)->GetPDivideInfo(); mDivideArea.CalcDivideInfo(divideInfo, pset_sa->GetWorkAab(), (*pset_obj)->ChkBsRevHit()); } @@ -454,10 +461,22 @@ void cCcS::CalcArea() { } void cCcS::Move() { + #if DEBUG + JUT_ASSERT(866, m_debug_code == 1234); + #endif + CalcArea(); ChkAtTg(); ChkCo(); MoveAfterCheck(); + + #if DEBUG + field_0x280c = mObjAtCount; + field_0x280e = mObjTgCount; + field_0x2810 = mObjCoCount; + field_0x2812 = mObjCount; + #endif + mObjAtCount = 0; mObjTgCount = 0; mObjCoCount = 0; diff --git a/src/SSystem/SComponent/c_m3d.cpp b/src/SSystem/SComponent/c_m3d.cpp index 8487468223..c44ea66bf8 100644 --- a/src/SSystem/SComponent/c_m3d.cpp +++ b/src/SSystem/SComponent/c_m3d.cpp @@ -66,14 +66,14 @@ bool cM3d_Len2dSqPntAndSegLine(f32 param_1, f32 param_2, f32 param_3, f32 param_ bool cM3d_Len3dSqPntAndSegLine(const cM3dGLin* pLine, const Vec* pVec, Vec* pOutVec, f32* pOutF) { bool retVal = false; Vec tmp; - VECSubtract(&pLine->GetEndP(), &pLine->GetStartP(), &tmp); + VECSubtract(pLine->GetEndP(), pLine->GetStartP(), &tmp); f32 seqLen = VECDotProduct(&tmp, &tmp); if (cM3d_IsZero(seqLen)) { *pOutF = 0.0f; return retVal; } else { Vec tmp2; - VECSubtract(pVec, &pLine->GetStartP(), &tmp2); + VECSubtract(pVec, pLine->GetStartP(), &tmp2); f32 tmpF = VECDotProduct(&tmp2, &tmp); tmpF /= seqLen; if (tmpF < 0.0f || tmpF > 1.0f) { @@ -82,7 +82,7 @@ bool cM3d_Len3dSqPntAndSegLine(const cM3dGLin* pLine, const Vec* pVec, Vec* pOut retVal = true; } VECScale(&tmp, &tmp, tmpF); - VECAdd(&tmp, &pLine->GetStartP(), pOutVec); + VECAdd(&tmp, pLine->GetStartP(), pOutVec); *pOutF = VECSquareDistance(pOutVec, pVec); return retVal; } @@ -213,7 +213,7 @@ int cM3d_Check_LinLin(const cM3dGLin* lin_a, const cM3dGLin* lin_b, f32* dst_a, VECScale(&linAVec, &linAVec, invLinALen); VECScale(&linBVec, &linBVec, invLinBLen); Vec tmp; - VECSubtract(&lin_a->GetStartP(), &lin_b->GetStartP(), &tmp); + VECSubtract(lin_a->GetStartP(), lin_b->GetStartP(), &tmp); f32 tmpF = -VECDotProduct(&linAVec, &linBVec); f32 tmpF2 = VECDotProduct(&tmp, &linAVec); VECSquareMag(&tmp); // result not used @@ -262,19 +262,19 @@ static bool cM3d_CrossInfLineVsInfPlane_proc(f32 pFloatA, f32 pFloatB, const Vec } bool cM3d_Cross_LinPla(const cM3dGLin* lin, const cM3dGPla* pla, Vec* dst, bool a, bool b) { - f32 startVal = pla->getPlaneFunc(&lin->GetStartP()); - f32 endVal = pla->getPlaneFunc(&lin->GetEndP()); + f32 startVal = pla->getPlaneFunc(lin->GetStartP()); + f32 endVal = pla->getPlaneFunc(lin->GetEndP()); if (startVal * endVal > 0.0f) { *dst = lin->GetEnd(); return false; } else { if (startVal >= 0.0f && endVal <= 0.0f) { if (a) { - return cM3d_CrossInfLineVsInfPlane_proc(startVal, endVal, &lin->GetStartP(), &lin->GetEndP(), dst); + return cM3d_CrossInfLineVsInfPlane_proc(startVal, endVal, lin->GetStartP(), lin->GetEndP(), dst); } } else { if (b) { - return cM3d_CrossInfLineVsInfPlane_proc(startVal, endVal, &lin->GetStartP(), &lin->GetEndP(), dst); + return cM3d_CrossInfLineVsInfPlane_proc(startVal, endVal, lin->GetStartP(), lin->GetEndP(), dst); } } *dst = lin->GetEnd(); @@ -1034,53 +1034,53 @@ bool cM3d_Cross_LinSph(cM3dGLin const* line, cM3dGSph const* sph, Vec* param_2) const Vec* center = sph->GetCP(); f32 max_x = center->x + sph->GetR(); - if (max_x < line->GetStartP().x && max_x < line->GetEndP().x) { + if (max_x < line->GetStartP()->x && max_x < line->GetEndP()->x) { return false; } f32 min_x = center->x - sph->GetR(); - if (min_x > line->GetStartP().x && min_x > line->GetEndP().x) { + if (min_x > line->GetStartP()->x && min_x > line->GetEndP()->x) { return false; } f32 max_y = center->y + sph->GetR(); - if (max_y < line->GetStartP().y && max_y < line->GetEndP().y) { + if (max_y < line->GetStartP()->y && max_y < line->GetEndP()->y) { return false; } f32 min_y = center->y - sph->GetR(); - if (min_y > line->GetStartP().y && min_y > line->GetEndP().y) { + if (min_y > line->GetStartP()->y && min_y > line->GetEndP()->y) { return false; } f32 max_z = center->z + sph->GetR(); - if (max_z < line->GetStartP().z && max_z < line->GetEndP().z) { + if (max_z < line->GetStartP()->z && max_z < line->GetEndP()->z) { return false; } f32 min_z = center->z - sph->GetR(); - if (min_z > line->GetStartP().z && min_z > line->GetEndP().z) { + if (min_z > line->GetStartP()->z && min_z > line->GetEndP()->z) { return false; } - VECSubtract(&line->GetEndP(), &line->GetStartP(), &lin_vec); + VECSubtract(line->GetEndP(), line->GetStartP(), &lin_vec); f32 len_sq = VECSquareMag(&lin_vec); if (cM3d_IsZero(len_sq)) { return false; } - VECSubtract(center, &line->GetStartP(), &vec); + VECSubtract(center, line->GetStartP(), &vec); f32 proj = VECDotProduct(&vec, &lin_vec) / len_sq; if (proj < 0.0f || proj > 1.0f) { - if (line->GetStartP().abs2(*center) < line->GetEndP().abs2(*center)) { - if (cM3d_Cross_SphPnt(sph, &line->GetStartP())) { - param_2->x = line->GetStartP().x; - param_2->y = line->GetStartP().y; - param_2->z = line->GetStartP().z; + if (line->GetStartP()->abs2(*center) < line->GetEndP()->abs2(*center)) { + if (cM3d_Cross_SphPnt(sph, line->GetStartP())) { + param_2->x = line->GetStartP()->x; + param_2->y = line->GetStartP()->y; + param_2->z = line->GetStartP()->z; return true; } } else { - if (cM3d_Cross_SphPnt(sph, &line->GetEndP())) { - param_2->x = line->GetEndP().x; - param_2->y = line->GetEndP().y; - param_2->z = line->GetEndP().z; + if (cM3d_Cross_SphPnt(sph, line->GetEndP())) { + param_2->x = line->GetEndP()->x; + param_2->y = line->GetEndP()->y; + param_2->z = line->GetEndP()->z; return true; } } @@ -1089,7 +1089,7 @@ bool cM3d_Cross_LinSph(cM3dGLin const* line, cM3dGSph const* sph, Vec* param_2) Vec proj_vec; VECScale(&lin_vec, &proj_vec, proj); - VECAdd(&proj_vec, &line->GetStartP(), param_2); + VECAdd(&proj_vec, line->GetStartP(), param_2); if (cM3d_LenSq(param_2, center) <= sph->GetR() * sph->GetR()) { return true; } @@ -1100,8 +1100,8 @@ int cM3d_Cross_LinSph_CrossPos(cM3dGSph const& sph, cM3dGLin const& line, Vec* p Vec* param_3) { int ret; Vec line_vec, vec; - VECSubtract(&line.GetEndP(), &line.GetStartP(), &line_vec); - VECSubtract(&line.GetStartP(), sph.GetCP(), &vec); + VECSubtract(line.GetEndP(), line.GetStartP(), &line_vec); + VECSubtract(line.GetStartP(), sph.GetCP(), &vec); f32 len_sq = VECDotProduct(&line_vec, &line_vec); f32 dVar9 = VECDotProduct(&line_vec, &vec) * 2.0f; f32 dVar6 = VECDotProduct(&vec, &vec) - sph.GetR() * sph.GetR(); @@ -1113,7 +1113,7 @@ int cM3d_Cross_LinSph_CrossPos(cM3dGSph const& sph, cM3dGLin const& line, Vec* p ret = 1; Vec vec2; VECScale(&line_vec, &vec2, -dVar6 / dVar9); - VECAdd(&vec2, &line.GetStartP(), param_2); + VECAdd(&vec2, line.GetStartP(), param_2); } } else { f32 f11 = dVar9 * dVar9 - len_sq * 4.0f * dVar6; @@ -1121,7 +1121,7 @@ int cM3d_Cross_LinSph_CrossPos(cM3dGSph const& sph, cM3dGLin const& line, Vec* p ret = 1; Vec vec2; VECScale(&line_vec, &vec2, -dVar9 / (len_sq * 2.0f)); - VECAdd(&vec2, &line.GetStartP(), param_2); + VECAdd(&vec2, line.GetStartP(), param_2); } else if (f11 < 0.0f) { ret = 0; } else { @@ -1131,9 +1131,9 @@ int cM3d_Cross_LinSph_CrossPos(cM3dGSph const& sph, cM3dGLin const& line, Vec* p f32 scale1 = f1 * (-dVar9 + sqrtf(f11)); f32 scale2 = f1 * (-dVar9 - sqrtf(f11)); VECScale(&line_vec, &vec2, scale1); - VECAdd(&vec2, &line.GetStartP(), param_2); + VECAdd(&vec2, line.GetStartP(), param_2); VECScale(&line_vec, &vec2, scale2); - VECAdd(&vec2, &line.GetStartP(), param_3); + VECAdd(&vec2, line.GetStartP(), param_3); } } @@ -1460,17 +1460,17 @@ int cM3d_Cross_CylLin(cM3dGCyl const* cyl, cM3dGLin const* line, Vec* param_2, V f2 = 0.0f; uVar11 = 0; - if (cM3d_Cross_CylPnt(cyl, &line->GetStartP()) && cM3d_Cross_CylPnt(cyl, &line->GetEndP())) { - *param_2 = line->GetStartP(); - *param_3 = line->GetEndP(); + if (cM3d_Cross_CylPnt(cyl, line->GetStartP()) && cM3d_Cross_CylPnt(cyl, line->GetEndP())) { + *param_2 = *line->GetStartP(); + *param_3 = *line->GetEndP(); return 2; } Vec vec1, vec2, vec3; Vec vec[4]; const Vec* center = cyl->GetCP(); - VECSubtract(&line->GetStartP(), center, &vec1); - VECSubtract(&line->GetEndP(), center, &vec2); + VECSubtract(line->GetStartP(), center, &vec1); + VECSubtract(line->GetEndP(), center, &vec2); VECSubtract(&vec2, &vec1, &vec3); r_sq = cyl->GetR() * cyl->GetR(); @@ -1599,7 +1599,7 @@ int cM3d_Cross_CylLin(cM3dGCyl const* cyl, cM3dGLin const* line, Vec* param_2, V if (count == 0) { *param_2 = vec[i]; } else if (count == 1) { - if (cM3d_LenSq(&line->GetStartP(), param_2) < cM3d_LenSq(&line->GetStartP(), &vec[i])) { + if (cM3d_LenSq(line->GetStartP(), param_2) < cM3d_LenSq(line->GetStartP(), &vec[i])) { *param_3 = vec[i]; } else { *param_3 = *param_2; @@ -1707,36 +1707,36 @@ inline bool cM3d_Cross_CpsCyl_Check(cM3dGCps const& cps, cM3dGCyl const& cyl, Ve bool cM3d_Cross_CpsCyl(cM3dGCps const& cps, cM3dGCyl const& cyl, Vec* param_2) { cM3dGLin line; - if (cM3d_Cross_CylPnt(&cyl, &cps.GetEndP())) { - *param_2 = cps.GetEndP(); + if (cM3d_Cross_CylPnt(&cyl, cps.GetEndP())) { + *param_2 = *cps.GetEndP(); return true; } - if (cM3d_Cross_CylPnt(&cyl, &cps.GetStartP())) { - *param_2 = cps.GetStartP(); + if (cM3d_Cross_CylPnt(&cyl, cps.GetStartP())) { + *param_2 = *cps.GetStartP(); return true; } - line.GetStartP() = *cyl.GetCP(); - line.GetEndP() = *cyl.GetCP(); - line.GetEndP().y += cyl.GetH(); + *line.GetStartP() = *cyl.GetCP(); + *line.GetEndP() = *cyl.GetCP(); + line.GetEndP()->y += cyl.GetH(); Vec vec; f32 tmp; - if (cM3d_Len3dSqPntAndSegLine(&cps, &line.GetEndP(), &vec, &tmp)) { - f32 dist = VECDistance(&line.GetEndP(), &vec); + if (cM3d_Len3dSqPntAndSegLine(&cps, line.GetEndP(), &vec, &tmp)) { + f32 dist = VECDistance(line.GetEndP(), &vec); if (dist < cps.GetR()) { - VECAdd(&line.GetEndP(), &vec, param_2); + VECAdd(line.GetEndP(), &vec, param_2); VECScale(param_2, param_2, 0.5f); - *param_2 = line.GetEndP(); + *param_2 = *line.GetEndP(); return true; } } - if (cM3d_Len3dSqPntAndSegLine(&cps, &line.GetStartP(), &vec, &tmp)) { - f32 dist = VECDistance(&line.GetStartP(), &vec); + if (cM3d_Len3dSqPntAndSegLine(&cps, line.GetStartP(), &vec, &tmp)) { + f32 dist = VECDistance(line.GetStartP(), &vec); if (dist < cps.GetR()) { - VECAdd(&line.GetStartP(), &vec, param_2); + VECAdd(line.GetStartP(), &vec, param_2); VECScale(param_2, param_2, 0.5f); return true; } @@ -1749,7 +1749,7 @@ bool cM3d_Cross_CpsCyl(cM3dGCps const& cps, cM3dGCyl const& cyl, Vec* param_2) { cM3dGSph sph; f32 tmp2; sph.SetR(cps.GetR()); - sph.SetC(cps.GetStartP()); + sph.SetC(*cps.GetStartP()); return cM3d_Cross_CylSph(&cyl, &sph, param_2, &tmp2); } else if (iVar2 == 2) { if (f1 >= 0.0f && f1 <= 1.0f && f2 >= 0.0f && f2 <= 1.0f) { @@ -1818,8 +1818,8 @@ static void cM3d_Cross_CpsSph_CrossPos(cM3dGCps const& param_1, cM3dGSph const& if (iVar5 == 1) { *param_4 = aVStack_70; } else if (iVar5 == 2) { - f32 dVar8 = VECSquareDistance(&aVStack_70, ¶m_1.GetStartP()); - f32 dVar9 = VECSquareDistance(&VStack_7c, ¶m_1.GetStartP()); + f32 dVar8 = VECSquareDistance(&aVStack_70, param_1.GetStartP()); + f32 dVar9 = VECSquareDistance(&VStack_7c, param_1.GetStartP()); if (dVar8 < dVar9) { *param_4 = aVStack_70; } else { @@ -1840,14 +1840,14 @@ static void cM3d_Cross_CpsSph_CrossPos(cM3dGCps const& param_1, cM3dGSph const& bool cM3d_Cross_CpsSph(cM3dGCps const& param_1, cM3dGSph const& param_2, Vec* param_3) { - f32 local_38 = VECDistance(¶m_1.GetStartP(), param_2.GetCP()); + f32 local_38 = VECDistance(param_1.GetStartP(), param_2.GetCP()); if (local_38 < param_1.GetR() + param_2.GetR()) { - cM3d_Cross_CpsSph_CrossPos(param_1, param_2, param_1.GetStartP(), param_3); + cM3d_Cross_CpsSph_CrossPos(param_1, param_2, *param_1.GetStartP(), param_3); return true; } - local_38 = VECDistance(¶m_1.GetEndP(), param_2.GetCP()); + local_38 = VECDistance(param_1.GetEndP(), param_2.GetCP()); if (local_38 < param_1.GetR() + param_2.GetR()) { - cM3d_Cross_CpsSph_CrossPos(param_1, param_2, param_1.GetEndP(), param_3); + cM3d_Cross_CpsSph_CrossPos(param_1, param_2, *param_1.GetEndP(), param_3); return true; } Vec auStack_34; @@ -1922,13 +1922,13 @@ inline f32 cM3d_2LinCenter(cM3dGLin const& pLinA, f32 pLinAF, cM3dGLin const& pL bool cM3d_Cross_CpsTri(cM3dGCps const& cps, cM3dGTri tri, Vec* param_2) { cM3dGSph sph; - sph.SetC(cps.GetStartP()); + sph.SetC(*cps.GetStartP()); sph.SetR(cps.GetR()); if (cM3d_Cross_SphTri(&sph, &tri, param_2)) { return true; } - sph.SetC(cps.GetEndP()); + sph.SetC(*cps.GetEndP()); sph.SetR(cps.GetR()); if (cM3d_Cross_SphTri(&sph, &tri, param_2)) { return true; @@ -2044,25 +2044,25 @@ static int cM3d_2PlaneCrossLine(const cM3dGPla& pPlaneA, const cM3dGPla& pPlaneB if (absTX >= absTY && absTX >= absTZ) { cM3d_PlaneCrossLineProcWork(pPlaneA.GetNP()->y, pPlaneA.GetNP()->z, pPlaneB.GetNP()->y, pPlaneB.GetNP()->z, tmp.x, pPlaneA.GetD(), pPlaneB.GetD(), - &pLinOut->GetStartP().y, &pLinOut->GetStartP().z); - pLinOut->GetStartP().x = 0.0f; + &pLinOut->GetStartP()->y, &pLinOut->GetStartP()->z); + pLinOut->GetStartP()->x = 0.0f; } else if (absTY >= absTX && absTY >= absTZ) { cM3d_PlaneCrossLineProcWork(pPlaneA.GetNP()->z, pPlaneA.GetNP()->x, pPlaneB.GetNP()->z, pPlaneB.GetNP()->x, tmp.y, pPlaneA.GetD(), pPlaneB.GetD(), - &pLinOut->GetStartP().z, &pLinOut->GetStartP().x); - pLinOut->GetStartP().y = 0.0f; + &pLinOut->GetStartP()->z, &pLinOut->GetStartP()->x); + pLinOut->GetStartP()->y = 0.0f; } else { cM3d_PlaneCrossLineProcWork(pPlaneA.GetNP()->x, pPlaneA.GetNP()->y, pPlaneB.GetNP()->x, pPlaneB.GetNP()->y, tmp.z, pPlaneA.GetD(), pPlaneB.GetD(), - &pLinOut->GetStartP().x, &pLinOut->GetStartP().y); - pLinOut->GetStartP().z = 0.0f; + &pLinOut->GetStartP()->x, &pLinOut->GetStartP()->y); + pLinOut->GetStartP()->z = 0.0f; } - f32 scale = VECMag(&pLinOut->GetStartP()); + f32 scale = VECMag(pLinOut->GetStartP()); if (cM3d_IsZero(scale)) { scale = 1.0f; } VECScale(&tmp, &tmp, scale); - VECAdd(&pLinOut->GetStartP(), &tmp, &pLinOut->GetEndP()); + VECAdd(pLinOut->GetStartP(), &tmp, pLinOut->GetEndP()); return 1; } } @@ -2073,10 +2073,10 @@ BOOL cM3d_3PlaneCrossPos(const cM3dGPla& pPlaneA, const cM3dGPla& pPlaneB, const if (!cM3d_2PlaneCrossLine(pPlaneA, pPlaneB, &lin)) { return false; } else { - const Vec* end = &lin.GetEndP(); - f32 tmpf1 = pPlaneC.getPlaneFunc(&lin.GetStartP()); + const Vec* end = lin.GetEndP(); + f32 tmpf1 = pPlaneC.getPlaneFunc(lin.GetStartP()); f32 tmpf2 = pPlaneC.getPlaneFunc(end); - if (!cM3d_CrossInfLineVsInfPlane_proc(tmpf1, tmpf2, &lin.GetStartP(), end, pVecOut)) { + if (!cM3d_CrossInfLineVsInfPlane_proc(tmpf1, tmpf2, lin.GetStartP(), end, pVecOut)) { return false; } else { return true; @@ -2094,10 +2094,10 @@ f32 cM3d_lineVsPosSuisenCross(const cM3dGLin* pLine, const Vec* pPoint, Vec* pVe *pVecOut = *pPoint; return 0.0f; } else { - VECSubtract(pPoint, &pLine->GetStartP(), &tmp2); + VECSubtract(pPoint, pLine->GetStartP(), &tmp2); f32 retVal = VECDotProduct(&tmp2, &tmp1) / diffLen; VECScale(&tmp1, &tmp3, retVal); - VECAdd(&tmp3, &pLine->GetStartP(), pVecOut); + VECAdd(&tmp3, pLine->GetStartP(), pVecOut); return retVal; } } diff --git a/src/d/actor/d_a_tag_sppath.cpp b/src/d/actor/d_a_tag_sppath.cpp index b40908b387..81fbe04184 100644 --- a/src/d/actor/d_a_tag_sppath.cpp +++ b/src/d/actor/d_a_tag_sppath.cpp @@ -97,7 +97,7 @@ int daTagSppath_c::getNearPathPos(cXyz* i_result, dPath* i_path) { if (flatness > 0.001f) { flatness = 30.0f / flatness; if (segLen > flatness) { - line.GetStartP() = line.GetStart() + pntDiff * flatness; + *line.GetStartP() = line.GetStart() + pntDiff * flatness; } } } @@ -111,7 +111,7 @@ int daTagSppath_c::getNearPathPos(cXyz* i_result, dPath* i_path) { if (flatness > 0.001f) { flatness = 30.0f / flatness; if (segLen > flatness) { - line.GetEndP() = line.GetEnd() + pntDiff * flatness; + *line.GetEndP() = line.GetEnd() + pntDiff * flatness; } } } diff --git a/src/d/d_bg_w.cpp b/src/d/d_bg_w.cpp index 1407b38b15..1b4cca4837 100644 --- a/src/d/d_bg_w.cpp +++ b/src/d/d_bg_w.cpp @@ -516,8 +516,8 @@ bool cBgW::LineCheckRp(cBgS_LinChk* plinchk, int node_index) { cBgW_NodeTree* node = &pm_node_tree[node_index]; if (!cM3d_Cross_MinMaxBoxLine(node->GetMinP(), node->GetMaxP(), - &plinchk->GetLinP()->GetStartP(), - &plinchk->GetLinP()->GetEndP())) + plinchk->GetLinP()->GetStartP(), + plinchk->GetLinP()->GetEndP())) { return false; } diff --git a/src/d/d_cc_d.cpp b/src/d/d_cc_d.cpp index 3c1acd7d5a..1c30502d03 100644 --- a/src/d/d_cc_d.cpp +++ b/src/d/d_cc_d.cpp @@ -365,7 +365,7 @@ void dCcD_Cps::Draw(const GXColor& color) { cXyz cStack_d8; CalcVec(&cStack_d8); - cMtx_trans(auStack_98, GetStartP().x, GetStartP().y, GetStartP().z); + cMtx_trans(auStack_98, GetStartP()->x, GetStartP()->y, GetStartP()->z); cM3d_UpMtx(cStack_d8, auStack_c8); cMtx_concat(auStack_98, auStack_c8, auStack_68); cMtx_scale(auStack_98, GetR(), 0.5f * GetLen(), GetR()); @@ -375,8 +375,8 @@ void dCcD_Cps::Draw(const GXColor& color) { cMtx_XrotS(auStack_98, 0x4000); cMtx_concat(auStack_68, auStack_98, auStack_68); dDbVw_drawCylinderMXlu(auStack_68, color, 1); - dDbVw_drawSphereXlu(GetStartP(), GetR(), color, 1); - dDbVw_drawSphereXlu(GetEndP(), GetR(), color, 1); + dDbVw_drawSphereXlu(*GetStartP(), GetR(), color, 1); + dDbVw_drawSphereXlu(*GetEndP(), GetR(), color, 1); } #endif diff --git a/src/d/d_cc_mass_s.cpp b/src/d/d_cc_mass_s.cpp index 3a8ecdc7b2..1bc43a4565 100644 --- a/src/d/d_cc_mass_s.cpp +++ b/src/d/d_cc_mass_s.cpp @@ -10,16 +10,16 @@ #include "d/d_cc_d.h" #include "f_op/f_op_actor.h" -void dCcMassS_Obj::Set(cCcD_Obj* p_obj, u8 priority, dCcMassS_ObjCallback callback) { - mpObj = p_obj; - mPriority = priority; - mpCallback = callback; +void dCcMassS_Obj::Set(cCcD_Obj* pobj, u8 priority, dCcMassS_ObjCallback callback) { + mpObj = pobj; + mPriority = (u8)priority; + mpAreaCheckFunc = callback; } void dCcMassS_Obj::Clear() { mpObj = NULL; mPriority = 5; - mpCallback = NULL; + mpAreaCheckFunc = NULL; mDivideInfo.Set(0, 0, 0); } @@ -53,24 +53,30 @@ void dCcMassS_Mng::Ct() { void dCcMassS_Mng::SetAttr(f32 radius, f32 height, u8 param_2, u8 param_3) { mCylAttr.SetR(radius); mCylAttr.SetH(height); - field_0x200 = param_2; - field_0x201 = param_3; + field_0x200 = (u8)param_2; + field_0x201 = (u8)param_3; } void dCcMassS_Mng::Prepare() { cM3dGAab aab; aab.ClearForMinMax(); - for (dCcMassS_Obj* pObj = mMassObjs; pObj < mMassObjs + mMassObjCount; ++pObj) { - cCcD_ShapeAttr* objShape = pObj->GetObj()->GetShapeAttr(); - objShape->CalcAabBox(); - aab.SetMinMax(objShape->GetWorkAab()); + for (dCcMassS_Obj* i = mMassObjs; i < mMassObjs + mMassObjCount; ++i) { + cCcD_Obj* pobj = i->GetObj(); + JUT_ASSERT(123, pobj != NULL); + + cCcD_ShapeAttr* shape = pobj->GetShapeAttr(); + shape->CalcAabBox(); + aab.SetMinMax(shape->GetWorkAab()); } - for (dCcMassS_Obj* pObj = mMassAreas; pObj < mMassAreas + mMassAreaCount; ++pObj) { - cCcD_ShapeAttr* objShape = pObj->GetObj()->GetShapeAttr(); - objShape->CalcAabBox(); - aab.SetMinMax(objShape->GetWorkAab()); + for (dCcMassS_Obj* i = mMassAreas; i < mMassAreas + mMassAreaCount; ++i) { + cCcD_Obj* parea = i->GetObj(); + JUT_ASSERT(135, parea != NULL); + + cCcD_ShapeAttr* shape = parea->GetShapeAttr(); + shape->CalcAabBox(); + aab.SetMinMax(shape->GetWorkAab()); } if (field_0x202 & 1) { @@ -79,16 +85,23 @@ void dCcMassS_Mng::Prepare() { } mDivideArea.SetArea(aab); - for (dCcMassS_Obj* pObj = mMassObjs; pObj < mMassObjs + mMassObjCount; ++pObj) { - cCcD_ShapeAttr* objShape = pObj->GetObj()->GetShapeAttr(); - cCcD_DivideInfo* divideInfo = &pObj->GetDivideInfo(); - mDivideArea.CalcDivideInfo(divideInfo, objShape->GetWorkAab(), 0); + + for (dCcMassS_Obj* i = mMassObjs; i < mMassObjs + mMassObjCount; ++i) { + cCcD_Obj* pobj = i->GetObj(); + JUT_ASSERT(155, pobj != NULL); + + cCcD_ShapeAttr* shape = pobj->GetShapeAttr(); + cCcD_DivideInfo* pdivinfo = i->GetPDivideInfo(); + mDivideArea.CalcDivideInfo(pdivinfo, shape->GetWorkAab(), 0); } - for (dCcMassS_Obj* pObj = mMassAreas; pObj < mMassAreas + mMassAreaCount; ++pObj) { - cCcD_ShapeAttr* objShape = pObj->GetObj()->GetShapeAttr(); - cCcD_DivideInfo* divideInfo = &pObj->GetDivideInfo(); - mDivideArea.CalcDivideInfo(divideInfo, objShape->GetWorkAab(), 0); + for (dCcMassS_Obj* i = mMassAreas; i < mMassAreas + mMassAreaCount; ++i) { + cCcD_Obj* parea = i->GetObj(); + JUT_ASSERT(166, parea != NULL); + + cCcD_ShapeAttr* shape = parea->GetShapeAttr(); + cCcD_DivideInfo* pdivinfo = i->GetPDivideInfo(); + mDivideArea.CalcDivideInfo(pdivinfo, shape->GetWorkAab(), 0); } if (field_0x202 & 1) { @@ -106,32 +119,36 @@ void dCcMassS_Mng::Prepare() { mCamBottomDist = G_CM3D_F_INF; } -u32 dCcMassS_Mng::Chk(cXyz* p_xyz, fopAc_ac_c** p_actor, dCcMassS_HitInf* p_hitInf) { +u32 dCcMassS_Mng::Chk(cXyz* ppos, fopAc_ac_c** ppactor, dCcMassS_HitInf* phitinf) { cCcD_DivideInfo divideInfo; u32 flagsMaybe = 0; - *p_actor = NULL; + *ppactor = NULL; - mCylAttr.SetC(*p_xyz); + mCylAttr.SetC(*ppos); mCylAttr.CalcAabBox(); mDivideArea.CalcDivideInfoOverArea(÷Info, mCylAttr.GetWorkAab()); - p_hitInf->ClearPointer(); + phitinf->ClearPointer(); if (field_0x200 & 8) { for (dCcMassS_Obj* massObj = mMassAreas; massObj < mMassAreas + mMassAreaCount; ++massObj) { - if (massObj->GetDivideInfo().Chk(divideInfo)) { - cCcD_Obj* obj = massObj->GetObj(); - cCcD_ShapeAttr* objShape = obj->GetShapeAttr(); + cCcD_DivideInfo* pdivinfo = massObj->GetPDivideInfo(); + if (pdivinfo->Chk(divideInfo)) { + cCcD_Obj* pobj = massObj->GetObj(); + JUT_ASSERT(226, pobj != NULL); + + cCcD_ShapeAttr* shape = pobj->GetShapeAttr(); f32 f; - if (obj->ChkCoSet() && mCylAttr.CrossCo(*objShape, &f)) { + if (pobj->ChkCoSet() && mCylAttr.CrossCo(*shape, &f)) { flagsMaybe |= 4; - *p_actor = obj->GetStts()->GetAc(); - if (p_hitInf != NULL) { - p_hitInf->SetAreaHitObj(obj); + *ppactor = pobj->GetStts()->GetActor(); + if (phitinf != NULL) { + phitinf->SetAreaHitObj(pobj); } - if (massObj->GetCallback() != NULL) { - massObj->GetCallback()(obj->GetStts()->GetAc(), p_xyz, field_0x201); + if (massObj->GetAreaCheckFunc() != NULL) { + dCcMassS_ObjCallback sp1C = massObj->GetAreaCheckFunc(); + sp1C(pobj->GetStts()->GetActor(), ppos, field_0x201); } } } @@ -139,42 +156,46 @@ u32 dCcMassS_Mng::Chk(cXyz* p_xyz, fopAc_ac_c** p_actor, dCcMassS_HitInf* p_hitI } for (dCcMassS_Obj* massObj = mMassObjs; massObj < mMassObjs + mMassObjCount; ++massObj) { - if (massObj->GetDivideInfo().Chk(divideInfo)) { - cCcD_Obj* obj = massObj->GetObj(); - dCcD_GObjInf* gobjInf = (dCcD_GObjInf*)obj->GetGObjInf(); - cCcD_ShapeAttr* objShape = obj->GetShapeAttr(); + cCcD_DivideInfo* pdivinfo = massObj->GetPDivideInfo(); + if (pdivinfo->Chk(divideInfo)) { cXyz unusedVec; - if (obj->ChkAtSet() && !gobjInf->ChkAtNoMass() && - mCylAttr.CrossAtTg(*objShape, &unusedVec) && (field_0x200 & 1)) + cCcD_Obj* pobj = massObj->GetObj(); + dCcD_GObjInf* gobjInf = (dCcD_GObjInf*)pobj->GetGObjInf(); + JUT_ASSERT(266, pobj != NULL); + + cCcD_ShapeAttr* shape = pobj->GetShapeAttr(); + + if (pobj->ChkAtSet() && !gobjInf->ChkAtNoMass() && + mCylAttr.CrossAtTg(*shape, &unusedVec) && (field_0x200 & 1)) { flagsMaybe |= 1; - *p_actor = obj->GetStts()->GetAc(); - if (p_hitInf != NULL) { - p_hitInf->SetAtHitObj(obj); + *ppactor = pobj->GetStts()->GetActor(); + if (phitinf != NULL) { + phitinf->SetAtHitObj(pobj); } } f32 f; - if (obj->ChkCoSet() && mCylAttr.CrossCo(*objShape, &f) && (field_0x200 & 2)) { + if (pobj->ChkCoSet() && mCylAttr.CrossCo(*shape, &f) && (field_0x200 & 2)) { flagsMaybe |= 2; - *p_actor = obj->GetStts()->GetAc(); + *ppactor = pobj->GetStts()->GetActor(); if (field_0x200 & 0x10) { - Vec vec; - VECSubtract(&(*p_actor)->current.pos, p_xyz, &vec); + cXyz vec; + PSVECSubtract(&(*ppactor)->current.pos, ppos, &vec); vec.y = 0; - f32 vecMag = VECMag(&vec); + f32 vecMag = PSVECMag(&vec); if (cM3d_IsZero(vecMag)) { vec.x = 1; } else { - VECScale(&vec, &vec, f / vecMag); + PSVECScale(&vec, &vec, f / vecMag); } - obj->GetStts()->PlusCcMove(vec.x, vec.y, vec.z); + pobj->GetStts()->PlusCcMove(vec.x, vec.y, vec.z); } - if (p_hitInf != NULL) { - p_hitInf->SetCoHitObj(obj); - p_hitInf->SetCoHitLen(f); + if (phitinf != NULL) { + phitinf->SetCoHitObj(pobj); + phitinf->SetCoHitLen(f); } } } @@ -182,18 +203,18 @@ u32 dCcMassS_Mng::Chk(cXyz* p_xyz, fopAc_ac_c** p_actor, dCcMassS_HitInf* p_hitI f32 f; if ((field_0x202 & 1) && mDivideInfo.Chk(divideInfo) && mCylAttr.CrossCo(mCpsAttr, &f)) { - mResultCam |= 1; - mResultCam |= 1 << (field_0x201 + 1); + mResultCam |= (u8)1; + mResultCam |= (1 << (field_0x201 + 1)); if ((mResultCam & 2) || (mResultCam & 8)) { - cXyz tmpVec; - f32 plusH = p_xyz->y + mCylAttr.GetH(); - tmpVec.x = p_xyz->x; + Vec tmpVec; + f32 plusH = ppos->y + mCylAttr.GetH(); + tmpVec.x = ppos->x; tmpVec.y = plusH; - tmpVec.z = p_xyz->z; + tmpVec.z = ppos->z; if (mCamTopPos.y < (20.0f + plusH)) { - f32 newCamTopDist = VECSquareDistance(&tmpVec, &mCpsAttr.GetStartP()); + f32 newCamTopDist = PSVECSquareDistance(&tmpVec, mCpsAttr.GetStartP()); if (mCamTopDist > newCamTopDist) { mCamTopDist = newCamTopDist; mCamTopPos = tmpVec; @@ -201,7 +222,7 @@ u32 dCcMassS_Mng::Chk(cXyz* p_xyz, fopAc_ac_c** p_actor, dCcMassS_HitInf* p_hitI } if (mCamBottomPos.y < (20.0f + plusH)) { - f32 newCamBottomDist = VECSquareDistance(&tmpVec, &mCpsAttr.GetEndP()); + f32 newCamBottomDist = PSVECSquareDistance(&tmpVec, mCpsAttr.GetEndP()); if (mCamBottomDist > newCamBottomDist) { mCamBottomDist = newCamBottomDist; mCamBottomPos = tmpVec; @@ -231,24 +252,24 @@ void dCcMassS_Mng::Clear() { field_0x201 = 4; } -void dCcMassS_Mng::Set(cCcD_Obj* p_obj, u8 priority) { +void dCcMassS_Mng::Set(cCcD_Obj* pobj, u8 priority) { if (mMassObjCount >= ARRAY_SIZE(mMassObjs)) { for (int i = 0; i < ARRAY_SIZE(mMassObjs); ++i) { int prevPrio = mMassObjs[i].GetPriority(); if (prevPrio > priority || (prevPrio == priority && cM_rndF(1.0f) < 0.5f)) { - mMassObjs[i].Set(p_obj, priority, NULL); + mMassObjs[i].Set(pobj, priority, NULL); break; } } } else { - mMassObjs[mMassObjCount].Set(p_obj, priority, NULL); + mMassObjs[mMassObjCount].Set(pobj, priority, NULL); mMassObjCount++; } } -void dCcMassS_Mng::SetCam(cM3dGCps const& cps) { +void dCcMassS_Mng::SetCam(const cM3dGCps& cps) { mCpsAttr.SetCps(cps); - field_0x202 |= 1; + field_0x202 |= (u8)1; mResultCam = 0; } @@ -256,6 +277,6 @@ u32 dCcMassS_Mng::GetResultCam() const { return mResultCam; } -void dCcMassS_Mng::GetCamTopPos(Vec* p_out) { - *p_out = mCamTopPos; +void dCcMassS_Mng::GetCamTopPos(Vec* ppos) { + *ppos = mCamTopPos; } diff --git a/src/d/d_cc_s.cpp b/src/d/d_cc_s.cpp index ccb8501542..de9fa587ed 100644 --- a/src/d/d_cc_s.cpp +++ b/src/d/d_cc_s.cpp @@ -10,13 +10,114 @@ #include "d/d_jnt_col.h" #include "f_op/f_op_actor_mng.h" +class dCcS_HIO : public JORReflexible { +public: + enum flags_e { + FLAG_CAM_COL_DISP_e = 0x1, + FLAG_AT_ON_e = 0x2, + FLAG_TG_ON_e = 0x4, + FLAG_CO_ON_e = 0x8, + FLAG_DRAW_CLEAR_OFF_e = 0x10, + FLAG_COUNTER_e = 0x20, + FLAG_MOVE_OFF_e = 0x40, + FLAG_MASS_OFF_e = 0x80, + FLAG_MOVE_TIMER_e = 0x100, + FLAG_MASS_TIMER_e = 0x200, + FLAG_MASS_COUNTER_e = 0x400, + FLAG_ALL_MASS_TIMER_e = 0x800, + + }; + + dCcS_HIO() { + m_flags = 0; + m_shield_range = 0x4000; + } + + virtual ~dCcS_HIO(); + + void genMessage(JORMContext*); + + BOOL ChkMoveTimer() { return m_flags & FLAG_MOVE_TIMER_e; } + BOOL ChkMoveOff() { return m_flags & FLAG_MOVE_OFF_e; } + BOOL ChkAllMassTimer() { return m_flags & FLAG_ALL_MASS_TIMER_e; } + BOOL ChkDrawClearOff() { return m_flags & FLAG_DRAW_CLEAR_OFF_e; } + BOOL ChkCounter() { return m_flags & FLAG_COUNTER_e; } + BOOL ChkCamColDisp() { return m_flags & FLAG_CAM_COL_DISP_e; } + BOOL CheckCoOn() { return m_flags & FLAG_CO_ON_e; } + BOOL CheckTgOn() { return m_flags & FLAG_TG_ON_e; } + BOOL CheckAtOn() { return m_flags & FLAG_AT_ON_e; } + BOOL ChkMassCounter() { return m_flags & FLAG_MASS_COUNTER_e; } + BOOL ChkMassOff() { return m_flags & FLAG_MASS_OFF_e; } + BOOL ChkMassTimer() { return m_flags & FLAG_MASS_TIMER_e; } + + /* 0x4 */ s8 id; + /* 0x6 */ u16 m_flags; + /* 0x8 */ s16 m_shield_range; +}; + +#if DEBUG +dCcS_HIO::~dCcS_HIO() {} + +void dCcS_HIO::genMessage(JORMContext* mctx) { + mctx->genLabel("処理関係 -----", 0); + mctx->genCheckBox("処理Off", &m_flags, 0x40); + mctx->genCheckBox("多数ヒットチェック(草木花)Off", &m_flags, 0x80); + mctx->genCheckBox("多数ヒット 1回時間", &m_flags, 0x200); + mctx->genCheckBox("多数ヒット 通しの処理時間(->terminal)", &m_flags, 0x800); + mctx->genCheckBox("多数ヒット チェックカウンタ", &m_flags, 0x400); + mctx->genCheckBox("処理時間(->terminal)", &m_flags, 0x100); + + mctx->genLabel("描画関係 -----", 0); + mctx->genCheckBox("At 描画", &m_flags, 2); + mctx->genCheckBox("Tg 描画", &m_flags, 4); + mctx->genCheckBox("Co 描画", &m_flags, 8); + mctx->genCheckBox("カメラCo描画", &m_flags, 1); + mctx->genCheckBox("クリアOff", &m_flags, 0x10); + + mctx->genLabel("情報(->terminal) -----", 0); + mctx->genCheckBox("個数", &m_flags, 0x20); + + mctx->genLabel("特殊-----", 0); + mctx->genSlider("盾範囲(max=360度)", &m_shield_range, 0, 0x7FFF); +} + +static OSStopwatch s_move_timer; +static OSStopwatch s_mass_timer; + +static dCcS_HIO s_Hio; + +int g_mass_counter; +#endif + void dCcS::Ct() { cCcS::Ct(); + + #if DEBUG + m_is_mass_all_timer = 0; + s_Hio.id = mDoHIO_CREATE_CHILD("zelda コリジョンシステム", &s_Hio); + + OSInitStopwatch(&s_move_timer, "CollsionCheckMove"); + OSResetStopwatch(&s_move_timer); + OSInitStopwatch(&s_mass_timer, "MassCheck"); + OSResetStopwatch(&s_mass_timer); + + g_mass_counter = 0; + #endif + mMass_Mng.Ct(); + + #if DEBUG + dJntCol_setDebugHIO(); + #endif } void dCcS::Dt() { cCcS::Dt(); + + #if DEBUG + mDoHIO_DELETE_CHILD(s_Hio.id); + dJntCol_deleteDebugHIO(); + #endif } bool dCcS::ChkShieldFrontRange(cCcD_Obj* i_atObj, cCcD_Obj* i_tgObj, int param_2, @@ -110,11 +211,11 @@ void dCcS::CalcTgPlusDmg(cCcD_Obj* i_atObj, cCcD_Obj* i_tgObj, cCcD_Stts* i_atSt bool dCcS::ChkAtTgHitAfterCross(bool i_setAt, bool i_setTg, cCcD_GObjInf const* i_atObjInf, cCcD_GObjInf const* i_tgObjInf, cCcD_Stts* i_atStts, cCcD_Stts* i_tgStts, cCcD_GStts* i_atGStts, cCcD_GStts* i_tgGStts) { - dCcD_GObjInf* atObjInf = (dCcD_GObjInf*)i_atObjInf; - dCcD_GObjInf* tgObjInf = (dCcD_GObjInf*)i_tgObjInf; - fpc_ProcID tgApid = i_atStts->GetApid(); fpc_ProcID atApid = i_tgStts->GetApid(); + + dCcD_GObjInf* atObjInf = (dCcD_GObjInf*)i_atObjInf; + dCcD_GObjInf* tgObjInf = (dCcD_GObjInf*)i_tgObjInf; if (i_setAt) { static_cast(i_atGStts)->SetAtApid(atApid); @@ -269,9 +370,10 @@ void dCcS::SetPosCorrect(cCcD_Obj* i_co1Obj, cXyz* i_pos1, cCcD_Obj* i_co2Obj, c int co1_rank = GetRank(i_co1Obj->GetStts()->GetWeightUc()); int co2_rank = GetRank(i_co2Obj->GetStts()->GetWeightUc()); u8 rank = rank_tbl[co1_rank][co2_rank]; + u8 var_r22 = 100 - rank; f32 fvar1 = rank * 0.01f; - f32 fvar2 = (u8)(100 - rank) * 0.01f; + f32 fvar2 = var_r22 * 0.01f; cXyz co1_move; cXyz co2_move; @@ -279,8 +381,8 @@ void dCcS::SetPosCorrect(cCcD_Obj* i_co1Obj, cXyz* i_pos1, cCcD_Obj* i_co2Obj, c f32 fvar14; if (bvar2) { - VECSubtract(i_pos2, i_pos1, &local_c8); - fvar14 = VECMag(&local_c8); + PSVECSubtract(i_pos2, i_pos1, &local_c8); + fvar14 = PSVECMag(&local_c8); } else { local_c8.x = i_pos2->x - i_pos1->x; local_c8.y = 0.0f; @@ -290,14 +392,15 @@ void dCcS::SetPosCorrect(cCcD_Obj* i_co1Obj, cXyz* i_pos1, cCcD_Obj* i_co2Obj, c if (!cM3d_IsZero(fvar14)) { if (bvar2) { - VECScale(&local_c8, &local_c8, i_cross_len / fvar14); + f32 var_f26 = i_cross_len / fvar14; + PSVECScale(&local_c8, &local_c8, var_f26); fvar1 *= -1.0f; - VECScale(&local_c8, &co1_move, fvar1); - VECScale(&local_c8, &co2_move, fvar2); + PSVECScale(&local_c8, &co1_move, fvar1); + PSVECScale(&local_c8, &co2_move, fvar2); } else { - fvar14 = i_cross_len / fvar14; - local_c8.x *= fvar14; - local_c8.z *= fvar14; + f32 var_f27 = i_cross_len / fvar14; + local_c8.x *= var_f27; + local_c8.z *= var_f27; co1_move.x = -local_c8.x * fvar1; co1_move.y = 0.0f; @@ -332,27 +435,25 @@ void dCcS::CalcParticleAngle(dCcD_GObjInf* i_atObjInf, cCcD_Stts* i_atStts, cCcD csXyz* o_angle) { cXyz vec(*i_atObjInf->GetAtVecP()); - if (cM3d_IsZero(VECMag(&vec))) { + if (cM3d_IsZero(PSVECMag(&vec))) { fopAc_ac_c* atActor = i_atStts->GetActor(); fopAc_ac_c* tgActor = i_tgStts->GetActor(); if (atActor == NULL || tgActor == NULL) { - vec.z = 0.0f; - vec.x = 0.0f; + vec.x = vec.z = 0.0f; vec.y = -1.0f; } else { - VECSubtract(&tgActor->current.pos, &atActor->current.pos, &vec); + PSVECSubtract(&tgActor->current.pos, &atActor->current.pos, &vec); - if (cM3d_IsZero(VECMag(&vec))) { - vec.z = 0.0f; - vec.x = 0.0f; + if (cM3d_IsZero(PSVECMag(&vec))) { + vec.x = vec.z = 0.0f; vec.y = -1.0f; } else { - VECNormalize(&vec, &vec); + PSVECNormalize(&vec, &vec); } } } else { - VECNormalize(&vec, &vec); + PSVECNormalize(&vec, &vec); } cM3d_CalcVecZAngle(vec, o_angle); @@ -441,9 +542,9 @@ void dCcS::SetAtTgGObjInf(bool i_setAt, bool i_setTg, cCcD_Obj* i_atObj, cCcD_Ob atObjInf->SetAtHitApid(i_tgStts->GetApid()); - if (chk_shield || tgObjInf->GetTgHitMark() == 8 && atObjInf->GetAtMtrl() != dCcD_MTRL_ICE && + if (chk_shield || (tgObjInf->GetTgHitMark() == 8 && atObjInf->GetAtMtrl() != dCcD_MTRL_ICE && (atObjInf->GetAtSpl() == 0 || atObjInf->GetAtSpl() == 5 || - atObjInf->GetAtSpl() == 8)) + atObjInf->GetAtSpl() == 8))) { atObjInf->OnAtShieldHit(); } @@ -466,7 +567,8 @@ void dCcS::SetAtTgGObjInf(bool i_setAt, bool i_setTg, cCcD_Obj* i_atObj, cCcD_Ob if (chk_shield) { tgObjInf->OnTgShieldHit(); } else { - i_tgStts->PlusDmg(i_atObj->GetAtAtp()); + int atp = i_atObj->GetAtAtp(); + i_tgStts->PlusDmg(atp); } if (at_gstts->ChkNoActor()) { @@ -523,9 +625,10 @@ bool dCcS::ChkCamera(cXyz& param_0, cXyz& param_1, f32 param_2, fopAc_ac_c* para dCcD_GObjInf* obj = (dCcD_GObjInf*)(*i)->GetGObjInf(); if (obj == NULL || !obj->ChkCoNoCamHit()) { - cCcD_ShapeAttr* shapeAttr = (*i)->GetShapeAttr(); + cCcD_ShapeAttr* pco_sa = (*i)->GetShapeAttr(); + JUT_ASSERT(1058, pco_sa != NULL); - if (sp48.CrossCo(*shapeAttr, &sp14)) { + if (sp48.CrossCo(*pco_sa, &sp14)) { return true; } } @@ -604,10 +707,11 @@ bool dCcS::chkCameraPoint(cXyz const& param_0, cCcD_ShapeAttr::Shape* param_1, f dCcD_GObjInf* obj = (dCcD_GObjInf*)(*i)->GetGObjInf(); if (obj == NULL || !obj->ChkCoNoCamHit()) { - cCcD_ShapeAttr* shapeAttr = (*i)->GetShapeAttr(); + cCcD_ShapeAttr* pco_sa = (*i)->GetShapeAttr(); + JUT_ASSERT(1196, pco_sa != NULL); - if (sp48.CrossCo(*shapeAttr, &sp14)) { - shapeAttr->getShapeAccess(param_1); + if (sp48.CrossCo(*pco_sa, &sp14)) { + pco_sa->getShapeAccess(param_1); if (param_1->_0 != 2) { return true; @@ -626,12 +730,110 @@ void dCcS::MoveAfterCheck() {} void dCcS::DrawAfter() {} void dCcS::Move() { + #if DEBUG + if (s_Hio.ChkAllMassTimer()) { + OnMassAllTimer(); + } else { + OffMassAllTimer(); + } + + if (s_Hio.ChkMoveOff()) { + return; + } + + if (s_Hio.ChkMoveTimer()) { + OSStartStopwatch(&s_move_timer); + } + #endif + cCcS::Move(); + + #if DEBUG + if (s_Hio.ChkMoveTimer()) { + OSStopStopwatch(&s_move_timer); + OSDumpStopwatch(&s_move_timer); + } + #endif } void dCcS::Draw() { + #if DEBUG + if (s_Hio.ChkMassCounter()) { + OS_REPORT("Mass Counter %d\n", g_mass_counter); + g_mass_counter = 0; + } + + if (s_Hio.CheckAtOn()) { + for (int i = 0; i < field_0x280c; i++) { + if (mpObjAt[i] != NULL && mpObjAt[i]->ChkAtSet()) { + dCcD_GObjInf* gobj = (dCcD_GObjInf*)mpObjAt[i]->GetGObjInf(); + if (gobj->ChkAtHit()) { + GXColor color = {0xFF, 0, 0, 0xB4}; + mpObjAt[i]->Draw(color); + } else { + GXColor color = {0xFF, 0, 0, 0x50}; + mpObjAt[i]->Draw(color); + } + } + } + } + + if (s_Hio.CheckTgOn()) { + for (int i = 0; i < field_0x280e; i++) { + if (mpObjTg[i] != NULL && mpObjTg[i]->ChkTgSet()) { + dCcD_GObjInf* gobj = (dCcD_GObjInf*)mpObjTg[i]->GetGObjInf(); + if (gobj->ChkTgHit()) { + GXColor color = {0, 0xFF, 0, 0xB4}; + mpObjTg[i]->Draw(color); + } else { + GXColor color = {0, 0xFF, 0, 0x50}; + mpObjTg[i]->Draw(color); + } + } + } + } + + if (s_Hio.CheckCoOn()) { + for (int i = 0; i < field_0x2810; i++) { + if (mpObjCo[i] != NULL && mpObjCo[i]->ChkCoSet()) { + dCcD_GObjInf* gobj = (dCcD_GObjInf*)mpObjCo[i]->GetGObjInf(); + if (gobj->ChkCoHit()) { + GXColor color = {0xFF, 0xFF, 0xFF, 0xB4}; + mpObjCo[i]->Draw(color); + } else { + GXColor color = {0xFF, 0xFF, 0xFF, 0x50}; + mpObjCo[i]->Draw(color); + } + } + } + } + + if (s_Hio.ChkCamColDisp()) { + for (int i = 0; i < field_0x2810; i++) { + if (mpObjCo[i] != NULL && mpObjCo[i]->ChkCoSet()) { + dCcD_GObjInf* gobj = (dCcD_GObjInf*)mpObjCo[i]->GetGObjInf(); + if (!gobj->ChkCoNoCamHit()) { + GXColor color = {0xFF, 0xFF, 0, 0x50}; + mpObjCo[i]->Draw(color); + } + } + } + } + + if (s_Hio.ChkCounter()) { + OS_REPORT("At:%d,Tg:%d,Co:%d\n", field_0x280c, field_0x280e, field_0x2810); + } + #endif + DrawAfter(); - DrawClear(); + + #if DEBUG + if (!s_Hio.ChkDrawClearOff()) + #endif + { + DrawClear(); + } + mMass_Mng.Clear(); } @@ -657,7 +859,10 @@ BOOL dCcS::ChkAtTgMtrlHit(u8 i_atMtrl, u8 i_tgMtrl) { } bool dCcS::ChkNoHitGAtTg(cCcD_GObjInf const* i_atObjInf, cCcD_GObjInf const* i_tgObjInf, - cCcD_GStts*, cCcD_GStts*) { + cCcD_GStts* i_atStts, cCcD_GStts* i_tgStts) { + UNUSED(i_atStts); + UNUSED(i_tgStts); + dCcD_GObjInf* atObjInf = (dCcD_GObjInf*)i_atObjInf; dCcD_GObjInf* tgObjInf = (dCcD_GObjInf*)i_tgObjInf; diff --git a/src/d/d_jnt_col.cpp b/src/d/d_jnt_col.cpp index 7cf0d4af2b..a4e9e9bafc 100644 --- a/src/d/d_jnt_col.cpp +++ b/src/d/d_jnt_col.cpp @@ -376,8 +376,8 @@ int dJntCol_c::searchNearPos(cM3dGLin const* param_1, cXyz const* param_2, cXyz* mDoMtx_stack_c::YrotM(cM_atan2s(-sp1AC.x, sp1AC.z)); mDoMtx_stack_c::transM(-sp188.x, -sp188.y, -sp188.z); mDoMtx_stack_c::multVec(&sp17C, &sp194); - mDoMtx_stack_c::multVec(¶m_1->GetStartP(), &sp170); - mDoMtx_stack_c::multVec(¶m_1->GetEndP(), &sp164); + mDoMtx_stack_c::multVec(param_1->GetStartP(), &sp170); + mDoMtx_stack_c::multVec(param_1->GetEndP(), &sp164); sp1C4.SetStartEnd(sp170, sp164); sp1C = 1; } else {