ksys/act: Start adding ActorCaptureMgr

This commit is contained in:
Léo Lam
2020-11-08 18:47:26 +01:00
parent ff3421d4eb
commit 7d2ef1d6b2
7 changed files with 155 additions and 7 deletions
+7 -7
View File
@@ -51834,19 +51834,19 @@
0x000000710089ca9c,sub_710089CA9C,88,
0x000000710089caf4,sub_710089CAF4,88,
0x000000710089cb4c,sub_710089CB4C,40,
0x000000710089cb74,ActorCaptureMgr::ctor,276,
0x000000710089cc88,ActorCaptureMgr::init,332,
0x000000710089cdd4,ActorCaptureMgr::init2,12,
0x000000710089cb74,ActorCaptureMgr::ctor,276,_ZN4ksys3act15ActorCaptureMgrC1Ev
0x000000710089cc88,ActorCaptureMgr::init,332,_ZN4ksys3act15ActorCaptureMgr4initERKNS1_7InitArgE
0x000000710089cdd4,ActorCaptureMgr::init2,12,_ZN4ksys3act15ActorCaptureMgr9setCameraEPNS0_6CameraE
0x000000710089cde0,sub_710089CDE0,4112,
0x000000710089ddf0,_ZN4sead21FormatFixedSafeStringILi1024EEC2EPKcz,224,
0x000000710089ded0,sub_710089DED0,572,
0x000000710089e10c,sub_710089E10C,804,
0x000000710089e430,sub_710089E430,1028,
0x000000710089e834,ActorCaptureMgr::loadActorCapture,492,
0x000000710089e834,ActorCaptureMgr::loadActorCapture,492,_ZN4ksys3act15ActorCaptureMgr16loadCaptureParamEv
0x000000710089ea20,sub_710089EA20,1612,
0x000000710089f06c,sub_710089F06C,244,
0x000000710089f160,sub_710089F160,244,
0x000000710089f254,sub_710089F254,36,
0x000000710089f160,sub_710089F160,244,_ZN4ksys3act15ActorCaptureMgrD1Ev
0x000000710089f254,sub_710089F254,36,_ZN4ksys3act15ActorCaptureMgrD0Ev
0x000000710089f278,sub_710089F278,216,
0x000000710089f350,sub_710089F350,224,
0x000000710089f430,EntryFactoryBactcapt::rtti1,132,
@@ -85567,7 +85567,7 @@
0x0000007101089518,nullsub_4456,4,_ZThn632_N4ksys3res12ActorCapture9doCreate_EPhjPN4sead4HeapE
0x000000710108951c,sub_710108951C,72,_ZN4ksys3res12ActorCapture6parse_EPhmPN4sead4HeapE
0x0000007101089564,sub_7101089564,72,_ZThn632_N4ksys3res12ActorCapture6parse_EPhmPN4sead4HeapE
0x00000071010895ac,sub_71010895AC,664,
0x00000071010895ac,sub_71010895AC,664,_ZN4ksys3res12ActorCapture5resetEv
0x0000007101089844,sub_7101089844,180,
0x00000071010898f8,sub_71010898F8,168,
0x00000071010899a0,sub_71010899A0,8,
Can't render this file because it is too large.
@@ -1,5 +1,7 @@
target_sources(uking PRIVATE
actActor.h
actActorCaptureMgr.cpp
actActorCaptureMgr.h
actActorConstDataAccess.cpp
actActorConstDataAccess.h
actActorCreator.cpp
@@ -0,0 +1,66 @@
#include "KingSystem/ActorSystem/actActorCaptureMgr.h"
#include "KingSystem/ActorSystem/actActor.h"
#include "KingSystem/Resource/resEntryFactory.h"
#include "KingSystem/Resource/resLoadRequest.h"
#include "KingSystem/Resource/resResourceMgrTask.h"
#include "KingSystem/Resource/resSystem.h"
#include "KingSystem/Utils/SafeDelete.h"
namespace ksys::act {
ActorCaptureMgr::ActorCaptureMgr() {
mRes.reset();
mTimer.reset(30.0);
}
ActorCaptureMgr::~ActorCaptureMgr() {
mActor = nullptr;
mCamera = nullptr;
res::unregisterEntryFactory(mFactory);
util::safeDelete(mFactory);
}
void ActorCaptureMgr::init(const InitArg& arg) {
mFactory = new (arg.heap) res::EntryFactory<res::ActorCapture>(1.0, 0x1000);
res::registerEntryFactory(mFactory, "bactcapt");
res::LoadRequest req;
req.mRequester = "ActorCaptureMgr";
req._26 = false;
mDummyFile.load("Actor/ActorCapture/Dummy.bactcapt", &req);
}
void ActorCaptureMgr::setCamera(Camera* camera) {
if (camera)
mCamera = camera;
}
void ActorCaptureMgr::loadCaptureParam() {
if (!mActor || !mActor->mActorParam)
return;
const char* name = getCapturedActorName();
if (!name)
return;
res::ActorCapture* param = nullptr;
{
res::LoadRequest req;
req.mRequester = "ActorCaptureMgr";
sead::FormatFixedSafeString<128> path("Actor/ActorCapture/%s.bactcapt", name);
res::ResourceMgrTask::instance()->controlField9c0d88(false);
auto* file = sead::DynamicCast<res::ActorCapture>(mCaptureParamFile.load(path, &req));
res::ResourceMgrTask::instance()->controlField9c0d88(true);
if (file)
param = file;
if (!param)
param = sead::DynamicCast<res::ActorCapture>(mDummyFile.getResource());
}
mRes.mCameraInfoObj.copy(param->mCameraInfoObj);
mRes.mActorInfoObj.copy(param->mActorInfoObj);
mRes.mLightInfoObj.copy(param->mLightInfoObj);
}
} // namespace ksys::act
@@ -0,0 +1,59 @@
#pragma once
#include <basis/seadTypes.h>
#include <prim/seadSafeString.h>
#include "KingSystem/Resource/resHandle.h"
#include "KingSystem/Resource/resResourceActorCapture.h"
#include "KingSystem/System/Timer.h"
#include "KingSystem/Utils/Types.h"
namespace ksys::res {
class EntryFactoryBase;
}
namespace ksys::act {
class Actor;
class Camera;
// TODO: incomplete
class ActorCaptureMgr {
public:
struct InitArg {
sead::Heap* heap;
};
ActorCaptureMgr();
virtual ~ActorCaptureMgr();
void init(const InitArg& arg);
void setCamera(Camera* camera);
void loadCaptureParam();
const char* getCapturedActorName() const;
private:
Actor* mActor{};
Camera* mCamera{};
res::EntryFactoryBase* mFactory{};
res::Handle mDummyFile;
res::Handle mCaptureParamFile;
sead::FixedSafeString<64> mStr;
sead::FixedSafeString<256> mStr2;
res::ActorCapture mRes;
struct Field768 {
Field768() {
_76c = 0;
_768 = 0;
}
u32 _768;
u8 _76c;
} _768;
s32 _770 = -1;
u32 _774{};
u32 _778{};
Timer mTimer;
};
KSYS_CHECK_SIZE_NX150(ActorCaptureMgr, 0x788);
} // namespace ksys::act
@@ -40,4 +40,22 @@ bool ActorCapture::parse_(u8* data, size_t, sead::Heap*) {
return true;
}
void ActorCapture::reset() {
mCameraInfoObj.position.ref() = sConstants.camera_position;
mCameraInfoObj.direction.ref() = sConstants.camera_direction;
mCameraInfoObj.fov.ref() = 50;
mCameraInfoObj.tilt.ref() = 0;
mActorInfoObj.position.ref() = sConstants.actor_position;
mActorInfoObj.rotation.ref() = sConstants.actor_rotation;
mActorInfoObj.as_name.ref().copy(sead::FixedSafeString<32>(sead::SafeString::cEmptyString));
mActorInfoObj.apply_skel_anim.ref() = false;
mActorInfoObj.frame.ref() = 0;
mActorInfoObj.bounding_adjustment.ref() = false;
mActorInfoObj.force_idle.ref() = false;
mActorInfoObj.disable_cloth.ref() = false;
mLightInfoObj.direction.ref() = sConstants.light_direction;
}
} // namespace ksys::res
@@ -55,6 +55,8 @@ public:
bool needsParse() const override { return true; }
bool ParamIO_m0() override { return true; }
void reset();
static const ActorCaptureConstants& getConstants();
CameraInfo mCameraInfoObj;
+1
View File
@@ -7,6 +7,7 @@ namespace ksys::res {
class EntryFactoryBase;
void registerEntryFactory(EntryFactoryBase* factory, const sead::SafeString& name);
void unregisterEntryFactory(EntryFactoryBase* factory);
// In release builds, the only thing this function does is return 1.
// TODO: figure out what this is used for. Stubbed log function?