Barbosik / MultiOgar

An open source Ogar server implementation, written with Node.js.
Other
61 stars 44 forks source link

I have two questions. #271

Closed BaumanDev closed 8 years ago

BaumanDev commented 8 years ago

@Barbosik

  1. What is the cause of linesplit failure?
  2. When do I need to use updateNodeQuad(node)?
makandz commented 8 years ago
  1. Rigid bodies of cells or something, don't remember about it much :smile:
BaumanDev commented 8 years ago

Well that I know. :/ But what could be the problem in it? Seems like a good function.

Barbosik commented 8 years ago

1) root of cause for linesplit issue is rigid body physics. The cells should not penetrate each other when moving. Currently cell movement implemented in ogar style - with direct cell coordinate update, it doesn't allow to resolve rigid body collisions in such way. So, the cells may penetrate each other and it affects linesplit behavior.

2) when cell bounds changed. When cell coordinate changed or when cell size changed.

BaumanDev commented 8 years ago

@Barbosik Thanks you for your answers.

  1. I am still a little confused on it. Could you explain it more, please?
  2. Thank you!
Barbosik commented 8 years ago

@NatsuTheGreat:

1) in order to process rigid body collisions, there is need to calculate movement vector instead of modification of cell coordinates directly. Without it, you cannot handle rigid body collisions in the way which prevents cell overlapping on cell move. If cells can overlap each other, they will affect movement direction of each other, because extrusion force should be applied to both overlapped cells. It add small movements in random direction and your cells line will just spreading into cells heap

BaumanDev commented 8 years ago

So the problem is extrusion force?

BaumanDev commented 8 years ago

http://prntscr.com/c2wqg6

BaumanDev commented 8 years ago

I had to be very delicate.

Barbosik commented 8 years ago

the problem is that cells can overlap each other on cell movement (they should not). When it happens, we need to resolve it, and it's done with extrusion force, but it add random fluctuations in movement direction. The cells should overlap each other on split or eject only, but not on movement.

BaumanDev commented 8 years ago

I made a small fix, but.. For some reason, sometimes the cells don't split Math,PI/2 and linesplit doesn't work.

Barbosik commented 8 years ago

if the cells overlap each other before movement - it's ok and will works fine with extrusion force. But if they didn't overlapped before movement and overlapped after movement - it's the issue and it will leads to problem with linesplit. To fix it, there is need to add check which will prevent movement to coordinate which is occupied with another cell. But you cannot implement it when the cell coordinate is changed directly. You need to calculate movement vector with no change cell coordinate. And then check if movement in that vector is safe (doesn't overlap other cell). If it's not safe, you need to resolve movement vector, but not coordinate. When all movement vectors for all cells will be resolved, then you can apply it to cell coordinate. But cell coordinates should not be modified before this.

BaumanDev commented 8 years ago

Why does it add random angles though?

Barbosik commented 8 years ago

because when cell B is pop-out from cell A, it can overlap cell C. And if it will happens, both cells (B and C) will get extrusion force. But at the same time the cell B has extrusion force from cell A (from which it pop-out). So cell B will ping-pong from cell A to cell C and it will add extrusion force to both - cell A and cell C. This force has some small calculation error due to limited float type resolution. It's small, but it will be applied a lot of times, because of ping-pong in a loop. And in sum it will leads to random shift. And cells A, B and C will fly away from each other in random direction.

BaumanDev commented 8 years ago

I understand. I have multiple fixes, but they all cause problems. Linesplit works though.

BaumanDev commented 8 years ago

Look what I was even able to do. http://prntscr.com/c2x1j1

BaumanDev commented 8 years ago

Hey, Barbosik, is extrusion force the reason why the doublesplit is like the agar.io doublesplits?

Barbosik commented 8 years ago

extrusion force is just a part of rigid body physics

BaumanDev commented 8 years ago

Thank you for your help Barbosik, I appreciate it.