-
-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add object LOD management functions #3831
base: master
Are you sure you want to change the base?
Add object LOD management functions #3831
Conversation
Server/mods/deathmatch/logic/luadefs/CLuaFunctionDefs.Server.cpp
Outdated
Show resolved
Hide resolved
The lod arrays from the map editor are incomplete, so I assume this function is also incomplete. Therefore, a note should be added on the wiki once this PR is merged |
No. I completed the table. It's good now. |
getObjectLODModel(int objectModel)
getObjectLODModel
and getObjectModelOfLOD
getObjectLODModel
and getObjectModelOfLOD
getObjectLODOfModel
and getObjectModelOfLOD
The provided LOD model list not only is incomplete, it also contains plain incorrections. Examples are the LLODs for HLOD models 10428, 10369, 10439. |
I'm surprised, I thought the list was generated from the game files not missing anything. Will you suggest a fix for the array? |
Just a note: |
I'm gonna investigate the HLOD => LLOD array. @lotsofs @spooky-spook
It's interesting that PS2 and XBOX versions of the games have different world mapping, but I think this is out of the scope of this LLOD-improvements PR.
|
…a-blue into add-lod-model-func
getObjectLODOfModel
and getObjectModelOfLOD
getObjectLowLODOfModel
and getObjectHighLODOfModel
There is a function that we can use in MTA to obtain a building (world object)'s LLOD model ID: MTA Map Editor makes use of this to find any building's LLOD model so it can be removed from the map along with its HLOD model, using removeWorldModel.
I found that, for example, 10369'S LLOD model is 10511. Both these HLOD and LLOD models are defined in the game IPL files: 10511 is defined in a plaintext IPL "SFs.ipl", while 10369 is in a binary IPL that I converted to text "sfs_stream0.ipl" 😃 According to these 2 images, you can see that 10369's IPL line has "128" in the last position, which means that its LLOD model is the object instantiated at index 128 (indexes start at 0) of SFs. The LLOD 10511 is instantiated at exactly index 128 in SFS.ipl. The only annoying fact is that they are in different files that both start with sfs. So, yes, something went wrong creating the LODs table, I will look into generating a correct one. |
Don't get me wrong I didn't mean that you should fix this :) It was just a note that game files are different on some platforms. We cannot be sure on how much port has differences. Not only xbox, ps2 and pc. The newer versions mainly use the xbox version, but who knows if they left out something OR re-added missing objects for example. (They could also added new objects, object-placements which were missing from ps2/xbox but were existed in dev files.) The xbox and ps2 persions created at the same time, but ps2 was the superior. Yet they still could have made differences in xbox's .ipl and .ide files for some reason. (very likely they didn't) PC is ported from xbox, and they cut of a lot of objects from the .ipl files there who knows why. But that doesn't mean that these objects not even exist, they can be used, they still have LLODs as well but never used in the game. So for someone who wants to collect the LLOD ids by deleting objects in map editor is not ideal if the objects newer placed at all. Problem is if the ports also have different .ide files, then the objects doesn't even exist. (Very likely the .ide files are not touched, only .ipl files are) And btw, the site you give me is very good, I didn't read it fully but I already read some things which I didn't know and I'm always interested to read about this game, especially if its new to me. I'd like to point out that these sites, and youtube videos etc are mainly based on very dedicated person's self observations when playing the game. So like nobody had the chance to have all main ports game files at their side and make comparisons between them, they just noticed these changes/differences by playing :) What i wrote now has nothing to do with this PR and it's just a side note. |
@derxgbb Thank you for the observations. Indeed, we could work on improving the I didn't mind you mentioning this stuff on this PR as it is related to the theme of LODs. :-) |
I made a few experiments and a script to generate the new HLOD=>LLOD table (fixed, no missing models or incorrect assignments) directly from games files. I've commited the newly generated file! Now, with model names and IPL file names! mtasa-blue/Shared/mods/deathmatch/logic/CLodModels.cpp Lines 18 to 29 in 81c971a
HLOD 3427 (derrick01):
HLOD 3303 (des_bighus03):
HLOD 3724 (laxrf_cargotop):
Here Rockstar applies different LLODs for HLOD 16273 (derrick01), which can be oilderricklod02, oilderricklod03 etc... Also happens for des_bighus03 and laxrf_cargotop. Doesn't happen for any other HLOD models. This seems pointless. |
✅ I conclude that these 3 different models with various super similar LLODs were mistakes made by the creators. I have chosen only 1 LOD for each of these 3 models in CLodModels.cpp (that best match the High Level of Detail model) :D |
In my opinion this is now ready to be implemented. I'd be happy to hear from the people who have commented on this PR previously. |
I would suggest to move these functions into a resource. So developers will able to customize the list with their own models |
ProcessLineOfSight is useful, but about .5% of LLODs are not caught by it. Indeed, I have started deleting the entirety of San Andreas in the map editor to compile a list of removeWorldObjects in the .map file which contains both HLOD and LLOD models, and apply manual corrections where applicable. It's about 40% done. It takes a bit of time, but it's also kind of therapeutic so I mind not. Once it's done it can be put side by side with your newly automatic generated list and we can investigate discrepancies. Unfortunately I have neglected to make note of the special cases that required manual correction. |
Please comment again when you've compared the table I've generated with yours. If you look at the comment at the end of each line in I'm sure with high certainty that this table is correct. |
The benefit of not having a resource is so that new .map generated by the Map Editor can have native LOD support without the need to include a separate resource just for this in the server, thanks to small .lua script included in the map resource (without a HUGE lods lua table). See multitheftauto/mtasa-resources#556 I can easily make a "set function" to "customize this list" in this c++ PR. Let me try. |
getObjectLowLODOfModel
and getObjectHighLODOfModel
Done, check it out @TheNormalnij |
Definitions:
HLOD = High Level of Detail (normal object models the player sees when near the object)
LLOD = Low Level of Detail (object models with less detail the player sees when far from the object)
Adds new clientside functions:
getObjectLowLODModel(number highLODModel)
- returns the LLOD model of the HLOD model passedgetObjectHighLODModel(number lowLODModel)
- counterpart function start searches the HLOD of a LLODsetObjectCustomLowLODModel(number highLODModel, number lowLODModel)
- defines a custom LLOD of a HLOD that will be returned in the previous functionsresetObjectCustomLowLODModel(number highLODModel)
- unsets a custom LLOD of a HLOD that was set with the previous functionresetAllObjectCustomLowLODModels()
- unsets all custom LLODs of HLODsTo be used in conjunction with:
createObject
/createBuilding
setLowLODElement
engineSetModelLODDistance
This solves the problem of having to include a Lua LOD_TABLE in every map's script, which has been happening for years (the map editor's LOD table happens to be incomplete as of submitting this PR), providing a simple solution to obtain an object's LLOD model ID in the code.
Related to multitheftauto/mtasa-resources#556
Examples:
LLOD model of HLOD model ganghous03_LAx (3655) is lodganghous03_lax (3656).