[Rseding91] [0.14] AoE works against entity center instead of collision

This subforum contains all the issues which we already resolved.
Post Reply
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

[Rseding91] [0.14] AoE works against entity center instead of collision

Post by Mooncat »

Bug:
Area-of-effect in the game works against the center point of each entity.
This leads to undesired result when a small AoE is used against an entity with large collision box.
The follow GIF shows the problem:
GIF

Steps to reproduce:
1) Download the following mod.
aoe-works-on-center-only_0.0.1.zip
(978 Bytes) Downloaded 70 times
It scales up the iron chest, and makes wooden chest, iron chest and grenade free to make.
(The collision box of iron chest is slightly updated after recording that GIF)
(Rocket silo may also do the trick)

2) Start a game. Place an iron chest. Maybe place some wooden chests for comparison.

3) Get yourself some grenades. Throw them near the iron chest and observe.


Expected:
Area-of-effect is applied according to collision detection. Grenade should be able to damage the iron chest whenever its area hits the collision box of the chest.

Loewchen
Global Moderator
Global Moderator
Posts: 8308
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

Re: [0.14] AoE works against entity center instead of collision

Post by Loewchen »

This looks more like an intended simplification than a bug to me.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [0.14] AoE works against entity center instead of collision

Post by Mooncat »

Loewchen wrote:This looks more like an intended simplification than a bug to me.
I know performance is considered. But I think it is not a common approach in games?
You can see the problem with grenade vs rocket silo. So it is not just about mod.
I'd let the devs to decide whether fix it or not. :)

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [0.14] AoE works against entity center instead of collision

Post by orzelek »

It would also count (on smaller scale most likely) when throwing grenades near biter spawners. So could be visible by just playing game.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13202
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.14] AoE works against entity center instead of collision

Post by Rseding91 »

This isn't a bug so much as "not working how might be desired". The AoE was programmed to specifically check distance from entity position (entity center) so it's working as programmed. The AoE trigger is what you describe: distance from center point of entity. Most entities have square bounding boxes so when an entity is large you can see the "distance from center" logic happening far easier.

Now, even though it's not a bug it would still be useful to have it capable of working against the collision boxes of entities instead of the entity position. I'll see what can be done.
If you want to get ahold of me I'm almost always on Discord.

Engimage
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Wed Jun 29, 2016 10:02 am
Contact:

Re: [0.14] AoE works against entity center instead of collision

Post by Engimage »

Rseding91 wrote:This isn't a bug so much as "not working how might be desired". The AoE was programmed to specifically check distance from entity position (entity center) so it's working as programmed. The AoE trigger is what you describe: distance from center point of entity. Most entities have square bounding boxes so when an entity is large you can see the "distance from center" logic happening far easier.

Now, even though it's not a bug it would still be useful to have it capable of working against the collision boxes of entities instead of the entity position. I'll see what can be done.
Actually that is pretty simple - you got to test all four corners of the entity as opposed to center one which will be almost ideal. 8 points is nearly perfect but thats a bit too much.
As an alternative you might calculate entity "radius" (despite being square) and measure distance between explosion center and entity center with the sum of radii of entity and explosion.

SyncViews
Filter Inserter
Filter Inserter
Posts: 295
Joined: Thu Apr 21, 2016 3:17 pm
Contact:

Re: [0.14] AoE works against entity center instead of collision

Post by SyncViews »

PacifyerGrey wrote:Actually that is pretty simple - you got to test all four corners of the entity as opposed to center one which will be almost ideal. 8 points is nearly perfect but thats a bit too much.
Actually, if you have an axis aligned rectangle (say centered at (rx,ry) of size (rw,rh)) and want the distance from a point (px,py) to the nearest edge (0 for "inside") you can just calculate it. There are similar ways for various shapes (including rotated rectangles, or getting the intersection coordinates, etc.), and most applies to both 2D and 3D.

Code: Select all

//abs(px - rx) will give distance on that axis to the centre. -rw/2 along with max converts that to the edge on that axis or 0 for inside.
dx = max(abs(px - rx) - rw/2, 0)
dy = max(abs(py - ry) - rh/2, 0)
//so now squared distance between
distanceSqr = dx*dx + dy*dy
//generally for most purposes, distance squared is desired anyway, square root is expensive (doing "distanceSqr <= radius*radius" is cheaper and could potentially be precomputed and cached)
distance = sqrt(distanceSqr)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13202
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Rseding91] [0.14] AoE works against entity center instead of collision

Post by Rseding91 »

I've changed this for 0.16 so the AoE check works against the bounding box instead of the center position.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Resolved Problems and Bugs”