Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Switching to nipple_03_vdm resets some values

A very minor issue - when switching to nipple_03_vdm shape while you have any other nipple equipped, the NormalRadius and NormalFadeFactor values get set to 0.

Comments

  • odesodes Administrator
    Great find, thanks for pointing that out!
  • odesodes Administrator
    edited February 6
    Ok, so this is problem I've been seeing popping up from time to time. Not only in our own code, but also in 3rd party libraries.

    C# does something that no other language does, as far as I know. When converting a string to a float, most languages offer some method for accomplishing this. In C#, you can do this with either float.Parse or Convert.ToSingle. Now, if you pass a string, let's say "0.1" to such a string-to-float conversion function, you'd expect it to return 0.1 as a float, right? Wrong! Well, it does work for the most part, but not on all platforms. As it turns out, float conversion in C# is platform specific. You have to strictly tell it to convert from a specific format. If none is specified, it assumes the string is formatted in the systems default format. So that means if you pass "0.1" on a platform that expects "0,1" (comma), you won't get the right number back!

    It's a very tricky thing, because on my system this works as expected (I'm using English), but for others it might not.

    No other language I've worked with works in this way, and indeed many other developers seem unaware of this as well. Almost every single 3rd party library we're using has had this "bug" in them.

    Wrong way of converting string to float in C#:
    f = float.Parse(str);

    Right way:
    f = float.Parse(str, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture);


    Anyway, hopefully this bug should be fixed.


    edit:

    lol, I might add what this has to do with the sliders resetting for nipple_03_vdm:

    There's a file with stored values (a json file) that the sliders are supposed to be set to when switching to certain vdm maps. There is such an entry for nipple_03_vdm. The problem is that since this is a text file, floats need to be converted from string to float. But this conversion in the 3rd party json parser we've been using had this bug in it (that it assumes "0.1" gets converted to 0.1, for example). This has now been fixed.

Sign In or Register to comment.