-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix character volume calculation #74348
Fix character volume calculation #74348
Conversation
There's a problem with bionics in this method. If I understand correctly, we are using the average human body density. But by installing the module, we increase the mass of the character. Or we change his density, since installing a module does not change the volume or height of the character. The formula does not take this into account. Just for reference, installing all bionics will give a minimum of +60 kg. (Quick test with scales: naked man 77 kg, the same with all bionics: "error: weight more than 150 kg"). |
Ah, I understand. The formula assumes fat, bone and muscle. I suppose we can subtract the weight of the installed bionics from the total weight and use that? I'll give it a try and see what I can come up with. |
At a closer look, bodyweight() returns the current weight of the character without bionics. However, when your character is standing on a scale, their weight is calculated by get_weight(), which sums bodyweight(), inventory weight, weight of worn items, weight of wielded items, and the weight of installed bionics. So I think the original calculation is correct, bodyweight() returns only the base weight of the character, and the density calculation holds. |
I did some deeper research into body volume calculations, the results of which can be found here: https://github.com/feinorgh/body_volume_calculation I have not compared the results of the implementation in C++ with the Python variants, further adjustments might be needed to fine tune it. Anyway, hopefully this helps with estimating the usefulness of the PR. |
Relying on volumes down to the ml allows us to make changes to volume calculations, and keep the tests withing reasaonable boundaries. references CleverRaven#74263
Make tests more flexible
This strategy makes the test repeatable
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.
Any concerns I've mentioned have been addressed. The Brozek formula is a more accurate way to measure human body volume. Tests have been properly updated to account for the new formula.
Summary
Balance "Bring volume calculations for player body more in line with realistic examples"
Purpose of change
After the addition of volume calculations in #74162, my current character could no longer use any vehicles. The change is well meaning and brings realism, which I like, but the values seemed off, so I set out to make reasonably sized characters (both height and weight wise) able to get into car seats again, while retaining the limits for huge characters.
Describe the solution
I looked up how to calculate volume in the real world, from body density, which itself is dependent on the body fat to muscle and bone ratio, and age (age is NOT included in these calculations currently).
I tried calculating the volume sizes for various heights and sizes to see if they seem reasonable, the results can be found here: #74263.
I changed the volume calculation method for the character, and adjusted the unit tests accordingly.
The previous tests now pass. I removed some assertions based on assumptions on a default character having exactly 70 000 ml volume at 175 cm height, but the functional tests for getting into a vehicle and being cramped now works.
I play tested with my current character too (200 cm tall, normal weight), and she can now get into a car seat, even though she gets the "cramped" debuff.
Describe alternatives you've considered
Another approach would be to change the way car seats and volume calculations are performed, but this seemed like a MUCH bigger task, which would bring little benefit to the game or the maintainability of vehicles and vehicle parts.
Testing
The tests for the volume calculations and getting into a vehicle works, and gives the same results as before.
I've play tested the change, and now my character has to take off her rucksack to be able to sit in the driver seat, but she can drive the car, even though it's cramped.
Additional context
With military rucksack on.
With military rucksack taken off.
Driving nude, in the middle of summer.