AABB.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="AABB" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. A 3D axis-aligned bounding box.
  5. </brief_description>
  6. <description>
  7. [AABB] consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.
  8. It uses floating-point coordinates. The 2D counterpart to [AABB] is [Rect2].
  9. Negative values for [member size] are not supported and will not work for most methods. Use [method abs] to get an AABB with a positive size.
  10. [b]Note:[/b] Unlike [Rect2], [AABB] does not have a variant that uses integer coordinates.
  11. </description>
  12. <tutorials>
  13. <link title="Math documentation index">$DOCS_URL/tutorials/math/index.html</link>
  14. <link title="Vector math">$DOCS_URL/tutorials/math/vector_math.html</link>
  15. <link title="Advanced vector math">$DOCS_URL/tutorials/math/vectors_advanced.html</link>
  16. </tutorials>
  17. <constructors>
  18. <constructor name="AABB">
  19. <return type="AABB" />
  20. <description>
  21. Constructs a default-initialized [AABB] with default (zero) values of [member position] and [member size].
  22. </description>
  23. </constructor>
  24. <constructor name="AABB">
  25. <return type="AABB" />
  26. <param index="0" name="from" type="AABB" />
  27. <description>
  28. Constructs an [AABB] as a copy of the given [AABB].
  29. </description>
  30. </constructor>
  31. <constructor name="AABB">
  32. <return type="AABB" />
  33. <param index="0" name="position" type="Vector3" />
  34. <param index="1" name="size" type="Vector3" />
  35. <description>
  36. Constructs an [AABB] from a position and size.
  37. </description>
  38. </constructor>
  39. </constructors>
  40. <methods>
  41. <method name="abs" qualifiers="const">
  42. <return type="AABB" />
  43. <description>
  44. Returns an AABB with equivalent position and size, modified so that the most-negative corner is the origin and the size is positive.
  45. </description>
  46. </method>
  47. <method name="encloses" qualifiers="const">
  48. <return type="bool" />
  49. <param index="0" name="with" type="AABB" />
  50. <description>
  51. Returns [code]true[/code] if this [AABB] completely encloses another one.
  52. </description>
  53. </method>
  54. <method name="expand" qualifiers="const">
  55. <return type="AABB" />
  56. <param index="0" name="to_point" type="Vector3" />
  57. <description>
  58. Returns a copy of this [AABB] expanded to include a given point.
  59. [b]Example:[/b]
  60. [codeblocks]
  61. [gdscript]
  62. # position (-3, 2, 0), size (1, 1, 1)
  63. var box = AABB(Vector3(-3, 2, 0), Vector3(1, 1, 1))
  64. # position (-3, -1, 0), size (3, 4, 2), so we fit both the original AABB and Vector3(0, -1, 2)
  65. var box2 = box.expand(Vector3(0, -1, 2))
  66. [/gdscript]
  67. [csharp]
  68. // position (-3, 2, 0), size (1, 1, 1)
  69. var box = new Aabb(new Vector3(-3, 2, 0), new Vector3(1, 1, 1));
  70. // position (-3, -1, 0), size (3, 4, 2), so we fit both the original AABB and Vector3(0, -1, 2)
  71. var box2 = box.Expand(new Vector3(0, -1, 2));
  72. [/csharp]
  73. [/codeblocks]
  74. </description>
  75. </method>
  76. <method name="get_center" qualifiers="const">
  77. <return type="Vector3" />
  78. <description>
  79. Returns the center of the [AABB], which is equal to [member position] + ([member size] / 2).
  80. </description>
  81. </method>
  82. <method name="get_endpoint" qualifiers="const">
  83. <return type="Vector3" />
  84. <param index="0" name="idx" type="int" />
  85. <description>
  86. Gets the position of the 8 endpoints of the [AABB] in space.
  87. </description>
  88. </method>
  89. <method name="get_longest_axis" qualifiers="const">
  90. <return type="Vector3" />
  91. <description>
  92. Returns the normalized longest axis of the [AABB].
  93. </description>
  94. </method>
  95. <method name="get_longest_axis_index" qualifiers="const">
  96. <return type="int" />
  97. <description>
  98. Returns the index of the longest axis of the [AABB] (according to [Vector3]'s [code]AXIS_*[/code] constants).
  99. </description>
  100. </method>
  101. <method name="get_longest_axis_size" qualifiers="const">
  102. <return type="float" />
  103. <description>
  104. Returns the scalar length of the longest axis of the [AABB].
  105. </description>
  106. </method>
  107. <method name="get_shortest_axis" qualifiers="const">
  108. <return type="Vector3" />
  109. <description>
  110. Returns the normalized shortest axis of the [AABB].
  111. </description>
  112. </method>
  113. <method name="get_shortest_axis_index" qualifiers="const">
  114. <return type="int" />
  115. <description>
  116. Returns the index of the shortest axis of the [AABB] (according to [Vector3]::AXIS* enum).
  117. </description>
  118. </method>
  119. <method name="get_shortest_axis_size" qualifiers="const">
  120. <return type="float" />
  121. <description>
  122. Returns the scalar length of the shortest axis of the [AABB].
  123. </description>
  124. </method>
  125. <method name="get_support" qualifiers="const">
  126. <return type="Vector3" />
  127. <param index="0" name="dir" type="Vector3" />
  128. <description>
  129. Returns the support point in a given direction. This is useful for collision detection algorithms.
  130. </description>
  131. </method>
  132. <method name="get_volume" qualifiers="const">
  133. <return type="float" />
  134. <description>
  135. Returns the volume of the [AABB].
  136. </description>
  137. </method>
  138. <method name="grow" qualifiers="const">
  139. <return type="AABB" />
  140. <param index="0" name="by" type="float" />
  141. <description>
  142. Returns a copy of the [AABB] grown a given number of units towards all the sides.
  143. </description>
  144. </method>
  145. <method name="has_point" qualifiers="const">
  146. <return type="bool" />
  147. <param index="0" name="point" type="Vector3" />
  148. <description>
  149. Returns [code]true[/code] if the [AABB] contains a point. Points on the faces of the AABB are considered included, though float-point precision errors may impact the accuracy of such checks.
  150. [b]Note:[/b] This method is not reliable for [AABB] with a [i]negative size[/i]. Use [method abs] to get a positive sized equivalent [AABB] to check for contained points.
  151. </description>
  152. </method>
  153. <method name="has_surface" qualifiers="const">
  154. <return type="bool" />
  155. <description>
  156. Returns [code]true[/code] if the [AABB] has a surface or a length, and [code]false[/code] if the [AABB] is empty (all components of [member size] are zero or negative).
  157. </description>
  158. </method>
  159. <method name="has_volume" qualifiers="const">
  160. <return type="bool" />
  161. <description>
  162. Returns [code]true[/code] if the [AABB] has a volume, and [code]false[/code] if the [AABB] is flat, empty, or has a negative [member size].
  163. </description>
  164. </method>
  165. <method name="intersection" qualifiers="const">
  166. <return type="AABB" />
  167. <param index="0" name="with" type="AABB" />
  168. <description>
  169. Returns the intersection between two [AABB]. An empty AABB (size [code](0, 0, 0)[/code]) is returned on failure.
  170. </description>
  171. </method>
  172. <method name="intersects" qualifiers="const">
  173. <return type="bool" />
  174. <param index="0" name="with" type="AABB" />
  175. <description>
  176. Returns [code]true[/code] if the [AABB] overlaps with another.
  177. </description>
  178. </method>
  179. <method name="intersects_plane" qualifiers="const">
  180. <return type="bool" />
  181. <param index="0" name="plane" type="Plane" />
  182. <description>
  183. Returns [code]true[/code] if the [AABB] is on both sides of a plane.
  184. </description>
  185. </method>
  186. <method name="intersects_ray" qualifiers="const">
  187. <return type="Variant" />
  188. <param index="0" name="from" type="Vector3" />
  189. <param index="1" name="dir" type="Vector3" />
  190. <description>
  191. Returns the point of intersection of the given ray with this [AABB] or [code]null[/code] if there is no intersection. Ray length is infinite.
  192. </description>
  193. </method>
  194. <method name="intersects_segment" qualifiers="const">
  195. <return type="Variant" />
  196. <param index="0" name="from" type="Vector3" />
  197. <param index="1" name="to" type="Vector3" />
  198. <description>
  199. Returns the point of intersection between [param from] and [param to] with this [AABB] or [code]null[/code] if there is no intersection.
  200. </description>
  201. </method>
  202. <method name="is_equal_approx" qualifiers="const">
  203. <return type="bool" />
  204. <param index="0" name="aabb" type="AABB" />
  205. <description>
  206. Returns [code]true[/code] if this [AABB] and [param aabb] are approximately equal, by calling [method @GlobalScope.is_equal_approx] on each component.
  207. </description>
  208. </method>
  209. <method name="is_finite" qualifiers="const">
  210. <return type="bool" />
  211. <description>
  212. Returns [code]true[/code] if this [AABB] is finite, by calling [method @GlobalScope.is_finite] on each component.
  213. </description>
  214. </method>
  215. <method name="merge" qualifiers="const">
  216. <return type="AABB" />
  217. <param index="0" name="with" type="AABB" />
  218. <description>
  219. Returns a larger [AABB] that contains both this [AABB] and [param with].
  220. </description>
  221. </method>
  222. </methods>
  223. <members>
  224. <member name="end" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)">
  225. Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size.
  226. </member>
  227. <member name="position" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)">
  228. Beginning corner. Typically has values lower than [member end].
  229. </member>
  230. <member name="size" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)">
  231. Size from [member position] to [member end]. Typically, all components are positive.
  232. If the size is negative, you can use [method abs] to fix it.
  233. </member>
  234. </members>
  235. <operators>
  236. <operator name="operator !=">
  237. <return type="bool" />
  238. <param index="0" name="right" type="AABB" />
  239. <description>
  240. Returns [code]true[/code] if the AABBs are not equal.
  241. [b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable.
  242. </description>
  243. </operator>
  244. <operator name="operator *">
  245. <return type="AABB" />
  246. <param index="0" name="right" type="Transform3D" />
  247. <description>
  248. Inversely transforms (multiplies) the [AABB] by the given [Transform3D] transformation matrix.
  249. </description>
  250. </operator>
  251. <operator name="operator ==">
  252. <return type="bool" />
  253. <param index="0" name="right" type="AABB" />
  254. <description>
  255. Returns [code]true[/code] if the AABBs are exactly equal.
  256. [b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable.
  257. </description>
  258. </operator>
  259. </operators>
  260. </class>