LevelLocals.SphericalCoords: Compute spherical coordinates

Moderator: GZDoom Developers

Post Reply
argv
Posts: 184
Joined: Tue Aug 30, 2016 4:47 pm

LevelLocals.SphericalCoords: Compute spherical coordinates

Post by argv »

PR #553 adds LevelLocals.SphericalCoords, a method that computes spherical coordinates from one point in the world to another.

This can be trivially wrapped to create a PitchTo method, as was requested back in March:

Code: Select all

extend class Actor
{
	clearscope double PitchTo(Actor other) const
	{
		Vector3 sphericalCoords = LevelLocals.SphericalCoords(Pos, other.Pos);
		return sphericalCoords.Y;
	}
}
I could also add PitchTo and SphericalCoordsTo methods to the Actor class, but as discussed, I'm leaving non-static Actor methods alone for now, pending the completion of the client-server branch. LevelLocals.SphericalCoords operates on world coordinates and doesn't look at actors at all, so it should be safe.
User avatar
Major Cooke
Posts: 8170
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: LevelLocals.SphericalCoords: Compute spherical coordinat

Post by Major Cooke »

argv wrote:Useful for checking whether one actor is inside another actor's view cone.
Can you demonstrate how to do this? I'm super curious now.
argv
Posts: 184
Joined: Tue Aug 30, 2016 4:47 pm

Re: LevelLocals.SphericalCoords: Compute spherical coordinat

Post by argv »

I've added the wiki documentation I mentioned in the pull request. It contains two examples. The second one does exactly that: check which actors are inside a cone projected from the player's viewpoint.
argv
Posts: 184
Joined: Tue Aug 30, 2016 4:47 pm

Re: LevelLocals.SphericalCoords: Compute spherical coordinat

Post by argv »

Should SphericalCoords be tagged with version("3.6.0")? It seems appropriate, since SphericalCoords won't be available before 3.6.0, but I notice a lot of new features these days aren't versioned.
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: LevelLocals.SphericalCoords: Compute spherical coordinat

Post by Graf Zahl »

That's not really necessary. It'd just error out anyway. Versioning is important where actual syntax changes would break old scripts otherwise or when a function needs to be deprecated.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”