How do you make bodies react kinetically to new bodies being created or scaled? #177
Replies: 1 comment
-
I don't fully understand what you see when you add the cube so it's hard to say anything sensible (perhaps a video is more instructive?). What I can say is that scaling doesn't work the way you think it does. Scaling a shape doesn't create a force. Jolt is a rigid body simulator (stressing rigid). When you scale an object, it is not a rigid body, Jolt only knows that the shape has changed (not how). What Jolt sees is that a sphere suddenly started to overlap with two other spheres and an algorithm kicks in that tries to correct these overlaps (aka constraint errors). What happens is that the spheres get pushed apart by calculating:
Only the position change is kept, the velocity change is forgotten. This means that a body cannot gain velocity by being pushed away by a scaling body. For a normal rigid body simulation this prevents the case where a discrete time step made 2 bodies intersect a bit, followed by the energy in the system increasing because the bodies get pushed apart and gain velocity. |
Beta Was this translation helpful? Give feedback.
-
When I first create these shapes it is three spheres bunched together:
![image](https://private-user-images.githubusercontent.com/1397052/336678111-0ac81e71-5460-4279-8e68-02729aff80b5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NzE0NDIsIm5iZiI6MTcyNDU3MTE0MiwicGF0aCI6Ii8xMzk3MDUyLzMzNjY3ODExMS0wYWM4MWU3MS01NDYwLTQyNzktOGU2OC0wMjcyOWFmZjgwYjUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjVUMDczMjIyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NmViMDkzMWJkYzk1ZmY0ZjU1OWNhOTNhMTdjNTZjN2JjMmIzMzk5NjBmMWEzOGY0NTJiOTg3OWQwNzljMTI0YiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.32iPZBgAovu1Z6Vf9T-JfF4bxHEVa_9H40NDGJlfoKc)
Then I upscale one of the shapes, and it gently pushes the other shapes to the new position to clear any collision.
Then I add a cube right in the center.
![image](https://private-user-images.githubusercontent.com/1397052/336677812-357fb8c3-55bb-42c9-949d-b09965850d5b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NzE0NDIsIm5iZiI6MTcyNDU3MTE0MiwicGF0aCI6Ii8xMzk3MDUyLzMzNjY3NzgxMi0zNTdmYjhjMy01NWJiLTQyYzktOTQ5ZC1iMDk5NjU4NTBkNWIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjVUMDczMjIyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MWMxZmRlODVkZTliMmRlMTBmNWY0YWY3MTBlODhkZjJhYWZiMDlhMWM1ZmE0YTBhMWY5Nzg0NTQ4MDI3ODM3MCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.7z52L_CdW_ZUTuaWmM-k7ZUGyTuFSO8wQ4yJEXGyuZY)
I figured the scaling might be ignored, but even spawning a new object just clears the collision.
What I expected: when the cube drops in the other bodies have a force applied and move out of the way
as the shape scaled, a force is created and applied outward.
Now I know I could spawn the object elsewhere and use
moveKinematic
to throw it into place which would work, but the vector of the forces would come from it's initial position.It's less of a thing with the new shape as it's pretty common but with the inflation of a shale (scale change) I would expect the other bodies to have a force applied. I'm not sure how to model/apply that...
Beta Was this translation helpful? Give feedback.
All reactions