-
-
Notifications
You must be signed in to change notification settings - Fork 439
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 LOD management functions #3831
base: master
Are you sure you want to change the base?
Add 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.
|
No but no feedback beyond that as I thought it was a great idea from your point of view. |
Updated main post with code example usages. |
|
World object LOD is actually not managed by any Lua functions currently. So, as you said, if you want to customize a palm tree's LLOD, you need to use removeWorldModel to remove both the HLOD and the LLOD of that tree, create a custom object/building with HLOD model there, then create another object/building with the LLOD model, and finally set it as the low lod element of the high lod element. Or you can do use engineReplaceModel to replace a palm tree Low LOD model, and the result will be seen on all world object palm trees part of the default map. |
Yeah but the thing is, palm trees dont have LLODs, thats why I made that question But I think thats out of the scope of this PR, thanks for the response Fer |
Someone could want to change CJ's house's LLOD model from lod1carlshou1_lae (17768) to something else, while automatically updating the world/landscape object in Grove Street, without having to mess with the object/building system. Automatic LLOD creation & assignment is a problem. There are 3 different object types in the world:
As a developer, I'd love to have a function that automatically creates and assigns a LLOD object to a given or all objects with a certain HLOD model in my server. We could have a function to do automatic LOD management for world objects. For object/building elements the way to create and set LLODs is the following: We can think about how we would improve this process.
Oh I'm always happy to discuss, I think it's related to this topic and we can do lil brainstorming. |
I can also make It'd be useful for projects that a lot of LLOD models to objects that don't have LOD in GTA SA, giving the game a new look and feel. E.g. https://www.mixmods.com.br/2021/12/lod-vegetation-distant-trees/ Opinions? |
I would prefer a simple solution with |
#include "CLodModels.h" | ||
|
||
constexpr std::size_t OBJ_LOD_MODELS_COUNT = 4289; | ||
constexpr std::pair<std::uint32_t, std::uint32_t> OBJ_LOD_MODELS_ARRAY[] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this array. Just define a hashmap
createObjectWithLod and createBuildingWithLod sound good! I am still in favor of implementing the new LOD ID management functions described the main post. They are useful for getting the LLOD id of an HLOD id, and also setting custom LLOD ids for custom systems. Also, what do you think about making |
The new LLOD ID management functions are a big step towards a more robust and adaptable system. The possibility of customizing LLOD IDs for specific systems offers a high degree of control. The setObjectCustomLowLODModel function is particularly interesting. By automatically updating LLOD models, it not only simplifies development, but also helps to avoid visual inconsistencies in the game. |
yes that would be nice... although im guessing that function is also useful for custom models. My request was surely really specific so I'm not sure everyone would like that... maybe we could have a third argument that if its I'm down to test that change if needed because i think it would be pretty cool. Otherwise the only way to implement loads of LLODs to existing world buildings would be to delete them all (reading IPL files, parsing those) and create new ones. Second option seems to be too problematic/not worth it. Out of the scope of this PR but maybe we should have a way to retrieve all world objects in some way. Right now if you want to find a world object you need to use |
Sure, I'd like to add the feature to automatically update world object LLODs. For finding all world objects, I have parsed all of the game IPLs. This is enough tbh, and you can easily use Lua scripts for your needs. I put everything here, including the binary ipls I converted to text. https://github.com/Fernando-A-Rocha/mta-binary-ipl-to-text |
Check it out so far, ive redone some functions. Moved things to model related files. Added isValidModel (general purpose func) @TheNormalnij I added model id checks, and also made it reset in engineFreeModel and when model manager is unloaded. Is this ok? |
CLuaCFunctions::AddFunction(name, func); | ||
} | ||
|
||
bool CLuaModelDefs::IsValidModel(std::string modelPurpose, std::uint32_t id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about an enum instead of string?
|
||
bool CLuaModelDefs::SetModelLOD(std::string modelPurpose, std::uint32_t hLODModel, std::uint32_t lLODModel) | ||
{ | ||
if (!(modelPurpose == "object" || modelPurpose == "building")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(modelPurpose != "object" && modelPurpose != "building")
|
||
constexpr std::size_t OBJ_LOD_MODELS_COUNT = 4289; | ||
constexpr std::pair<std::uint32_t, std::uint32_t> OBJ_LOD_MODELS_ARRAY[] = { | ||
{694, 784}, // sm_redwoodgrp => lod_redwoodgrp (countryS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe too much spacing before the comment?
{X, Y}, // comment
instead of
{X, Y}, // comment
{13804, 13808}, // cuntelandf4 => lodcuntelandf4 (LAhills) | ||
{13805, 13807}, // celalandbiv => lodcelalandbiv (LAhills) | ||
{13809, 13811}, // ce_grndpalcst02 => lodcepalcst02 (LAhills) | ||
{13810, 13812}, // ce_grndpalcst05 => lodce_grndpalcst05 (LAhills) | ||
{13813, 13815}, // cegraveblok03e => lodcegraveblok03e (LAhills) | ||
{13814, 13787}, // ceroadn => lodceroadn (LAhills) | ||
{13816, 13877}, // ce_safeground => ce_s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need that?
Important
HLOD = High Level of Detail (normal models the player sees when near)
LLOD = Low Level of Detail (models with less detail the player sees when far)
Details
Adds new clientside model utility & Level-Of-Detail(LOD) management functions
WIP
To 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).
Practical code examples:
WIP