CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

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 a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

by Xaser » Mon Jan 21, 2019 10: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!

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

by Graf Zahl » Sat Jan 19, 2019 2: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.

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

by Apeirogon » Sat Jan 19, 2019 2: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.

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

by Graf Zahl » Sat Jan 19, 2019 2:19 am

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.

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

by Xaser » Sat Jan 19, 2019 12: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 34 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.

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

by Graf Zahl » Thu Mar 01, 2018 5: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.

Re: CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

by Graf Zahl » Fri Feb 09, 2018 11:18 am

Damnit, I thought this had been fixed when deprecating the old versions of these functions.

CMF_OFFSETPITCH inverts pitch in A_SpawnProjectile

by Marrub » Fri Feb 09, 2018 7: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.

Top