mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 00:27:42 +00:00
New code style refactor
This commit is contained in:
@@ -2,48 +2,45 @@
|
||||
#include "CPASAnimParmData.hpp"
|
||||
#include "CRandom16.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
namespace urde {
|
||||
|
||||
void CPASDatabase::AddAnimState(CPASAnimState&& state)
|
||||
{
|
||||
auto it = std::lower_bound(x0_states.begin(), x0_states.end(), state,
|
||||
[](const CPASAnimState& item, const CPASAnimState& test) -> bool {return item.GetStateId() < test.GetStateId();});
|
||||
x0_states.insert(it, std::move(state));
|
||||
void CPASDatabase::AddAnimState(CPASAnimState&& state) {
|
||||
auto it = std::lower_bound(x0_states.begin(), x0_states.end(), state,
|
||||
[](const CPASAnimState& item, const CPASAnimState& test) -> bool {
|
||||
return item.GetStateId() < test.GetStateId();
|
||||
});
|
||||
x0_states.insert(it, std::move(state));
|
||||
}
|
||||
|
||||
CPASDatabase::CPASDatabase(CInputStream& in)
|
||||
{
|
||||
in.readUint32Big();
|
||||
u32 animStateCount = in.readUint32Big();
|
||||
u32 defaultState = in.readUint32Big();
|
||||
CPASDatabase::CPASDatabase(CInputStream& in) {
|
||||
in.readUint32Big();
|
||||
u32 animStateCount = in.readUint32Big();
|
||||
u32 defaultState = in.readUint32Big();
|
||||
|
||||
x0_states.reserve(animStateCount);
|
||||
for (u32 i=0 ; i<animStateCount ; ++i)
|
||||
{
|
||||
CPASAnimState state(in);
|
||||
AddAnimState(std::move(state));
|
||||
}
|
||||
x0_states.reserve(animStateCount);
|
||||
for (u32 i = 0; i < animStateCount; ++i) {
|
||||
CPASAnimState state(in);
|
||||
AddAnimState(std::move(state));
|
||||
}
|
||||
|
||||
if (animStateCount)
|
||||
SetDefaultState(defaultState);
|
||||
if (animStateCount)
|
||||
SetDefaultState(defaultState);
|
||||
}
|
||||
|
||||
std::pair<float, s32> CPASDatabase::FindBestAnimation(const CPASAnimParmData& data, s32 ignoreAnim) const
|
||||
{
|
||||
CRandom16 rnd(4660);
|
||||
return FindBestAnimation(data, rnd, ignoreAnim);
|
||||
std::pair<float, s32> CPASDatabase::FindBestAnimation(const CPASAnimParmData& data, s32 ignoreAnim) const {
|
||||
CRandom16 rnd(4660);
|
||||
return FindBestAnimation(data, rnd, ignoreAnim);
|
||||
}
|
||||
|
||||
std::pair<float, s32> CPASDatabase::FindBestAnimation(const CPASAnimParmData& data, CRandom16& rand, s32 ignoreAnim) const
|
||||
{
|
||||
auto it = rstl::binary_find(x0_states.cbegin(), x0_states.cend(), data.GetStateId(),
|
||||
[](const CPASAnimState& item) {return item.GetStateId();});
|
||||
std::pair<float, s32> CPASDatabase::FindBestAnimation(const CPASAnimParmData& data, CRandom16& rand,
|
||||
s32 ignoreAnim) const {
|
||||
auto it = rstl::binary_find(x0_states.cbegin(), x0_states.cend(), data.GetStateId(),
|
||||
[](const CPASAnimState& item) { return item.GetStateId(); });
|
||||
|
||||
if (it == x0_states.cend())
|
||||
return {0.f, -1};
|
||||
if (it == x0_states.cend())
|
||||
return {0.f, -1};
|
||||
|
||||
return (*it).FindBestAnimation(data.GetAnimParmData(), rand, ignoreAnim);
|
||||
return (*it).FindBestAnimation(data.GetAnimParmData(), rand, ignoreAnim);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace urde
|
||||
|
||||
Reference in New Issue
Block a user