AABB.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. 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. [b]Note:[/b] Unlike [Rect2], [AABB] does not have a variant that uses integer coordinates.
  10. </description>
  11. <tutorials>
  12. <link title="Math tutorial index">$DOCS_URL/tutorials/math/index.html</link>
  13. <link title="Vector math">$DOCS_URL/tutorials/math/vector_math.html</link>
  14. <link title="Advanced vector math">$DOCS_URL/tutorials/math/vectors_advanced.html</link>
  15. </tutorials>
  16. <methods>
  17. <method name="AABB">
  18. <return type="AABB" />
  19. <argument index="0" name="position" type="Vector3" />
  20. <argument index="1" name="size" type="Vector3" />
  21. <description>
  22. Constructs an [AABB] from a position and size.
  23. </description>
  24. </method>
  25. <method name="abs">
  26. <return type="AABB" />
  27. <description>
  28. Returns an AABB with equivalent position and size, modified so that the most-negative corner is the origin and the size is positive.
  29. </description>
  30. </method>
  31. <method name="encloses">
  32. <return type="bool" />
  33. <argument index="0" name="with" type="AABB" />
  34. <description>
  35. Returns [code]true[/code] if this [AABB] completely encloses another one.
  36. </description>
  37. </method>
  38. <method name="expand">
  39. <return type="AABB" />
  40. <argument index="0" name="to_point" type="Vector3" />
  41. <description>
  42. Returns a copy of this [AABB] expanded to include a given point.
  43. [b]Example:[/b]
  44. [codeblock]
  45. # position (-3, 2, 0), size (1, 1, 1)
  46. var box = AABB(Vector3(-3, 2, 0), Vector3(1, 1, 1))
  47. # position (-3, -1, 0), size (3, 4, 2), so we fit both the original AABB and Vector3(0, -1, 2)
  48. var box2 = box.expand(Vector3(0, -1, 2))
  49. [/codeblock]
  50. </description>
  51. </method>
  52. <method name="get_area">
  53. <return type="float" />
  54. <description>
  55. Returns the volume of the [AABB].
  56. </description>
  57. </method>
  58. <method name="get_center">
  59. <return type="Vector3" />
  60. <description>
  61. Returns the center of the [AABB], which is equal to [member position] + ([member size] / 2).
  62. </description>
  63. </method>
  64. <method name="get_endpoint">
  65. <return type="Vector3" />
  66. <argument index="0" name="idx" type="int" />
  67. <description>
  68. Gets the position of the 8 endpoints of the [AABB] in space.
  69. </description>
  70. </method>
  71. <method name="get_longest_axis">
  72. <return type="Vector3" />
  73. <description>
  74. Returns the normalized longest axis of the [AABB].
  75. </description>
  76. </method>
  77. <method name="get_longest_axis_index">
  78. <return type="int" />
  79. <description>
  80. Returns the index of the longest axis of the [AABB] (according to [Vector3]'s [code]AXIS_*[/code] constants).
  81. </description>
  82. </method>
  83. <method name="get_longest_axis_size">
  84. <return type="float" />
  85. <description>
  86. Returns the scalar length of the longest axis of the [AABB].
  87. </description>
  88. </method>
  89. <method name="get_shortest_axis">
  90. <return type="Vector3" />
  91. <description>
  92. Returns the normalized shortest axis of the [AABB].
  93. </description>
  94. </method>
  95. <method name="get_shortest_axis_index">
  96. <return type="int" />
  97. <description>
  98. Returns the index of the shortest axis of the [AABB] (according to [Vector3]::AXIS* enum).
  99. </description>
  100. </method>
  101. <method name="get_shortest_axis_size">
  102. <return type="float" />
  103. <description>
  104. Returns the scalar length of the shortest axis of the [AABB].
  105. </description>
  106. </method>
  107. <method name="get_support">
  108. <return type="Vector3" />
  109. <argument index="0" name="dir" type="Vector3" />
  110. <description>
  111. Returns the support point in a given direction. This is useful for collision detection algorithms.
  112. </description>
  113. </method>
  114. <method name="grow">
  115. <return type="AABB" />
  116. <argument index="0" name="by" type="float" />
  117. <description>
  118. Returns a copy of the [AABB] grown a given amount of units towards all the sides.
  119. </description>
  120. </method>
  121. <method name="has_no_area">
  122. <return type="bool" />
  123. <description>
  124. Returns [code]true[/code] if the [AABB] is flat or empty.
  125. </description>
  126. </method>
  127. <method name="has_no_surface">
  128. <return type="bool" />
  129. <description>
  130. Returns [code]true[/code] if the [AABB] is empty.
  131. </description>
  132. </method>
  133. <method name="has_point">
  134. <return type="bool" />
  135. <argument index="0" name="point" type="Vector3" />
  136. <description>
  137. Returns [code]true[/code] if the [AABB] contains a point.
  138. </description>
  139. </method>
  140. <method name="intersection">
  141. <return type="AABB" />
  142. <argument index="0" name="with" type="AABB" />
  143. <description>
  144. Returns the intersection between two [AABB]. An empty AABB (size 0,0,0) is returned on failure.
  145. </description>
  146. </method>
  147. <method name="intersects">
  148. <return type="bool" />
  149. <argument index="0" name="with" type="AABB" />
  150. <description>
  151. Returns [code]true[/code] if the [AABB] overlaps with another.
  152. </description>
  153. </method>
  154. <method name="intersects_plane">
  155. <return type="bool" />
  156. <argument index="0" name="plane" type="Plane" />
  157. <description>
  158. Returns [code]true[/code] if the [AABB] is on both sides of a plane.
  159. </description>
  160. </method>
  161. <method name="intersects_segment">
  162. <return type="bool" />
  163. <argument index="0" name="from" type="Vector3" />
  164. <argument index="1" name="to" type="Vector3" />
  165. <description>
  166. Returns [code]true[/code] if the [AABB] intersects the line segment between [code]from[/code] and [code]to[/code].
  167. </description>
  168. </method>
  169. <method name="is_equal_approx">
  170. <return type="bool" />
  171. <argument index="0" name="aabb" type="AABB" />
  172. <description>
  173. Returns [code]true[/code] if this [AABB] and [code]aabb[/code] are approximately equal, by calling [method @GDScript.is_equal_approx] on each component.
  174. </description>
  175. </method>
  176. <method name="merge">
  177. <return type="AABB" />
  178. <argument index="0" name="with" type="AABB" />
  179. <description>
  180. Returns a larger [AABB] that contains both this [AABB] and [code]with[/code].
  181. </description>
  182. </method>
  183. </methods>
  184. <members>
  185. <member name="end" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )">
  186. Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size.
  187. </member>
  188. <member name="position" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )">
  189. Beginning corner. Typically has values lower than [member end].
  190. </member>
  191. <member name="size" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )">
  192. Size from [member position] to [member end]. Typically, all components are positive.
  193. If the size is negative, you can use [method abs] to fix it.
  194. </member>
  195. </members>
  196. <constants>
  197. </constants>
  198. </class>