[Fixed] CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Postby Marrub » Fri Feb 09, 2018 8:42 am

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.
User avatar
Marrub
Xevv Va Rkvyr
 
 
 
Joined: 26 Feb 2013
Discord: Marrub#5455
Twitch ID: marrubdaskuleion
Github ID: marrub--

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Postby Graf Zahl » Fri Feb 09, 2018 12:18 pm

Damnit, I thought this had been fixed when deprecating the old versions of these functions.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Postby Graf Zahl » Thu Mar 01, 2018 6:14 am

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.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Postby Xaser » Sat Jan 19, 2019 1:36 am

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:

BackwardsImp.wad
(1.09 KiB) Downloaded 10 times


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.
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Postby Graf Zahl » Sat Jan 19, 2019 3:19 am

Interesting. The last time someone encountered this bug the following happened:

Code: Select allExpand view
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()
   ));


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.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Postby Apeirogon » Sat Jan 19, 2019 3:51 am

Graf Zahl wrote:The TVector::Pitch() function got the pitch's sign inverted

Does this because (g)zdoom use strange decision to make "up" pitch (looking at the ceiling) negative and "down" pitch positive?
Because, since it use right handed coordinate system, pitch signs must be inverted, positive up - negative down.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Postby Graf Zahl » Sat Jan 19, 2019 3:58 am

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.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Postby Xaser » Mon Jan 21, 2019 11:14 pm

Bit late I suppose, since 3.7.2 is out, but this is indeed all working in Square-land. Thanks for the fix!
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 1 guest