CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile
Moderator: GZDoom Developers
Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
- Marrub
-
- Posts: 1193
- Joined: Tue Feb 26, 2013 2:48 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Arch Linux
- Graphics Processor: ATI/AMD with Vulkan/Metal Support
- Contact:
CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile
Subject says it all. Projectiles are fired downward when the player is above the monster and upward when the player is above them. Any parameter for pitch will cause this, just having the flag is enough to break it.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile
Damnit, I thought this had been fixed when deprecating the old versions of these functions.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile
To ensure that I actually test your problem case, a small demo would be appreciated. I already tried to address this last year but apparently it didn't catch all eventualities.
Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile
Welp, this affects one of the enemies in Square, and we're working on updating it for 3.7.x, so time to bump I guess.
Here's a quick test wad:
The imp is supposed to chuck a fireball at you with very slight vertical pitch randomness; instead, the fireball goes up and clonk's the ceiling.
Any chance of taking a look at this before 3.7.2? I dunno if it's possible to handle it on Square's side without it re-breaking in the future.
Here's a quick test wad:
The imp is supposed to chuck a fireball at you with very slight vertical pitch randomness; instead, the fireball goes up and clonk's the ceiling.
Any chance of taking a look at this before 3.7.2? I dunno if it's possible to handle it on Square's side without it re-breaking in the future.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile
Interesting. The last time someone encountered this bug the following happened:
See that '-' in front of vecTo.Pitch()? That's only there to compensate for the bug. The TVector::Pitch() function got the pitch's sign inverted. Fortunately there's only 3 places in the entire engine using it, and one already compensates for the inversion.
The third place is the function to check actor visibility in the renderer and apparently isn't used in sufficient quantity to have registered. CMF_OFFSETPITCH is the only really critical one.
Let's just hope that no mod depends on it, otherwise a compatibility option will be needed.
Code: Select all
DEFINE_ACTION_FUNCTION(FLevelLocals, SphericalCoords)
{
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
PARAM_FLOAT(viewpointX);
PARAM_FLOAT(viewpointY);
PARAM_FLOAT(viewpointZ);
PARAM_FLOAT(targetX);
PARAM_FLOAT(targetY);
PARAM_FLOAT(targetZ);
PARAM_ANGLE(viewYaw);
PARAM_ANGLE(viewPitch);
PARAM_BOOL(absolute);
DVector3 viewpoint(viewpointX, viewpointY, viewpointZ);
DVector3 target(targetX, targetY, targetZ);
auto vecTo = absolute ? target - viewpoint : VecDiff(self, viewpoint, target);
ACTION_RETURN_VEC3(DVector3(
deltaangle(vecTo.Angle(), viewYaw).Degrees,
deltaangle(-vecTo.Pitch(), viewPitch).Degrees,
vecTo.Length()
));
The third place is the function to check actor visibility in the renderer and apparently isn't used in sufficient quantity to have registered. CMF_OFFSETPITCH is the only really critical one.
Let's just hope that no mod depends on it, otherwise a compatibility option will be needed.
Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile
Does this because (g)zdoom use strange decision to make "up" pitch (looking at the ceiling) negative and "down" pitch positive?Graf Zahl wrote:The TVector::Pitch() function got the pitch's sign inverted
Because, since it use right handed coordinate system, pitch signs must be inverted, positive up - negative down.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile
Yes, to match the internal usage it needs to invert the sign here. Why was it inverse? No idea, it predates my involvement in this code. Early ZDoom had a few of these odd gotchas attached to it, unfortunately, but since this got exposed to scripting very early on there is no chance to fix the design flaw now.
Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile
Bit late I suppose, since 3.7.2 is out, but this is indeed all working in Square-land. Thanks for the fix!