# Knowing when an object is "squished"

This topic is 3009 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm currently running into an issue in which I have an object of infinite mass pushing an object with no mass, through other objects.

For example, imagine object A has infinite mass, object B has no mass, and there is a wall that also has infinite mass. If object A continues to push object B into the wall, it can eventually go through the wall.

I believe this is somewhat normal with most physics engines. The problem is I have been given a design that says that no interpenetration is acceptable. So, the compromise is that, any object that is being "squished" between two other objects, will die/delete/etc.

My main issue is how to determine that an object is in fact being squished. For example, lets say object B has object A and the wall touching it on each side, but neither are really pushing on it, then it would not be being squished. I need to know with some certainty that the object is trying to be forced to move in such a way that it will be interpenetrating other objects.

If it helps, I'm working with Havok as my physics engine at the moment. I may end up posing this same question on Intel's Havok forum, but amount of feedback on that forum sucks so I thought I'd try here first.

##### Share on other sites
my short answer, though probably not the most accurate:

So basically, you want to know if two walls are squeezing an object in the middle. I would just find the sum of the distance between the object and the two walls. If it's less than 0, it's being squished. In code terms..

[script
float distance(wall w, object o){
//if w is facing o, return a positive number. else, return a negative number.
}
if(distance(wall1,object)+distance(wall2,object)<0)squished=true;
[/script]

Both walls (at the beginning) will be facing in the direction of the object.

The other method, which is almost the same as the first, though a bit easier to understand:

[script]
[/script]

These methods only work with spheres, though with a bit of tweaking can be fit to other shapes.

Another approach:

if any part of the object is outside of the two walls, then it is squished.

##### Share on other sites
To make it accurate though, the positions of the objects would not be very useful. I would need to know if any vertex of the physics mesh was interpenetrating my object. These objects can be of literally any shape, so checking position on a sphere might be accurate enough, but checking position on an large L-shaped wall would be highly inaccurate, as the center of that object might not even be within it's physics bounds.

EDIT: Reading fail, I missed the part where you mentioned this works for spheres. Because of the fact this needs to work with any shape, I'm not sure that any approximation will work. Havok will let me know when I have contact points between objects, I just need to be able to figure out if this contact is the type that would squish the object.

Possibly if I took the velocity of that contact point and determined it was pushing toward my object. But I'd have to also know that I have a contact point on the other side pushing in an opposite direction. Ugh....complicated.

##### Share on other sites
I'm not familiar with Havok. But you say it will tell you if you have contact between two objects. In ODE, that contact information would include penetration depth. Does Havok's contact info have a similar parameter? Looks like you want to kill the object if penetration depth > 0.

##### Share on other sites
Quote:
 Original post by BuckeyeI'm not familiar with Havok. But you say it will tell you if you have contact between two objects. In ODE, that contact information would include penetration depth. Does Havok's contact info have a similar parameter? Looks like you want to kill the object if penetration depth > 0.

It does include penetration depth. I might be able to store that data over a few frames to determine if the penetration is not resolving itself, and consider that to be a good enough criteria for "squishing" an object. However, I wonder if one object is pushing another around, if each frame it will have a penetration depth?

For example, object A pushes object B around, but there is no wall on the other side of object B, so there is no "squishing" going on, just pushing. In that case there might be some penetration depth, but not enough to consider it to be squishing.

I could potentially only look for penetration depths that exceed a certain threshold. That alone might be enough.

Anyway, thanks, that gives me an idea on a starting off point for this.

##### Share on other sites
Again, I'm sure about Havok, but does the contact data have references or pointers to the two objects in contact? Also, each object should be able to be assigned a type, or a combination of types.

If the above is true for Havok, you can check the contacts for "squishables." If a "squishable" is in contact with an object that's not a "valid-pusher" and the penetration depth is > epsilon, kill the "squishable."

In pseudo-code:
set_kill = NULLfor each contact C   if ( (C.obj1.type & SQUISHABLE) && (C.obj2.type & SQUISHER) ) ||      ( (C.obj1.type & SQUISHER) && (C.obj2.type & SQUISHABLE) ) &&      C.depth > 0.1      then if( C.obj1.type & SQUISHABLE ) set_kill = C.obj1      else set_kill = C.obj2if ( set_kill != NULL ) then kill set_skill

##### Share on other sites
Quote:
 Original post by BuckeyeAgain, I'm sure about Havok, but does the contact data have references or pointers to the two objects in contact? Also, each object should be able to be assigned a type, or a combination of types.If the above is true for Havok, you can check the contacts for "squishables." If a "squishable" is in contact with an object that's not a "valid-pusher" and the penetration depth is > epsilon, kill the "squishable."In pseudo-code:set_kill = NULLfor each contact C if ( (C.obj1.type & SQUISHABLE) && (C.obj2.type & SQUISHER) ) || ( (C.obj1.type & SQUISHER) && (C.obj2.type & SQUISHABLE) ) && C.depth > 0.1 then if( C.obj1.type & SQUISHABLE ) set_kill = C.obj1 else set_kill = C.obj2if ( set_kill != NULL ) then kill set_skill

The contact points themselves do not have the data, however, havok lets you create a listener that will fire whenever a contact point is created, and within that listener it includes the two bodies that are colliding. So I should be able to try something like this.

##### Share on other sites
I haven't used Havok either, but...I wonder...

To each contact point, there has got to be an associated Lagrange multiplier, somewhere inside Havok. Will it give you either the multiplier, or the contact force? It would seem that killing objects when this becomes very large would be the most natural way of dealing with your problem.

##### Share on other sites
Quote:
 Original post by EmergentI haven't used Havok either, but...I wonder...To each contact point, there has got to be an associated Lagrange multiplier, somewhere inside Havok. Will it give you either the multiplier, or the contact force? It would seem that killing objects when this becomes very large would be the most natural way of dealing with your problem.

I should be able to get the depth of the contact, and the separating velocity. I'm not sure I can simply use a single contact point to determine "squishing" though. A high speed collision (like one pool ball hitting another), may give a deep and fast moving contact point, but it wouldn't constitute "squishing". I need to know if the body is being contacted, but also that it cannot move away from the contact.

##### Share on other sites
Quote:
 I'm not sure I can simply use a single contact point...

My concern as well. Idea: If Havok allows it, you search for two contact points (or multiple such pairs) sharing the object, i.e. your squishable. Compare somehow the contact normals (the ones pointing to the squishy) or rather their current forces/velocities to determine an actual squish. For instance check if they span an angle greater than 150 degrees (close to "opposite") and, if you got forces/velocities, both have a minimum magnitude. Don't know Havok either, but you probably need to look for resting contact resolution information, that's AFAIK the way forces are propagated if multiple bodies are in contact (e.g. stacking).

unbird

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 9
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632948
• Total Posts
3009391
• ### Who's Online (See full list)

There are no registered users currently online

×