mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 15:28:11 -05:00
Reformat code with clang format
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderAddonMapEnts.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderAddonMapEnts::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderClipMap.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderClipMap::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -22,4 +22,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD asset_type_t GetHandlingAssetType() const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderComWorld.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderComWorld::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderFont.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderFont::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderFx.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderFx::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderFxImpactTable.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderFxImpactTable::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderFxWorld.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderFxWorld::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderGameWorldMp.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderGameWorldMp::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderGameWorldSp.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderGameWorldSp::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderGfxImage.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderGfxImage::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "AssetLoaderGfxLightDef.h"
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
std::string AssetLoaderGfxLightDef::GetAssetFilename(const std::string& assetName)
|
||||
@ -32,7 +32,8 @@ bool AssetLoaderGfxLightDef::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderGfxLightDef::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderGfxLightDef::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto filename = GetAssetFilename(assetName);
|
||||
const auto file = searchPath->Open(filename);
|
||||
@ -53,7 +54,7 @@ bool AssetLoaderGfxLightDef::LoadFromRaw(const std::string& assetName, ISearchPa
|
||||
|
||||
auto* imageDependency = reinterpret_cast<XAssetInfo<GfxImage>*>(manager->LoadDependency(ASSET_TYPE_IMAGE, imageName));
|
||||
|
||||
if(!imageDependency)
|
||||
if (!imageDependency)
|
||||
{
|
||||
std::cerr << "Could not load GfxLightDef \"" << assetName << "\" due to missing image \"" << imageName << "\"\n";
|
||||
return false;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -15,6 +15,7 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderGfxWorld.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderGfxWorld::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderLeaderboard.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderLeaderboard::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderLoadedSound.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderLoadedSound::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "AssetLoaderLocalizeEntry.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "Localize/LocalizeCommon.h"
|
||||
#include "Parsing/LocalizeFile/LocalizeFileReader.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
XAssetInfoGeneric* AssetLoaderLocalizeEntry::LoadFromGlobalAssetPools(const std::string& assetName) const
|
||||
@ -22,7 +22,8 @@ bool AssetLoaderLocalizeEntry::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderLocalizeEntry::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderLocalizeEntry::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
std::string fileName;
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -12,6 +12,7 @@ namespace IW4
|
||||
_NODISCARD XAssetInfoGeneric* LoadFromGlobalAssetPools(const std::string& assetName) const override;
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderMapEnts.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderMapEnts::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,12 +1,6 @@
|
||||
#include "AssetLoaderMaterial.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "AssetLoaderTechniqueSet.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "AssetLoading/AbstractGdtEntryReader.h"
|
||||
#include "Game/IW4/CommonIW4.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
@ -14,11 +8,17 @@
|
||||
#include "Game/IW4/ObjConstantsIW4.h"
|
||||
#include "Game/IW4/TechsetConstantsIW4.h"
|
||||
#include "Math/Vector.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
#include "StateMap/StateMapFromTechniqueExtractor.h"
|
||||
#include "StateMap/StateMapHandler.h"
|
||||
#include "Techset/TechniqueFileReader.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
namespace IW4
|
||||
@ -68,9 +68,7 @@ namespace IW4
|
||||
{
|
||||
const auto materialType = ReadStringProperty("materialType");
|
||||
|
||||
if (materialType == GDT_MATERIAL_TYPE_MODEL_PHONG
|
||||
|| materialType == GDT_MATERIAL_TYPE_WORLD_PHONG
|
||||
|| materialType == GDT_MATERIAL_TYPE_IMPACT_MARK)
|
||||
if (materialType == GDT_MATERIAL_TYPE_MODEL_PHONG || materialType == GDT_MATERIAL_TYPE_WORLD_PHONG || materialType == GDT_MATERIAL_TYPE_IMPACT_MARK)
|
||||
{
|
||||
mtl_phong_template();
|
||||
}
|
||||
@ -82,8 +80,7 @@ namespace IW4
|
||||
{
|
||||
mtl_2d_template();
|
||||
}
|
||||
else if (materialType == GDT_MATERIAL_TYPE_MODEL_UNLIT
|
||||
|| materialType == GDT_MATERIAL_TYPE_WORLD_UNLIT)
|
||||
else if (materialType == GDT_MATERIAL_TYPE_MODEL_UNLIT || materialType == GDT_MATERIAL_TYPE_WORLD_UNLIT)
|
||||
{
|
||||
mtl_unlit_template();
|
||||
}
|
||||
@ -557,11 +554,10 @@ namespace IW4
|
||||
sortKey = GDT_SORTKEY_DECAL_WEAPON_IMPACT;
|
||||
else if (materialType == GDT_MATERIAL_TYPE_EFFECT)
|
||||
sortKey = GDT_SORTKEY_EFFECT_AUTO_SORT;
|
||||
else if (materialType == GDT_MATERIAL_TYPE_OBJECTIVE
|
||||
|| blendFunc == "Blend" || blendFunc == "Add" || blendFunc == "Screen Add")
|
||||
else if (materialType == GDT_MATERIAL_TYPE_OBJECTIVE || blendFunc == "Blend" || blendFunc == "Add" || blendFunc == "Screen Add")
|
||||
sortKey = GDT_SORTKEY_BLEND_ADDITIVE;
|
||||
// else if (blendFunc == "Multiply") // TODO
|
||||
// sortKey = GDT_SORTKEY_MULTIPLICATIVE;
|
||||
// else if (blendFunc == "Multiply") // TODO
|
||||
// sortKey = GDT_SORTKEY_MULTIPLICATIVE;
|
||||
else if (materialType == GDT_MATERIAL_TYPE_SKY)
|
||||
sortKey = GDT_SORTKEY_SKY;
|
||||
else if (materialType == GDT_MATERIAL_TYPE_MODEL_AMBIENT)
|
||||
@ -599,9 +595,7 @@ namespace IW4
|
||||
}
|
||||
}
|
||||
|
||||
void clamp_template()
|
||||
{
|
||||
}
|
||||
void clamp_template() {}
|
||||
|
||||
void textureAtlas_template()
|
||||
{
|
||||
@ -674,11 +668,15 @@ namespace IW4
|
||||
else if (blendFunc == GDT_BLEND_FUNC_CUSTOM)
|
||||
{
|
||||
const auto customBlendOpRgb = ReadEnumProperty<BlendOp_e>("customBlendOpRgb", GdtBlendOpNames, std::extent_v<decltype(GdtBlendOpNames)>);
|
||||
const auto srcCustomBlendFunc = ReadEnumProperty<CustomBlendFunc_e>("srcCustomBlendFunc", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
|
||||
const auto destCustomBlendFunc = ReadEnumProperty<CustomBlendFunc_e>("destCustomBlendFunc", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
|
||||
const auto srcCustomBlendFunc =
|
||||
ReadEnumProperty<CustomBlendFunc_e>("srcCustomBlendFunc", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
|
||||
const auto destCustomBlendFunc =
|
||||
ReadEnumProperty<CustomBlendFunc_e>("destCustomBlendFunc", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
|
||||
const auto customBlendOpAlpha = ReadEnumProperty<BlendOp_e>("customBlendOpAlpha", GdtBlendOpNames, std::extent_v<decltype(GdtBlendOpNames)>);
|
||||
const auto srcCustomBlendFuncAlpha = ReadEnumProperty<CustomBlendFunc_e>("srcCustomBlendFuncAlpha", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
|
||||
const auto destCustomBlendFuncAlpha = ReadEnumProperty<CustomBlendFunc_e>("destCustomBlendFuncAlpha", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
|
||||
const auto srcCustomBlendFuncAlpha =
|
||||
ReadEnumProperty<CustomBlendFunc_e>("srcCustomBlendFuncAlpha", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
|
||||
const auto destCustomBlendFuncAlpha =
|
||||
ReadEnumProperty<CustomBlendFunc_e>("destCustomBlendFuncAlpha", GdtCustomBlendFuncNames, std::extent_v<decltype(GdtCustomBlendFuncNames)>);
|
||||
|
||||
SetBlendFunc(customBlendOpRgb, srcCustomBlendFunc, destCustomBlendFunc);
|
||||
SetSeparateAlphaBlendFunc(customBlendOpAlpha, srcCustomBlendFuncAlpha, destCustomBlendFuncAlpha);
|
||||
@ -693,10 +691,14 @@ namespace IW4
|
||||
|
||||
void colorwrite_template()
|
||||
{
|
||||
const auto colorWriteRed = ReadEnumProperty<StateBitsEnabledStatus_e>("colorWriteRed", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
|
||||
const auto colorWriteGreen = ReadEnumProperty<StateBitsEnabledStatus_e>("colorWriteGreen", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
|
||||
const auto colorWriteBlue = ReadEnumProperty<StateBitsEnabledStatus_e>("colorWriteBlue", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
|
||||
const auto colorWriteAlpha = ReadEnumProperty<StateBitsEnabledStatus_e>("colorWriteAlpha", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
|
||||
const auto colorWriteRed = ReadEnumProperty<StateBitsEnabledStatus_e>(
|
||||
"colorWriteRed", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
|
||||
const auto colorWriteGreen = ReadEnumProperty<StateBitsEnabledStatus_e>(
|
||||
"colorWriteGreen", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
|
||||
const auto colorWriteBlue = ReadEnumProperty<StateBitsEnabledStatus_e>(
|
||||
"colorWriteBlue", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
|
||||
const auto colorWriteAlpha = ReadEnumProperty<StateBitsEnabledStatus_e>(
|
||||
"colorWriteAlpha", GdtStateBitsEnabledStatusNames, std::extent_v<decltype(GdtStateBitsEnabledStatusNames)>);
|
||||
|
||||
SetColorWrite(colorWriteRed, colorWriteGreen, colorWriteBlue, colorWriteAlpha);
|
||||
}
|
||||
@ -717,7 +719,8 @@ namespace IW4
|
||||
|
||||
void depthwrite_template()
|
||||
{
|
||||
const auto depthWrite = ReadEnumProperty<StateBitsEnabledStatus_e>("depthWrite", GdtStateBitsOnOffStatusNames, std::extent_v<decltype(GdtStateBitsOnOffStatusNames)>);
|
||||
const auto depthWrite =
|
||||
ReadEnumProperty<StateBitsEnabledStatus_e>("depthWrite", GdtStateBitsOnOffStatusNames, std::extent_v<decltype(GdtStateBitsOnOffStatusNames)>);
|
||||
const auto blendFunc = ReadStringProperty("blendFunc");
|
||||
|
||||
if (depthWrite == StateBitsEnabledStatus_e::ENABLED)
|
||||
@ -746,7 +749,8 @@ namespace IW4
|
||||
|
||||
void gammawrite_template()
|
||||
{
|
||||
const auto gammaWrite = ReadEnumProperty<StateBitsEnabledStatus_e>("gammaWrite", GdtStateBitsOnOffStatusNames, std::extent_v<decltype(GdtStateBitsOnOffStatusNames)>);
|
||||
const auto gammaWrite =
|
||||
ReadEnumProperty<StateBitsEnabledStatus_e>("gammaWrite", GdtStateBitsOnOffStatusNames, std::extent_v<decltype(GdtStateBitsOnOffStatusNames)>);
|
||||
|
||||
if (gammaWrite == StateBitsEnabledStatus_e::UNKNOWN)
|
||||
{
|
||||
@ -760,7 +764,8 @@ namespace IW4
|
||||
|
||||
void polygonoffset_template()
|
||||
{
|
||||
const auto polygonOffset = ReadEnumProperty<PolygonOffset_e>("polygonOffset", GdtPolygonOffsetNames, std::extent_v<decltype(GdtPolygonOffsetNames)>);
|
||||
const auto polygonOffset =
|
||||
ReadEnumProperty<PolygonOffset_e>("polygonOffset", GdtPolygonOffsetNames, std::extent_v<decltype(GdtPolygonOffsetNames)>);
|
||||
|
||||
SetPolygonOffset(polygonOffset);
|
||||
}
|
||||
@ -778,17 +783,23 @@ namespace IW4
|
||||
{
|
||||
if (stencilMode == StencilMode_e::TWO_SIDED)
|
||||
{
|
||||
const auto stencilBackFunc = ReadEnumProperty<StencilFunc_e>("stencilFunc2", GdtStencilFuncNames, std::extent_v<decltype(GdtStencilFuncNames)>);
|
||||
const auto stencilBackOpFail = ReadEnumProperty<StencilOp_e>("stencilOpFail2", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
|
||||
const auto stencilBackOpZFail = ReadEnumProperty<StencilOp_e>("stencilOpZFail2", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
|
||||
const auto stencilBackOpPass = ReadEnumProperty<StencilOp_e>("stencilOpPass2", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
|
||||
const auto stencilBackFunc =
|
||||
ReadEnumProperty<StencilFunc_e>("stencilFunc2", GdtStencilFuncNames, std::extent_v<decltype(GdtStencilFuncNames)>);
|
||||
const auto stencilBackOpFail =
|
||||
ReadEnumProperty<StencilOp_e>("stencilOpFail2", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
|
||||
const auto stencilBackOpZFail =
|
||||
ReadEnumProperty<StencilOp_e>("stencilOpZFail2", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
|
||||
const auto stencilBackOpPass =
|
||||
ReadEnumProperty<StencilOp_e>("stencilOpPass2", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
|
||||
|
||||
EnableStencil(StencilIndex::BACK, stencilBackFunc, stencilBackOpFail, stencilBackOpZFail, stencilBackOpPass);
|
||||
}
|
||||
|
||||
const auto stencilFrontFunc = ReadEnumProperty<StencilFunc_e>("stencilFunc1", GdtStencilFuncNames, std::extent_v<decltype(GdtStencilFuncNames)>);
|
||||
const auto stencilFrontFunc =
|
||||
ReadEnumProperty<StencilFunc_e>("stencilFunc1", GdtStencilFuncNames, std::extent_v<decltype(GdtStencilFuncNames)>);
|
||||
const auto stencilFrontOpFail = ReadEnumProperty<StencilOp_e>("stencilOpFail1", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
|
||||
const auto stencilFrontOpZFail = ReadEnumProperty<StencilOp_e>("stencilOpZFail1", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
|
||||
const auto stencilFrontOpZFail =
|
||||
ReadEnumProperty<StencilOp_e>("stencilOpZFail1", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
|
||||
const auto stencilFrontOpPass = ReadEnumProperty<StencilOp_e>("stencilOpPass1", GdtStencilOpNames, std::extent_v<decltype(GdtStencilOpNames)>);
|
||||
|
||||
EnableStencil(StencilIndex::FRONT, stencilFrontFunc, stencilFrontOpFail, stencilFrontOpZFail, stencilFrontOpPass);
|
||||
@ -833,11 +844,13 @@ namespace IW4
|
||||
if (techsetDefinition->GetTechniqueByIndex(i, techniqueName))
|
||||
{
|
||||
const auto stateBitsForTechnique = GetStateBitsForTechnique(techniqueName);
|
||||
const auto foundStateBits = std::find_if(m_state_bits.begin(), m_state_bits.end(),
|
||||
[stateBitsForTechnique](const GfxStateBits& s1)
|
||||
{
|
||||
return s1.loadBits[0] == stateBitsForTechnique.loadBits[0] && s1.loadBits[1] == stateBitsForTechnique.loadBits[1];
|
||||
});
|
||||
const auto foundStateBits =
|
||||
std::find_if(m_state_bits.begin(),
|
||||
m_state_bits.end(),
|
||||
[stateBitsForTechnique](const GfxStateBits& s1)
|
||||
{
|
||||
return s1.loadBits[0] == stateBitsForTechnique.loadBits[0] && s1.loadBits[1] == stateBitsForTechnique.loadBits[1];
|
||||
});
|
||||
|
||||
if (foundStateBits != m_state_bits.end())
|
||||
{
|
||||
@ -928,7 +941,8 @@ namespace IW4
|
||||
}
|
||||
}
|
||||
|
||||
void AddMapTexture(const std::string& typeName, const TileMode_e tileMode, GdtFilter_e filterMode, const TextureSemantic semantic, const std::string& textureName)
|
||||
void AddMapTexture(
|
||||
const std::string& typeName, const TileMode_e tileMode, GdtFilter_e filterMode, const TextureSemantic semantic, const std::string& textureName)
|
||||
{
|
||||
MaterialTextureDef textureDef{};
|
||||
textureDef.nameHash = Common::R_HashString(typeName.c_str());
|
||||
@ -1086,7 +1100,9 @@ namespace IW4
|
||||
m_base_state_bits.loadBits[0] |= ((static_cast<unsigned>(destFunc) - 1) << GFXS0_DSTBLEND_ALPHA_SHIFT) & GFXS0_DSTBLEND_ALPHA_MASK;
|
||||
}
|
||||
|
||||
void SetColorWrite(const StateBitsEnabledStatus_e colorWriteRed, const StateBitsEnabledStatus_e colorWriteGreen, const StateBitsEnabledStatus_e colorWriteBlue,
|
||||
void SetColorWrite(const StateBitsEnabledStatus_e colorWriteRed,
|
||||
const StateBitsEnabledStatus_e colorWriteGreen,
|
||||
const StateBitsEnabledStatus_e colorWriteBlue,
|
||||
const StateBitsEnabledStatus_e colorWriteAlpha)
|
||||
{
|
||||
if (colorWriteRed == StateBitsEnabledStatus_e::UNKNOWN || colorWriteGreen == StateBitsEnabledStatus_e::UNKNOWN
|
||||
@ -1200,8 +1216,16 @@ namespace IW4
|
||||
m_base_state_bits.loadBits[1] |= ((static_cast<unsigned>(polygonOffset) - 1) << GFXS1_POLYGON_OFFSET_SHIFT) & GFXS1_POLYGON_OFFSET_MASK;
|
||||
}
|
||||
|
||||
static void GetStencilMasksForIndex(const StencilIndex stencil, unsigned& enabledMask, unsigned& funcShift, unsigned& funcMask, unsigned& opFailShift, unsigned& opFailMask,
|
||||
unsigned& opZFailShift, unsigned& opZFailMask, unsigned& opPassShift, unsigned& opPassMask)
|
||||
static void GetStencilMasksForIndex(const StencilIndex stencil,
|
||||
unsigned& enabledMask,
|
||||
unsigned& funcShift,
|
||||
unsigned& funcMask,
|
||||
unsigned& opFailShift,
|
||||
unsigned& opFailMask,
|
||||
unsigned& opZFailShift,
|
||||
unsigned& opZFailMask,
|
||||
unsigned& opPassShift,
|
||||
unsigned& opPassMask)
|
||||
{
|
||||
if (stencil == StencilIndex::FRONT)
|
||||
{
|
||||
@ -1239,7 +1263,8 @@ namespace IW4
|
||||
m_base_state_bits.loadBits[1] &= ~(enabledMask | funcMask | opFailMask | opZFailMask | opPassMask);
|
||||
}
|
||||
|
||||
void EnableStencil(const StencilIndex stencil, StencilFunc_e stencilFunc, StencilOp_e stencilOpFail, StencilOp_e stencilOpZFail, StencilOp_e stencilOpPass)
|
||||
void EnableStencil(
|
||||
const StencilIndex stencil, StencilFunc_e stencilFunc, StencilOp_e stencilOpFail, StencilOp_e stencilOpZFail, StencilOp_e stencilOpPass)
|
||||
{
|
||||
unsigned enabledMask, funcShift, funcMask, opFailShift, opFailMask, opZFailShift, opZFailMask, opPassShift, opPassMask;
|
||||
GetStencilMasksForIndex(stencil, enabledMask, funcShift, funcMask, opFailShift, opFailMask, opZFailShift, opZFailMask, opPassShift, opPassMask);
|
||||
@ -1298,7 +1323,8 @@ namespace IW4
|
||||
}
|
||||
}
|
||||
|
||||
static size_t GetIndexForString(const std::string& propertyName, const std::string& value, const char** validValuesArray, const size_t validValuesArraySize)
|
||||
static size_t
|
||||
GetIndexForString(const std::string& propertyName, const std::string& value, const char** validValuesArray, const size_t validValuesArraySize)
|
||||
{
|
||||
for (auto i = 0u; i < validValuesArraySize; i++)
|
||||
{
|
||||
@ -1311,8 +1337,7 @@ namespace IW4
|
||||
throw GdtReadingException(ss.str());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T ReadEnumProperty(const std::string& propertyName, const char** validValuesArray, const size_t validValuesArraySize) const
|
||||
template<typename T> T ReadEnumProperty(const std::string& propertyName, const char** validValuesArray, const size_t validValuesArraySize) const
|
||||
{
|
||||
return static_cast<T>(GetIndexForString(propertyName, ReadStringProperty(propertyName), validValuesArray, validValuesArraySize));
|
||||
}
|
||||
@ -1330,7 +1355,7 @@ namespace IW4
|
||||
std::vector<MaterialTextureDef> m_textures;
|
||||
std::vector<MaterialConstantDef> m_constants;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
||||
void* AssetLoaderMaterial::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
@ -1345,7 +1370,8 @@ bool AssetLoaderMaterial::CanLoadFromGdt() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderMaterial::LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderMaterial::LoadFromGdt(
|
||||
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto* entry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_MATERIAL, assetName);
|
||||
if (!entry)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,6 +11,7 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromGdt() const override;
|
||||
bool LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool LoadFromGdt(
|
||||
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderMenuDef.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderMenuDef::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,15 +1,15 @@
|
||||
#include "AssetLoaderMenuList.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Game/IW4/Menu/MenuConversionZoneStateIW4.h"
|
||||
#include "Game/IW4/Menu/MenuConverterIW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Parsing/Menu/MenuFileReader.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
namespace IW4
|
||||
@ -17,8 +17,14 @@ namespace IW4
|
||||
class MenuLoader
|
||||
{
|
||||
public:
|
||||
static bool ProcessParsedResults(const std::string& fileName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, menu::ParsingResult* parsingResult,
|
||||
menu::MenuAssetZoneState* zoneState, MenuConversionZoneState* conversionState, std::vector<menuDef_t*>& menus,
|
||||
static bool ProcessParsedResults(const std::string& fileName,
|
||||
ISearchPath* searchPath,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
menu::ParsingResult* parsingResult,
|
||||
menu::MenuAssetZoneState* zoneState,
|
||||
MenuConversionZoneState* conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
std::vector<XAssetInfoGeneric*>& menuListDependencies)
|
||||
{
|
||||
const auto menuCount = parsingResult->m_menus.size();
|
||||
@ -28,8 +34,8 @@ namespace IW4
|
||||
for (const auto& menu : parsingResult->m_menus)
|
||||
totalItemCount += menu->m_items.size();
|
||||
|
||||
std::cout << "Successfully read menu file \"" << fileName << "\" (" << menuLoadCount << " loads, " << menuCount << " menus, " << functionCount << " functions, " << totalItemCount <<
|
||||
" items)\n";
|
||||
std::cout << "Successfully read menu file \"" << fileName << "\" (" << menuLoadCount << " loads, " << menuCount << " menus, " << functionCount
|
||||
<< " functions, " << totalItemCount << " items)\n";
|
||||
|
||||
// Add all functions to the zone state to make them available for all menus to be converted
|
||||
for (auto& function : parsingResult->m_functions)
|
||||
@ -51,7 +57,8 @@ namespace IW4
|
||||
}
|
||||
|
||||
menus.push_back(menuAsset);
|
||||
auto* menuAssetInfo = manager->AddAsset(ASSET_TYPE_MENU, menu->m_name, menuAsset, std::move(converter.GetDependencies()), std::vector<scr_string_t>());
|
||||
auto* menuAssetInfo =
|
||||
manager->AddAsset(ASSET_TYPE_MENU, menu->m_name, menuAsset, std::move(converter.GetDependencies()), std::vector<scr_string_t>());
|
||||
|
||||
if (menuAssetInfo)
|
||||
{
|
||||
@ -86,20 +93,24 @@ namespace IW4
|
||||
return menuListAsset;
|
||||
}
|
||||
|
||||
static std::unique_ptr<menu::ParsingResult> ParseMenuFile(const std::string& menuFileName, ISearchPath* searchPath, const menu::MenuAssetZoneState* zoneState)
|
||||
static std::unique_ptr<menu::ParsingResult>
|
||||
ParseMenuFile(const std::string& menuFileName, ISearchPath* searchPath, const menu::MenuAssetZoneState* zoneState)
|
||||
{
|
||||
const auto file = searchPath->Open(menuFileName);
|
||||
if (!file.IsOpen())
|
||||
return nullptr;
|
||||
|
||||
menu::MenuFileReader reader(*file.m_stream, menuFileName, menu::FeatureLevel::IW4, [searchPath](const std::string& filename, const std::string& sourceFile) -> std::unique_ptr<std::istream>
|
||||
{
|
||||
auto foundFileToInclude = searchPath->Open(filename);
|
||||
if (!foundFileToInclude.IsOpen() || !foundFileToInclude.m_stream)
|
||||
return nullptr;
|
||||
menu::MenuFileReader reader(*file.m_stream,
|
||||
menuFileName,
|
||||
menu::FeatureLevel::IW4,
|
||||
[searchPath](const std::string& filename, const std::string& sourceFile) -> std::unique_ptr<std::istream>
|
||||
{
|
||||
auto foundFileToInclude = searchPath->Open(filename);
|
||||
if (!foundFileToInclude.IsOpen() || !foundFileToInclude.m_stream)
|
||||
return nullptr;
|
||||
|
||||
return std::move(foundFileToInclude.m_stream);
|
||||
});
|
||||
return std::move(foundFileToInclude.m_stream);
|
||||
});
|
||||
|
||||
reader.IncludeZoneState(zoneState);
|
||||
reader.SetPermissiveMode(ObjLoading::Configuration.MenuPermissiveParsing);
|
||||
@ -107,7 +118,7 @@ namespace IW4
|
||||
return reader.ReadMenuFile();
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
||||
void* AssetLoaderMenuList::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
@ -122,8 +133,15 @@ bool AssetLoaderMenuList::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuildMenuFileQueue(std::deque<std::string>& menuLoadQueue, const std::string& menuListAssetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, menu::MenuAssetZoneState* zoneState,
|
||||
MenuConversionZoneState* conversionState, std::vector<menuDef_t*>& menus, std::vector<XAssetInfoGeneric*>& menuListDependencies)
|
||||
bool BuildMenuFileQueue(std::deque<std::string>& menuLoadQueue,
|
||||
const std::string& menuListAssetName,
|
||||
ISearchPath* searchPath,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
menu::MenuAssetZoneState* zoneState,
|
||||
MenuConversionZoneState* conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
std::vector<XAssetInfoGeneric*>& menuListDependencies)
|
||||
{
|
||||
const auto alreadyLoadedMenuListFileMenus = conversionState->m_menus_by_filename.find(menuListAssetName);
|
||||
|
||||
@ -132,7 +150,8 @@ bool BuildMenuFileQueue(std::deque<std::string>& menuLoadQueue, const std::strin
|
||||
const auto menuListResult = MenuLoader::ParseMenuFile(menuListAssetName, searchPath, zoneState);
|
||||
if (menuListResult)
|
||||
{
|
||||
MenuLoader::ProcessParsedResults(menuListAssetName, searchPath, memory, manager, menuListResult.get(), zoneState, conversionState, menus, menuListDependencies);
|
||||
MenuLoader::ProcessParsedResults(
|
||||
menuListAssetName, searchPath, memory, manager, menuListResult.get(), zoneState, conversionState, menus, menuListDependencies);
|
||||
|
||||
for (const auto& menuToLoad : menuListResult->m_menus_to_load)
|
||||
menuLoadQueue.push_back(menuToLoad);
|
||||
@ -146,8 +165,14 @@ bool BuildMenuFileQueue(std::deque<std::string>& menuLoadQueue, const std::strin
|
||||
return true;
|
||||
}
|
||||
|
||||
void LoadMenuFileFromQueue(const std::string& menuFilePath, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, menu::MenuAssetZoneState* zoneState,
|
||||
MenuConversionZoneState* conversionState, std::vector<menuDef_t*>& menus, std::vector<XAssetInfoGeneric*>& menuListDependencies)
|
||||
void LoadMenuFileFromQueue(const std::string& menuFilePath,
|
||||
ISearchPath* searchPath,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
menu::MenuAssetZoneState* zoneState,
|
||||
MenuConversionZoneState* conversionState,
|
||||
std::vector<menuDef_t*>& menus,
|
||||
std::vector<XAssetInfoGeneric*>& menuListDependencies)
|
||||
{
|
||||
const auto alreadyLoadedMenuFile = conversionState->m_menus_by_filename.find(menuFilePath);
|
||||
if (alreadyLoadedMenuFile != conversionState->m_menus_by_filename.end())
|
||||
@ -164,7 +189,8 @@ void LoadMenuFileFromQueue(const std::string& menuFilePath, ISearchPath* searchP
|
||||
const auto menuFileResult = MenuLoader::ParseMenuFile(menuFilePath, searchPath, zoneState);
|
||||
if (menuFileResult)
|
||||
{
|
||||
MenuLoader::ProcessParsedResults(menuFilePath, searchPath, memory, manager, menuFileResult.get(), zoneState, conversionState, menus, menuListDependencies);
|
||||
MenuLoader::ProcessParsedResults(
|
||||
menuFilePath, searchPath, memory, manager, menuFileResult.get(), zoneState, conversionState, menus, menuListDependencies);
|
||||
if (!menuFileResult->m_menus_to_load.empty())
|
||||
std::cout << "WARNING: Menu file has menus to load even though it is not a menu list, ignoring: \"" << menuFilePath << "\"\n";
|
||||
}
|
||||
@ -172,7 +198,8 @@ void LoadMenuFileFromQueue(const std::string& menuFilePath, ISearchPath* searchP
|
||||
std::cerr << "Could not read menu file \"" << menuFilePath << "\"\n";
|
||||
}
|
||||
|
||||
bool AssetLoaderMenuList::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderMenuList::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
std::vector<menuDef_t*> menus;
|
||||
std::vector<XAssetInfoGeneric*> menuListDependencies;
|
||||
@ -184,7 +211,7 @@ bool AssetLoaderMenuList::LoadFromRaw(const std::string& assetName, ISearchPath*
|
||||
if (!BuildMenuFileQueue(menuLoadQueue, assetName, searchPath, memory, manager, zoneState, conversionState, menus, menuListDependencies))
|
||||
return false;
|
||||
|
||||
while(!menuLoadQueue.empty())
|
||||
while (!menuLoadQueue.empty())
|
||||
{
|
||||
const auto& menuFileToLoad = menuLoadQueue.front();
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -12,7 +12,8 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
void FinalizeAssetsForZone(AssetLoadingContext* context) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderPhysCollmap.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderPhysCollmap::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include "AssetLoaderPhysPreset.h"
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Game/IW4/InfoString/InfoStringToStructConverter.h"
|
||||
#include "Game/IW4/InfoString/PhysPresetFields.h"
|
||||
#include "Game/IW4/ObjConstantsIW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Game/IW4/ObjConstantsIW4.h"
|
||||
#include "Game/IW4/InfoString/InfoStringToStructConverter.h"
|
||||
#include "Game/IW4/InfoString/PhysPresetFields.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
namespace IW4
|
||||
@ -25,13 +25,18 @@ namespace IW4
|
||||
}
|
||||
|
||||
public:
|
||||
InfoStringToPhysPresetConverter(const InfoString& infoString, PhysPresetInfo* physPreset, ZoneScriptStrings& zoneScriptStrings, MemoryManager* memory, IAssetLoadingManager* manager,
|
||||
const cspField_t* fields, const size_t fieldCount)
|
||||
InfoStringToPhysPresetConverter(const InfoString& infoString,
|
||||
PhysPresetInfo* physPreset,
|
||||
ZoneScriptStrings& zoneScriptStrings,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
const cspField_t* fields,
|
||||
const size_t fieldCount)
|
||||
: InfoStringToStructConverter(infoString, physPreset, zoneScriptStrings, memory, manager, fields, fieldCount)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
||||
void AssetLoaderPhysPreset::CopyFromPhysPresetInfo(const PhysPresetInfo* physPresetInfo, PhysPreset* physPreset)
|
||||
{
|
||||
@ -52,11 +57,13 @@ void AssetLoaderPhysPreset::CopyFromPhysPresetInfo(const PhysPresetInfo* physPre
|
||||
physPreset->perSurfaceSndAlias = physPresetInfo->perSurfaceSndAlias != 0;
|
||||
}
|
||||
|
||||
bool AssetLoaderPhysPreset::LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
bool AssetLoaderPhysPreset::LoadFromInfoString(
|
||||
const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone)
|
||||
{
|
||||
const auto presetInfo = std::make_unique<PhysPresetInfo>();
|
||||
memset(presetInfo.get(), 0, sizeof(PhysPresetInfo));
|
||||
InfoStringToPhysPresetConverter converter(infoString, presetInfo.get(), zone->m_script_strings, memory, manager, phys_preset_fields, std::extent<decltype(phys_preset_fields)>::value);
|
||||
InfoStringToPhysPresetConverter converter(
|
||||
infoString, presetInfo.get(), zone->m_script_strings, memory, manager, phys_preset_fields, std::extent<decltype(phys_preset_fields)>::value);
|
||||
if (!converter.Convert())
|
||||
{
|
||||
std::cout << "Failed to parse phys preset: \"" << assetName << "\"" << std::endl;
|
||||
@ -86,7 +93,8 @@ bool AssetLoaderPhysPreset::CanLoadFromGdt() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderPhysPreset::LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderPhysPreset::LoadFromGdt(
|
||||
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
auto* gdtEntry = gdtQueryable->GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_PHYS_PRESET, assetName);
|
||||
if (gdtEntry == nullptr)
|
||||
@ -107,7 +115,8 @@ bool AssetLoaderPhysPreset::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderPhysPreset::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderPhysPreset::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto fileName = "physic/" + assetName;
|
||||
const auto file = searchPath->Open(fileName);
|
||||
@ -123,4 +132,3 @@ bool AssetLoaderPhysPreset::LoadFromRaw(const std::string& assetName, ISearchPat
|
||||
|
||||
return LoadFromInfoString(infoString, assetName, memory, manager, zone);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
@ -11,13 +11,16 @@ namespace IW4
|
||||
{
|
||||
static void CopyFromPhysPresetInfo(const PhysPresetInfo* physPresetInfo, PhysPreset* physPreset);
|
||||
|
||||
static bool LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone);
|
||||
static bool
|
||||
LoadFromInfoString(const InfoString& infoString, const std::string& assetName, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone);
|
||||
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromGdt() const override;
|
||||
bool LoadFromGdt(const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool LoadFromGdt(
|
||||
const std::string& assetName, IGdtQueryable* gdtQueryable, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "AssetLoaderPixelShader.h"
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderPixelShader::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
@ -31,14 +31,15 @@ std::string AssetLoaderPixelShader::GetFileNameForAsset(const std::string& asset
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool AssetLoaderPixelShader::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderPixelShader::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto fileName = GetFileNameForAsset(assetName);
|
||||
const auto file = searchPath->Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return false;
|
||||
|
||||
if(file.m_length % sizeof(uint32_t) != 0)
|
||||
if (file.m_length % sizeof(uint32_t) != 0)
|
||||
{
|
||||
std::cerr << "Invalid pixel shader \"" << assetName << "\": Size must be dividable by " << sizeof(uint32_t) << "\n";
|
||||
return false;
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
class AssetLoaderPixelShader final : public BasicAssetLoader<ASSET_TYPE_PIXELSHADER, MaterialPixelShader>
|
||||
@ -15,6 +15,7 @@ namespace IW4
|
||||
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "AssetLoaderRawFile.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderRawFile::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
@ -20,7 +20,8 @@ bool AssetLoaderRawFile::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderRawFile::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderRawFile::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(assetName);
|
||||
if (!file.IsOpen())
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,6 +11,7 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "AssetLoaderSndCurve.h"
|
||||
|
||||
#include "AssetLoading/SndCurve/SndCurveReader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "AssetLoading/SndCurve/SndCurveReader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
std::string AssetLoaderSndCurve::GetAssetFilename(const std::string& assetName)
|
||||
@ -33,7 +33,8 @@ bool AssetLoaderSndCurve::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderSndCurve::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderSndCurve::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto filename = GetAssetFilename(assetName);
|
||||
const auto file = searchPath->Open(filename);
|
||||
@ -47,7 +48,7 @@ bool AssetLoaderSndCurve::LoadFromRaw(const std::string& assetName, ISearchPath*
|
||||
if (!sndCurveData)
|
||||
return false;
|
||||
|
||||
if(sndCurveData->m_knots.size() > std::extent_v<decltype(SndCurve::knots)>)
|
||||
if (sndCurveData->m_knots.size() > std::extent_v<decltype(SndCurve::knots)>)
|
||||
{
|
||||
std::cerr << "Failed to load SndCurve \"" << assetName << "\": Too many knots (" << sndCurveData->m_knots.size() << ")\n";
|
||||
return false;
|
||||
@ -57,9 +58,9 @@ bool AssetLoaderSndCurve::LoadFromRaw(const std::string& assetName, ISearchPath*
|
||||
sndCurve->filename = memory->Dup(assetName.c_str());
|
||||
sndCurve->knotCount = static_cast<uint16_t>(sndCurveData->m_knots.size());
|
||||
|
||||
for(auto i = 0u; i < std::extent_v<decltype(SndCurve::knots)>; i++)
|
||||
for (auto i = 0u; i < std::extent_v<decltype(SndCurve::knots)>; i++)
|
||||
{
|
||||
if(i < sndCurveData->m_knots.size())
|
||||
if (i < sndCurveData->m_knots.size())
|
||||
{
|
||||
const auto& [x, y] = sndCurveData->m_knots[i];
|
||||
sndCurve->knots[i][0] = static_cast<float>(x);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -13,6 +13,7 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderSoundAliasList.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderSoundAliasList::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "AssetLoaderStringTable.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Csv/CsvStream.h"
|
||||
#include "Game/IW4/CommonIW4.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderStringTable::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
@ -23,7 +23,8 @@ bool AssetLoaderStringTable::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderStringTable::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderStringTable::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(assetName);
|
||||
if (!file.IsOpen())
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,6 +11,7 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "AssetLoaderStructuredDataDefSet.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "StructuredDataDef/StructuredDataDefReader.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
#include "StructuredDataDef/StructuredDataDefReader.h"
|
||||
#include "Utils/Alignment.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderStructuredDataDefSet::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
@ -88,7 +88,8 @@ void AssetLoaderStructuredDataDefSet::ConvertStruct(StructuredDataStruct* output
|
||||
inputStruct->SortPropertiesByName();
|
||||
if (!inputStruct->m_properties.empty())
|
||||
{
|
||||
outputStruct->properties = static_cast<StructuredDataStructProperty*>(memory->Alloc(sizeof(StructuredDataStructProperty) * inputStruct->m_properties.size()));
|
||||
outputStruct->properties =
|
||||
static_cast<StructuredDataStructProperty*>(memory->Alloc(sizeof(StructuredDataStructProperty) * inputStruct->m_properties.size()));
|
||||
for (auto propertyIndex = 0u; propertyIndex < inputStruct->m_properties.size(); propertyIndex++)
|
||||
{
|
||||
auto& outputProperty = outputStruct->properties[propertyIndex];
|
||||
@ -110,14 +111,18 @@ void AssetLoaderStructuredDataDefSet::ConvertStruct(StructuredDataStruct* output
|
||||
outputStruct->properties = nullptr;
|
||||
}
|
||||
|
||||
void AssetLoaderStructuredDataDefSet::ConvertIndexedArray(StructuredDataIndexedArray* outputIndexedArray, const CommonStructuredDataIndexedArray* inputIndexedArray, MemoryManager* memory)
|
||||
void AssetLoaderStructuredDataDefSet::ConvertIndexedArray(StructuredDataIndexedArray* outputIndexedArray,
|
||||
const CommonStructuredDataIndexedArray* inputIndexedArray,
|
||||
MemoryManager* memory)
|
||||
{
|
||||
outputIndexedArray->arraySize = static_cast<int>(inputIndexedArray->m_element_count);
|
||||
outputIndexedArray->elementType = ConvertType(inputIndexedArray->m_array_type);
|
||||
outputIndexedArray->elementSize = utils::Align(inputIndexedArray->m_element_size_in_bits, 8u) / 8u;
|
||||
}
|
||||
|
||||
void AssetLoaderStructuredDataDefSet::ConvertEnumedArray(StructuredDataEnumedArray* outputEnumedArray, const CommonStructuredDataEnumedArray* inputEnumedArray, MemoryManager* memory)
|
||||
void AssetLoaderStructuredDataDefSet::ConvertEnumedArray(StructuredDataEnumedArray* outputEnumedArray,
|
||||
const CommonStructuredDataEnumedArray* inputEnumedArray,
|
||||
MemoryManager* memory)
|
||||
{
|
||||
outputEnumedArray->enumIndex = static_cast<int>(inputEnumedArray->m_enum_index);
|
||||
outputEnumedArray->elementType = ConvertType(inputEnumedArray->m_array_type);
|
||||
@ -152,7 +157,8 @@ void AssetLoaderStructuredDataDefSet::ConvertDef(StructuredDataDef* outputDef, c
|
||||
outputDef->indexedArrayCount = static_cast<int>(inputDef->m_indexed_arrays.size());
|
||||
if (!inputDef->m_indexed_arrays.empty())
|
||||
{
|
||||
outputDef->indexedArrays = static_cast<StructuredDataIndexedArray*>(memory->Alloc(sizeof(StructuredDataIndexedArray) * inputDef->m_indexed_arrays.size()));
|
||||
outputDef->indexedArrays =
|
||||
static_cast<StructuredDataIndexedArray*>(memory->Alloc(sizeof(StructuredDataIndexedArray) * inputDef->m_indexed_arrays.size()));
|
||||
for (auto indexedArrayIndex = 0u; indexedArrayIndex < inputDef->m_indexed_arrays.size(); indexedArrayIndex++)
|
||||
ConvertIndexedArray(&outputDef->indexedArrays[indexedArrayIndex], &inputDef->m_indexed_arrays[indexedArrayIndex], memory);
|
||||
}
|
||||
@ -173,7 +179,9 @@ void AssetLoaderStructuredDataDefSet::ConvertDef(StructuredDataDef* outputDef, c
|
||||
outputDef->size = inputDef->m_size_in_byte;
|
||||
}
|
||||
|
||||
StructuredDataDefSet* AssetLoaderStructuredDataDefSet::ConvertSet(const std::string& assetName, const std::vector<std::unique_ptr<CommonStructuredDataDef>>& defs, MemoryManager* memory)
|
||||
StructuredDataDefSet* AssetLoaderStructuredDataDefSet::ConvertSet(const std::string& assetName,
|
||||
const std::vector<std::unique_ptr<CommonStructuredDataDef>>& defs,
|
||||
MemoryManager* memory)
|
||||
{
|
||||
auto* set = memory->Create<StructuredDataDefSet>();
|
||||
set->name = memory->Dup(assetName.c_str());
|
||||
@ -186,20 +194,23 @@ StructuredDataDefSet* AssetLoaderStructuredDataDefSet::ConvertSet(const std::str
|
||||
return set;
|
||||
}
|
||||
|
||||
bool AssetLoaderStructuredDataDefSet::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderStructuredDataDefSet::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto file = searchPath->Open(assetName);
|
||||
if (!file.IsOpen())
|
||||
return false;
|
||||
|
||||
StructuredDataDefReader reader(*file.m_stream, assetName, [searchPath](const std::string& filename, const std::string& sourceFile) -> std::unique_ptr<std::istream>
|
||||
{
|
||||
auto foundFileToInclude = searchPath->Open(filename);
|
||||
if (!foundFileToInclude.IsOpen() || !foundFileToInclude.m_stream)
|
||||
return nullptr;
|
||||
StructuredDataDefReader reader(*file.m_stream,
|
||||
assetName,
|
||||
[searchPath](const std::string& filename, const std::string& sourceFile) -> std::unique_ptr<std::istream>
|
||||
{
|
||||
auto foundFileToInclude = searchPath->Open(filename);
|
||||
if (!foundFileToInclude.IsOpen() || !foundFileToInclude.m_stream)
|
||||
return nullptr;
|
||||
|
||||
return std::move(foundFileToInclude.m_stream);
|
||||
});
|
||||
return std::move(foundFileToInclude.m_stream);
|
||||
});
|
||||
|
||||
bool readingDefsSuccessful;
|
||||
const auto defs = reader.ReadStructureDataDefs(readingDefsSuccessful);
|
||||
|
@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "StructuredDataDef/CommonStructuredDataDef.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "StructuredDataDef/CommonStructuredDataDef.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
@ -15,10 +15,15 @@ namespace IW4
|
||||
static StructuredDataType ConvertType(CommonStructuredDataType inputType);
|
||||
static void ConvertEnum(StructuredDataEnum* outputEnum, CommonStructuredDataEnum* inputEnum, MemoryManager* memory);
|
||||
static void ConvertStruct(StructuredDataStruct* outputStruct, CommonStructuredDataStruct* inputStruct, MemoryManager* memory);
|
||||
static void ConvertIndexedArray(StructuredDataIndexedArray* outputIndexedArray, const CommonStructuredDataIndexedArray* inputIndexedArray, MemoryManager* memory);
|
||||
static void ConvertEnumedArray(StructuredDataEnumedArray* outputEnumedArray, const CommonStructuredDataEnumedArray* inputEnumedArray, MemoryManager* memory);
|
||||
static void ConvertIndexedArray(StructuredDataIndexedArray* outputIndexedArray,
|
||||
const CommonStructuredDataIndexedArray* inputIndexedArray,
|
||||
MemoryManager* memory);
|
||||
static void
|
||||
ConvertEnumedArray(StructuredDataEnumedArray* outputEnumedArray, const CommonStructuredDataEnumedArray* inputEnumedArray, MemoryManager* memory);
|
||||
static void ConvertDef(StructuredDataDef* outputDef, const CommonStructuredDataDef* inputDef, MemoryManager* memory);
|
||||
static StructuredDataDefSet* ConvertSet(const std::string& assetName, const std::vector<std::unique_ptr<CommonStructuredDataDef>>& defs, MemoryManager* memory);
|
||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
static StructuredDataDefSet*
|
||||
ConvertSet(const std::string& assetName, const std::vector<std::unique_ptr<CommonStructuredDataDef>>& defs, MemoryManager* memory);
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,26 +1,26 @@
|
||||
#include "AssetLoaderTechniqueSet.h"
|
||||
|
||||
#include "AssetLoaderPixelShader.h"
|
||||
#include "AssetLoaderVertexShader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Game/IW4/TechsetConstantsIW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
#include "Shader/D3D9ShaderAnalyser.h"
|
||||
#include "StateMap/StateMapReader.h"
|
||||
#include "Techset/TechniqueFileReader.h"
|
||||
#include "Techset/TechniqueStateMapCache.h"
|
||||
#include "Techset/TechsetDefinitionCache.h"
|
||||
#include "Techset/TechsetFileReader.h"
|
||||
#include "Utils/Alignment.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
#include "AssetLoaderPixelShader.h"
|
||||
#include "AssetLoaderVertexShader.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Game/IW4/TechsetConstantsIW4.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
#include "Techset/TechniqueFileReader.h"
|
||||
#include "Techset/TechsetFileReader.h"
|
||||
#include "Shader/D3D9ShaderAnalyser.h"
|
||||
#include "StateMap/StateMapReader.h"
|
||||
#include "Techset/TechniqueStateMapCache.h"
|
||||
#include "Techset/TechsetDefinitionCache.h"
|
||||
#include "Utils/Alignment.h"
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace IW4;
|
||||
using namespace std::string_literals;
|
||||
@ -61,7 +61,8 @@ namespace IW4
|
||||
|
||||
const LoadedTechnique* AddLoadedTechnique(std::string techniqueName, MaterialTechnique* technique, std::vector<XAssetInfoGeneric*> dependencies)
|
||||
{
|
||||
return m_loaded_techniques.emplace(std::make_pair(std::move(techniqueName), std::make_unique<LoadedTechnique>(technique, std::move(dependencies)))).first->second.get();
|
||||
return m_loaded_techniques.emplace(std::make_pair(std::move(techniqueName), std::make_unique<LoadedTechnique>(technique, std::move(dependencies))))
|
||||
.first->second.get();
|
||||
}
|
||||
|
||||
literal_t GetAllocatedLiteral(MemoryManager* memory, techset::ShaderArgumentLiteralSource source)
|
||||
@ -205,7 +206,11 @@ namespace IW4
|
||||
std::vector<Pass> m_passes;
|
||||
std::vector<XAssetInfoGeneric*> m_dependencies;
|
||||
|
||||
TechniqueCreator(const std::string& techniqueName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, TechniqueZoneLoadingState* zoneState,
|
||||
TechniqueCreator(const std::string& techniqueName,
|
||||
ISearchPath* searchPath,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager,
|
||||
TechniqueZoneLoadingState* zoneState,
|
||||
ShaderInfoFromFileSystemCacheState* shaderInfoCache,
|
||||
techset::TechniqueStateMapCache* stateMapCache)
|
||||
: m_technique_name(techniqueName),
|
||||
@ -225,20 +230,22 @@ namespace IW4
|
||||
|
||||
static size_t RegisterCountPerElement(const d3d9::ShaderConstant& constant)
|
||||
{
|
||||
const auto valuesPerRegister = constant.m_register_set == d3d9::RegisterSet::BOOL || constant.m_register_set == d3d9::RegisterSet::SAMPLER ? 1u : 4u;
|
||||
const auto valuesPerRegister =
|
||||
constant.m_register_set == d3d9::RegisterSet::BOOL || constant.m_register_set == d3d9::RegisterSet::SAMPLER ? 1u : 4u;
|
||||
return utils::Align(constant.m_type_columns * constant.m_type_rows, valuesPerRegister) / valuesPerRegister;
|
||||
}
|
||||
|
||||
static bool IsSamplerArgument(const d3d9::ShaderConstant& constant)
|
||||
{
|
||||
return constant.m_type == d3d9::ParameterType::SAMPLER
|
||||
|| constant.m_type == d3d9::ParameterType::SAMPLER_1D
|
||||
|| constant.m_type == d3d9::ParameterType::SAMPLER_2D
|
||||
|| constant.m_type == d3d9::ParameterType::SAMPLER_3D
|
||||
|| constant.m_type == d3d9::ParameterType::SAMPLER_CUBE;
|
||||
return constant.m_type == d3d9::ParameterType::SAMPLER || constant.m_type == d3d9::ParameterType::SAMPLER_1D
|
||||
|| constant.m_type == d3d9::ParameterType::SAMPLER_2D || constant.m_type == d3d9::ParameterType::SAMPLER_3D
|
||||
|| constant.m_type == d3d9::ParameterType::SAMPLER_CUBE;
|
||||
}
|
||||
|
||||
bool AutoCreateShaderArgument(const techset::ShaderSelector shaderType, const d3d9::ShaderConstant& shaderArgument, const size_t elementOffset, const size_t registerOffset)
|
||||
bool AutoCreateShaderArgument(const techset::ShaderSelector shaderType,
|
||||
const d3d9::ShaderConstant& shaderArgument,
|
||||
const size_t elementOffset,
|
||||
const size_t registerOffset)
|
||||
{
|
||||
assert(!m_passes.empty());
|
||||
auto& pass = m_passes.at(m_passes.size() - 1);
|
||||
@ -367,7 +374,8 @@ namespace IW4
|
||||
assert(!m_passes.empty());
|
||||
auto& pass = m_passes.at(m_passes.size() - 1);
|
||||
|
||||
std::sort(std::begin(pass.m_vertex_decl.routing.data), std::begin(pass.m_vertex_decl.routing.data) + pass.m_vertex_decl.streamCount,
|
||||
std::sort(std::begin(pass.m_vertex_decl.routing.data),
|
||||
std::begin(pass.m_vertex_decl.routing.data) + pass.m_vertex_decl.streamCount,
|
||||
[](const MaterialStreamRouting& r1, const MaterialStreamRouting& r2)
|
||||
{
|
||||
return r1.source < r2.source;
|
||||
@ -395,19 +403,22 @@ namespace IW4
|
||||
return false;
|
||||
|
||||
// Sort args by their update frequency
|
||||
std::sort(pass.m_arguments.begin(), pass.m_arguments.end(), [](const PassShaderArgument& arg1, const PassShaderArgument& arg2)
|
||||
{
|
||||
if (arg1.m_update_frequency != arg2.m_update_frequency)
|
||||
return arg1.m_update_frequency < arg2.m_update_frequency;
|
||||
std::sort(pass.m_arguments.begin(),
|
||||
pass.m_arguments.end(),
|
||||
[](const PassShaderArgument& arg1, const PassShaderArgument& arg2)
|
||||
{
|
||||
if (arg1.m_update_frequency != arg2.m_update_frequency)
|
||||
return arg1.m_update_frequency < arg2.m_update_frequency;
|
||||
|
||||
if (arg1.m_arg.type != arg2.m_arg.type)
|
||||
return arg1.m_arg.type < arg2.m_arg.type;
|
||||
if (arg1.m_arg.type != arg2.m_arg.type)
|
||||
return arg1.m_arg.type < arg2.m_arg.type;
|
||||
|
||||
if (arg1.m_arg.type == MTL_ARG_MATERIAL_VERTEX_CONST || arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_CONST || arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_SAMPLER)
|
||||
return arg1.m_arg.u.codeSampler < arg2.m_arg.u.codeSampler;
|
||||
if (arg1.m_arg.type == MTL_ARG_MATERIAL_VERTEX_CONST || arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_CONST
|
||||
|| arg1.m_arg.type == MTL_ARG_MATERIAL_PIXEL_SAMPLER)
|
||||
return arg1.m_arg.u.codeSampler < arg2.m_arg.u.codeSampler;
|
||||
|
||||
return arg1.m_arg.dest < arg2.m_arg.dest;
|
||||
});
|
||||
return arg1.m_arg.dest < arg2.m_arg.dest;
|
||||
});
|
||||
|
||||
AllocateVertexDecl();
|
||||
|
||||
@ -430,7 +441,9 @@ namespace IW4
|
||||
return true;
|
||||
}
|
||||
|
||||
static void InitializeArgumentState(const d3d9::ShaderInfo& shaderInfo, std::vector<size_t>& argumentHandledOffsetVector, std::vector<bool>& argumentHandledVector)
|
||||
static void InitializeArgumentState(const d3d9::ShaderInfo& shaderInfo,
|
||||
std::vector<size_t>& argumentHandledOffsetVector,
|
||||
std::vector<bool>& argumentHandledVector)
|
||||
{
|
||||
auto vertexShaderArgumentSlotCount = 0u;
|
||||
auto argIndex = 0u;
|
||||
@ -464,7 +477,8 @@ namespace IW4
|
||||
|
||||
if (pass.m_vertex_shader->Asset()->name && pass.m_vertex_shader->Asset()->name[0] == ',')
|
||||
{
|
||||
pass.m_vertex_shader_info = m_shader_info_cache->LoadShaderInfoFromDisk(m_search_path, AssetLoaderVertexShader::GetFileNameForAsset(vertexShaderName));
|
||||
pass.m_vertex_shader_info =
|
||||
m_shader_info_cache->LoadShaderInfoFromDisk(m_search_path, AssetLoaderVertexShader::GetFileNameForAsset(vertexShaderName));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -503,7 +517,8 @@ namespace IW4
|
||||
|
||||
if (pass.m_pixel_shader->Asset()->name && pass.m_pixel_shader->Asset()->name[0] == ',')
|
||||
{
|
||||
pass.m_pixel_shader_info = m_shader_info_cache->LoadShaderInfoFromDisk(m_search_path, AssetLoaderPixelShader::GetFileNameForAsset(pixelShaderName));
|
||||
pass.m_pixel_shader_info =
|
||||
m_shader_info_cache->LoadShaderInfoFromDisk(m_search_path, AssetLoaderPixelShader::GetFileNameForAsset(pixelShaderName));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -579,12 +594,18 @@ namespace IW4
|
||||
return foundSource;
|
||||
}
|
||||
|
||||
bool FindShaderArgument(const d3d9::ShaderInfo& shaderInfo, const techset::ShaderArgument& argument, size_t& constantIndex, size_t& registerOffset, std::string& errorMessage) const
|
||||
bool FindShaderArgument(const d3d9::ShaderInfo& shaderInfo,
|
||||
const techset::ShaderArgument& argument,
|
||||
size_t& constantIndex,
|
||||
size_t& registerOffset,
|
||||
std::string& errorMessage) const
|
||||
{
|
||||
const auto matchingShaderConstant = std::find_if(shaderInfo.m_constants.begin(), shaderInfo.m_constants.end(), [argument](const d3d9::ShaderConstant& constant)
|
||||
{
|
||||
return constant.m_name == argument.m_argument_name;
|
||||
});
|
||||
const auto matchingShaderConstant = std::find_if(shaderInfo.m_constants.begin(),
|
||||
shaderInfo.m_constants.end(),
|
||||
[argument](const d3d9::ShaderConstant& constant)
|
||||
{
|
||||
return constant.m_name == argument.m_argument_name;
|
||||
});
|
||||
|
||||
if (matchingShaderConstant == shaderInfo.m_constants.end())
|
||||
{
|
||||
@ -623,8 +644,12 @@ namespace IW4
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SetArgumentCodeConst(MaterialShaderArgument& argument, const techset::ShaderArgumentCodeSource& source, const d3d9::ShaderConstant& shaderConstant, const unsigned sourceIndex,
|
||||
const unsigned arrayCount, std::string& errorMessage)
|
||||
static bool SetArgumentCodeConst(MaterialShaderArgument& argument,
|
||||
const techset::ShaderArgumentCodeSource& source,
|
||||
const d3d9::ShaderConstant& shaderConstant,
|
||||
const unsigned sourceIndex,
|
||||
const unsigned arrayCount,
|
||||
std::string& errorMessage)
|
||||
{
|
||||
if (arrayCount > 0u)
|
||||
{
|
||||
@ -657,8 +682,12 @@ namespace IW4
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SetArgumentCodeSampler(MaterialShaderArgument& argument, const techset::ShaderArgumentCodeSource& source, const d3d9::ShaderConstant& shaderConstant, const unsigned sourceIndex,
|
||||
const unsigned arrayCount, std::string& errorMessage)
|
||||
static bool SetArgumentCodeSampler(MaterialShaderArgument& argument,
|
||||
const techset::ShaderArgumentCodeSource& source,
|
||||
const d3d9::ShaderConstant& shaderConstant,
|
||||
const unsigned sourceIndex,
|
||||
const unsigned arrayCount,
|
||||
std::string& errorMessage)
|
||||
{
|
||||
if (arrayCount > 0u)
|
||||
{
|
||||
@ -689,7 +718,9 @@ namespace IW4
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AcceptVertexShaderConstantArgument(const techset::ShaderArgument& shaderArgument, const techset::ShaderArgumentCodeSource& source, std::string& errorMessage)
|
||||
bool AcceptVertexShaderConstantArgument(const techset::ShaderArgument& shaderArgument,
|
||||
const techset::ShaderArgumentCodeSource& source,
|
||||
std::string& errorMessage)
|
||||
{
|
||||
assert(!m_passes.empty());
|
||||
auto& pass = m_passes.at(m_passes.size() - 1);
|
||||
@ -737,7 +768,10 @@ namespace IW4
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AcceptPixelShaderCodeArgument(const techset::ShaderArgument& shaderArgument, const techset::ShaderArgumentCodeSource& source, std::string& errorMessage, const bool isSampler)
|
||||
bool AcceptPixelShaderCodeArgument(const techset::ShaderArgument& shaderArgument,
|
||||
const techset::ShaderArgumentCodeSource& source,
|
||||
std::string& errorMessage,
|
||||
const bool isSampler)
|
||||
{
|
||||
assert(!m_passes.empty());
|
||||
auto& pass = m_passes.at(m_passes.size() - 1);
|
||||
@ -809,14 +843,15 @@ namespace IW4
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
pass.m_arguments.emplace_back(argument);
|
||||
pass.m_handled_pixel_shader_arguments[pass.m_pixel_shader_argument_handled_offset[shaderConstantIndex] + elementOffset] = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AcceptShaderConstantArgument(const techset::ShaderSelector shader, const techset::ShaderArgument shaderArgument, const techset::ShaderArgumentCodeSource source,
|
||||
bool AcceptShaderConstantArgument(const techset::ShaderSelector shader,
|
||||
const techset::ShaderArgument shaderArgument,
|
||||
const techset::ShaderArgumentCodeSource source,
|
||||
std::string& errorMessage) override
|
||||
{
|
||||
if (shader == techset::ShaderSelector::VERTEX_SHADER)
|
||||
@ -826,7 +861,9 @@ namespace IW4
|
||||
return AcceptPixelShaderCodeArgument(shaderArgument, source, errorMessage, false);
|
||||
}
|
||||
|
||||
bool AcceptShaderSamplerArgument(const techset::ShaderSelector shader, const techset::ShaderArgument shaderArgument, const techset::ShaderArgumentCodeSource source,
|
||||
bool AcceptShaderSamplerArgument(const techset::ShaderSelector shader,
|
||||
const techset::ShaderArgument shaderArgument,
|
||||
const techset::ShaderArgumentCodeSource source,
|
||||
std::string& errorMessage) override
|
||||
{
|
||||
if (shader == techset::ShaderSelector::VERTEX_SHADER)
|
||||
@ -839,7 +876,10 @@ namespace IW4
|
||||
return AcceptPixelShaderCodeArgument(shaderArgument, source, errorMessage, true);
|
||||
}
|
||||
|
||||
bool AcceptShaderLiteralArgument(const techset::ShaderSelector shader, techset::ShaderArgument shaderArgument, techset::ShaderArgumentLiteralSource source, std::string& errorMessage) override
|
||||
bool AcceptShaderLiteralArgument(const techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
techset::ShaderArgumentLiteralSource source,
|
||||
std::string& errorMessage) override
|
||||
{
|
||||
assert(!m_passes.empty());
|
||||
auto& pass = m_passes.at(m_passes.size() - 1);
|
||||
@ -895,7 +935,9 @@ namespace IW4
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AcceptShaderMaterialArgument(const techset::ShaderSelector shader, techset::ShaderArgument shaderArgument, const techset::ShaderArgumentMaterialSource source,
|
||||
bool AcceptShaderMaterialArgument(const techset::ShaderSelector shader,
|
||||
techset::ShaderArgument shaderArgument,
|
||||
const techset::ShaderArgumentMaterialSource source,
|
||||
std::string& errorMessage) override
|
||||
{
|
||||
assert(!m_passes.empty());
|
||||
@ -1010,52 +1052,53 @@ namespace IW4
|
||||
static void UpdateTechniqueFlags(MaterialTechnique& technique)
|
||||
{
|
||||
// This is stupid but that's what the game does for zprepass for sure
|
||||
// The other ones might be handled by the game in the same fashion because there is not recognizable pattern that connects the shaders with the same flags
|
||||
// The other ones might be handled by the game in the same fashion because there is not recognizable pattern that connects the shaders with the same
|
||||
// flags
|
||||
static std::unordered_map<std::string, size_t> flagsByTechniqueName({
|
||||
{"zprepass", TECHNIQUE_FLAG_4 | TECHNIQUE_FLAG_200},
|
||||
{"build_floatz", TECHNIQUE_FLAG_8},
|
||||
{"build_shadowmap_depth", TECHNIQUE_FLAG_10 | TECHNIQUE_FLAG_200},
|
||||
{"build_shadowmap_model", TECHNIQUE_FLAG_10 | TECHNIQUE_FLAG_200},
|
||||
{"distortion_scale_ua_zfeather", TECHNIQUE_FLAG_100},
|
||||
{"distortion_scale_zfeather", TECHNIQUE_FLAG_100},
|
||||
{"distortion_scale_zfeather_dtex", TECHNIQUE_FLAG_100},
|
||||
{"alternate_scene_overlay", TECHNIQUE_FLAG_200},
|
||||
{"blur_apply", TECHNIQUE_FLAG_200},
|
||||
{"build_floatz", TECHNIQUE_FLAG_200},
|
||||
{"build_floatz_clear", TECHNIQUE_FLAG_200},
|
||||
{"build_floatz_dtex", TECHNIQUE_FLAG_200},
|
||||
{"build_floatz_ua", TECHNIQUE_FLAG_200},
|
||||
{"build_floatz_ua_dtex", TECHNIQUE_FLAG_200},
|
||||
{"build_shadowmap_depth_nc", TECHNIQUE_FLAG_200},
|
||||
{"build_shadowmap_depth_ua", TECHNIQUE_FLAG_200},
|
||||
{"build_shadowmap_model_dtex", TECHNIQUE_FLAG_200},
|
||||
{"build_shadowmap_model_nc_dtex", TECHNIQUE_FLAG_200},
|
||||
{"build_shadowmap_model_ua", TECHNIQUE_FLAG_200},
|
||||
{"cinematic", TECHNIQUE_FLAG_200},
|
||||
{"cinematic_3d", TECHNIQUE_FLAG_200},
|
||||
{"cinematic_dtex_3d", TECHNIQUE_FLAG_200},
|
||||
{"dof_near_coc", TECHNIQUE_FLAG_200},
|
||||
{"floatz", TECHNIQUE_FLAG_200},
|
||||
{"floatzdisplay", TECHNIQUE_FLAG_200},
|
||||
{"particle_blend", TECHNIQUE_FLAG_200},
|
||||
{"particle_zdownsample", TECHNIQUE_FLAG_200},
|
||||
{"passthru_alpha", TECHNIQUE_FLAG_200},
|
||||
{"postfx", TECHNIQUE_FLAG_200},
|
||||
{"postfx_mblur", TECHNIQUE_FLAG_200},
|
||||
{"processed_floatz", TECHNIQUE_FLAG_200},
|
||||
{"ps3_aadownsample", TECHNIQUE_FLAG_200},
|
||||
{"shell_shock", TECHNIQUE_FLAG_200},
|
||||
{"shell_shock_flashed", TECHNIQUE_FLAG_200},
|
||||
{"small_blur", TECHNIQUE_FLAG_200},
|
||||
{"stencildisplay", TECHNIQUE_FLAG_200},
|
||||
{"stencilshadow", TECHNIQUE_FLAG_200},
|
||||
{"wireframe_solid", TECHNIQUE_FLAG_200},
|
||||
{"wireframe_solid_atest_dtex", TECHNIQUE_FLAG_200},
|
||||
{"wireframe_solid_dtex", TECHNIQUE_FLAG_200},
|
||||
{"wireframe_solid_nc", TECHNIQUE_FLAG_200},
|
||||
{"wireframe_solid_nc_dtex", TECHNIQUE_FLAG_200},
|
||||
{"wireframe_solid_ua", TECHNIQUE_FLAG_200},
|
||||
{"wireframe_solid_ua_dtex", TECHNIQUE_FLAG_200}
|
||||
{"zprepass", TECHNIQUE_FLAG_4 | TECHNIQUE_FLAG_200 },
|
||||
{"build_floatz", TECHNIQUE_FLAG_8 },
|
||||
{"build_shadowmap_depth", TECHNIQUE_FLAG_10 | TECHNIQUE_FLAG_200},
|
||||
{"build_shadowmap_model", TECHNIQUE_FLAG_10 | TECHNIQUE_FLAG_200},
|
||||
{"distortion_scale_ua_zfeather", TECHNIQUE_FLAG_100 },
|
||||
{"distortion_scale_zfeather", TECHNIQUE_FLAG_100 },
|
||||
{"distortion_scale_zfeather_dtex", TECHNIQUE_FLAG_100 },
|
||||
{"alternate_scene_overlay", TECHNIQUE_FLAG_200 },
|
||||
{"blur_apply", TECHNIQUE_FLAG_200 },
|
||||
{"build_floatz", TECHNIQUE_FLAG_200 },
|
||||
{"build_floatz_clear", TECHNIQUE_FLAG_200 },
|
||||
{"build_floatz_dtex", TECHNIQUE_FLAG_200 },
|
||||
{"build_floatz_ua", TECHNIQUE_FLAG_200 },
|
||||
{"build_floatz_ua_dtex", TECHNIQUE_FLAG_200 },
|
||||
{"build_shadowmap_depth_nc", TECHNIQUE_FLAG_200 },
|
||||
{"build_shadowmap_depth_ua", TECHNIQUE_FLAG_200 },
|
||||
{"build_shadowmap_model_dtex", TECHNIQUE_FLAG_200 },
|
||||
{"build_shadowmap_model_nc_dtex", TECHNIQUE_FLAG_200 },
|
||||
{"build_shadowmap_model_ua", TECHNIQUE_FLAG_200 },
|
||||
{"cinematic", TECHNIQUE_FLAG_200 },
|
||||
{"cinematic_3d", TECHNIQUE_FLAG_200 },
|
||||
{"cinematic_dtex_3d", TECHNIQUE_FLAG_200 },
|
||||
{"dof_near_coc", TECHNIQUE_FLAG_200 },
|
||||
{"floatz", TECHNIQUE_FLAG_200 },
|
||||
{"floatzdisplay", TECHNIQUE_FLAG_200 },
|
||||
{"particle_blend", TECHNIQUE_FLAG_200 },
|
||||
{"particle_zdownsample", TECHNIQUE_FLAG_200 },
|
||||
{"passthru_alpha", TECHNIQUE_FLAG_200 },
|
||||
{"postfx", TECHNIQUE_FLAG_200 },
|
||||
{"postfx_mblur", TECHNIQUE_FLAG_200 },
|
||||
{"processed_floatz", TECHNIQUE_FLAG_200 },
|
||||
{"ps3_aadownsample", TECHNIQUE_FLAG_200 },
|
||||
{"shell_shock", TECHNIQUE_FLAG_200 },
|
||||
{"shell_shock_flashed", TECHNIQUE_FLAG_200 },
|
||||
{"small_blur", TECHNIQUE_FLAG_200 },
|
||||
{"stencildisplay", TECHNIQUE_FLAG_200 },
|
||||
{"stencilshadow", TECHNIQUE_FLAG_200 },
|
||||
{"wireframe_solid", TECHNIQUE_FLAG_200 },
|
||||
{"wireframe_solid_atest_dtex", TECHNIQUE_FLAG_200 },
|
||||
{"wireframe_solid_dtex", TECHNIQUE_FLAG_200 },
|
||||
{"wireframe_solid_nc", TECHNIQUE_FLAG_200 },
|
||||
{"wireframe_solid_nc_dtex", TECHNIQUE_FLAG_200 },
|
||||
{"wireframe_solid_ua", TECHNIQUE_FLAG_200 },
|
||||
{"wireframe_solid_ua_dtex", TECHNIQUE_FLAG_200 },
|
||||
});
|
||||
|
||||
const auto flagsForName = flagsByTechniqueName.find(technique.name);
|
||||
@ -1140,19 +1183,19 @@ namespace IW4
|
||||
stableArgCount++;
|
||||
break;
|
||||
case MTL_UPDATE_CUSTOM:
|
||||
{
|
||||
assert(arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER);
|
||||
if (arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER)
|
||||
{
|
||||
assert(arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER);
|
||||
if (arg.m_arg.type == MTL_ARG_CODE_PIXEL_SAMPLER)
|
||||
const auto customSampler = std::find(std::begin(g_customSamplerSrc), std::end(g_customSamplerSrc), arg.m_arg.u.codeSampler);
|
||||
assert(customSampler != std::end(g_customSamplerSrc));
|
||||
if (customSampler != std::end(g_customSamplerSrc))
|
||||
{
|
||||
const auto customSampler = std::find(std::begin(g_customSamplerSrc), std::end(g_customSamplerSrc), arg.m_arg.u.codeSampler);
|
||||
assert(customSampler != std::end(g_customSamplerSrc));
|
||||
if (customSampler != std::end(g_customSamplerSrc))
|
||||
{
|
||||
const auto customSamplerIndex = customSampler - std::begin(g_customSamplerSrc);
|
||||
out.customSamplerFlags |= 1 << customSamplerIndex;
|
||||
}
|
||||
const auto customSamplerIndex = customSampler - std::begin(g_customSamplerSrc);
|
||||
out.customSamplerFlags |= 1 << customSamplerIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
assert(false);
|
||||
@ -1174,7 +1217,9 @@ namespace IW4
|
||||
dependencies.push_back(in.m_vertex_decl_asset);
|
||||
}
|
||||
|
||||
MaterialTechnique* ConvertTechnique(const std::string& techniqueName, const std::vector<TechniqueCreator::Pass>& passes, std::vector<XAssetInfoGeneric*>& dependencies) const
|
||||
MaterialTechnique* ConvertTechnique(const std::string& techniqueName,
|
||||
const std::vector<TechniqueCreator::Pass>& passes,
|
||||
std::vector<XAssetInfoGeneric*>& dependencies) const
|
||||
{
|
||||
assert(!passes.empty());
|
||||
const auto techniqueSize = sizeof(MaterialTechnique) + (passes.size() - 1u) * sizeof(MaterialPass);
|
||||
@ -1231,7 +1276,7 @@ namespace IW4
|
||||
return m_zone_state->AddLoadedTechnique(techniqueName, techniqueFromRaw, dependencies);
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
||||
void* AssetLoaderTechniqueSet::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
{
|
||||
@ -1262,8 +1307,8 @@ std::string AssetLoaderTechniqueSet::GetStateMapFileName(const std::string& stat
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool AssetLoaderTechniqueSet::CreateTechsetFromDefinition(const std::string& assetName, const techset::TechsetDefinition& definition, ISearchPath* searchPath, MemoryManager* memory,
|
||||
IAssetLoadingManager* manager)
|
||||
bool AssetLoaderTechniqueSet::CreateTechsetFromDefinition(
|
||||
const std::string& assetName, const techset::TechsetDefinition& definition, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager)
|
||||
{
|
||||
auto* techset = memory->Create<MaterialTechniqueSet>();
|
||||
memset(techset, 0, sizeof(MaterialTechniqueSet));
|
||||
@ -1293,7 +1338,8 @@ bool AssetLoaderTechniqueSet::CreateTechsetFromDefinition(const std::string& ass
|
||||
return true;
|
||||
}
|
||||
|
||||
techset::TechsetDefinition* AssetLoaderTechniqueSet::LoadTechsetDefinition(const std::string& assetName, ISearchPath* searchPath, techset::TechsetDefinitionCache* definitionCache)
|
||||
techset::TechsetDefinition*
|
||||
AssetLoaderTechniqueSet::LoadTechsetDefinition(const std::string& assetName, ISearchPath* searchPath, techset::TechsetDefinitionCache* definitionCache)
|
||||
{
|
||||
auto* cachedTechsetDefinition = definitionCache->GetCachedTechsetDefinition(assetName);
|
||||
if (cachedTechsetDefinition)
|
||||
@ -1313,7 +1359,8 @@ techset::TechsetDefinition* AssetLoaderTechniqueSet::LoadTechsetDefinition(const
|
||||
return techsetDefinitionPtr;
|
||||
}
|
||||
|
||||
const state_map::StateMapDefinition* AssetLoaderTechniqueSet::LoadStateMapDefinition(const std::string& stateMapName, ISearchPath* searchPath, techset::TechniqueStateMapCache* stateMapCache)
|
||||
const state_map::StateMapDefinition*
|
||||
AssetLoaderTechniqueSet::LoadStateMapDefinition(const std::string& stateMapName, ISearchPath* searchPath, techset::TechniqueStateMapCache* stateMapCache)
|
||||
{
|
||||
auto* cachedStateMap = stateMapCache->GetCachedStateMap(stateMapName);
|
||||
if (cachedStateMap)
|
||||
@ -1341,7 +1388,8 @@ bool AssetLoaderTechniqueSet::CanLoadFromRaw() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderTechniqueSet::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderTechniqueSet::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
auto* definitionCache = manager->GetAssetLoadingContext()->GetZoneAssetLoaderState<techset::TechsetDefinitionCache>();
|
||||
const auto* techsetDefinition = LoadTechsetDefinition(assetName, searchPath, definitionCache);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "StateMap/StateMapDefinition.h"
|
||||
#include "Techset/TechniqueStateMapCache.h"
|
||||
@ -12,7 +12,10 @@ namespace IW4
|
||||
{
|
||||
class AssetLoaderTechniqueSet final : public BasicAssetLoader<ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet>
|
||||
{
|
||||
static bool CreateTechsetFromDefinition(const std::string& assetName, const techset::TechsetDefinition& definition, ISearchPath* searchPath, MemoryManager* memory,
|
||||
static bool CreateTechsetFromDefinition(const std::string& assetName,
|
||||
const techset::TechsetDefinition& definition,
|
||||
ISearchPath* searchPath,
|
||||
MemoryManager* memory,
|
||||
IAssetLoadingManager* manager);
|
||||
|
||||
public:
|
||||
@ -20,11 +23,14 @@ namespace IW4
|
||||
static std::string GetTechniqueFileName(const std::string& techniqueName);
|
||||
static std::string GetStateMapFileName(const std::string& stateMapName);
|
||||
|
||||
static techset::TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, ISearchPath* searchPath, techset::TechsetDefinitionCache* definitionCache);
|
||||
static const state_map::StateMapDefinition* LoadStateMapDefinition(const std::string& stateMapName, ISearchPath* searchPath, techset::TechniqueStateMapCache* stateMapCache);
|
||||
static techset::TechsetDefinition*
|
||||
LoadTechsetDefinition(const std::string& assetName, ISearchPath* searchPath, techset::TechsetDefinitionCache* definitionCache);
|
||||
static const state_map::StateMapDefinition*
|
||||
LoadStateMapDefinition(const std::string& stateMapName, ISearchPath* searchPath, techset::TechniqueStateMapCache* stateMapCache);
|
||||
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderTracer.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderTracer::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderVehicle.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderVehicle::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "AssetLoaderVertexDecl.h"
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Game/IW4/TechsetConstantsIW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Game/IW4/TechsetConstantsIW4.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderVertexDecl::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
@ -42,7 +42,8 @@ bool AssetLoaderVertexDecl::NextAbbreviation(const std::string& assetName, std::
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssetLoaderVertexDecl::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderVertexDecl::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
MaterialVertexDeclaration decl{};
|
||||
|
||||
@ -50,7 +51,7 @@ bool AssetLoaderVertexDecl::LoadFromRaw(const std::string& assetName, ISearchPat
|
||||
std::string sourceAbbreviation;
|
||||
while (NextAbbreviation(assetName, sourceAbbreviation, currentOffset))
|
||||
{
|
||||
if(decl.streamCount >= std::extent_v<decltype(MaterialVertexStreamRouting::data)>)
|
||||
if (decl.streamCount >= std::extent_v<decltype(MaterialVertexStreamRouting::data)>)
|
||||
{
|
||||
std::cout << "Failed to add vertex decl stream. Too many abbreviations: " << assetName << "\n";
|
||||
return false;
|
||||
@ -63,14 +64,16 @@ bool AssetLoaderVertexDecl::LoadFromRaw(const std::string& assetName, ISearchPat
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto foundSourceAbbreviation = std::find(std::begin(materialStreamSourceAbbreviation), std::end(materialStreamSourceAbbreviation), sourceAbbreviation);
|
||||
const auto foundSourceAbbreviation =
|
||||
std::find(std::begin(materialStreamSourceAbbreviation), std::end(materialStreamSourceAbbreviation), sourceAbbreviation);
|
||||
if (foundSourceAbbreviation == std::end(materialStreamSourceAbbreviation))
|
||||
{
|
||||
std::cout << "Unknown vertex decl source abbreviation: " << sourceAbbreviation << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto foundDestinationAbbreviation = std::find(std::begin(materialStreamDestinationAbbreviation), std::end(materialStreamDestinationAbbreviation), destinationAbbreviation);
|
||||
const auto foundDestinationAbbreviation =
|
||||
std::find(std::begin(materialStreamDestinationAbbreviation), std::end(materialStreamDestinationAbbreviation), destinationAbbreviation);
|
||||
if (foundDestinationAbbreviation == std::end(materialStreamDestinationAbbreviation))
|
||||
{
|
||||
std::cout << "Unknown vertex decl destination abbreviation: " << destinationAbbreviation << "\n";
|
||||
@ -78,7 +81,8 @@ bool AssetLoaderVertexDecl::LoadFromRaw(const std::string& assetName, ISearchPat
|
||||
}
|
||||
|
||||
const auto sourceIndex = static_cast<MaterialStreamStreamSource_e>(foundSourceAbbreviation - std::begin(materialStreamSourceAbbreviation));
|
||||
const auto destinationIndex = static_cast<MaterialStreamDestination_e>(foundDestinationAbbreviation - std::begin(materialStreamDestinationAbbreviation));
|
||||
const auto destinationIndex =
|
||||
static_cast<MaterialStreamDestination_e>(foundDestinationAbbreviation - std::begin(materialStreamDestinationAbbreviation));
|
||||
|
||||
decl.routing.data[decl.streamCount].source = sourceIndex;
|
||||
decl.routing.data[decl.streamCount].dest = destinationIndex;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -14,6 +14,7 @@ namespace IW4
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "AssetLoaderVertexShader.h"
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderVertexShader::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
@ -31,7 +31,8 @@ std::string AssetLoaderVertexShader::GetFileNameForAsset(const std::string& asse
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool AssetLoaderVertexShader::LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
bool AssetLoaderVertexShader::LoadFromRaw(
|
||||
const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const
|
||||
{
|
||||
const auto fileName = GetFileNameForAsset(assetName);
|
||||
const auto file = searchPath->Open(fileName);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -13,6 +13,7 @@ namespace IW4
|
||||
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
bool LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
bool
|
||||
LoadFromRaw(const std::string& assetName, ISearchPath* searchPath, MemoryManager* memory, IAssetLoadingManager* manager, Zone* zone) const override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderWeapon.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderWeapon::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderXAnim.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderXAnim::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderXModel.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderXModel::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AssetLoaderXModelSurfs.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "ObjLoading.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
void* AssetLoaderXModelSurfs::CreateEmptyAsset(const std::string& assetName, MemoryManager* memory)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "AssetLoading/BasicAssetLoader.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
namespace IW4
|
||||
@ -11,4 +11,4 @@ namespace IW4
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
};
|
||||
}
|
||||
} // namespace IW4
|
||||
|
Reference in New Issue
Block a user