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

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9104
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #15 on: January 24, 2016, 11:17:43 pm »
The only things you cannot fix are those you do not want to fix.

You should also only fix things that need fixing.

Offline Coincident

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #16 on: January 24, 2016, 11:22:08 pm »
You should also only fix things that need fixing.
Also true.

Is that just a general observation, or are you implying that it applies to this case?
If so, could you please explain why?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9104
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #17 on: January 24, 2016, 11:23:16 pm »
Just a general observation.

Offline 7Saturn

  • Colonel
  • ****
  • Posts: 457
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #18 on: January 24, 2016, 11:34:19 pm »
Nice of you, to point that out.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #19 on: January 25, 2016, 12:59:40 am »
The only things you cannot fix are those you do not want to fix.
How do you want map 2d world to 3d world? One way I see is simply drop all current graphic and use only voxel display. Then you will have perfect match between display and physic. Then you would see that your shoot never hit target only pass him very close by. Of course you have line of fire to target, but most of it is hidden behind wall (from eye perspective its invisible, only gun "see" him).

Offline yrizoud

  • Commander
  • *****
  • Posts: 1014
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #20 on: January 25, 2016, 01:49:57 am »
I don't know if it's clear, but this misunderstanding is because the system that shows the result of a shot makes a visual approximation : If you hit a unit, the shot appears to go straight to its center. You've all certainly seen a shot pass through solid things in the way (windows, low obstacles, nearby units...)... This is because this part is for visual feedback only. If the voxel-based calculation says that the shot went from A to B, there was a way.

If somebody can determine a more precise rendering of a voxel/unit hit, I'd be curious to test it, (seriously, I'd be interested). But I'm pretty sure it will introduce new problems that the original UFO and openxcom don't have :
- You will see no difference between shots that hit the foot of an alien (hit) and the ground near it (miss)
- Hits in the back of the screen (usually shots going from top to bottom of screen) will not visible, as they will be drawn behind the character sprites or walls.

Offline Coincident

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #21 on: January 25, 2016, 01:58:11 am »
How do you want map 2d world to 3d world?
I did not mean that would need / want to map a 2D world into a 3D world.
I meant that no problem is "impossible" to fix, there are always multiple ways to solve things - some more complicated than others... it's just a matter of "looking outside the box", and finding a different - easier way to fix things. (Unless of course if you can't bother to look.) And sometimes it's just not worth to fix things at all, because some fixes can cause more trouble than improvement, as Meridian was trying to point out...

Anyway, don't get me wrong. All I want is to help make OpenXCom a better game for everyone.
Obviously I don't decide if something should or not be "fixed". For now, all that I want is identify a problem, and understand what's going on. After that, if there's something that can be fixed/changed to improve the game, all the better. If not, I would only like to understand why.

The problem that I've identified is:
 - Occasionally, bullets appear to go inside the aliens but do not hit, which can be frustrating for the player and cause detriment to the overall game-play experience.



Yankes: I have to confess I've had some trouble understanding what you wrote previously, so I went back and read things a few more times. Please correct me if I'm wrong, but to sum things up:

In the 3D voxel world, all units are represented as a fixed-radius cylinder. This cylinder is used for collision detection, correct?
I presume this was made so, for simplification purposes, it would be too much work to support customized voxel hit-boxes for each alien, correct?

This means that all aliens are cylinders, regardless of how they look like to the player.
So I could go and make a custom Super-Fat-Snakeman sprite that is 2 times larger than normal - the cylinder would remain the same size, correct?
« Last Edit: January 25, 2016, 03:57:00 pm by Coincident »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #22 on: January 25, 2016, 07:46:46 pm »
Yankes: I have to confess I've had some trouble understanding what you wrote previously, so I went back and read things a few more times. Please correct me if I'm wrong, but to sum things up:

In the 3D voxel world, all units are represented as a fixed-radius cylinder. This cylinder is used for collision detection, correct?
I presume this was made so, for simplification purposes, it would be too much work to support customized voxel hit-boxes for each alien, correct?

This means that all aliens are cylinders, regardless of how they look like to the player.
So I could go and make a custom Super-Fat-Snakeman sprite that is 2 times larger than normal - the cylinder would remain the same size, correct?

Yes, No, Yes, Yes. If you want change "fat" of unit you should look for `loftempsSet:`in armor. PirazteZ using it to made untargetable unit.

Offline Arthanor

  • Commander
  • *****
  • Posts: 2488
  • XCom Armoury Quartermaster
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #23 on: January 25, 2016, 07:51:21 pm »
ninja'd by Yankes in a rather succinct way, so here goes any ways:

All hits and visibility calculations are made in 3D space using loftemps, which define what 3D volume is associated with a unit. These have nothing to do with the graphics displayed to the player, but you can see them using the 1st person screenshot like Yankes displayed.

What you see in game is a bunch of stacked 2D images, which approximates what happens in 3D. In this case, in the 3D world the shot missed the cylinder so kept going. In the 2D world, the 2D rendition of the shot went through the 2D rendition of the snakeman and kept going, because the 3D world said that the shot had to keep going. This happens because the 2D snakeman is wider than its 3D cylinder, so the shot looks like it's going through it instead of going next to it.

This can be solved by:
1 - Fixing the snakemen sprite to be skinnier so it matches its cylinder better
2 - Making the snakemen cylinder larger so it matches its sprite better
3 - Designing an all new 3D volume for snakemen that matches the sprite even better
4 - Understanding that the 2D representation is just a graphical approximation to the 3D game engine and rolling with it

Obviously, option 4 needs much less work and in the spirit of sticking to vanilla, will likely be the one for openxcom. Nothing prevents you from making a mod to implement options 1-2-3 though.

Offline Coincident

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #24 on: January 25, 2016, 09:28:52 pm »
I see. I understand the situation now.

`loftempsSet:`in armor
https://www.ufopaedia.org/index.php?title=LOFTEMPS#Template_Tables
This is very interesting, exactly what I was looking for.
I checked the standard armors.rul and noticed that every unit uses template 3 (small cylinder), except Sectoids that use 2 (even smaller), and Silacoids that use 5 (large cylinder, although they have low height).

So this can be modded! Using template 4 (medium cylinder) or 5 for Mutons and Snakemen will make them large enough to make this situation not happen so often, and be less frustrating for the player with these near-misses.
(To be balanced, X-Com Soldiers should be 4 too, since I've seen this bug happen to the aliens shooting at my soldiers. And probably Chrysalids and Zombies, I will try changing a few and test some more)

It's a pity that it won't be changed directly in OpenXcom, but if the argument is sticking faithfully to vanilla, so be it...



Thank you Arthanor and Yankes for the info.  :)

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #25 on: January 25, 2016, 10:06:27 pm »
I see. I understand the situation now.
https://www.ufopaedia.org/index.php?title=LOFTEMPS#Template_Tables
This is very interesting, exactly what I was looking for.
I checked the standard armors.rul and noticed that every unit uses template 3 (small cylinder), except Sectoids that use 2 (even smaller), and Silacoids that use 5 (large cylinder, although they have low height).

So this can be modded! Using template 4 (medium cylinder) or 5 for Mutons and Snakemen will make them large enough to make this situation not happen so often, and be less frustrating for the player with these near-misses.
(To be balanced, X-Com Soldiers should be 4 too, since I've seen this bug happen to the aliens shooting at my soldiers. And probably Chrysalids and Zombies, I will try changing a few and test some more)

It's a pity that it won't be changed directly in OpenXcom, but if the argument is sticking faithfully to vanilla, so be it...



Thank you Arthanor and Yankes for the info.  :)
This is simply "Call for Modders" :) If you think that something is not right with ruleset you are encourage to change it (and publish on openxcom.org).
I personally think this behavior is not problem but maybe other people think like you?

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11731
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Possible bug in projectile collision detection
« Reply #26 on: January 25, 2016, 10:11:43 pm »
Yeah, it happens, but in my opinion not frequently enough to make it a problem. It can be tweaked, but I've never felt the need to.

A much more serious problem is that the game very often allows you to shoot when hitting is impossible, due to the difference between position of eyes and weapon. But this cannot be fixed with rulesets.

Offline Coincident

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #27 on: January 25, 2016, 10:27:07 pm »
A much more serious problem is that the game very often allows you to shoot when hitting is impossible, due to the difference between position of eyes and weapon. But this cannot be fixed with rulesets.
Yes, I've also come across that, indeed, serious problem. It is related to, but different from the problem being discussed here.

I've also reported that different bug before, with a savegame:
https://openxcom.org/bugs/openxcom/issues/1122
But even for that bug, I'm sure that a easy feasible solution will present itself, eventually.

Offline Cristao

  • Colonel
  • ****
  • Posts: 407
    • View Profile
Re: Possible bug in projectile collision detection
« Reply #28 on: January 27, 2016, 03:16:56 pm »
^Happens a lot. Tempted to use the arcing mechanics I see in Dioxine's mod but that is asking for more trouble.