GetZAt Decorate Function

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: GetZAt Decorate Function

Re: GetZAt Decorate Function

by Major Cooke » Thu May 12, 2016 2:18 pm

Ah okay. Still, thanks a ton! :mrgreen:

Re: GetZAt Decorate Function

by Graf Zahl » Thu May 12, 2016 2:14 pm

Better, yes. But since P_PointInSector will always return something valid the 'if (sec)' isn't really needed. Good enough, though.

Re: GetZAt Decorate Function

by Major Cooke » Thu May 12, 2016 1:48 pm

Graf Zahl wrote:Why do you use secnum instead of the pointer that was returned by P_PointInSector?
Was using the same code as GetSectorFloorZ in ACS. Changed it. Is that better?

Re: GetZAt Decorate Function

by Graf Zahl » Thu May 12, 2016 1:15 pm

Why do you use secnum instead of the pointer that was returned by P_PointInSector?

Re: GetZAt Decorate Function

by Edward-san » Thu May 12, 2016 1:14 pm

Imho the name of the enum should be GZAFlags, not GZFlags, with the enum elements having GZAF_ as prefix (the action function is called GetZAt, not GetZat, then the question would be `what's a Zat?`). Also that sounds too familiar with GZDoom :P

Re: GetZAt Decorate Function

by Major Cooke » Thu May 12, 2016 12:28 pm

Done. I added a couple more flags to disable 3D floor, portal, and midtexture checking in case someone needs it (I can tell this will be handy).
  • 3DRESTRICT: Ignore midtextures and 3D floors whose floorz is above the actor's z.
  • NOPORTALS: Don't check through portals, only the original sector designated.
  • NO3DFLOORS: Ignore all 3D floors.

Re: GetZAt Decorate Function

by Graf Zahl » Thu May 12, 2016 10:45 am

Precisely that. It really only matters if an actor intersects with a 3D floor.

Re: GetZAt Decorate Function

by Major Cooke » Thu May 12, 2016 7:55 am

What should I be using for bottomz and topz? Looks like the actor's Z and their Top... Not sure.

Re: GetZAt Decorate Function

by Graf Zahl » Wed May 11, 2016 1:36 pm

I don't think that your submission is really usable, it's missing both 3D floor and portal handling. And that's also the reason why no GetHighestCeiling function exists.
The functions that should be used are:

double HighestCeilingAt(const DVector2 &a, sector_t **resultsec = NULL);
double LowestFloorAt(const DVector2 &a, sector_t **resultsec = NULL);
double NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
double NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);

which are all portal-aware, and the 'Next...' variants also 3D floor aware.

Re: GetZAt Decorate Function

by Major Cooke » Wed May 11, 2016 12:47 pm

Slightly offtopic, but Graf, is there an equivalent way to get the highest floor or lowest ceiling by chance? I know one exists for a vertex but I'm looking for an opposite of GetLowestFloor function in the source.

GetZAt Decorate Function

by Major Cooke » Thu May 05, 2016 5:48 pm

Pull Request

float GetZAt(x, y, angle, flags, pick_pointer);
Gets the floor z at x distance ahead and y distance to the side in relative form from the calling actor pointer. Flags are as follows (GZF_ prefix):
  • CEILING: Returns the ceiling z instead of floor.
  • ABSOLUTEPOS: x and y are absolute positions.
  • ABSOLUTEANG: angle parameter does not add the pointer's angle to the angle parameter.
  • 3DRESTRICT: Ignore midtextures and 3D floors whose floorz is above the actor's z.
  • NOPORTALS: Don't check through portals.
  • NO3DFLOORS: Ignore all 3D floors.
Why?

As it stands, I have in one of my projects a VERY unwieldy system that calls A_Warp to move an actor towards a location, grab the floorz, and head back to the origin. After a while, mounting the A_Warp calls slowly becomes a BIT expensive when relying on multiple actors to get the job done.

Cutting out the need to move at all can enhance this performance by removing the unneeded overhead. So I came up with this. It's basically GetSectorFloor/CeilingZ for DECORATE, but better and enhanced with the same genious relativity of A_SpawnItemEx.

A test sample:

Code: Select all

Actor Da
{
	+NOINTERACTION
	States
	{
	Spawn:
		TNT1 A 35 NoDelay
		{
			A_Log("My FloorZ Is");
			A_Warp(AAPTR_PLAYER1,x,y,z,0,WARPF_NOCHECKPOSITION|WARPF_ABSOLUTEPOSITION,"Null");
			A_LogFloat(FloorZ);
			A_LogFloat(GetZAt(0,0));
			A_Log("50 Units From Me Is");
			A_LogFloat(GetZAt(50,0));
			
		}
		Stop
	}
}

Top