From adffc15dd8546e9a6dcb4d2493760c4fc31415c7 Mon Sep 17 00:00:00 2001 From: MonsterDruide1 <5958456@gmail.com> Date: Tue, 31 Dec 2024 16:30:07 +0100 Subject: [PATCH] Library/Camera: Implement `ActorCameraSubTarget` --- data/odyssey_functions.csv | 20 +++---- .../Library/Camera/ActorCameraSubTarget.cpp | 58 +++++++++++++++++++ .../{Play => }/Camera/ActorCameraSubTarget.h | 25 +++++++- .../{Play => }/Camera/ActorCameraTarget.cpp | 2 +- .../{Play => }/Camera/ActorCameraTarget.h | 4 ++ lib/al/Library/Obj/CameraWatchPoint.cpp | 2 +- 6 files changed, 96 insertions(+), 15 deletions(-) create mode 100644 lib/al/Library/Camera/ActorCameraSubTarget.cpp rename lib/al/Library/{Play => }/Camera/ActorCameraSubTarget.h (50%) rename lib/al/Library/{Play => }/Camera/ActorCameraTarget.cpp (96%) rename lib/al/Library/{Play => }/Camera/ActorCameraTarget.h (91%) diff --git a/data/odyssey_functions.csv b/data/odyssey_functions.csv index 32d45bc1..2b900a13 100644 --- a/data/odyssey_functions.csv +++ b/data/odyssey_functions.csv @@ -60819,16 +60819,16 @@ Address,Quality,Size,Name 0x0000007100971b50,U,000080,_ZN2al12ViewCtrlAreaC2EPKc 0x0000007100971ba0,U,000092,_ZN2al12ViewCtrlAreaC1EPKc 0x0000007100971bfc,U,000044,_ZN2al12ViewCtrlArea4initERKNS_12AreaInitInfoE -0x0000007100971c28,U,000056,_ZN2al20ActorCameraSubTargetC2EPKNS_9LiveActorE -0x0000007100971c60,U,000016,_ZNK2al20ActorCameraSubTarget13getTargetNameEv -0x0000007100971c70,U,000256,_ZNK2al20ActorCameraSubTarget9calcTransEPN4sead7Vector3IfEE -0x0000007100971d70,U,000016,_ZNK2al20ActorCameraSubTarget8calcSideEPN4sead7Vector3IfEE -0x0000007100971d80,U,000016,_ZNK2al20ActorCameraSubTarget6calcUpEPN4sead7Vector3IfEE -0x0000007100971d90,U,000016,_ZNK2al20ActorCameraSubTarget9calcFrontEPN4sead7Vector3IfEE -0x0000007100971da0,U,000052,_ZNK2al20ActorCameraSubTarget12calcVelocityEPN4sead7Vector3IfEE -0x0000007100971dd4,U,000248,_ZN2al30ActorBackAroundCameraSubTargetC2EPKNS_9LiveActorE -0x0000007100971ecc,U,000120,_ZNK2al30ActorBackAroundCameraSubTarget9calcTransEPN4sead7Vector3IfEE -0x0000007100971f44,U,000048,_ZNK2al30ActorBackAroundCameraSubTarget13getTargetNameEv +0x0000007100971c28,O,000056,_ZN2al20ActorCameraSubTargetC2EPKNS_9LiveActorE +0x0000007100971c60,O,000016,_ZNK2al20ActorCameraSubTarget13getTargetNameEv +0x0000007100971c70,O,000256,_ZNK2al20ActorCameraSubTarget9calcTransEPN4sead7Vector3IfEE +0x0000007100971d70,O,000016,_ZNK2al20ActorCameraSubTarget8calcSideEPN4sead7Vector3IfEE +0x0000007100971d80,O,000016,_ZNK2al20ActorCameraSubTarget6calcUpEPN4sead7Vector3IfEE +0x0000007100971d90,O,000016,_ZNK2al20ActorCameraSubTarget9calcFrontEPN4sead7Vector3IfEE +0x0000007100971da0,O,000052,_ZNK2al20ActorCameraSubTarget12calcVelocityEPN4sead7Vector3IfEE +0x0000007100971dd4,O,000248,_ZN2al30ActorBackAroundCameraSubTargetC2EPKNS_9LiveActorE +0x0000007100971ecc,O,000120,_ZNK2al30ActorBackAroundCameraSubTarget9calcTransEPN4sead7Vector3IfEE +0x0000007100971f44,O,000048,_ZNK2al30ActorBackAroundCameraSubTarget13getTargetNameEv 0x0000007100971f74,O,000084,_ZN2al17ActorCameraTargetC2EPKNS_9LiveActorEfPKN4sead7Vector3IfEE 0x0000007100971fc8,O,000016,_ZNK2al17ActorCameraTarget13getTargetNameEv 0x0000007100971fd8,O,000076,_ZNK2al17ActorCameraTarget9calcTransEPN4sead7Vector3IfEE diff --git a/lib/al/Library/Camera/ActorCameraSubTarget.cpp b/lib/al/Library/Camera/ActorCameraSubTarget.cpp new file mode 100644 index 00000000..4580f525 --- /dev/null +++ b/lib/al/Library/Camera/ActorCameraSubTarget.cpp @@ -0,0 +1,58 @@ +#include "Library/Camera/ActorCameraSubTarget.h" + +#include "Library/LiveActor/ActorMovementFunction.h" +#include "Library/LiveActor/ActorPoseKeeper.h" +#include "Library/LiveActor/LiveActor.h" + +namespace al { + +ActorCameraSubTarget::ActorCameraSubTarget(const LiveActor* actor) : mActor(actor) {} + +const char* ActorCameraSubTarget::getTargetName() const { + return mActor->getName(); +} + +void ActorCameraSubTarget::calcTrans(sead::Vector3f* trans) const { + trans->set(getTrans(mActor)); + if (mOffset) { + sead::Vector3f side, up, front; + calcSide(&side); + calcUp(&up); + calcFront(&front); + *trans += side * mOffset->x + up * mOffset->y + front * mOffset->z; + } +} + +void ActorCameraSubTarget::calcSide(sead::Vector3f* side) const { + calcSideDir(side, mActor); +} + +void ActorCameraSubTarget::calcUp(sead::Vector3f* up) const { + calcUpDir(up, mActor); +} + +void ActorCameraSubTarget::calcFront(sead::Vector3f* front) const { + calcFrontDir(front, mActor); +} + +void ActorCameraSubTarget::calcVelocity(sead::Vector3f* velocity) const { + velocity->set(getVelocity(mActor)); +} + +ActorBackAroundCameraSubTarget::ActorBackAroundCameraSubTarget(const LiveActor* actor) + : ActorCameraSubTarget(actor) { + mTargetName.format("%s[背後回り込み]", actor->getName()); +} + +void ActorBackAroundCameraSubTarget::calcTrans(sead::Vector3f* trans) const { + ActorCameraSubTarget::calcTrans(trans); + sead::Vector3f front = {0.0f, 0.0f, 0.0f}; + calcFrontDir(&front, getActor()); + *trans += front * 200.0f; +} + +const char* ActorBackAroundCameraSubTarget::getTargetName() const { + return mTargetName.cstr(); +} + +} // namespace al diff --git a/lib/al/Library/Play/Camera/ActorCameraSubTarget.h b/lib/al/Library/Camera/ActorCameraSubTarget.h similarity index 50% rename from lib/al/Library/Play/Camera/ActorCameraSubTarget.h rename to lib/al/Library/Camera/ActorCameraSubTarget.h index 447e8b4e..a7e5872c 100644 --- a/lib/al/Library/Play/Camera/ActorCameraSubTarget.h +++ b/lib/al/Library/Camera/ActorCameraSubTarget.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "Library/Camera/CameraSubTargetBase.h" @@ -9,19 +10,37 @@ class LiveActor; class ActorCameraSubTarget : public CameraSubTargetBase { public: - ActorCameraSubTarget(const LiveActor*); - const char* getTargetName() const override; + ActorCameraSubTarget(const LiveActor* actor); + const char* getTargetName() const override; void calcTrans(sead::Vector3f* trans) const override; void calcSide(sead::Vector3f* side) const override; void calcUp(sead::Vector3f* up) const override; void calcFront(sead::Vector3f* front) const override; void calcVelocity(sead::Vector3f* velocity) const override; + const LiveActor* getActor() const { return mActor; } + + void setOffset(const sead::Vector3f* offset) { mOffset = offset; } + private: const LiveActor* mActor; - const sead::Vector3f* mOffset; + const sead::Vector3f* mOffset = nullptr; }; static_assert(sizeof(ActorCameraSubTarget) == 0x28); + +class ActorBackAroundCameraSubTarget : public ActorCameraSubTarget { +public: + ActorBackAroundCameraSubTarget(const LiveActor* actor); + + void calcTrans(sead::Vector3f* trans) const override; + const char* getTargetName() const override; + +private: + sead::FixedSafeString<128> mTargetName{""}; +}; + +static_assert(sizeof(ActorBackAroundCameraSubTarget) == 0xC0); + } // namespace al diff --git a/lib/al/Library/Play/Camera/ActorCameraTarget.cpp b/lib/al/Library/Camera/ActorCameraTarget.cpp similarity index 96% rename from lib/al/Library/Play/Camera/ActorCameraTarget.cpp rename to lib/al/Library/Camera/ActorCameraTarget.cpp index b4f90515..3973ccaf 100644 --- a/lib/al/Library/Play/Camera/ActorCameraTarget.cpp +++ b/lib/al/Library/Camera/ActorCameraTarget.cpp @@ -1,4 +1,4 @@ -#include "Library/Play/Camera/ActorCameraTarget.h" +#include "Library/Camera/ActorCameraTarget.h" #include "Library/LiveActor/ActorAreaFunction.h" #include "Library/LiveActor/ActorCollisionFunction.h" diff --git a/lib/al/Library/Play/Camera/ActorCameraTarget.h b/lib/al/Library/Camera/ActorCameraTarget.h similarity index 91% rename from lib/al/Library/Play/Camera/ActorCameraTarget.h rename to lib/al/Library/Camera/ActorCameraTarget.h index fe7b6fe5..aab7e5f3 100644 --- a/lib/al/Library/Play/Camera/ActorCameraTarget.h +++ b/lib/al/Library/Camera/ActorCameraTarget.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "Library/Camera/CameraTargetBase.h" namespace al { @@ -25,4 +27,6 @@ class ActorCameraTarget : public CameraTargetBase { f32 mYOffset; }; +static_assert(sizeof(ActorCameraTarget) == 0x28); + } // namespace al diff --git a/lib/al/Library/Obj/CameraWatchPoint.cpp b/lib/al/Library/Obj/CameraWatchPoint.cpp index 2f245c49..323891ea 100644 --- a/lib/al/Library/Obj/CameraWatchPoint.cpp +++ b/lib/al/Library/Obj/CameraWatchPoint.cpp @@ -1,10 +1,10 @@ #include "Library/Obj/CameraWatchPoint.h" +#include "Library/Camera/ActorCameraSubTarget.h" #include "Library/Camera/CameraUtil.h" #include "Library/LiveActor/ActorClippingFunction.h" #include "Library/LiveActor/ActorDrawFunction.h" #include "Library/LiveActor/ActorInitFunction.h" -#include "Library/Play/Camera/ActorCameraSubTarget.h" #include "Project/Camera/CameraSubTargetTurnParam.h" namespace al {