diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h index 796b669c..b705940e 100644 --- a/include/d/a/d_a_base.h +++ b/include/d/a/d_a_base.h @@ -93,27 +93,29 @@ protected: public: /* 8002c3b0 */ dAcBase_c(); - void setPostion(mVec3_c *r) { - position.set(r->x, r->y, r->z); + void setPostion(mVec3_c &r) { + position = r; } - void setScale(f32 x, f32 y, f32 z) { - scale.set(x, y, z); + void SetScale(mVec3_c &r) { + scale = r; } - void setScale(mVec3_c *r) { - scale.set(r->x, r->y, r->z); - } - void setRotation(mAng3_c *r) { - rotation = *r; + void SetRotation(mAng3_c &r) { + rotation = r; } void copyPosition() { - pos_copy.x = position.x; - pos_copy.y = position.y; - pos_copy.z = position.z; + pos_copy = position; + } + + const mVec3_c &GetPostion() const { + return position; } void copyRotation() { rot_copy = rotation; } + mVec3_c GetPostionDifference(const dAcBase_c *other) { + return position - other->position; + } public: // funcs found in TU diff --git a/include/m/m_vec.h b/include/m/m_vec.h index b182642e..1ea23afb 100644 --- a/include/m/m_vec.h +++ b/include/m/m_vec.h @@ -9,7 +9,7 @@ class mVec3_c : public EGG::Vector3f { public: /// @brief Constructs an empty vector. /* 80009ee0 */ mVec3_c() {} - /* 80007460 */ ~mVec3_c() {} + // /* 80007460 */ ~mVec3_c() {} /// @brief Constructs a vector from a float array. mVec3_c(const f32 *p) { @@ -17,6 +17,7 @@ public: y = p[1]; z = p[2]; } + mVec3_c(const mVec3_c &other) { x = other.x; y = other.y; @@ -30,15 +31,8 @@ public: z = fz; } - void set(f32 fx, f32 fy, f32 fz) { - x = fx; - y = fy; - z = fz; - } mVec3_c &operator=(const mVec3_c &r) { - x = r.x; - y = r.y; - z = r.z; + set(r.x, r.y, r.z); return *this; } @@ -86,14 +80,6 @@ public: return (const nw4r::math::VEC3 *)&x; } - /// @brief Augmented addition operator. - mVec3_c &operator+=(const mVec3_c &v) { - x += v.x; - y += v.y; - z += v.z; - return *this; - } - /// @brief Augmented subtraction operator. mVec3_c &operator-=(const mVec3_c &v) { x -= v.x; diff --git a/src/d/a/d_a_base.cpp b/src/d/a/d_a_base.cpp index 87367333..e61b938a 100644 --- a/src/d/a/d_a_base.cpp +++ b/src/d/a/d_a_base.cpp @@ -45,18 +45,18 @@ dAcBase_c::dAcBase_c() JStudio_actor = 0; someStr[0] = 0; - if (s_Create_Position != nullptr) { - position.set(s_Create_Position->x, s_Create_Position->y, s_Create_Position->z); + if (s_Create_Position) { + setPostion(*s_Create_Position); } - if (s_Create_Rotation != nullptr) { - rotation = *(s_Create_Rotation); + if (s_Create_Rotation) { + SetRotation(*s_Create_Rotation); } - if (s_Create_Scale != nullptr) { - setScale(s_Create_Scale->x, s_Create_Scale->y, s_Create_Scale->z); + if (s_Create_Scale) { + SetScale(*s_Create_Scale); } else { - setScale(1.0, 1.0, 1.0); + scale.set(1.0f, 1.0f, 1.0f); } if (s_Create_Parent != nullptr) { @@ -74,11 +74,7 @@ dAcBase_c::dAcBase_c() // 8002c530 dBase_c::~dBase_c() {} -dAcBase_c::~dAcBase_c() { - if (sound_source != nullptr) { - // call obj_sound dtor once defined - } -} +dAcBase_c::~dAcBase_c() {} void dAcBase_c::setTempCreateParams(mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, s32 roomId, u32 params2, dAcBase_c *parent, u8 subtype, s16 unkFlag, u8 viewClipIdx, ObjInfo *objInfo) { @@ -392,8 +388,7 @@ bool dAcBase_c::getDistanceAndAngleToActor(dAcBase_c *actor, f32 distThresh, s16 // 8002d3e0 bool dAcBase_c::isWithinPlayerRadius(f32 radius) { - mVec3_c dist_diff = position - dPlayer::LINK->position; - + mVec3_c dist_diff = GetPostionDifference(dPlayer::LINK); return dist_diff.x * dist_diff.x + dist_diff.z * dist_diff.z < radius * radius; } @@ -559,12 +554,11 @@ void dAcBase_c::FUN_8002dc20(s16 *, s16 *) {} void dAcBase_c::incrementKillCounter() { dAcObjBase_c *object = (dAcObjBase_c *)this; // Probably wrong - if (group_type == ACTOR && object->unkByteTargetFiRelated == 1) { int killCounterId = object->targetFiTextId; if (killCounterId < 91 && (killCounterId & 0x300) == 0) { - FileManager *fileMgr = FileManager::sInstance; + FileManager *fileMgr = FileManager::sInstance; u16 killCount = fileMgr->getEnemyKillCount(killCounterId) + 1; fileMgr->setEnemyKillCount(killCounterId, killCount); }