Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library/Camera: Implement ActorCameraSubTarget #214

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions data/odyssey_functions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 58 additions & 0 deletions lib/al/Library/Camera/ActorCameraSubTarget.cpp
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <math/seadVector.h>
#include <prim/seadSafeString.h>

#include "Library/Camera/CameraSubTargetBase.h"

Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <math/seadVector.h>

#include "Library/Camera/CameraTargetBase.h"

namespace al {
Expand All @@ -25,4 +27,6 @@ class ActorCameraTarget : public CameraTargetBase {
f32 mYOffset;
};

static_assert(sizeof(ActorCameraTarget) == 0x28);

} // namespace al
2 changes: 1 addition & 1 deletion lib/al/Library/Obj/CameraWatchPoint.cpp
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Loading