d_jnt_col OK (#174)

* d_jnt_col almost ok

* OK: Thanks Robo!
This commit is contained in:
Elijah Thomas
2025-05-24 03:42:26 -04:00
committed by GitHub
parent 9efc1e0ab9
commit 4c62e01025
13 changed files with 475 additions and 69 deletions
+5
View File
@@ -12,5 +12,10 @@
"isDefault": true
}
},
{
"label": "Apply Objdiff Mappings",
"type": "shell",
"command": "python ${workspaceFolder}/tools/custom/apply_objdiff_mappings.py",
},
]
}
+6 -1
View File
@@ -2331,8 +2331,13 @@ d/col/cc/d_cc_s.cpp:
.sbss start:0x80575D20 end:0x80575D28
.sdata2 start:0x8057D258 end:0x8057D298
d/d_jnt_col.cpp:
.text start:0x80358660 end:0x803598C4 align:16
.sdata start:0x80574088 end:0x8057408C
.sdata2 start:0x8057D298 end:0x8057D2B8
toBeSorted/col/cc/misc_unks.cpp:
.text start:0x80358660 end:0x80359D20 align:16
.text start:0x803598D0 end:0x80359D20 align:16
.sbss start:0x80575D28 end:0x80575D30
d/snd/d_snd.cpp:
+19 -19
View File
@@ -14043,12 +14043,12 @@ __dt__23sFState_c<10dAcArrow_c>Fv = .text:0x8025D6F0; // type:function size:0x58
__dt__26sFStateFct_c<10dAcArrow_c>Fv = .text:0x8025D750; // type:function size:0x6C
__dt__79sStateMgr_c<10dAcArrow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x8025D7C0; // type:function size:0xA0
__dt__49sFStateMgr_c<10dAcArrow_c,20sStateMethodUsr_FI_c>Fv = .text:0x8025D860; // type:function size:0xA4
hitCallback__FP12dAcObjBase_cP12dCcD_GObjInfP12dAcObjBase_cP12dCcD_GObjInf = .text:0x8025D910; // type:function size:0x24
hitCallback__FP12dAcObjBase_cP8cCcD_ObjP12dAcObjBase_cP8cCcD_Obj = .text:0x8025D910; // type:function size:0x24
createHeap__10dAcArrow_cFv = .text:0x8025D940; // type:function size:0x90
create__10dAcArrow_cFv = .text:0x8025D9D0; // type:function size:0x184
changeState__79sStateMgr_c<10dAcArrow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x8025DB60; // type:function size:0x10
__dt__10dAcArrow_cFv = .text:0x8025DB70; // type:function size:0x110
hitCallback__10dAcArrow_cFP12dCcD_GObjInfP12dAcObjBase_cP12dCcD_GObjInf = .text:0x8025DC80; // type:function size:0xA0
hitCallback__10dAcArrow_cFP8cCcD_ObjP12dAcObjBase_cP8cCcD_Obj = .text:0x8025DC80; // type:function size:0xA0
fn_8025DD20 = .text:0x8025DD20; // type:function size:0x1AC
fn_8025DED0 = .text:0x8025DED0; // type:function size:0x288
fn_8025E160 = .text:0x8025E160; // type:function size:0x480
@@ -19782,14 +19782,14 @@ MassClear__4dCcSFv = .text:0x80358460; // type:function size:0x8
SetArea__4dCcSFP6mMtx_c = .text:0x80358470; // type:function size:0x114
ClearArea__4dCcSFv = .text:0x80358590; // type:function size:0xC
AdjustHitPos__4dCcSFv = .text:0x803585A0; // type:function size:0xB4
__ct__12todoStruct00Fv = .text:0x80358660; // type:function size:0x1C
fn_80358680 = .text:0x80358680; // type:function size:0x2C
fn_803586B0 = .text:0x803586B0; // type:function size:0x7C
fn_80358730 = .text:0x80358730; // type:function size:0x11C
fn_80358850 = .text:0x80358850; // type:function size:0xBC0
fn_80359410 = .text:0x80359410; // type:function size:0xF0
fn_80359500 = .text:0x80359500; // type:function size:0x30C
fn_80359810 = .text:0x80359810; // type:function size:0xB4
__ct__9dJntCol_cFv = .text:0x80358660; // type:function size:0x1C
init__9dJntCol_cFP12dAcObjBase_cPC13dJntColData_cPQ23m3d5mdl_ci = .text:0x80358680; // type:function size:0x2C
getAnmMtx__9dJntCol_cCFlP6mMtx_c = .text:0x803586B0; // type:function size:0x7C
setNowLine__9dJntCol_cFP8cM3dGLinPC7mVec3_cPC7mAng3_cP7mVec3_c = .text:0x80358730; // type:function size:0x11C
searchNearPos__9dJntCol_cCFPC8cM3dGLinPC7mVec3_cP7mVec3_ci = .text:0x80358850; // type:function size:0xBC0
getArrowOffsetPosAndAngle__9dJntCol_cCFPC7mVec3_cPC7mAng3_cP7mVec3_cP7mVec3_cb = .text:0x80359410; // type:function size:0xF0
getHitmarkPosAndAngle__9dJntCol_cCFPC7mVec3_cPC7mAng3_cP7mVec3_cP7mAng3_ci = .text:0x80359500; // type:function size:0x30C
setArrowPosAndAngle__9dJntCol_cFPC7mVec3_cPC7mVec3_ciP7mVec3_cP7mAng3_c = .text:0x80359810; // type:function size:0xB4
__ct__14dBgW_Base_0x18Fv = .text:0x803598D0; // type:function size:0x18
__dt__14dBgW_Base_0x18Fv = .text:0x803598F0; // type:function size:0x40
fn_80359930 = .text:0x80359930; // type:function size:0x14
@@ -40617,7 +40617,7 @@ lbl_8057406C = .sdata:0x8057406C; // type:object size:0x4 data:4byte
lbl_80574070 = .sdata:0x80574070; // type:object size:0x8
lbl_80574078 = .sdata:0x80574078; // type:object size:0x8
lbl_80574080 = .sdata:0x80574080; // type:object size:0x8
lbl_80574088 = .sdata:0x80574088; // type:object size:0x8 data:4byte
lbl_80574088 = .sdata:0x80574088; // type:object size:0x4 scope:local data:4byte
lbl_80574090 = .sdata:0x80574090; // type:object size:0x8
lbl_80574098 = .sdata:0x80574098; // type:object size:0x4
lbl_8057409C = .sdata:0x8057409C; // type:object size:0x4
@@ -48327,14 +48327,14 @@ lbl_8057D284 = .sdata2:0x8057D284; // type:object size:0x4 align:4 data:float
lbl_8057D288 = .sdata2:0x8057D288; // type:object size:0x4 align:4 data:float
lbl_8057D28C = .sdata2:0x8057D28C; // type:object size:0x4 align:4 data:float
lbl_8057D290 = .sdata2:0x8057D290; // type:object size:0x4 align:4 data:float
lbl_8057D298 = .sdata2:0x8057D298; // type:object size:0x4 align:4 data:float
lbl_8057D29C = .sdata2:0x8057D29C; // type:object size:0x4 align:4 data:float
lbl_8057D2A0 = .sdata2:0x8057D2A0; // type:object size:0x4 align:4 data:float
lbl_8057D2A4 = .sdata2:0x8057D2A4; // type:object size:0x4 align:4 data:float
lbl_8057D2A8 = .sdata2:0x8057D2A8; // type:object size:0x4 align:4 data:float
lbl_8057D2AC = .sdata2:0x8057D2AC; // type:object size:0x4 align:4 data:float
lbl_8057D2B0 = .sdata2:0x8057D2B0; // type:object size:0x4 align:4 data:float
lbl_8057D2B4 = .sdata2:0x8057D2B4; // type:object size:0x4 align:4 data:float
lbl_8057D298 = .sdata2:0x8057D298; // type:object size:0x4 scope:local align:4 data:float
lbl_8057D29C = .sdata2:0x8057D29C; // type:object size:0x4 scope:local align:4 data:float
lbl_8057D2A0 = .sdata2:0x8057D2A0; // type:object size:0x4 scope:local align:4 data:float
lbl_8057D2A4 = .sdata2:0x8057D2A4; // type:object size:0x4 scope:local align:4 data:float
lbl_8057D2A8 = .sdata2:0x8057D2A8; // type:object size:0x4 scope:local align:4 data:float
lbl_8057D2AC = .sdata2:0x8057D2AC; // type:object size:0x4 scope:local align:4 data:float
lbl_8057D2B0 = .sdata2:0x8057D2B0; // type:object size:0x4 scope:local align:4 data:float
lbl_8057D2B4 = .sdata2:0x8057D2B4; // type:object size:0x4 scope:local align:4 data:float
lbl_8057D2B8 = .sdata2:0x8057D2B8; // type:object size:0x4 align:4 data:float
lbl_8057D2C0 = .sdata2:0x8057D2C0; // type:object size:0x4 align:4 data:float
lbl_8057D2C4 = .sdata2:0x8057D2C4; // type:object size:0x4 align:4 data:float
+1
View File
@@ -688,6 +688,7 @@ config.libs = [
Object(NonMatching, "toBeSorted/col/cc/unk_flag_check.cpp"),
Object(Matching, "d/col/cc/d_cc_mass_s.cpp"),
Object(NonMatching, "d/col/cc/d_cc_s.cpp"),
Object(Matching, "d/d_jnt_col.cpp"),
Object(NonMatching, "toBeSorted/col/cc/misc_unks.cpp"),
],
},
+2 -2
View File
@@ -7,8 +7,8 @@
#include "d/a/obj/d_a_obj_bomb.h"
#include "d/col/bg/d_bg_s_acch.h"
#include "d/col/cc/d_cc_d.h"
#include "d/d_jnt_col.h"
#include "d/d_shadow.h"
#include "d/flag/sceneflag_manager.h"
#include "m/m3d/m_anmmatclr.h"
#include "m/m3d/m_anmtexpat.h"
#include "m/m_angle.h"
@@ -139,7 +139,7 @@ private:
/* 0x600 */ dBgS_ObjAcch mObjAcch;
/* 0x9B0 */ STATE_MGR_DECLARE(dAcEsm_c);
/* 0x9EC */ dAcRef_c<dAcBomb_c> mBombRef;
/* 0x9F8 */ todoStruct00 field_0x9f8;
/* 0x9F8 */ dJntCol_c mJntCol;
/* 0xA0C */ EffectsStruct mEffArr[2];
/* 0xA74 */ TimeAreaStruct mTimeArea;
/* 0xA80 */ mVec3_c mPosCopy1;
+7 -25
View File
@@ -1,11 +1,12 @@
#ifndef D_A_OBJ_BASE_H
#define D_A_OBJ_BASE_H
#include "c/c_math.h"
#include "common.h"
#include "d/a/d_a_base.h"
#include "d/col/c/c_cc_d.h"
#include "d/col/c/c_m3d_g_aab.h"
#include "d/col/c/c_m3d_g_lin.h"
#include "d/d_jnt_col.h"
#include "egg/math/eggMath.h"
#include "m/m3d/m_shadow.h"
#include "m/m3d/m_smdl.h"
@@ -14,33 +15,10 @@
#include "m/m_mtx.h"
#include "m/m_vec.h"
#include "m/types_m.h"
#include "rvl/MTX/mtx.h"
class dAcObjBase_c;
class dBgS_Acch;
// This is found in dAcObamboo, dAcPy, and dAcEsm
// Since they have object in common, it will reside here
// until further notice.
#include "m/m3d/m_mdl.h"
struct todoStruct00 {
struct InternalData {
u16 field_0x00;
f32 field_0x04;
InternalData *pNextData;
};
todoStruct00();
void Set(dAcObjBase_c *pActor, InternalData *pData, m3d::mdl_c *pMdl, u32);
/* 0x00 */ InternalData *field_0x00;
/* 0x04 */ m3d::mdl_c *mpMdl;
/* 0x08 */ dAcObjBase_c *mpActor;
/* 0x0C */ u32 mCount; // Guess
/* 0x10 */ u32 field_0x10;
};
// Size: 0xA8
struct ActorCarryStruct {
/* 0x00 */ dAcRefBase_c actorLink;
@@ -61,7 +39,7 @@ struct ActorCarryStruct {
ActorCarryStruct();
/* vt 0x9C */
virtual ~ActorCarryStruct();
/* 0xA0 */ u32 field_0xA0;
/* 0xA0 */ dJntCol_c *field_0xA0;
/* 0xA4 */ u32 field_0xA4;
void set(u32 flags, f32 x, f32 y, f32 z, void *unk);
@@ -189,6 +167,10 @@ public:
return mObjectActorFlags & property;
}
void SetJntCol(dJntCol_c *pCol) {
mActorCarryInfo.field_0xA0 = pCol;
}
// could be their own thing?
/* 8002de40 */ static void *getOarcFile(const char *oarcName, const char *fileName);
/* 8002de60 */ static void *getOarcSubEntry(const char *oarcName, const char *fileName);
+18 -7
View File
@@ -3,9 +3,10 @@
#include "common.h"
#include "math.h"
#include "nw4r/math.h" // IWYU pragma: export
#include "nw4r/types_nw4r.h"
#include "nw4r/math.h" // IWYU pragma: export
class cM3dGAab;
class cM3dGCps;
class cM3dGCyl;
@@ -21,18 +22,24 @@ extern const f32 G_CM3D_F_ABS_MIN;
bool cM3d_Len2dSqPntAndSegLine(f32, f32, f32, f32, f32, f32, f32 *, f32 *, f32 *);
bool cM3d_Len3dSqPntAndSegLine(const cM3dGLin &, const nw4r::math::VEC3 &, nw4r::math::VEC3 *, f32 *, f32 *);
f32 cM3d_SignedLenPlaAndPos(const cM3dGPla &, const nw4r::math::VEC3 *);
void cM3d_CalcPla(const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, nw4r::math::VEC3 *, f32 *);
f32 cM3d_SignedLenPlaAndPos(const cM3dGPla *, const nw4r::math::VEC3 *);
void cM3d_CalcPla(
const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, nw4r::math::VEC3 *, f32 *
);
int cM3d_Check_LinLin(const cM3dGLin &, const cM3dGLin *, f32 *, f32 *);
bool cM3d_Cross_LinPla(const cM3dGLin &, const cM3dGPla *, nw4r::math::VEC3 *, bool, bool);
bool cM3d_Cross_MinMaxBoxLine(const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *);
bool cM3d_Cross_MinMaxBoxLine(
const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *
);
bool cM3d_InclusionCheckPosIn3PosBox3d(
const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, f32
);
bool cM3d_CrossX_Tri(const cM3dGTri &, const nw4r::math::VEC3 *, f32);
bool cM3d_CrossX_Tri(const cM3dGTri &, const nw4r::math::VEC3 *);
bool cM3d_CrossY_Tri(const cM3dGTri &, const nw4r::math::VEC3 *);
bool cM3d_CrossY_Tri_Front(const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 *);
bool cM3d_CrossY_Tri_Front(
const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 *
);
bool cM3d_CrossY_Tri(const cM3dGTri &, const nw4r::math::VEC3 *, f32 *);
bool cM3d_CrossY_Tri(const cM3dGTri &, const nw4r::math::VEC3 *, f32);
bool cM3d_CrossY_Tri(const cM3dGTri &, const nw4r::math::VEC3 *, const cM3d_Range *, f32 *);
@@ -59,7 +66,9 @@ bool cM3d_Cross_CylCyl(const cM3dGCyl &, const cM3dGCyl &, f32 *);
bool cM3d_Cross_CylCyl(const cM3dGCyl &, const cM3dGCyl &, nw4r::math::VEC3 *);
bool cM3d_Cross_CylTri(const cM3dGCyl &, const cM3dGTri &, nw4r::math::VEC3 *);
int cM3d_Cross_CylLin(const cM3dGCyl &, const cM3dGLin &, nw4r::math::VEC3 *, nw4r::math::VEC3 *);
int cM3d_Cross_CylPntPnt(const cM3dGCyl &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, nw4r::math::VEC3 *, nw4r::math::VEC3 *);
int cM3d_Cross_CylPntPnt(
const cM3dGCyl &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, nw4r::math::VEC3 *, nw4r::math::VEC3 *
);
bool cM3d_Cross_CylPnt(const cM3dGCyl &, const nw4r::math::VEC3 &);
bool cM3d_Cross_CpsCps(const cM3dGCps &, const cM3dGCps &, nw4r::math::VEC3 *, f32 *, f32 *);
bool cM3d_Cross_CpsCyl(const cM3dGCps &, const cM3dGCyl &, nw4r::math::VEC3 *);
@@ -72,7 +81,9 @@ void cM3d_PlaneCrossLineProcWork(f32, f32, f32, f32, f32, f32, f32, f32 *, f32 *
int cM3d_2PlaneCrossLine(const cM3dGPla &, const cM3dGPla &, cM3dGLin *);
bool cM3d_3PlaneCrossPos(const cM3dGPla &, const cM3dGPla &, const cM3dGPla &, nw4r::math::VEC3 *);
f32 cM3d_lineVsPosSuisenCross(const cM3dGLin &, const nw4r::math::VEC3 &, nw4r::math::VEC3 *);
f32 cM3d_lineVsPosSuisenCross(const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, nw4r::math::VEC3 *);
f32 cM3d_lineVsPosSuisenCross(
const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, nw4r::math::VEC3 *
);
bool cM3d_Cross_UnkTri(const cM3dGUnk &, cM3dGTri &, nw4r::math::VEC3 *);
bool cM3d_Cross_CylUnk(const cM3dGCyl &, cM3dGUnk &, nw4r::math::VEC3 *);
+7 -1
View File
@@ -5,6 +5,7 @@
#include "d/col/c/c_m3d.h"
#include "m/m_angle.h"
#include "m/m_vec.h"
#include "rvl/MTX/vec.h"
// Plane with a normal
class cM3dGPla {
@@ -22,8 +23,13 @@ public:
mAng GetAngle(mAng) const;
mAng GetNegativeAngle(mAng) const;
void SetupNP0(const mVec3_c &normal, const mVec3_c &point) {
mNormal = normal;
VECNormalize(mNormal, mNormal);
mD = -VECDotProduct(mNormal, point);
}
// Unused
// void SetupNP0(const mVec3_c &, const mVec3_c &);
// void SetupNP(const mVec3_c &, const mVec3_c &);
// bool getCrossY(const mVec3_c &, f32 *) const;
// void Set(const cM3dGPla *);
+68
View File
@@ -0,0 +1,68 @@
#ifndef D_JNT_COL_H
#define D_JNT_COL_H
#include "d/col/c/c_m3d_g_lin.h"
#include "m/m3d/m_mdl.h"
#include "m/m_mtx.h"
#include "m/m_vec.h"
class dAcObjBase_c;
class dJntColData_c {
public:
/* 0x0 */ u8 field_0x0;
/* 0x1 */ u8 mType;
/* 0x2 */ s16 mJntNum;
/* 0x4 */ f32 field_0x4;
/* 0x8 */ Vec *field_0x8;
mVec3_c getVec(int i) const {
return field_0x8[i];
}
};
class dJntCol_c {
public:
dJntCol_c();
void getAnmMtx(s32, mMtx_c *) const;
int init(dAcObjBase_c *, dJntColData_c const *, m3d::mdl_c *, int);
static void setNowLine(cM3dGLin *, mVec3_c const *, mAng3_c const *, mVec3_c *);
int searchNearPos(cM3dGLin const *, mVec3_c const *, mVec3_c *, int) const;
int getArrowOffsetPosAndAngle(mVec3_c const *, mAng3_c const *, mVec3_c *, mVec3_c *, bool) const;
int getHitmarkPosAndAngle(mVec3_c const *, mAng3_c const *, mVec3_c *, mAng3_c *, int) const;
void setArrowPosAndAngle(mVec3_c const *, mVec3_c const *, int, mVec3_c *, mAng3_c *);
bool checkPassNum(int bit) const {
return field_0x10 & (1 << bit);
}
void onPassNum(int num) {
field_0x10 |= (1 << num);
}
void offPassNum(int num) {
field_0x10 &= ~(1 << num);
}
s8 getType(int i) const {
return mData[i].mType;
}
int getJntNum(int i) const {
return mData[i].mJntNum;
}
u8 getfield_0x0(int i) const {
return mData[i].field_0x0;
}
f32 getfield_0x4(int i) const {
return mData[i].field_0x4;
}
mVec3_c getVec(int i) const {
return mData->field_0x8[i];
}
/* 0x00 */ const dJntColData_c *mData;
/* 0x04 */ m3d::mdl_c *mpModel;
/* 0x08 */ dAcObjBase_c *mpActor;
/* 0x0C */ int field_0xC;
/* 0x10 */ int field_0x10;
};
#endif /* D_D_JNT_COL_H */
+40 -11
View File
@@ -35,7 +35,7 @@ public:
operator const nw4r::math::MTX34 *() const {
return (nw4r::math::MTX34 *)(this);
}
operator const nw4r::math::MTX34 &() const {
operator const nw4r::math::MTX34 &() const {
return *(nw4r::math::MTX34 *)(this);
}
@@ -78,9 +78,15 @@ public:
void ZYXrotM(const mAng3_c &ang) {
ZYXrotM(ang.x, ang.y, ang.z);
}
void ZXYrotS(const mAng3_c &ang) {
ZXYrotS(ang.x, ang.y, ang.z);
}
void toRot(mAng3_c &out) const; ///< Converts the matrix to a rotation vector.
void inverse() {
MTXInverse(*this, *this);
}
void multVecZero(nw4r::math::VEC3 &out) const; ///< Converts the matrix to a vector.
void zero(); ///< Zeroes out the matrix.
@@ -88,34 +94,57 @@ public:
bool quatRelated();
void transS(const mVec3_c &v) {
PSMTXTrans(*this, v.x, v.y, v.z);
MTXTrans(*this, v.x, v.y, v.z);
}
void transS(f32 x, f32 y, f32 z) {
PSMTXTrans(*this, x, y, z);
MTXTrans(*this, x, y, z);
}
mVec3_c multVec(const mVec3_c &v) const {
mVec3_c ret = v;
PSMTXMultVec(*this, ret, ret);
return ret;
void transM(const mVec3_c &v) {
mMtx_c m;
MTXTrans(m, v.x, v.y, v.z);
*this += m;
}
void transM(f32 x, f32 y, f32 z) {
mMtx_c m;
MTXTrans(m, x, y, z);
*this += m;
}
void multVec(const mVec3_c &in, mVec3_c &out) const {
PSMTXMultVec(*this, in, out);
MTXMultVec(*this, in, out);
}
mVec3_c multVec(const mVec3_c &v) const {
mVec3_c ret = v;
MTXMultVec(*this, ret, ret);
return ret;
}
void multVecSR(const mVec3_c &in, mVec3_c &out) const {
MTXMultVecSR(*this, in, out);
}
mVec3_c multVecSR(const mVec3_c &v) const {
mVec3_c ret = v;
MTXMultVecSR(*this, ret, ret);
return ret;
}
mMtx_c &operator+=(const mMtx_c &rhs) {
PSMTXConcat(*this, rhs, *this);
MTXConcat(*this, rhs, *this);
return *this;
}
mVec3_c operator*(const mVec3_c &rhs) {
mVec3_c out;
PSMTXMultVec(*this, rhs, out);
MTXMultVec(*this, rhs, out);
return out;
}
void applyQuat(mQuat_c &quat) {
PSMTXMultVec(m, quat.v, quat.v);
MTXMultVec(m, quat.v, quat.v);
}
f32 baseLen(int i) const {
return m[0][i] * m[0][i] + m[1][i] * m[1][i] + m[2][i] * m[2][i];
}
void fn_802F1C40(s32, s32);
+13
View File
@@ -5,6 +5,7 @@
#include "common.h"
#include "egg/math/eggMath.h"
#include "egg/math/eggVector.h"
#include "nw4r/math/math_arithmetic.h"
#include "nw4r/math/math_types.h"
#include "nw4r/types_nw4r.h"
#include "rvl/MTX/vec.h"
@@ -247,6 +248,18 @@ public:
f32 inprodXZ(const mVec3_c &other) const {
return x * other.x + z * other.z;
}
f32 getSquareMag() const {
return VEC3LenSq(*this);
}
f32 absXZ() const {
return EGG::Math<f32>::sqrt(squareMagXZ());
}
s16 atan2sX_Z() const {
return cM::atan2s(x, z);
}
s16 atan2sY_XZ() const {
return cM::atan2s(-y, absXZ());
}
static mVec3_c Zero;
static mVec3_c Ex;
+4 -3
View File
@@ -15,6 +15,7 @@
#include "d/col/cc/d_cc_d.h"
#include "d/col/cc/d_cc_s.h"
#include "d/d_camera.h"
#include "d/d_jnt_col.h"
#include "d/d_sc_game.h"
#include "d/flag/sceneflag_manager.h"
#include "d/flag/storyflag_manager.h"
@@ -189,9 +190,9 @@ int dAcEsm_c::actorCreate() {
*parr++ = false;
}
static todoStruct00::InternalData data0 = {0, 100.f, nullptr};
static todoStruct00::InternalData data1 = {1, 130.f, &data0};
field_0x9f8.Set(this, &data1, &mMdl.getModel(), 1);
static Vec data0 = {0.f, 100.f, 0.f};
static dJntColData_c data1 = {0, 1, 0, 130.f, &data0};
mJntCol.init(this, &data1, &mMdl.getModel(), 1);
mLightInfo.SetColor(mColor(0xCC, 0xFF, 0xFF, 0xFF));
mLightInfo.SetScale(0.f);
+285
View File
@@ -0,0 +1,285 @@
#include "d/d_jnt_col.h"
#include "c/c_math.h"
#include "common.h"
#include "d/a/obj/d_a_obj_base.h"
#include "egg/math/eggMath.h"
#include "m/m_mtx.h"
#include "m/m_vec.h"
#include "nw4r/math/math_arithmetic.h"
#include "rvl/MTX/mtxvec.h"
dJntCol_c::dJntCol_c() : mData(nullptr), mpModel(nullptr), mpActor(nullptr), field_0xC(0), field_0x10(0) {}
int dJntCol_c::init(dAcObjBase_c *i_actorP, dJntColData_c const *i_jntColP, m3d::mdl_c *i_modelP, int param_3) {
mData = i_jntColP;
mpModel = i_modelP;
field_0xC = param_3;
field_0x10 = 0;
if (i_actorP) {
i_actorP->SetJntCol(this);
mpActor = i_actorP;
}
return 1;
}
void dJntCol_c::getAnmMtx(s32 jntId, mMtx_c *pOutMtx) const {
if (mpModel != nullptr) {
mpModel->getNodeWorldMtx(jntId, *pOutMtx);
} else {
*pOutMtx = mpActor->mWorldMtx;
}
}
void dJntCol_c::setNowLine(cM3dGLin *i_line, mVec3_c const *param_1, mAng3_c const *param_2, mVec3_c *param_3) {
mMtx_c mtx;
if (param_2 != nullptr) {
mtx.ZXYrotS(*param_2);
mtx.multVec(mVec3_c::Ez, *param_3);
} else {
*param_3 = mVec3_c::Ez;
}
mVec3_c start_pos = *param_1 - *param_3 * 500.0f;
mVec3_c end_pos = *param_1 + *param_3 * 500.0f;
i_line->Set(start_pos, end_pos);
}
int dJntCol_c::searchNearPos(cM3dGLin const *param_1, mVec3_c const *param_2, mVec3_c *param_3, int param_4) const {
mVec3_c const *pcVar9 = param_2;
const dJntColData_c *pcVar12 = mData;
mMtx_c mtx;
cM3dGSph sphere;
cM3dGCyl cylinder;
cM3dGLin line;
cM3dGPla plane;
mVec3_c local_19c, local_1a8;
mVec3_c local_1b4, local_1c0;
mVec3_c local_1cc, local_1d8;
mVec3_c local_1e4, local_1f0;
f32 mag;
bool bVar5 = false;
int rv = -1;
f32 max = EGG::Math<f32>::maxNumber();
f32 min = -10000000.0f;
for (int i = 0; i < field_0xC; i++, pcVar12++) {
if (checkPassNum(i) == 0 && (param_4 & (1 << pcVar12->mType))) {
getAnmMtx(pcVar12->mJntNum, &mtx);
mtx.multVec(pcVar12->getVec(0), local_1cc);
f32 radius = nw4r::math::FSqrt(mtx(0) * mtx(0) + mtx(4) * mtx(4) + mtx(8) * mtx(8)) * pcVar12->field_0x4;
if (pcVar12->field_0x0 == 0) {
sphere.Set(&local_1cc, radius);
int iVar6 = cM3d_Cross_LinSph_CrossPos(sphere, *param_1, &local_1b4, &local_1c0);
if (iVar6 != 0) {
if (iVar6 == 1) {
local_19c = local_1b4;
} else {
f32 dVar15 = local_1c0.squareDistance(param_1->GetStart());
f32 dVar16 = local_1b4.squareDistance(param_1->GetStart());
if (dVar16 < dVar15) {
local_19c = local_1b4;
} else {
local_19c = local_1c0;
}
}
} else {
local_1a8 = *param_2 - local_1cc;
local_1a8.normalize();
local_19c = local_1cc + local_1a8 * radius;
}
} else if (pcVar12->field_0x0 == 1) {
mtx.multVecSR(pcVar12->getVec(1), local_1a8);
local_1d8 = local_1cc + local_1a8;
int bVar13;
if (!cM::isZero(local_1a8.absXZ())) {
mtx.transS(local_1cc);
mtx.XrotM(cM::atan2s(-local_1a8.absXZ(), local_1a8.y));
mtx.YrotM(cM::atan2s(-local_1a8.x, local_1a8.z));
mtx.transM(-local_1cc.x, -local_1cc.y, -local_1cc.z);
mtx.multVec(local_1d8, local_1c0);
mtx.multVec(param_1->GetStart(), local_1e4);
mtx.multVec(param_1->GetEnd(), local_1f0);
line.Set(local_1e4, local_1f0);
bVar13 = true;
} else {
if (local_1d8.y < local_1cc.y) {
mVec3_c tmp = local_1cc;
local_1cc = local_1d8;
local_1d8 = tmp;
}
local_1c0 = local_1d8;
line.Set(param_1->GetStart(), param_1->GetEnd());
bVar13 = false;
}
cylinder.SetC(local_1cc, radius, nw4r::ut::Max<f32>(local_1c0.y - local_1cc.y, 0.f));
if (cM3d_Cross_CylLin(cylinder, line, &local_1b4, &local_1c0)) {
if (bVar13) {
mtx.inverse();
mtx.multVec(local_1b4, local_19c);
} else {
local_19c = local_1b4;
}
} else {
line.Set(local_1cc, local_1d8);
f32 dVar15 = cM3d_lineVsPosSuisenCross(line, *param_2, local_1b4);
local_1a8 = *param_2 - local_1b4;
mag = local_1a8.getSquareMag();
if (mag < 1e-04f) {
local_1b4 = line.GetStart() - line.GetEnd();
local_1c0 = param_1->GetStart() - param_1->GetEnd();
f32 inprod = local_1b4.dot(local_1c0);
if (inprod > 0.0f) {
local_19c = line.GetEnd();
} else if (inprod < 0.0f) {
local_19c = line.GetStart();
} else if (dVar15 < 0.5f) {
local_19c = line.GetStart();
} else {
local_19c = line.GetEnd();
}
} else {
if (dVar15 >= 0.0f && dVar15 <= 1.0f) {
local_19c = local_1b4 + (local_1a8 / nw4r::math::FSqrt(mag)) * radius;
} else {
local_1b4 = line.GetStart() - line.GetEnd();
local_1c0 = param_1->GetStart() - param_1->GetEnd();
f32 dVar14 = local_1b4.dot(local_1c0);
if (dVar14 > 0.0f) {
local_1b4 = line.GetEnd();
} else {
if (dVar14 < 0.0f) {
local_1b4 = line.GetStart();
} else {
if (dVar15 < 0.5f) {
local_1b4 = line.GetStart();
} else {
local_1b4 = line.GetEnd();
}
}
}
local_19c = local_1b4 + (local_1a8 / nw4r::math::FSqrt(mag)) * radius;
}
}
}
} else {
mtx.multVecSR(pcVar12->getVec(1), local_1a8);
plane.SetupNP0(local_1a8, local_1cc);
if (plane.CrossInfLin(*param_2, param_1->GetEnd(), local_19c)) {
if (!(local_1cc.distance(local_19c) < radius)) {
local_1a8 = local_19c - local_1cc;
local_1a8.normalize();
local_19c = local_1cc + local_1a8 * radius;
}
} else {
f32 pla = cM3d_SignedLenPlaAndPos(&plane, param_2);
local_1a8.normalize();
local_19c = *param_2 - local_1a8 * pla;
}
}
f32 cross = cM3d_lineVsPosSuisenCross(*param_1, local_19c, &local_1b4);
f32 dVar16 = local_19c.squareDistance(local_1b4);
if (dVar16 < 1e-04f) {
if (!bVar5 || min < cross) {
min = cross;
*param_3 = local_19c;
rv = i;
bVar5 = TRUE;
}
} else {
if (!bVar5 && (max >= dVar16)) {
max = dVar16;
*param_3 = local_19c;
rv = i;
}
}
};
}
return rv;
}
int dJntCol_c::getArrowOffsetPosAndAngle(
mVec3_c const *param_1, mAng3_c const *param_2, mVec3_c *param_3, mVec3_c *param_4, bool param_5
) const {
cM3dGLin acStack_34;
mVec3_c cStack_40;
setNowLine(&acStack_34, param_1, param_2, &cStack_40);
mVec3_c cStack_4c;
int iVar1 = searchNearPos(&acStack_34, param_1, &cStack_4c, param_5 ? 12 : 3);
if (iVar1 < 0) {
return -3;
}
const dJntColData_c *jntColData = &mData[iVar1];
if (jntColData->mType == 0) {
return -3;
}
if (jntColData->mType == 2) {
return -2;
}
mMtx_c mtx;
getAnmMtx(jntColData->mJntNum, &mtx);
mtx.inverse();
MTXMultVecSR(mtx, cStack_40, *param_4);
MTXMultVec(mtx, cStack_4c, *param_3);
return jntColData->mJntNum;
}
int dJntCol_c::getHitmarkPosAndAngle(
mVec3_c const *param_1, mAng3_c const *param_2, mVec3_c *param_3, mAng3_c *param_4, int param_5
) const {
cM3dGLin acStack_54;
mVec3_c cStack_60;
setNowLine(&acStack_54, param_1, param_2, &cStack_60);
int iVar3 = searchNearPos(&acStack_54, param_1, param_3, param_5);
if (iVar3 < 0) {
return -1;
}
const dJntColData_c *jntColData = &mData[iVar3];
mVec3_c cStack_6c;
mVec3_c local_78;
mMtx_c mtx;
getAnmMtx(jntColData->mJntNum, &mtx);
MTXMultVec(mtx, jntColData->getVec(0), cStack_6c);
if (jntColData->field_0x0 == 0) {
local_78 = *param_3 - cStack_6c;
} else if (jntColData->field_0x0 == 1) {
mVec3_c cStack_84;
mVec3_c cStack_90;
MTXMultVecSR(mtx, jntColData->getVec(1), cStack_84);
cStack_84 += cStack_6c;
cM3d_lineVsPosSuisenCross(cStack_6c, cStack_84, *param_3, &cStack_90);
local_78 = *param_3 - cStack_90;
if (local_78.getSquareMag() < 1e-04f) {
if (param_3->squareDistance(cStack_6c) < param_3->squareDistance(cStack_84)) {
local_78 = cStack_6c - cStack_84;
} else {
local_78 = cStack_84 - cStack_6c;
}
}
} else {
MTXMultVecSR(mtx, jntColData->getVec(1), local_78);
}
param_4->x = cM::atan2s(local_78.y, local_78.absXZ());
param_4->y = cM::atan2s(-local_78.x, -local_78.z);
param_4->z = 0;
return iVar3;
}
void dJntCol_c::setArrowPosAndAngle(
mVec3_c const *param_0, mVec3_c const *i_srcPos, int i_anmMtxIdx, mVec3_c *param_3, mAng3_c *i_arrowPosP
) {
mMtx_c mtx;
mVec3_c dstPos;
getAnmMtx(i_anmMtxIdx, &mtx);
MTXMultVecSR(mtx, *i_srcPos, dstPos);
i_arrowPosP->x = dstPos.atan2sY_XZ();
i_arrowPosP->y = dstPos.atan2sX_Z();
MTXMultVec(mtx, *param_0, *param_3);
}