erincatto / box2d

Box2D is a 2D physics engine for games

Home Page:https://box2d.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enhancement: dynamic radius joints

DjSapsan opened this issue · comments

I'm developing a big scale cell simulation. The most needed and important feature of the project is multicellular organisms. Currently it's impossible to implement proper joints. Cells are constantly grow and shrink so currently I forced to create and destroy lots of unnecessary joints every update. And all of existing joints are causing jittering.
What is really needed is a joint that will bring two bodies together even with constantly changing body sizes. Name can be something like StickyJoint. If new joint won't be implemented then at lest let us set new anchor points for existing joints without destroying them.
Thanks a lot!

Animated_GIF-original.mp4

I'd like to address the jittering first. Please create a dump file.

I'm working with Love2D. There is no direct way to dump a world. So I captured a demo.
Here are two best implementations - with distance and with weld joints.
I have tried different parameters, but here are only the best combinations. I didn't show multiplying, growth and shrink of cells but it results in a total unbearable nightmare. So for now just straight connections.
Distance: length = 0, frequency = 100
https://user-images.githubusercontent.com/12209464/147980897-ac823176-5edc-41d3-96dc-0ed988b055ca.mp4

Weld: frequency = 50
https://user-images.githubusercontent.com/12209464/147980938-77a65d39-4afa-448e-9441-f59418786bfb.mp4

Weld is much better but it has many disadvantages too. First - constant ghost forces. Often cells are rotating forever without resolving to a new configuration. Second - if cells are joined during intersection then they will stay in that position. But only edge-to-edge connection is needed.

Desired result - https://www.youtube.com/watch?v=UVuRSrMqx70&ab_channel=TheCellLabTeam
Author of the videogame explained that he implemented his own engine for this, but I wanna stick to Box2D.