Page 1 of 1

I need to properly join cells with joints

Posted: Fri Mar 20, 2020 10:05 pm
by DjSapsan
I creating a very sophisticated simulation of evolution with the DNA code. I have the cells that eats, moves and divides. New cell might be connected to parent. But this feature requires a very complicated handling of physical joints.
There are few cases that can happen:
1)
The attachment cells1.png is no longer available
2)
cells2.png
cells2.png (56.62 KiB) Viewed 2441 times
3)
cells3.png
cells3.png (178.1 KiB) Viewed 2441 times
Currently i'm trying to solve problem with growing in size (picture 3). But others problem needs to be solved as well.
For now i asking to help just with last picture. Here is what i getting actually:
cells3.png
cells3.png (178.1 KiB) Viewed 2438 times
When cell are eating and getting bigger joints are becoming wrong placed. How can i reconnect joint in optimal way, considering i will have thousands of cells?
Animation link

sorry, but forum is broken i can't properly create a post

Re: I need to properly join cells with joints

Posted: Fri Mar 20, 2020 10:10 pm
by DjSapsan
Sorry, but this forum is broken, i cant put pictures properly, they are appears randomly and attachment box is broken...

Re: I need to properly join cells with joints

Posted: Fri Mar 20, 2020 11:41 pm
by DjSapsan
Picture 1 is here

Re: I need to properly join cells with joints

Posted: Sat Mar 21, 2020 4:47 am
by bobbyjones
I'm guessing the problem is less how to do such a thing and more so how to do so efficiently? Why not create the naive approach if you haven't already and check if it's actually a bottle neck. Right now off the top of my head I can't think of any optimizations. I think it mainly depends on what you are using for your physics engine. The actual joint changing stuff is a couple variables and a tiny bit of math. There very few things you can do to optimize that. The bigger problem is the propagation of that change throughout your physics engine. Even then create the naive solution first and see what happens.

Re: I need to properly join cells with joints

Posted: Sat Mar 21, 2020 7:52 pm
by DjSapsan
bobbyjones wrote:
Sat Mar 21, 2020 4:47 am
I'm guessing the problem is less how to do such a thing and more so how to do so efficiently? Why not create the naive approach if you haven't already and check if it's actually a bottle neck. Right now off the top of my head I can't think of any optimizations. I think it mainly depends on what you are using for your physics engine. The actual joint changing stuff is a couple variables and a tiny bit of math. There very few things you can do to optimize that. The bigger problem is the propagation of that change throughout your physics engine. Even then create the naive solution first and see what happens.
I still have no working solution for reconnection of joints. I suppose that i need to follow next algorithm:
1) Create a child cell.
2) Check if it is colliding with "brothers"
3) If it is colliding sufficient then:
4) If it is "stick" then stick to parent and brother
5) if it is sticking only to parents then reconnect and cut off brother
6) if it is "free" then leave and also cut off brother

Problem is that it hardly can be done in the same tick, because of callbacks will be called later. Also it is hard to check how sufficient collide is. Maybe there is a little colliding area and i dont need to bother about breaking existing joints.

Beside described problem there is another problem, maybe not so hard but still. I dont know how to reconnect joint if cells are growing/shrinking. Or can i connect it to edge of the circle in such way that after growing in size joint will be still connected to the edge?