2

I've got a problem about physics modeling in a really particular case. I'm not exactly sure if i have to ask it into physics or gamedev,but i suppose the problem is best suited here, since it is about modeling. I'm not really good with physics, so I'll try to improve this post's formulation regarding answers.

First, let's go for some context

(that's not mandatory, you can skip if needed). I'm currently implementing a -supposedly- lightweight game engine using a predictive approach : instead of simulating on a succession of interval and therefore looking at "what happened" after each interval (frame) to update the state of the simulation, I look in the future for when the next state changing event (for example a collision) happens, and I only recompute simulation when the event occurs. For physics, it means that my collision detection takes acceleration and speed in account.

if only physics simulation is taken in account, this gives something like this :

"traditional approach" : move bodies by the interval time -> detect collision by interpenetration -> update simulation -> move bodies by the interval time

"predictive approach" : compute when the next collision occurs -> wait for the game's clock to reach next collision time -> update bodies involved in the collision -> compute when the next collision occurs -> etc

Now, the problem

I therefore need to compute acceleration and speed of bodies in order to perform collision. Please note that in my simulation, I do not want rotation involved, so every movement is translation. Computing acceleration for an isolated rigid body is trivial (it's the sum of forces on the rigid body divided by the mass), as Newton's law states. Body can have any shape, but it's ok to restrain shapes to convex shapes.

collision with several bodies involved

One problem comes when a collision involves several bodies, as described in this post (not mine), to compute resulting speed change of every bodies involved in the collision. Since this already has a quite good solution, I think there is no need for solving it again.

Several bodies "sharing" forces

My problem is to compute resulting acceleration when several bodies "shares" their resulting forces :

forces acting on a group of bodies

We can see that A and B are "pushing" in the same direction. By "pushing", I mean that the net force affecting isolated A and isolated B (if there were no contact at all). Let's call them Ra and Rb. Intuitively, if we consider A, B, C and D to have equal mass Mi, and Ra and Rb to be equal as well, with no other forces involved, the resulting acceleration Acc per body is

$ Acc = (Ra + Rb) / (Ma + Mb + Mc + Md) $

But when cases becomes complicated, I struggle to see how to solve the problem :

case 1 : one object is distanced by others

push break

Here A and B are pushing together, yet, push of A is much much less than push of B, so instantly after this instant, A will be distanced by the group, therefore, A push shall not influence neither B or C. Here my problem is detecting efficiently when a force has no relation with another.

Case 2 "resisting" forces

Second problem I encounter is when objects are subject to forces which adapt to counter other forces up to a certain threshold, as for example friction (represented by circles on C and D).

enter image description here

Case 3 : forces depending on other forces

Third problem (and the worst of all), which can eventually be removed for game simulation purpose, is when forces are depending over each other. :

enter image description here

Here we suppose D has an infinite mass, it can't move. There is no friction between B and D. A is pressing B on D, while "dragging" B along the border of D, through friction represented by a circle. The more A presses B on D, the more the friction will be strong between B and A, and therefore the more A will efficiently drag B along.

Kind of solution I'm looking for

I feel like this problem is meant to be solved as an equation system or alike, since it involves finding a "balance point" between every forces computing against each other. I'm currently trying to model relations between bodies like a graph to parse to exchange forces according to the "action-reaction" principle (a body applying a force to another body will get the opposite force applied to in return).
It seems it will lead to a tremendous algorithmic complexity, which is unwanted in the case of real-time game.

I would appreciate an already existing solution (well, that's logic) if one of you have it, but hints and modeling thought are more than welcome, they will be precious for me. Also, if you spot wrong formulations in the post, please let me know so I can change it.

Thanks you for reading !

EDIT I found a solution based on linear programming, I will take some time to check its robustness and then I'll add it as a solution

  • Usually, contacts are handled by impacts (exchanges of momentum) along with the contact normal after the integration step. Each contact pair produces a single equation to be solved for the impulse quantity. Multiple contacts yield a system of equations for resting contacts. – John Alexiou Jul 23 '19 at 13:02
  • 1
    @ja72 yes I already did, thank you ! I had seen your answer to this post that I mentioned in my question. It helped me quite a lot to understand constraint modeling, but I had a bit of struggle with it since I don't work with impacts. However it seems, as I edited, that I got a solution inspired from it using linear programming. I'm going to test it when I got the time and if it work i'll post it as an answer. Thanks you a lot ! – Felix Bertoni Jul 23 '19 at 13:28
  • If you do find something that works, please post it as a community wiki for the future generations :-), or as an answer below at least. – John Alexiou Jul 23 '19 at 13:31
  • @ja72 sure :) Wait, there is a community wiki ? 0.o. As I thought, my solution idea seems to work but :1] my first math model wasn't robust enough (I'm currently improving it), and 2] I still need to formulate it into a way acceptable for a computer, but I think I'll post it as answer before having computer-ready model. – Felix Bertoni Jul 24 '19 at 14:07
  • You can post an answer below and mark it as community wiki, but only a moderator can mark a question as such. – John Alexiou Jul 24 '19 at 14:43

0 Answers0