Author Topic: Possible bug in projectile collision detection  (Read 12420 times)

Offline Coincident

  • Captain
  • ***
  • Posts: 54
    • View Profile
Possible bug in projectile collision detection
« on: November 11, 2015, 08:03:09 pm »
I think I might have found a bug.
I've read about the bug-tracker, but I'm new around here and I'm not sure if this behaviour is intended (???) or has been reported before (couldn't find anything after searching).
Can someone confirm that this is indeed a bug so I can create an issue on the bug-tracker?


I got save-game where you can reproduce the bug twice in a row (check attachment).

How to reproduce the bug:

 1) Go to options and reduce the bullet speed to the minimum
 2) Still in the options: make sure you save-scumming turned off to use the same random seed as the save-game
 3) Load the save-game
 4) The selected soldier has a rifle.
 5) There is a Snakeman at the top-left side of the screen.
 6) Choose snap-shot, target the Snakeman, and fire.
 7) Repeat step 6: take a second snap-shot.

Both shots will very clearly go through the belly of the snakeman, and hit the ground behind him, making no damage.
It only happens sometimes, and in different maps / weapons / aliens, I'm not sure what are the exact circumstances that cause this.
I think it might have to do with shooting next to that side of the wall. It also happens when shooting next to sides of UFO hulls, and also happens to the aliens when shooting at my soldiers, next to a side wall.
Anyway, it is simultaneously frustrating and strange...  ???



PS - I'm using the latest nightly build. No mods are needed to load the game and reproduce the bug.
PS2 - This happens both with or without the UFO Extended Accuracy.
« Last Edit: November 12, 2015, 01:08:08 pm by Coincident »

Offline Coincident

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #1 on: November 14, 2015, 02:21:10 pm »
I've opened a bug issue with this, so it doesn't get forgotten.

https://openxcom.org/bugs/openxcom/issues/1116

Offline DeltaEpsilon

  • Captain
  • ***
  • Posts: 86
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #2 on: January 02, 2016, 02:00:17 am »
You are correct.
A bullet really goes right through snakemen:


What's even more interesting is that it's definitely possible to hit that snakemen using autoshot but bullets seem to hit his back.
« Last Edit: January 02, 2016, 02:07:56 am by EditorRUS »

Offline Countdown

  • Colonel
  • ****
  • Posts: 246
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #3 on: January 24, 2016, 05:58:43 am »
This has happened to me a few times as well in different places. Next time I'll save it. I just thought it was a "graphics" issue where it looked like it was hitting the alien, but not really hitting him. When it happened to me, it did very much look like it was going straight through the belly like in the photo above, except it was a Muton for me.

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #4 on: January 24, 2016, 01:32:25 pm »
You are correct.
A bullet really goes right through snakemen:


What's even more interesting is that it's definitely possible to hit that snakemen using autoshot but bullets seem to hit his back.
where is shadow? This is 2d pic, it could fly at top of closer tile to screen. If it directly fly to snakeman then shadow of bullet should be cast under it.

Offline Coincident

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #5 on: January 24, 2016, 01:50:21 pm »
The shadow is under the Snakeman.

I went back to the save-game and made 2 more screenshots of the 2 snapshots that have this collision problem:





In both shots you can see the shadow from the "head" of the bullet appearing behing the Snakeman.
« Last Edit: January 24, 2016, 05:59:27 pm by Coincident »

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #6 on: January 24, 2016, 02:35:18 pm »
Using voxel dump I can say that you miss by 1 voxel (depending where I put start and end line result will be different).

Offline 7Saturn

  • Colonel
  • ****
  • Posts: 457
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #7 on: January 24, 2016, 02:41:36 pm »
Wait, wait, wait! Where did I see something, before? No, no, we don't have a problem with the targeting algorithm, Warboy probably won't see any need to change anything on that. (End of sarcasm.)

Offline Coincident

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #8 on: January 24, 2016, 06:14:12 pm »
If it depends on where you choose to put the start and end line, how can you say for sure that I miss by 1 voxel?
Even if that were true for the first shot, which enters the snakeman closer to its right side:


...the second shot is several voxels closer to the center of the snakemen:


I don't know if this has been discussed before, or if there's a problem in the targeting algorithm.

The way I see it, there's either a problem:
1 - Detecting projectile collisions (my initial guess)
2 - Drawing the trajectory of projectiles (those shots did miss but were drawn as a hit)
3 - With the aliens' voxel hit-boxes (is there such a thing?)
4 - Drawing aliens (snakeman too fat? or any alien for that matter; this bug happens with all aliens and humans too)

I believe that 4 makes no sense because the snakemen graphics are identical to vanilla XCom:EU, where I've never seen this bug happen...
So it's either 1, 2, or 3.
« Last Edit: January 24, 2016, 06:25:06 pm by Coincident »

Offline 7Saturn

  • Colonel
  • ****
  • Posts: 457
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #9 on: January 24, 2016, 06:31:18 pm »
Problem three would be my guess. It's enough, to miss by one voxel. And this specific behavior makes it possible, that in certain situations, where the always present tiny deviation from a perfect shot (even with accuracy 250) sees to it, that you will almost always miss. And this happens in exactly that type of very narrow targeting field, where hits are possible, at all. This shooting almost through a corner, be it a horizontal or vertical one. And this has been reported numerous times, but always was ignored or talked into »I don't care any more. Let's leave it at that.«
« Last Edit: January 24, 2016, 06:39:45 pm by 7Saturn »

Offline R1dO

  • Colonel
  • ****
  • Posts: 436
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #10 on: January 24, 2016, 06:36:02 pm »
Your pictures show that you're using quite an advanced scaler. So i wouldn't rule out number 4 just yet.
(if you want, try recreating those shots with scaler ``disabled`` or ``*raw``)

Offline Coincident

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #11 on: January 24, 2016, 06:47:54 pm »
I was using the sabr-xcomified scaler for higher-quality graphics.
The scalers should only make the edges smoother (like anti-aliasing), not change the apparent size of units.

Anyway, to leave no doubts open, I took the screenshots again without any scaler:

Snapshot 1:


Snapshot 2:

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #12 on: January 24, 2016, 10:56:14 pm »
From perspective of bullet alien is small cylinder that occupy around 1/4 of tile. Snakeman graphic and order of drawing is interrelate in that case.
Look on screen I post. black line is one possible bullet trajectory. It touch real body of snakeman (purple circle). But if you put graphic position then you will see that bullet trajectory hit it (brown line).

This is case where graphic is not aligned with game physic engine. You can't fix it because one use 2d and second 3d.

Offline 7Saturn

  • Colonel
  • ****
  • Posts: 457
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #13 on: January 24, 2016, 10:57:46 pm »
The problem with this is (once again): You are pretty much unable to hit the target, at all. Why does the engine allow to aim there, without forcing it to?

Offline Coincident

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #14 on: January 24, 2016, 11:13:19 pm »
EditorRUS has already said this before actually. 2nd post on this thread.
What's even more interesting is that it's definitely possible to hit that snakemen using autoshot but bullets seem to hit his back.

I'm sorry, but you guys are mistaken.
There IS a line of fire, and it IS possible to actually hit the Snakeman from that position.

Try it yourselves: load the game, and take 6 snapshots. The 6th snapshot will hit.

You need the following ruleset to test it:
SpoilerInfinite-Shots-Rifle:
items:
  - type: STR_RIFLE
    tuSnap: 1


You can't fix it
The only things you cannot fix are those you do not want to fix.
« Last Edit: January 24, 2016, 11:17:54 pm by Coincident »