From 8e20697f4ffbdfedff87c10cfedf5e439849dc3b Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 13 Apr 2022 18:27:21 -0700 Subject: [PATCH] Change how DynOS generates actors - generate any geolayout that isn't referenced by another --- data/dynos.cpp.h | 5 ++--- data/dynos_bin_actor.cpp | 32 +++++++++++--------------------- data/dynos_bin_geo.cpp | 4 +++- data/dynos_bin_lvl.cpp | 5 +++-- 4 files changed, 19 insertions(+), 27 deletions(-) diff --git a/data/dynos.cpp.h b/data/dynos.cpp.h index f6bd2b85..4906b495 100644 --- a/data/dynos.cpp.h +++ b/data/dynos.cpp.h @@ -450,9 +450,8 @@ struct GfxData : NoCopy { DataNodes mAnimations; Array> mAnimationTable; - // Generate - Array *> mGenerateGeoLayouts; - Array *> mGenerateLevelScripts; + // Skip bin output of children + Array *> mChildGeoLayouts; // Current u64 mLoadIndex = 0; diff --git a/data/dynos_bin_actor.cpp b/data/dynos_bin_actor.cpp index 0083da32..1fa9638a 100644 --- a/data/dynos_bin_actor.cpp +++ b/data/dynos_bin_actor.cpp @@ -146,7 +146,15 @@ static String GetActorFolder(const Array> &aActorsFolders, u64 } static void DynOS_Actor_Generate(const SysPath &aPackFolder, Array> _ActorsFolders, GfxData *_GfxData) { - for (auto &_GeoNode : _GfxData->mGenerateGeoLayouts) { + // generate in reverse order to detect children + for (s32 geoIndex = _GfxData->mGeoLayouts.Count() - 1; geoIndex >= 0; geoIndex--) { + auto &_GeoNode = _GfxData->mGeoLayouts[geoIndex]; + + // if this is a child geo layout, don't save it as a bin + if (_GfxData->mChildGeoLayouts.Find(_GeoNode) != -1) { + continue; + } + String _GeoRootName = _GeoNode->mName; // If there is an existing binary file for this layout, skip and go to the next actor @@ -220,6 +228,8 @@ static void DynOS_Actor_Generate(const SysPath &aPackFolder, ArraymLuaPointerList.Clear(); _GfxData->mLuaTokenList.Clear(); } + + _GfxData->mChildGeoLayouts.Clear(); } void DynOS_Actor_GeneratePack(const SysPath &aPackFolder) { @@ -250,26 +260,6 @@ void DynOS_Actor_GeneratePack(const SysPath &aPackFolder) { DynOS_Read_Source(_GfxData, fstring("%s/geo.inc.c", _Folder.c_str())); DynOS_Read_Source(_GfxData, fstring("%s/collision.inc.c", _Folder.c_str())); - // Figure out which geo layouts to generate - s32 geoLayoutCount = _GfxData->mGeoLayouts.Count(); - if (geoLayoutCount > prevGeoLayoutCount) { - // find actors to generate - bool foundActor = false; - for (s32 i = prevGeoLayoutCount; i < geoLayoutCount; i++) { - String _GeoRootName = _GfxData->mGeoLayouts[i]->mName; - const void* actor = DynOS_Actor_GetLayoutFromName(_GeoRootName.begin()); - if (actor != NULL) { - foundActor = true; - _GfxData->mGenerateGeoLayouts.Add(_GfxData->mGeoLayouts[i]); - } - } - - // if we haven't found an actor, just add the last geo layout found - if (!foundActor) { - _GfxData->mGenerateGeoLayouts.Add(_GfxData->mGeoLayouts[geoLayoutCount - 1]); - } - } - if (_GfxData->mModelIdentifier != 0) { _ActorsFolders.Add({ _GfxData->mModelIdentifier, String(_PackEnt->d_name) }); } diff --git a/data/dynos_bin_geo.cpp b/data/dynos_bin_geo.cpp index ae453fc4..be556e3b 100644 --- a/data/dynos_bin_geo.cpp +++ b/data/dynos_bin_geo.cpp @@ -111,7 +111,9 @@ static s64 ParseGeoSymbolArg(GfxData* aGfxData, DataNode* aNode, u64& // Geo layouts for (auto& _Node : aGfxData->mGeoLayouts) { if (_Arg == _Node->mName) { - return (s64) DynOS_Geo_Parse(aGfxData, _Node, false)->mData; + auto geoNode = DynOS_Geo_Parse(aGfxData, _Node, false); + aGfxData->mChildGeoLayouts.Add(geoNode); + return (s64) geoNode->mData; } } diff --git a/data/dynos_bin_lvl.cpp b/data/dynos_bin_lvl.cpp index 633a39ca..f1936f1e 100644 --- a/data/dynos_bin_lvl.cpp +++ b/data/dynos_bin_lvl.cpp @@ -2086,14 +2086,15 @@ static bool DynOS_Lvl_GeneratePack_Internal(const SysPath &aPackFolder, ArraymMovtexs); ClearLvlDataNodes(_GfxData->mMovtexQCs); ClearLvlDataNodes(_GfxData->mRooms); - ClearLvlDataNodes(_GfxData->mGenerateGeoLayouts); - ClearLvlDataNodes(_GfxData->mGenerateLevelScripts); _GfxData->mPointerList.Clear(); _GfxData->mPointerOffsetList.Clear(); _GfxData->mLuaPointerList.Clear(); _GfxData->mLuaTokenList.Clear(); generated = true; } + + _GfxData->mChildGeoLayouts.Clear(); + return generated; }