[posila][16.4][MOD]Fish creating not check terrain colliding
Posted: Sun Dec 17, 2017 10:05 am
by maroder
When a new fish is created, it is checked collision_box, but not checked terrain_collision_box. Because of this, new fish often gets stuck on the shore.
some data
{
type = "fish",
name = "fish",
collision_box = {{0,0}, {0,0}},
terrain_collision_box = {{-0.75, -0.75}, {0.75, 0.75}},
},
{
type = "fish",
name = "tiny-fish",
collision_box = {{-0.12, -0.06}, {0.12, 0.06}},
terrain_collision_box = {{-0.75, -0.75}, {0.75, 0.75}},
},
{
type = "fish",
name = "small-fish",
collision_box = {{-0.24, -0.12}, {0.24, 0.12}},
terrain_collision_box = {{-0.75, -0.75}, {0.75, 0.75}},
},
Re: [16.4][MOD]Fish creating not check terrain colliding
Posted: Sun Dec 17, 2017 10:14 am
by posila
How exactly are mod-fish created? This doesn't happen when map generator autoplaces them.
Re: [16.4][MOD]Fish creating not check terrain colliding
Posted: Sun Dec 17, 2017 11:14 am
by maroder
posila wrote:How exactly are mod-fish created? This doesn't happen when map generator autoplaces them.
1)by script, 2)manual(by player in game). Anywhere it check collision_box only.
In the picture above:
1) Stuck fish.fish in the lower left corner. Was ctrated by script (dozens in one place).
script
pos = game.surfaces[1].find_non_colliding_position("fish", j.position, 4, 0.2)
game.surfaces[1].create_entity{name = "fish", position = pos, force = game.forces.natural}
Re: [16.4][MOD]Fish creating not check terrain colliding
Posted: Wed Dec 20, 2017 11:50 pm
by posila
I still haven't decided how to resolve this,
I am inclined to removing terrain_collision_box from fish prototype and revert it to use just collision_box. I added terrain_collision_box as an optimization, beacuse I didn't want fish with big collision boxes to register on multiple tiles unnecesserily, making their update more expensive ... but if I am to pollute all collision checks with extra case for fish, I want to be sure the optimization was not pre-mature.
Re: [16.4][MOD]Fish creating not check terrain colliding
Posted: Thu Dec 21, 2017 1:12 am
by maroder
If the decision is made not to remove terrain_collision_box, then it will be optimal to first check whether the entity has terrain_collision_box.
Perhaps it would be better to add some collision to the coast.
I hope there is a reasonable solution that will not be perceived in the game itself as "what the hell is going on ?!"
Re: [16.4][MOD]Fish creating not check terrain colliding
Posted: Thu Dec 21, 2017 10:34 am
by posila
Ok, I am going to remove terrain_collision_box. But after the Christmas, we had some issues with entities expanding their collision boxes before, so I am not going risk breaking everyone's saves before holidays just to fix this.
For the time being, configure your fish with collision_box equal to terrain_collision_box.
Re: [posila][16.4][MOD]Fish creating not check terrain colliding
Re: [16.4][MOD]Fish creating not check terrain colliding
Posted: Thu Dec 21, 2017 12:20 pm
by maroder
posila wrote:Ok, I am going to remove terrain_collision_box. But after the Christmas, we had some issues with entities expanding their collision boxes before, so I am not going risk breaking everyone's saves before holidays just to fix this.
For the time being, configure your fish with collision_box equal to terrain_collision_box.
Ok, I got it. Thank you.
I'll just removed all terrain_collision_box.
Re: [posila][16.4][MOD]Fish creating not check terrain colliding
Posted: Wed Jan 10, 2018 6:35 pm
by posila
So, terrain_collision_box won't be used anymore in 0.16.17. Normal collision_box will be changed to size of terrain_collision_box and by default the fish won't collide with entities (it's default collision mask will have 'colliding-with-tiles-only' flag)
It took so long because fish with non-zero collision boxes were blocking offshore pump placement, and I had hard time to decide what's the best way to solve it.
Re: [posila][16.4][MOD]Fish creating not check terrain colliding
Posted: Wed Jan 10, 2018 10:33 pm
by maroder
posila wrote:Normal collision_box will be changed to size of terrain_collision_box and by default the fish won't collide with entities (it's default collision mask will have 'colliding-with-tiles-only' flag)
I hope that with such а large collision_box there will not be a problem of the appearance of a new fish over the existing one. If the "construction" of a new fish takes into account only the collision of tiles, then everything is fine.