Thyme icon indicating copy to clipboard operation
Thyme copied to clipboard

Fix polygon trigger radius

Open xezon opened this issue 3 years ago • 2 comments

OmniBlade on behalf of OpenSAGE developer:

I found one little thing you might be interested in - while parsing .sav files, specifically the state for PolygonTrigger, I think I found a bug in the original game. I found a value that looks like it's supposed to be the radius of the polygon trigger, but it's wrong. Maybe it's something you can fix in Thyme? The value stored in .sav files is what you get if you do this:

width = (bottomRight.X - topLeft.X) * 0.5
height = (bottomRight.Y + topLeft.Y) * 0.5
radius = sqrt(width * width + height * height)

... but that's wrong. The height should be bottomRight.Y - topLeft.Y, not bottomRight.Y + topLeft.Y. If this is indeed a bug in the original game, the radius would be way too large, and would presumably lead to many false-positives when doing the radius check, which would be bad for performance. Presumably there's then a more precise check that uses the actual polygon, so this bug wouldn't actually change anything... it would just make it slower than it needs to be.

I added a comment about this buggy radius here: https://github.com/OpenSAGE/OpenSAGE/blob/899b380545a7ca17aa9cae936974a3ce367ec018/src/OpenSage.Game/Data/Map/PolygonTrigger.cs#L185-L199

xezon avatar Jan 10 '22 17:01 xezon

I don't know how to test this fix. But should be possible to test this in some sort of test map. I will ask kABUSE.

xezon avatar Jan 10 '22 17:01 xezon

PolygonTrigger refers to water area. That is the thing with the blue line in World Builder. Tournament Desert (2) map has 2 of these polygon triggers for example (ID 7 and 9).

xezon avatar Jan 13 '22 20:01 xezon