diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 690e5281..2f25777f 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -2168,8 +2168,12 @@ m/m_pad.cpp: .bss start:0x805CB0B8 end:0x805CB1F8 m/m_quat.cpp: - .text start:0x802F2330 end:0x802F2918 align:16 - .sdata2 start:0x8057CE00 end:0x8057CE28 + .text start:0x802F2330 end:0x802F277C align:16 + .sdata2 start:0x8057CE00 end:0x8057CE18 + +m/m_sphere.cpp: + .text start:0x802F2780 end:0x802F2918 align:16 + .sdata2 start:0x8057CE18 end:0x8057CE28 m/m_thread.cpp: .text start:0x802F2920 end:0x802F2968 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index f1c3bfb6..41c3fdef 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -1136,8 +1136,8 @@ ActorObjectBase__putInODesert = .text:0x8002EB90; // type:function size:0xD8 drawModelType1__12dAcObjBase_cFPQ23m3d6smdl_c = .text:0x8002EC70; // type:function size:0x60 fn_8002ECD0__12dAcObjBase_cFPQ23m3d6smdl_ci = .text:0x8002ECD0; // type:function size:0x50 fn_8002ED20 = .text:0x8002ED20; // type:function size:0x88 -fn_8002edb0__12dAcObjBase_cFRQ23m3d15mShadowCircle_cRQ23m3d6smdl_cPC7mQuat_cllf = .text:0x8002EDB0; // type:function size:0x8C -drawShadow__12dAcObjBase_cFRQ23m3d15mShadowCircle_cPvRC6mMtx_cPC7mQuat_clllllf = .text:0x8002EE40; // type:function size:0xFC +fn_8002edb0__12dAcObjBase_cFRQ23m3d15mShadowCircle_cRQ23m3d6smdl_cPC9mSphere_cllf = .text:0x8002EDB0; // type:function size:0x8C +drawShadow__12dAcObjBase_cFRQ23m3d15mShadowCircle_cPvRC6mMtx_cPC9mSphere_clllllf = .text:0x8002EE40; // type:function size:0xFC create__12dAcObjBase_cFP12dAcObjBase_cQ28fProfile14PROFILE_NAME_eUlPC7mVec3_cPC7mAng3_cPC7mVec3_cUlUl = .text:0x8002EF40; // type:function size:0x24 fn_8002EF70 = .text:0x8002EF70; // type:function size:0x28 fn_8002EFA0 = .text:0x8002EFA0; // type:function size:0x50 @@ -3062,7 +3062,7 @@ fn_8006B800__16dEnemySwordMdl_cFUl = .text:0x8006B800; // type:function size:0x1 fn_8006B810 = .text:0x8006B810; // type:function size:0x5C fn_8006B870 = .text:0x8006B870; // type:function size:0x10 calc__16dEnemySwordMdl_cFRC6mMtx_cRC7mVec3_cb = .text:0x8006B880; // type:function size:0x2A8 -entry__16dEnemySwordMdl_cFP12dAcObjBase_cP15dShadowCircle_cP7mQuat_c = .text:0x8006BB30; // type:function size:0xA4 +entry__16dEnemySwordMdl_cFP12dAcObjBase_cP15dShadowCircle_cP9mSphere_c = .text:0x8006BB30; // type:function size:0xA4 doCreate__13dCameraBase_cFl = .text:0x8006BBE0; // type:function size:0x70 doRemove__13dCameraBase_cFv = .text:0x8006BC50; // type:function size:0x18 doExecute__13dCameraBase_cFv = .text:0x8006BC70; // type:function size:0xA8 @@ -17659,10 +17659,10 @@ __ct__Q23m3d14mShadowChild_cFv = .text:0x802EC300; // type:function size:0x2C remove__Q23m3d9mShadow_cFv = .text:0x802EC330; // type:function size:0xD4 reset__Q23m3d9mShadow_cFv = .text:0x802EC410; // type:function size:0x8C addCircle__Q23m3d9mShadow_cFPQ23m3d15mShadowCircle_cUlUl = .text:0x802EC4A0; // type:function size:0x1DC -drawMdl__Q23m3d9mShadow_cFPQ23m3d15mShadowCircle_cUlRQ23m3d9scnLeaf_cRC7mQuat_cR7mVec3_c6mColorUlf = .text:0x802EC680; // type:function size:0x9C -addMdlToCircle__Q23m3d9mShadow_cFPQ23m3d15mShadowCircle_cRQ23m3d9scnLeaf_cRC7mQuat_c = .text:0x802EC720; // type:function size:0x24 +drawMdl__Q23m3d9mShadow_cFPQ23m3d15mShadowCircle_cUlRQ23m3d9scnLeaf_cRC9mSphere_cR7mVec3_c6mColorUlf = .text:0x802EC680; // type:function size:0x9C +addMdlToCircle__Q23m3d9mShadow_cFPQ23m3d15mShadowCircle_cRQ23m3d9scnLeaf_cRC9mSphere_c = .text:0x802EC720; // type:function size:0x24 removeCircle__Q23m3d9mShadow_cFPQ23m3d15mShadowCircle_c = .text:0x802EC750; // type:function size:0x28 -drawTexObj__Q23m3d9mShadow_cFPQ23m3d15mShadowCircle_cUlPC9_GXTexObjRC6mMtx_cRC7mQuat_cR7mVec3_c6mColorUlf = .text:0x802EC780; // type:function size:0xA4 +drawTexObj__Q23m3d9mShadow_cFPQ23m3d15mShadowCircle_cUlPC9_GXTexObjRC6mMtx_cRC9mSphere_cR7mVec3_c6mColorUlf = .text:0x802EC780; // type:function size:0xA4 drawSub2__3m3dFPvUc = .text:0x802EC830; // type:function size:0x368 scope:local drawSub1__3m3dFPvUc = .text:0x802ECBA0; // type:function size:0x170 scope:local drawAllShadows__Q23m3d9mShadow_cFv = .text:0x802ECD10; // type:function size:0x3E4 @@ -17675,8 +17675,8 @@ destroy__Q23m3d9mShadow_cFv = .text:0x802ED2D0; // type:function size:0x60 __dt__Q23m3d14mShadowChild_cFv = .text:0x802ED330; // type:function size:0x9C create__Q23m3d14mShadowChild_cFUcPQ23EGG4Heap = .text:0x802ED3D0; // type:function size:0x7C set__Q23m3d14mShadowChild_cFRC7mVec3_cf6mColor = .text:0x802ED450; // type:function size:0x40 -addMdl__Q23m3d14mShadowChild_cFRQ23m3d9scnLeaf_cRC7mQuat_c = .text:0x802ED490; // type:function size:0x16C -setGeom__Q23m3d14mShadowChild_cFPC9_GXTexObjRC6mMtx_cRC7mQuat_c = .text:0x802ED600; // type:function size:0xF8 +addMdl__Q23m3d14mShadowChild_cFRQ23m3d9scnLeaf_cRC9mSphere_c = .text:0x802ED490; // type:function size:0x16C +setGeom__Q23m3d14mShadowChild_cFPC9_GXTexObjRC6mMtx_cRC9mSphere_c = .text:0x802ED600; // type:function size:0xF8 updateMtx__Q23m3d14mShadowChild_cFv = .text:0x802ED700; // type:function size:0x148 drawMdl__Q23m3d14mShadowChild_cFv = .text:0x802ED850; // type:function size:0x24C draw__Q23m3d14mShadowChild_cFv = .text:0x802EDAA0; // type:function size:0x108 @@ -17860,9 +17860,9 @@ __ct__Q24mPad19PadAdditionalData_tFv = .text:0x802F22C0; // type:function size:0 __dt__Q24mPad19PadAdditionalData_tFv = .text:0x802F22D0; // type:function size:0x40 scope:weak __arraydtor$4439 = .text:0x802F2310; // type:function size:0x1C scope:local Set__7mQuat_cFRC7mVec3_cRC7mVec3_c = .text:0x802F2330; // type:function size:0x120 -fn_802F2450__7mQuat_cFRC7mVec3_cRC7mVec3_cf = .text:0x802F2450; // type:function size:0x18C -fn_802F25E0 = .text:0x802F25E0; // type:function size:0x19C -fn_802F2780__7mQuat_cFRC7mQuat_c = .text:0x802F2780; // type:function size:0x198 +slerp__7mQuat_cFRC7mVec3_cRC7mVec3_cf = .text:0x802F2450; // type:function size:0x18C +slerpTo__7mQuat_cFRC7mVec3_cRC7mVec3_cf = .text:0x802F25E0; // type:function size:0x19C +merge__9mSphere_cFRC9mSphere_c = .text:0x802F2780; // type:function size:0x198 registerThread__7mThreadFP8OSThreadPv = .text:0x802F2920; // type:function size:0x48 createProjectionXZ__7mVec3_cFRC7mAng3_cf = .text:0x802F2970; // type:function size:0x110 fromXY__7mVec3_cFRC4mAngRC4mAngf = .text:0x802F2A80; // type:function size:0xF0 @@ -42681,7 +42681,7 @@ sCurrentObtainingItemOarcName = .sbss:0x80575918; // type:object size:0x4 data:4 @GUARD@create__9dAcTbox_cFv@bbUp@8 = .sbss:0x80575923; // type:object size:0x1 data:byte @GUARD@create__9dAcTbox_cFv@bbLo@9 = .sbss:0x80575924; // type:object size:0x1 data:byte @GUARD@create__9dAcTbox_cFv@bbUp@10 = .sbss:0x80575925; // type:object size:0x1 data:byte -@GUARD@draw__9dAcTbox_cFv@shadowDirs = .sbss:0x80575926; // type:object size:0x1 data:byte +@GUARD@draw__9dAcTbox_cFv@shadowSphs = .sbss:0x80575926; // type:object size:0x1 data:byte @GUARD@checkIsClear__9dAcTbox_cCFv@offsets = .sbss:0x80575927; // type:object size:0x1 data:byte lbl_80575928 = .sbss:0x80575928; // type:object size:0x8 data:byte sInstance__12dTgMassObj_c = .sbss:0x80575930; // type:object size:0x4 data:4byte diff --git a/configure.py b/configure.py index 06b43cc1..e7616299 100644 --- a/configure.py +++ b/configure.py @@ -897,9 +897,9 @@ config.libs = [ Object(NonMatching, "m/m_frustum.cpp"), Object(Matching, "m/m_heap.cpp"), Object(NonMatching, "m/m_mtx.cpp"), - Object(Matching, "m/m_pad.cpp"), - # probably two files due to sdata2 float duplication and gap - Object(NonMatching, "m/m_quat.cpp"), + Object(Matching, "m/m_pad.cpp"), + Object(Matching, "m/m_quat.cpp"), + Object(NonMatching, "m/m_sphere.cpp"), Object(Matching, "m/m_thread.cpp"), Object(NonMatching, "m/m_vec.cpp"), Object(NonMatching, "m/m_video.cpp"), diff --git a/include/d/a/d_a_salbage_obj.h b/include/d/a/d_a_salbage_obj.h index 70b1d082..85c690cd 100644 --- a/include/d/a/d_a_salbage_obj.h +++ b/include/d/a/d_a_salbage_obj.h @@ -9,7 +9,7 @@ #include "d/d_shadow.h" #include "m/m3d/m_smdl.h" #include "m/m_mtx.h" -#include "m/m_quat.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "s/s_State.hpp" #include "toBeSorted/dowsing_target.h" @@ -169,7 +169,7 @@ protected: /* 0x334 */ m3d::smdl_c *mpMdl; /* 0x338 */ dShadowCircle_c mShadow; - /* 0x340 */ mQuat_c mShadowRot; + /* 0x340 */ mSphere_c mShadowSph; /* 0x350 */ dBgS_AcchCir mBgAcchCir; /* 0x3AC */ dBgS_ObjAcch mBgObjAcch; /* 0x75C */ dCcD_Cyl mCcCyl; diff --git a/include/d/a/obj/d_a_obj_amber.h b/include/d/a/obj/d_a_obj_amber.h index 02dc8b07..19f48f7e 100644 --- a/include/d/a/obj/d_a_obj_amber.h +++ b/include/d/a/obj/d_a_obj_amber.h @@ -4,7 +4,7 @@ #include "d/a/obj/d_a_obj_base.h" #include "d/d_shadow.h" #include "m/m3d/m_smdl.h" -#include "m/m_quat.h" +#include "m/m_sphere.h" #include "m/m_vec.h" class dAcOAmber_c : public dAcObjBase_c { @@ -24,7 +24,7 @@ private: /* 0x34C */ dShadowCircle_c mShadowCircle; /* 0x354 */ mVec3_c mMin; /* 0x360 */ mVec3_c mMax; - /* 0x36C */ mQuat_c mShadowRot; + /* 0x36C */ mSphere_c mShadowSph; /* 0x37C */ f32 field_0x37c; }; diff --git a/include/d/a/obj/d_a_obj_base.h b/include/d/a/obj/d_a_obj_base.h index d82181ef..a72d3ea6 100644 --- a/include/d/a/obj/d_a_obj_base.h +++ b/include/d/a/obj/d_a_obj_base.h @@ -220,9 +220,9 @@ public: // Disabling make Lava and other objects Disappear void drawModel2(); void fn_8002ed20(); - void fn_8002edb0(m3d::mShadowCircle_c &shadow, m3d::smdl_c &smdl, const mQuat_c *rot, s32, s32, f32); + void fn_8002edb0(m3d::mShadowCircle_c &shadow, m3d::smdl_c &smdl, const mSphere_c *sph, s32, s32, f32); void drawShadow( - m3d::mShadowCircle_c &shadow, void *, const mMtx_c &mtx, const mQuat_c *rot, s32, s32, s32, s32, s32, f32 + m3d::mShadowCircle_c &shadow, void *, const mMtx_c &mtx, const mSphere_c *sph, s32, s32, s32, s32, s32, f32 ); void createChildAttached( fProfile::PROFILE_NAME_e actorId, u32 params1, mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, u32 params2, diff --git a/include/d/a/obj/d_a_obj_girahim_foot.h b/include/d/a/obj/d_a_obj_girahim_foot.h index 55fab69f..ab85daa5 100644 --- a/include/d/a/obj/d_a_obj_girahim_foot.h +++ b/include/d/a/obj/d_a_obj_girahim_foot.h @@ -27,7 +27,7 @@ private: /* 0x334 */ m3d::smdl_c mMdl; /* 0x350 */ dShadowCircle_c mShadow; /* 0x358 */ STATE_MGR_DECLARE(dAcOgirahimFoot_c); - /* 0x394 */ bool field_0x394; + /* 0x394 */ u8 field_0x394; }; #endif diff --git a/include/egg/geom/eggSphere.h b/include/egg/geom/eggSphere.h new file mode 100644 index 00000000..4c0ec610 --- /dev/null +++ b/include/egg/geom/eggSphere.h @@ -0,0 +1,21 @@ +#ifndef EGG_SPHERE_H +#define EGG_SPHERE_H + +#include "egg/math/eggVector.h" + +namespace EGG { + +class Sphere3f { +public: + Sphere3f() {} + ~Sphere3f() {} + + Sphere3f(const Vector3f ¢er, f32 radius) : mCenter(center), mRadius(radius) {} + + Vector3f mCenter; + f32 mRadius; +}; + +} // namespace EGG + +#endif diff --git a/include/m/m3d/m_shadow.h b/include/m/m3d/m_shadow.h index 963d9f2c..c49c4740 100644 --- a/include/m/m3d/m_shadow.h +++ b/include/m/m3d/m_shadow.h @@ -6,9 +6,8 @@ #include "m/m3d/m_proc.h" #include "m/m_color.h" #include "m/m_frustum.h" -#include "m/m_heap.h" #include "m/m_mtx.h" -#include "m/m_quat.h" +#include "m/m_sphere.h" #include "m/m_vec.h" namespace m3d { @@ -55,19 +54,19 @@ public: bool create(u8, EGG::Heap *); void set(const mVec3_c &pos, f32 dist, mColor color); - bool setGeom(const GXTexObj *texObj, const mMtx_c &mtx, const mQuat_c &quat); + bool setGeom(const GXTexObj *texObj, const mMtx_c &mtx, const mSphere_c &sph); void draw(); void updateMtx(); void drawMdl(); - bool addMdl(scnLeaf_c &mdl, const mQuat_c &quat); + bool addMdl(scnLeaf_c &mdl, const mSphere_c &sph); void set0x154(UNKWORD arg) { field_0x154 = arg; } - const mQuat_c &GetQuat() const { - return mQuat; + const mSphere_c &GetBoundSph() const { + return mBoundSph; } const mVec3_c &GetPosition() const { return mPositionMaybe; @@ -92,7 +91,7 @@ private: /* 0x014 */ u32 mPriorityMaybe; /* 0x018 */ GXTexObj mTexObj; /* 0x038 */ mColor mShadowColor; - /* 0x03C */ mQuat_c mQuat; + /* 0x03C */ mSphere_c mBoundSph; /* 0x04C */ mFrustum_c mFrustum; /* 0x13C */ f32 field_0x13C; /* 0x140 */ scnLeaf_c **mpLeaves; @@ -143,15 +142,15 @@ public: virtual void drawOpa() override; bool drawMdl( - mShadowCircle_c *circle, u32 priority, scnLeaf_c &mdl, const mQuat_c &quat, mVec3_c &pos, mColor color, + mShadowCircle_c *circle, u32 priority, scnLeaf_c &mdl, const mSphere_c &sph, mVec3_c &pos, mColor color, u32 param9, f32 dist ); bool drawTexObj( - mShadowCircle_c *circle, u32 priority, const GXTexObj *texObj, const mMtx_c &mtx, const mQuat_c &quat, + mShadowCircle_c *circle, u32 priority, const GXTexObj *texObj, const mMtx_c &mtx, const mSphere_c &sph, mVec3_c &pos, mColor color, u32 param9, f32 dist ); - bool addMdlToCircle(mShadowCircle_c *circle, scnLeaf_c &mdl, const mQuat_c &quat); + bool addMdlToCircle(mShadowCircle_c *circle, scnLeaf_c &mdl, const mSphere_c &sph); void beforeDraw(); void draw(const mMtx_c &, u32); diff --git a/include/m/m_quat.h b/include/m/m_quat.h index 5393e0e7..a17aa88f 100644 --- a/include/m/m_quat.h +++ b/include/m/m_quat.h @@ -6,6 +6,8 @@ class mQuat_c : public EGG::Quatf { public: + using EGG::Quatf::slerpTo; + mQuat_c() {} mQuat_c(f32 x, f32 y, f32 z, f32 w) : EGG::Quatf(w, x, y, z) {} mQuat_c(const mQuat_c &other) : EGG::Quatf(other.w, other.v) {} @@ -23,9 +25,9 @@ public: return *this; } - bool Set(const mVec3_c &, const mVec3_c &); - void fn_802F2780(const mQuat_c &other); - bool fn_802F2450(const mVec3_c &, const mVec3_c &, f32); + bool Set(const mVec3_c &from, const mVec3_c &to); + bool slerp(const mVec3_c &from, const mVec3_c &to, f32 interp); + bool slerpTo(const mVec3_c &from, const mVec3_c &to, f32 maxStep); }; #endif diff --git a/include/m/m_sphere.h b/include/m/m_sphere.h new file mode 100644 index 00000000..d62c2442 --- /dev/null +++ b/include/m/m_sphere.h @@ -0,0 +1,42 @@ +#ifndef M_SPHERE_H +#define M_SPHERE_H + +#include "egg/geom/eggSphere.h" +#include "egg/math/eggMath.h" +#include "egg/math/eggVector.h" +#include "m/m_vec.h" + +class mSphere_c : public EGG::Sphere3f { +public: + mSphere_c() {} + mSphere_c(const mVec3_c ¢er, f32 radius) : EGG::Sphere3f(center, radius) {} + mSphere_c(const mSphere_c &other) : EGG::Sphere3f(other.mCenter, other.mRadius) {} + + mSphere_c &operator=(const mSphere_c &r) { + mCenter.x = r.mCenter.x; + mCenter.y = r.mCenter.y; + mCenter.z = r.mCenter.z; + mRadius = r.mRadius; + return *this; + } + + void set(const mVec3_c ¢er, f32 radius) { + mCenter = center; + mRadius = radius; + } + + bool isZero() { + return std::fabs(mRadius) <= EGG::Math::epsilon(); + } + + const mVec3_c &getCenter() const { + return static_cast(mCenter); + } + f32 getRadius() const { + return mRadius; + } + + mSphere_c &merge(const mSphere_c &); +}; + +#endif diff --git a/include/m/types_m.h b/include/m/types_m.h index 6da5f4e0..d99ea479 100644 --- a/include/m/types_m.h +++ b/include/m/types_m.h @@ -20,6 +20,7 @@ struct mAng; class mAng3_c; class mVec3_c; class mFrustum_c; +class mSphere_c; namespace m2d { class Layout_c; diff --git a/include/toBeSorted/d_enemy_sword_mdl.h b/include/toBeSorted/d_enemy_sword_mdl.h index fcbe5c07..28fea0f0 100644 --- a/include/toBeSorted/d_enemy_sword_mdl.h +++ b/include/toBeSorted/d_enemy_sword_mdl.h @@ -10,7 +10,7 @@ #include "m/m_allocator.h" #include "m/m_angle.h" #include "m/m_mtx.h" -#include "m/m_quat.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "nw4r/types_nw4r.h" #include "toBeSorted/d_sword_swing_effect_mgr.h" @@ -53,7 +53,7 @@ public: mVec3_c v1 = mVec3_c(angle.sin(), 0.0f, angle.cos()); calc(mtx, v1, mass); } - bool entry(dAcObjBase_c *obj, dShadowCircle_c *shadow, mQuat_c *quat); + bool entry(dAcObjBase_c *obj, dShadowCircle_c *shadow, mSphere_c *sph); void enableAttack(); void fn_8006B660(UNKWORD, UNKWORD, UNKWORD, UNKWORD, UNKWORD, UNKWORD, UNKWORD, UNKWORD, UNKWORD, f32); diff --git a/src/REL/d/a/e/d_a_e_ks.cpp b/src/REL/d/a/e/d_a_e_ks.cpp index e35e6123..fc397e1c 100644 --- a/src/REL/d/a/e/d_a_e_ks.cpp +++ b/src/REL/d/a/e/d_a_e_ks.cpp @@ -31,7 +31,6 @@ #include "m/m_angle.h" #include "m/m_color.h" #include "m/m_mtx.h" -#include "m/m_quat.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resanmtexpat.h" #include "nw4r/g3d/res/g3d_resfile.h" @@ -111,6 +110,10 @@ struct dAcEKs_HIO_c { s32 _weird_zero = 0; return _0x04; } + const s32 getZero1() const { + s32 _weird_zero = 0; + return _0x04; + } static const dAcEKs_HIO_c sInstance; }; const dAcEKs_HIO_c dAcEKs_HIO_c::sInstance = { @@ -1748,13 +1751,13 @@ int dAcEKs_c::draw() { if (!isState(StateID_Wait)) { field_0xD18 = mPosition.y - mAcch.GetGroundH(); - // I hate this xD - mQuat_c shadowRot( - mVec3_c(0.f + dAcEKs_HIO_c::sInstance.getZero(), 5, 0.f + dAcEKs_HIO_c::sInstance.getZero()), - 50.f + dAcEKs_HIO_c::sInstance.getZero() + + mSphere_c sph( + mVec3_c(0.f + dAcEKs_HIO_c::sInstance.getZero(), 5.0f, 0.f + dAcEKs_HIO_c::sInstance.getZero()), + 50.f + dAcEKs_HIO_c::sInstance.getZero1() ); field_0xAE4.transS(mPosition); - drawShadow(mShadow, nullptr, field_0xAE4, &shadowRot, -1, -1, -1, -1, -1, field_0xD18); + drawShadow(mShadow, nullptr, field_0xAE4, &sph, -1, -1, -1, -1, -1, field_0xD18); } return SUCCEEDED; diff --git a/src/REL/d/a/e/d_a_e_remly.cpp b/src/REL/d/a/e/d_a_e_remly.cpp index 5df1fc7d..ad4cfdbd 100644 --- a/src/REL/d/a/e/d_a_e_remly.cpp +++ b/src/REL/d/a/e/d_a_e_remly.cpp @@ -33,7 +33,7 @@ #include "m/m3d/m_smdl.h" #include "m/m_angle.h" #include "m/m_mtx.h" -#include "m/m_quat.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resanmtexpat.h" #include "nw4r/g3d/res/g3d_resfile.h" @@ -577,9 +577,8 @@ int dAcEremly_c::draw() { m3d::smdl_c &mdl = mMdl.getModel(); drawModelType1(&mdl); - // elp - static mQuat_c shadow(0.f, getValue0(), 0.f, _weird_zero + 290.f); - fn_8002edb0(mShadow, mdl, &shadow, -1, -1, mPosition.y - mAcch.GetGroundH()); + static mSphere_c sph(mVec3_c(0.f, getValue0(), 0.f), _weird_zero + 290.f); + fn_8002edb0(mShadow, mdl, &sph, -1, -1, mPosition.y - mAcch.GetGroundH()); return SUCCEEDED; } diff --git a/src/REL/d/a/e/d_a_e_sm.cpp b/src/REL/d/a/e/d_a_e_sm.cpp index e7d89d7d..41f43331 100644 --- a/src/REL/d/a/e/d_a_e_sm.cpp +++ b/src/REL/d/a/e/d_a_e_sm.cpp @@ -28,7 +28,6 @@ #include "m/m_angle.h" #include "m/m_color.h" #include "m/m_mtx.h" -#include "m/m_quat.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resanmclr.h" #include "nw4r/g3d/res/g3d_resanmtexpat.h" @@ -725,8 +724,8 @@ int dAcEsm_c::draw() { } s8 var = 0; - mQuat_c q(mVec3_c(0.f, 50.f, 0.f), mScale.x * (var + 240.f)); - drawShadow(mShadowCircle, nullptr, mWorldMtx, &q, -1, -1, -1, -1, -1, mPosition.y - mObjAcch.GetGroundH()); + mSphere_c sph(mVec3_c(0.f, 50.f, 0.f), mScale.x * (var + 240.f)); + drawShadow(mShadowCircle, nullptr, mWorldMtx, &sph, -1, -1, -1, -1, -1, mPosition.y - mObjAcch.GetGroundH()); return SUCCEEDED; } diff --git a/src/REL/d/a/obj/d_a_obj_amber.cpp b/src/REL/d/a/obj/d_a_obj_amber.cpp index cf3cbd16..33ff845a 100644 --- a/src/REL/d/a/obj/d_a_obj_amber.cpp +++ b/src/REL/d/a/obj/d_a_obj_amber.cpp @@ -3,7 +3,6 @@ #include "d/a/obj/d_a_obj_base.h" #include "d/col/bg/d_bg_s_gnd_chk.h" #include "f/f_base.h" -#include "m/m_quat.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resfile.h" #include "nw4r/g3d/res/g3d_resmdl.h" @@ -45,8 +44,8 @@ int dAcOAmber_c::actorPostCreate() { } mMdl.getBounds(&mMin, &mMax); mBoundingBox.Set(mMin, mMax); - mShadowRot.v = (mMin + mMax) * 0.5f; - mShadowRot.w = ((mMax - mMin) * 0.5f).mag(); + mShadowSph.mCenter = (mMin + mMax) * 0.5f; + mShadowSph.mRadius = ((mMax - mMin) * 0.5f).mag(); updateMatrix(); mMdl.setLocalMtx(mWorldMtx); mVec3_c chkPos = mPosition + mVec3_c::Ey * mMax.y; @@ -62,7 +61,7 @@ int dAcOAmber_c::actorPostCreate() { int dAcOAmber_c::draw() { drawModelType1(&mMdl); if (field_0x37c != 1.0e+9f) { - drawShadow(mShadowCircle, nullptr, mWorldMtx, &mShadowRot, -1, -1, -1, -1, -1, field_0x37c); + drawShadow(mShadowCircle, nullptr, mWorldMtx, &mShadowSph, -1, -1, -1, -1, -1, field_0x37c); } return SUCCEEDED; } diff --git a/src/REL/d/a/obj/d_a_obj_barrel.cpp b/src/REL/d/a/obj/d_a_obj_barrel.cpp index 9400a0d0..79fb7ce2 100644 --- a/src/REL/d/a/obj/d_a_obj_barrel.cpp +++ b/src/REL/d/a/obj/d_a_obj_barrel.cpp @@ -28,6 +28,7 @@ #include "m/m_angle.h" #include "m/m_mtx.h" #include "m/m_quat.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resfile.h" #include "nw4r/math/math_arithmetic.h" @@ -391,10 +392,10 @@ void dAcOBarrel_c::doInteraction(s32 i) { int dAcOBarrel_c::draw() { drawModelType1(&mMdl); - static mQuat_c shadow(0.f, 50.f, 0.f, 80.f); + static mSphere_c sph(mVec3_c(0.f, 50.f, 0.f), 80.f); if (mYOffset >= 0.f) { - drawShadow(mShadow, nullptr, mWorldMtx, &shadow, -1, -1, -1, -1, -1, mPosition.y - mObjAcch.GetGroundH()); + drawShadow(mShadow, nullptr, mWorldMtx, &sph, -1, -1, -1, -1, -1, mPosition.y - mObjAcch.GetGroundH()); } return SUCCEEDED; diff --git a/src/REL/d/a/obj/d_a_obj_chair.cpp b/src/REL/d/a/obj/d_a_obj_chair.cpp index e5372827..b618aa17 100644 --- a/src/REL/d/a/obj/d_a_obj_chair.cpp +++ b/src/REL/d/a/obj/d_a_obj_chair.cpp @@ -1,7 +1,6 @@ #include "d/a/obj/d_a_obj_chair.h" #include "common.h" -#include "d/a/d_a_base.h" #include "d/a/d_a_item.h" #include "d/a/d_a_player.h" #include "d/a/obj/d_a_obj_base.h" @@ -11,7 +10,7 @@ #include "d/flag/sceneflag_manager.h" #include "f/f_base.h" #include "m/m_angle.h" -#include "m/m_quat.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resfile.h" #include "nw4r/math/math_arithmetic.h" @@ -189,8 +188,8 @@ int dAcOChair_c::actorExecute() { int dAcOChair_c::draw() { if (!isBench()) { drawModelType1(&mMdl); - static mQuat_c shadowRot(0.f, 40.f, 0.f, 80.f); - drawShadow(mShadow, nullptr, mWorldMtx, &shadowRot, -1, -1, -1, -1, -1, 0.f); + static mSphere_c sph(mVec3_c(0.f, 40.f, 0.f), 80.f); + drawShadow(mShadow, nullptr, mWorldMtx, &sph, -1, -1, -1, -1, -1, 0.f); } return SUCCEEDED; } diff --git a/src/REL/d/a/obj/d_a_obj_flying_clawshot_target.cpp b/src/REL/d/a/obj/d_a_obj_flying_clawshot_target.cpp index 59c63009..33b6a7dd 100644 --- a/src/REL/d/a/obj/d_a_obj_flying_clawshot_target.cpp +++ b/src/REL/d/a/obj/d_a_obj_flying_clawshot_target.cpp @@ -101,7 +101,7 @@ int dAcOFlyingClawshotTarget_c::actorExecute() { f32 f = 0.16f; mQuat_c q; - if (!q.fn_802F2450(v2, vec, f)) { + if (!q.slerp(v2, vec, f)) { q.set(1.f, 0.f, 0.f, 0.f); } @@ -116,7 +116,7 @@ int dAcOFlyingClawshotTarget_c::actorExecute() { f32 f = 0.1f; mQuat_c q; - if (!q.fn_802F2450(v2, vec, f)) { + if (!q.slerp(v2, vec, f)) { q.set(1.f, 0.f, 0.f, 0.f); } diff --git a/src/REL/d/a/obj/d_a_obj_girahim_foot.cpp b/src/REL/d/a/obj/d_a_obj_girahim_foot.cpp index ab3bcbc2..b0023024 100644 --- a/src/REL/d/a/obj/d_a_obj_girahim_foot.cpp +++ b/src/REL/d/a/obj/d_a_obj_girahim_foot.cpp @@ -3,7 +3,7 @@ #include "common.h" #include "d/a/obj/d_a_obj_base.h" #include "f/f_base.h" -#include "m/m_angle.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resfile.h" #include "s/s_State.hpp" @@ -51,8 +51,8 @@ int dAcOgirahimFoot_c::doDelete() { int dAcOgirahimFoot_c::draw() { if (*mStateMgr.getStateID() == StateID_Appear) { drawModelType1(&mMdl); - static mQuat_c rot(0.0f, 25.0f, 0.0f, 200.0f); - fn_8002edb0(mShadow, mMdl, &rot, -1, -1, 0.0f); + static mSphere_c sph(mVec3_c(0.0f, 25.0f, 0.0f), 200.0f); + fn_8002edb0(mShadow, mMdl, &sph, -1, -1, 0.0f); } return SUCCEEDED; } diff --git a/src/REL/d/a/obj/d_a_obj_grave.cpp b/src/REL/d/a/obj/d_a_obj_grave.cpp index b840bcf6..437c83a4 100644 --- a/src/REL/d/a/obj/d_a_obj_grave.cpp +++ b/src/REL/d/a/obj/d_a_obj_grave.cpp @@ -13,6 +13,7 @@ #include "d/flag/sceneflag_manager.h" #include "d/snd/d_snd_wzsound.h" #include "f/f_base.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "m/types_m.h" #include "nw4r/g3d/res/g3d_resanmclr.h" @@ -29,7 +30,11 @@ STATE_DEFINE(dAcOGrave_c, Move); dCcD_SrcUnk dAcOGrave_c::sUnkSrc = { {/* mObjAt */ {0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0}, /* mObjTg */ - {~(AT_TYPE_BUGNET | AT_TYPE_BEETLE | AT_TYPE_GLITTERING_SPORES | AT_TYPE_0x8000 | AT_TYPE_WIND), 0x111, {0, 6, 0x407}, 0, 0}, + {~(AT_TYPE_BUGNET | AT_TYPE_BEETLE | AT_TYPE_GLITTERING_SPORES | AT_TYPE_0x8000 | AT_TYPE_WIND), + 0x111, + {0, 6, 0x407}, + 0, + 0}, /* mObjCo */ {0}}, {-65.0f, 0.0f, -25.0f, 65.0f, 156.0f, 25.0f}, }; @@ -142,8 +147,8 @@ int dAcOGrave_c::actorExecute() { int dAcOGrave_c::draw() { drawModelType1(&mMdl); - static mQuat_c shadowRot(0.f, 50.f, 0.f, 50.f); - drawShadow(mShadow, nullptr, mWorldMtx, &shadowRot, -1, -1, -1, -1, -1, 0.f); + static mSphere_c sph(mVec3_c(0.f, 50.f, 0.f), 50.f); + drawShadow(mShadow, nullptr, mWorldMtx, &sph, -1, -1, -1, -1, -1, 0.f); return SUCCEEDED; } diff --git a/src/REL/d/a/obj/d_a_obj_ivy_rope.cpp b/src/REL/d/a/obj/d_a_obj_ivy_rope.cpp index b1976feb..cfbe3258 100644 --- a/src/REL/d/a/obj/d_a_obj_ivy_rope.cpp +++ b/src/REL/d/a/obj/d_a_obj_ivy_rope.cpp @@ -12,10 +12,9 @@ #include "d/flag/sceneflag_manager.h" #include "d/snd/d_snd_wzsound.h" #include "egg/math/eggMath.h" -#include "m/m3d/m3d.h" #include "m/m_angle.h" #include "m/m_mtx.h" -#include "m/m_quat.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "nw4r/math/math_arithmetic.h" #include "nw4r/math/math_triangular.h" @@ -912,7 +911,7 @@ void dAcOivyRope_c::fn_256_D850() { } if (draw_shadow) { - static mQuat_c shadow_q = mQuat_c(0.f, 0.f, 0.f, 30.f); + static mSphere_c sph(mVec3_c(0.0f, 0.0f, 0.0f), 30.0f); if (mSubtype == 7) { // This section is just weird int idk; @@ -931,12 +930,12 @@ void dAcOivyRope_c::fn_256_D850() { } mMtx_c m; m.transS(field_0xF68); - drawShadow(mShadow, nullptr, m, &shadow_q, -1, idk, -1, -1, -1, val); + drawShadow(mShadow, nullptr, m, &sph, -1, idk, -1, -1, -1, val); } } else { mMtx_c m; m.transS(fn_256_D730(mSegmentCount - 1)); - drawShadow(mShadow, nullptr, m, &shadow_q, -1, -1, -1, -1, -1, 175.f); + drawShadow(mShadow, nullptr, m, &sph, -1, -1, -1, -1, -1, 175.f); } } } diff --git a/src/REL/d/a/obj/d_a_obj_junk_repairing.cpp b/src/REL/d/a/obj/d_a_obj_junk_repairing.cpp index 2eb060dc..72762c8f 100644 --- a/src/REL/d/a/obj/d_a_obj_junk_repairing.cpp +++ b/src/REL/d/a/obj/d_a_obj_junk_repairing.cpp @@ -1,6 +1,8 @@ #include "d/a/obj/d_a_obj_junk_repairing.h" #include "d/flag/storyflag_manager.h" +#include "m/m_sphere.h" +#include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resfile.h" SPECIAL_ACTOR_PROFILE(OBJ_JUNK_REPAIR, dAcOJunkRep_c, fProfile::OBJ_JUNK_REPAIR, 0x027B, 0, 3); @@ -57,8 +59,8 @@ int dAcOJunkRep_c::actorExecute() { int dAcOJunkRep_c::draw() { drawModelType1(mpModelToUse); - static mQuat_c rot(0.0f, 37.5f, 0.0f, 75.0f); - fn_8002edb0(mShadow, *mpModelToUse, &rot, -1, -1, sSomeFloat); + static mSphere_c sph(mVec3_c(0.0f, 37.5f, 0.0f), 75.0f); + fn_8002edb0(mShadow, *mpModelToUse, &sph, -1, -1, sSomeFloat); return SUCCEEDED; } diff --git a/src/REL/d/a/obj/d_a_obj_paint.cpp b/src/REL/d/a/obj/d_a_obj_paint.cpp index 883bfdf8..dc971d4d 100644 --- a/src/REL/d/a/obj/d_a_obj_paint.cpp +++ b/src/REL/d/a/obj/d_a_obj_paint.cpp @@ -6,7 +6,7 @@ #include "d/snd/d_snd_wzsound.h" #include "f/f_base.h" #include "m/m_mtx.h" -#include "m/m_quat.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resfile.h" #include "nw4r/g3d/res/g3d_resmdl.h" @@ -61,8 +61,8 @@ int dAcOpaint_c::actorExecute() { int dAcOpaint_c::draw() { drawModelType1(&mMdl); - static mQuat_c rot(0.0f, 0.0f, 0.0f, 100.0f); - fn_8002edb0(mShadow, mMdl, &rot, -1, -1, 0.0f); + static mSphere_c sph(mVec3_c(0.0f, 0.0f, 0.0f), 100.0f); + fn_8002edb0(mShadow, mMdl, &sph, -1, -1, 0.0f); return SUCCEEDED; } diff --git a/src/REL/d/a/obj/d_a_obj_tubo.cpp b/src/REL/d/a/obj/d_a_obj_tubo.cpp index 91607903..83a90f23 100644 --- a/src/REL/d/a/obj/d_a_obj_tubo.cpp +++ b/src/REL/d/a/obj/d_a_obj_tubo.cpp @@ -28,6 +28,7 @@ #include "m/m_angle.h" #include "m/m_mtx.h" #include "m/m_quat.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "nw4r/math/math_arithmetic.h" #include "rvl/MTX/mtxvec.h" @@ -201,10 +202,10 @@ void dAcOtubo_c::registerInEvent() { int dAcOtubo_c::draw() { drawModelType1(&mMdl); - static mQuat_c quat(0.f, 30.f, 0.f, 40.f); + static mSphere_c sph(mVec3_c(0.f, 30.f, 0.f), 40.f); if (mYOffset >= 0.f) { - drawShadow(mShdw, nullptr, mWorldMtx, &quat, -1, -1, -1, -1, -1, mPosition.y - mObjAcch.GetGroundH()); + drawShadow(mShdw, nullptr, mWorldMtx, &sph, -1, -1, -1, -1, -1, mPosition.y - mObjAcch.GetGroundH()); } return SUCCEEDED; } diff --git a/src/REL/d/a/obj/d_a_obj_tumble_weed.cpp b/src/REL/d/a/obj/d_a_obj_tumble_weed.cpp index 6d4f8062..1a42712d 100644 --- a/src/REL/d/a/obj/d_a_obj_tumble_weed.cpp +++ b/src/REL/d/a/obj/d_a_obj_tumble_weed.cpp @@ -17,6 +17,7 @@ #include "m/m_angle.h" #include "m/m_mtx.h" #include "m/m_quat.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "s/s_Math.h" #include "toBeSorted/d_emitter.h" @@ -154,9 +155,9 @@ int dAcOTumbleWeed_c::actorExecute() { int dAcOTumbleWeed_c::draw() { drawModelType1(&mMdl); - static mQuat_c shadowRot(0.f, 30.f, 0.f, 50.f); + static mSphere_c sph(mVec3_c(0.f, 30.f, 0.f), 50.f); if (0.f < mScale.x) { - drawShadow(mShdw, nullptr, mShadowMtx, &shadowRot, -1, -1, -1, -1, -1, mPosition.y - mObjAcch.GetGroundH()); + drawShadow(mShdw, nullptr, mShadowMtx, &sph, -1, -1, -1, -1, -1, mPosition.y - mObjAcch.GetGroundH()); } return SUCCEEDED; diff --git a/src/d/a/d_a_item.cpp b/src/d/a/d_a_item.cpp index 1606c315..dbd17943 100644 --- a/src/d/a/d_a_item.cpp +++ b/src/d/a/d_a_item.cpp @@ -1297,10 +1297,10 @@ int dAcItem_c::draw() { (mId == ITEM_STAMINA_FRUIT && getParams2Lower_shift1_0x7()) || isLightFruit() || (mItemFlags & 0x10) == 0) { /* nothing */ } else if (mMdlScaleType == 2) { - mQuat_c v(mVec3_c(0.0f, 0.0f, 0.0f), getItemFlagStruct(getItemId())->field_0x02); + mSphere_c v(mVec3_c(0.0f, 0.0f, 0.0f), getItemFlagStruct(getItemId())->field_0x02); drawShadow(mShdw, nullptr, mWorldMtx, &v, -1, -1, -1, -1, -1, field_0xD18); } else { - mQuat_c v( + mSphere_c v( mVec3_c(0.0f, field_0xCD8 * 0.5f * getItemFlagStruct(getItemId())->field_0x01, 0.0f), field_0xCD8 * getItemFlagStruct(getItemId())->field_0x02 ); diff --git a/src/d/a/d_a_salbage_obj.cpp b/src/d/a/d_a_salbage_obj.cpp index 6fef71f6..33c183ee 100644 --- a/src/d/a/d_a_salbage_obj.cpp +++ b/src/d/a/d_a_salbage_obj.cpp @@ -116,7 +116,7 @@ int dAcSalbageObj_c::preDraw() { int dAcSalbageObj_c::draw() { drawModelType1(mpMdl); - fn_8002edb0(mShadow, *mpMdl, &mShadowRot, -1, -1, field_0x900); + fn_8002edb0(mShadow, *mpMdl, &mShadowSph, -1, -1, field_0x900); return SUCCEEDED; } @@ -140,8 +140,7 @@ void dAcSalbageObj_c::executeInternal() { } void dAcSalbageObj_c::initSalbageObj() { - mShadowRot.v = mVec3_c(0.0f, 90.0f, 0.0f); - mShadowRot.w = 180.0f; + mShadowSph.set(mVec3_c(0.0f, 90.0f, 0.0f), 180.0f); mScale.set(1.0f, 1.0f, 1.0f); mBehavior = getFromParams(4, 0xF); mpSalvageIf = &mSalvageIf; diff --git a/src/d/a/obj/d_a_obj_bomb.cpp b/src/d/a/obj/d_a_obj_bomb.cpp index 2550062d..339548d5 100644 --- a/src/d/a/obj/d_a_obj_bomb.cpp +++ b/src/d/a/obj/d_a_obj_bomb.cpp @@ -29,7 +29,6 @@ #include "m/m_angle.h" #include "m/m_color.h" #include "m/m_mtx.h" -#include "m/m_quat.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resfile.h" #include "nw4r/g3d/res/g3d_resmdl.h" @@ -1249,10 +1248,10 @@ int dAcBomb_c::draw() { drawModelType1(&mMdl); - mQuat_c rot(0.0f, mScale.x * sHIO.getBombScale(), 0.0f, mScale.x * sHIO.getBombScale()); + mSphere_c sph(mVec3_c(0.0f, mScale.x * sHIO.getBombScale(), 0.0f), mScale.x * sHIO.getBombScale()); if (!isState(StateID_FlowerWait)) { - drawShadow(mShdw, nullptr, mWorldMtx, &rot, -1, -1, -1, -1, -1, mPosition.y - mAcch.GetGroundH()); + drawShadow(mShdw, nullptr, mWorldMtx, &sph, -1, -1, -1, -1, -1, mPosition.y - mAcch.GetGroundH()); } return SUCCEEDED; } diff --git a/src/d/a/obj/d_a_obj_boomerang.cpp b/src/d/a/obj/d_a_obj_boomerang.cpp index e1bb4ab2..ad220988 100644 --- a/src/d/a/obj/d_a_obj_boomerang.cpp +++ b/src/d/a/obj/d_a_obj_boomerang.cpp @@ -18,7 +18,7 @@ #include "m/m_color.h" #include "m/m_fader_base.h" #include "m/m_mtx.h" -#include "m/m_quat.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "nw4r/g3d/g3d_anmchr.h" #include "nw4r/g3d/res/g3d_resanmchr.h" @@ -544,9 +544,7 @@ int dAcBoomerang_c::actorExecute() { } if (field_0x8B1 == 0 && (mStateMgr.isState(StateID_Move) || mStateMgr.isState(StateID_MoveCancelWait))) { - mEff2.holdEffect( - PARTICLE_RESOURCE_ID_MAPPING_5_, player->getPosition(), nullptr, nullptr, nullptr, nullptr - ); + mEff2.holdEffect(PARTICLE_RESOURCE_ID_MAPPING_5_, player->getPosition(), nullptr, nullptr, nullptr, nullptr); } else { mEff2.remove(true); } @@ -570,8 +568,8 @@ int dAcBoomerang_c::draw() { drawModelType1(&mMdl); if (!mStateMgr.isState(StateID_Wait)) { mProc.entry(); - static mQuat_c shadow(mVec3_c::Zero, 50.f); - drawShadow(mShadow, nullptr, mWorldMtx, &shadow, -1, -1, -1, -1, -1, mPosition.y - mAcch.GetGroundH()); + static mSphere_c sph(mVec3_c::Zero, 50.f); + drawShadow(mShadow, nullptr, mWorldMtx, &sph, -1, -1, -1, -1, -1, mPosition.y - mAcch.GetGroundH()); } return SUCCEEDED; } diff --git a/src/d/a/obj/d_a_obj_fairy.cpp b/src/d/a/obj/d_a_obj_fairy.cpp index adf76ac8..7dd556e3 100644 --- a/src/d/a/obj/d_a_obj_fairy.cpp +++ b/src/d/a/obj/d_a_obj_fairy.cpp @@ -21,6 +21,7 @@ #include "f/f_base.h" #include "m/m3d/m_fanm.h" #include "m/m_mtx.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "nw4r/math/math_arithmetic.h" #include "s/s_Math.h" @@ -257,9 +258,9 @@ int dAcOFairy_c::draw() { drawModelType1(&mModel.getModel()); if (!isCuring()) { - static mQuat_c rot(0.0f, 0.0f, 0.0f, 10.0f); + static mSphere_c sph(mVec3_c(0.0f, 0.0f, 0.0f), 10.0f); f32 f = mObjAcch.GetGroundH(); - drawShadow(mShadow, nullptr, mWorldMtx, &rot, -1, -1, -1, -1, -1, mPosition.y - f); + drawShadow(mShadow, nullptr, mWorldMtx, &sph, -1, -1, -1, -1, -1, mPosition.y - f); } } diff --git a/src/d/a/obj/d_a_obj_tbox.cpp b/src/d/a/obj/d_a_obj_tbox.cpp index 7f219bc4..45ce812f 100644 --- a/src/d/a/obj/d_a_obj_tbox.cpp +++ b/src/d/a/obj/d_a_obj_tbox.cpp @@ -24,6 +24,7 @@ #include "m/m3d/m_fanm.h" #include "m/m3d/m_scnleaf.h" #include "m/m_mtx.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resanmchr.h" #include "nw4r/g3d/res/g3d_resanmtexpat.h" @@ -1511,14 +1512,14 @@ int dAcTbox_c::draw() { drawModelType1(&mOpenFxMdl); } - static mQuat_c shadowDirs[4] = { - mQuat_c(0.0f, 45.0f, 0.0f, 100.0f), - mQuat_c(0.0f, 25.0f, 0.0f, 80.0f), - mQuat_c(0.0f, 55.0f, 0.0f, 120.0f), - mQuat_c(0.0f, 45.0f, 0.0f, 100.0f), + static mSphere_c shadowSphs[4] = { + mSphere_c(mVec3_c(0.0f, 45.0f, 0.0f), 100.0f), + mSphere_c(mVec3_c(0.0f, 25.0f, 0.0f), 80.0f), + mSphere_c(mVec3_c(0.0f, 55.0f, 0.0f), 120.0f), + mSphere_c(mVec3_c(0.0f, 45.0f, 0.0f), 100.0f), }; - drawShadow(mShadowCircle, nullptr, mWorldMtx, &shadowDirs[mVariant], -1, -1, -1, -1, -1, 0.0f); + drawShadow(mShadowCircle, nullptr, mWorldMtx, &shadowSphs[mVariant], -1, -1, -1, -1, -1, 0.0f); return SUCCEEDED; } diff --git a/src/m/m3d/m_shadow.cpp b/src/m/m3d/m_shadow.cpp index 2cb88080..5ef73781 100644 --- a/src/m/m3d/m_shadow.cpp +++ b/src/m/m3d/m_shadow.cpp @@ -2,7 +2,7 @@ #include "c/c_math.h" #include "m/m_mtx.h" -#include "m/m_quat.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "nw4r/g3d/g3d_calcview.h" #include "nw4r/g3d/g3d_draw.h" @@ -186,7 +186,7 @@ bool mShadow_c::addCircle(mShadowCircle_c *circle, u32 priority, u32 isMdl) { } bool mShadow_c::drawMdl( - mShadowCircle_c *circle, u32 priority, scnLeaf_c &mdl, const mQuat_c &quat, mVec3_c &pos, mColor color, u32 param9, + mShadowCircle_c *circle, u32 priority, scnLeaf_c &mdl, const mSphere_c &sph, mVec3_c &pos, mColor color, u32 param9, f32 dist ) { if (!addCircle(circle, priority, 1)) { @@ -196,14 +196,14 @@ bool mShadow_c::drawMdl( mShadowChild_c *child = circle->mpChild; child->set(pos, dist, color); child->set0x154(param9); - return child->addMdl(mdl, quat); + return child->addMdl(mdl, sph); } -bool mShadow_c::addMdlToCircle(mShadowCircle_c *circle, scnLeaf_c &mdl, const mQuat_c &quat) { +bool mShadow_c::addMdlToCircle(mShadowCircle_c *circle, scnLeaf_c &mdl, const mSphere_c &sph) { if (circle->mpChild == nullptr) { return false; } - return circle->mpChild->addMdl(mdl, quat); + return circle->mpChild->addMdl(mdl, sph); } void mShadow_c::removeCircle(mShadowCircle_c *circle) { @@ -231,8 +231,8 @@ static GXColor sColors[] = { }; bool mShadow_c::drawTexObj( - mShadowCircle_c *circle, u32 priority, const GXTexObj *texObj, const mMtx_c &mtx, const mQuat_c &quat, mVec3_c &pos, - mColor color, u32 param9, f32 dist + mShadowCircle_c *circle, u32 priority, const GXTexObj *texObj, const mMtx_c &mtx, const mSphere_c &sph, + mVec3_c &pos, mColor color, u32 param9, f32 dist ) { if (!addCircle(circle, priority, 0)) { return false; @@ -241,7 +241,7 @@ bool mShadow_c::drawTexObj( mShadowChild_c *child = circle->mpChild; child->set(pos, dist, color); child->set0x154(param9); - return child->setGeom(texObj, mtx, quat); + return child->setGeom(texObj, mtx, sph); } static void drawSub2(void *data, u8 i) { @@ -478,7 +478,7 @@ void mShadowChild_c::set(const mVec3_c &pos, f32 dist, mColor color) { mShadowColor = color; } -bool mShadowChild_c::addMdl(scnLeaf_c &mdl, const mQuat_c &quat) { +bool mShadowChild_c::addMdl(scnLeaf_c &mdl, const mSphere_c &sph) { if (!(mNumLeaves < mMaxNumLeaves)) { return false; } @@ -490,21 +490,21 @@ bool mShadowChild_c::addMdl(scnLeaf_c &mdl, const mQuat_c &quat) { mtx.copyFrom(static_cast(mdl).mMtx); } - mQuat_c q = quat; - mtx.applyQuat(q); + mSphere_c tempSph = sph; + MTXMultVec(mtx, tempSph.mCenter, tempSph.mCenter); if (mNumLeaves == 0) { - mQuat = q; + mBoundSph = tempSph; } else { - mQuat.fn_802F2780(q); + mBoundSph.merge(tempSph); } mpLeaves[mNumLeaves++] = &mdl; return true; } -bool mShadowChild_c::setGeom(const GXTexObj *texObj, const mMtx_c &mtx, const mQuat_c &quat) { - mQuat = quat; - MTXMultVec(mtx.m, mQuat.v, mQuat.v); +bool mShadowChild_c::setGeom(const GXTexObj *texObj, const mMtx_c &mtx, const mSphere_c &sph) { + mBoundSph = sph; + MTXMultVec(mtx.m, mBoundSph.mCenter, mBoundSph.mCenter); if (texObj == nullptr) { mTexObj = *mShadow_c::sTexObj; } else { @@ -513,25 +513,18 @@ bool mShadowChild_c::setGeom(const GXTexObj *texObj, const mMtx_c &mtx, const mQ return true; } +// NONMATCHING void mShadowChild_c::updateMtx() { - // NONMATCHING - field_0x13C = mQuat.w; + field_0x13C = mBoundSph.getRadius(); - mVec3_c a(mQuat.v.x, mQuat.v.y, mQuat.v.z); - a += mPositionMaybe * GetOffset(); - - mVec3_c b(mQuat.v.x, mQuat.v.y, mQuat.v.z); - b -= mPositionMaybe * field_0x13C; - - const mVec3_c *up; - if (cM::isZero((a - b).squareMagXZ())) { - up = &mVec3_c::Ez; - } else { - up = &mVec3_c::Ey; - } + mVec3_c pos = mBoundSph.getCenter(); + pos -= (mPositionMaybe * GetOffset()); + mVec3_c target = mBoundSph.getCenter(); + target += (mPositionMaybe * mBoundSph.getRadius()); + f32 diff = target.squareDistanceToXZ(pos); mMtx_c mtx; - C_MTXLookAt(mtx.m, a, *up, b); + C_MTXLookAt(mtx, pos, cM::isZero(diff) ? mVec3_c::Ez : mVec3_c::Ey, target); f32 f = field_0x13C; mFrustum.set(f, -f, -f, f, f, f + GetOffset(), mtx, true); diff --git a/src/m/m_quat.cpp b/src/m/m_quat.cpp new file mode 100644 index 00000000..151dd7fc --- /dev/null +++ b/src/m/m_quat.cpp @@ -0,0 +1,62 @@ +#include "m/m_quat.h" + +#include "c/c_math.h" +#include "common.h" +#include "egg/math/eggMath.h" +#include "m/m_vec.h" +#include "nw4r/math/math_arithmetic.h" +#include "nw4r/ut/ut_algorithm.h" + +bool mQuat_c::Set(const mVec3_c &from, const mVec3_c &to) { + mVec3_c cross; + cross.x = (from.y * to.z) - (from.z * to.y); + cross.y = (from.z * to.x) - (from.x * to.z); + cross.z = (from.x * to.y) - (from.y * to.x); + f32 dot = (from.dot(to) + 1.0f) * 2.0f; + + if (dot < 0.0f) { + dot = 0.0f; + } + f32 f = nw4r::math::FSqrt(dot); + if (f <= EGG::Math::epsilon()) { + return false; + } + + f32 norm = (1.0f / f); + set(f * 0.5f, cross.x * norm, cross.y * norm, cross.z * norm); + return true; +} + +bool mQuat_c::slerp(const mVec3_c &from, const mVec3_c &to, f32 interp) { + f32 z = (from.x * to.y) - (from.y * to.x); + f32 y = (from.z * to.x) - (from.x * to.z); + f32 x = (from.y * to.z) - (from.z * to.y); + + mVec3_c cross(x, y, z); + f32 mag = cross.mag(); + + if (cM::isZero(mag)) { + set(1.0f, 0.0f, 0.0f, 0.0f); + return from.dot(to) > 0.0f; + } + cross *= 1.0f / mag; + setAxisRotation(cross, interp * cM::atan2f(mag, from.dot(to))); + return true; +} + +bool mQuat_c::slerpTo(const mVec3_c &from, const mVec3_c &to, f32 maxStep) { + f32 z = (from.x * to.y) - (from.y * to.x); + f32 y = (from.z * to.x) - (from.x * to.z); + f32 x = (from.y * to.z) - (from.z * to.y); + + mVec3_c cross(x, y, z); + f32 mag = cross.mag(); + + if (cM::isZero(mag)) { + set(1.0f, 0.0f, 0.0f, 0.0f); + return from.dot(to) > 0.0f; + } + cross *= 1.0f / mag; + setAxisRotation(cross, nw4r::ut::Min(cM::atan2f(mag, from.dot(to)), maxStep)); + return true; +} diff --git a/src/m/m_sphere.cpp b/src/m/m_sphere.cpp new file mode 100644 index 00000000..ed093507 --- /dev/null +++ b/src/m/m_sphere.cpp @@ -0,0 +1,38 @@ +#include "m/m_sphere.h" + +#include "c/c_math.h" +#include "egg/math/eggVector.h" +#include "m/m_vec.h" +#include "nw4r/math/math_arithmetic.h" +#include "nw4r/math/math_types.h" + +mSphere_c &mSphere_c::merge(const mSphere_c &other) { + mVec3_c cDiff; + + mVec3_c sub; + nw4r::math::VEC3Sub(&sub, &mCenter, &other.mCenter); + cDiff = sub; + + f32 dot = cDiff.getSquareMag(); + + f32 rDiff = (other.mRadius - mRadius); + + if (rDiff * rDiff >= dot) { + if (other.mRadius >= mRadius) { + mCenter = other.mCenter; + mRadius = other.mRadius; + } + } else { + f32 norm = nw4r::math::FSqrt(dot); + + mRadius = norm + mRadius; + mRadius = (mRadius + other.mRadius) * 0.5f; + + if (!cM::isZero(norm)) { + mVec3_c shift = cDiff * ((mRadius - other.mRadius) / norm); + mCenter = other.mCenter + shift; + } + } + + return *this; +} diff --git a/src/toBeSorted/d_enemy_sword_mdl.cpp b/src/toBeSorted/d_enemy_sword_mdl.cpp index 0c030dcd..aee66acc 100644 --- a/src/toBeSorted/d_enemy_sword_mdl.cpp +++ b/src/toBeSorted/d_enemy_sword_mdl.cpp @@ -4,6 +4,7 @@ #include "d/col/cc/d_cc_s.h" #include "d/d_sc_game.h" #include "m/m3d/m_shadow.h" +#include "m/m_sphere.h" #include "m/m_vec.h" #include "nw4r/g3d/res/g3d_resfile.h" #include "nw4r/g3d/res/g3d_resmdl.h" @@ -117,15 +118,15 @@ void dEnemySwordMdl_c::calc(const mMtx_c &mtx, const mVec3_c &v1, bool mass) { mProc.calc(field_0x098, field_0x08C); } -bool dEnemySwordMdl_c::entry(dAcObjBase_c *obj, dShadowCircle_c *shadow, mQuat_c *quat) { +bool dEnemySwordMdl_c::entry(dAcObjBase_c *obj, dShadowCircle_c *shadow, mSphere_c *sph) { if (dScGame_c::currentSpawnInfo.getTrial() == SpawnInfo::TRIAL) { obj->fn_8002ECD0(&mMdl, 7); } else { obj->drawModelType1(&mMdl); } mProc.entry(); - if (shadow != nullptr && quat != nullptr) { - m3d::mShadow_c::GetInstance()->addMdlToCircle(shadow, mMdl, *quat); + if (shadow != nullptr && sph != nullptr) { + m3d::mShadow_c::GetInstance()->addMdlToCircle(shadow, mMdl, *sph); } return true; }