xolotl.h 1.3 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // Lol Engine - Xolotl algorithm test
  3. //
  4. // Copyright: (c) 2011 Soren Renner
  5. // (c) 2011 Sam Hocevar <sam@hocevar.net>
  6. // This program is free software; you can redistribute it and/or
  7. // modify it under the terms of the Do What The Fuck You Want To
  8. // Public License, Version 2, as published by Sam Hocevar. See
  9. // http://www.wtfpl.net/ for more details.
  10. //
  11. using namespace lol;
  12. struct Voxel
  13. {
  14. bool passable, lock, copymarker;
  15. struct Voxel *imposter;
  16. };
  17. struct MSV : public Voxel
  18. {
  19. };
  20. struct Ray
  21. {
  22. float theta, phi;
  23. vec3 origin, xyz, dxyz, ddxyz, lxyz, popdelta;
  24. struct Voxel *terminalvoxel;
  25. bool terminate;
  26. ivec3 counter;
  27. int scale;
  28. float length;
  29. bool di, dj, dk, changed, traced, far;
  30. int face;
  31. vec3 normal, bloxnorm, corner;
  32. int dtl;
  33. };
  34. template <int M> struct Cell : public MSV
  35. {
  36. Voxel blox[M * M * M];
  37. vec3 bloxnorm[M * M * M];
  38. int m;
  39. void Serp(Voxel v, Voxel w)
  40. {
  41. for (int i = 0; i < M; i++)
  42. for (int j = 0; j < M; j++)
  43. for (int k = 0; k < M; k++)
  44. if ((i == M_2) + (j == M_2) + (k == M_2) >= 2)
  45. blox[(i * M + j) * M + k] = v;
  46. else
  47. blox[(i * M + j) * M + k] = w;
  48. }
  49. static const int M_2 = M / 2;
  50. };