Advertisement
spiritovod

W component

Jul 30th, 2022
888
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.16 KB | None | 0 0
  1.     FPackedNormal& operator=(const uint16& InData)
  2.     {
  3.         auto x = (byte)(InData & 0xFF);
  4.         auto y = (byte)((InData >> 8) & 0xFF);
  5.  
  6.         //ugly af, copied the vertex shader glsl code, didnt bother with W component
  7.         FVector2D v27; // = v30;
  8.         float f29;
  9.         v27.X = x;
  10.         v27.Y = y;
  11.         if (((int)(x + 0.5f)) > 127 && ((int)(y + 0.5f)) > 127)
  12.         {
  13.             v27.X = (v27.X + -128.0f) / 127.0f;
  14.             v27.Y = (v27.Y + -128.0f) / 127.0f;
  15.             f29 = -1.0f;
  16.         }
  17.         else
  18.         {
  19.             v27.X /= 127.0f;
  20.             v27.Y /= 127.0f;
  21.             f29 = 1.0f;
  22.         }
  23.         FVector2D v31;
  24.         v31.X = (v27.X * 2) + -1.0f;
  25.         v31.Y = (v27.Y * 2) + -1.0f;
  26.         FVector v32;
  27.         v32.Set(v31.X, v31.Y, 1.0f + -(1.0f * fabsf(v31.X) + 1.0f * fabsf(v31.Y)));
  28.         FVector v28 = v32;
  29.         if (v32.Z < 0.0f)
  30.         {
  31.             FVector2D v33;
  32.             v33.X = fabsf(v32.Y);
  33.             v33.Y = fabsf(v32.X);
  34.             FVector2D v34;
  35.             v34.X = v32.X >= 0.0f ? 1.0f : -1.0f;
  36.             v34.Y = v32.Y >= 0.0f ? 1.0f : -1.0f;
  37.             v28.X = (1.0f + -v33.X) * v34.X;
  38.             v28.Y = (1.0f + -v33.Y) * v34.Y;
  39.         }
  40.         CVec3 v35 = (CVec3&)v28;
  41.         v35.Normalize();
  42.         v28 = (FVector&)v35;
  43.         FVector4 v36;
  44.         v36.X = v28.X;
  45.         v36.Y = v28.Y;
  46.         v36.Z = v28.Z;
  47.         v36.W = f29;
  48.         return *this = v36;
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement