[Added] LevelLocals.SphericalCoords: Compute spherical coordinates

Moderator: GZDoom Developers

LevelLocals.SphericalCoords: Compute spherical coordinates

Postby argv » Mon Aug 20, 2018 7:39 pm

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 allExpand view
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.
argv
 
Joined: 30 Aug 2016

Re: LevelLocals.SphericalCoords: Compute spherical coordinat

Postby Major Cooke » Tue Aug 21, 2018 8:03 am

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.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: LevelLocals.SphericalCoords: Compute spherical coordinat

Postby argv » Tue Aug 21, 2018 4:37 pm

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
 
Joined: 30 Aug 2016

Re: LevelLocals.SphericalCoords: Compute spherical coordinat

Postby argv » Wed Aug 22, 2018 1:32 am

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.
argv
 
Joined: 30 Aug 2016

Re: LevelLocals.SphericalCoords: Compute spherical coordinat

Postby Graf Zahl » Wed Aug 22, 2018 2:21 am

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


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: Semrush [Bot], Yandex [Bot] and 1 guest