-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
dxDrawModel3D reimplementation #3266
Conversation
The |
I feel draw functions shouldn't manage model loading. Using this draw function with blocking mode is totally wrong, it causes FPS drops. Async mode is bad too, it causes drawing in a wrong frame. So only "loaded" mode is good here.
|
I feel the same. But the nonblocking model loading is exactly what SA streamer is doing. I mean this is natural for SA.
Looks like these functions do not fit that easy in the context of dxDrawModel3D. |
Are the rendering issues (models becoming invisible at certain view-angles for example) fixed in this PR? |
Of course. This PR is written from scratch keeping in mind all problems of the previous one. Moreover, it would be weird to just reopen a PR with the same problems. |
engineLoadModel and engineUnoadModel are bad names. |
Okay, I'll think about it. |
I think such a function (that loads models) could be handy in other situations too (like pre-loading a section of the world for custom maps, etc). |
Hey, any updates on this? |
Yes, I aggregated all suggestions so that the final PR will contain the following: It requires some polishing and the internal testing. I hope to finish it soon. |
Though, by using SA naming, |
I thought about it too. And I have come up with the following syntax:
There also can be event "onClientModelLoaded". But I'm not sure if this event is actually needed. |
How will it work with addRef = false and addRef = true ?
|
The better name for this argument is "retain". It increments the ref count for the specific model. But only one additional reference per resource. When addRef = false it's just trying to load a model without any guarantees. It's the way SA is doing the streaming. addRef = false is convinient for the case when you need a model just in the current(async = false) or the next frame(async = true). |
"the next frame"
I remember gta uses some sort of multi threading for file loading.
Does gta guarantee that the model will be loaded exactly on the next frame?
|
No, even SA does not guarantee that. I previously mentioned the next frame to emphasize the asynchronous nature of the argument. Of course the precise moment isn't specified. |
engineStreamingRequestModel with
|
I think it's even better to replace addRef = false with persistent = false. It's more illustrative. |
@tederis It is viable to have this feature now, right? |
There could be graphical issues with translucent objects but aside of it, it's viable. There were also proposals that complicate the entire system but they aren't essential. I will try to find time to give it another look. |
Will there still be any updates? I hope very much, as this function could be very useful |
This PR was initially small and simple. During code reviews several suggestions was made that complicate the initial idea. These suggestions may look minor but hide many edge cases that require thorough approach. In this regard I propose to separate |
I'll assist you with |
Great, this pull will be of great importance. |
In my opinion, @Dutchman101, @tederis commented that the problem was the 3D model allocator, with that already resolved by PR #3611 we can comment that now we only need to resolve some parts. |
Done. I have also added a render path for transparent objects. So this PR is fully functional now. But there is still a question whether this function should always work with "loaded" models or there can be several modes(the current implementation) [See the second comment by @TheNormalnij]. My personal opinion is that there's nothing wrong with it and can be considered as a "sugar" for the convenience. |
I suggest to remove modes completely, because they have unpredictable behavior (the function doesn't guarantee render) and cause fps drops (in blocking mode) and model flickering (all modes). local modelId = 1337
local function drawMyModel()
dxDrawModel3D(modelId, 0, 0, 4, 0, 0, 0)
end
local function startDraw()
engineStreamingRequestModel(modelId, true, true)
addEventHandler("onClientPreRender", root, drawMyModel)
end
local function stopDraw()
engineStreamingReleaseModel(modelId, true)
removeEventHandler("onClientPreRender", root, drawMyModel)
end |
This function is indeed doesn't guarantee render. But why do we need that? Async loading is what GTA renderer doing every frame. The blocking loading mode can be considered as an 3D analogue of dxDrawImage(with an image path as an argument). And now, when we have engineStreamingRequestModel/engineStreamingReleaseModel functions a developer can choose between them and a loading mode. The only change that I would make is set default mode to |
dxDrawImage causes only one fps drop on first use. dxDrawModel3D causes fps drops randomly.
It's about API quality. I think that predictable functions are better than functions with uncontrollable result. It's still possible to use this function without modes when you are ready for bugs: local modelId = 1337
engineStreamingRequestModel(modelId, false, false)
dxDrawModel3D(modelId, 0, 0, 4, 0, 0, 0)
-- or
engineStreamingRequestModel(modelId, false, true)
dxDrawModel3D(modelId, 0, 0, 4, 0, 0, 0) |
Your point is fair enough and I'm inclined to accept it. Okay, since there's no other's opinions I'll make the changes. |
The streaming model request functions have been implemented. This is also ready? 😇 |
Yeah, but our build server doesn't work. I'm afraid to put too many changes in a single build |
Brings
dxDrawModel3D
function(#3172) back. The syntax is compatible with the previous one:bool dxDrawModel3D(int model, float x, float y, float z, float rx, float ry, float rz, [float sx = 1.0f, float sy = 1.0f, float sz = 1.0f)
.