Question about Mmo.Vector

Options
void.pointer
edited August 2010 in Photon Server
So I'm a bit confused about Mmo.Vector. At first glance, it looks like it tries to treat floats as fixed point (although it doesn't seem to model it properly), since floats are not portable. The documentation states at various points in the Vector.cs metadata that each component in Vector is multiplied/divided by 100, this is one of the most confusing things.

If the ultimate goal of Vector was to make serialization of floats more accurate and portable, then why does the Mmo server demo use float arrays in its operation properties instead of Mmo.Vector? What is the actual purpose of the Mmo.Vector class? I would prefer not to use the class based on what I've seen so far, however most of the Mmo classes require its usage.

Comments

  • Boris
    Options
    The problem about floats is that once you calculate with them the result is often "wrong".
    For instance: add 400 times 0.05f and I would be surprised if the sum of each step is what you expect.. sometimes it's a bit off, for instance 3.999998f instead of 4.
    The server uses the positions to calculate which regions to un-/subscribe, but when using floats the numbers are often not what you expect and thus wrong regions are subscribed. I had major issues with that when testing the whole thing.. to make sure everything works as expected we had to convert the floats to integers. The operation and event parameter are still float because they are easier to use on unity clients.
    True, it's a bit unpleasant that the values you submit to the server are not exactly what is forwarded to the others...
    It's probably best we change it so that the Vector contains the original floats as well.
  • To me, the best solution for this is to make it transparent. Make a Vector class for the client as well, if possible. Have it perform the logic necessary to convert between your special integer values. That way there is no question as to what I need to use. I could use Vector exclusively at that point and just have it work as expected.

    Another thing as well, it would be great to see Vector have more features. If it's going to be the long-term solution to floating point inaccuracy, it should have operations like Normalize, Magnitude, dot product, cross product, etc. Without these it's going to be a rather useless class. As of right now I could wrap Vector with my own, so it's not such a big deal in the short-term.
  • zoultrex
    Options
    Another thing as well, it would be great to see Vector have more features. If it's going to be the long-term solution to floating point inaccuracy, it should have operations like Normalize, Magnitude, dot product, cross product, etc. Without these it's going to be a rather useless class. As of right now I could wrap Vector with my own, so it's not such a big deal in the short-term.
    Void as I am no expert in game development, rather I have just made a few casual games in 2d, I am now studying math for 3d games, and man what a pain. Bad time to have slept on trigonometry classes at school :roll:

    I see that the vector class on the server doesnt have many functions, I found this sharp set of math classes that may help:
    http://sharp3d.codeplex.com/releases/view/121

    What I am trying to do exactly now is just a simple movement forward based on the rotation that the object is but on the server side, I have even posted that here on the forums already, i think that this csharp class may be helpful at some point. If anyone download it and check it please let me know if its useful as I think I could use that but im unsure as I have no previous knowledge of 3d math for games.
  • Boris
    Options
    update on this:
    the new mmo package allows you to use your own coordinates.
    the vectors are just used for interest management calculations.