I am building a drag and drop space ship builder. You build ships with ship parts. I am using collision shapes and bullet to detect physics collisions so that I know if the parts are attached or not. My problem is that when they are colliding and part a (shown in green in the picture) is moved into part b, I need to know how deep part a is in part b because I want to restrict how much they can overlap.
Anyone know how I can get this information to restrict transform movement?
EDIT: The answer must be shape and rotation accurate. I am using a HullCollisionShape
Yes and yes … BUT what I really want to know … since the result has to be shape and rotation acurate is … based in the picture … for example, is the cockpit deepest spot in the hull more than 10 percent of the cockpit’s volume … but accurate volume. It might be trivial but my noob brain can’t get my head around the math.
I think I figured it out by just staring at my picture. Please shoot this theory to hell is it will not work.
Basically I do have the ORIGINAL collision point saved with the direction of object b from the physics engine so … for each axis, I send a ray down both directions of the axis and each ray will collide with the exterior of object A since the collision point will be inside object A. I then can divide the distance of the collision point from ray 1 and ray 2 with the distance of the ray pointing towards object b and presto magico I now know how deep each axis is inside object B … if I have the distance of each axis I can derive at least a basic cube volume.
It’s not super actuate but should be accurate enough so that I can configure the cockpit part to prevent the user from sticking the cockpit so far up the hull the you can’t even see the windows.
I got a much easier suggestion for you…
What about using 2 collision shapes?
The first one: bigger one - is used just to detect stuff and can overlap
The second one: smaller one - is used just to ensure things dont pass thru.
Ghost objects can use any collision shape, not just AABB. I’m very sure of this for native Bullet and reasonably sure for jBullet.
Bullet uses AABB for broadphase collision detection, to find candidate pairs of objects for collisions. However, there’s a 2nd phase in the collision-detection process, one that uses the actual collision shapes. The exact algorithm that’s dispatched depends on the shapes involved. All this is documented in Chapter 4 of the Bullet manual: bullet3/Bullet_User_Manual.pdf at master · bulletphysics/bullet3 · GitHub
When Bullet detects a collision, it calculates the depth of penetration. Unfortunately, this information doesn’t seem to be accessible through the current jme3-bullet API.
Yes, you can add 2 rigid-body controls to a single Spatial. To access them, you’d need to keep references (since Spatial.getControl() will only find one of them). And of course, if both RBCs were in dynamic mode, they’d interfere with each other, so I recommend that at least one of the controls be setKinematic(true).
In this case, however, I think a GhostControl for the outer envelope makes more sense than an RBC.