@@ -21,6 +21,13 @@ local LOADING_QUEUE_PHASES = {
2121local currFreeIdDelay = 9500 -- ms
2222local FREE_ID_DELAY_STEP = 500 -- ms
2323
24+ local function getCustomModelSetting (settings , key )
25+ if settings and settings [key ] ~= nil then
26+ return settings [key ]
27+ end
28+ return DEFAULT_AUTO_MODEL_SETTINGS [key ]
29+ end
30+
2431local function applyElementCustomModel (element )
2532 local customModel = elementModels [element ]
2633 if not customModel then return end
@@ -87,7 +94,7 @@ local function finishLoadCustomModel(customModel)
8794 return
8895 end
8996
90- local enableDFFAlphaTransparency = customInfo .settings . enableDFFAlphaTransparency
97+ local enableDFFAlphaTransparency = getCustomModelSetting ( customInfo .settings , " enableDFFAlphaTransparency" )
9198
9299 if (col and not engineReplaceCOL (col .element , allocatedModel ))
93100 or (txd and not engineImportTXD (txd .element , allocatedModel ))
@@ -114,14 +121,14 @@ local function finishLoadCustomModel(customModel)
114121 reusableModelElements [dff .path ] = dff .element
115122 end
116123
117- local disableAutoFree = customInfo .settings . disableAutoFree
118- local lodDistance = customInfo .settings . lodDistance
119- if lodDistance then
124+ local disableAutoFree = getCustomModelSetting ( customInfo .settings , " disableAutoFree" )
125+ local lodDistance = getCustomModelSetting ( customInfo .settings , " lodDistance" )
126+ if type ( lodDistance ) == " number " then
120127 engineSetModelLODDistance (allocatedModel , lodDistance )
121128 end
122129
123- local physicalPropsGroup = customInfo .settings . physicalPropsGroup
124- if physicalPropsGroup then
130+ local physicalPropsGroup = getCustomModelSetting ( customInfo .settings , " physicalPropsGroup" )
131+ if type ( physicalPropsGroup ) == " number " then
125132 engineSetModelPhysicalPropertiesGroup (allocatedModel , physicalPropsGroup )
126133 end
127134
@@ -196,7 +203,8 @@ local function beginLoadCustomModelElements(customModel)
196203 end
197204
198205 local colPath , txdPath , dffPath = customInfo .col , customInfo .txd , customInfo .dff
199- local disableTXDTextureFiltering = customInfo .settings .disableTXDTextureFiltering
206+ local disableTXDTextureFiltering = getCustomModelSetting (customInfo .settings , " disableTXDTextureFiltering" )
207+ local loadRawData = getCustomModelSetting (customInfo .settings , " loadRawData" )
200208
201209 local decryptFunc = getNandoDecrypterFunction ()
202210
@@ -234,10 +242,9 @@ local function beginLoadCustomModelElements(customModel)
234242 end
235243 if not modElement then
236244 onFailedToLoadModFile (customModel , modPath , modType )
237- return false
245+ return
238246 end
239247 onLoadedModFile (customModel , modType , modPath , modElement )
240- return true
241248 end
242249
243250 local function loadOneMod (modType , modPath )
@@ -249,12 +256,19 @@ local function beginLoadCustomModelElements(customModel)
249256 loadModElement (modType , modPath , data )
250257 end ) then
251258 onFailedToLoadModFile (customModel , modPath , modType )
252- return
253259 end
254- else
255- if not loadModElement (modType , modPath ) then
260+ elseif loadRawData then
261+ local file = fileOpen (modPath )
262+ if not file then
263+ onFailedToLoadModFile (customModel , modPath , modType )
256264 return
257265 end
266+ local data = fileRead (file , fileGetSize (file ))
267+ fileClose (file )
268+ -- print("Loaded raw data for", modType, "of custom model", customModel)
269+ loadModElement (modType , modPath , data )
270+ else
271+ loadModElement (modType , modPath )
258272 end
259273 end
260274
@@ -357,7 +371,7 @@ local function beginDownloadModelFiles(customModel)
357371 return
358372 end
359373
360- if (not customInfo .settings [ " downloadFilesOnDemand" ] ) then
374+ if (not getCustomModelSetting ( customInfo .settings , " downloadFilesOnDemand" ) ) then
361375 -- No downloading needed, proceed to load model elements
362376 beginLoadCustomModelElements (customModel )
363377 return
0 commit comments