ksys/res: Implement RagdollBlendWeight

This commit is contained in:
Léo Lam
2021-04-20 16:57:41 +02:00
parent 92c7645e70
commit 441a0e5240
3 changed files with 134 additions and 22 deletions
+21 -21
View File
@@ -87980,27 +87980,27 @@
0x000000710109a63c,sub_710109A63C,160,_ZThn664_N4ksys3res13LifeConditionD1Ev
0x000000710109a6dc,sub_710109A6DC,148,_ZThn664_N4ksys3res13LifeConditionD0Ev
0x000000710109a770,sub_710109A770,372,_ZN4ksys3res13LifeCondition33checkDerivedRuntimeTypeInfoStaticEPKN4sead15RuntimeTypeInfo9InterfaceE
0x000000710109a8e4,nullsub_4473,4,
0x000000710109a8e8,nullsub_4474,4,
0x000000710109a8ec,sub_710109A8EC,1460,
0x000000710109aea0,sub_710109AEA0,8,
0x000000710109aea8,sub_710109AEA8,56,
0x000000710109aee0,sub_710109AEE0,56,
0x000000710109af18,sub_710109AF18,316,
0x000000710109b054,sub_710109B054,208,
0x000000710109b124,sub_710109B124,196,
0x000000710109b1e8,sub_710109B1E8,8,
0x000000710109b1f0,sub_710109B1F0,8,
0x000000710109b1f8,sub_710109B1F8,92,
0x000000710109b254,sub_710109B254,8,
0x000000710109b25c,sub_710109B25C,8,
0x000000710109b264,sub_710109B264,92,
0x000000710109b2c0,sub_710109B2C0,208,
0x000000710109b390,sub_710109B390,196,
0x000000710109b454,sub_710109B454,8,
0x000000710109b45c,sub_710109B45C,208,
0x000000710109b52c,sub_710109B52C,196,
0x000000710109b5f0,sub_710109B5F0,372,
0x000000710109a8e4,nullsub_4473,4,_ZN4ksys3res18RagdollBlendWeight9doCreate_EPhjPN4sead4HeapE
0x000000710109a8e8,nullsub_4474,4,_ZThn632_N4ksys3res18RagdollBlendWeight9doCreate_EPhjPN4sead4HeapE
0x000000710109a8ec,sub_710109A8EC,1460,_ZN4ksys3res18RagdollBlendWeight6parse_EPhmPN4sead4HeapE
0x000000710109aea0,sub_710109AEA0,8,_ZThn632_N4ksys3res18RagdollBlendWeight6parse_EPhmPN4sead4HeapE
0x000000710109aea8,sub_710109AEA8,56,_ZNK4ksys3res18RagdollBlendWeight18getWeightRigidNameEii
0x000000710109aee0,sub_710109AEE0,56,_ZNK4ksys3res18RagdollBlendWeight18getWeightBlendRateEii
0x000000710109af18,sub_710109AF18,316,_ZNK4ksys3res18RagdollBlendWeight12findStateIdxERKN4sead14SafeStringBaseIcEE
0x000000710109b054,sub_710109B054,208,_ZN4ksys3res18RagdollBlendWeightD2Ev
0x000000710109b124,sub_710109B124,196,_ZN4ksys3res18RagdollBlendWeightD0Ev
0x000000710109b1e8,sub_710109B1E8,8,_ZN4ksys3res18RagdollBlendWeight10ParamIO_m0Ev
0x000000710109b1f0,sub_710109B1F0,8,_ZNK4ksys3res18RagdollBlendWeight27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
0x000000710109b1f8,sub_710109B1F8,92,_ZNK4ksys3res18RagdollBlendWeight18getRuntimeTypeInfoEv
0x000000710109b254,sub_710109B254,8,_ZNK4ksys3res18RagdollBlendWeight10needsParseEv
0x000000710109b25c,sub_710109B25C,8,_ZThn632_NK4ksys3res18RagdollBlendWeight27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
0x000000710109b264,sub_710109B264,92,_ZThn632_NK4ksys3res18RagdollBlendWeight18getRuntimeTypeInfoEv
0x000000710109b2c0,sub_710109B2C0,208,_ZThn632_N4ksys3res18RagdollBlendWeightD1Ev
0x000000710109b390,sub_710109B390,196,_ZThn632_N4ksys3res18RagdollBlendWeightD0Ev
0x000000710109b454,sub_710109B454,8,_ZThn632_NK4ksys3res18RagdollBlendWeight10needsParseEv
0x000000710109b45c,sub_710109B45C,208,_ZThn664_N4ksys3res18RagdollBlendWeightD1Ev
0x000000710109b52c,sub_710109B52C,196,_ZThn664_N4ksys3res18RagdollBlendWeightD0Ev
0x000000710109b5f0,sub_710109B5F0,372,_ZN4ksys3res18RagdollBlendWeight33checkDerivedRuntimeTypeInfoStaticEPKN4sead15RuntimeTypeInfo9InterfaceE
0x000000710109b764,nullsub_4475,4,_ZN4ksys3res4Shop9doCreate_EPhjPN4sead4HeapE
0x000000710109b768,nullsub_4476,4,_ZThn632_N4ksys3res4Shop9doCreate_EPhjPN4sead4HeapE
0x000000710109b76c,Bshop::parse,1404,_ZN4ksys3res4Shop6parse_EPhmPN4sead4HeapE
Can't render this file because it is too large.
@@ -1 +1,78 @@
#include "KingSystem/Resource/resResourceRagdollBlendWeight.h"
namespace ksys::res {
void RagdollBlendWeight::doCreate_(u8* buffer, u32 buffer_size, sead::Heap* heap) {}
bool RagdollBlendWeight::parse_(u8* data, size_t size, sead::Heap* heap) {
if (!data)
return false;
using FormatString = sead::FormatFixedSafeString<32>;
agl::utl::ResParameterArchive archive{data};
const auto root = archive.getRootList();
const auto num_states = root.getResParameterListNum();
if (num_states != 0) {
mStates.allocBufferAssert(num_states, heap);
int state_idx = 1;
for (auto it = mStates.begin(), end = mStates.end(); it != end; ++it) {
const auto State =
agl::utl::getResParameterList(root, FormatString("%s%d", "State_", state_idx));
if (State) {
it->state_key.init("", "StateKey", "ステートキー", "", &it->setting_obj);
it->system_key.init("", "SystemKey", "システムキー", "", &it->setting_obj);
const auto InputWeightList =
agl::utl::getResParameterList(State, "InputWeightList");
if (int num_weights; InputWeightList &&
(num_weights = InputWeightList.getResParameterObjNum()) != 0) {
it->input_weights.allocBufferAssert(num_weights, heap);
int weight_idx = 1;
for (auto wit = it->input_weights.begin(), wend = it->input_weights.end();
wit != wend; ++wit) {
wit->rigid_name.init("", "RigidName", "ボーン名", "", &wit->obj);
wit->blend_rate.init(1.0, "BlendRate", "ブレンド率", "", &wit->obj);
it->input_weight_list.addObj(
&wit->obj, FormatString("%s%d", "InputWeight_", weight_idx));
++weight_idx;
}
}
}
it->list.addObj(&it->setting_obj, FormatString("Setting"));
it->list.addList(&it->input_weight_list, FormatString("InputWeightList"));
addList(&it->list, FormatString("%s%d", "State_", state_idx));
++state_idx;
}
}
applyResParameterArchive(archive);
return true;
}
const sead::SafeString& RagdollBlendWeight::getWeightRigidName(int state_idx,
int weight_idx) const {
return mStates[state_idx].input_weights[weight_idx].rigid_name.ref();
}
float RagdollBlendWeight::getWeightBlendRate(int state_idx, int weight_idx) const {
return mStates[state_idx].input_weights[weight_idx].blend_rate.ref();
}
int RagdollBlendWeight::findStateIdx(const sead::SafeString& key) const {
for (int i = 0; i < mStates.size(); ++i) {
if (mStates[i].state_key.ref() == key)
return i;
}
return -1;
}
} // namespace ksys::res
@@ -1,13 +1,48 @@
#pragma once
#include <agl/Utils/aglParameter.h>
#include <agl/Utils/aglParameterList.h>
#include <agl/Utils/aglParameterObj.h>
#include <container/seadBuffer.h>
#include "KingSystem/Resource/resResource.h"
#include "KingSystem/Utils/ParamIO.h"
namespace ksys::res {
// TODO
class RagdollBlendWeight : public ParamIO, public Resource {
SEAD_RTTI_OVERRIDE(RagdollBlendWeight, Resource)
public:
struct InputWeight {
agl::utl::Parameter<sead::SafeString> rigid_name;
agl::utl::Parameter<float> blend_rate;
agl::utl::ParameterObj obj;
};
struct State {
agl::utl::ParameterList list;
agl::utl::Parameter<sead::SafeString> state_key;
agl::utl::Parameter<sead::SafeString> system_key;
agl::utl::ParameterObj setting_obj;
agl::utl::ParameterList input_weight_list;
sead::Buffer<InputWeight> input_weights;
};
RagdollBlendWeight() : ParamIO("rgbw", 0) {}
~RagdollBlendWeight() override { mStates.freeBuffer(); }
const sead::Buffer<State>& getStates() const { return mStates; }
const sead::SafeString& getWeightRigidName(int state_idx, int weight_idx) const;
float getWeightBlendRate(int state_idx, int weight_idx) const;
int findStateIdx(const sead::SafeString& key) const;
bool ParamIO_m0() override { return true; }
void doCreate_(u8* buffer, u32 buffer_size, sead::Heap* heap) override;
bool needsParse() const override { return true; }
bool parse_(u8* data, size_t size, sead::Heap* heap) override;
private:
sead::Buffer<State> mStates;
};
} // namespace ksys::res