@RayTest.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /******************************************************************************/
  2. /******************************************************************************/
  3. class RayTest // first all areas are added, then they are sorted depending on distance to camera, to test closer objects first
  4. {
  5. class Area
  6. {
  7. ::Area *area;
  8. int dist;
  9. Area(::Area &area, int dist);
  10. public:
  11. Area();
  12. };
  13. static int Compare(C Area &a, C Area &b);
  14. bool hit, on_heightmap, heightmaps, objects;
  15. flt frac;
  16. VecI2 center;
  17. Vec from, move;
  18. Obj *obj;
  19. SyncLock lock;
  20. Memc<Area> areas; // areas to process
  21. Memc<Obj*> objs2D; // 2d objects
  22. void clear();
  23. void init(C VecI2 &center, C Vec &from, C Vec &move, bool heightmaps, bool objects);
  24. static void ListAreas(Cell< ::Area> &cell, RayTest &ray_test); // add areas sorted by distance to center
  25. static void Test( Area &area, RayTest &rt, int thread_index);
  26. void test(::Area &area); // !! this function should be multi-threaded safe !!
  27. bool test()C;
  28. bool possibleHit(flt frac)C;
  29. void setHit(flt frac, bool heightmap, Obj*obj);
  30. void add2DObj(Obj *obj);
  31. bool process();
  32. public:
  33. RayTest();
  34. };
  35. /******************************************************************************/
  36. /******************************************************************************/
  37. /******************************************************************************/