BoundingBox.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef BOUNDINGBOX_H
  2. #define BOUNDINGBOX_H
  3. #include "finders.h"
  4. #include <string>
  5. class BoundingBox {
  6. public:
  7. Pos start;
  8. Pos end;
  9. static BoundingBox getBoundingBox(int minx, int miny, int minz, int maxx, int maxy, int maxz) {
  10. BoundingBox box;
  11. box.start.x = minx;
  12. box.start.z = minz;
  13. box.end.x = maxx;
  14. box.end.z = maxz;
  15. return box;
  16. }
  17. std::string getStr() {
  18. return std::string("(") + std::to_string(start.x) + std::string(",") + std::string(",") + std::to_string(start.z) + std::string(")(") + std::to_string(end.x) + std::string(",") + std::to_string(end.z) + std::string(")");
  19. }
  20. bool intersectsWith(BoundingBox* box)
  21. {
  22. return this->end.x >= box->start.x && this->start.x <= box->end.x && this->end.z >= box->start.z && this->start.z <= box->end.z;
  23. }
  24. void setStart(int x, int z) {
  25. this->start.x = x;
  26. this->start.z = z;
  27. }
  28. void setEnd(int x, int z) {
  29. this->end.x = x;
  30. this->end.z = z;
  31. }
  32. void setAll(int x1, int y1, int z1, int x2, int y2, int z2) {
  33. setStart(x1, z1);
  34. setEnd(x2, z2);
  35. }
  36. static BoundingBox getComponentToAddBoundingBox(int p_78889_0_, int p_78889_1_, int p_78889_2_, int p_78889_3_, int p_78889_4_, int p_78889_5_, int p_78889_6_, int p_78889_7_, int p_78889_8_, int p_78889_9_)
  37. {
  38. BoundingBox ret;
  39. ret.setAll(-133769, -2, -1, 1, 2, 3);
  40. switch (p_78889_9_)
  41. {
  42. case 0:
  43. ret.setAll(p_78889_0_ + p_78889_3_, p_78889_1_ + p_78889_4_, p_78889_2_ + p_78889_5_, p_78889_0_ + p_78889_6_ - 1 + p_78889_3_, p_78889_1_ + p_78889_7_ - 1 + p_78889_4_, p_78889_2_ + p_78889_8_ - 1 + p_78889_5_);
  44. return ret;
  45. case 1:
  46. ret.setAll(p_78889_0_ - p_78889_8_ + 1 + p_78889_5_, p_78889_1_ + p_78889_4_, p_78889_2_ + p_78889_3_, p_78889_0_ + p_78889_5_, p_78889_1_ + p_78889_7_ - 1 + p_78889_4_, p_78889_2_ + p_78889_6_ - 1 + p_78889_3_);
  47. return ret;
  48. case 2:
  49. ret.setAll(p_78889_0_ + p_78889_3_, p_78889_1_ + p_78889_4_, p_78889_2_ - p_78889_8_ + 1 + p_78889_5_, p_78889_0_ + p_78889_6_ - 1 + p_78889_3_, p_78889_1_ + p_78889_7_ - 1 + p_78889_4_, p_78889_2_ + p_78889_5_);
  50. return ret;
  51. case 3:
  52. ret.setAll(p_78889_0_ + p_78889_5_, p_78889_1_ + p_78889_4_, p_78889_2_ + p_78889_3_, p_78889_0_ + p_78889_8_ - 1 + p_78889_5_, p_78889_1_ + p_78889_7_ - 1 + p_78889_4_, p_78889_2_ + p_78889_6_ - 1 + p_78889_3_);
  53. return ret;
  54. default:
  55. return ret;
  56. }
  57. }
  58. };
  59. #endif