Damping must be must be treated like a force (like in real world) #9315
Replies: 5 comments 8 replies
-
As you can see from the description:
This is a limitation, you can simulate other physics with rigid bodies using custom integration |
Beta Was this translation helpful? Give feedback.
-
I understand, I suppose that the tolerance threshold where one considers a simulation good enough is subjective and very personal.
I didn't know about it, I'll look at it, thanks for the information.
Well, actually I didn't make a comparison with a superior engine, in fact I mentioned that Unity has the same "problem". I saw the opportunity here to do something better than in that other engine, and I thought that mentioning it would make the proposal more attractive. I didn't realize that it could be interpreted as very negative.
My fault, perhaps I underestimated the level of knowledge (in Physics) of the developers. I apologize if it was perceived that way.
Ok, I get it, maybe I don't get the idea of how demanding it is. I thought that, at each time step, the motor calculated the new speed (or velocity) in a similar way to the first equation I wrote. On the other hand, I suspected that the effect of gravity was calculated with some expression of the form Vf=Vi+g dt (well, in a vector version I suppose). That's why I thought it was immediate to integrate both expressions into a single one (like the one in the second to last equation), without this representing a greater requirement for resources. But of course, I imagine that many details escape me.
I agree, I understand that we are dealing with a solution where there is a trade-off between realism and functionality. I think the key is what departure from expected realistic behavior we can tolerate without perceiving dissonance. It is a very personal threshold. In my case, it feels strange to see a very massive body falling alongside a light body, because it is not what I expect to see (at least not under normal conditions with an atmosphere).
Me too, I don't expect to see a "Super Mario" where the movements look realistic. But there is a whole range of games where we want to maintain the illusion of realism.
Well... I don't know what to say there. I don't know if I'm understanding you. If there are people who have an expectation of what should happen in reality, that is not consistent with what happens in reality, it is a psychological issue that transcends the use of a game engine. If you are referring to people who do not want their game to look realistic, I suppose it would be enough to not make use of those functionalities provided by the engine.
As I said, I thought I was just integrating more or less the same amount of calculations. But if you as a collaborator/developer tell me that is not the case, then I guess I was oversimplifying the task.
I really do not know. I myself am trying to understand the scope and limitations of this tool to know what I can do with it.
I don't understand, are you saying that I should provide portions of code to implement in the engine? At the moment I don't think I can go that deep. And if you mean implementing "better" physics in my Godot projects... Well, maybe I could, but it would be less work if it were already built in natively.
Thank you for taking your time to respond to me. |
Beta Was this translation helpful? Give feedback.
-
I think I understand what you're saying. You're talking to me about generic damping. However, in the GODOT documentation that I cite, it mentions a calculation that it makes with the speed (or velocity) at each time step. This calculation is compatible with a very simplified model of friction damping with a fluid medium (Stooke's law). Using this already simplified model it is possible, in my opinion, to obtain a more realistic result. The truth is that without looking at the GODOT source code I don't understand why this calculation is not working as a friction force (because in that case the most massive block should reach the ground first).
I didn't expect something so sophisticated either.
I understand you, you are talking about an energy dissipation mechanism. In that case it is true that friction with a fluid is not the only way to dissipate energy... But, as I said before, in GODOT it seems that the energy is being dissipated by something very similar to Stooke's law Thank you for taking your time to respond to me. |
Beta Was this translation helpful? Give feedback.
-
ok...
I've known people with that attitude, but I didn't think it was the dominant position. I guess there's something else to add to the "I'm alone in this" list.
Okay. Thanks for the clarification. |
Beta Was this translation helpful? Give feedback.
-
@AThousandShips @yosoyfreeman Okay people, after considering what you told me, I realized that my proposal has a problem. Energy dissipation occurs by many mechanisms. Friction with air is not the only way damping occurs. If we considered damping as an effect of friction with the air, in a game taking place on the Moon, since the bodies take the same time to fall, we would be tempted to take damp=0. But that would be a mistake, because damping occurs anyway due to friction between the different bodies that interact in the scene. With my proposal we had a solution to "a problem" (unexpected behavior on Earth, bodies that take the same time to fall), but it would have introduced another new problem (unexpected behavior on the Moon, bodies that do not slow down at all). I understand better now that, regardless of the resemblance to Stokes' Law, the way damping is implemented cannot be assimilated with air friction. Sorry for the inconvenience, please reject my proposal. |
Beta Was this translation helpful? Give feedback.
-
I have done a test. I created two identical cubes, giving them the same linear damp value (10) and a very large mass difference 1 to 10 or even 1 to 100, and then the bodies fall together all the time. That's not what happens in the real world, and I think I know why it's happening in GODOT. Apparently damping is treated in isolation from the rest of the forces present.
Let me explain myself...
I've been trying to understand what the "Damp" (or Linear Damp) property represents in the RigidBody3D class.
Reference: https://docs.godotengine.org/en/latest/classes/class_projectsettings.html#property-descriptions
(...) During each physics tick, Godot will multiply the linear velocity of RigidBodies by 1.0 - combined_damp / physics_ticks_per_second. By default, bodies combine damp factors: combined_damp is the sum of the damp value of the body and this value or the area's value the body is in. See RigidBody3D.DampMode.(...)
Based on this description I understand that the equation is
Vf=Vi (1-D dt)
where
Vi: Original speed value
Vf: New speed value
D: Damp (or combined damp)
dt: time between ticks
assuming that
Vi>0 and D dt<1
I'm right?... RIGHT???
So, we can re-write it like:
dV/dt=-D Vi
where
dV=Vf-Vi
If we took dt in the limit to zero we have
A=-D V
where
A is the acceleration...
...and we can multiply it by the mass "M" to obtain de force
F=-C V "Stokes law"
where
C=D M (C shouldn't depend on the mass, some cancellation must happen with D)
Reference: https://en.wikipedia.org/wiki/Drag_(physics)
This equation represents the "Stokes law", a particular case of the drag force expression when the Reynolds number is small. That is, a force proportional to the speed. The truth is that this is an approximation for a small Reynolds number. In other cases, a force proportional to the square of the speed is considered more appropriate. But for a video game perhaps it is a good enough model. Well, I don't know, it depends on how realistic we want the video game to be. At the moment I am not interested in discussing at that level of detail.
Ok, a correct physical equation is being taken into account. However, the damp force is not the only force acting on a body. In GODOT we also have the force of gravity. So the acceleration of a body is:
A=Fnet/M
where
Fnet= "Damp force"+"Gravitational Force"
Of course I am simplifying, since it is correct to work with vector magnitudes. In a simplified way we have that the speed of a falling body is calculated in each time step as
Vf=Vi+g dt-Vi D dt
where
g=9.81m/s^2 is de gravity's acceleration
If the fall lasts long enough, the speed increases until the damp force equals the force of gravity. That is
g =V D or V=g M/C
This is terminal speed, and it is greater the greater the mass. This implies that a body with greater mass reaches the ground faster. Of course, when D (or C) is very small, that terminal speed is so big that everything happens as if there were no damping. It is for this reason that in a vacuum bodies released from the same height reach the ground at the same time.
But that's not what happens at GODOT. I have done the test. I created two identical cubes, giving them the same linear damp value (10) and a very large mass difference 1 to 10 or even 1 to 100, and then the bodies fall together all the time.
It seems like the GODOT physics engine doesn't handle damping correctly. It does not treat it as a force together with other forces in order to compute velocity (vector magnitude) or speed (scalar magnitude).
I have been able to see the same erroneous treatment is present in other engines (such as UNITY with the "drag" property). That's not how the world works. I understand that a videogame doesn't have to be realistic, but if one is going to rely on a physics engine, what's the point if it can't reproduce realistic behavior?
My suggestion is that damping must be treated as another force and not as an exotic effect that mysteriously attenuates speed. If the intention was always to treat damping as a force, then it is very poorly done, almost to the level of considering this implementation very BUGGY.
Beta Was this translation helpful? Give feedback.
All reactions