8
\$\begingroup\$

Let me explain Phase Lock first: When two objects of non zero mass occupy the same space but have zero energy (no velocity).

Do they bump forever with zero velocity resolution vectors or do they just stay locked together until an outside force interacts?

In my home brewed engine, I realized that if I loaded a character into a tree and moved them, they would signal a collision and hop back to their original spot. I suppose I could fix this by implementing impulses in the event of a collision instead of just jumping back to the last spot I was in (my implementation kind of sucks).

But while I make my engine more robust, I'm just curious on how most other physics engines handle this case. Do objects that start in the same spot with no movement speed just shoot out from each other in a random direction? Or do they sit there until something happens? Which option is generally the best approach?

\$\endgroup\$
2
  • 3
    \$\begingroup\$ I can't speak to an actual implementation (hence a comment instead of an answer), but in my experience physics engines will typically slowly push the two objects out of each other. For example, if two boxes spawned overlapping each other, they would slowly push away from each other until completely separate. Exactly how this would be implemented is up for consideration. \$\endgroup\$ Dec 17, 2012 at 6:04
  • \$\begingroup\$ Yeah, I realize this is somewhat of an odd question, since it's asking not so much on how to implement it, but more so how it's normally handled. Thanks for your input! \$\endgroup\$
    – C0M37
    Dec 17, 2012 at 6:31

2 Answers 2

4
\$\begingroup\$

I guess this kind of ends up being a non-answer...

I think sometimes it depends on the implementation and the basic approach used for collision detection and resolution (which is like 80% of a rigid body physics engine, I guess). It's funny because I just hit this problem the other day in my own home-grown physics engine and threw an object into NaN space.

I had an object spawn in exactly the same spot as another object and both were the same shape. In this particular case the contact generator made very bad values. I fixed it by picking arbitrary values for the contact (push smaller/lighter object straight up, basically). This was a pretty cut and dry, case, though.

If a chair were to spawn inside of a table then it would be dependent on what contacts were generated whether they flew apart or got stuck. In my case, I'm not using a constraints based system (at least not yet) so the object is just as likely to blow apart as to oscillate and fall asleep. In a penetration+impulse system like the one I use it's pretty easy to see all of the ugly and how it will result. I have no idea how a constraints based system solves this problem or if it even detects it... the constraint seems unreachable to me without some intervention and I have no idea if there is a standard way for those types of engines.

Others will surely have smarter things to say but this was too long for a comment.

\$\endgroup\$
2
  • \$\begingroup\$ I appreciate your answer. I felt like asking this question as sort of a life raft for others to find should they ever get caught in the same situation. \$\endgroup\$
    – C0M37
    Dec 18, 2012 at 7:32
  • \$\begingroup\$ Lol @PSpeed over here also ^^ \$\endgroup\$
    – SHiRKiT
    Dec 23, 2012 at 2:10
0
\$\begingroup\$

This is handled in two ways:

  1. Correct the overlap between collidable objects
  2. generate a "normal" force which will push objects apart, should they collide.

This only works, however, if you are differentiating velocity/time. It won't work in a tile based game, and will result in visible artefacts, such as one object either tunneling through an object, or being visibly pushed out of the other object.

In the case of tile based games, you can take a predictive approach, by checking where the object will be if it moves. If the movement would cause phase lock, then disallow the movement.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .