CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Bugs that have been investigated and resolved somehow.

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.
Post Reply
User avatar
Marrub
 
 
Posts: 1192
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

Post by Marrub »

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Post by Graf Zahl »

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

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Post by Graf Zahl »

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
Xaser
 
 
Posts: 10772
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Post by Xaser »

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 29 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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Post by Graf Zahl »

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

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()
	));
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
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Post by Apeirogon »

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Post by Graf Zahl »

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
Xaser
 
 
Posts: 10772
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Post by Xaser »

Bit late I suppose, since 3.7.2 is out, but this is indeed all working in Square-land. Thanks for the fix!
Post Reply

Return to “Closed Bugs [GZDoom]”