-
-
Notifications
You must be signed in to change notification settings - Fork 440
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
Draft
Fernando-A-Rocha
wants to merge
36
commits into
multitheftauto:master
Choose a base branch
from
Fernando-A-Rocha:add-lod-model-func
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
6f7c6c6
add shared func getObjectLODModel(int objectModel)
Fernando-A-Rocha f182db2
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha cb928f1
refactor 1
Fernando-A-Rocha 93251bd
new arg parser
Fernando-A-Rocha d0419a3
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha 62cb6e8
rename to GetObjectLODOfModel
Fernando-A-Rocha c648cbb
add getObjectModelOfLOD
Fernando-A-Rocha 405ad8d
refactors
Fernando-A-Rocha 51e8967
refactor
Fernando-A-Rocha 21e7b28
test @TracerDS
Fernando-A-Rocha 6244ebb
fix OBJ_LOD_MODELS array @TracerDS
Fernando-A-Rocha 73a4252
constexpr
Fernando-A-Rocha 832c6bd
Update CLodModels.cpp
Fernando-A-Rocha be36dc5
Update CLodModels.cpp
Fernando-A-Rocha 765f7aa
rename GetObjectLowLODOfModel and GetObjectHighLODOfModel
Fernando-A-Rocha c3613f3
Merge branch 'add-lod-model-func' of github.com:Fernando-A-Rocha/mtas…
Fernando-A-Rocha 71fb7f5
incomplete lod array sorted WIP
Fernando-A-Rocha 26f980e
comment
Fernando-A-Rocha 81c971a
Fixed LOD table WIP
Fernando-A-Rocha 1e223ab
funcs refactor
Fernando-A-Rocha 4225df7
uselesss include
Fernando-A-Rocha caec9d7
del getObjectCustomLowLODModel
Fernando-A-Rocha a6466f5
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha a43f1ad
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha 9a1fece
Update Shared/mods/deathmatch/logic/CLodModels.h
Fernando-A-Rocha 0b771df
Update Shared/mods/deathmatch/logic/CLodModels.h
Fernando-A-Rocha 9c117fd
optimize lookups
Fernando-A-Rocha 1f3ddc6
comments
Fernando-A-Rocha e563d71
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha 50e282e
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha 70809d5
Merge branch 'master' into add-lod-model-func
Fernando-A-Rocha 5af6b06
rename funcs, add isValidModel WIP
Fernando-A-Rocha 93c98c8
.
Fernando-A-Rocha cbad928
.
Fernando-A-Rocha ab63086
isValidModel update
Fernando-A-Rocha b03ea49
wip
Fernando-A-Rocha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: mods/shared_logic/luadefs/CLuaModelDefs.cpp | ||
* PURPOSE: Lua model definitions class | ||
* | ||
* Multi Theft Auto is available from http://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#include "StdInc.h" | ||
#include <lua/CLuaFunctionParser.h> | ||
#include "CLodModels.h" | ||
#include "CClientObjectManager.h" | ||
#include "CClientBuildingManager.h" | ||
|
||
void CLuaModelDefs::LoadFunctions() | ||
{ | ||
constexpr static const std::pair<const char*, lua_CFunction> functions[]{ | ||
// Util func | ||
{"isValidModel", ArgumentParser<IsValidModel>}, | ||
|
||
// LOD funcs | ||
{"getModelLowLOD", ArgumentParser<GetModelLowLOD>}, | ||
{"getModelHighLOD", ArgumentParser<GetModelHighLOD>}, | ||
{"setModelLOD", ArgumentParser<SetModelLOD>}, | ||
{"resetModelLODByHigh", ArgumentParser<ResetModelLODByHigh>}, | ||
{"resetModelLODByLow", ArgumentParser<ResetModelLODByLow>}, | ||
{"resetAllModelLOD", ArgumentParser<ResetAllModelLOD>}, | ||
}; | ||
|
||
// Add functions | ||
for (const auto& [name, func] : functions) | ||
CLuaCFunctions::AddFunction(name, func); | ||
} | ||
|
||
bool CLuaModelDefs::IsValidModel(std::string modelPurpose, std::uint32_t id) | ||
{ | ||
if (modelPurpose == "object") | ||
return CClientObjectManager::IsValidModel(id); | ||
else if (modelPurpose == "weapon") | ||
return CClientPedManager::IsValidWeaponModel(id); | ||
else if (modelPurpose == "upgrade") | ||
return CVehicleUpgrades::IsUpgrade(id); | ||
else if (modelPurpose == "building") | ||
return CClientBuildingManager::IsValidModel(id); | ||
else if (modelPurpose == "vehicle") | ||
return CClientVehicleManager::IsValidModel(id); | ||
else if (modelPurpose == "ped" || modelPurpose == "player") | ||
return CClientPlayerManager::IsValidModel(id); | ||
|
||
throw std::invalid_argument("Invalid model purpose passed, expected [object, weapon, upgrade, building, vehicle, ped, player]"); | ||
} | ||
|
||
std::variant<bool, std::uint32_t> CLuaModelDefs::GetModelLowLOD(std::uint32_t hLODModel) noexcept | ||
{ | ||
return CLodModels::GetModelLowLOD(hLODModel); | ||
} | ||
|
||
std::variant<bool, std::uint32_t> CLuaModelDefs::GetModelHighLOD(std::uint32_t lLODModel) noexcept | ||
{ | ||
return CLodModels::GetModelHighLOD(lLODModel); | ||
} | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
throw std::invalid_argument("Invalid model purpose passed, the only options for LOD are 'object' or 'building'"); | ||
|
||
if (!IsValidModel(modelPurpose, hLODModel)) | ||
throw std::invalid_argument("Invalid High-LOD model ID passed"); | ||
|
||
if (!IsValidModel(modelPurpose, lLODModel)) | ||
throw std::invalid_argument("Invalid Low-LOD model ID passed"); | ||
|
||
return CLodModels::SetModelLOD(hLODModel, lLODModel); | ||
} | ||
|
||
bool CLuaModelDefs::ResetModelLODByHigh(std::uint32_t hLODModel) noexcept | ||
{ | ||
return CLodModels::ResetModelLODByHigh(hLODModel); | ||
} | ||
|
||
bool CLuaModelDefs::ResetModelLODByLow(std::uint32_t hLODModel) noexcept | ||
{ | ||
return CLodModels::ResetModelLODByLow(hLODModel); | ||
} | ||
|
||
void CLuaModelDefs::ResetAllModelLOD() noexcept | ||
{ | ||
CLodModels::ResetAllModelLOD(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: mods/shared_logic/luadefs/CLuaModelDefs.h | ||
* PURPOSE: Lua model definitions class header | ||
* | ||
* Multi Theft Auto is available from http://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
#include "CLuaDefs.h" | ||
|
||
class CLuaModelDefs : public CLuaDefs | ||
{ | ||
public: | ||
static void LoadFunctions(); | ||
|
||
// Util func | ||
static bool IsValidModel(std::string modelPurpose, std::uint32_t id); | ||
|
||
// LOD funcs | ||
static std::variant<bool, std::uint32_t> GetModelLowLOD(std::uint32_t hLODModel) noexcept; | ||
static std::variant<bool, std::uint32_t> GetModelHighLOD(std::uint32_t lLODModel) noexcept; | ||
static bool SetModelLOD(std::string modelPurpose, std::uint32_t hLODModel, std::uint32_t lLODModel); | ||
static bool ResetModelLODByHigh(std::uint32_t hLODModel) noexcept; | ||
static bool ResetModelLODByLow(std::uint32_t lLODModel) noexcept; | ||
static void ResetAllModelLOD() noexcept; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?