-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Lowering the Minimum Unit at Shape3D and Cameras #43547
Lowering the Minimum Unit at Shape3D and Cameras #43547
Conversation
As we discussed this also in GodotVR/gdleapmotion#13 maybe @BastiaanOlij could be interested in a review too. |
Yes, it's true that the current Godot's physics is not very good, and it needs to be improved. That is being discussed in #43073 for 4.0, so we should be actively proposing it. However, the purpose of this PR is to remove the difference between CSG primitives and 3DShape minimums. |
Hey @TokageItLab I'm not sure if my comment was misunderstood. I only wanted to get Bastiaan informed as he is working a lot with VR and was also involved in #23472. |
to @pwab I anticipate that there is a fundamental problem apart from the problem with minimum units. And the cylinder/capsule collision issue affects the physical bones as well. I think this problem would be better recognized a bit more widely, so I hope Bastiaan will focus his attention on physics 4.0 as well. |
The GJK algorithm, used for collision detection, is cheaper when the two shapes are not overlapping. When those are overlapping, more calculations are needed to extract the collisions info. The margin, is used to keep the bodies at a safer distance so to prevent trigger those extra calculations, and keep performance up. Lowering the margin more than 0.04 is discouraged, and preventing the user to go too lower than 0.01 is a good thing. If you need to hide this margin you have two valid routes that allow to preserve the margin:
|
The minimum unit for margin is already 0.001, so it's not a problem to set the default value for margin to 0.04. However again, the difference between the CSG primitive's minimum unit being 0.001 and Shape3D's minimum unit being 0.01 is obviously strange. Using world scales is not a fundamental solution, and is a major obstacle to projects that involve import processes. If we are going to do that, we should add a feature that can be configured in the preferences as an engine feature. For now, I've reverted to 0.04 just for the default values. |
@AndreaCatania scaling up by 10 isn't actually a solution because to keep the physics animation realistic everything also moves 10x as fast and gravity needs to be 10x as high. The end result is that the engine behaves exactly the same asif you have set the margins to a 10th and left the scaling alone. The problem is that in all the videos and explanations I've seen that suggest this increase of scale, they aren't scaling up all the other factors. Yes the collisions work much smoother and faster, but everything moves as if you're on the moon instead of realistically. |
The changed hints seem fine. Could you squash the commits into one? See PR workflow. |
011e2b7
to
61bedbf
Compare
@akien-mga I squashed it. I apologize for not being familiar with the workflow and I will be careful from now on. |
61bedbf
to
4a2aaab
Compare
No need to apologize, you did nothing wrong :) |
Thanks! And congrats for your first merged Godot contribution 🎉 |
Yes that's right, you should also scale the other parameters (velocity, gravity, forces) 10x. The difference is that with the world scaled up, you feel the margin thinner. Though, you have much more room to account for floating point precision error because you are still using a good margin (in the order of 0.01). |
@AndreaCatania Scaling the world up or down does absolutely nothing to solve floating point precision error. If you double the size of everything, then the numbers will be half as precise (so the effective precision is exactly the same as before). If the behavior changes at different scales, that's a bug, and isn't caused by floating point numbers, just flawed code somewhere. |
You right, I was wrong mentioning floating point precision error. Though, I was referring more to the physics engine imprecision. |
Changing the physics update rate is the only way for this to improve (at the expense of performance as we're increasing the workload). Like @aaronfranke says, scale everything by 10x you're right back where you started. A 1meter x 1 meter x 1 meter cube with a 1 cm margin (0.01 meter) will behave exactly the same as a 100cm x 100cm x 100cm cube with a 1cm (1) margin. |
As for the Margin minimum, it was lowered once in #23472, but it was degraded to 0.04, so I put it back.
The issue is that the minimum unit for Sphere3D was 0.01, even though the minimum unit for primitives like CSGSphere is 0.001. As mentioned in #23472, the minimum unit of 1 cm (2 cm as a diameter) is too large when applying real world scale, as in VR. In addition to that, I've also lowered the minimum unit of camera clipping.
https://www.youtube.com/watch?v=YFwDJ0jQiQg
The scale is so small that the falling speed appears to be faster. Spherical collisions are generally not a problem, but they can get a little out of control when moments are involved, such as cylinder collisions.