fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using UnityEngine;
  6. using UltraTerrain.Common.Morton;
  7.  
  8. namespace UltraTerrain.Common.Morton
  9. {
  10. public static class Arithmetic
  11. {
  12. public const uint FullMask = 0xFFFFFFFF;
  13. public static uint SignMask = "10.000.000.000.000.000.000.000.000.000.000".FromBinary();// 0x80000000;
  14. public static uint XMask = "01.001.001.001.001.001.001.001.001.001.001".FromBinary(); //0x9249249;
  15. public static uint YMask = "10.010.010.010.010.010.010.010.010.010.010".FromBinary(); //0x12492492;
  16. public static uint ZMask = "00.100.100.100.100.100.100.100.100.100.100".FromBinary(); //0x24924924;
  17.  
  18. public static uint XMaskWithSign = XMask | SignMask;
  19. public static uint YMaskWithSign = YMask | SignMask;
  20. public static uint ZMaskWithSign = ZMask | SignMask;
  21.  
  22. public static uint AddMorton(this uint a, uint b)
  23. {
  24. var cx = ((a | ~XMask) + (b & XMask)) & XMask;
  25. var cy = ((a | ~YMask) + (b & YMask)) & YMask;
  26. var cz = ((a | ~ZMask) + (b & ZMask)) & ZMask;
  27.  
  28. var c = cx | cy | cz;
  29. return c;
  30. }
  31.  
  32. public static uint SubtractMorton(this uint a, uint b)
  33. {
  34. var cx = ((a & XMaskWithSign) - (b & XMask)) & XMaskWithSign;
  35. var cy = ((a & YMaskWithSign) - (b & YMask)) & YMaskWithSign;
  36. var cz = ((a & ZMaskWithSign) - (b & ZMask)) & ZMaskWithSign;
  37.  
  38. var c = cx | cy | cz;
  39. return c;
  40. }
  41. }
  42. }
  43.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(5,7): error CS0246: The type or namespace name `UnityEngine' could not be found. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty