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.
As the javadoc for PhysicsObjectControl says, the ghost object collision detection uses AABB (Axis-aligned bounding box) collision only, regardless of the collision shape it has been assigned.
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.
So out of curiosity, if I reduce a volume by x% whatās the reduced surface area % ? Iāve never come across a need for that but my brain wants to know. Sounds exponential.
Reason being that change in surface area is the square of the change in āsizeā⦠and change in volume is the cube of the change in size.
ā¦which is why I asked what the original x% was. Usually people think āI want to make this half the sizeā⦠which is a function of size and not volume.
In graphics, anyway⦠itās super weird to change somethingās size based on its volume.
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.
I was thinking if I altered the scale. So a 10% reduction in size would result in a volume reduction % of x
Itās more of a brain excercise than anything else, but I guess if the OP decreased the size by 10% or whatever then that would result in 10% wiggle room they desire.