mirror of https://github.com/AxioDL/metaforce.git
TLockedToken cached pointer
This commit is contained in:
parent
259eb89b00
commit
718436d2a6
|
@ -202,7 +202,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template <class T>
|
||||||
class TToken : public CToken
|
class TToken : public CToken
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -212,17 +212,21 @@ public:
|
||||||
}
|
}
|
||||||
TToken() = default;
|
TToken() = default;
|
||||||
TToken(const CToken& other) : CToken(other) {}
|
TToken(const CToken& other) : CToken(other) {}
|
||||||
|
TToken(CToken&& other) : CToken(std::move(other)) {}
|
||||||
TToken(T* obj)
|
TToken(T* obj)
|
||||||
: CToken(GetIObjObjectFor(std::unique_ptr<T>(obj))) {}
|
: CToken(GetIObjObjectFor(std::unique_ptr<T>(obj))) {}
|
||||||
TToken& operator=(T* obj) {*this = CToken(GetIObjObjectFor(obj)); return this;}
|
TToken& operator=(T* obj) {*this = CToken(GetIObjObjectFor(obj)); return this;}
|
||||||
T* GetObj() {return static_cast<TObjOwnerDerivedFromIObj<T>*>(CToken::GetObj())->GetObj();}
|
T* GetObj() {return static_cast<TObjOwnerDerivedFromIObj<T>*>(CToken::GetObj())->GetObj();}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template <class T>
|
||||||
class TLockedToken : public TToken<T>
|
class TLockedToken : public TToken<T>
|
||||||
{
|
{
|
||||||
|
T* m_obj;
|
||||||
public:
|
public:
|
||||||
TLockedToken(const CToken& other) : TToken<T>(other) {CToken::Lock();}
|
TLockedToken(const CToken& other) : TToken<T>(other) {m_obj = TToken<T>::GetObj();}
|
||||||
|
TLockedToken(CToken&& other) : TToken<T>(std::move(other)) {m_obj = TToken<T>::GetObj();}
|
||||||
|
T* GetObj() {return m_obj;}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#include "CElementGen.hpp"
|
||||||
|
#include "CGenDescription.hpp"
|
||||||
|
|
||||||
|
namespace Retro
|
||||||
|
{
|
||||||
|
|
||||||
|
CElementGen::CElementGen(const TToken<CGenDescription>& gen,
|
||||||
|
EModelOrientationType orientType,
|
||||||
|
EOptionalSystemFlags flags)
|
||||||
|
: x1c_genDesc(gen), x28_orientType(orientType)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,24 +5,62 @@
|
||||||
#include "CTransform.hpp"
|
#include "CTransform.hpp"
|
||||||
#include "CColor.hpp"
|
#include "CColor.hpp"
|
||||||
#include "CAABox.hpp"
|
#include "CAABox.hpp"
|
||||||
|
#include "CToken.hpp"
|
||||||
|
|
||||||
namespace Retro
|
namespace Retro
|
||||||
{
|
{
|
||||||
class CWarp;
|
class CWarp;
|
||||||
class CLight;
|
class CLight;
|
||||||
class CGenDescription
|
class CGenDescription;
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
class CElementGen
|
class CElementGen
|
||||||
{
|
{
|
||||||
bool x68_particleEmission;
|
public:
|
||||||
float x78_generatorRate;
|
enum class EModelOrientationType
|
||||||
|
{
|
||||||
|
};
|
||||||
|
enum class EOptionalSystemFlags
|
||||||
|
{
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
TLockedToken<CGenDescription> x1c_genDesc;
|
||||||
|
EModelOrientationType x28_orientType;
|
||||||
|
u32 x30 = 0;
|
||||||
|
u32 x34 = 0;
|
||||||
|
u32 x38 = 0;
|
||||||
|
u32 x40 = 0;
|
||||||
|
u32 x44 = 0;
|
||||||
|
u32 x48 = 0;
|
||||||
|
u32 x4c = 0;
|
||||||
|
u32 x50 = 0;
|
||||||
|
float x58 = 0.f;
|
||||||
|
u32 x64 = -1;
|
||||||
|
bool x68_particleEmission = true;
|
||||||
|
float x6c = 0.f;
|
||||||
|
u32 x70 = 0;
|
||||||
|
u16 x74 = 99;
|
||||||
|
float x78_generatorRate = 1.f;
|
||||||
|
float x7c = 0.f;
|
||||||
|
float x80 = 0.f;
|
||||||
|
float x84 = 0.f;
|
||||||
|
float x88 = 0.f;
|
||||||
|
float x8c = 0.f;
|
||||||
|
float x90 = 0.f;
|
||||||
|
float x94 = 0.f;
|
||||||
|
float x98 = 0.f;
|
||||||
|
float x9c = 0.f;
|
||||||
|
float xa0 = 1.f;
|
||||||
|
float xa4 = 1.f;
|
||||||
|
float xa8 = 1.f;
|
||||||
|
Zeus::CTransform xac = Zeus::CTransform::Identity();
|
||||||
Zeus::CVector3f x88_globalTranslation;
|
Zeus::CVector3f x88_globalTranslation;
|
||||||
Zeus::CTransform x1d8_globalOrientation;
|
Zeus::CTransform x1d8_globalOrientation;
|
||||||
std::vector<CElementGen> x240_children;
|
std::vector<CElementGen> x240_children;
|
||||||
std::vector<CElementGen> x254_children;
|
std::vector<CElementGen> x254_children;
|
||||||
public:
|
public:
|
||||||
|
CElementGen(const TToken<CGenDescription>& gen, EModelOrientationType orientType, EOptionalSystemFlags flags);
|
||||||
|
virtual ~CElementGen() = default;
|
||||||
|
|
||||||
virtual const Zeus::CVector3f& GetGlobalTranslation() const
|
virtual const Zeus::CVector3f& GetGlobalTranslation() const
|
||||||
{ return x88_globalTranslation; }
|
{ return x88_globalTranslation; }
|
||||||
virtual const Zeus::CTransform& GetGlobalOrientation() const
|
virtual const Zeus::CTransform& GetGlobalOrientation() const
|
||||||
|
@ -49,7 +87,6 @@ public:
|
||||||
}
|
}
|
||||||
void BuildParticleSystemBounds();
|
void BuildParticleSystemBounds();
|
||||||
|
|
||||||
virtual ~CElementGen() {}
|
|
||||||
virtual void Update(double);
|
virtual void Update(double);
|
||||||
virtual void Render();
|
virtual void Render();
|
||||||
virtual void SetOrientation(const Zeus::CTransform&);
|
virtual void SetOrientation(const Zeus::CTransform&);
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Retro
|
||||||
|
|
||||||
CUVEAnimTexture::CUVEAnimTexture(TToken<CTexture>&& tex, CIntElement* a, CIntElement* b,
|
CUVEAnimTexture::CUVEAnimTexture(TToken<CTexture>&& tex, CIntElement* a, CIntElement* b,
|
||||||
CIntElement* c, CIntElement* d, CIntElement* e, bool f)
|
CIntElement* c, CIntElement* d, CIntElement* e, bool f)
|
||||||
: x4_tex(std::move(tex)), xc_directTex(x4_tex.GetObj()), x24_loop(f), x28_cycleFrameRate(e)
|
: x4_tex(std::move(tex)), x24_loop(f), x28_cycleFrameRate(e)
|
||||||
{
|
{
|
||||||
a->GetValue(0, x10_tileW);
|
a->GetValue(0, x10_tileW);
|
||||||
delete a;
|
delete a;
|
||||||
|
@ -16,8 +16,8 @@ CUVEAnimTexture::CUVEAnimTexture(TToken<CTexture>&& tex, CIntElement* a, CIntEle
|
||||||
d->GetValue(0, x1c_strideH);
|
d->GetValue(0, x1c_strideH);
|
||||||
delete d;
|
delete d;
|
||||||
|
|
||||||
int width = xc_directTex->GetWidth();
|
int width = x4_tex.GetObj()->GetWidth();
|
||||||
int height = xc_directTex->GetHeight();
|
int height = x4_tex.GetObj()->GetHeight();
|
||||||
float widthF = width;
|
float widthF = width;
|
||||||
float heightF = height;
|
float heightF = height;
|
||||||
int xTiles = std::max(1, width / x18_strideW);
|
int xTiles = std::max(1, width / x18_strideW);
|
||||||
|
|
|
@ -9,14 +9,6 @@ namespace Retro
|
||||||
{
|
{
|
||||||
class CToken;
|
class CToken;
|
||||||
|
|
||||||
struct SUVElementTexture
|
|
||||||
{
|
|
||||||
TToken<CTexture> m_tex;
|
|
||||||
CTexture* m_directTex;
|
|
||||||
SUVElementTexture(TToken<CTexture>&& tex, CTexture* directTex)
|
|
||||||
: m_tex(std::move(tex)), m_directTex(directTex) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SUVElementSet
|
struct SUVElementSet
|
||||||
{
|
{
|
||||||
float xMin, yMin, xMax, yMax;
|
float xMin, yMin, xMax, yMax;
|
||||||
|
@ -25,7 +17,7 @@ struct SUVElementSet
|
||||||
class CUVElement : public IElement
|
class CUVElement : public IElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual SUVElementTexture GetValueTexture(int frame) const=0;
|
virtual TLockedToken<CTexture> GetValueTexture(int frame) const=0;
|
||||||
virtual void GetValueUV(int frame, SUVElementSet& valOut) const=0;
|
virtual void GetValueUV(int frame, SUVElementSet& valOut) const=0;
|
||||||
virtual bool HasConstantTexture() const=0;
|
virtual bool HasConstantTexture() const=0;
|
||||||
virtual bool HasConstantUV() const=0;
|
virtual bool HasConstantUV() const=0;
|
||||||
|
@ -33,14 +25,13 @@ public:
|
||||||
|
|
||||||
struct CUVEConstant : public CUVElement
|
struct CUVEConstant : public CUVElement
|
||||||
{
|
{
|
||||||
TToken<CTexture> x4_tex;
|
TLockedToken<CTexture> x4_tex;
|
||||||
CTexture* xc_directTex;
|
|
||||||
public:
|
public:
|
||||||
CUVEConstant(TToken<CTexture>&& tex)
|
CUVEConstant(TToken<CTexture>&& tex)
|
||||||
: x4_tex(std::move(tex)), xc_directTex(x4_tex.GetObj()) {}
|
: x4_tex(std::move(tex)) {}
|
||||||
SUVElementTexture GetValueTexture(int frame) const
|
TLockedToken<CTexture> GetValueTexture(int frame) const
|
||||||
{
|
{
|
||||||
return SUVElementTexture(TLockedToken<CTexture>(x4_tex), xc_directTex);
|
return TLockedToken<CTexture>(x4_tex);
|
||||||
}
|
}
|
||||||
void GetValueUV(int frame, SUVElementSet& valOut) const
|
void GetValueUV(int frame, SUVElementSet& valOut) const
|
||||||
{
|
{
|
||||||
|
@ -52,8 +43,7 @@ public:
|
||||||
|
|
||||||
struct CUVEAnimTexture : public CUVElement
|
struct CUVEAnimTexture : public CUVElement
|
||||||
{
|
{
|
||||||
TToken<CTexture> x4_tex;
|
TLockedToken<CTexture> x4_tex;
|
||||||
CTexture* xc_directTex;
|
|
||||||
int x10_tileW, x14_tileH, x18_strideW, x1c_strideH;
|
int x10_tileW, x14_tileH, x18_strideW, x1c_strideH;
|
||||||
int x20_tiles;
|
int x20_tiles;
|
||||||
bool x24_loop;
|
bool x24_loop;
|
||||||
|
@ -62,9 +52,9 @@ struct CUVEAnimTexture : public CUVElement
|
||||||
public:
|
public:
|
||||||
CUVEAnimTexture(TToken<CTexture>&& tex, CIntElement* a, CIntElement* b,
|
CUVEAnimTexture(TToken<CTexture>&& tex, CIntElement* a, CIntElement* b,
|
||||||
CIntElement* c, CIntElement* d, CIntElement* e, bool f);
|
CIntElement* c, CIntElement* d, CIntElement* e, bool f);
|
||||||
SUVElementTexture GetValueTexture(int frame) const
|
TLockedToken<CTexture> GetValueTexture(int frame) const
|
||||||
{
|
{
|
||||||
return SUVElementTexture(TLockedToken<CTexture>(x4_tex), xc_directTex);
|
return TLockedToken<CTexture>(x4_tex);
|
||||||
}
|
}
|
||||||
void GetValueUV(int frame, SUVElementSet& valOut) const;
|
void GetValueUV(int frame, SUVElementSet& valOut) const;
|
||||||
bool HasConstantTexture() const {return true;}
|
bool HasConstantTexture() const {return true;}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 56dfa0a19591b46e4735c77e6a28fdbff5aa84ed
|
Subproject commit 16b7449c0a2ea2e2824bf0cbd3936ecd59e04cba
|
Loading…
Reference in New Issue