Open Rartii opened 3 years ago
As the author of the PR that added this function to MTA, allow me to explain what I think it's going on here.
It seems that R* original vision for vehicle wheel sizes aimed at solving two problems: telling the game engine how big the wheels actually are (so the appropriate collision and ground clearance can be calculated) and representing the relationship between the sizes of the wheels in each axle. IMO, the way they used vehicle wheel sizes to solve these problems (which is exposed in MTA via setVehicleModelWheelSize
) is smart, and although it might seem odd at a first glance, understanding how different "pieces" of the game work together will help making sense of it.
Let's see in detail how GTA: SA uses the wheel size data for rendering vehicles according to whether they have wheel upgrades or not:
Vehicle with non-upgraded wheels (default): as you can read in the fantastic Tut's guide to MTA Modding in 3D, every vehicle model has a hierarchy of components, and the usual wheel-related components that you manipulate with functions like setVehicleComponentPosition
(wheel_lb_dummy
, wheel_rb_dummy
...) are just dummies (i.e. do not have any associated geometry). The only wheel dummy which has geometry below it is wheel_rf_dummy
, where "rf" stands for "right front". This means that every vehicle model contains geometry for just a single wheel, which is a good way to save both space in the resulting DFF and modelling time, because it saves copying the same wheel four times. But, done naively, this would mean that every wheel of every vehicle would be of the same size, and this clearly isn't the case, as several default vehicle models have wheels with different sizes. What kind of black magic is going on here? Well, it's not magic, it's just wheel sizes: if we know the size of the wheels in the front axle and the rear axle, and we assume that the wheel geometry we have for the single wheel in the front axle is of that size, then, to draw the wheels in the rear axle, we just need to scale that reference front wheel by the division of the rear axle size by the front axle size. For example, let's say that the front axle wheel size is 0.7 and the rear size 1.4. As discussed before, the model has geometry data for a wheel in the front axle, so GTA: SA can assume its size is 0.7. As the wheels in the rear axle are 1.4 / 0.7 = 2 times bigger, GTA: SA just draws those wheels two times bigger and leaves the front wheels alone. Problem solved!
Vehicle with upgraded wheels: in this case, as you might already know, GTA: SA does not use the wheels embedded in the vehicle model. Instead of those wheels, it renders the wheels contained in specific wheel models, that you can replace with MTA: SA engine functions. Therefore, a natural question is: how is GTA: SA capable of reusing a single wheel model for a wide range of vehicles, with different wheel sizes, without the result looking atrocious? The answer is, again, wheel sizes. Every upgraded wheel model is exactly 1 unit in size, so we can constrain the previous usage of wheel size values in a way that they also represents the exact size in units of the wheels in that axle. Continuing the previous example, if the front axle wheel size is 0.7, GTA: SA just scales the wheel upgrade model by 0.7, with the expectation that it matches the size of the default wheels (and this expectation holds true because the wheel sizes are chosen such that they represent the size of the default wheels). GTA: SA repeats the process for the wheels in the rear axle, and because their size is 1.4, they are drawn 2 times bigger while still at the same visual size that their default counterparts. Nice! Modelers are happy that they only have to make a single wheel upgrade for every vehicle, and game programmers are also happy to save some precious space!
The bottom line is that the GTA: SA behavior (and, in turn, MTA: SA's) you report is, thus, correct and to be expected. The function is working as intended. I reckon this might sound complex or dense at a first glance, but once you get the hang of it, it's not an issue.
Describe the bug
setVehicleModelWheelSize doesn't change stock wheel visual scale properly.
To reproduce
Change rear only: Size changes properly. Change front only: Front wheel scale stays the same. Rear wheels end up smaller if the front one was made bigger or larger if the front one was made smaller. Change both: No size change
Expected behaviour
If the car has the default wheels the visual size will not match. On the custom wheels this issue does not happen.
Screenshots
Version
v1.5.8-release-20809
Additional context
The wheel scale change only seems to affect the rear axle, the front axle applies negative scale to the rear wheels and this might be the reason why they are the same default size when both axles are changed.