Export level.info->pixelstretch to ZScript

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: Export level.info->pixelstretch to ZScript

Re: Export level.info->pixelstretch to ZScript

by _mental_ » Fri Dec 29, 2017 1:51 am

I re-exposed pixel stretch as member variable in 996bddd.

If somebody wants to get rid of FLevelLocals and export level_info_t directly then he/she is welcome.
Until that moment let's keep existing interface consistent.

Re: Export level.info->pixelstretch to ZScript

by Rachael » Thu Dec 28, 2017 11:57 am

@Major Cooke: That was strictly in context of converting from Fixed point to doubles. Remember that bug with the model interpolation where all the models suddenly got real janky?

That was because the "float" structure was being overflowed. The same thing will happen with certain ACS-to-ZScript calculations.

From what I understand "double" is better on performance anyway so I tend to avoid using "float" at all, but if "float" is needed (such as passing uniforms to shaders in the GL renderer) they should be fine, depending on how they're used. (Float can only gracefully handle smaller numbers without precision loss)

Re: Export level.info->pixelstretch to ZScript

by _mental_ » Thu Dec 28, 2017 11:12 am

Most of game engine uses floats for everything. Some can be customized to use doubles.
But it’s very common to pack 3 or 4 floats into one 128-bit SIMD type. Quaternion is the same as 4 component vector, matrix uses 3 or 4 such vectors, etc.
Doubles double memory requirements for such data and performance is often worse than with floats. The latter point is quite hardware dependent though.

Re: Export level.info->pixelstretch to ZScript

by Major Cooke » Thu Dec 28, 2017 10:51 am

I forgot that it actually deals with the renderer itself and all of those utilize floats heavily.

Re: Export level.info->pixelstretch to ZScript

by _mental_ » Thu Dec 28, 2017 10:30 am

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.

Re: Export level.info->pixelstretch to ZScript

by Major Cooke » Thu Dec 28, 2017 10:15 am

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.

Re: Export level.info->pixelstretch to ZScript

by _mental_ » Thu Dec 28, 2017 10:04 am

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.

Re: Export level.info->pixelstretch to ZScript

by Major Cooke » Thu Dec 28, 2017 9:33 am

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?

Re: Export level.info->pixelstretch to ZScript

by _mental_ » Thu Dec 28, 2017 9:22 am

I thought that the mentioned commit is self-explanatory. You had to search similar members in code, outsidefogdensity for example, and do the same.

Re: Export level.info->pixelstretch to ZScript

by Major Cooke » Thu Dec 28, 2017 9:09 am

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

Re: Export level.info->pixelstretch to ZScript

by _mental_ » Thu Dec 28, 2017 8:57 am

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.

Re: Export level.info->pixelstretch to ZScript

by Leonard2 » Thu Dec 28, 2017 8:43 am

I still think the info type should be exported, anything else would just be a temporary kludge anyways.

Re: Export level.info->pixelstretch to ZScript

by Nash » Thu Dec 28, 2017 8:26 am

Mental's implementation looks better, IMO (no offense to Cooke!)

Re: Export level.info->pixelstretch to ZScript

by _mental_ » Thu Dec 28, 2017 5:39 am

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.

Re: Export level.info->pixelstretch to ZScript

by Gutawer » Thu Dec 28, 2017 5:13 am

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.

Top