OctreeQuery.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #include "../Precompiled.h"
  4. #include "../Graphics/OctreeQuery.h"
  5. #include "../DebugNew.h"
  6. namespace Urho3D
  7. {
  8. Intersection PointOctreeQuery::TestOctant(const BoundingBox& box, bool inside)
  9. {
  10. if (inside)
  11. return INSIDE;
  12. else
  13. return box.IsInside(point_);
  14. }
  15. void PointOctreeQuery::TestDrawables(Drawable** start, Drawable** end, bool inside)
  16. {
  17. while (start != end)
  18. {
  19. Drawable* drawable = *start++;
  20. if (!!(drawable->GetDrawableType() & drawableTypes_) && (drawable->GetViewMask() & viewMask_))
  21. {
  22. if (inside || drawable->GetWorldBoundingBox().IsInside(point_))
  23. result_.Push(drawable);
  24. }
  25. }
  26. }
  27. Intersection SphereOctreeQuery::TestOctant(const BoundingBox& box, bool inside)
  28. {
  29. if (inside)
  30. return INSIDE;
  31. else
  32. return sphere_.IsInside(box);
  33. }
  34. void SphereOctreeQuery::TestDrawables(Drawable** start, Drawable** end, bool inside)
  35. {
  36. while (start != end)
  37. {
  38. Drawable* drawable = *start++;
  39. if (!!(drawable->GetDrawableType() & drawableTypes_) && (drawable->GetViewMask() & viewMask_))
  40. {
  41. if (inside || sphere_.IsInsideFast(drawable->GetWorldBoundingBox()))
  42. result_.Push(drawable);
  43. }
  44. }
  45. }
  46. Intersection BoxOctreeQuery::TestOctant(const BoundingBox& box, bool inside)
  47. {
  48. if (inside)
  49. return INSIDE;
  50. else
  51. return box_.IsInside(box);
  52. }
  53. void BoxOctreeQuery::TestDrawables(Drawable** start, Drawable** end, bool inside)
  54. {
  55. while (start != end)
  56. {
  57. Drawable* drawable = *start++;
  58. if (!!(drawable->GetDrawableType() & drawableTypes_) && (drawable->GetViewMask() & viewMask_))
  59. {
  60. if (inside || box_.IsInsideFast(drawable->GetWorldBoundingBox()))
  61. result_.Push(drawable);
  62. }
  63. }
  64. }
  65. Intersection FrustumOctreeQuery::TestOctant(const BoundingBox& box, bool inside)
  66. {
  67. if (inside)
  68. return INSIDE;
  69. else
  70. return frustum_.IsInside(box);
  71. }
  72. void FrustumOctreeQuery::TestDrawables(Drawable** start, Drawable** end, bool inside)
  73. {
  74. while (start != end)
  75. {
  76. Drawable* drawable = *start++;
  77. if (!!(drawable->GetDrawableType() & drawableTypes_) && (drawable->GetViewMask() & viewMask_))
  78. {
  79. if (inside || frustum_.IsInsideFast(drawable->GetWorldBoundingBox()))
  80. result_.Push(drawable);
  81. }
  82. }
  83. }
  84. Intersection AllContentOctreeQuery::TestOctant(const BoundingBox& box, bool inside)
  85. {
  86. return INSIDE;
  87. }
  88. void AllContentOctreeQuery::TestDrawables(Drawable** start, Drawable** end, bool inside)
  89. {
  90. while (start != end)
  91. {
  92. Drawable* drawable = *start++;
  93. if (!!(drawable->GetDrawableType() & drawableTypes_) && (drawable->GetViewMask() & viewMask_))
  94. result_.Push(drawable);
  95. }
  96. }
  97. }