-
Notifications
You must be signed in to change notification settings - Fork 5
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
Demo scene seems a bit broken #13
Comments
One thing that has to be mentioned is that the CollisionShape of the cans is a When changing this to a
The only one that worked was the |
That was a bit fast. Change from Bullet to Godot Physics and you can clearly see that SphereShape and CapsuleShape are working there perfectly. Still the CylinderShape does not. So it boils down to this:
EDIT:
|
The collision margin is an extra distance at which things collide, so it won't work well if this margin is larger than the size of your shapes. The default value of 0.04 is meant to be used for objects of scale around 1. There are two things you can do to fix the problem:
|
Hey @pouleyKetchoupp thanks for your suggestions. Just some remarks on that:
We already discussed this with @BastiaanOlij at BastiaanOlij/gdleapmotion-asset#1. You are totally right that this would much improve the physics performance but it is not the way VR systems - and therefore also the leap motion - work. Using units as meters is the standard here. Apart from the possible offsets in perception Bastiaan mentioned in the discussion you also have the problem that external tools like Blender or the common CAD packages used to create objects for real world scenarios work with units as meters. You would have to scale every asset then.
I did not think about the hand margins - thank you. But in the comment above you can see that just the demo scene (without hands) has issues that are not affected by the hands margins - it did help to lower the margin but not that much. The problem might be that the minimum margin you mentioned isn't small enough when working with units as meters. I'll try to look into the shapes and margins again but I'm quite sure the problems can only be solved by allowing smaller margins and using the (currently not working) CCD. |
I understand you need real world scale for your objects, but scale is relative. You can apply a global scale on the root of your whole scene that affects the camera and all objects inside, without changing all of your assets. The user wouldn't be able to tell the difference. Problems would occur only if some scripts you use have hardcoded values based on real world scale, but even then that shouldn't be a huge problem to fix. Of course I might be missing something specific to VR though :) Making the physics engine work with smaller scale using CCD is overkill for this use case imo. |
The confusing thing is that 1 unit = 1 meter and thus 0.04 is 4 centimeters is no longer just a standard in VR but often applied to normal games as well. I don't know yet whether this is a hard limit in the bullet physics engine that is not designed to work at this scale or if the precision configured in Godot is just ill chosen. But this is definitely a problem that needs to be fixed upstream. Godot should allow values with higher precision when set from code so one thing to try is to add a script to our cans and in its _ready function set the margin to 0.001 and see if that improves things |
Yes, 1 unit = 1 meter is the standard in most games and physics engines as well. The problem here is caused by the fact this scene works with objects around 1 cm, and Bullet is not configured to work well at this scale. Using smaller margins for all objects is worth trying (including the hand if it uses rigid bodies, otherwise it won't help), but I don't know if it will solve the problem completely. That's why I was proposing another simple solution, which doesn't require extra changes in the engine. Just put the whole scene in a Spatial node with a uniform scale of 20. It's easy to do and could work. I'm sure the physics engine supports uniform scale, and it works better with large scale than small scale. So in a use case where you mix 1 cm objects with 1 m objects, it's safer to scale everything up in physics than working with real world scale. |
Oh, I forgot that for the test with scaling the scene, you would need to scale gravity as well by the same amount. So that adds a little bit more to do :) |
While this works fine for a desktop game, scaling stuff up in VR provides all sorts of problems. While the ARVRServer is able to deal with most of those by applying a world scale I think its the wrong solution. It's all relative, I need to find out why bullet can't work with small units while it can when you scale it all up by 20x. That doesn't make mathematical sense, the exact same should be achievable with making all margins 20x smaller. The reality in VR is that you will often work with centimeters. Objects you pick up are that size |
Well in mechanical lectures you are confronted with scaling effects that occur when you scale a structure and try to use the same structural principles. A construction could fail because if length is scaled linear, area and volume do not - and so some terms in equations grow unproportionally. But this phenomenom is more likely to see in materials engineering and I'm not sure if rigid body dymanics are affected in any way - especially when using uniform scaling for the world and all including objects. I'm not sure but isn't it possible that quadratic and exponential terms in equations could lead to accuracy issues if small floats are used as parameters? Like a cylinder collision shape with radius of 0.001 would be followed by a inertia tensor (which is calculated by bullet) with the quadratic radius of 0.000001 - and so maybe other parameters with higher exponents lead to floating point problems? Anyway. I'm investigating the Bullet documentation and forum about units, scale and scaling effects. I found a 5 year old Bullet_User_Manual for version 2.83 in the bullet3 repository. It could be outdated but I'm sure it still could be quite informative. Some excerpts:
Also btCollisionShape::setMargin uses a btScalar as parameter which is documented here and seems to be able to switch between single and double point precision:
In a forum thread it is stated that:
This is also explained here . In the manual I also found the following General Tips:
From the before mentioned forum thread you will get the following tips:
Just a sidenote about CCD:
Other topics about world scale:
This is quite interesting. If those tips are still valid then we should investigate those points:
|
@pwab good info man! thanks for digging that all up :) I think the problem is that when you're building a normal desktop game, having things sized in meters is normal for large games. You rarely deal with small objects other then maybe bullets. The collision shapes are around characters, vehicles, etc. We're usually dealing with an area that is an entire building, or a town, definitely a large amount of space, so we can be efficient if everything is handled at a larger scale. VR breaks that mold, we're dealing with things close to the user, objects you hold, direct interactions with your hands, etc. So we're working at a completely different scale but seeing floating point math doesn't change noticeably whether your units are meters or centimeters and tracking is already done in meters.... It would also suggest that larger worlds in VR will start to clash because you're dealing with two scales at the same time, needing precise collisions for things close to you while loosing efficiency because you're trying to do physics in a large area. Anyway, it does sound that the default configuration for bullet does not rhyme well with what we're trying to do and we're going to have to start experimenting with that :) |
Bullet can use doubles, but not in Godot (yet). It might be supported in 4.0. However, from a quick glance at this, I doubt the issue is with single-precision float limitations. You need to have a world several kilometers in size to notice such issues.
For many reasons, it's best to keep objects at as close to a real-world scale as possible. If there are issues with physics objects at very large or very small scales, that's a bug. |
Hey @aaronfranke thanks for joining the discussion.
Yes I also think that this might not be the case here. We were able to make the demo scene work again with the following adjustments:
The last point seems to be a bug in the Godot Inspector where the user can't set values lower than 0.001 for the margin. This is critical in VR environments because we work with objects in a scale that is in this range and therefore the margin must be way smaller. |
This is an intentional feature, which can be changed here: |
Ah yes, that limit comes from elsewhere, from this line of code:
That limit came from... @BastiaanOlij, here lowered from its previous value of 0.04 (?!?) It does seem surprising that you need a value smaller than 0.001, though. That's 1 millimeter. I think this solution you've found is masking the real problem of Godot's physics just being buggy. |
Well this comes from two points:
Could be true. I don't want to assume that Godots physics is free of bugs 😅
And exactly here seems to be the comment that talks about that topic: Why did @erwincoumans stated the lowest margin size should be 0.001? Was this statement just made for CollisionShapes in the scale of around 1m³? Would it be a problem to set it to a lower value for smaller objects in the scale of around 1cm³ and less (despite of performance)? |
I tried your provided demo scene and was confused about the cylinder behavior. Here is a short gif:
The reason could be the broken CylinderCollisionShape in Godot 3.2.
The text was updated successfully, but these errors were encountered: