CCharacterFactory imps

This commit is contained in:
Jack Andersen 2016-04-14 17:02:21 -10:00
parent 8608b52774
commit c91bfade75
29 changed files with 254 additions and 82 deletions

View File

@ -40,7 +40,7 @@ size_t ComputeBitstreamSize(size_t keyFrameCount, const std::vector<Channel>& ch
static inline QuantizedRot QuantizeRotation(const Value& quat, atUint32 div) static inline QuantizedRot QuantizeRotation(const Value& quat, atUint32 div)
{ {
float q = M_PI / 2.0f / float(div); float q = M_PIF / 2.0f / float(div);
return return
{ {
{ {
@ -54,7 +54,7 @@ static inline QuantizedRot QuantizeRotation(const Value& quat, atUint32 div)
static inline Value DequantizeRotation(const QuantizedRot& v, atUint32 div) static inline Value DequantizeRotation(const QuantizedRot& v, atUint32 div)
{ {
float q = M_PI / 2.0f / float(div); float q = M_PIF / 2.0f / float(div);
Value retval = Value retval =
{ {
0.0f, 0.0f,

View File

@ -38,6 +38,7 @@ add_executable(urde WIN32 MACOSX_BUNDLE
target_link_libraries(urde target_link_libraries(urde
UrdeLocales UrdeLocales
UrdeIcons UrdeIcons
RuntimeMP1
RuntimeCommonCharacter RuntimeCommonCharacter
RuntimeCommonInput RuntimeCommonInput
RuntimeCommonParticle RuntimeCommonParticle

View File

@ -11,6 +11,7 @@
#include "Runtime/Graphics/CMoviePlayer.hpp" #include "Runtime/Graphics/CMoviePlayer.hpp"
#include "Runtime/Graphics/CModel.hpp" #include "Runtime/Graphics/CModel.hpp"
#include "Runtime/Particle/CGenDescription.hpp" #include "Runtime/Particle/CGenDescription.hpp"
#include "Runtime/Character/CAssetFactory.hpp"
namespace urde namespace urde
{ {
@ -32,6 +33,7 @@ class ViewManager : public specter::IViewManager
boo::GraphicsDataToken m_iconsToken; boo::GraphicsDataToken m_iconsToken;
specter::Translator m_translator; specter::Translator m_translator;
std::unique_ptr<boo::IWindow> m_mainWindow; std::unique_ptr<boo::IWindow> m_mainWindow;
CCharacterFactoryBuilder m_test;
std::unique_ptr<specter::RootView> m_rootView; std::unique_ptr<specter::RootView> m_rootView;
std::unique_ptr<SplashScreen> m_splash; std::unique_ptr<SplashScreen> m_splash;

View File

@ -69,7 +69,7 @@ add_library(RuntimeCommon
CPlayMovieBase.hpp CPlayMovieBase.hpp
CGameDebug.hpp CGameDebug.cpp CGameDebug.hpp CGameDebug.cpp
rstl.hpp rstl.cpp rstl.hpp rstl.cpp
GameGlobalObjects.hpp GameGlobalObjects.hpp GameGlobalObjects.cpp
RetroTypes.hpp RetroTypes.hpp
GCNTypes.hpp GCNTypes.hpp
${PLAT_SRCS}) ${PLAT_SRCS})

View File

@ -71,6 +71,7 @@ IAllocator& CMemorySys::GetGameAllocator() {return g_gameAllocator;}
} }
#if 0
void* operator new(std::size_t sz) void* operator new(std::size_t sz)
{ {
if (!urde::g_memoryAllocatorReady) if (!urde::g_memoryAllocatorReady)
@ -140,3 +141,5 @@ void operator delete[](void* ptr) noexcept
} }
urde::CMemory::Free(ptr); urde::CMemory::Free(ptr);
} }
#endif

View File

@ -30,7 +30,7 @@ public:
} }
/* Custom new funcs */ /* Custom new funcs */
void* operator new(std::size_t sz, const char* funcName, const char* typeName); //void* operator new(std::size_t sz, const char* funcName, const char* typeName);
void* operator new[](std::size_t sz, const char* funcName, const char* typeName); //void* operator new[](std::size_t sz, const char* funcName, const char* typeName);
#endif // __URDE_CMEMORY_HPP__ #endif // __URDE_CMEMORY_HPP__

View File

@ -11,17 +11,12 @@ CSimplePool::CSimplePool(IFactory& factory)
CToken CSimplePool::GetObj(const SObjectTag& tag, const CVParamTransfer& paramXfer) CToken CSimplePool::GetObj(const SObjectTag& tag, const CVParamTransfer& paramXfer)
{ {
auto iter = std::find_if(x4_resources.begin(), x4_resources.end(), auto iter = x4_resources.find(tag);
[&tag](std::pair<SObjectTag, CObjectReference*> pair) -> bool
{
return pair.first == tag;
});
if (iter != x4_resources.end()) if (iter != x4_resources.end())
return CToken(iter->second); return CToken(iter->second);
CObjectReference* ret = new CObjectReference(*this, std::unique_ptr<IObj>(), tag, paramXfer); CObjectReference* ret = new CObjectReference(*this, std::unique_ptr<IObj>(), tag, paramXfer);
x4_resources.push_back(std::make_pair<SObjectTag, CObjectReference*>((SObjectTag)tag, std::move(ret))); x4_resources.emplace(std::make_pair<SObjectTag, CObjectReference*>((SObjectTag)tag, std::move(ret)));
return CToken(ret); return CToken(ret);
} }
@ -45,16 +40,18 @@ CToken CSimplePool::GetObj(const char* resourceName, const CVParamTransfer& para
bool CSimplePool::HasObject(const SObjectTag& tag) const bool CSimplePool::HasObject(const SObjectTag& tag) const
{ {
auto iter = std::find_if(x4_resources.begin(), x4_resources.end(), [&tag](std::pair<SObjectTag, CObjectReference*> pair)->bool{ auto iter = x4_resources.find(tag);
return pair.first == tag; if (iter != x4_resources.cend())
}); return true;
return x30_factory.CanBuild(tag);
return iter != x4_resources.end();
} }
bool CSimplePool::ObjectIsLive(const SObjectTag&) const bool CSimplePool::ObjectIsLive(const SObjectTag& tag) const
{ {
return false; auto iter = x4_resources.find(tag);
if (iter == x4_resources.cend())
return false;
return iter->second->IsLoaded();
} }
void CSimplePool::Flush() void CSimplePool::Flush()
@ -63,9 +60,7 @@ void CSimplePool::Flush()
void CSimplePool::ObjectUnreferenced(const SObjectTag& tag) void CSimplePool::ObjectUnreferenced(const SObjectTag& tag)
{ {
auto iter = std::find_if(x4_resources.begin(), x4_resources.end(), [&tag](std::pair<SObjectTag, CObjectReference*> pair)->bool{ auto iter = x4_resources.find(tag);
return pair.first == tag;
});
if (iter != x4_resources.end()) if (iter != x4_resources.end())
x4_resources.erase(iter); x4_resources.erase(iter);
} }

View File

@ -14,8 +14,8 @@ class CObjectReference;
class CSimplePool : public IObjectStore class CSimplePool : public IObjectStore
{ {
protected: protected:
std::list<std::pair<SObjectTag, CObjectReference*>> x4_resources; //std::list<std::pair<SObjectTag, CObjectReference*>> x4_resources;
//std::unordered_map<SObjectTag, CObjectReference*> x4_resources; std::unordered_map<SObjectTag, CObjectReference*> x4_resources;
IFactory& x30_factory; IFactory& x30_factory;
CVParamTransfer x34_paramXfer; CVParamTransfer x34_paramXfer;
public: public:

View File

@ -21,7 +21,7 @@ public:
const std::weak_ptr<CPlayerState>&, const std::weak_ptr<CPlayerState>&,
const std::weak_ptr<CWorldTransManager>&); const std::weak_ptr<CWorldTransManager>&);
const std::shared_ptr<CPlayerState> GetPlayerState() const {return x8b8_playerState;} const std::shared_ptr<CPlayerState>& GetPlayerState() const {return x8b8_playerState;}
void GetObjectListById() const void GetObjectListById() const
{ {

View File

@ -18,9 +18,12 @@ void CAnimData::InitializeCache()
{ {
} }
CAnimData::CAnimData(ResId id, const CCharacterInfo& character, int a, int b, bool c, CAnimData::CAnimData(ResId id,
const CCharacterInfo& character,
int defaultAnim, int charIdx, bool loop,
const TLockedToken<CCharLayoutInfo>& layout, const TLockedToken<CCharLayoutInfo>& layout,
const TToken<CSkinnedModel>& model, const TToken<CSkinnedModel>& model,
const std::experimental::optional<TToken<CMorphableSkinnedModel>>& iceModel,
const std::weak_ptr<CAnimSysContext>& ctx, const std::weak_ptr<CAnimSysContext>& ctx,
const std::shared_ptr<CAnimationManager>& animMgr, const std::shared_ptr<CAnimationManager>& animMgr,
const std::shared_ptr<CTransitionManager>& transMgr, const std::shared_ptr<CTransitionManager>& transMgr,
@ -33,12 +36,14 @@ CAnimData::CAnimData(ResId id, const CCharacterInfo& character, int a, int b, bo
x100_animMgr(animMgr), x100_animMgr(animMgr),
x1d8_selfId(id), x1d8_selfId(id),
x1fc_transMgr(transMgr), x1fc_transMgr(transMgr),
x204_b(b), x204_charIdx(charIdx),
x208_a(a), x208_defaultAnim(defaultAnim),
x21c_25_loop(c), x21c_25_loop(loop),
x220_pose(layout->GetSegIdList().GetList().size()), x220_pose(layout->GetSegIdList().GetList().size()),
x2f8_poseBuilder(layout) x2f8_poseBuilder(layout)
{ {
if (iceModel)
xe4_iceModelData = *iceModel;
} }
ResId CAnimData::GetEventResourceIdForAnimResourceId(ResId) const ResId CAnimData::GetEventResourceIdForAnimResourceId(ResId) const

View File

@ -17,6 +17,7 @@ namespace urde
{ {
class CCharLayoutInfo; class CCharLayoutInfo;
class CSkinnedModel; class CSkinnedModel;
class CMorphableSkinnedModel;
class CAnimSysContext; class CAnimSysContext;
class CAnimationManager; class CAnimationManager;
class CTransitionManager; class CTransitionManager;
@ -44,7 +45,7 @@ class CAnimData
CCharacterInfo xc_charInfo; CCharacterInfo xc_charInfo;
TLockedToken<CCharLayoutInfo> xcc_layoutData; TLockedToken<CCharLayoutInfo> xcc_layoutData;
TCachedToken<CSkinnedModel> xd8_modelData; TCachedToken<CSkinnedModel> xd8_modelData;
// TLockedToken<CSkinnedModelWithAvgNormals> xe4_modelAvgNormalData; TLockedToken<CMorphableSkinnedModel> xe4_iceModelData;
std::shared_ptr<CSkinnedModel> xf4_xrayModel; std::shared_ptr<CSkinnedModel> xf4_xrayModel;
std::shared_ptr<CSkinnedModel> xf8_infraModel; std::shared_ptr<CSkinnedModel> xf8_infraModel;
std::shared_ptr<CAnimSysContext> xfc_animCtx; std::shared_ptr<CAnimSysContext> xfc_animCtx;
@ -59,8 +60,8 @@ class CAnimData
std::shared_ptr<CTransitionManager> x1fc_transMgr; std::shared_ptr<CTransitionManager> x1fc_transMgr;
float x200_ = 1.f; float x200_ = 1.f;
u32 x204_b; u32 x204_charIdx;
u16 x208_a; u16 x208_defaultAnim;
u32 x20c_passedBoolCount = 0; u32 x20c_passedBoolCount = 0;
u32 x210_passedIntCount = 0; u32 x210_passedIntCount = 0;
u32 x214_passedParticleCount = 0; u32 x214_passedParticleCount = 0;
@ -98,9 +99,12 @@ class CAnimData
u32 x1044_ = 0; u32 x1044_ = 0;
public: public:
CAnimData(ResId, const CCharacterInfo& character, int a, int b, bool c, CAnimData(ResId,
const CCharacterInfo& character,
int defaultAnim, int charIdx, bool loop,
const TLockedToken<CCharLayoutInfo>& layout, const TLockedToken<CCharLayoutInfo>& layout,
const TToken<CSkinnedModel>& model, const TToken<CSkinnedModel>& model,
const std::experimental::optional<TToken<CMorphableSkinnedModel>>& iceModel,
const std::weak_ptr<CAnimSysContext>& ctx, const std::weak_ptr<CAnimSysContext>& ctx,
const std::shared_ptr<CAnimationManager>& animMgr, const std::shared_ptr<CAnimationManager>& animMgr,
const std::shared_ptr<CTransitionManager>& transMgr, const std::shared_ptr<CTransitionManager>& transMgr,

View File

@ -1,6 +1,52 @@
#include "CAssetFactory.hpp" #include "CAssetFactory.hpp"
#include "CAnimCharacterSet.hpp"
#include "CCharacterFactory.hpp"
#include "GameGlobalObjects.hpp"
#include "CModelData.hpp"
namespace urde namespace urde
{ {
CFactoryFnReturn CCharacterFactoryBuilder::CDummyFactory::Build(const SObjectTag& tag,
const CVParamTransfer&)
{
TLockedToken<CAnimCharacterSet> ancs =
g_SimplePool->GetObj({SBIG('ANCS'), tag.id});
return TToken<CCharacterFactory>::GetIObjObjectFor(
std::make_unique<CCharacterFactory>(*g_SimplePool, *ancs.GetObj(), tag.id));
}
void CCharacterFactoryBuilder::CDummyFactory::BuildAsync(const SObjectTag& tag,
const CVParamTransfer& parms,
IObj** objOut)
{
*objOut = Build(tag, parms).release();
}
void CCharacterFactoryBuilder::CDummyFactory::CancelBuild(const SObjectTag&)
{
}
bool CCharacterFactoryBuilder::CDummyFactory::CanBuild(const SObjectTag&)
{
return true;
}
const SObjectTag* CCharacterFactoryBuilder::CDummyFactory::GetResourceIdByName(const char*) const
{
return nullptr;
}
FourCC CCharacterFactoryBuilder::CDummyFactory::GetResourceTypeById(ResId id) const
{
return {};
}
CCharacterFactoryBuilder::CCharacterFactoryBuilder() : x4_dummyStore(x0_dummyFactory) {}
TToken<CCharacterFactory> CCharacterFactoryBuilder::GetFactory(const CAnimRes& res)
{
return x4_dummyStore.GetObj({SBIG('ANCS'), res.x0_ancsId});
}
} }

View File

@ -4,21 +4,33 @@
#include "IFactory.hpp" #include "IFactory.hpp"
#include "IObj.hpp" #include "IObj.hpp"
#include "CToken.hpp" #include "CToken.hpp"
#include "CSimplePool.hpp"
namespace urde namespace urde
{ {
class CCharacterFactory; class CCharacterFactory;
class CAnimRes; class CAnimRes;
class CCharacterFactoryBuilder : public IFactory class CCharacterFactoryBuilder
{ {
public: public:
std::unique_ptr<IObj> Build(const SObjectTag&, const CVParamTransfer&) {return std::unique_ptr<IObj>();} class CDummyFactory : public IFactory
void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**) {} {
void CancelBuild(const SObjectTag&) {} public:
bool CanBuild(const SObjectTag&) {return false;} CFactoryFnReturn Build(const SObjectTag&, const CVParamTransfer&);
const SObjectTag* GetResourceIdByName(const char*) const {return nullptr;} void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**);
FourCC GetResourceTypeById(ResId id) const {return {};} void CancelBuild(const SObjectTag&);
bool CanBuild(const SObjectTag&);
const SObjectTag* GetResourceIdByName(const char*) const;
FourCC GetResourceTypeById(ResId id) const;
};
private:
CDummyFactory x0_dummyFactory;
CSimplePool x4_dummyStore;
public:
CCharacterFactoryBuilder();
TToken<CCharacterFactory> GetFactory(const CAnimRes& res); TToken<CCharacterFactory> GetFactory(const CAnimRes& res);
}; };

View File

@ -7,17 +7,48 @@
#include "CTransitionManager.hpp" #include "CTransitionManager.hpp"
#include "CRandom16.hpp" #include "CRandom16.hpp"
#include "CPrimitive.hpp" #include "CPrimitive.hpp"
#include "CAnimData.hpp"
#include "GameGlobalObjects.hpp"
#include "Graphics/CSkinnedModel.hpp"
namespace urde namespace urde
{ {
CFactoryFnReturn CCharacterFactory::CDummyFactory::Build(const SObjectTag&, const CVParamTransfer&) CFactoryFnReturn CCharacterFactory::CDummyFactory::Build(const SObjectTag& tag,
const CVParamTransfer& params)
{ {
const CCharacterInfo& charInfo =
*static_cast<TObjOwnerParam<const CCharacterInfo*>&>(*params.GetObj()).GetParam();
switch (tag.type.toUint32())
{
case 0:
return TToken<CSkinnedModel>::GetIObjObjectFor(
std::make_unique<CSkinnedModel>(*g_SimplePool,
charInfo.GetModelId(),
charInfo.GetSkinRulesId(),
charInfo.GetCharLayoutInfoId(),
CSkinnedModel::EDataOwnership::One));
case 1:
return TToken<CSkinnedModel>::GetIObjObjectFor(
std::make_unique<CMorphableSkinnedModel>(*g_SimplePool,
charInfo.GetIceModelId(),
charInfo.GetIceSkinRulesId(),
charInfo.GetCharLayoutInfoId(),
CSkinnedModel::EDataOwnership::One));
default:
break;
}
return {}; return {};
} }
void CCharacterFactory::CDummyFactory::BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**) void CCharacterFactory::CDummyFactory::BuildAsync(const SObjectTag& tag,
const CVParamTransfer& parms,
IObj** objOut)
{ {
*objOut = Build(tag, parms).release();
} }
void CCharacterFactory::CDummyFactory::CancelBuild(const SObjectTag&) void CCharacterFactory::CDummyFactory::CancelBuild(const SObjectTag&)
@ -36,10 +67,40 @@ const SObjectTag* CCharacterFactory::CDummyFactory::GetResourceIdByName(const ch
FourCC CCharacterFactory::CDummyFactory::GetResourceTypeById(ResId id) const FourCC CCharacterFactory::CDummyFactory::GetResourceTypeById(ResId id) const
{ {
return {};
} }
ResId CCharacterFactory::GetEventResourceIdForAnimResourceId(ResId) const std::unique_ptr<CAnimData>
CCharacterFactory::CreateCharacter(int charIdx, bool loop,
const TLockedToken<CCharacterFactory>& factory,
int defaultAnim) const
{ {
const CCharacterInfo& charInfo = x4_charInfoDB[charIdx];
CVParamTransfer charParm(new TObjOwnerParam<const CCharacterInfo*>(&charInfo));
TToken<CSkinnedModel> skinnedModel =
((CCharacterFactory*)this)->x70_cacheResPool.GetObj({FourCC(), charInfo.GetModelId()}, charParm);
std::experimental::optional<TToken<CMorphableSkinnedModel>> iceModel;
if (charInfo.GetIceModelId() && charInfo.GetIceSkinRulesId())
iceModel.emplace(((CCharacterFactory*)this)->x70_cacheResPool.GetObj({FourCC(1), charInfo.GetIceModelId()}, charParm));
return std::make_unique<CAnimData>(x68_selfId, charInfo, defaultAnim, charIdx, loop,
x14_charLayoutInfoDB[charIdx], skinnedModel,
iceModel, x24_sysContext, x28_animMgr, x2c_transMgr,
factory);
}
ResId CCharacterFactory::GetEventResourceIdForAnimResourceId(ResId id) const
{
auto search = std::find_if(x58_animResources.cbegin(), x58_animResources.cend(),
[&](const std::pair<ResId, ResId>& elem) -> bool
{
return id == elem.first;
});
if (search == x58_animResources.cend())
return -1;
return search->second;
} }
std::vector<CCharacterInfo> std::vector<CCharacterInfo>

View File

@ -56,7 +56,9 @@ private:
public: public:
CCharacterFactory(CSimplePool& store, const CAnimCharacterSet& ancs, ResId); CCharacterFactory(CSimplePool& store, const CAnimCharacterSet& ancs, ResId);
std::unique_ptr<CAnimData> CreateCharacter(int, bool, const TLockedToken<CCharacterFactory>& factory, int) const; std::unique_ptr<CAnimData> CreateCharacter(int charIdx, bool loop,
const TLockedToken<CCharacterFactory>& factory,
int defaultAnim) const;
ResId GetEventResourceIdForAnimResourceId(ResId animId) const; ResId GetEventResourceIdForAnimResourceId(ResId animId) const;
}; };

View File

@ -41,7 +41,12 @@ private:
public: public:
CCharacterInfo(CInputStream& in); CCharacterInfo(CInputStream& in);
ResId GetModelId() const {return x14_cmdl;}
ResId GetSkinRulesId() const {return x18_cskr;}
ResId GetCharLayoutInfoId() const {return x1c_cinf;} ResId GetCharLayoutInfoId() const {return x1c_cinf;}
ResId GetIceModelId() const {return xa8_cmdlOverlay;}
ResId GetIceSkinRulesId() const {return xac_cskrOverlay;}
}; };
} }

View File

@ -16,13 +16,15 @@
namespace urde namespace urde
{ {
CModelData::~CModelData() {}
CModelData::CModelData() {} CModelData::CModelData() {}
CModelData CModelData::CModelDataNull() {return CModelData();}
CModelData::CModelData(const CStaticRes& res) CModelData::CModelData(const CStaticRes& res)
: x0_particleScale(res.x4_particleScale) : x0_particleScale(res.x4_particleScale)
{ {
IObjectStore& objStore = ProjectManager::g_SharedManager->objectStore(); x1c_normalModel = g_SimplePool->GetObj({SBIG('CMDL'), res.x0_cmdlId});
x1c_normalModel = objStore.GetObj({SBIG('CMDL'), res.x0_cmdlId});
} }
CModelData::CModelData(const CAnimRes& res) CModelData::CModelData(const CAnimRes& res)
@ -96,19 +98,17 @@ void CModelData::SetXRayModel(const std::pair<ResId, ResId>& modelSkin)
{ {
if (modelSkin.first) if (modelSkin.first)
{ {
IObjectStore& objStore = ProjectManager::g_SharedManager->objectStore(); if (g_ResFactory->GetResourceTypeById(modelSkin.first) == SBIG('CMDL'))
IFactory& resFactory = ProjectManager::g_SharedManager->resourceFactoryMP1();
if (resFactory.GetResourceTypeById(modelSkin.first) == SBIG('CMDL'))
{ {
if (xc_animData && modelSkin.second && if (xc_animData && modelSkin.second &&
resFactory.GetResourceTypeById(modelSkin.second) == SBIG('CSKR')) g_ResFactory->GetResourceTypeById(modelSkin.second) == SBIG('CSKR'))
{ {
xc_animData->SetXRayModel(objStore.GetObj({SBIG('CMDL'), modelSkin.first}), xc_animData->SetXRayModel(g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first}),
objStore.GetObj({SBIG('CSKR'), modelSkin.second})); g_SimplePool->GetObj({SBIG('CSKR'), modelSkin.second}));
} }
else else
{ {
x2c_xrayModel = objStore.GetObj({SBIG('CMDL'), modelSkin.first}); x2c_xrayModel = g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first});
} }
} }
} }
@ -118,19 +118,17 @@ void CModelData::SetInfraModel(const std::pair<ResId, ResId>& modelSkin)
{ {
if (modelSkin.first) if (modelSkin.first)
{ {
IObjectStore& objStore = ProjectManager::g_SharedManager->objectStore(); if (g_ResFactory->GetResourceTypeById(modelSkin.first) == SBIG('CMDL'))
IFactory& resFactory = ProjectManager::g_SharedManager->resourceFactoryMP1();
if (resFactory.GetResourceTypeById(modelSkin.first) == SBIG('CMDL'))
{ {
if (xc_animData && modelSkin.second && if (xc_animData && modelSkin.second &&
resFactory.GetResourceTypeById(modelSkin.second) == SBIG('CSKR')) g_ResFactory->GetResourceTypeById(modelSkin.second) == SBIG('CSKR'))
{ {
xc_animData->SetInfraModel(objStore.GetObj({SBIG('CMDL'), modelSkin.first}), xc_animData->SetInfraModel(g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first}),
objStore.GetObj({SBIG('CSKR'), modelSkin.second})); g_SimplePool->GetObj({SBIG('CSKR'), modelSkin.second}));
} }
else else
{ {
x3c_infraModel = objStore.GetObj({SBIG('CMDL'), modelSkin.first}); x3c_infraModel = g_SimplePool->GetObj({SBIG('CMDL'), modelSkin.first});
} }
} }
} }

View File

@ -52,6 +52,9 @@ class CModelData
TLockedToken<CModel> x1c_normalModel; TLockedToken<CModel> x1c_normalModel;
TLockedToken<CModel> x2c_xrayModel; TLockedToken<CModel> x2c_xrayModel;
TLockedToken<CModel> x3c_infraModel; TLockedToken<CModel> x3c_infraModel;
CModelData();
public: public:
enum class EWhichModel enum class EWhichModel
{ {
@ -60,10 +63,11 @@ public:
Thermal Thermal
}; };
CModelData(); ~CModelData();
CModelData(const CStaticRes& res); CModelData(const CStaticRes& res);
CModelData(const CAnimRes& res); CModelData(const CAnimRes& res);
CModelData CModelDataNull() {return CModelData();} CModelData(CModelData&&) = default;
CModelData CModelDataNull();
SAdvancementDeltas GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const; SAdvancementDeltas GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const;
void Render(const CStateManager& stateMgr, const zeus::CTransform& xf, void Render(const CStateManager& stateMgr, const zeus::CTransform& xf,

View File

@ -0,0 +1,19 @@
#include "GameGlobalObjects.hpp"
namespace urde
{
class CMemoryCardSys* g_MemoryCardSys = nullptr;
class IFactory* g_ResFactory = nullptr;
class CSimplePool* g_SimplePool = nullptr;
class CCharacterFactoryBuilder* g_CharFactoryBuilder = nullptr;
class CAiFuncMap* g_AiFuncMap = nullptr;
class CGameState* g_GameState = nullptr;
class CInGameTweakManagerBase* g_TweakManager = nullptr;
class CBooRenderer* g_Renderer = nullptr;
DataSpec::ITweakGame* g_tweakGame = nullptr;
DataSpec::ITweakPlayer* g_tweakPlayer = nullptr;
DataSpec::ITweakPlayerControl* g_tweakPlayerControl = nullptr;
}

View File

@ -8,7 +8,7 @@ namespace urde
{ {
extern class CMemoryCardSys* g_MemoryCardSys; extern class CMemoryCardSys* g_MemoryCardSys;
extern class CResFactory* g_ResFactory; extern class IFactory* g_ResFactory;
extern class CSimplePool* g_SimplePool; extern class CSimplePool* g_SimplePool;
extern class CCharacterFactoryBuilder* g_CharFactoryBuilder; extern class CCharacterFactoryBuilder* g_CharFactoryBuilder;
extern class CAiFuncMap* g_AiFuncMap; extern class CAiFuncMap* g_AiFuncMap;

View File

@ -69,7 +69,7 @@ CLight::CLight(ELightType type,
{ {
case ELightType::Spot: case ELightType::Spot:
{ {
float cosCutoff = std::cos(cutoff * M_PI / 180.0); float cosCutoff = std::cos(cutoff * M_PIF / 180.f);
x30_angleC = 0.f; x30_angleC = 0.f;
x34_angleL = -cosCutoff / (1.0 - cosCutoff); x34_angleL = -cosCutoff / (1.0 - cosCutoff);
x38_angleQ = 1.f / (1.0 - cosCutoff); x38_angleQ = 1.f / (1.0 - cosCutoff);

View File

@ -11,9 +11,22 @@ CSkinnedModel::CSkinnedModel(const TLockedToken<CModel>& model,
} }
CSkinnedModel::CSkinnedModel(IObjectStore& store, ResId model,
ResId skinRules, ResId layoutInfo,
EDataOwnership ownership)
{
}
void CSkinnedModel::Calculate(const CPoseAsTransforms& pose, void CSkinnedModel::Calculate(const CPoseAsTransforms& pose,
const std::experimental::optional<CVertexMorphEffect>&) const std::experimental::optional<CVertexMorphEffect>&)
{ {
} }
CMorphableSkinnedModel::CMorphableSkinnedModel(IObjectStore& store, ResId model,
ResId skinRules, ResId layoutInfo,
EDataOwnership ownership)
: CSkinnedModel(store, model, skinRules, layoutInfo, ownership)
{
}
} }

View File

@ -21,10 +21,16 @@ class CSkinnedModel
TLockedToken<CSkinRules> x10_skinRules; TLockedToken<CSkinRules> x10_skinRules;
TLockedToken<CCharLayoutInfo> x1c_layoutInfo; TLockedToken<CCharLayoutInfo> x1c_layoutInfo;
public: public:
enum class EDataOwnership
{
Zero,
One
};
CSkinnedModel(const TLockedToken<CModel>& model, CSkinnedModel(const TLockedToken<CModel>& model,
const TLockedToken<CSkinRules>& skinRules, const TLockedToken<CSkinRules>& skinRules,
const TLockedToken<CCharLayoutInfo>& layoutInfo); const TLockedToken<CCharLayoutInfo>& layoutInfo);
CSkinnedModel(IObjectStore& store, ResId model, ResId skinRules, ResId layoutInfo); CSkinnedModel(IObjectStore& store, ResId model, ResId skinRules,
ResId layoutInfo, EDataOwnership ownership);
const TLockedToken<CModel>& GetModel() const {return x4_model;} const TLockedToken<CModel>& GetModel() const {return x4_model;}
const TLockedToken<CSkinRules>& GetSkinRules() const {return x10_skinRules;} const TLockedToken<CSkinRules>& GetSkinRules() const {return x10_skinRules;}
@ -34,6 +40,13 @@ public:
void Draw(const CModelFlags& drawFlags) const; void Draw(const CModelFlags& drawFlags) const;
}; };
class CMorphableSkinnedModel : public CSkinnedModel
{
public:
CMorphableSkinnedModel(IObjectStore& store, ResId model, ResId skinRules,
ResId layoutInfo, EDataOwnership ownership);
};
} }
#endif // __URDE_CSKINNEDMODEL_HPP__ #endif // __URDE_CSKINNEDMODEL_HPP__

View File

@ -30,8 +30,6 @@ template<class T>
class TObjOwnerParam : public IVParamObj class TObjOwnerParam : public IVParamObj
{ {
T m_param; T m_param;
protected:
~TObjOwnerParam() {}
public: public:
TObjOwnerParam(T&& obj) : m_param(std::move(obj)) {} TObjOwnerParam(T&& obj) : m_param(std::move(obj)) {}
T& GetParam() {return m_param;} T& GetParam() {return m_param;}

View File

@ -40,9 +40,11 @@ void CMainFlow::SetGameState(EClientFlowStates state, CArchitectureQueue& queue)
g_main->SetGameplayResult(EGameplayResult::Playing); g_main->SetGameplayResult(EGameplayResult::Playing);
break; break;
} }
/* TODO: URDE handling
CResLoader& loader = g_ResFactory->GetLoader(); CResLoader& loader = g_ResFactory->GetLoader();
while (!loader.AreAllPaksLoaded()) while (!loader.AreAllPaksLoaded())
loader.AsyncIdlePakLoading(); loader.AsyncIdlePakLoading();
*/
g_main->LoadAudio(); g_main->LoadAudio();
g_main->RegisterResourceTweaks(); g_main->RegisterResourceTweaks();
queue.Push(std::move(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, new CFrontEndUI(queue)))); queue.Push(std::move(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, new CFrontEndUI(queue))));

View File

@ -9,9 +9,6 @@
namespace urde namespace urde
{ {
DataSpec::ITweakGame* g_tweakGame = nullptr;
DataSpec::ITweakPlayer* g_tweakPlayer = nullptr;
DataSpec::ITweakPlayerControl* g_tweakPlayerControl = nullptr;
namespace MP1 namespace MP1
{ {

View File

@ -42,14 +42,6 @@
namespace urde namespace urde
{ {
CMemoryCardSys* g_MemoryCardSys = nullptr;
CResFactory* g_ResFactory = nullptr;
CSimplePool* g_SimplePool = nullptr;
CCharacterFactoryBuilder* g_CharFactoryBuilder = nullptr;
CAiFuncMap* g_AiFuncMap = nullptr;
CGameState* g_GameState = nullptr;
CInGameTweakManagerBase* g_TweakManager = nullptr;
CBooRenderer* g_Renderer = nullptr;
namespace MP1 namespace MP1
{ {

View File

@ -858,9 +858,9 @@ void CElementGen::UpdatePSTranslationAndOrientation()
zeus::CVector3f angles; zeus::CVector3f angles;
psov->GetValue(x50_curFrame, angles); psov->GetValue(x50_curFrame, angles);
zeus::CTransform xf(x178_orientation); zeus::CTransform xf(x178_orientation);
xf.rotateLocalX(angles[0] * M_PI / 180.f); xf.rotateLocalX(angles[0] * M_PIF / 180.f);
xf.rotateLocalY(angles[1] * M_PI / 180.f); xf.rotateLocalY(angles[1] * M_PIF / 180.f);
xf.rotateLocalZ(angles[2] * M_PI / 180.f); xf.rotateLocalZ(angles[2] * M_PIF / 180.f);
SetOrientation(xf); SetOrientation(xf);
} }
*/ */

@ -1 +1 @@
Subproject commit c4d0d0e8016f2d8f0772e5ad63e2ac1ed2a07915 Subproject commit 65cdadfe16cbb63c0f7d9408e822af31b9d8dab7