mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
Only dump model surfs once
This commit is contained in:
parent
6ff86ae5e7
commit
30870c5e07
@ -11,6 +11,24 @@
|
|||||||
|
|
||||||
using namespace IW4;
|
using namespace IW4;
|
||||||
|
|
||||||
|
namespace IW4
|
||||||
|
{
|
||||||
|
class SurfsDumpingZoneState final : public IZoneAssetDumperState
|
||||||
|
{
|
||||||
|
std::set<const XModelSurfs*> m_dumped_surfs;
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool ShouldDumpTechnique(const XModelSurfs* surfs)
|
||||||
|
{
|
||||||
|
if (m_dumped_surfs.find(surfs) != m_dumped_surfs.end())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_dumped_surfs.emplace(surfs);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
bool AssetDumperXModel::ShouldDump(XAssetInfo<XModel>* asset)
|
bool AssetDumperXModel::ShouldDump(XAssetInfo<XModel>* asset)
|
||||||
{
|
{
|
||||||
return !asset->m_name.empty() && asset->m_name[0] != ',';
|
return !asset->m_name.empty() && asset->m_name[0] != ',';
|
||||||
@ -235,10 +253,14 @@ void AssetDumperXModel::DumpObjLod(const AssetDumpingContext& context, XAssetInf
|
|||||||
void AssetDumperXModel::DumpObj(AssetDumpingContext& context, XAssetInfo<XModel>* asset)
|
void AssetDumperXModel::DumpObj(AssetDumpingContext& context, XAssetInfo<XModel>* asset)
|
||||||
{
|
{
|
||||||
const auto* model = asset->Asset();
|
const auto* model = asset->Asset();
|
||||||
|
auto* surfZoneState = context.GetZoneAssetDumperState<SurfsDumpingZoneState>();
|
||||||
|
|
||||||
DumpObjMat(context, asset);
|
DumpObjMat(context, asset);
|
||||||
for (auto currentLod = 0u; currentLod < model->numLods; currentLod++)
|
for (auto currentLod = 0u; currentLod < model->numLods; currentLod++)
|
||||||
{
|
{
|
||||||
|
if (!model->lodInfo[currentLod].modelSurfs || !surfZoneState->ShouldDumpTechnique(model->lodInfo[currentLod].modelSurfs))
|
||||||
|
continue;
|
||||||
|
|
||||||
DumpObjLod(context, asset, currentLod);
|
DumpObjLod(context, asset, currentLod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -593,11 +615,14 @@ void AssetDumperXModel::DumpXModelExportLod(const AssetDumpingContext& context,
|
|||||||
writer->Write(*assetFile);
|
writer->Write(*assetFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetDumperXModel::DumpXModelExport(const AssetDumpingContext& context, XAssetInfo<XModel>* asset)
|
void AssetDumperXModel::DumpXModelExport(AssetDumpingContext& context, XAssetInfo<XModel>* asset)
|
||||||
{
|
{
|
||||||
|
auto* surfZoneState = context.GetZoneAssetDumperState<SurfsDumpingZoneState>();
|
||||||
const auto* model = asset->Asset();
|
const auto* model = asset->Asset();
|
||||||
for (auto currentLod = 0u; currentLod < model->numLods; currentLod++)
|
for (auto currentLod = 0u; currentLod < model->numLods; currentLod++)
|
||||||
{
|
{
|
||||||
|
if (!model->lodInfo[currentLod].modelSurfs || !surfZoneState->ShouldDumpTechnique(model->lodInfo[currentLod].modelSurfs))
|
||||||
|
continue;
|
||||||
DumpXModelExportLod(context, asset, currentLod);
|
DumpXModelExportLod(context, asset, currentLod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace IW4
|
|||||||
static void AddXModelVertexBoneWeights(AbstractXModelWriter& writer, const XModelSurfs* modelSurfs, XModelVertexBoneWeightCollection& weightCollection);
|
static void AddXModelVertexBoneWeights(AbstractXModelWriter& writer, const XModelSurfs* modelSurfs, XModelVertexBoneWeightCollection& weightCollection);
|
||||||
static void AddXModelFaces(AbstractXModelWriter& writer, const DistinctMapper<Material*>& materialMapper, const XModelSurfs* modelSurfs, int baseSurfaceIndex);
|
static void AddXModelFaces(AbstractXModelWriter& writer, const DistinctMapper<Material*>& materialMapper, const XModelSurfs* modelSurfs, int baseSurfaceIndex);
|
||||||
static void DumpXModelExportLod(const AssetDumpingContext& context, XAssetInfo<XModel>* asset, unsigned lod);
|
static void DumpXModelExportLod(const AssetDumpingContext& context, XAssetInfo<XModel>* asset, unsigned lod);
|
||||||
static void DumpXModelExport(const AssetDumpingContext& context, XAssetInfo<XModel>* asset);
|
static void DumpXModelExport(AssetDumpingContext& context, XAssetInfo<XModel>* asset);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool ShouldDump(XAssetInfo<XModel>* asset) override;
|
bool ShouldDump(XAssetInfo<XModel>* asset) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user