Export level.info->pixelstretch to ZScript

Moderator: GZDoom Developers

User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Export level.info->pixelstretch to ZScript

Post by Gutawer »

As the title says, I need this exported to ZScript so that I can finish off a HUDMessageOnActor-like function (for ZScript) using a perspective projection matrix. It's working mostly perfectly, but I need it to react to the pixel ratio dynamically and right now I don't think that's exported. A LevelLocals.pixelstretch field would be nice for this.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: Export level.info->pixelstretch to ZScript

Post by Major Cooke »

_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Export level.info->pixelstretch to ZScript

Post by _mental_ »

One question: why was it done with a function while others are fields a.k.a. member variables?
User avatar
Leonard2
Posts: 313
Joined: Tue Aug 14, 2012 6:10 pm

Re: Export level.info->pixelstretch to ZScript

Post by Leonard2 »

I wondered this too and here's a comment from base.txt:

Code: Select all

// level_info_t *info cannot be done yet.
Perhaps now is a good time to export this type.
On top of this, the function returns information from level.info rather than from the info given by the instance itself, was that intended?
User avatar
Gutawer
Posts: 469
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: Export level.info->pixelstretch to ZScript

Post by Gutawer »

I originally wanted this as a member variable on the ZScript LevelLocals struct, but since info wasn't exported, I wasn't sure how that could be done. I'm happy with using it as a function, though it taking from level.info is probably a problem, yeah. If info could be exported, that'd be cool too - whatever works.
_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Export level.info->pixelstretch to ZScript

Post by _mental_ »

This should be done in a uniform way with other members.
Read-only field is more than enough here. Function is needed to do a lazy evaluation or calculate the value on the fly.
User avatar
Nash
 
 
Posts: 17492
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Export level.info->pixelstretch to ZScript

Post by Nash »

Mental's implementation looks better, IMO (no offense to Cooke!)
User avatar
Leonard2
Posts: 313
Joined: Tue Aug 14, 2012 6:10 pm

Re: Export level.info->pixelstretch to ZScript

Post by Leonard2 »

I still think the info type should be exported, anything else would just be a temporary kludge anyways.
_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Export level.info->pixelstretch to ZScript

Post by _mental_ »

Leonard2 wrote:I still think the info type should be exported, anything else would just be a temporary kludge anyways.
Sure, please do it if you have ability to implement and test it.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: Export level.info->pixelstretch to ZScript

Post by Major Cooke »

I had no idea on how to do it that way instead of a function, honestly. By all means, do show how it's done. I'd love to learn how. :D
_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Export level.info->pixelstretch to ZScript

Post by _mental_ »

I thought that the mentioned commit is self-explanatory. You had to search similar members in code, outsidefogdensity for example, and do the same.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: Export level.info->pixelstretch to ZScript

Post by Major Cooke »

I didn't see you expose that until now.
Also I saw this and I thought that to be true.

Also also, that float in zscript should be a double, right?
_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Export level.info->pixelstretch to ZScript

Post by _mental_ »

Major Cooke wrote:Also also, that float in zscript should be a double, right?
No, C++ float and double both are fine to be exported as native member variables with ZScript's float type.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: Export level.info->pixelstretch to ZScript

Post by Major Cooke »

Hmm... Well, I mainly say that because Rachael says don't use floats for zscript.
Rachael wrote:Remember to use doubles (I think ZScript supports them, right?) to store the final values. As you no doubt know, fractionals in ACS are fixed precision and are simply (xxxx.xxxx * 65536) when stored as its final value.

Don't use float because you will lose some precision. Floats can no doubt store the value, yes, but they do a terrible job of it.
EDIT: Added link to where I quoted her from.
_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Export level.info->pixelstretch to ZScript

Post by _mental_ »

And how is this applicable to our topic? You need more than 6 significant digits for pixelstretch, right? I think two or three "ought to be enough for anybody".
Although if you plan to do lots of calculations with values of various range then it makes sense. But not if you are about to store one read-only value then it's not.
Generic suggestion like "do not use floats, use doubles" is the same as suggestions to "do not use 32-bit integers as they overflow quicker than 64-bit". Out of context this is plainly ridiculous.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”