DrChat / Gmod-vphysics

Replacement vphysics module for the Source engine (originally meant for Garry's Mod)
Other
92 stars 15 forks source link

Able To Physgun Objects Through Anything Immobile #25

Open kklouzal opened 10 years ago

kklouzal commented 10 years ago

You are able to take any object that can be picked up with the physgun and move it through another object that is currently frozen as well as the world geometry itself, the object is constantly being 'pushed' out of the other object instead of blocking the held object from entering the other, this leads to the inability to effectively build in a variety of ways.

DrChat commented 10 years ago

Caused because bullet has no CCD solving.

kklouzal commented 10 years ago

Okay I understand now, I have done C++ programming in the past using a small amount of Bullet in conjunction with the Irrlicht 3D engine as well as MikeNet networking api to make some small games, collision detection was always a big headache, if I may suggest a possible method to tackle this, unless of course you already have an idea as to how you'll go about it, if the object is moving you might be apt to do a ray cast in the direction the object is moving and get the collision point from that to accomplish the CCD test? It is most likely much more complicated that I am aware of.

DrChat commented 10 years ago

Bullet has some faux CCD in btDiscreteDynamicsWorld.cpp, but I have it disabled because it's really slow on large maps.

DrChat commented 10 years ago

So, turns out I was completely wrong! Awesome!

This has absolutely nothing do with ccd (except for if the object goes through the ground fast enough, no contact points will be generated). The constraint solver will "push" interpenetrating objects out of eachother, but it does not alter the velocity of the objects. And apparently there's a load of left over delta impulse after every iteration, even more since the shadow controller is forcing the object into an invalid state. So then the next step in the tick is to integrate the transforms, which means moving the objects to their new positions based on their velocity and the timestep.

It may be better to just detect contact points in the shadow controller and slide along them rather than forcing the object through them.

DrChat commented 10 years ago

Update: This appears to be caused by the physgun giving the object a huge mass. The impulse on a object by a contact point is scaled by the object's inverse mass, so the delta velocity is really small.

The impulse is scaled up by the inverse diagonal jacobian between A and B in setupContactConstraint, but that doesn't scale up the impulse nearly enough. Need to look into this.

Okay, the inverse diag jacobian is too small cause of the angular component being factored in. If the angular component is 0, there is absolutely no passthrough, but the objects won't be rotated by the contact points.

DrChat commented 10 years ago

(Sort of) fixed in 67d8dc4ba5506f7bb5c7c9397b426d1abeb9b1cc. It's not impossible but it's harder to do.