Expose IsZero()

Moderator: GZDoom Developers

Post Reply
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Expose IsZero()

Post by Major Cooke »

Because

Code: Select all

if (!vel.IsZero() && Limbs.Size() > 0)
produces

Code: Select all

Script error, "PSB.pk3:zs/player/playerfunc.txt" line 120:
Unknown function IsZero
User avatar
AFADoomer
Posts: 1324
Joined: Tue Jul 15, 2003 4:18 pm
Contact:

Re: Expose IsZero()

Post by AFADoomer »

I haven't looked at the code, but, functionally, what's the difference between using !vel.IsZero() and vel.length() here?
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Expose IsZero()

Post by Major Cooke »

Performs an unnecessary square root.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Expose IsZero()

Post by Graf Zahl »

vel == (0,0,0) will do the job just fine.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Expose IsZero()

Post by Matt »

why does IsZero() exist anyway?
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Expose IsZero()

Post by _mental_ »

Just compare cost of inlined C++ function with cost of calling ZScript one in VM. In C++ the cost is zero but it's not in ZScript.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Expose IsZero()

Post by Graf Zahl »

In C++ there are no vector literals so this function was more convenient.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”