5 registered members (Petra, AndrewAMD, VoroneTZ, 2 invisible),
822
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
fixed vs. fixv
#416207
01/29/13 03:47
01/29/13 03:47
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
OP
Expert
|
OP
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Hello Mr. Lotter, I guess the manual page concerning fixed(float) isn't correct. http://www.conitec.net/beta/afixed.htmThe functions name should be "fixv", not "fixed", right? At least that's what the example on that page suggests and what actually compiles. Using "fixed" results in an compile time error. The type of the parameter should also be float, not var.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: fixed vs. fixv
[Re: jcl]
#416237
01/29/13 16:25
01/29/13 16:25
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
OP
Expert
|
OP
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
I can only speak for myself here, but for me the changes you did have not made the description any clearer. Especially the term "'real' var" might confuse beginners even more. In the end it comes down to a format conversion from the IEEE floating point format to the fixed format gamestudio uses, right? Maybe you could cure my curiosity and explain how this monstrum works: Casting the address of the var to float* and dereferencing it again does not make sense on a first glance to me. ^^ I had expected something like
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: fixed vs. fixv
[Re: jcl]
#416251
01/29/13 18:50
01/29/13 18:50
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
OP
Expert
|
OP
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
This explanation is perfectly fine for me. So, more precisely it is not a conversion that takes place but instead a hint to the compiler concerning the actual number representation format the number is encoded in, isn't it?
The scenario in water.c corresponds exactly to my use case with the exception that I use material skills instead of entity skills.
Thanks for taking the time to explain. Your patience is highly appreciated.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: fixed vs. fixv
[Re: Uhrwerk]
#416264
01/29/13 20:27
01/29/13 20:27
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
This explanation is perfectly fine for me. So, more precisely it is not a conversion that takes place but instead a hint to the compiler concerning the actual number representation format the number is encoded in, isn't it? Correct, that's why a simple cast ala ((float)x) won't work here, because then the compiler would attempt to convert the variable into a float, which it already is. By taking the address of the variable and casting it to a float pointer, no conversion is done, and dereferencing a float pointer won't do any conversion either. imho this is pretty dirty since it actively tries to "outsmart" the compilers typesystem. Wouldn't it be better to make at least the material skills float by default and then use an implicit type cast? (As far as I can see, they are expected to be float anyways) That explanation is probably not much better It should be noted that there is no actual conversion happening (with the exception being var -> float), but instead that the functions are used to force a float into a var without any implicit conversion that would occur if one would just type 'x = y'
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: fixed vs. fixv
[Re: MasterQ32]
#416396
01/30/13 23:32
01/30/13 23:32
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
You will since the invocation of fixv() and floatv() isn't guaranteed to be exclusive for material skills.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: fixed vs. fixv
[Re: WretchedSid]
#416397
01/31/13 00:23
01/31/13 00:23
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
OP
Expert
|
OP
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
@JustSid: Thanks, your posts are always helpful. @MasterQ32: I don't think that this is a good suggestion. Tons of code might break with this change. Apart from that: there is no need to change. The discussion we're doing here is very interesting for me. But you don't need to understand a word of what's being written here in order to successfully apply the concept. @jcl: In the end it can be brought down to: Use floatv when you want to pass something to a shader, use fixv for the inverse operation. I'm the living proof for that as I applied the technique correctly without even knowing fixv was a macro and how it worked. I guess this is even the most important message for the manual page. I don't know if the background information about memory space and casting is really required there. If however you want to include advanced info the JustSid is absolutely right with: It should be noted that there is no actual conversion happening (with the exception being var -> float), but instead that the functions are used to force a float into a var without any implicit conversion that would occur if one would just type 'x = y' The example provided on the manual page does not do a good job from my point of view. Just showing the inverse function does not make the purpose or the usage of the function any clearer. It's quite the opposite for. When there are two functions and one reverses the other you might expect that both of them do a conversion.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|