diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2026-03-17 22:48:37 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-17 22:48:37 -0700 |
| commit | f64015ea383cc3ba93a90918ac3dd1d2f66e1e17 (patch) | |
| tree | e5b1205895176398034a77ccba6e2c498522fd88 /src/SSystem | |
| parent | 6694c1b281a142972fce587bd20cd82ee65ab38f (diff) | |
cc debug work (#3133)
Diffstat (limited to 'src/SSystem')
| -rw-r--r-- | src/SSystem/SComponent/c_bg_s_gnd_chk.cpp | 28 | ||||
| -rw-r--r-- | src/SSystem/SComponent/c_bg_s_lin_chk.cpp | 8 | ||||
| -rw-r--r-- | src/SSystem/SComponent/c_cc_d.cpp | 206 | ||||
| -rw-r--r-- | src/SSystem/SComponent/c_cc_s.cpp | 87 | ||||
| -rw-r--r-- | src/SSystem/SComponent/c_m3d.cpp | 148 |
5 files changed, 262 insertions, 215 deletions
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,43 +395,46 @@ 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; + } + + cXyz vec1; + PSVECSubtract(¶m_0, GetStartP(), &vec1); + f32 vec1Len = PSVECDotProduct(&vec1, &diff) / diffLen; + + cXyz vec2; + if (vec1Len < 0.0f) { + vec2 = *GetStartP(); } else { - Vec vec1, vec2; - VECSubtract(¶m_0, &mStart, &vec1); - f32 vec1Len = VECDotProduct(&vec1, &diff) / diffLen; - if (vec1Len < 0.0f) { - vec2 = mStart; + if (vec1Len > 1.0f) { + vec2 = *GetEndP(); } else { - if (vec1Len > 1.0f) { - vec2 = endP; - } else { - VECScale(&diff, &diff, vec1Len); - VECAdd(&diff, &mStart, &vec2); - } + PSVECScale(&diff, &diff, vec1Len); + PSVECAdd(&diff, GetStartP(), &vec2); } + } - VECSubtract(¶m_0, &vec2, param_1); - if (cM3d_IsZero(VECMag(param_1))) { - param_1->set(0.0f, 0.0f, 0.0f); - return false; - } else { - VECNormalize(param_1, param_1); - return true; - } + 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; } } @@ -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; - } 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(); + const cXyz* cp = GetCP(); + cXyz vec; + if (cp->y > param_0.y) { + vec = *cp; + } else { + 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; } } |
