mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-14 03:26:10 +00:00
Refactorings to support .upak generation
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define __URDE_CDVDFILE_HPP__
|
||||
|
||||
#include "RetroTypes.hpp"
|
||||
#include "athena/FileReader.hpp"
|
||||
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
||||
@@ -20,7 +20,7 @@ enum ESortedList
|
||||
struct SSortedList
|
||||
{
|
||||
s16 x0_ids[1024];
|
||||
u32 x800_size;
|
||||
u32 x800_size = 0;
|
||||
void Reset() {std::fill(std::begin(x0_ids), std::end(x0_ids), -1);}
|
||||
SSortedList() {Reset();}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "CStaticInterference.hpp"
|
||||
#include "zeus/Math.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
@@ -24,7 +25,7 @@ void CStaticInterference::Update(CStateManager&, float dt)
|
||||
newSources.reserve(m_sources.size());
|
||||
for (CStaticInterferenceSource& src : m_sources)
|
||||
{
|
||||
if (src.timeLeft >= 0.0)
|
||||
if (src.timeLeft >= 0.f)
|
||||
{
|
||||
src.timeLeft -= dt;
|
||||
newSources.push_back(src);
|
||||
@@ -35,8 +36,8 @@ void CStaticInterference::Update(CStateManager&, float dt)
|
||||
|
||||
float CStaticInterference::GetTotalInterference() const
|
||||
{
|
||||
float validAccum = 0.0;
|
||||
float invalidAccum = 0.0;
|
||||
float validAccum = 0.f;
|
||||
float invalidAccum = 0.f;
|
||||
for (const CStaticInterferenceSource& src : m_sources)
|
||||
{
|
||||
if (src.id == kInvalidUniqueId)
|
||||
@@ -44,11 +45,11 @@ float CStaticInterference::GetTotalInterference() const
|
||||
else
|
||||
validAccum += src.magnitude;
|
||||
}
|
||||
if (validAccum > 0.80000001)
|
||||
validAccum = 0.80000001;
|
||||
if (validAccum > 0.80000001f)
|
||||
validAccum = 0.80000001f;
|
||||
validAccum += invalidAccum;
|
||||
if (validAccum > 1.0)
|
||||
return 1.0;
|
||||
if (validAccum > 1.f)
|
||||
return 1.f;
|
||||
return validAccum;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define __URDE_CCAMERASPLINE_HPP__
|
||||
|
||||
#include "World/CEntityInfo.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "CBodyStateCmdMgr.hpp"
|
||||
#include <cfloat>
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define __URDE_CHUDBOSSENERGYINTERFACE_HPP__
|
||||
|
||||
#include "RetroTypes.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "RetroTypes.hpp"
|
||||
#include "CHudInterface.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define __URDE_CHUDVISORBEAMMENU_HPP__
|
||||
|
||||
#include "RetroTypes.hpp"
|
||||
#include <cfloat>
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define __URDE_CNESEMULATOR_HPP__
|
||||
|
||||
#include "RetroTypes.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include "GCNTypes.hpp"
|
||||
#include "rstl.hpp"
|
||||
#include "DataSpec/DNACommon/DNACommon.hpp"
|
||||
#include "IOStreams.hpp"
|
||||
#include "hecl/hecl.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
@@ -24,10 +25,9 @@ public:
|
||||
explicit CAssetId(CInputStream& in);
|
||||
bool IsValid() const { return id != UINT64_MAX; }
|
||||
u64 Value() const { return id; }
|
||||
void Assign(u64 v) { id = (v == UINT32_MAX ? UINT64_MAX : (v == 0 ? UINT64_MAX : v)); }
|
||||
void Assign(u64 v) { id = (v == UINT32_MAX ? UINT64_MAX : (v == 0 ? UINT64_MAX : v)); }
|
||||
void Reset() { id = UINT64_MAX; }
|
||||
void PutTo(COutputStream& out);
|
||||
|
||||
bool operator==(const CAssetId& other) const { return id == other.id; }
|
||||
bool operator!=(const CAssetId& other) const { return id != other.id; }
|
||||
bool operator<(const CAssetId& other) const { return id < other.id; }
|
||||
@@ -39,6 +39,7 @@ struct SObjectTag
|
||||
{
|
||||
FourCC type;
|
||||
CAssetId id;
|
||||
|
||||
operator bool() const { return id.IsValid(); }
|
||||
bool operator!=(const SObjectTag& other) const { return id != other.id; }
|
||||
bool operator==(const SObjectTag& other) const { return id == other.id; }
|
||||
@@ -65,11 +66,11 @@ struct TEditorId
|
||||
u8 LayerNum() const { return u8((id >> 26) & 0x3f); }
|
||||
u16 AreaNum() const { return u16((id >> 16) & 0x3ff); }
|
||||
u16 Id() const { return u16(id & 0xffff); }
|
||||
|
||||
bool operator<(const TEditorId& other) const { return (id & 0x3ffffff) < (other.id & 0x3ffffff); }
|
||||
bool operator!=(const TEditorId& other) const { return (id & 0x3ffffff) != (other.id & 0x3ffffff); }
|
||||
bool operator==(const TEditorId& other) const { return (id & 0x3ffffff) == (other.id & 0x3ffffff); }
|
||||
};
|
||||
|
||||
#define kInvalidEditorId TEditorId()
|
||||
|
||||
struct TUniqueId
|
||||
@@ -77,9 +78,8 @@ struct TUniqueId
|
||||
TUniqueId() = default;
|
||||
TUniqueId(u16 value, u16 version) : id(value | (version << 10)) {}
|
||||
u16 id = u16(-1);
|
||||
|
||||
u16 Version() const { return u16((id >> 10) & 0x3f);}
|
||||
u16 Value() const { return u16(id & 0x3ff);}
|
||||
u16 Version() const { return u16((id >> 10) & 0x3f); }
|
||||
u16 Value() const { return u16(id & 0x3ff); }
|
||||
bool operator<(const TUniqueId& other) const { return (id < other.id); }
|
||||
bool operator!=(const TUniqueId& other) const { return (id != other.id); }
|
||||
bool operator==(const TUniqueId& other) const { return (id == other.id); }
|
||||
@@ -90,7 +90,6 @@ struct TUniqueId
|
||||
using TAreaId = s32;
|
||||
|
||||
#define kInvalidAreaId TAreaId(-1)
|
||||
}
|
||||
|
||||
#if 0
|
||||
template <class T, size_t N>
|
||||
@@ -113,7 +112,7 @@ public:
|
||||
};
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
template<class T>
|
||||
T GetAverage(const T* v, s32 count)
|
||||
{
|
||||
T r = v[0];
|
||||
@@ -123,11 +122,12 @@ T GetAverage(const T* v, s32 count)
|
||||
return r / count;
|
||||
}
|
||||
|
||||
template <class T, size_t N>
|
||||
template<class T, size_t N>
|
||||
class TReservedAverage : rstl::reserved_vector<T, N>
|
||||
{
|
||||
public:
|
||||
TReservedAverage() = default;
|
||||
|
||||
TReservedAverage(const T& t) { rstl::reserved_vector<T, N>::resize(N, t); }
|
||||
|
||||
void AddValue(const T& t)
|
||||
@@ -135,8 +135,7 @@ public:
|
||||
if (this->size() < N)
|
||||
{
|
||||
this->insert(this->begin(), t);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
this->pop_back();
|
||||
this->insert(this->begin(), t);
|
||||
@@ -148,7 +147,7 @@ public:
|
||||
if (this->empty())
|
||||
return {};
|
||||
|
||||
return {::GetAverage<T>(this->data(), this->size())};
|
||||
return {urde::GetAverage<T>(this->data(), this->size())};
|
||||
}
|
||||
|
||||
rstl::optional_object<T> GetEntry(int i) const
|
||||
@@ -163,18 +162,20 @@ public:
|
||||
size_t Size() const { return this->size(); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<urde::SObjectTag>
|
||||
{
|
||||
inline size_t operator()(const urde::SObjectTag& tag) const { return tag.id.Value(); }
|
||||
size_t operator()(const urde::SObjectTag& tag) const noexcept { return tag.id.Value(); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash<urde::CAssetId>
|
||||
{
|
||||
inline size_t operator()(const urde::CAssetId& id) const { return id.Value(); }
|
||||
size_t operator()(const urde::CAssetId& id) const noexcept { return id.Value(); }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define __URDE_CAIFUNCMAP_HPP__
|
||||
|
||||
#include "RetroTypes.hpp"
|
||||
#include <unordered_map>
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "RetroTypes.hpp"
|
||||
#include "CToken.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "CWorldLight.hpp"
|
||||
#include <cfloat>
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user